From e1ed292a9194db55dae5b821a77930a31a723ffb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Thu, 30 Sep 2021 21:57:55 +0200 Subject: [PATCH 01/93] Convert emit(signal()) calls to emit signal() --- YACReader/bookmarks_dialog.cpp | 4 ++-- YACReader/goto_dialog.cpp | 2 +- YACReader/goto_flow_toolbar.cpp | 4 ++-- YACReader/options_dialog.cpp | 6 +++--- YACReader/translator.cpp | 12 ++++++------ YACReader/viewer.cpp | 10 +++++----- common/comic.cpp | 6 +++--- custom_widgets/yacreader_options_dialog.cpp | 2 +- 8 files changed, 23 insertions(+), 23 deletions(-) diff --git a/YACReader/bookmarks_dialog.cpp b/YACReader/bookmarks_dialog.cpp index aebfd574..ec843e87 100644 --- a/YACReader/bookmarks_dialog.cpp +++ b/YACReader/bookmarks_dialog.cpp @@ -133,7 +133,7 @@ bool BookmarksDialog::eventFilter(QObject *obj, QEvent *event) { if (event->type() == QEvent::MouseButtonPress) { if (obj == images.at(0)) { - emit(goToPage(lastPage)); + emit goToPage(lastPage); close(); event->accept(); } @@ -142,7 +142,7 @@ bool BookmarksDialog::eventFilter(QObject *obj, QEvent *event) bool b; int page = pages.at(i)->text().toInt(&b) - 1; if (b) { - emit(goToPage(page)); + emit goToPage(page); close(); } event->accept(); diff --git a/YACReader/goto_dialog.cpp b/YACReader/goto_dialog.cpp index 749dd17a..ea783fb7 100644 --- a/YACReader/goto_dialog.cpp +++ b/YACReader/goto_dialog.cpp @@ -61,7 +61,7 @@ void GoToDialog::goTo() { unsigned int page = pageNumber->text().toInt(); if (page >= 1 && page <= v->top()) { - emit(goToPage(page - 1)); + emit goToPage(page - 1); close(); } } diff --git a/YACReader/goto_flow_toolbar.cpp b/YACReader/goto_flow_toolbar.cpp index 183f7dc9..cc7bec73 100644 --- a/YACReader/goto_flow_toolbar.cpp +++ b/YACReader/goto_flow_toolbar.cpp @@ -112,14 +112,14 @@ void GoToFlowToolBar::goTo() { unsigned int page = edit->text().toInt(); if (page >= 1 && page <= v->top()) { - emit(goToPage(page - 1)); + emit goToPage(page - 1); } } void GoToFlowToolBar::centerSlide() { if (edit->text().toInt() != 0) - emit(setCenter(edit->text().toInt() - 1)); + emit setCenter(edit->text().toInt() - 1); } void GoToFlowToolBar::updateOptions() diff --git a/YACReader/options_dialog.cpp b/YACReader/options_dialog.cpp index 8ba99c40..16f06509 100644 --- a/YACReader/options_dialog.cpp +++ b/YACReader/options_dialog.cpp @@ -140,7 +140,7 @@ OptionsDialog::OptionsDialog(QWidget *parent) connect(scaleCheckbox, &QCheckBox::clicked, [=](bool checked) { Configuration::getConfiguration().setEnlargeImages(checked); - emit(changedImageOptions()); + emit changedImageOptions(); }); scaleLayout->addWidget(scaleCheckbox); @@ -153,7 +153,7 @@ OptionsDialog::OptionsDialog(QWidget *parent) connect(coverSPCheckBox, &QCheckBox::clicked, [=](bool checked) { settings->setValue(COVER_IS_SP, checked); - emit(changedImageOptions()); + emit changedImageOptions(); }); doublePageBoxLayout->addWidget(coverSPCheckBox); @@ -262,7 +262,7 @@ void OptionsDialog::updateColor(const QColor &color) settings->setValue(BACKGROUND_COLOR, color); - emit(changedOptions()); + emit changedOptions(); } void OptionsDialog::brightnessChanged(int value) diff --git a/YACReader/translator.cpp b/YACReader/translator.cpp index f35ddfc0..53217400 100644 --- a/YACReader/translator.cpp +++ b/YACReader/translator.cpp @@ -368,11 +368,11 @@ void TranslationLoader::run() utf8 = utf8.remove(utf8.count() - 1, 1); QString translated(utf8); - emit(requestFinished(translated)); + emit requestFinished(translated); } else - emit(error()); + emit error(); } else { - emit(timeOut()); + emit timeOut(); } } @@ -411,10 +411,10 @@ void TextToSpeachLoader::run() utf8 = utf8.remove(utf8.count() - 1, 1); utf8 = utf8.replace("\\", ""); - emit(requestFinished(QUrl(utf8))); + emit requestFinished(QUrl(utf8)); } else - emit(error()); + emit error(); } else { - emit(timeOut()); + emit timeOut(); } } diff --git a/YACReader/viewer.cpp b/YACReader/viewer.cpp index 8e4a743e..20a35764 100644 --- a/YACReader/viewer.cpp +++ b/YACReader/viewer.cpp @@ -318,7 +318,7 @@ void Viewer::updatePage() if (currentPage->isNull()) setPageUnavailableMessage(); else - emit(pageAvailable(true)); + emit pageAvailable(true); emit backgroundChanges(); @@ -955,7 +955,7 @@ void Viewer::setLoadingMessage() hideMagnifyingGlass(); restoreMagnifyingGlass = true; } - emit(pageAvailable(false)); + emit pageAvailable(false); configureContent(tr("Loading...please wait!")); } @@ -965,7 +965,7 @@ void Viewer::setPageUnavailableMessage() hideMagnifyingGlass(); restoreMagnifyingGlass = true; } - emit(pageAvailable(false)); + emit pageAvailable(false); configureContent(tr("Page not available!")); } @@ -1107,7 +1107,7 @@ void Viewer::showIsCoverMessage() shouldOpenPrevious = true; } else { shouldOpenPrevious = false; - emit(openPreviousComic()); + emit openPreviousComic(); } shouldOpenNext = false; // single page comic @@ -1121,7 +1121,7 @@ void Viewer::showIsLastMessage() shouldOpenNext = true; } else { shouldOpenNext = false; - emit(openNextComic()); + emit openNextComic(); } shouldOpenPrevious = false; // single page comic diff --git a/common/comic.cpp b/common/comic.cpp index ee4aa890..50a31d2c 100644 --- a/common/comic.cpp +++ b/common/comic.cpp @@ -604,7 +604,7 @@ void FileComic::process() } _index = _firstPage; - emit(openAt(_index)); + emit openAt(_index); int sectionIndex; QList> sections = getSections(sectionIndex); @@ -701,7 +701,7 @@ void FolderComic::process() _index = _firstPage; - emit(openAt(_index)); + emit openAt(_index); emit pageChanged(0); // this indicates new comic, index=0 emit numPages(_pages.size()); @@ -847,7 +847,7 @@ void PDFComic::process() } _index = _firstPage; - emit(openAt(_index)); + emit openAt(_index); // buffer index to avoid race conditions int buffered_index = _index; diff --git a/custom_widgets/yacreader_options_dialog.cpp b/custom_widgets/yacreader_options_dialog.cpp index 66590ff1..8f6de9a8 100644 --- a/custom_widgets/yacreader_options_dialog.cpp +++ b/custom_widgets/yacreader_options_dialog.cpp @@ -136,7 +136,7 @@ void YACReaderOptionsDialog::saveFlowParameters() void YACReaderOptionsDialog::saveOptions() { - emit(optionsChanged()); + emit optionsChanged(); close(); } From 5557cfe5b34c9040ccf11043f3b41f9dc122dad5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Thu, 30 Sep 2021 21:58:22 +0200 Subject: [PATCH 02/93] Remove unused variable --- common/check_new_version.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/common/check_new_version.cpp b/common/check_new_version.cpp index 5c046650..2d94f323 100644 --- a/common/check_new_version.cpp +++ b/common/check_new_version.cpp @@ -27,7 +27,6 @@ bool HttpVersionChecker::checkNewVersion(QString sourceContent) { QRegExp rx("#define VERSION \"([0-9]+).([0-9]+).([0-9]+)\""); - int index = 0; bool newVersion = false; bool sameVersion = true; // bool currentVersionIsNewer = false; @@ -37,7 +36,7 @@ bool HttpVersionChecker::checkNewVersion(QString sourceContent) QString version(VERSION); #endif QStringList sl = version.split("."); - if ((index = rx.indexIn(sourceContent)) != -1) { + if (rx.indexIn(sourceContent) != -1) { int length = qMin(sl.size(), (rx.cap(4) != "") ? 4 : 3); for (int i = 0; i < length; i++) { if (rx.cap(i + 1).toInt() < sl.at(i).toInt()) { From 078a97c1d1a8547c4af6791e8d7208b82668e8de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Thu, 30 Sep 2021 21:59:08 +0200 Subject: [PATCH 03/93] Remove unused variables --- custom_widgets/rounded_corners_dialog.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/custom_widgets/rounded_corners_dialog.cpp b/custom_widgets/rounded_corners_dialog.cpp index f3ce5179..a47907a8 100644 --- a/custom_widgets/rounded_corners_dialog.cpp +++ b/custom_widgets/rounded_corners_dialog.cpp @@ -12,7 +12,6 @@ YACReader::RoundedCornersDialog::RoundedCornersDialog(QWidget *parent) void YACReader::RoundedCornersDialog::paintEvent(QPaintEvent *) { qreal radius = 36.0; // desired radius in absolute pixels - qreal borderWidth = 0.0; if (!(windowFlags() & Qt::FramelessWindowHint) && !testAttribute(Qt::WA_TranslucentBackground)) return; // nothing to do @@ -22,8 +21,7 @@ void YACReader::RoundedCornersDialog::paintEvent(QPaintEvent *) // Paint thyself. QRectF rect(QPointF(0, 0), size()); - // Check for a border size. - qreal penWidth = borderWidth; + p.setPen(Qt::NoPen); // Set the brush from palette role. From d8cb61314d95d25a5865960b70b5927b29c76705 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Thu, 30 Sep 2021 21:59:40 +0200 Subject: [PATCH 04/93] Getter is not a slot --- custom_widgets/yacreader_spin_slider_widget.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/custom_widgets/yacreader_spin_slider_widget.h b/custom_widgets/yacreader_spin_slider_widget.h index 37e41462..284d9f00 100644 --- a/custom_widgets/yacreader_spin_slider_widget.h +++ b/custom_widgets/yacreader_spin_slider_widget.h @@ -18,12 +18,13 @@ private: public: YACReaderSpinSliderWidget(QWidget *parent = 0, bool strechableSlider = false); + QSize minimumSizeHint() const; + public slots: void setRange(int lowValue, int topValue, int step = 1); void setValue(int value); void setText(const QString &text); int getValue(); - QSize minimumSizeHint() const; void setTracking(bool b); void valueWillChange(int); void valueWillChangeFromSpinBox(int); @@ -32,4 +33,4 @@ signals: void valueChanged(int); }; -#endif // YACREADER_SPIN_SLIDER_WIDGET_H \ No newline at end of file +#endif // YACREADER_SPIN_SLIDER_WIDGET_H From cc927de7de4ffa90a6b9bb57751714e00d1090f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Thu, 30 Sep 2021 22:01:07 +0200 Subject: [PATCH 05/93] Use ints for colors instead of string literals --- YACReader/bookmarks_dialog.cpp | 2 +- YACReader/goto_flow_toolbar.cpp | 2 +- YACReader/notifications_label_widget.cpp | 2 +- YACReader/page_label_widget.cpp | 2 +- YACReader/translator.cpp | 2 +- YACReader/width_slider.cpp | 2 +- shortcuts_management/actions_shortcuts_model.cpp | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/YACReader/bookmarks_dialog.cpp b/YACReader/bookmarks_dialog.cpp index ec843e87..938f2f48 100644 --- a/YACReader/bookmarks_dialog.cpp +++ b/YACReader/bookmarks_dialog.cpp @@ -85,7 +85,7 @@ BookmarksDialog::BookmarksDialog(QWidget *parent) QPalette Pal(palette()); // set black background - Pal.setColor(QPalette::Background, QColor("#454545")); + Pal.setColor(QPalette::Background, QColor(0x454545)); this->setAutoFillBackground(true); this->setPalette(Pal); diff --git a/YACReader/goto_flow_toolbar.cpp b/YACReader/goto_flow_toolbar.cpp index cc7bec73..8fd8ea6e 100644 --- a/YACReader/goto_flow_toolbar.cpp +++ b/YACReader/goto_flow_toolbar.cpp @@ -93,7 +93,7 @@ GoToFlowToolBar::GoToFlowToolBar(QWidget *parent) void GoToFlowToolBar::paintEvent(QPaintEvent *) { QPainter painter(this); - painter.fillRect(0, 0, width(), height(), QColor("#99000000")); + painter.fillRect(0, 0, width(), height(), QColor(0x99000000)); } void GoToFlowToolBar::setPage(int pageNumber) diff --git a/YACReader/notifications_label_widget.cpp b/YACReader/notifications_label_widget.cpp index 4e601d83..c6939493 100644 --- a/YACReader/notifications_label_widget.cpp +++ b/YACReader/notifications_label_widget.cpp @@ -47,7 +47,7 @@ void NotificationsLabelWidget::paintEvent(QPaintEvent *) QPainterPath path; path.addRoundedRect(QRectF(0, 0, width(), height()), 5.0, 5.0); painter.setPen(Qt::NoPen); - painter.fillPath(path, QColor("#BB000000")); + painter.fillPath(path, QColor(0xBB000000)); painter.drawPath(path); } diff --git a/YACReader/page_label_widget.cpp b/YACReader/page_label_widget.cpp index bab7106e..fd30ba92 100644 --- a/YACReader/page_label_widget.cpp +++ b/YACReader/page_label_widget.cpp @@ -82,7 +82,7 @@ void PageLabelWidget::paintEvent(QPaintEvent *) { QPainter painter(this); - painter.fillRect(0, 0, width(), height(), QColor("#BB000000")); + painter.fillRect(0, 0, width(), height(), QColor(0xBB000000)); } void PageLabelWidget::updatePosition() diff --git a/YACReader/translator.cpp b/YACReader/translator.cpp index 53217400..7551488d 100644 --- a/YACReader/translator.cpp +++ b/YACReader/translator.cpp @@ -51,7 +51,7 @@ YACReaderTranslator::YACReaderTranslator(Viewer *parent) this->setAutoFillBackground(true); this->setBackgroundRole(QPalette::Window); QPalette p(this->palette()); - p.setColor(QPalette::Window, QColor("#404040")); + p.setColor(QPalette::Window, QColor(0x404040)); this->setPalette(p); auto layout = new QVBoxLayout(this); diff --git a/YACReader/width_slider.cpp b/YACReader/width_slider.cpp index 9915742d..1b13f1f0 100644 --- a/YACReader/width_slider.cpp +++ b/YACReader/width_slider.cpp @@ -79,7 +79,7 @@ void YACReaderSlider::paintEvent(QPaintEvent *) { QPainter painter(this); - painter.fillRect(0, 0, width(), height(), QColor("#BB000000")); + painter.fillRect(0, 0, width(), height(), QColor(0xBB000000)); } void YACReaderSlider::show() diff --git a/shortcuts_management/actions_shortcuts_model.cpp b/shortcuts_management/actions_shortcuts_model.cpp index 91447231..eb014268 100644 --- a/shortcuts_management/actions_shortcuts_model.cpp +++ b/shortcuts_management/actions_shortcuts_model.cpp @@ -59,7 +59,7 @@ QVariant ActionsShortcutsModel::data(const QModelIndex &index, int role) const } if (role == Qt::ForegroundRole && index.column() == KEYS && actions[index.row()]->shortcut().isEmpty()) - return QBrush(QColor("#AAAAAA")); + return QBrush(QColor(0xAAAAAA)); if (role != Qt::DisplayRole) return QVariant(); From c03b1075f3307800746ddcb1217b44aa535360eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Thu, 30 Sep 2021 22:03:51 +0200 Subject: [PATCH 06/93] Do not mix const an non-const iterators --- common/bookmarks.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/bookmarks.cpp b/common/bookmarks.cpp index b016ed58..21b27c8e 100644 --- a/common/bookmarks.cpp +++ b/common/bookmarks.cpp @@ -143,7 +143,7 @@ void BookmarksList::deleteOldest(int num) Q_UNUSED(num) QString comic; QDateTime date(QDate(10000, 1, 1)); // TODO MAX_DATE?? - for (QMap::const_iterator itr = list.begin(); itr != list.end(); itr++) { + for (QMap::const_iterator itr = list.constBegin(); itr != list.constEnd(); itr++) { if (itr->added < date) { comic = itr.key(); date = itr->added; From c1d3fb077800f9ff68a4ab9a520aeafa763d2c32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Thu, 30 Sep 2021 22:05:15 +0200 Subject: [PATCH 07/93] Proper use of range for --- common/comic.cpp | 4 ++-- common/gl/yacreader_flow_gl.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/common/comic.cpp b/common/comic.cpp index 50a31d2c..b6ea1792 100644 --- a/common/comic.cpp +++ b/common/comic.cpp @@ -27,7 +27,7 @@ QStringList Comic::getSupportedImageFormats() { QList supportedImageFormats = QImageReader::supportedImageFormats(); QStringList supportedImageFormatStrings; - for (QByteArray item : supportedImageFormats) { + for (QByteArray &item : supportedImageFormats) { supportedImageFormatStrings.append(QString::fromLocal8Bit("*." + item)); } return supportedImageFormatStrings; @@ -37,7 +37,7 @@ QStringList Comic::getSupportedImageLiteralFormats() { QList supportedImageFormats = QImageReader::supportedImageFormats(); QStringList supportedImageFormatStrings; - for (QByteArray item : supportedImageFormats) { + for (QByteArray &item : supportedImageFormats) { supportedImageFormatStrings.append(QString::fromLocal8Bit(item)); } return supportedImageFormatStrings; diff --git a/common/gl/yacreader_flow_gl.cpp b/common/gl/yacreader_flow_gl.cpp index ba61a2b7..07d19062 100644 --- a/common/gl/yacreader_flow_gl.cpp +++ b/common/gl/yacreader_flow_gl.cpp @@ -1276,7 +1276,7 @@ YACReaderPageFlowGL::~YACReaderPageFlowGL() makeCurrent(); - for (auto image : images) { + for (auto &image : images) { if (image.texture != defaultTexture) { if (image.texture->isCreated()) { image.texture->destroy(); From a56914bec3ccfb265fdec8776e28b3df5d799210 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Thu, 30 Sep 2021 22:05:41 +0200 Subject: [PATCH 08/93] Do not use foreach --- common/comic.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/comic.cpp b/common/comic.cpp index b6ea1792..3d2e0b64 100644 --- a/common/comic.cpp +++ b/common/comic.cpp @@ -994,7 +994,8 @@ QString get_most_common_prefix(const QList &pageNames) uint maxFrequency = 0; QString common_prefix = ""; - foreach (QString key, frequency.keys()) { + auto keys = frequency.keys(); + for (QString &key : keys) { if (maxFrequency < frequency.value(key)) { maxFrequency = frequency.value(key); common_prefix = key; From 459883d7bea32eb7502d13f2343d09f0190b774f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Thu, 30 Sep 2021 22:06:20 +0200 Subject: [PATCH 09/93] Use *Ref methods instead --- common/comic.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/comic.cpp b/common/comic.cpp index 3d2e0b64..e80f09c3 100644 --- a/common/comic.cpp +++ b/common/comic.cpp @@ -937,8 +937,8 @@ bool is_double_page(const QString &pageName, const QString &commonPrefix, const return false; } - int leftPageNumber = pageNumbersSubString.left(pageNumbersSubString.length() / 2).toInt(); - int rightPageNumber = pageNumbersSubString.mid(pageNumbersSubString.length() / 2).toInt(); + int leftPageNumber = pageNumbersSubString.leftRef(pageNumbersSubString.length() / 2).toInt(); + int rightPageNumber = pageNumbersSubString.midRef(pageNumbersSubString.length() / 2).toInt(); if (leftPageNumber == 0 || rightPageNumber == 0) { return false; From 32b4e420a247d72d50d811eea504e74f0548368c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Thu, 30 Sep 2021 22:06:39 +0200 Subject: [PATCH 10/93] Fix emit calls --- YACReader/goto_flow_toolbar.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/YACReader/goto_flow_toolbar.cpp b/YACReader/goto_flow_toolbar.cpp index 8fd8ea6e..81e49f90 100644 --- a/YACReader/goto_flow_toolbar.cpp +++ b/YACReader/goto_flow_toolbar.cpp @@ -32,8 +32,8 @@ GoToFlowToolBar::GoToFlowToolBar(QWidget *parent) " border-radius: 1px;" "}"); - connect(slider, &QSlider::valueChanged, this, [&](int v) { emit(setCenter(v)); }); - connect(slider, &QSlider::valueChanged, this, [=](int v) { emit(setPage(v)); }); + connect(slider, &QSlider::valueChanged, this, [&](int v) { emit setCenter(v); }); + connect(slider, &QSlider::valueChanged, this, [=](int v) { emit goToPage(v); }); pageHint = new QLabel("" + tr("Page : ") + "", this); v = new QIntValidator(this); From 3291300d5136e5d4864e24b479d4d1ac7c2ddd9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Thu, 30 Sep 2021 22:07:18 +0200 Subject: [PATCH 11/93] Use continue instead of relying on garbage bool --- compressed_archive/compressed_archive.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compressed_archive/compressed_archive.cpp b/compressed_archive/compressed_archive.cpp index 830531ff..9f54c89d 100644 --- a/compressed_archive/compressed_archive.cpp +++ b/compressed_archive/compressed_archive.cpp @@ -376,6 +376,8 @@ CompressedArchive::CompressedArchive(const QString &filePath, QObject *parent) isDir = VARIANT_BOOLToBool(prop.boolVal); else if (prop.vt == VT_EMPTY) isDir = false; + else + continue; if (!isDir) { szInterface->archive->GetProperty(i, kpidPath, &prop); From 0a2f7bd2afebfe6460482474950fb82bd7a5003a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Thu, 30 Sep 2021 22:08:03 +0200 Subject: [PATCH 12/93] Proper use of QString::arg --- YACReader/translator.cpp | 4 ++-- custom_widgets/help_about_dialog.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/YACReader/translator.cpp b/YACReader/translator.cpp index 7551488d..5915b50d 100644 --- a/YACReader/translator.cpp +++ b/YACReader/translator.cpp @@ -353,7 +353,7 @@ void TranslationLoader::run() connect(&manager, &QNetworkAccessManager::finished, &q, &QEventLoop::quit); QString url = "http://api.microsofttranslator.com/V2/Ajax.svc/Translate?appid=%1&from=%2&to=%3&text=%4&contentType=text/plain"; - url = url.arg(APPID).arg(from).arg(to).arg(text); + url = url.arg(APPID, from, to, text); QNetworkReply *reply = manager.get(QNetworkRequest(QUrl(url))); @@ -396,7 +396,7 @@ void TextToSpeachLoader::run() connect(&manager, &QNetworkAccessManager::finished, &q, &QEventLoop::quit); QString url = "http://api.microsofttranslator.com/V2/Ajax.svc/Speak?appid=%1&language=%2&text=%3&contentType=text/plain"; - url = url.arg(APPID).arg(language).arg(text); + url = url.arg(APPID, language, text); QNetworkReply *reply = manager.get(QNetworkRequest(QUrl(url))); diff --git a/custom_widgets/help_about_dialog.cpp b/custom_widgets/help_about_dialog.cpp index 9e6d745d..680e9210 100644 --- a/custom_widgets/help_about_dialog.cpp +++ b/custom_widgets/help_about_dialog.cpp @@ -56,7 +56,7 @@ void HelpAboutDialog::loadAboutInformation(const QString &path) buildNumber = BUILD_NUMBER; #endif - aboutText->setHtml(fileToString(path).arg(VERSION).arg(buildNumber)); + aboutText->setHtml(fileToString(path).arg(VERSION, buildNumber)); aboutText->moveCursor(QTextCursor::Start); } From 5f55dab0cc225c46bc4b8abb0b23e8b73c38e2c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Thu, 30 Sep 2021 22:08:19 +0200 Subject: [PATCH 13/93] Do not write unused values --- YACReader/viewer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/YACReader/viewer.cpp b/YACReader/viewer.cpp index 20a35764..6f2ee1fa 100644 --- a/YACReader/viewer.cpp +++ b/YACReader/viewer.cpp @@ -763,8 +763,8 @@ void Viewer::mouseMoveEvent(QMouseEvent *event) if (drag) { int currentPosY = verticalScrollBar()->sliderPosition(); int currentPosX = horizontalScrollBar()->sliderPosition(); - verticalScrollBar()->setSliderPosition(currentPosY = currentPosY + (yDragOrigin - event->y())); - horizontalScrollBar()->setSliderPosition(currentPosX = currentPosX + (xDragOrigin - event->x())); + verticalScrollBar()->setSliderPosition(currentPosY + (yDragOrigin - event->y())); + horizontalScrollBar()->setSliderPosition(currentPosX + (xDragOrigin - event->x())); yDragOrigin = event->y(); xDragOrigin = event->x(); } From b878e8169e9d3bc96d275bbd6b397c910ac94ecb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Fri, 1 Oct 2021 19:46:54 +0200 Subject: [PATCH 14/93] Replace QDateTime constructor Using the last moment of the day is enough because all other dates in bookmarks have happened before. --- common/bookmarks.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/bookmarks.cpp b/common/bookmarks.cpp index 21b27c8e..4db72435 100644 --- a/common/bookmarks.cpp +++ b/common/bookmarks.cpp @@ -142,7 +142,7 @@ void BookmarksList::deleteOldest(int num) { Q_UNUSED(num) QString comic; - QDateTime date(QDate(10000, 1, 1)); // TODO MAX_DATE?? + auto date = QDate().endOfDay(); for (QMap::const_iterator itr = list.constBegin(); itr != list.constEnd(); itr++) { if (itr->added < date) { comic = itr.key(); From db433be88c3d27ba331ce72b9faba777ac43237b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Fri, 1 Oct 2021 19:47:22 +0200 Subject: [PATCH 15/93] Include QRegExp explicitly --- common/check_new_version.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/common/check_new_version.cpp b/common/check_new_version.cpp index 2d94f323..501191b0 100644 --- a/common/check_new_version.cpp +++ b/common/check_new_version.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #define PREVIOUS_VERSION_TESTING "6.0.0" From ecd149737005860296ae3137ce8bc09a985c7118 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Fri, 1 Oct 2021 19:49:21 +0200 Subject: [PATCH 16/93] Don't use virtual methods unnecessarily --- common/comic.cpp | 6 +++--- common/comic.h | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/common/comic.cpp b/common/comic.cpp index e80f09c3..afcd5119 100644 --- a/common/comic.cpp +++ b/common/comic.cpp @@ -352,7 +352,7 @@ FileComic::FileComic() FileComic::FileComic(const QString &path, int atPage) : Comic(path, atPage) { - load(path, atPage); + FileComic::load(path, atPage); } FileComic::~FileComic() @@ -649,7 +649,7 @@ FolderComic::FolderComic() FolderComic::FolderComic(const QString &path, int atPage) : Comic(path, atPage) { - load(path, atPage); + FolderComic::load(path, atPage); } FolderComic::~FolderComic() @@ -745,7 +745,7 @@ PDFComic::PDFComic() PDFComic::PDFComic(const QString &path, int atPage) : Comic(path, atPage) { - load(path, atPage); + PDFComic::load(path, atPage); } PDFComic::~PDFComic() diff --git a/common/comic.h b/common/comic.h index cf83d4de..a64da6f5 100644 --- a/common/comic.h +++ b/common/comic.h @@ -123,8 +123,8 @@ public: FileComic(); FileComic(const QString &path, int atPage = -1); ~FileComic(); - virtual bool load(const QString &path, int atPage = -1); - virtual bool load(const QString &path, const ComicDB &comic); + bool load(const QString &path, int atPage = -1); + bool load(const QString &path, const ComicDB &comic); static QList filter(const QList &src); // ExtractDelegate @@ -150,7 +150,7 @@ public: FolderComic(const QString &path, int atPage = -1); ~FolderComic(); - virtual bool load(const QString &path, int atPage = -1); + bool load(const QString &path, int atPage = -1); public slots: @@ -179,8 +179,8 @@ public: PDFComic(const QString &path, int atPage = -1); ~PDFComic(); - virtual bool load(const QString &path, int atPage = -1); - virtual bool load(const QString &path, const ComicDB &comic); + bool load(const QString &path, int atPage = -1); + bool load(const QString &path, const ComicDB &comic); public slots: From a792a03760f91087ad0a10b8801551b1ee19da1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Fri, 1 Oct 2021 19:49:44 +0200 Subject: [PATCH 17/93] Use QRegularExpression instead of QRegExp --- common/comic.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/comic.cpp b/common/comic.cpp index afcd5119..886ec61c 100644 --- a/common/comic.cpp +++ b/common/comic.cpp @@ -1,7 +1,7 @@ #include "comic.h" #include -#include +#include #include #include #include @@ -1002,8 +1002,8 @@ QString get_most_common_prefix(const QList &pageNames) } } - QRegExp allNumberRegExp("\\d+"); - if (allNumberRegExp.exactMatch(common_prefix)) { + QRegularExpression allNumberRegExp(QRegularExpression::anchoredPattern("\\d+")); + if (allNumberRegExp.match(common_prefix).hasMatch()) { return ""; } From 326cebdf7f87c8f98458be545b5b485a599e9417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Fri, 1 Oct 2021 19:50:03 +0200 Subject: [PATCH 18/93] *Ref methods are deprecated in Qt6 --- common/comic.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/comic.cpp b/common/comic.cpp index 886ec61c..5051ed32 100644 --- a/common/comic.cpp +++ b/common/comic.cpp @@ -937,8 +937,8 @@ bool is_double_page(const QString &pageName, const QString &commonPrefix, const return false; } - int leftPageNumber = pageNumbersSubString.leftRef(pageNumbersSubString.length() / 2).toInt(); - int rightPageNumber = pageNumbersSubString.midRef(pageNumbersSubString.length() / 2).toInt(); + int leftPageNumber = pageNumbersSubString.left(pageNumbersSubString.length() / 2).toInt(); + int rightPageNumber = pageNumbersSubString.mid(pageNumbersSubString.length() / 2).toInt(); if (leftPageNumber == 0 || rightPageNumber == 0) { return false; From 35fa03549b1951b32cbb333c58f756f1f09605b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Fri, 1 Oct 2021 19:50:52 +0200 Subject: [PATCH 19/93] Use fully qualified names --- common/gl/yacreader_flow_gl.cpp | 4 ++-- common/gl/yacreader_flow_gl.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common/gl/yacreader_flow_gl.cpp b/common/gl/yacreader_flow_gl.cpp index 07d19062..9aa54306 100644 --- a/common/gl/yacreader_flow_gl.cpp +++ b/common/gl/yacreader_flow_gl.cpp @@ -950,7 +950,7 @@ void YACReaderFlowGL::setShowMarks(bool value) showMarks = value; } -void YACReaderFlowGL::setMarks(QVector marks) +void YACReaderFlowGL::setMarks(QVector marks) { startAnimationTimer(); @@ -963,7 +963,7 @@ void YACReaderFlowGL::setMarkImage(QImage &image) // deleteTexture(markTexture); // markTexture = bindTexture(image,GL_TEXTURE_2D,GL_RGBA,QGLContext::LinearFilteringBindOption | QGLContext::MipmapBindOption); } -void YACReaderFlowGL::markSlide(int index, YACReaderComicReadStatus status) +void YACReaderFlowGL::markSlide(int index, YACReader::YACReaderComicReadStatus status) { startAnimationTimer(); diff --git a/common/gl/yacreader_flow_gl.h b/common/gl/yacreader_flow_gl.h index bc6bb6e2..2b51a1af 100644 --- a/common/gl/yacreader_flow_gl.h +++ b/common/gl/yacreader_flow_gl.h @@ -252,9 +252,9 @@ public slots: // interface with yacreaderlibrary, compatibility void setShowMarks(bool value); - void setMarks(QVector marks); + void setMarks(QVector marks); void setMarkImage(QImage &image); - void markSlide(int index, YACReaderComicReadStatus status); + void markSlide(int index, YACReader::YACReaderComicReadStatus status); void unmarkSlide(int index); void setSlideSize(QSize size); void clear(); From 2de4b26b711352e7cc4f594c0822edfcbbebe021 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Fri, 1 Oct 2021 19:54:41 +0200 Subject: [PATCH 20/93] Start supporting Qt6 Everything is broken but we want to start fixing as much as possible --- YACReader/YACReader.pro | 2 ++ YACReaderLibrary/YACReaderLibrary.pro | 2 ++ YACReaderLibraryServer/YACReaderLibraryServer.pro | 2 ++ config.pri | 4 ---- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/YACReader/YACReader.pro b/YACReader/YACReader.pro index 067e78e3..fe2f6c7b 100644 --- a/YACReader/YACReader.pro +++ b/YACReader/YACReader.pro @@ -70,6 +70,8 @@ macx { QT += network widgets core multimedia svg +greaterThan(QT_MAJOR_VERSION, 5): QT += openglwidgets core5compat + #CONFIG += release CONFIG -= flat diff --git a/YACReaderLibrary/YACReaderLibrary.pro b/YACReaderLibrary/YACReaderLibrary.pro index 0ff05782..17a6a94c 100644 --- a/YACReaderLibrary/YACReaderLibrary.pro +++ b/YACReaderLibrary/YACReaderLibrary.pro @@ -71,6 +71,8 @@ macx { CONFIG -= flat QT += sql network widgets svg +greaterThan(QT_MAJOR_VERSION, 5): QT += openglwidgets core5compat + # Input HEADERS += comic_flow.h \ ../common/concurrent_queue.h \ diff --git a/YACReaderLibraryServer/YACReaderLibraryServer.pro b/YACReaderLibraryServer/YACReaderLibraryServer.pro index e84ab29a..54fb3431 100644 --- a/YACReaderLibraryServer/YACReaderLibraryServer.pro +++ b/YACReaderLibraryServer/YACReaderLibraryServer.pro @@ -37,6 +37,8 @@ unix:haiku { CONFIG -= flat QT += core sql network +greaterThan(QT_MAJOR_VERSION, 5): QT += core5compat + # Source files HEADERS += ../YACReaderLibrary/library_creator.h \ ../YACReaderLibrary/package_manager.h \ diff --git a/config.pri b/config.pri index 3b14f8c2..3553c277 100644 --- a/config.pri +++ b/config.pri @@ -35,10 +35,6 @@ defineTest(minQtVersion) { error(YACReader requires Qt 5.9 or newer but $$[QT_VERSION] was detected) } -minQtVersion(6, 0, 0) { - error(YACReader does not support building with Qt6 (yet)) -} - DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x050900 DEFINES += QT_DEPRECATED_WARNINGS From 9ebd6e32da2c71d44e3eb9537da828081ae848ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Fri, 1 Oct 2021 19:55:17 +0200 Subject: [PATCH 21/93] Fix QtOpenGL* includes in Qt6 --- common/gl/yacreader_flow_gl.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/common/gl/yacreader_flow_gl.h b/common/gl/yacreader_flow_gl.h index 2b51a1af..e594c4f4 100644 --- a/common/gl/yacreader_flow_gl.h +++ b/common/gl/yacreader_flow_gl.h @@ -2,9 +2,17 @@ #ifndef __YACREADER_FLOW_GL_H #define __YACREADER_FLOW_GL_H +#include + +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +#include +#include +#else #include -#include #include +#endif + +#include #include #include "pictureflow.h" //TODO mover los tipos de flow de sitio From bdb23de74a8495987ee467a4fe494b62e29b0b83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Fri, 1 Oct 2021 19:56:07 +0200 Subject: [PATCH 22/93] Use fully qualified names --- common/pictureflow.cpp | 4 ++-- common/pictureflow.h | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/common/pictureflow.cpp b/common/pictureflow.cpp index bcd222e6..893f8883 100644 --- a/common/pictureflow.cpp +++ b/common/pictureflow.cpp @@ -1338,7 +1338,7 @@ void PictureFlow::setMarkImage(const QImage &m) d->state->mark = m; } -void PictureFlow::markSlide(int index, YACReaderComicReadStatus readStatus) +void PictureFlow::markSlide(int index, YACReader::YACReaderComicReadStatus readStatus) { if (index < d->state->marks.size()) d->state->marks[index] = readStatus; @@ -1356,7 +1356,7 @@ void PictureFlow::unmarkSlide(int index) d->state->marks[index] = YACReader::Unread; } -void PictureFlow::setMarks(const QVector &m) +void PictureFlow::setMarks(const QVector &m) { d->state->marks = m; updateMarks(); diff --git a/common/pictureflow.h b/common/pictureflow.h index 03230051..d7d6ea05 100644 --- a/common/pictureflow.h +++ b/common/pictureflow.h @@ -187,21 +187,21 @@ public slots: */ void triggerRender(); - void setFlowType(FlowType flowType); + void setFlowType(YACReader::FlowType flowType); void setMarkImage(const QImage &mark); - void markSlide(int index, YACReaderComicReadStatus readStatus = Read); + void markSlide(int index, YACReader::YACReaderComicReadStatus readStatus = Read); void updateMarks(); void unmarkSlide(int index); - void setMarks(const QVector &marks); + void setMarks(const QVector &marks); void setShowMarks(bool enable); - QVector getMarks(); + QVector getMarks(); void resortCovers(QList newOrder); From b83d7150d772a27836063104e407f9c46c1463a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Fri, 1 Oct 2021 19:56:49 +0200 Subject: [PATCH 23/93] Use QElapsedTimer instead of QTime --- common/pictureflow.cpp | 8 +++++--- common/scroll_management.cpp | 2 +- common/scroll_management.h | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/common/pictureflow.cpp b/common/pictureflow.cpp index 893f8883..4e552a50 100644 --- a/common/pictureflow.cpp +++ b/common/pictureflow.cpp @@ -26,6 +26,8 @@ #include "pictureflow.h" +#include + // detect Qt version #if QT_VERSION >= 0x040000 #define PICTUREFLOW_QT4 @@ -1281,8 +1283,8 @@ void PictureFlow::resizeEvent(QResizeEvent *event) #include void PictureFlow::updateAnimation() // bucle principal { - QTime now; - now.start(); + QElapsedTimer timer; + timer.start(); bool frameSkiped = false; int old_center = d->state->centerIndex; @@ -1297,7 +1299,7 @@ void PictureFlow::updateAnimation() // bucle principal if (d->state->centerIndex != old_center) emit centerIndexChangedSilent(d->state->centerIndex); if (d->animator->animating == true) { - int difference = 10 - now.elapsed(); + int difference = 10 - timer.elapsed(); if (difference >= 0 && !frameSkiped) QTimer::singleShot(difference, this, &PictureFlow::updateAnimation); else { diff --git a/common/scroll_management.cpp b/common/scroll_management.cpp index 8b4674f4..0fdd5dbc 100644 --- a/common/scroll_management.cpp +++ b/common/scroll_management.cpp @@ -2,7 +2,7 @@ ScrollManagement::ScrollManagement() { - wheelTimer = new QTime(); + wheelTimer = new QElapsedTimer(); wheelTimer->start(); wheelAccumulator = 0; } diff --git a/common/scroll_management.h b/common/scroll_management.h index 3ed9185d..f7cd362a 100644 --- a/common/scroll_management.h +++ b/common/scroll_management.h @@ -1,7 +1,7 @@ #ifndef SCROLLMANAGAMENT_H #define SCROLLMANAGAMENT_H -#include +#include #include class ScrollManagement @@ -18,7 +18,7 @@ public: ~ScrollManagement(); private: - QTime *wheelTimer; + QElapsedTimer *wheelTimer; int wheelAccumulator; }; From f300bc3aa0c9b47facd839afb56866adea3612f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Fri, 1 Oct 2021 19:57:04 +0200 Subject: [PATCH 24/93] Include QMetaType explicitly --- common/yacreader_global.h | 1 + 1 file changed, 1 insertion(+) diff --git a/common/yacreader_global.h b/common/yacreader_global.h index d01c9af9..ab0c5681 100644 --- a/common/yacreader_global.h +++ b/common/yacreader_global.h @@ -3,6 +3,7 @@ #include #include +#include #define VERSION "9.8.2" From b07ec73ccca1dbddffe4527a977b7b56c20b3a25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Fri, 1 Oct 2021 19:57:34 +0200 Subject: [PATCH 25/93] Use Qt::endl instead of endl --- compressed_archive/compressed_archive.cpp | 38 +++++++++++------------ compressed_archive/extract_callbacks.h | 2 +- compressed_archive/open_callbacks.h | 2 +- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/compressed_archive/compressed_archive.cpp b/compressed_archive/compressed_archive.cpp index 9f54c89d..6b8a1c6a 100644 --- a/compressed_archive/compressed_archive.cpp +++ b/compressed_archive/compressed_archive.cpp @@ -206,11 +206,11 @@ CompressedArchive::CompressedArchive(const QString &filePath, QObject *parent) // GUID uuid = supportedFileFormats[i]; // qDebug() << "trying : " << uuid << endl; if (szInterface->createObjectFunc(&supportedFileFormats[i], &IID_InArchive, (void **)&szInterface->archive) == S_OK) { - // qDebug() << "Can not open archive file : " + filePath << endl; + // qDebug() << "Can not open archive file : " + filePath << Qt::endl; if (szInterface->archive->Open(file, 0, openCallback) == S_OK) { valid = formatFound = true; - qDebug() << "Opened archive file : " + filePath << endl; + qDebug() << "Opened archive file : " + filePath << Qt::endl; setupFilesNames(); return; } @@ -218,7 +218,7 @@ CompressedArchive::CompressedArchive(const QString &filePath, QObject *parent) #ifdef Q_OS_WIN if (!formatFound) { - qDebug() << "Can not open archive" << endl; + qDebug() << "Can not open archive" << Qt::endl; } } } @@ -258,7 +258,7 @@ CompressedArchive::CompressedArchive(const QString &filePath, QObject *parent) qDebug() << "Error opening rar file :" + filePath; return; } - // qDebug() << "Can not open archive file : " + filePath << endl; + // qDebug() << "Can not open archive file : " + filePath << Qt::endl; if (szInterface->archive->Open(file, 0, openCallback) == S_OK) { valid = formatFound = true; @@ -311,7 +311,7 @@ CompressedArchive::CompressedArchive(const QString &filePath, QObject *parent) } #endif if (!rarLib->load()) { - qDebug() << "Error Loading Rar.so : " + rarLib->errorString() << endl; + qDebug() << "Error Loading Rar.so : " + rarLib->errorString() << Qt::endl; QCoreApplication::exit(700); // TODO yacreader_global can't be used here, it is GUI dependant, YACReader::SevenZNotFound return false; } @@ -328,34 +328,34 @@ CompressedArchive::CompressedArchive(const QString &filePath, QObject *parent) #endif } if (!sevenzLib->load()) { - qDebug() << "Error Loading 7z.dll : " + sevenzLib->errorString() << endl; + qDebug() << "Error Loading 7z.dll : " + sevenzLib->errorString() << Qt::endl; QCoreApplication::exit(700); // TODO yacreader_global can't be used here, it is GUI dependant, YACReader::SevenZNotFound return false; } else { - qDebug() << "Loading functions" << endl; + qDebug() << "Loading functions" << Qt::endl; if ((szInterface->createObjectFunc = (CreateObjectFunc)sevenzLib->resolve("CreateObject")) == 0) - qDebug() << "fail loading function : CreateObject" << endl; + qDebug() << "fail loading function : CreateObject" << Qt::endl; if ((szInterface->getMethodPropertyFunc = (GetMethodPropertyFunc)sevenzLib->resolve("GetMethodProperty")) == 0) - qDebug() << "fail loading function : GetMethodProperty" << endl; + qDebug() << "fail loading function : GetMethodProperty" << Qt::endl; if ((szInterface->getNumberOfMethodsFunc = (GetNumberOfMethodsFunc)sevenzLib->resolve("GetNumberOfMethods")) == 0) - qDebug() << "fail loading function : GetNumberOfMethods" << endl; + qDebug() << "fail loading function : GetNumberOfMethods" << Qt::endl; if ((szInterface->getNumberOfFormatsFunc = (GetNumberOfFormatsFunc)sevenzLib->resolve("GetNumberOfFormats")) == 0) - qDebug() << "fail loading function : GetNumberOfFormats" << endl; + qDebug() << "fail loading function : GetNumberOfFormats" << Qt::endl; if ((szInterface->getHandlerPropertyFunc = (GetHandlerPropertyFunc)sevenzLib->resolve("GetHandlerProperty")) == 0) - qDebug() << "fail loading function : GetHandlerProperty" << endl; + qDebug() << "fail loading function : GetHandlerProperty" << Qt::endl; if ((szInterface->getHandlerPropertyFunc2 = (GetHandlerPropertyFunc2)sevenzLib->resolve("GetHandlerProperty2")) == 0) - qDebug() << "fail loading function : GetHandlerProperty2" << endl; + qDebug() << "fail loading function : GetHandlerProperty2" << Qt::endl; if ((szInterface->setLargePageModeFunc = (SetLargePageModeFunc)sevenzLib->resolve("SetLargePageMode")) == 0) - qDebug() << "fail loading function : SetLargePageMode" << endl; + qDebug() << "fail loading function : SetLargePageMode" << Qt::endl; #ifdef Q_OS_UNIX if ((szInterface->createObjectFuncRar = (CreateObjectFunc)rarLib->resolve("CreateObject")) == 0) - qDebug() << "fail loading function (rar) : CreateObject" << endl; + qDebug() << "fail loading function (rar) : CreateObject" << Qt::endl; if ((szInterface->getMethodPropertyFuncRar = (GetMethodPropertyFunc)rarLib->resolve("GetMethodProperty")) == 0) - qDebug() << "fail loading function (rar) : GetMethodProperty" << endl; + qDebug() << "fail loading function (rar) : GetMethodProperty" << Qt::endl; if ((szInterface->getNumberOfMethodsFuncRar = (GetNumberOfMethodsFunc)rarLib->resolve("GetNumberOfMethods")) == 0) - qDebug() << "fail loading function (rar) : GetNumberOfMethods" << endl; + qDebug() << "fail loading function (rar) : GetNumberOfMethods" << Qt::endl; #endif } @@ -445,7 +445,7 @@ CompressedArchive::CompressedArchive(const QString &filePath, QObject *parent) else result = szInterface->archive->Extract(currentIndexes.data(), currentIndexes.count(), false, extractCallback); if (result != S_OK) { - qDebug() << "Extract Error" << endl; + qDebug() << "Extract Error" << Qt::endl; } return extractCallbackSpec->allFiles; @@ -468,7 +468,7 @@ CompressedArchive::CompressedArchive(const QString &filePath, QObject *parent) HRESULT result = szInterface->archive->Extract(indices, 1, false, extractCallback); if (result != S_OK) { - qDebug() << "Extract Error" << endl; + qDebug() << "Extract Error" << Qt::endl; } return QByteArray((char *)extractCallbackSpec->data, extractCallbackSpec->newFileSize); diff --git a/compressed_archive/extract_callbacks.h b/compressed_archive/extract_callbacks.h index 4d94a562..080ada8c 100644 --- a/compressed_archive/extract_callbacks.h +++ b/compressed_archive/extract_callbacks.h @@ -309,7 +309,7 @@ STDMETHODIMP YCArchiveExtractCallback::CryptoGetTextPassword(BSTR *password) // You can ask real password here from user // Password = GetPassword(OutStream); // PasswordIsDefined = true; - qDebug() << "Password is not defined" << endl; + qDebug() << "Password is not defined" << Qt::endl; return E_ABORT; } return StringToBstr(Password, password); diff --git a/compressed_archive/open_callbacks.h b/compressed_archive/open_callbacks.h index 15f38d98..1a4dc4ee 100644 --- a/compressed_archive/open_callbacks.h +++ b/compressed_archive/open_callbacks.h @@ -44,7 +44,7 @@ STDMETHODIMP YCArchiveOpenCallback::CryptoGetTextPassword(BSTR *password) // You can ask real password here from user // Password = GetPassword(OutStream); // PasswordIsDefined = true; - qDebug() << "Password is not defined" << endl; + qDebug() << "Password is not defined" << Qt::endl; return E_ABORT; } return StringToBstr(Password, password); From 2a90b1c6ef039ecd2c2bfe12463ee37bba6d75bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Fri, 1 Oct 2021 20:00:19 +0200 Subject: [PATCH 26/93] Stop using availableGeometry --- YACReader/bookmarks_dialog.cpp | 9 +++++++-- YACReader/main_window_viewer.cpp | 10 +++++++--- YACReader/page_label_widget.cpp | 9 +++++++-- custom_widgets/help_about_dialog.cpp | 12 ++++++++++-- 4 files changed, 31 insertions(+), 9 deletions(-) diff --git a/YACReader/bookmarks_dialog.cpp b/YACReader/bookmarks_dialog.cpp index 938f2f48..f39685db 100644 --- a/YACReader/bookmarks_dialog.cpp +++ b/YACReader/bookmarks_dialog.cpp @@ -3,9 +3,9 @@ #include #include #include -#include #include #include +#include #include "bookmarks.h" @@ -32,7 +32,12 @@ BookmarksDialog::BookmarksDialog(QWidget *parent) label->setStyleSheet(labelsStyle); } - int heightDesktopResolution = QApplication::desktop()->screenGeometry().height(); + QScreen *screen = parent != nullptr ? parent->window()->screen() : nullptr; + if (screen == nullptr) { + screen = QApplication::screens().constFirst(); + } + + int heightDesktopResolution = screen != nullptr ? screen->size().height() : 600; int height, width; height = heightDesktopResolution * 0.50; width = height * 0.65; diff --git a/YACReader/main_window_viewer.cpp b/YACReader/main_window_viewer.cpp index c00c8216..2faaee1f 100644 --- a/YACReader/main_window_viewer.cpp +++ b/YACReader/main_window_viewer.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -146,8 +145,13 @@ void MainWindowViewer::setupUI() connect(viewer, &Viewer::openPreviousComic, this, &MainWindowViewer::openPreviousComic); setCentralWidget(viewer); - int heightDesktopResolution = QApplication::desktop()->screenGeometry().height(); - int widthDesktopResolution = QApplication::desktop()->screenGeometry().width(); + QScreen *screen = window()->screen(); + if (screen == nullptr) { + screen = QApplication::screens().constFirst(); + } + + int heightDesktopResolution = screen != nullptr ? screen->size().height() : 600; + int widthDesktopResolution = screen != nullptr ? screen->size().height() : 1024; int height, width; height = static_cast(heightDesktopResolution * 0.84); width = static_cast(height * 0.70); diff --git a/YACReader/page_label_widget.cpp b/YACReader/page_label_widget.cpp index fd30ba92..f257a201 100644 --- a/YACReader/page_label_widget.cpp +++ b/YACReader/page_label_widget.cpp @@ -9,10 +9,15 @@ PageLabelWidget::PageLabelWidget(QWidget *parent) animation->setDuration(150); animation->setEndValue(QPoint((parent->geometry().size().width() - this->width()), -this->height())); - int verticalRes = QApplication::desktop()->screenGeometry().height(); + QScreen *screen = parent != nullptr ? parent->window()->screen() : nullptr; + if (screen == nullptr) { + screen = QApplication::screens().constFirst(); + } + + int verticalRes = screen != nullptr ? screen->size().height() : 600; auto layout = new QHBoxLayout; - layout->setMargin(0); + layout->setContentsMargins(0, 0, 0, 0); setContentsMargins(0, 0, 0, 0); QSize labelSize; diff --git a/custom_widgets/help_about_dialog.cpp b/custom_widgets/help_about_dialog.cpp index 680e9210..c2e8db47 100644 --- a/custom_widgets/help_about_dialog.cpp +++ b/custom_widgets/help_about_dialog.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include "yacreader_global.h" @@ -31,7 +31,15 @@ HelpAboutDialog::HelpAboutDialog(QWidget *parent) layout->setContentsMargins(1, 3, 1, 1); setLayout(layout); - resize(500, QApplication::desktop()->availableGeometry().height() * 0.83); + + QScreen *screen = parent != nullptr ? parent->window()->screen() : nullptr; + if (screen == nullptr) { + screen = QApplication::screens().constFirst(); + } + + int heightDesktopResolution = screen != nullptr ? screen->size().height() : 600; + + resize(500, heightDesktopResolution * 0.83); } HelpAboutDialog::~HelpAboutDialog() From 1012ec37c7d616492d3227ed3a4f1433b3902963 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Fri, 1 Oct 2021 20:03:37 +0200 Subject: [PATCH 27/93] Use setContentsMargins instead of setMargin --- YACReader/goto_flow_toolbar.cpp | 2 +- YACReader/goto_flow_widget.cpp | 2 +- YACReader/notifications_label_widget.cpp | 2 +- custom_widgets/whats_new_dialog.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/YACReader/goto_flow_toolbar.cpp b/YACReader/goto_flow_toolbar.cpp index 81e49f90..41ea3253 100644 --- a/YACReader/goto_flow_toolbar.cpp +++ b/YACReader/goto_flow_toolbar.cpp @@ -71,7 +71,7 @@ GoToFlowToolBar::GoToFlowToolBar(QWidget *parent) connect(goToButton, &QPushButton::clicked, this, &GoToFlowToolBar::goTo); - normalLayout->setMargin(0); + normalLayout->setContentsMargins(0, 0, 0, 0); normalLayout->setSpacing(0); normalLayout->addStretch(); normalLayout->addWidget(pageHint); diff --git a/YACReader/goto_flow_widget.cpp b/YACReader/goto_flow_widget.cpp index 123472f4..0b32bf7d 100644 --- a/YACReader/goto_flow_widget.cpp +++ b/YACReader/goto_flow_widget.cpp @@ -12,7 +12,7 @@ GoToFlowWidget::GoToFlowWidget(QWidget *parent) : QWidget(parent) { mainLayout = new QVBoxLayout(this); - mainLayout->setMargin(0); + mainLayout->setContentsMargins(0, 0, 0, 0); mainLayout->setSpacing(0); toolBar = new GoToFlowToolBar(this); diff --git a/YACReader/notifications_label_widget.cpp b/YACReader/notifications_label_widget.cpp index c6939493..d450e84b 100644 --- a/YACReader/notifications_label_widget.cpp +++ b/YACReader/notifications_label_widget.cpp @@ -7,7 +7,7 @@ NotificationsLabelWidget::NotificationsLabelWidget(QWidget *parent) { auto layout = new QVBoxLayout; layout->setSpacing(0); - layout->setMargin(0); + layout->setContentsMargins(0, 0, 0, 0); setAttribute(Qt::WA_LayoutUsesWidgetRect, true); effect = new QGraphicsOpacityEffect(this); diff --git a/custom_widgets/whats_new_dialog.cpp b/custom_widgets/whats_new_dialog.cpp index 4fe9c541..7e41e77e 100644 --- a/custom_widgets/whats_new_dialog.cpp +++ b/custom_widgets/whats_new_dialog.cpp @@ -14,7 +14,7 @@ YACReader::WhatsNewDialog::WhatsNewDialog(QWidget *parent) scrollArea->setContentsMargins(0, 0, 0, 0); auto mainLayout = new QVBoxLayout(this); - mainLayout->setMargin(0); + mainLayout->setContentsMargins(0, 0, 0, 0); auto contentLayout = new QGridLayout(); auto content = new QFrame(); From 474689e24b2832f30e7e3e8a965d1646f9f71003 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Fri, 1 Oct 2021 20:05:34 +0200 Subject: [PATCH 28/93] Replace deprecated QPalette role --- YACReader/bookmarks_dialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/YACReader/bookmarks_dialog.cpp b/YACReader/bookmarks_dialog.cpp index f39685db..75bfac04 100644 --- a/YACReader/bookmarks_dialog.cpp +++ b/YACReader/bookmarks_dialog.cpp @@ -90,7 +90,7 @@ BookmarksDialog::BookmarksDialog(QWidget *parent) QPalette Pal(palette()); // set black background - Pal.setColor(QPalette::Background, QColor(0x454545)); + Pal.setColor(QPalette::Window, QColor(0x454545)); this->setAutoFillBackground(true); this->setPalette(Pal); From 1c144d950d9f40bce8517705922d1c5d69bc3e8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Fri, 1 Oct 2021 20:06:00 +0200 Subject: [PATCH 29/93] Use fully qualified names --- YACReader/goto_flow.cpp | 2 +- YACReader/goto_flow.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/YACReader/goto_flow.cpp b/YACReader/goto_flow.cpp index 97a8f4e0..89b3ff6b 100644 --- a/YACReader/goto_flow.cpp +++ b/YACReader/goto_flow.cpp @@ -202,7 +202,7 @@ void GoToFlow::wheelEvent(QWheelEvent *event) event->accept(); } -void GoToFlow::setFlowType(FlowType flowType) +void GoToFlow::setFlowType(YACReader::FlowType flowType) { flow->setFlowType(flowType); } diff --git a/YACReader/goto_flow.h b/YACReader/goto_flow.h index 60664d42..14b52929 100644 --- a/YACReader/goto_flow.h +++ b/YACReader/goto_flow.h @@ -60,7 +60,7 @@ public slots: void reset() override; void setNumSlides(unsigned int slides) override; void setImageReady(int index, const QByteArray &image) override; - void setFlowType(FlowType flowType) override; + void setFlowType(YACReader::FlowType flowType) override; void updateConfig(QSettings *settings) override; void setFlowRightToLeft(bool b) override; }; From 740eab502543089c5a2ed15b5538f0c03ffee852 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Fri, 1 Oct 2021 20:07:14 +0200 Subject: [PATCH 30/93] Update QWheelEvent delta usage --- YACReader/goto_flow.cpp | 2 +- YACReader/magnifying_glass.cpp | 8 ++++---- YACReader/viewer.cpp | 10 +++++----- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/YACReader/goto_flow.cpp b/YACReader/goto_flow.cpp index 89b3ff6b..615204df 100644 --- a/YACReader/goto_flow.cpp +++ b/YACReader/goto_flow.cpp @@ -195,7 +195,7 @@ void GoToFlow::updateImageData() void GoToFlow::wheelEvent(QWheelEvent *event) { - if (event->delta() < 0) + if (event->pixelDelta().y() < 0) flow->showNext(); else flow->showPrevious(); diff --git a/YACReader/magnifying_glass.cpp b/YACReader/magnifying_glass.cpp index 49e3dab4..cccd028a 100644 --- a/YACReader/magnifying_glass.cpp +++ b/YACReader/magnifying_glass.cpp @@ -144,28 +144,28 @@ void MagnifyingGlass::wheelEvent(QWheelEvent *event) switch (event->modifiers()) { // size case Qt::NoModifier: - if (event->delta() < 0) + if (event->pixelDelta().y() < 0) sizeUp(); else sizeDown(); break; // size height case Qt::ControlModifier: - if (event->delta() < 0) + if (event->pixelDelta().y() < 0) heightUp(); else heightDown(); break; // size width case Qt::AltModifier: - if (event->delta() < 0) + if (event->pixelDelta().y() < 0) widthUp(); else widthDown(); break; // zoom level case Qt::ShiftModifier: - if (event->delta() < 0) + if (event->pixelDelta().y() < 0) zoomIn(); else zoomOut(); diff --git a/YACReader/viewer.cpp b/YACReader/viewer.cpp index 6f2ee1fa..029f306f 100644 --- a/YACReader/viewer.cpp +++ b/YACReader/viewer.cpp @@ -689,12 +689,12 @@ static void animateScroll(QPropertyAnimation &scroller, const QScrollBar &scroll void Viewer::wheelEvent(QWheelEvent *event) { if (render->hasLoadedComic()) { - if (event->orientation() == Qt::Horizontal) { - animateScroll(*horizontalScroller, *horizontalScrollBar(), event->delta()); + if (event->pixelDelta().x() != 0) { + animateScroll(*horizontalScroller, *horizontalScrollBar(), event->pixelDelta().x()); return; } - if ((event->delta() < 0) && (verticalScrollBar()->sliderPosition() == verticalScrollBar()->maximum())) { + if ((event->pixelDelta().y() < 0) && (verticalScrollBar()->sliderPosition() == verticalScrollBar()->maximum())) { if (wheelStop || verticalScrollBar()->maximum() == verticalScrollBar()->minimum()) { if (getMovement(event) == Forward) { next(); @@ -706,7 +706,7 @@ void Viewer::wheelEvent(QWheelEvent *event) } else wheelStop = true; } else { - if ((event->delta() > 0) && (verticalScrollBar()->sliderPosition() == verticalScrollBar()->minimum())) { + if ((event->pixelDelta().y() > 0) && (verticalScrollBar()->sliderPosition() == verticalScrollBar()->minimum())) { if (wheelStop || verticalScrollBar()->maximum() == verticalScrollBar()->minimum()) { if (getMovement(event) == Backward) { prev(); @@ -720,7 +720,7 @@ void Viewer::wheelEvent(QWheelEvent *event) } } - animateScroll(*verticalScroller, *verticalScrollBar(), event->delta()); + animateScroll(*verticalScroller, *verticalScrollBar(), event->pixelDelta().y()); } } From 052e7ffba004b2e2083ca0ddbe47130ec7649344 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Fri, 1 Oct 2021 20:07:34 +0200 Subject: [PATCH 31/93] Add override annotation --- YACReader/goto_flow_gl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/YACReader/goto_flow_gl.h b/YACReader/goto_flow_gl.h index e5d07a5c..34ede703 100644 --- a/YACReader/goto_flow_gl.h +++ b/YACReader/goto_flow_gl.h @@ -24,7 +24,7 @@ public: void setNumSlides(unsigned int slides) override; void setImageReady(int index, const QByteArray &image) override; - void updateConfig(QSettings *settings); + void updateConfig(QSettings *settings) override; void setFlowRightToLeft(bool b) override; private: From ae43f23c859fed95cf5a44bda7d1bc11d4234360 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Fri, 1 Oct 2021 20:23:20 +0200 Subject: [PATCH 32/93] Use angleDelta pixelDelta is only provided in systems that support it --- YACReader/goto_flow.cpp | 2 +- YACReader/magnifying_glass.cpp | 8 ++++---- YACReader/viewer.cpp | 12 +++++++----- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/YACReader/goto_flow.cpp b/YACReader/goto_flow.cpp index 615204df..325a5259 100644 --- a/YACReader/goto_flow.cpp +++ b/YACReader/goto_flow.cpp @@ -195,7 +195,7 @@ void GoToFlow::updateImageData() void GoToFlow::wheelEvent(QWheelEvent *event) { - if (event->pixelDelta().y() < 0) + if (event->angleDelta().y() < 0) flow->showNext(); else flow->showPrevious(); diff --git a/YACReader/magnifying_glass.cpp b/YACReader/magnifying_glass.cpp index cccd028a..28cce728 100644 --- a/YACReader/magnifying_glass.cpp +++ b/YACReader/magnifying_glass.cpp @@ -144,28 +144,28 @@ void MagnifyingGlass::wheelEvent(QWheelEvent *event) switch (event->modifiers()) { // size case Qt::NoModifier: - if (event->pixelDelta().y() < 0) + if (event->angleDelta().y() < 0) sizeUp(); else sizeDown(); break; // size height case Qt::ControlModifier: - if (event->pixelDelta().y() < 0) + if (event->angleDelta().y() < 0) heightUp(); else heightDown(); break; // size width case Qt::AltModifier: - if (event->pixelDelta().y() < 0) + if (event->angleDelta().y() < 0) widthUp(); else widthDown(); break; // zoom level case Qt::ShiftModifier: - if (event->pixelDelta().y() < 0) + if (event->angleDelta().y() < 0) zoomIn(); else zoomOut(); diff --git a/YACReader/viewer.cpp b/YACReader/viewer.cpp index 029f306f..2ac31308 100644 --- a/YACReader/viewer.cpp +++ b/YACReader/viewer.cpp @@ -688,13 +688,15 @@ static void animateScroll(QPropertyAnimation &scroller, const QScrollBar &scroll void Viewer::wheelEvent(QWheelEvent *event) { + auto delta = event->angleDelta(); + if (render->hasLoadedComic()) { - if (event->pixelDelta().x() != 0) { - animateScroll(*horizontalScroller, *horizontalScrollBar(), event->pixelDelta().x()); + if (delta.x() != 0) { + animateScroll(*horizontalScroller, *horizontalScrollBar(), delta.x()); return; } - if ((event->pixelDelta().y() < 0) && (verticalScrollBar()->sliderPosition() == verticalScrollBar()->maximum())) { + if ((delta.y() < 0) && (verticalScrollBar()->sliderPosition() == verticalScrollBar()->maximum())) { if (wheelStop || verticalScrollBar()->maximum() == verticalScrollBar()->minimum()) { if (getMovement(event) == Forward) { next(); @@ -706,7 +708,7 @@ void Viewer::wheelEvent(QWheelEvent *event) } else wheelStop = true; } else { - if ((event->pixelDelta().y() > 0) && (verticalScrollBar()->sliderPosition() == verticalScrollBar()->minimum())) { + if ((delta.y() > 0) && (verticalScrollBar()->sliderPosition() == verticalScrollBar()->minimum())) { if (wheelStop || verticalScrollBar()->maximum() == verticalScrollBar()->minimum()) { if (getMovement(event) == Backward) { prev(); @@ -720,7 +722,7 @@ void Viewer::wheelEvent(QWheelEvent *event) } } - animateScroll(*verticalScroller, *verticalScrollBar(), event->pixelDelta().y()); + animateScroll(*verticalScroller, *verticalScrollBar(), delta.y()); } } From d5e6623e33d1937b5be719460080c9786a7ad228 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Fri, 1 Oct 2021 20:24:05 +0200 Subject: [PATCH 33/93] Fix connections signals can be chained and setCenter was an slot not a signal --- YACReader/goto_flow_toolbar.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/YACReader/goto_flow_toolbar.cpp b/YACReader/goto_flow_toolbar.cpp index 41ea3253..bf2b1e9f 100644 --- a/YACReader/goto_flow_toolbar.cpp +++ b/YACReader/goto_flow_toolbar.cpp @@ -32,8 +32,8 @@ GoToFlowToolBar::GoToFlowToolBar(QWidget *parent) " border-radius: 1px;" "}"); - connect(slider, &QSlider::valueChanged, this, [&](int v) { emit setCenter(v); }); - connect(slider, &QSlider::valueChanged, this, [=](int v) { emit goToPage(v); }); + connect(slider, &QSlider::valueChanged, this, &GoToFlowToolBar::setCenter); + connect(slider, &QSlider::valueChanged, this, &GoToFlowToolBar::setPage); pageHint = new QLabel("" + tr("Page : ") + "", this); v = new QIntValidator(this); From f5035b4bacf5a978901d33f912b4244784fa4629 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Fri, 1 Oct 2021 20:24:27 +0200 Subject: [PATCH 34/93] Use fully qualified names --- YACReader/main_window_viewer.cpp | 2 +- YACReader/main_window_viewer.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/YACReader/main_window_viewer.cpp b/YACReader/main_window_viewer.cpp index 2faaee1f..8f9e496f 100644 --- a/YACReader/main_window_viewer.cpp +++ b/YACReader/main_window_viewer.cpp @@ -858,7 +858,7 @@ void MainWindowViewer::open(QString path, ComicDB &comic, QList &siblin optionsDialog->setFilters(currentComicDB.info.brightness, currentComicDB.info.contrast, currentComicDB.info.gamma); } -void MainWindowViewer::open(QString path, qint64 comicId, qint64 libraryId, OpenComicSource source) +void MainWindowViewer::open(QString path, qint64 comicId, qint64 libraryId, YACReader::OpenComicSource source) { currentDirectory = path; diff --git a/YACReader/main_window_viewer.h b/YACReader/main_window_viewer.h index f2edee90..2c83c054 100644 --- a/YACReader/main_window_viewer.h +++ b/YACReader/main_window_viewer.h @@ -35,7 +35,7 @@ class MainWindowViewer : public QMainWindow public slots: void open(); void open(QString path, ComicDB &comic, QList &siblings); - void open(QString path, qint64 comicId, qint64 libraryId, OpenComicSource source); + void open(QString path, qint64 comicId, qint64 libraryId, YACReader::OpenComicSource source); void openFolder(); void openRecent(); void openLatestComic(); From 567c00102daf70f72e66681ea993533c9f4d7572 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Fri, 1 Oct 2021 20:24:43 +0200 Subject: [PATCH 35/93] Use fully qualified names --- YACReader/goto_flow_widget.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/YACReader/goto_flow_widget.h b/YACReader/goto_flow_widget.h index 03130fa7..1cb26d14 100644 --- a/YACReader/goto_flow_widget.h +++ b/YACReader/goto_flow_widget.h @@ -25,7 +25,7 @@ public slots: virtual void reset() = 0; virtual void centerSlide(int slide) = 0; virtual void setPageNumber(int page); - virtual void setFlowType(FlowType flowType) = 0; + virtual void setFlowType(YACReader::FlowType flowType) = 0; virtual void setNumSlides(unsigned int slides) = 0; virtual void setImageReady(int index, const QByteArray &image) = 0; virtual void updateSize(); From 154f215c38fd5b743447aaed46a6db3d7b3e1302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Fri, 1 Oct 2021 20:25:01 +0200 Subject: [PATCH 36/93] Use 4 args connect --- YACReader/options_dialog.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/YACReader/options_dialog.cpp b/YACReader/options_dialog.cpp index 16f06509..5ea3890a 100644 --- a/YACReader/options_dialog.cpp +++ b/YACReader/options_dialog.cpp @@ -137,7 +137,7 @@ OptionsDialog::OptionsDialog(QWidget *parent) auto scaleBox = new QGroupBox(tr("Fit options")); auto scaleLayout = new QVBoxLayout(); scaleCheckbox = new QCheckBox(tr("Enlarge images to fit width/height")); - connect(scaleCheckbox, &QCheckBox::clicked, + connect(scaleCheckbox, &QCheckBox::clicked, scaleCheckbox, [=](bool checked) { Configuration::getConfiguration().setEnlargeImages(checked); emit changedImageOptions(); @@ -150,7 +150,7 @@ OptionsDialog::OptionsDialog(QWidget *parent) auto doublePageBox = new QGroupBox(tr("Double Page options")); auto doublePageBoxLayout = new QVBoxLayout(); coverSPCheckBox = new QCheckBox(tr("Show covers as single page")); - connect(coverSPCheckBox, &QCheckBox::clicked, + connect(coverSPCheckBox, &QCheckBox::clicked, coverSPCheckBox, [=](bool checked) { settings->setValue(COVER_IS_SP, checked); emit changedImageOptions(); From 100e1c40a1498b4625c57203e1f09904a6aa1e5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Fri, 1 Oct 2021 20:25:21 +0200 Subject: [PATCH 37/93] Use QTransform instead of QMatrix --- YACReader/render.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/YACReader/render.cpp b/YACReader/render.cpp index 9139c504..a0218a68 100644 --- a/YACReader/render.cpp +++ b/YACReader/render.cpp @@ -348,7 +348,7 @@ void PageRender::run() QImage img; img.loadFromData(data); if (degrees > 0) { - QMatrix m; + QTransform m; m.rotate(degrees); img = img.transformed(m, Qt::SmoothTransformation); } From 09e85e48bf483e534dfa6a8ab26aa65652d4bba9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Fri, 1 Oct 2021 20:25:38 +0200 Subject: [PATCH 38/93] Remove unused include --- YACReader/translator.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/YACReader/translator.cpp b/YACReader/translator.cpp index 5915b50d..a5cbf4ca 100644 --- a/YACReader/translator.cpp +++ b/YACReader/translator.cpp @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include From 088ccdf09493d0ab99f708b9a241099111243120 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Fri, 1 Oct 2021 20:26:35 +0200 Subject: [PATCH 39/93] Remove setMargin usage --- YACReader/translator.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/YACReader/translator.cpp b/YACReader/translator.cpp index a5cbf4ca..d3a81979 100644 --- a/YACReader/translator.cpp +++ b/YACReader/translator.cpp @@ -143,7 +143,6 @@ YACReaderTranslator::YACReaderTranslator(Viewer *parent) resize(400, 479); - layout->setMargin(0); layout->setContentsMargins(18, 12, 18, 12); setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); From 5e1e0b1d4a0c5b1866958d4aa7f65f164ff27bda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Fri, 1 Oct 2021 20:26:49 +0200 Subject: [PATCH 40/93] Add include --- YACReader/width_slider.h | 1 + 1 file changed, 1 insertion(+) diff --git a/YACReader/width_slider.h b/YACReader/width_slider.h index 3a7c2570..df5522ff 100644 --- a/YACReader/width_slider.h +++ b/YACReader/width_slider.h @@ -2,6 +2,7 @@ #define WIDTH_SLIDER_H #include +#include class QLabel; class QSlider; From 8207f75297078c63117586befd1e3f486071cf92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Fri, 1 Oct 2021 20:34:18 +0200 Subject: [PATCH 41/93] Replace setMargin with setContentsMargins --- YACReader/width_slider.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/YACReader/width_slider.cpp b/YACReader/width_slider.cpp index 1b13f1f0..70912043 100644 --- a/YACReader/width_slider.cpp +++ b/YACReader/width_slider.cpp @@ -55,7 +55,7 @@ YACReaderSlider::YACReaderSlider(QWidget *parent) pLayout->addWidget(resetButton, 1, Qt::AlignHCenter | Qt::AlignBottom); pLayout->setSpacing(elementsSpacing); - pLayout->setMargin(0); + pLayout->setContentsMargins(0, 0, 0, 0); setLayout(pLayout); setAutoFillBackground(false); From d47bd55fa04f63f95b4f6f75014287cdb255204c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sat, 2 Oct 2021 07:55:01 +0200 Subject: [PATCH 42/93] Don't use helper function to avoid raising the Qt5 min version requeriment --- common/comic.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/comic.cpp b/common/comic.cpp index 5051ed32..0349bf93 100644 --- a/common/comic.cpp +++ b/common/comic.cpp @@ -1002,7 +1002,7 @@ QString get_most_common_prefix(const QList &pageNames) } } - QRegularExpression allNumberRegExp(QRegularExpression::anchoredPattern("\\d+")); + QRegularExpression allNumberRegExp("\\A\\d+\\z"); if (allNumberRegExp.match(common_prefix).hasMatch()) { return ""; } From dc8c6e23e9ae738c8ca2be8f4462e0934ee72cc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sat, 2 Oct 2021 07:57:42 +0200 Subject: [PATCH 43/93] Use angleDelta instead of delta --- common/scroll_management.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/scroll_management.cpp b/common/scroll_management.cpp index 0fdd5dbc..a9573037 100644 --- a/common/scroll_management.cpp +++ b/common/scroll_management.cpp @@ -23,10 +23,10 @@ ScrollManagement::Movement ScrollManagement::getMovement(QWheelEvent *event) } // Accumulate the delta - if ((event->delta() < 0) != (wheelAccumulator < 0)) // different sign means change in direction + if ((event->angleDelta().y() < 0) != (wheelAccumulator < 0)) // different sign means change in direction wheelAccumulator = 0; - wheelAccumulator += event->delta(); + wheelAccumulator += event->angleDelta().y(); // Do not process events too fast if ((wheelTimer->elapsed() < timeThrottle)) { From 5fbd100449fc348b280a73530bab2970ed922530 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sat, 2 Oct 2021 07:58:19 +0200 Subject: [PATCH 44/93] Use non deprecated QStandardPaths and remove Qt4 alternative --- common/yacreader_global.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/common/yacreader_global.cpp b/common/yacreader_global.cpp index 53d2bf75..f802c1e4 100644 --- a/common/yacreader_global.cpp +++ b/common/yacreader_global.cpp @@ -4,11 +4,7 @@ using namespace YACReader; QString YACReader::getSettingsPath() { -#if QT_VERSION >= 0x050000 - return QStandardPaths::writableLocation(QStandardPaths::DataLocation); -#else - return QDesktopServices::storageLocation(QDesktopServices::DataLocation); -#endif + return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation); } QString YACReader::colorToName(LabelColors colors) From a7e3c41f34061b0971898c8ca7ccc5ab71914650 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sat, 2 Oct 2021 08:07:15 +0200 Subject: [PATCH 45/93] QLabel QPixmap *pixmap() method is deprecated const QPixmap should perform as fast as a pointer there is a replacement version for Qt5 but it requires Qt5.15, so we are using indirection witch is unsafer but it should be ok as all the action is happen in the main thread --- YACReader/magnifying_glass.cpp | 30 +++++++++++++++--------------- YACReader/main_window_viewer.cpp | 7 ++++--- YACReader/viewer.cpp | 6 +++++- YACReader/viewer.h | 2 +- 4 files changed, 25 insertions(+), 20 deletions(-) diff --git a/YACReader/magnifying_glass.cpp b/YACReader/magnifying_glass.cpp index 28cce728..9db4b137 100644 --- a/YACReader/magnifying_glass.cpp +++ b/YACReader/magnifying_glass.cpp @@ -38,9 +38,9 @@ void MagnifyingGlass::updateImage(int x, int y) int zoomHeight = static_cast(height() * zoomLevel); auto p = (Viewer *)parent(); int currentPos = p->verticalScrollBar()->sliderPosition(); - const QPixmap *image = p->pixmap(); - int iWidth = image->width(); - int iHeight = image->height(); + const QPixmap image = p->pixmap(); + int iWidth = image.width(); + int iHeight = image.height(); float wFactor = static_cast(iWidth) / p->widget()->width(); float hFactor = static_cast(iHeight) / p->widget()->height(); zoomWidth *= wFactor; @@ -67,12 +67,12 @@ void MagnifyingGlass::updateImage(int x, int y) outImage = true; } - if (xp + zoomWidth >= image->width()) { - zw -= xp + zw - image->width(); + if (xp + zoomWidth >= image.width()) { + zw -= xp + zw - image.width(); outImage = true; } - if (yp + zoomHeight >= image->height()) { - zh -= yp + zh - image->height(); + if (yp + zoomHeight >= image.height()) { + zh -= yp + zh - image.height(); outImage = true; } if (outImage) { @@ -81,11 +81,11 @@ void MagnifyingGlass::updateImage(int x, int y) img.fill(Configuration::getConfiguration().getBackgroundColor()); if (zw > 0 && zh > 0) { QPainter painter(&img); - painter.drawPixmap(xOffset, yOffset, image->copy(xp, yp, zw, zh)); + painter.drawPixmap(xOffset, yOffset, image.copy(xp, yp, zw, zh)); } setPixmap(QPixmap().fromImage(img)); } else - setPixmap(image->copy(xp, yp, zoomWidth, zoomHeight)); + setPixmap(image.copy(xp, yp, zoomWidth, zoomHeight)); } else { int xp = static_cast(((x - p->widget()->pos().x()) * wFactor) - zoomWidth / 2); int yp = static_cast((y + currentPos) * hFactor - zoomHeight / 2); @@ -108,12 +108,12 @@ void MagnifyingGlass::updateImage(int x, int y) outImage = true; } - if (xp + zoomWidth >= image->width()) { - zw -= xp + zw - image->width(); + if (xp + zoomWidth >= image.width()) { + zw -= xp + zw - image.width(); outImage = true; } - if (yp + zoomHeight >= image->height()) { - zh -= yp + zh - image->height(); + if (yp + zoomHeight >= image.height()) { + zh -= yp + zh - image.height(); outImage = true; } if (outImage) { @@ -122,11 +122,11 @@ void MagnifyingGlass::updateImage(int x, int y) img.fill(Configuration::getConfiguration().getBackgroundColor()); if (zw > 0 && zh > 0) { QPainter painter(&img); - painter.drawPixmap(xOffset, yOffset, image->copy(xp, yp, zw, zh)); + painter.drawPixmap(xOffset, yOffset, image.copy(xp, yp, zw, zh)); } setPixmap(QPixmap().fromImage(img)); } else - setPixmap(image->copy(xp, yp, zoomWidth, zoomHeight)); + setPixmap(image.copy(xp, yp, zoomWidth, zoomHeight)); } move(static_cast(x - float(width()) / 2), static_cast(y - float(height()) / 2)); } diff --git a/YACReader/main_window_viewer.cpp b/YACReader/main_window_viewer.cpp index 8f9e496f..9bd53f53 100644 --- a/YACReader/main_window_viewer.cpp +++ b/YACReader/main_window_viewer.cpp @@ -978,9 +978,10 @@ void MainWindowViewer::saveImage() if (!pathFile.isEmpty()) { QFileInfo fi(pathFile); currentDirectoryImgDest = fi.absolutePath(); - const QPixmap *p = viewer->pixmap(); - if (p != nullptr) - p->save(pathFile); + const QPixmap p = viewer->pixmap(); + if (!p.isNull()) { + p.save(pathFile); + } } } diff --git a/YACReader/viewer.cpp b/YACReader/viewer.cpp index 2ac31308..bf7df3b9 100644 --- a/YACReader/viewer.cpp +++ b/YACReader/viewer.cpp @@ -773,9 +773,13 @@ void Viewer::mouseMoveEvent(QMouseEvent *event) } } -const QPixmap *Viewer::pixmap() +const QPixmap Viewer::pixmap() { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) return content->pixmap(); +#else + return *(content->pixmap()); +#endif } void Viewer::magnifyingGlassSwitch() diff --git a/YACReader/viewer.h b/YACReader/viewer.h index f7aab2ed..393815d9 100644 --- a/YACReader/viewer.h +++ b/YACReader/viewer.h @@ -178,7 +178,7 @@ private: public: Viewer(QWidget *parent = nullptr); ~Viewer(); - const QPixmap *pixmap(); + const QPixmap pixmap(); // Comic * getComic(){return comic;} const BookmarksDialog *getBookmarksDialog() { return bd; } // returns the current index starting in 1 [1,nPages] From e7f3d294779f69da9c18c90eeac2c4f2f3652a27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sun, 3 Oct 2021 12:35:23 +0200 Subject: [PATCH 46/93] Tag ComicDB::operator== as const --- common/comic_db.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/comic_db.h b/common/comic_db.h index 926a2193..30b893f3 100644 --- a/common/comic_db.h +++ b/common/comic_db.h @@ -253,7 +253,7 @@ public: Q_PROPERTY(ComicInfo info MEMBER info) ComicDB &operator=(const ComicDB &other); - bool operator==(const ComicDB &other) { return id == other.id; } + bool operator==(const ComicDB &other) const { return id == other.id; } friend QDataStream &operator<<(QDataStream &, const ComicDB &); friend QDataStream &operator>>(QDataStream &, ComicDB &); From 75060d4f249c94dd3d14349016243e70aa1222d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sun, 3 Oct 2021 12:36:57 +0200 Subject: [PATCH 47/93] Do not use QTextCodec in Qt6 --- YACReader/shortcuts_dialog.cpp | 9 +++++++++ custom_widgets/help_about_dialog.cpp | 9 ++++++++- third_party/QsLog/QsLogDestFile.cpp | 17 +++++++++++++++-- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/YACReader/shortcuts_dialog.cpp b/YACReader/shortcuts_dialog.cpp index af960c92..3994656d 100644 --- a/YACReader/shortcuts_dialog.cpp +++ b/YACReader/shortcuts_dialog.cpp @@ -6,7 +6,10 @@ #include #include #include + +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) #include +#endif ShortcutsDialog::ShortcutsDialog(QWidget *parent) : QDialog(parent) //,Qt::FramelessWindowHint) @@ -44,7 +47,13 @@ ShortcutsDialog::ShortcutsDialog(QWidget *parent) QFile f(":/files/shortcuts.html"); f.open(QIODevice::ReadOnly); QTextStream txtS(&f); + +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + txtS.setEncoding(QStringConverter::Utf8); +#else txtS.setCodec(QTextCodec::codecForName("UTF-8")); +#endif + QString content = txtS.readAll(); f.close(); diff --git a/custom_widgets/help_about_dialog.cpp b/custom_widgets/help_about_dialog.cpp index c2e8db47..d2ff2286 100644 --- a/custom_widgets/help_about_dialog.cpp +++ b/custom_widgets/help_about_dialog.cpp @@ -6,9 +6,12 @@ #include #include #include -#include #include +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#include +#endif + #include "yacreader_global.h" HelpAboutDialog::HelpAboutDialog(QWidget *parent) @@ -80,7 +83,11 @@ QString HelpAboutDialog::fileToString(const QString &path) f.open(QIODevice::ReadOnly); QTextStream txtS(&f); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + txtS.setEncoding(QStringConverter::Utf8); +#else txtS.setCodec(QTextCodec::codecForName("UTF-8")); +#endif QString content = txtS.readAll(); f.close(); diff --git a/third_party/QsLog/QsLogDestFile.cpp b/third_party/QsLog/QsLogDestFile.cpp index 3986cd49..331d0a09 100644 --- a/third_party/QsLog/QsLogDestFile.cpp +++ b/third_party/QsLog/QsLogDestFile.cpp @@ -24,12 +24,15 @@ // OF THE POSSIBILITY OF SUCH DAMAGE. #include "QsLogDestFile.h" -#include #include #include #include #include +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#include +#endif + const int QsLogging::SizeRotationStrategy::MaxBackupCount = 10; QsLogging::RotationStrategy::~RotationStrategy() noexcept = default; @@ -148,8 +151,14 @@ QsLogging::FileDestination::FileDestination(const QString& filePath, RotationStr if (!mFile.open(QFile::WriteOnly | QFile::Text | mRotationStrategy->recommendedOpenModeFlag())) { std::cerr << "QsLog: could not open log file " << qPrintable(filePath); } + mOutputStream.setDevice(&mFile); + +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + mOutputStream.setEncoding(QStringConverter::Utf8); +#else mOutputStream.setCodec(QTextCodec::codecForName("UTF-8")); +#endif mRotationStrategy->setInitialInfo(mFile); } @@ -167,10 +176,14 @@ void QsLogging::FileDestination::write(const LogMessage& message) } mRotationStrategy->setInitialInfo(mFile); mOutputStream.setDevice(&mFile); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + mOutputStream.setEncoding(QStringConverter::Utf8); +#else mOutputStream.setCodec(QTextCodec::codecForName("UTF-8")); +#endif } - mOutputStream << utf8Message << endl; + mOutputStream << utf8Message << Qt::endl; mOutputStream.flush(); } From e91481d0c3b88f2797b6ed8d7cf4544a32f42d51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sun, 3 Oct 2021 12:37:37 +0200 Subject: [PATCH 48/93] Fix QMediaPlayer usage in Qt6 --- YACReader/translator.cpp | 22 +++++----------------- YACReader/translator.h | 10 ---------- 2 files changed, 5 insertions(+), 27 deletions(-) diff --git a/YACReader/translator.cpp b/YACReader/translator.cpp index d3a81979..dcae81c0 100644 --- a/YACReader/translator.cpp +++ b/YACReader/translator.cpp @@ -287,26 +287,14 @@ void YACReaderTranslator::populateCombos() void YACReaderTranslator::play() { - // QMessageBox::question(this,"xxx",ttsSource.toString()); -#if QT_VERSION >= 0x050000 +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + player->setSource(ttsSource); +#else player->setMedia(ttsSource); +#endif + player->play(); - -#else - MediaSource src(ttsSource); - src.setAutoDelete(true); - music->setCurrentSource(src); - music->play(); -#endif -} - -YACReaderTranslator::~YACReaderTranslator() -{ -#if QT_VERSION >= 0x050000 -#else - delete music; -#endif } void YACReaderTranslator::mousePressEvent(QMouseEvent *event) diff --git a/YACReader/translator.h b/YACReader/translator.h index 189c8fb8..be50f8b6 100644 --- a/YACReader/translator.h +++ b/YACReader/translator.h @@ -15,19 +15,13 @@ class YACReaderBusyWidget; #include #include "viewer.h" -#if QT_VERSION >= 0x050000 class QMediaPlayer; -#else -#include -using namespace Phonon; -#endif class YACReaderTranslator : public QWidget { Q_OBJECT public: YACReaderTranslator(Viewer *parent = nullptr); - ~YACReaderTranslator() override; public slots: void play(); @@ -50,11 +44,7 @@ protected: QPoint click; private: -#if QT_VERSION >= 0x050000 QMediaPlayer *player; -#else - MediaObject *music; -#endif QTextEdit *text; QComboBox *from; From 2cdd53c316e6ec0f5dcaa0529fb5cec7d3f48c52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sun, 3 Oct 2021 12:37:58 +0200 Subject: [PATCH 49/93] Replace forward declaration with import --- YACReader/yacreader_local_client.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/YACReader/yacreader_local_client.h b/YACReader/yacreader_local_client.h index 1f4f08e7..b683d694 100644 --- a/YACReader/yacreader_local_client.h +++ b/YACReader/yacreader_local_client.h @@ -2,11 +2,11 @@ #define YACREADER_LOCAL_CLIENT_H #include "yacreader_global.h" +#include "comic_db.h" #include class QLocalSocket; -class ComicDB; class YACReaderLocalClient : public QObject { From 81ff663acda90c6335ce6b8b85cc904a0541fa40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sun, 3 Oct 2021 12:38:32 +0200 Subject: [PATCH 50/93] Use qt5.15 --- YACReader/viewer.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/YACReader/viewer.cpp b/YACReader/viewer.cpp index bf7df3b9..6b595a70 100644 --- a/YACReader/viewer.cpp +++ b/YACReader/viewer.cpp @@ -775,11 +775,7 @@ void Viewer::mouseMoveEvent(QMouseEvent *event) const QPixmap Viewer::pixmap() { -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) return content->pixmap(); -#else - return *(content->pixmap()); -#endif } void Viewer::magnifyingGlassSwitch() From 122082a2a7b83418e8463e3fac27f4ed6f025b7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sun, 3 Oct 2021 12:39:20 +0200 Subject: [PATCH 51/93] Bump c++ version to 17 and configure the projects to use Qt5.15 or newer --- config.pri | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config.pri b/config.pri index 3553c277..940aa6f8 100644 --- a/config.pri +++ b/config.pri @@ -2,7 +2,7 @@ # default values if they're not set on build time # for a more detailed description, see INSTALL.TXT -CONFIG += c++11 +CONFIG += c++17 unix:QMAKE_CXXFLAGS_RELEASE += -DNDEBUG win32:QMAKE_CXXFLAGS_RELEASE += /DNDEBUG @@ -31,11 +31,11 @@ defineTest(minQtVersion) { return(false) } -!minQtVersion(5, 9, 0) { - error(YACReader requires Qt 5.9 or newer but $$[QT_VERSION] was detected) +!minQtVersion(5, 15, 0) { + error(YACReader requires Qt 5.15 or newer but $$[QT_VERSION] was detected) } -DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x050900 +DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x050F00 DEFINES += QT_DEPRECATED_WARNINGS # reduce log pollution From 4dd945c3a6133697f9baea6fe5a46dc56aa27614 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sun, 3 Oct 2021 12:39:50 +0200 Subject: [PATCH 52/93] Add missing include --- shortcuts_management/actions_shortcuts_model.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/shortcuts_management/actions_shortcuts_model.cpp b/shortcuts_management/actions_shortcuts_model.cpp index eb014268..7238b2c7 100644 --- a/shortcuts_management/actions_shortcuts_model.cpp +++ b/shortcuts_management/actions_shortcuts_model.cpp @@ -2,6 +2,7 @@ #include "shortcuts_manager.h" #include +#include ActionsShortcutsModel::ActionsShortcutsModel(QObject *parent) : QAbstractItemModel(parent) From aeb64281e7a7b1fa88dc6e84f3fa552acff2aff5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sun, 3 Oct 2021 12:59:45 +0200 Subject: [PATCH 53/93] Enable /std:c++17 for msvc --- config.pri | 1 + 1 file changed, 1 insertion(+) diff --git a/config.pri b/config.pri index 940aa6f8..0b00b076 100644 --- a/config.pri +++ b/config.pri @@ -3,6 +3,7 @@ # for a more detailed description, see INSTALL.TXT CONFIG += c++17 +win32:QMAKE_CXXFLAGS += /std:c++17 #enable c++17 explicitly in msvc unix:QMAKE_CXXFLAGS_RELEASE += -DNDEBUG win32:QMAKE_CXXFLAGS_RELEASE += /DNDEBUG From 8bcea9cc8d2eb83ad69656821522ff9a9e5f3cc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sun, 3 Oct 2021 20:37:13 +0200 Subject: [PATCH 54/93] Enable core5compat in YACReaderLibraryServer --- YACReaderLibraryServer/YACReaderLibraryServer.pro | 2 ++ 1 file changed, 2 insertions(+) diff --git a/YACReaderLibraryServer/YACReaderLibraryServer.pro b/YACReaderLibraryServer/YACReaderLibraryServer.pro index 54fb3431..6978b181 100644 --- a/YACReaderLibraryServer/YACReaderLibraryServer.pro +++ b/YACReaderLibraryServer/YACReaderLibraryServer.pro @@ -16,6 +16,8 @@ DEFINES += SERVER_RELEASE NOMINMAX YACREADER_LIBRARY include(headless_config.pri) include(../dependencies/pdf_backend.pri) +greaterThan(QT_MAJOR_VERSION, 5): QT += core5compat + win32 { LIBS += -loleaut32 -lole32 -lshell32 -luser32 QMAKE_CXXFLAGS_RELEASE += /MP /Ob2 /Oi /Ot /GT /GL From f11f3f185881989d49f1600384a32ff88a9154e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sun, 3 Oct 2021 20:37:32 +0200 Subject: [PATCH 55/93] Use Qt::endl --- YACReaderLibraryServer/main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/YACReaderLibraryServer/main.cpp b/YACReaderLibraryServer/main.cpp index dc91573c..7d76bdba 100644 --- a/YACReaderLibraryServer/main.cpp +++ b/YACReaderLibraryServer/main.cpp @@ -119,7 +119,7 @@ int main(int argc, char **argv) if (parser.isSet(versionOption)) { qout << "YACReaderLibraryServer" - << " " << VERSION << endl; + << " " << VERSION << Qt::endl; return 0; } @@ -199,7 +199,7 @@ int main(int argc, char **argv) bool valid; qint32 port = parser.value("port").toInt(&valid); if (!valid || port < 1 || port > 65535) { - qout << "Error: " << parser.value("port") << " is not a valid port" << endl; + qout << "Error: " << parser.value("port") << " is not a valid port" << Qt::endl; parser.showHelp(); return 0; } else { @@ -304,7 +304,7 @@ int main(int argc, char **argv) YACReaderLibraries libraries = DBHelper::getLibraries(); for (QString libraryName : libraries.getNames()) - qout << libraryName << " : " << libraries.getPath(libraryName) << endl; + qout << libraryName << " : " << libraries.getPath(libraryName) << Qt::endl; return 0; } else if (command == "set-port") { From 24b2def878626d08b861ee8bdae186dd589bcf5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sun, 3 Oct 2021 21:05:02 +0200 Subject: [PATCH 56/93] Compare with QString --- YACReaderLibrary/xml_info_parser.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/YACReaderLibrary/xml_info_parser.cpp b/YACReaderLibrary/xml_info_parser.cpp index aa51ad73..b144047b 100644 --- a/YACReaderLibrary/xml_info_parser.cpp +++ b/YACReaderLibrary/xml_info_parser.cpp @@ -114,7 +114,7 @@ bool tryValues(QXmlStreamReader &reader, ComicInfo &info) } } - if (reader.name() == "BlackAndWhite") { + if (reader.name() == QString("BlackAndWhite")) { auto string = reader.readElementText(); if (isValidText(string)) { if (string == "Yes") { @@ -127,7 +127,7 @@ bool tryValues(QXmlStreamReader &reader, ComicInfo &info) return true; } - if (reader.name() == "Manga") { + if (reader.name() == QString("Manga")) { auto string = reader.readElementText(); if (isValidText(string)) { if (string == "Yes" || string == "YesAndRightToLeft") { @@ -140,7 +140,7 @@ bool tryValues(QXmlStreamReader &reader, ComicInfo &info) return true; } - if (reader.name() == "Web") { + if (reader.name() == QString("Web")) { auto string = reader.readElementText(); if (isValidText(string)) { auto comicVineId = string.split("-").last().replace("/", ""); @@ -168,7 +168,7 @@ bool YACReader::parseXMLIntoInfo(const QByteArray &xmlRawData, ComicInfo &info) if (tryValues(reader, info)) { someDataWasParsed = true; } else { - if (reader.name() != "ComicInfo") { + if (reader.name() != QString("ComicInfo")) { reader.skipCurrentElement(); } } From baccb1a21b473c17ab767115847bebf1370222bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sun, 3 Oct 2021 21:15:04 +0200 Subject: [PATCH 57/93] Include QRegExp --- YACReaderLibrary/server/requestmapper.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/YACReaderLibrary/server/requestmapper.cpp b/YACReaderLibrary/server/requestmapper.cpp index 6c012f56..c0694c97 100644 --- a/YACReaderLibrary/server/requestmapper.cpp +++ b/YACReaderLibrary/server/requestmapper.cpp @@ -48,6 +48,8 @@ #include "QsLog.h" +#include + using stefanfrings::HttpRequest; using stefanfrings::HttpRequestHandler; using stefanfrings::HttpResponse; From 986450eb20b2c617e7be772a766f2b4c69bbb640 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sun, 3 Oct 2021 21:17:49 +0200 Subject: [PATCH 58/93] Update QtWebApp to 1.8.3 nullptr redefinition for old __cplusplus versions has been removed, the rest is vanilla --- third_party/QtWebApp/CHANGELOG.txt | 21 +++++++++++++ third_party/QtWebApp/README.txt | 15 ++++------ .../httpserver/httpconnectionhandler.cpp | 12 ++++---- .../httpserver/httpconnectionhandler.h | 2 +- .../httpserver/httpconnectionhandlerpool.cpp | 7 +++-- .../QtWebApp/httpserver/httpcookie.cpp | 24 ++++++++++++++- third_party/QtWebApp/httpserver/httpcookie.h | 21 +++++++++---- .../QtWebApp/httpserver/httpglobal.cpp | 2 +- third_party/QtWebApp/httpserver/httpglobal.h | 1 - .../QtWebApp/httpserver/httplistener.cpp | 2 +- .../QtWebApp/httpserver/httprequest.cpp | 3 +- third_party/QtWebApp/httpserver/httpsession.h | 3 +- .../QtWebApp/httpserver/httpsessionstore.cpp | 10 +++++-- .../QtWebApp/httpserver/httpsessionstore.h | 8 +++++ .../httpserver/staticfilecontroller.cpp | 3 +- .../QtWebApp/templateengine/template.h | 1 - .../QtWebApp/templateengine/templatecache.cpp | 3 +- .../templateengine/templateengine.pri | 4 +++ .../templateengine/templateloader.cpp | 30 +++++++++++++++---- .../QtWebApp/templateengine/templateloader.h | 2 +- 20 files changed, 131 insertions(+), 43 deletions(-) diff --git a/third_party/QtWebApp/CHANGELOG.txt b/third_party/QtWebApp/CHANGELOG.txt index e24ec4af..19183495 100644 --- a/third_party/QtWebApp/CHANGELOG.txt +++ b/third_party/QtWebApp/CHANGELOG.txt @@ -1,6 +1,27 @@ Dont forget to update the release number also in QtWebApp.pro and httpserver/httpglobal.cpp. +1.8.3 +21.03.2021 +The minLevel for logging can now be configured as string: +DEBUG/ALL=0, INFO=4, WARNING=1, ERROR/CRITICAL=2, FATAL=3 +Info messages are now positioned between DEBUG and WARNING. +I also added an example for HTTP Basic authorization. + +1.8.2 +08.03.2021 +Fix threadId not printed in log file. + +1.8.1 +07.02.2021 +Add Cookie attribute "SameSite". +SessionStore does now emit a signal when a session expires. + +1.8.0 +06.02.2021 +Fix compatibility issues to Qt 4.7 and 6.0. +Removed qtservice, use the Non-Sucking Service Manager (https://nssm.cc/) instead. + 1.7.11 28.12.2019 Fix Http Headers are not properly received if the two characters of diff --git a/third_party/QtWebApp/README.txt b/third_party/QtWebApp/README.txt index 50c73a34..e9b2f575 100644 --- a/third_party/QtWebApp/README.txt +++ b/third_party/QtWebApp/README.txt @@ -1,25 +1,22 @@ QtWebAppLib is a library to develop server-side web applications in C++. -It requires the Qt SDK version 4.7.0 or newer. +Works with Qt SDK version 4.7 until at least 6.0 License: LGPL v3. -Project homepage: http://stefanfrings.de/qtwebapp/index.html +Project homepage: http://stefanfrings.de/qtwebapp/index-en.html Tutorial: http://stefanfrings.de/qtwebapp/tutorial/index.html API doc: http://stefanfrings.de/qtwebapp/api/index.html -There are three demo applications that demonstrate how to use the library. +In Qt 6.0 or newer, you must install the optional "core5compat" component. +This package contains the QTextCodec class which is needed to decode template files. +It supports a lot more encodings, for example ISO-8859-15 with the EUR symbol. Demo1 shows how to use the library by including the source code into your -project. This does not depend on the shared library. +project, the preferred method. Demo2 shows how to link against the shared library. Build the project QtWebApp to generate the shared library. -Demo3 shows how to use the qtservice component to start the application -as a Windows Service or Unix daemon. Start it with option -h to get help. - -I recommend to include the library by source as shown in Demo1 and 3. - Stefan Frings http://stefanfrings.de diff --git a/third_party/QtWebApp/httpserver/httpconnectionhandler.cpp b/third_party/QtWebApp/httpserver/httpconnectionhandler.cpp index f5fb8327..849425d3 100644 --- a/third_party/QtWebApp/httpserver/httpconnectionhandler.cpp +++ b/third_party/QtWebApp/httpserver/httpconnectionhandler.cpp @@ -28,16 +28,16 @@ HttpConnectionHandler::HttpConnectionHandler(const QSettings *settings, HttpRequ readTimer.setSingleShot(true); // Create TCP or SSL socket - createSocket(); + createSocket(); socket->moveToThread(thread); // Connect signals - connect(socket, &QIODevice::readyRead, this, &HttpConnectionHandler::read); - connect(socket, &QAbstractSocket::disconnected, this, &HttpConnectionHandler::disconnected); - connect(&readTimer, &QTimer::timeout, this, &HttpConnectionHandler::readTimeout); - connect(thread, &QThread::finished, this, &HttpConnectionHandler::thread_done); + connect(socket, SIGNAL(readyRead()), SLOT(read())); + connect(socket, SIGNAL(disconnected()), SLOT(disconnected())); + connect(&readTimer, SIGNAL(timeout()), SLOT(readTimeout())); + connect(thread, SIGNAL(finished()), this, SLOT(thread_done())); - qDebug("HttpConnectionHandler (%p): constructed", static_cast(this)); + qDebug("HttpConnectionHandler (%p): constructed", static_cast(this)); } diff --git a/third_party/QtWebApp/httpserver/httpconnectionhandler.h b/third_party/QtWebApp/httpserver/httpconnectionhandler.h index bf9bffac..fc03cc1d 100644 --- a/third_party/QtWebApp/httpserver/httpconnectionhandler.h +++ b/third_party/QtWebApp/httpserver/httpconnectionhandler.h @@ -20,7 +20,7 @@ namespace stefanfrings { /** Alias type definition, for compatibility to different Qt versions */ -#if QT_VERSION >= 0x050000 +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) typedef qintptr tSocketDescriptor; #else typedef int tSocketDescriptor; diff --git a/third_party/QtWebApp/httpserver/httpconnectionhandlerpool.cpp b/third_party/QtWebApp/httpserver/httpconnectionhandlerpool.cpp index f22eb087..56a15ec9 100644 --- a/third_party/QtWebApp/httpserver/httpconnectionhandlerpool.cpp +++ b/third_party/QtWebApp/httpserver/httpconnectionhandlerpool.cpp @@ -18,7 +18,7 @@ HttpConnectionHandlerPool::HttpConnectionHandlerPool(const QSettings *settings, this->sslConfiguration=NULL; loadSslConfig(); cleanupTimer.start(settings->value("cleanupInterval",1000).toInt()); - connect(&cleanupTimer, &QTimer::timeout, this, &HttpConnectionHandlerPool::cleanup); + connect(&cleanupTimer, SIGNAL(timeout()), SLOT(cleanup())); } @@ -77,7 +77,8 @@ void HttpConnectionHandlerPool::cleanup() { delete handler; pool.removeOne(handler); - qDebug("HttpConnectionHandlerPool: Removed connection handler (%p), pool size is now %i",handler,pool.size()); + long int poolSize=(long int)pool.size(); + qDebug("HttpConnectionHandlerPool: Removed connection handler (%p), pool size is now %li",handler,poolSize); break; // remove only one handler in each interval } } @@ -140,7 +141,7 @@ void HttpConnectionHandlerPool::loadSslConfig() sslConfiguration->setLocalCertificate(certificate); sslConfiguration->setPrivateKey(sslKey); sslConfiguration->setPeerVerifyMode(QSslSocket::VerifyNone); - sslConfiguration->setProtocol(QSsl::TlsV1SslV3); + sslConfiguration->setProtocol(QSsl::AnyProtocol); qDebug("HttpConnectionHandlerPool: SSL settings loaded"); #endif diff --git a/third_party/QtWebApp/httpserver/httpcookie.cpp b/third_party/QtWebApp/httpserver/httpcookie.cpp index f09a2c37..d85232e8 100644 --- a/third_party/QtWebApp/httpserver/httpcookie.cpp +++ b/third_party/QtWebApp/httpserver/httpcookie.cpp @@ -14,7 +14,9 @@ HttpCookie::HttpCookie() secure=false; } -HttpCookie::HttpCookie(const QByteArray name, const QByteArray value, const int maxAge, const QByteArray path, const QByteArray comment, const QByteArray domain, const bool secure, const bool httpOnly) +HttpCookie::HttpCookie(const QByteArray name, const QByteArray value, const int maxAge, const QByteArray path, + const QByteArray comment, const QByteArray domain, const bool secure, const bool httpOnly, + const QByteArray sameSite) { this->name=name; this->value=value; @@ -24,6 +26,7 @@ HttpCookie::HttpCookie(const QByteArray name, const QByteArray value, const int this->domain=domain; this->secure=secure; this->httpOnly=httpOnly; + this->sameSite=sameSite; this->version=1; } @@ -32,6 +35,7 @@ HttpCookie::HttpCookie(const QByteArray source) version=1; maxAge=0; secure=false; + httpOnly=false; QList list=splitCSV(source); foreach(QByteArray part, list) { @@ -76,6 +80,10 @@ HttpCookie::HttpCookie(const QByteArray source) { httpOnly=true; } + else if (name=="SameSite") + { + sameSite=value; + } else if (name=="Version") { version=value.toInt(); @@ -125,6 +133,10 @@ QByteArray HttpCookie::toByteArray() const if (httpOnly) { buffer.append("; HttpOnly"); } + if (!sameSite.isEmpty()) { + buffer.append("; SameSite="); + buffer.append(sameSite); + } buffer.append("; Version="); buffer.append(QByteArray::number(version)); return buffer; @@ -170,6 +182,11 @@ void HttpCookie::setHttpOnly(const bool httpOnly) this->httpOnly=httpOnly; } +void HttpCookie::setSameSite(const QByteArray sameSite) +{ + this->sameSite=sameSite; +} + QByteArray HttpCookie::getName() const { return name; @@ -210,6 +227,11 @@ bool HttpCookie::getHttpOnly() const return httpOnly; } +QByteArray HttpCookie::getSameSite() const +{ + return sameSite; +} + int HttpCookie::getVersion() const { return version; diff --git a/third_party/QtWebApp/httpserver/httpcookie.h b/third_party/QtWebApp/httpserver/httpcookie.h index f649f15f..f46cebd3 100644 --- a/third_party/QtWebApp/httpserver/httpcookie.h +++ b/third_party/QtWebApp/httpserver/httpcookie.h @@ -13,9 +13,8 @@ namespace stefanfrings { /** - HTTP cookie as defined in RFC 2109. This class can also parse - RFC 2965 cookies, but skips fields that are not defined in RFC - 2109. + HTTP cookie as defined in RFC 2109. + Supports some additional attributes of RFC6265bis. */ class DECLSPEC HttpCookie @@ -35,11 +34,13 @@ public: @param domain Optional domain for that the cookie will be sent. Defaults to the current domain @param secure If true, the cookie will be sent by the browser to the server only on secure connections @param httpOnly If true, the browser does not allow client-side scripts to access the cookie + @param sameSite Declare if the cookie can only be read by the same site, which is a stronger + restriction than the domain. Allowed values: "Lax" and "Strict". */ HttpCookie(const QByteArray name, const QByteArray value, const int maxAge, const QByteArray path="/", const QByteArray comment=QByteArray(), const QByteArray domain=QByteArray(), const bool secure=false, - const bool httpOnly=false); + const bool httpOnly=false, const QByteArray sameSite=QByteArray()); /** Create a cookie from a string. @@ -77,9 +78,15 @@ public: /** Set secure mode, so that the cookie will be sent by the browser to the server only on secure connections */ void setSecure(const bool secure); - /** Set HTTP-only mode, so that he browser does not allow client-side scripts to access the cookie */ + /** Set HTTP-only mode, so that the browser does not allow client-side scripts to access the cookie */ void setHttpOnly(const bool httpOnly); + /** + * Set same-site mode, so that the browser does not allow other web sites to access the cookie. + * Allowed values: "Lax" and "Strict". + */ + void setSameSite(const QByteArray sameSite); + /** Get the name of this cookie */ QByteArray getName() const; @@ -104,6 +111,9 @@ public: /** Get the HTTP-only flag of this cookie */ bool getHttpOnly() const; + /** Get the same-site flag of this cookie */ + QByteArray getSameSite() const; + /** Returns always 1 */ int getVersion() const; @@ -117,6 +127,7 @@ private: QByteArray path; bool secure; bool httpOnly; + QByteArray sameSite; int version; }; diff --git a/third_party/QtWebApp/httpserver/httpglobal.cpp b/third_party/QtWebApp/httpserver/httpglobal.cpp index d938a95c..a5b72a6a 100644 --- a/third_party/QtWebApp/httpserver/httpglobal.cpp +++ b/third_party/QtWebApp/httpserver/httpglobal.cpp @@ -2,6 +2,6 @@ const char* getQtWebAppLibVersion() { - return "1.7.11"; + return "1.8.3"; } diff --git a/third_party/QtWebApp/httpserver/httpglobal.h b/third_party/QtWebApp/httpserver/httpglobal.h index e7e856a9..4f499871 100644 --- a/third_party/QtWebApp/httpserver/httpglobal.h +++ b/third_party/QtWebApp/httpserver/httpglobal.h @@ -23,6 +23,5 @@ /** Get the library version number */ DECLSPEC const char* getQtWebAppLibVersion(); - #endif // HTTPGLOBAL_H diff --git a/third_party/QtWebApp/httpserver/httplistener.cpp b/third_party/QtWebApp/httpserver/httplistener.cpp index 768ab842..74871584 100644 --- a/third_party/QtWebApp/httpserver/httplistener.cpp +++ b/third_party/QtWebApp/httpserver/httplistener.cpp @@ -83,7 +83,7 @@ void HttpListener::incomingConnection(tSocketDescriptor socketDescriptor) { qDebug("HttpListener: Too many incoming connections"); QTcpSocket* socket=new QTcpSocket(this); socket->setSocketDescriptor(socketDescriptor); - connect(socket, &QAbstractSocket::disconnected, socket, &QObject::deleteLater); + connect(socket, SIGNAL(disconnected()), socket, SLOT(deleteLater())); socket->write("HTTP/1.1 503 too many connections\r\nConnection: close\r\n\r\nToo many connections\r\n"); socket->disconnectFromHost(); } diff --git a/third_party/QtWebApp/httpserver/httprequest.cpp b/third_party/QtWebApp/httpserver/httprequest.cpp index 75642b90..c9294b7a 100644 --- a/third_party/QtWebApp/httpserver/httprequest.cpp +++ b/third_party/QtWebApp/httpserver/httprequest.cpp @@ -482,7 +482,8 @@ void HttpRequest::parseMultiPartFile() parameters.insert(fieldName,fileName); qDebug("HttpRequest: set parameter %s=%s",fieldName.data(),fileName.data()); uploadedFiles.insert(fieldName,uploadedFile); - qDebug("HttpRequest: uploaded file size is %lli",uploadedFile->size()); + long int fileSize=(long int) uploadedFile->size(); + qDebug("HttpRequest: uploaded file size is %li",fileSize); } else { diff --git a/third_party/QtWebApp/httpserver/httpsession.h b/third_party/QtWebApp/httpserver/httpsession.h index 35ed1f26..e9d40b04 100644 --- a/third_party/QtWebApp/httpserver/httpsession.h +++ b/third_party/QtWebApp/httpserver/httpsession.h @@ -43,7 +43,6 @@ public: */ HttpSession& operator= (const HttpSession& other); - /** Destructor. Detaches from the shared data. */ @@ -54,7 +53,7 @@ public: /** Null sessions cannot store data. All calls to set() and remove() - do not have any effect.This method is thread safe. + do not have any effect. This method is thread safe. */ bool isNull() const; diff --git a/third_party/QtWebApp/httpserver/httpsessionstore.cpp b/third_party/QtWebApp/httpserver/httpsessionstore.cpp index 3939aca4..123dea8a 100644 --- a/third_party/QtWebApp/httpserver/httpsessionstore.cpp +++ b/third_party/QtWebApp/httpserver/httpsessionstore.cpp @@ -13,7 +13,7 @@ HttpSessionStore::HttpSessionStore(const QSettings *settings, QObject* parent) :QObject(parent) { this->settings=settings; - connect(&cleanupTimer,&QTimer::timeout,this,&HttpSessionStore::sessionTimerEvent); + connect(&cleanupTimer,SIGNAL(timeout()),this,SLOT(sessionTimerEvent())); cleanupTimer.start(60000); cookieName=settings->value("cookieName","sessionid").toByteArray(); expirationTime=settings->value("expirationTime",3600000).toInt(); @@ -64,7 +64,8 @@ HttpSession HttpSessionStore::getSession(HttpRequest& request, HttpResponse& res QByteArray cookiePath=settings->value("cookiePath").toByteArray(); QByteArray cookieComment=settings->value("cookieComment").toByteArray(); QByteArray cookieDomain=settings->value("cookieDomain").toByteArray(); - response.setCookie(HttpCookie(cookieName,session.getId(),expirationTime/1000,cookiePath,cookieComment,cookieDomain)); + response.setCookie(HttpCookie(cookieName,session.getId(),expirationTime/1000, + cookiePath,cookieComment,cookieDomain,false,false,"Lax")); session.setLastAccess(); return session; } @@ -79,7 +80,8 @@ HttpSession HttpSessionStore::getSession(HttpRequest& request, HttpResponse& res HttpSession session(true); qDebug("HttpSessionStore: create new session with ID %s",session.getId().data()); sessions.insert(session.getId(),session); - response.setCookie(HttpCookie(cookieName,session.getId(),expirationTime/1000,cookiePath,cookieComment,cookieDomain)); + response.setCookie(HttpCookie(cookieName,session.getId(),expirationTime/1000, + cookiePath,cookieComment,cookieDomain,false,false,"Lax")); mutex.unlock(); return session; } @@ -111,6 +113,7 @@ void HttpSessionStore::sessionTimerEvent() if (now-lastAccess>expirationTime) { qDebug("HttpSessionStore: session %s expired",session.getId().data()); + emit sessionDeleted(session.getId()); sessions.erase(prev); } } @@ -122,6 +125,7 @@ void HttpSessionStore::sessionTimerEvent() void HttpSessionStore::removeSession(HttpSession session) { mutex.lock(); + emit sessionDeleted(session.getId()); sessions.remove(session.getId()); mutex.unlock(); } diff --git a/third_party/QtWebApp/httpserver/httpsessionstore.h b/third_party/QtWebApp/httpserver/httpsessionstore.h index de86ecd2..65fa2c92 100644 --- a/third_party/QtWebApp/httpserver/httpsessionstore.h +++ b/third_party/QtWebApp/httpserver/httpsessionstore.h @@ -112,6 +112,14 @@ private slots: /** Called every minute to cleanup expired sessions. */ void sessionTimerEvent(); + +signals: + + /** + Emitted when the session is deleted. + @param sessionId The ID number of the session. + */ + void sessionDeleted(const QByteArray& sessionId); }; } // end of namespace diff --git a/third_party/QtWebApp/httpserver/staticfilecontroller.cpp b/third_party/QtWebApp/httpserver/staticfilecontroller.cpp index 9510aec9..bafe4509 100644 --- a/third_party/QtWebApp/httpserver/staticfilecontroller.cpp +++ b/third_party/QtWebApp/httpserver/staticfilecontroller.cpp @@ -33,7 +33,8 @@ StaticFileController::StaticFileController(const QSettings *settings, QObject* p maxCachedFileSize=settings->value("maxCachedFileSize","65536").toInt(); cache.setMaxCost(settings->value("cacheSize","1000000").toInt()); cacheTimeout=settings->value("cacheTime","60000").toInt(); - qDebug("StaticFileController: cache timeout=%i, size=%i",cacheTimeout,cache.maxCost()); + long int cacheMaxCost=(long int)cache.maxCost(); + qDebug("StaticFileController: cache timeout=%i, size=%li",cacheTimeout,cacheMaxCost); } diff --git a/third_party/QtWebApp/templateengine/template.h b/third_party/QtWebApp/templateengine/template.h index 01716c53..d476fb3c 100644 --- a/third_party/QtWebApp/templateengine/template.h +++ b/third_party/QtWebApp/templateengine/template.h @@ -7,7 +7,6 @@ #define TEMPLATE_H #include -#include #include #include #include diff --git a/third_party/QtWebApp/templateengine/templatecache.cpp b/third_party/QtWebApp/templateengine/templatecache.cpp index e0f22bf5..60135f67 100644 --- a/third_party/QtWebApp/templateengine/templatecache.cpp +++ b/third_party/QtWebApp/templateengine/templatecache.cpp @@ -10,7 +10,8 @@ TemplateCache::TemplateCache(const QSettings* settings, QObject* parent) { cache.setMaxCost(settings->value("cacheSize","1000000").toInt()); cacheTimeout=settings->value("cacheTime","60000").toInt(); - qDebug("TemplateCache: timeout=%i, size=%i",cacheTimeout,cache.maxCost()); + long int cacheMaxCost=(long int)cache.maxCost(); + qDebug("TemplateCache: timeout=%i, size=%li",cacheTimeout,cacheMaxCost); } QString TemplateCache::tryFile(const QString localizedName) diff --git a/third_party/QtWebApp/templateengine/templateengine.pri b/third_party/QtWebApp/templateengine/templateengine.pri index 722c17fc..faca956a 100644 --- a/third_party/QtWebApp/templateengine/templateengine.pri +++ b/third_party/QtWebApp/templateengine/templateengine.pri @@ -1,6 +1,10 @@ INCLUDEPATH += $$PWD DEPENDPATH += $$PWD +greaterThan(QT_VERSION,6) { + QT += core5compat +} + HEADERS += $$PWD/templateglobal.h HEADERS += $$PWD/template.h HEADERS += $$PWD/templateloader.h diff --git a/third_party/QtWebApp/templateengine/templateloader.cpp b/third_party/QtWebApp/templateengine/templateloader.cpp index 2379755c..0db3115b 100644 --- a/third_party/QtWebApp/templateengine/templateloader.cpp +++ b/third_party/QtWebApp/templateengine/templateloader.cpp @@ -9,6 +9,12 @@ #include #include #include +#include +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + #include +#else + #include +#endif using namespace stefanfrings; @@ -35,8 +41,8 @@ TemplateLoader::TemplateLoader(const QSettings *settings, QObject *parent) else { textCodec=QTextCodec::codecForName(encoding.toLocal8Bit()); - } - qDebug("TemplateLoader: path=%s, codec=%s",qPrintable(templatePath),textCodec->name().data()); + } + qDebug("TemplateLoader: path=%s, codec=%s",qPrintable(templatePath),qPrintable(encoding)); } TemplateLoader::~TemplateLoader() @@ -67,13 +73,23 @@ QString TemplateLoader::tryFile(QString localizedName) Template TemplateLoader::getTemplate(QString templateName, QString locales) { QSet tried; // used to suppress duplicate attempts - QStringList locs=locales.split(',',QString::SkipEmptyParts); + + #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) + QStringList locs=locales.split(',',Qt::SkipEmptyParts); + #else + QStringList locs=locales.split(',',QString::SkipEmptyParts); + #endif // Search for exact match foreach (QString loc,locs) { - loc.replace(QRegExp(";.*"),""); + #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + loc.replace(QRegularExpression(";.*"),""); + #else + loc.replace(QRegExp(";.*"),""); + #endif loc.replace('-','_'); + QString localizedName=templateName+"-"+loc.trimmed(); if (!tried.contains(localizedName)) { @@ -88,7 +104,11 @@ Template TemplateLoader::getTemplate(QString templateName, QString locales) // Search for correct language but any country foreach (QString loc,locs) { - loc.replace(QRegExp("[;_-].*"),""); + #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + loc.replace(QRegularExpression("[;_-].*"),""); + #else + loc.replace(QRegExp("[;_-].*"),""); + #endif QString localizedName=templateName+"-"+loc.trimmed(); if (!tried.contains(localizedName)) { diff --git a/third_party/QtWebApp/templateengine/templateloader.h b/third_party/QtWebApp/templateengine/templateloader.h index dd41fa53..faf24977 100644 --- a/third_party/QtWebApp/templateengine/templateloader.h +++ b/third_party/QtWebApp/templateengine/templateloader.h @@ -8,8 +8,8 @@ #include #include -#include #include +#include #include "templateglobal.h" #include "template.h" From 4c2d6be1ef5a3708cf10d8f5472788cb41025ba7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Thu, 7 Oct 2021 21:49:24 +0200 Subject: [PATCH 59/93] Use angleDelta instead of delta --- YACReaderLibrary/comic_flow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/YACReaderLibrary/comic_flow.cpp b/YACReaderLibrary/comic_flow.cpp index 4f56afd8..931aae93 100644 --- a/YACReaderLibrary/comic_flow.cpp +++ b/YACReaderLibrary/comic_flow.cpp @@ -105,7 +105,7 @@ void ComicFlow::keyPressEvent(QKeyEvent *event) void ComicFlow::wheelEvent(QWheelEvent *event) { - if (event->delta() < 0) + if (event->angleDelta().y() < 0) showNext(); else showPrevious(); From 8173f9f94cede234c5b10acac12cd9c43f9e0865 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Thu, 7 Oct 2021 22:16:33 +0200 Subject: [PATCH 60/93] Use setContentsMargins instead of setMargin --- YACReaderLibrary/classic_comics_view.cpp | 2 +- YACReaderLibrary/empty_folder_widget.cpp | 2 +- YACReaderLibrary/grid_comics_view.cpp | 2 +- YACReaderLibrary/import_widget.cpp | 2 +- YACReaderLibrary/library_window.cpp | 2 +- YACReaderLibrary/no_libraries_widget.cpp | 2 +- YACReaderLibrary/no_search_results_widget.cpp | 2 +- YACReaderLibrary/server_config_dialog.cpp | 2 +- YACReaderLibrary/yacreader_main_toolbar.cpp | 2 +- custom_widgets/yacreader_deleting_progress.cpp | 2 +- custom_widgets/yacreader_library_item_widget.cpp | 2 +- custom_widgets/yacreader_library_list_widget.cpp | 2 +- custom_widgets/yacreader_titled_toolbar.cpp | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/YACReaderLibrary/classic_comics_view.cpp b/YACReaderLibrary/classic_comics_view.cpp index c10cebb9..c5a8bbc1 100644 --- a/YACReaderLibrary/classic_comics_view.cpp +++ b/YACReaderLibrary/classic_comics_view.cpp @@ -76,7 +76,7 @@ ClassicComicsView::ClassicComicsView(QWidget *parent) layout->addWidget(sVertical); setLayout(layout); - layout->setMargin(0); + layout->setContentsMargins(0, 0, 0, 0); #ifdef Q_OS_MAC sVertical->setCollapsible(1, false); diff --git a/YACReaderLibrary/empty_folder_widget.cpp b/YACReaderLibrary/empty_folder_widget.cpp index 2b07b479..c1edb960 100644 --- a/YACReaderLibrary/empty_folder_widget.cpp +++ b/YACReaderLibrary/empty_folder_widget.cpp @@ -114,7 +114,7 @@ EmptyFolderWidget::EmptyFolderWidget(QWidget *parent) layout->addSpacing(12); layout->addWidget(foldersView, 1); layout->addStretch(); - layout->setMargin(0); + layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); setContentsMargins(0, 0, 0, 0); diff --git a/YACReaderLibrary/grid_comics_view.cpp b/YACReaderLibrary/grid_comics_view.cpp index 848c20b1..35d52049 100644 --- a/YACReaderLibrary/grid_comics_view.cpp +++ b/YACReaderLibrary/grid_comics_view.cpp @@ -208,7 +208,7 @@ void GridComicsView::createCoverSizeSliderWidget() bigLabel->setPixmap(QPixmap(":/images/comics_view_toolbar/big_size_grid_zoom.png")); horizontalLayout->addWidget(bigLabel); horizontalLayout->addSpacing(10); - horizontalLayout->setMargin(0); + horizontalLayout->setContentsMargins(0, 0, 0, 0); coverSizeSliderWidget->setLayout(horizontalLayout); // TODO add shortcuts (ctrl-+ and ctrl-- for zooming in out, + ctrl-0 for reseting the zoom) diff --git a/YACReaderLibrary/import_widget.cpp b/YACReaderLibrary/import_widget.cpp index e1b5ad74..dee85a76 100644 --- a/YACReaderLibrary/import_widget.cpp +++ b/YACReaderLibrary/import_widget.cpp @@ -48,7 +48,7 @@ YACReaderActivityIndicatorWidget::YACReaderActivityIndicatorWidget(QWidget *pare setLayout(layout); - layout->setMargin(4); + layout->setContentsMargins(4, 4, 4, 4); layout->setSpacing(0); // setFixedHeight(3); diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp index 8a5e80a1..b351ea1a 100644 --- a/YACReaderLibrary/library_window.cpp +++ b/YACReaderLibrary/library_window.cpp @@ -285,7 +285,7 @@ void LibraryWindow::doLayout() rightLayout->addWidget(libraryToolBar); rightLayout->addWidget(comicsViewsManager->containerWidget()); - rightLayout->setMargin(0); + rightLayout->setContentsMargins(0, 0, 0, 0); rightLayout->setSpacing(0); QWidget *rightWidget = new QWidget(); diff --git a/YACReaderLibrary/no_libraries_widget.cpp b/YACReaderLibrary/no_libraries_widget.cpp index 15530470..2420def8 100644 --- a/YACReaderLibrary/no_libraries_widget.cpp +++ b/YACReaderLibrary/no_libraries_widget.cpp @@ -52,7 +52,7 @@ NoLibrariesWidget::NoLibrariesWidget(QWidget *parent) topLayout->addSpacing(30); topLayout->addLayout(textLayout, 1); topLayout->addStretch(); - topLayout->setMargin(0); + topLayout->setContentsMargins(0, 0, 0, 0); topWidget->setLayout(topLayout); diff --git a/YACReaderLibrary/no_search_results_widget.cpp b/YACReaderLibrary/no_search_results_widget.cpp index ef7dc611..30dd4bde 100644 --- a/YACReaderLibrary/no_search_results_widget.cpp +++ b/YACReaderLibrary/no_search_results_widget.cpp @@ -33,7 +33,7 @@ NoSearchResultsWidget::NoSearchResultsWidget(QWidget *parent) layout->addSpacing(30); layout->addWidget(titleLabel); layout->addStretch(); - layout->setMargin(0); + layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); setContentsMargins(0, 0, 0, 0); diff --git a/YACReaderLibrary/server_config_dialog.cpp b/YACReaderLibrary/server_config_dialog.cpp index 1e110a65..3041d29d 100644 --- a/YACReaderLibrary/server_config_dialog.cpp +++ b/YACReaderLibrary/server_config_dialog.cpp @@ -135,7 +135,7 @@ ServerConfigDialog::ServerConfigDialog(QWidget *parent) auto portWidgetLayout = new QHBoxLayout(this); portWidgetLayout->addWidget(port); portWidgetLayout->addWidget(accept); - portWidgetLayout->setMargin(0); + portWidgetLayout->setContentsMargins(0, 0, 0, 0); portWidget->setLayout(portWidgetLayout); portWidget->move(332, 244); // accept->move(514,149); diff --git a/YACReaderLibrary/yacreader_main_toolbar.cpp b/YACReaderLibrary/yacreader_main_toolbar.cpp index 5dcfe34a..a6732193 100644 --- a/YACReaderLibrary/yacreader_main_toolbar.cpp +++ b/YACReaderLibrary/yacreader_main_toolbar.cpp @@ -50,7 +50,7 @@ YACReaderMainToolBar::YACReaderMainToolBar(QWidget *parent) fullscreenButton->setStyleSheet(qToolButtonStyleSheet); fullscreenButton->setIconSize(QSize(24, 24)); - mainLayout->setMargin(0); + mainLayout->setContentsMargins(0, 0, 0, 0); mainLayout->setSpacing(0); mainLayout->addSpacing(12); diff --git a/custom_widgets/yacreader_deleting_progress.cpp b/custom_widgets/yacreader_deleting_progress.cpp index a466a234..fc54476b 100644 --- a/custom_widgets/yacreader_deleting_progress.cpp +++ b/custom_widgets/yacreader_deleting_progress.cpp @@ -46,7 +46,7 @@ YACReaderDeletingProgress::YACReaderDeletingProgress(QWidget *parent) contentLayout->addWidget(button, 0, Qt::AlignHCenter); contentLayout->addSpacing(18); - contentLayout->setMargin(0); + contentLayout->setContentsMargins(0, 0, 0, 0); setLayout(contentLayout); diff --git a/custom_widgets/yacreader_library_item_widget.cpp b/custom_widgets/yacreader_library_item_widget.cpp index 6830a4a8..9b17a633 100644 --- a/custom_widgets/yacreader_library_item_widget.cpp +++ b/custom_widgets/yacreader_library_item_widget.cpp @@ -9,7 +9,7 @@ YACReaderLibraryItemWidget::YACReaderLibraryItemWidget(QString n /*ame*/, QStrin : QWidget(parent), name(n), path(p), isSelected(false) { QHBoxLayout *mainLayout = new QHBoxLayout; - mainLayout->setMargin(0); + mainLayout->setContentsMargins(0, 0, 0, 0); mainLayout->setSpacing(0); // installEventFilter(this); diff --git a/custom_widgets/yacreader_library_list_widget.cpp b/custom_widgets/yacreader_library_list_widget.cpp index 83c1997b..5084024d 100644 --- a/custom_widgets/yacreader_library_list_widget.cpp +++ b/custom_widgets/yacreader_library_list_widget.cpp @@ -11,7 +11,7 @@ YACReaderLibraryListWidget::YACReaderLibraryListWidget(QWidget *parent) { QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->setSpacing(0); - mainLayout->setMargin(0); + mainLayout->setContentsMargins(0, 0, 0, 0); this->setLayout(mainLayout); } diff --git a/custom_widgets/yacreader_titled_toolbar.cpp b/custom_widgets/yacreader_titled_toolbar.cpp index e38c267f..516cc643 100644 --- a/custom_widgets/yacreader_titled_toolbar.cpp +++ b/custom_widgets/yacreader_titled_toolbar.cpp @@ -60,7 +60,7 @@ YACReaderTitledToolBar::YACReaderTitledToolBar(const QString &title, QWidget *pa : QWidget(parent) { QHBoxLayout *mainLayout = new QHBoxLayout; - mainLayout->setMargin(0); + mainLayout->setContentsMargins(0, 0, 0, 0); mainLayout->setSpacing(0); QString styleSheet = "QWidget {border:0px;}"; From 2e24c1f36f7f70c55ac49c88ddc5f619d7442f31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Thu, 7 Oct 2021 22:18:21 +0200 Subject: [PATCH 61/93] Simplify YACReaderSearchLineEdit Modifiers are no longer needed since we have advanced search --- custom_widgets/yacreader_search_line_edit.cpp | 51 +------------------ custom_widgets/yacreader_search_line_edit.h | 2 - 2 files changed, 2 insertions(+), 51 deletions(-) diff --git a/custom_widgets/yacreader_search_line_edit.cpp b/custom_widgets/yacreader_search_line_edit.cpp index a1d5e1aa..f0690268 100644 --- a/custom_widgets/yacreader_search_line_edit.cpp +++ b/custom_widgets/yacreader_search_line_edit.cpp @@ -4,8 +4,6 @@ #include #include -#include - #include "QsLog.h" YACReaderSearchLineEdit::YACReaderSearchLineEdit(QWidget *parent) @@ -47,26 +45,6 @@ YACReaderSearchLineEdit::YACReaderSearchLineEdit(QWidget *parent) setAttribute(Qt::WA_MacShowFocusRect, false); setPlaceholderText(tr("type to search")); - // search modifiers - modifiers << "[read]" - << "[unread]"; //<< "[author]"; - modifiersCompleter = new QCompleter(modifiers); - - QString regExpString; - foreach (QString modifier, modifiers) { - regExpString = regExpString + modifier.replace("[", "\\[").replace("]", "\\]") + ".*|"; - } - - regExpString = regExpString + "[^\\[].*"; - - QLOG_TRACE() << regExpString; - - QRegExp regExp(regExpString); - QValidator *validator = new QRegExpValidator(regExp, this); - - setValidator(validator); - setCompleter(modifiersCompleter); - connect(this, &QLineEdit::textChanged, this, &YACReaderSearchLineEdit::processText); } @@ -77,13 +55,9 @@ void YACReaderSearchLineEdit::clearText() connect(this, &QLineEdit::textChanged, this, &YACReaderSearchLineEdit::processText); } -// modifiers are not returned const QString YACReaderSearchLineEdit::text() { - QString text = QLineEdit::text(); - - QRegExp regExp("\\[.*\\]"); - return text.remove(regExp).trimmed(); + return QLineEdit::text(); } void YACReaderSearchLineEdit::resizeEvent(QResizeEvent *) @@ -115,26 +89,5 @@ void YACReaderSearchLineEdit::updateCloseButton(const QString &text) void YACReaderSearchLineEdit::processText(const QString &text) { - - QRegExp regExp("(\\[.*\\])(.*)"); - if (text.startsWith("[")) { - if (regExp.exactMatch(text)) // avoid search while the modifiers are being written - { - QString modifier = regExp.cap(1); - QString searchText = regExp.cap(2).trimmed(); - - int indexOfModifier = modifiers.indexOf(modifier); - if (indexOfModifier != -1) { - QLOG_TRACE() << "modifier : " << modifier << "text : " << searchText; - emit filterChanged(static_cast(indexOfModifier + 1), searchText); // TODO, do not use on indexOF - } else { - QLOG_ERROR() << "invalid modifier : " << modifier; - } - } - - QLOG_TRACE() << "full text :" << text << " : " << regExp.indexIn(text); - } else { - QLOG_TRACE() << "NoModifiers : " << text; - emit filterChanged(YACReader::NoModifiers, text); - } + emit filterChanged(YACReader::NoModifiers, text); } diff --git a/custom_widgets/yacreader_search_line_edit.h b/custom_widgets/yacreader_search_line_edit.h index bfe1dacd..33197222 100644 --- a/custom_widgets/yacreader_search_line_edit.h +++ b/custom_widgets/yacreader_search_line_edit.h @@ -31,8 +31,6 @@ private slots: private: QToolButton *clearButton; QLabel *searchLabel; - QCompleter *modifiersCompleter; - QStringList modifiers; }; #endif // YACREADER_SEARCH_LINE_EDIT_H From ec4deaf5946ccf58b326db2f55a12381405e8c21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Thu, 7 Oct 2021 22:21:43 +0200 Subject: [PATCH 62/93] background role is now window --- YACReaderLibrary/add_label_dialog.cpp | 2 +- YACReaderLibrary/classic_comics_view.cpp | 2 +- YACReaderLibrary/comic_flow_widget.cpp | 2 +- YACReaderLibrary/import_widget.cpp | 2 +- YACReaderLibrary/no_libraries_widget.cpp | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/YACReaderLibrary/add_label_dialog.cpp b/YACReaderLibrary/add_label_dialog.cpp index 215e91ae..359d9c18 100644 --- a/YACReaderLibrary/add_label_dialog.cpp +++ b/YACReaderLibrary/add_label_dialog.cpp @@ -24,7 +24,7 @@ AddLabelDialog::AddLabelDialog(QWidget *parent) list->addItem(new QListWidgetItem(QIcon(":/images/lists/label_light.png"), tr("light"))); list->addItem(new QListWidgetItem(QIcon(":/images/lists/label_dark.png"), tr("dark"))); - QColor backgroundColor = this->palette().background().color(); + QColor backgroundColor = this->palette().window().color(); list->setStyleSheet(QString("QListWidget {border : none; background-color: rgb(%1,%2,%3);}").arg(backgroundColor.red()).arg(backgroundColor.green()).arg(backgroundColor.blue())); list->setMinimumHeight(225); diff --git a/YACReaderLibrary/classic_comics_view.cpp b/YACReaderLibrary/classic_comics_view.cpp index c5a8bbc1..0896ebf2 100644 --- a/YACReaderLibrary/classic_comics_view.cpp +++ b/YACReaderLibrary/classic_comics_view.cpp @@ -364,7 +364,7 @@ void ClassicComicsView::setupSearchingIcon() searchingIcon->setLayout(h); QPalette pal(searchingIcon->palette()); - pal.setColor(QPalette::Background, Qt::black); + pal.setColor(QPalette::Window, Qt::black); searchingIcon->setAutoFillBackground(true); searchingIcon->setPalette(pal); diff --git a/YACReaderLibrary/comic_flow_widget.cpp b/YACReaderLibrary/comic_flow_widget.cpp index e515e8f3..ddbfeaa1 100644 --- a/YACReaderLibrary/comic_flow_widget.cpp +++ b/YACReaderLibrary/comic_flow_widget.cpp @@ -20,7 +20,7 @@ ComicFlowWidgetSW::ComicFlowWidgetSW(QWidget *parent) // TODO eleminar "padding" QPalette Pal(palette()); // set black background - Pal.setColor(QPalette::Background, Qt::black); + Pal.setColor(QPalette::Window, Qt::black); setAutoFillBackground(true); setPalette(Pal); diff --git a/YACReaderLibrary/import_widget.cpp b/YACReaderLibrary/import_widget.cpp index dee85a76..1f2d7587 100644 --- a/YACReaderLibrary/import_widget.cpp +++ b/YACReaderLibrary/import_widget.cpp @@ -87,7 +87,7 @@ ImportWidget::ImportWidget(QWidget *parent) setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); QPalette p(palette()); - p.setColor(QPalette::Background, QColor(250, 250, 250)); + p.setColor(QPalette::Window, QColor(250, 250, 250)); setAutoFillBackground(true); setPalette(p); diff --git a/YACReaderLibrary/no_libraries_widget.cpp b/YACReaderLibrary/no_libraries_widget.cpp index 2420def8..c0e05441 100644 --- a/YACReaderLibrary/no_libraries_widget.cpp +++ b/YACReaderLibrary/no_libraries_widget.cpp @@ -11,7 +11,7 @@ NoLibrariesWidget::NoLibrariesWidget(QWidget *parent) setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); QPalette p(palette()); - p.setColor(QPalette::Background, QColor(250, 250, 250)); + p.setColor(QPalette::Window, QColor(250, 250, 250)); setAutoFillBackground(true); setPalette(p); From 34aabb0685ed95ef3ee8591e741432aacbc6b608 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Thu, 7 Oct 2021 22:22:11 +0200 Subject: [PATCH 63/93] Use QTransform instead of QMatrix --- YACReaderLibrary/comic_flow_widget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/YACReaderLibrary/comic_flow_widget.cpp b/YACReaderLibrary/comic_flow_widget.cpp index ddbfeaa1..0ade1c0b 100644 --- a/YACReaderLibrary/comic_flow_widget.cpp +++ b/YACReaderLibrary/comic_flow_widget.cpp @@ -25,7 +25,7 @@ ComicFlowWidgetSW::ComicFlowWidgetSW(QWidget *parent) setPalette(Pal); // config - QMatrix m; + QTransform m; m.rotate(-90); m.scale(-1, 1); QImage image(":/images/setRead.png"); From 0bf7977145ca32d6765e357928b4a01f09d50718 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Thu, 7 Oct 2021 22:22:26 +0200 Subject: [PATCH 64/93] background role is now window --- YACReaderLibrary/comic_flow_widget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/YACReaderLibrary/comic_flow_widget.cpp b/YACReaderLibrary/comic_flow_widget.cpp index 0ade1c0b..372bb46f 100644 --- a/YACReaderLibrary/comic_flow_widget.cpp +++ b/YACReaderLibrary/comic_flow_widget.cpp @@ -166,7 +166,7 @@ ComicFlowWidgetGL::ComicFlowWidgetGL(QWidget *parent) // TODO eleminar "padding" QPalette Pal(palette()); // set black background - Pal.setColor(QPalette::Background, Qt::black); + Pal.setColor(QPalette::Window, Qt::black); setAutoFillBackground(true); setPalette(Pal); } From 314b6295de555720a5da793bc62c3fc9bd5d09ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Thu, 7 Oct 2021 22:22:48 +0200 Subject: [PATCH 65/93] Remove qt4 support --- YACReaderLibrary/comic_vine/comic_vine_dialog.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/YACReaderLibrary/comic_vine/comic_vine_dialog.cpp b/YACReaderLibrary/comic_vine/comic_vine_dialog.cpp index fd8a1130..e11f7225 100644 --- a/YACReaderLibrary/comic_vine/comic_vine_dialog.cpp +++ b/YACReaderLibrary/comic_vine/comic_vine_dialog.cpp @@ -8,11 +8,7 @@ #include #include #include -#if QT_VERSION >= 0x050000 #include -#else -#include -#endif #include "data_base_management.h" #include #include From 36227a135455e8dbd8f88782556d9fff30a659f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Thu, 7 Oct 2021 22:23:24 +0200 Subject: [PATCH 66/93] QtConcurrent::run has changed in Qt6 --- YACReaderLibrary/comic_vine/comic_vine_dialog.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/YACReaderLibrary/comic_vine/comic_vine_dialog.cpp b/YACReaderLibrary/comic_vine/comic_vine_dialog.cpp index e11f7225..d17633e2 100644 --- a/YACReaderLibrary/comic_vine/comic_vine_dialog.cpp +++ b/YACReaderLibrary/comic_vine/comic_vine_dialog.cpp @@ -151,13 +151,23 @@ void ComicVineDialog::goNext() QList> matchingInfo = sortVolumeComicsWidget->getMatchingInfo(); int count = selectVolumeWidget->getSelectedVolumeNumIssues(); QString publisher = selectVolumeWidget->getSelectedVolumePublisher(); + +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QtConcurrent::run(&ComicVineDialog::getComicsInfo, this, matchingInfo, count, publisher); +#else QtConcurrent::run(this, &ComicVineDialog::getComicsInfo, matchingInfo, count, publisher); +#endif + } else if (content->currentWidget() == selectComicWidget) { showLoading(); QString comicId = selectComicWidget->getSelectedComicId(); int count = selectVolumeWidget->getSelectedVolumeNumIssues(); QString publisher = selectVolumeWidget->getSelectedVolumePublisher(); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QtConcurrent::run(&ComicVineDialog::getComicInfo, this, comicId, count, publisher); +#else QtConcurrent::run(this, &ComicVineDialog::getComicInfo, comicId, count, publisher); +#endif } } From ec95f8f5c3b17873d172f1e8fcd791de126c41a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Thu, 7 Oct 2021 22:23:54 +0200 Subject: [PATCH 67/93] Do not use screengeometry --- YACReaderLibrary/comic_vine/comic_vine_dialog.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/YACReaderLibrary/comic_vine/comic_vine_dialog.cpp b/YACReaderLibrary/comic_vine/comic_vine_dialog.cpp index d17633e2..90bc9e4b 100644 --- a/YACReaderLibrary/comic_vine/comic_vine_dialog.cpp +++ b/YACReaderLibrary/comic_vine/comic_vine_dialog.cpp @@ -209,8 +209,14 @@ void ComicVineDialog::setComics(const QList &comics) QSize ComicVineDialog::sizeHint() const { - int heightDesktopResolution = QApplication::desktop()->screenGeometry().height(); - int widthDesktopResolution = QApplication::desktop()->screenGeometry().width(); + QScreen *screen = window()->screen(); + if (screen == nullptr) { + screen = QApplication::screens().constFirst(); + } + + int heightDesktopResolution = screen->geometry().height(); + int widthDesktopResolution = screen->geometry().width(); + int height, width; height = qMax(529, static_cast(heightDesktopResolution * 0.5)); width = height * 1.65; From 6f1f8198d90a81c04a40c3a1ae44e60ee05f04ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Thu, 7 Oct 2021 22:24:37 +0200 Subject: [PATCH 68/93] Use MultiMap instead of Map --- .../comic_vine/comic_vine_dialog.cpp | 30 +++++++++---------- .../comic_vine/comic_vine_dialog.h | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/YACReaderLibrary/comic_vine/comic_vine_dialog.cpp b/YACReaderLibrary/comic_vine/comic_vine_dialog.cpp index 90bc9e4b..8e568f48 100644 --- a/YACReaderLibrary/comic_vine/comic_vine_dialog.cpp +++ b/YACReaderLibrary/comic_vine/comic_vine_dialog.cpp @@ -533,14 +533,14 @@ ComicDB ComicVineDialog::parseComicInfo(ComicDB &comic, const QString &json, int comic.info.volume = result.value("volume").toMap().value("name"); if (result.contains("person_credits") && !result.value("person_credits").isNull()) { - QMap authors = getAuthors(result.value("person_credits")); + auto authors = getAuthors(result.value("person_credits")); - QString writer = QStringList(authors.values("writer")).join("\n"); - QString penciller = QStringList(authors.values("penciller")).join("\n"); - QString inker = QStringList(authors.values("inker")).join("\n"); - QString colorist = QStringList(authors.values("colorist")).join("\n"); - QString letterer = QStringList(authors.values("letterer")).join("\n"); - QString coverArtist = QStringList(authors.values("cover")).join("\n"); + QString writer = authors.values("writer").join("\n"); + QString penciller = authors.values("penciller").join("\n"); + QString inker = authors.values("inker").join("\n"); + QString colorist = authors.values("colorist").join("\n"); + QString letterer = authors.values("letterer").join("\n"); + QString coverArtist = authors.values("cover").join("\n"); comic.info.writer = writer; comic.info.penciller = penciller; @@ -612,9 +612,9 @@ QString ComicVineDialog::getCharacters(const QVariant &json_characters) return (characters.isEmpty()) ? "" : (characters.join("\n") + "\n"); } -QMap ComicVineDialog::getAuthors(const QVariant &json_authors) +QMultiMap ComicVineDialog::getAuthors(const QVariant &json_authors) { - QMap authors; + QMultiMap authors; QListIterator it(json_authors.toList()); QVariantMap resultsValue; @@ -626,17 +626,17 @@ QMap ComicVineDialog::getAuthors(const QVariant &json_authors) QStringList roles = resultsValue.value("role").toString().split(","); foreach (QString role, roles) { if (role.trimmed() == "writer") - authors.insertMulti("writer", authorName); + authors.insert("writer", authorName); else if (role.trimmed() == "inker") - authors.insertMulti("inker", authorName); + authors.insert("inker", authorName); else if (role.trimmed() == "penciler" || role.trimmed() == "penciller") - authors.insertMulti("penciller", authorName); + authors.insert("penciller", authorName); else if (role.trimmed() == "colorist") - authors.insertMulti("colorist", authorName); + authors.insert("colorist", authorName); else if (role.trimmed() == "letterer") - authors.insertMulti("letterer", authorName); + authors.insert("letterer", authorName); else if (role.trimmed() == "cover") - authors.insertMulti("cover", authorName); + authors.insert("cover", authorName); } } diff --git a/YACReaderLibrary/comic_vine/comic_vine_dialog.h b/YACReaderLibrary/comic_vine/comic_vine_dialog.h index f2531b0a..a61a5429 100644 --- a/YACReaderLibrary/comic_vine/comic_vine_dialog.h +++ b/YACReaderLibrary/comic_vine/comic_vine_dialog.h @@ -64,7 +64,7 @@ protected slots: private: QString getCharacters(const QVariant &json_characters); - QMap getAuthors(const QVariant &json_authors); + QMultiMap getAuthors(const QVariant &json_authors); QPair getFirstStoryArcIdAndName(const QVariant &json_story_arcs); QPair getArcNumberAndArcCount(const QString &storyArcId, const QString &comicId); From 509b33e99105ad1f686ea35693de355d3bbb754f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Thu, 7 Oct 2021 22:24:46 +0200 Subject: [PATCH 69/93] Methods are not slots --- YACReaderLibrary/comic_vine/comic_vine_dialog.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/YACReaderLibrary/comic_vine/comic_vine_dialog.h b/YACReaderLibrary/comic_vine/comic_vine_dialog.h index a61a5429..6a9f517c 100644 --- a/YACReaderLibrary/comic_vine/comic_vine_dialog.h +++ b/YACReaderLibrary/comic_vine/comic_vine_dialog.h @@ -31,6 +31,8 @@ public: void setComics(const QList &comics); QSize sizeHint() const override; QSize minimumSizeHint() const override; + void getComicsInfo(QList> &matchingInfo, int count, const QString &publisher); + void getComicInfo(const QString &comicId, int count, const QString &publisher); signals: @@ -56,8 +58,6 @@ protected slots: void showSelectComic(const QString &json); void showSortVolumeComics(const QString &json); void queryTimeOut(); - void getComicsInfo(QList> &matchingInfo, int count, const QString &publisher); - void getComicInfo(const QString &comicId, int count, const QString &publisher); ComicDB parseComicInfo(ComicDB &comic, const QString &json, int count, const QString &publisher); void setLoadingMessage(const QString &message); void goToNextComic(); From fdd98fc0126271f013673b1dc3b44d8d971bf889 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Thu, 7 Oct 2021 22:25:19 +0200 Subject: [PATCH 70/93] Return Qt::NoItemFlags instead of nullptr --- .../comic_vine/model/local_comic_list_model.cpp | 6 +++--- YACReaderLibrary/comic_vine/model/volume_comics_model.cpp | 2 +- YACReaderLibrary/comic_vine/model/volumes_model.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/YACReaderLibrary/comic_vine/model/local_comic_list_model.cpp b/YACReaderLibrary/comic_vine/model/local_comic_list_model.cpp index d6874f90..e2cbc2ba 100644 --- a/YACReaderLibrary/comic_vine/model/local_comic_list_model.cpp +++ b/YACReaderLibrary/comic_vine/model/local_comic_list_model.cpp @@ -57,7 +57,7 @@ QVariant LocalComicListModel::data(const QModelIndex &index, int role) const Qt::ItemFlags LocalComicListModel::flags(const QModelIndex &index) const { if (!index.isValid()) - return nullptr; + return Qt::NoItemFlags; return Qt::ItemIsEnabled | Qt::ItemIsSelectable; } @@ -144,7 +144,7 @@ void LocalComicListModel::moveSelectionUp(const QList &selectedInde beginMoveRows(mi.parent(), sourceRow, sourceLastRow, mi.parent(), destRow); for (int i = sourceRow; i <= sourceLastRow; i++) - _data.swap(i, i - 1); + _data.swapItemsAt(i, i - 1); endMoveRows(); } @@ -163,7 +163,7 @@ void LocalComicListModel::moveSelectionDown(const QList &selectedIn beginMoveRows(mi.parent(), sourceRow, sourceLastRow, mi.parent(), destRow + 1); for (int i = sourceLastRow; i >= sourceRow; i--) - _data.swap(i, i + 1); + _data.swapItemsAt(i, i + 1); endMoveRows(); } diff --git a/YACReaderLibrary/comic_vine/model/volume_comics_model.cpp b/YACReaderLibrary/comic_vine/model/volume_comics_model.cpp index a67f1211..908d7614 100644 --- a/YACReaderLibrary/comic_vine/model/volume_comics_model.cpp +++ b/YACReaderLibrary/comic_vine/model/volume_comics_model.cpp @@ -105,7 +105,7 @@ QVariant VolumeComicsModel::data(const QModelIndex &index, int role) const Qt::ItemFlags VolumeComicsModel::flags(const QModelIndex &index) const { if (!index.isValid()) - return nullptr; + return Qt::NoItemFlags; return Qt::ItemIsEnabled | Qt::ItemIsSelectable; } diff --git a/YACReaderLibrary/comic_vine/model/volumes_model.cpp b/YACReaderLibrary/comic_vine/model/volumes_model.cpp index ae8de88c..23015354 100644 --- a/YACReaderLibrary/comic_vine/model/volumes_model.cpp +++ b/YACReaderLibrary/comic_vine/model/volumes_model.cpp @@ -102,7 +102,7 @@ QVariant VolumesModel::data(const QModelIndex &index, int role) const Qt::ItemFlags VolumesModel::flags(const QModelIndex &index) const { if (!index.isValid()) - return nullptr; + return Qt::NoItemFlags; return Qt::ItemIsEnabled | Qt::ItemIsSelectable; } From 542b04287b10ee7b5e3142134c7e0b122c1248db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Thu, 7 Oct 2021 22:25:30 +0200 Subject: [PATCH 71/93] Remove unused function --- YACReaderLibrary/db/comic_query_result_processor.cpp | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/YACReaderLibrary/db/comic_query_result_processor.cpp b/YACReaderLibrary/db/comic_query_result_processor.cpp index e154f159..873ab3b5 100644 --- a/YACReaderLibrary/db/comic_query_result_processor.cpp +++ b/YACReaderLibrary/db/comic_query_result_processor.cpp @@ -9,17 +9,6 @@ #include "QsLog.h" -QString getLastExecutedQuery(const QSqlQuery &query) -{ - QString str = query.lastQuery(); - QMapIterator it(query.boundValues()); - while (it.hasNext()) { - it.next(); - str.replace(it.key(), it.value().toString()); - } - return str; -} - YACReader::ComicQueryResultProcessor::ComicQueryResultProcessor() : querySearchQueue(1) { From fe3ae36cc291e83f882200525ac927f0c328ceb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Thu, 7 Oct 2021 22:25:51 +0200 Subject: [PATCH 72/93] Move to QFontMetrics new api --- YACReaderLibrary/empty_folder_widget.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/YACReaderLibrary/empty_folder_widget.cpp b/YACReaderLibrary/empty_folder_widget.cpp index c1edb960..a267bd7c 100644 --- a/YACReaderLibrary/empty_folder_widget.cpp +++ b/YACReaderLibrary/empty_folder_widget.cpp @@ -47,7 +47,7 @@ public: QRect textRect = option.rect; - textRect.setLeft(std::max(0, (option.rect.size().width() - fm.width(text)) / 2)); + textRect.setLeft(std::max(0, (option.rect.size().width() - fm.horizontalAdvance(text)) / 2)); painter->drawText(textRect, text); @@ -62,7 +62,7 @@ public: QFontMetrics fm(option.font); QString text = qvariant_cast(index.data(Qt::DisplayRole)); - return QSize(fm.width(text), fm.height()); + return QSize(fm.horizontalAdvance(text), fm.height()); } }; From 0bfa0eb31ef28b80e5bfff83c73fb831084bddbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Thu, 7 Oct 2021 22:26:07 +0200 Subject: [PATCH 73/93] More setContentsMargins migrations --- YACReaderLibrary/import_widget.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/YACReaderLibrary/import_widget.cpp b/YACReaderLibrary/import_widget.cpp index 1f2d7587..4a266268 100644 --- a/YACReaderLibrary/import_widget.cpp +++ b/YACReaderLibrary/import_widget.cpp @@ -144,7 +144,7 @@ ImportWidget::ImportWidget(QWidget *parent) coversViewLayout->addWidget(topDecorator, 0); coversViewLayout->addWidget(coversView, 1); coversViewLayout->addWidget(bottomDecorator, 0); - coversViewLayout->setMargin(0); + coversViewLayout->setContentsMargins(0, 0, 0, 0); coversViewLayout->setSpacing(0); QPushButton *stop = new QPushButton(tr("stop")); @@ -169,7 +169,7 @@ ImportWidget::ImportWidget(QWidget *parent) topLayout->addSpacing(30); topLayout->addLayout(textLayout, 1); topLayout->addStretch(); - topLayout->setMargin(0); + topLayout->setContentsMargins(0, 0, 0, 0); topWidget->setLayout(topLayout); From 98851cf40f63845f7750ac49c46a0a837b76a6f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Thu, 7 Oct 2021 22:26:17 +0200 Subject: [PATCH 74/93] Use Qt::endl --- YACReaderLibrary/library_creator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/YACReaderLibrary/library_creator.cpp b/YACReaderLibrary/library_creator.cpp index 5ea413fa..cc00c7f9 100644 --- a/YACReaderLibrary/library_creator.cpp +++ b/YACReaderLibrary/library_creator.cpp @@ -117,7 +117,7 @@ void LibraryCreator::run() #endif if (!sevenzLib->load()) { - QLOG_ERROR() << "Loading 7z.dll : " + sevenzLib->errorString() << endl; + QLOG_ERROR() << "Loading 7z.dll : " + sevenzLib->errorString() << Qt::endl; QCoreApplication::exit(YACReader::SevenZNotFound); exit(); } From 47e7eb38014fbc596c57f571f3dc908fa04d6708 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Thu, 7 Oct 2021 22:26:30 +0200 Subject: [PATCH 75/93] Remove unused includes --- YACReaderLibrary/library_window.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp index b351ea1a..1ef0b382 100644 --- a/YACReaderLibrary/library_window.cpp +++ b/YACReaderLibrary/library_window.cpp @@ -6,14 +6,12 @@ #include #include #include -#include #include #include #include #include #include #include -#include #include #include From 2c0dccd7648427a5110d8dc39aec346a4b329e32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Thu, 7 Oct 2021 22:28:30 +0200 Subject: [PATCH 76/93] Use constructor explicitly --- YACReaderLibrary/library_window.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp index 1ef0b382..2af31787 100644 --- a/YACReaderLibrary/library_window.cpp +++ b/YACReaderLibrary/library_window.cpp @@ -2377,7 +2377,7 @@ void LibraryWindow::asignNumbers() void LibraryWindow::openContainingFolderComic() { QModelIndex modelIndex = comicsViewsManager->comicsView->currentIndex(); - QFileInfo file = QDir::cleanPath(currentPath() + comicsModel->getComicPath(modelIndex)); + QFileInfo file(QDir::cleanPath(currentPath() + comicsModel->getComicPath(modelIndex))); #if defined Q_OS_UNIX && !defined Q_OS_MAC QString path = file.absolutePath(); QDesktopServices::openUrl(QUrl("file:///" + path, QUrl::TolerantMode)); From 86a31c0ea58e6780a8a7aeb99b1f87c6ae90ade5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Thu, 7 Oct 2021 22:28:43 +0200 Subject: [PATCH 77/93] Use QRegularExpression --- YACReaderLibrary/library_window.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp index 2af31787..c148745b 100644 --- a/YACReaderLibrary/library_window.cpp +++ b/YACReaderLibrary/library_window.cpp @@ -1582,7 +1582,7 @@ void LibraryWindow::addFolderToCurrentIndex() "", &ok); // chars not supported in a folder's name: / \ : * ? " < > | - QRegExp invalidChars("\\/\\:\\*\\?\\\"\\<\\>\\|\\\\"); // TODO this regexp is not properly written + QRegularExpression invalidChars("\\/\\:\\*\\?\\\"\\<\\>\\|\\\\"); // TODO this regexp is not properly written bool isValid = !newFolderName.contains(invalidChars); if (ok && !newFolderName.isEmpty() && isValid) { From ffc0f9ec8a0df0f02c58ab7a22ea607012f58dd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Thu, 7 Oct 2021 22:29:17 +0200 Subject: [PATCH 78/93] Don't use QDesktopWidget --- YACReaderLibrary/properties_dialog.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/YACReaderLibrary/properties_dialog.cpp b/YACReaderLibrary/properties_dialog.cpp index ef61ec6c..1846820c 100644 --- a/YACReaderLibrary/properties_dialog.cpp +++ b/YACReaderLibrary/properties_dialog.cpp @@ -9,7 +9,6 @@ #include #include -#include #include #include #include @@ -51,8 +50,13 @@ PropertiesDialog::PropertiesDialog(QWidget *parent) mainWidget->setLayout(mainLayout); mainLayout->setSizeConstraint(QLayout::SetMinimumSize); - int heightDesktopResolution = QApplication::desktop()->screenGeometry().height(); - int widthDesktopResolution = QApplication::desktop()->screenGeometry().width(); + QScreen *screen = parent != nullptr ? parent->window()->screen() : nullptr; + if (screen == nullptr) { + screen = QApplication::screens().constFirst(); + } + + int heightDesktopResolution = screen->geometry().height(); + int widthDesktopResolution = screen->geometry().width(); int sHeight, sWidth; sHeight = static_cast(heightDesktopResolution * 0.65); sWidth = static_cast(sHeight * 1.4); From 2dbfc6cab5707c43877e9178916f93aa32f130cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Thu, 7 Oct 2021 22:29:50 +0200 Subject: [PATCH 79/93] Simplify connection from QComboBox All we want is the new text after it changes. --- YACReaderLibrary/server_config_dialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/YACReaderLibrary/server_config_dialog.cpp b/YACReaderLibrary/server_config_dialog.cpp index 3041d29d..68ce85ce 100644 --- a/YACReaderLibrary/server_config_dialog.cpp +++ b/YACReaderLibrary/server_config_dialog.cpp @@ -117,7 +117,7 @@ ServerConfigDialog::ServerConfigDialog(QWidget *parent) portLabel->setStyleSheet("QLabel {color:#575757; font-size:18px; font-family: Arial;}"); ip = new QComboBox(this); - connect(ip, QOverload::of(&QComboBox::activated), this, &ServerConfigDialog::regenerateQR); + connect(ip, &QComboBox::currentTextChanged, this, &ServerConfigDialog::regenerateQR); ip->setFixedWidth(200); ip->move(332, 153); From 89459a470d760fc79cf1637ada7f1b8011e05d5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Thu, 7 Oct 2021 22:30:20 +0200 Subject: [PATCH 80/93] Use Qt::endl --- YACReaderLibrary/xml_info_library_scanner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/YACReaderLibrary/xml_info_library_scanner.cpp b/YACReaderLibrary/xml_info_library_scanner.cpp index f8aa31fb..58cf9a85 100644 --- a/YACReaderLibrary/xml_info_library_scanner.cpp +++ b/YACReaderLibrary/xml_info_library_scanner.cpp @@ -37,7 +37,7 @@ void XMLInfoLibraryScanner::run() #endif if (!sevenzLib->load()) { - QLOG_ERROR() << "Loading 7z.dll : " + sevenzLib->errorString() << endl; + QLOG_ERROR() << "Loading 7z.dll : " + sevenzLib->errorString() << Qt::endl; QCoreApplication::exit(YACReader::SevenZNotFound); exit(); } From 997b82eb7981bb77bdf551c6d65b512840d3d470 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Thu, 7 Oct 2021 22:31:29 +0200 Subject: [PATCH 81/93] Add quickcontrols2 to YACReaderLibrary QtQuick.Controls v1 to v2 migration, yay! -_- --- YACReaderLibrary/YACReaderLibrary.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/YACReaderLibrary/YACReaderLibrary.pro b/YACReaderLibrary/YACReaderLibrary.pro index 17a6a94c..d5994578 100644 --- a/YACReaderLibrary/YACReaderLibrary.pro +++ b/YACReaderLibrary/YACReaderLibrary.pro @@ -69,7 +69,7 @@ macx { #CONFIG += release CONFIG -= flat -QT += sql network widgets svg +QT += sql network widgets svg quickcontrols2 greaterThan(QT_MAJOR_VERSION, 5): QT += openglwidgets core5compat From c5d3ebebc85c0adbb0062644ef9386fff036fb79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Thu, 7 Oct 2021 22:57:09 +0200 Subject: [PATCH 82/93] Remove commented code --- YACReaderLibrary/library_window.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp index c148745b..a1088e99 100644 --- a/YACReaderLibrary/library_window.cpp +++ b/YACReaderLibrary/library_window.cpp @@ -455,8 +455,6 @@ void LibraryWindow::doModels() // lists listsModel = new ReadingListModel(this); listsModelProxy = new ReadingListModelProxy(this); - - // setSearchFilter(YACReader::NoModifiers, ""); //clear search filter } void LibraryWindow::createActions() From 17064a12e6c5f498a949aa351a064a58924b3be9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sun, 17 Oct 2021 14:45:36 +0200 Subject: [PATCH 83/93] Remove qml components what won't be used anymore --- YACReaderLibrary/qml.qrc | 2 - YACReaderLibrary/qml/YACReaderScrollView.qml | 357 ---------------- .../qml/YACReaderScrollViewStyle.qml | 403 ------------------ 3 files changed, 762 deletions(-) delete mode 100644 YACReaderLibrary/qml/YACReaderScrollView.qml delete mode 100644 YACReaderLibrary/qml/YACReaderScrollViewStyle.qml diff --git a/YACReaderLibrary/qml.qrc b/YACReaderLibrary/qml.qrc index ae0b04ff..ce33b3d5 100644 --- a/YACReaderLibrary/qml.qrc +++ b/YACReaderLibrary/qml.qrc @@ -1,7 +1,6 @@ qml/GridComicsView.qml - qml/YACReaderScrollView.qml qml/tick.png qml/reading.png qml/star_menu.png @@ -27,6 +26,5 @@ qml/InfoTick.qml qml/InfoFavorites.qml qml/InfoRating.qml - qml/YACReaderScrollViewStyle.qml diff --git a/YACReaderLibrary/qml/YACReaderScrollView.qml b/YACReaderLibrary/qml/YACReaderScrollView.qml deleted file mode 100644 index 363d26ec..00000000 --- a/YACReaderLibrary/qml/YACReaderScrollView.qml +++ /dev/null @@ -1,357 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Controls module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.2 -import QtQuick.Controls 1.2 -import QtQuick.Controls.Private 1.0 -import QtQuick.Controls.Styles 1.1 - -/*! - \qmltype ScrollView - \inqmlmodule QtQuick.Controls - \since 5.1 - \ingroup views - \ingroup controls - \brief Provides a scrolling view within another Item. - - \image scrollview.png - - A ScrollView can be used either to replace a \l Flickable or decorate an - existing \l Flickable. Depending on the platform, it will add scroll bars and - a content frame. - - Only one Item can be a direct child of the ScrollView and the child is implicitly anchored - to fill the scroll view. - - Example: - \code - ScrollView { - Image { source: "largeImage.png" } - } - \endcode - - In the previous example the Image item will implicitly get scroll behavior as if it was - used within a \l Flickable. The width and height of the child item will be used to - define the size of the content area. - - Example: - \code - ScrollView { - ListView { - ... - } - } - \endcode - - In this case the content size of the ScrollView will simply mirror that of its contained - \l flickableItem. - - You can create a custom appearance for a ScrollView by - assigning a \l {ScrollViewStyle}. -*/ - -FocusScope { - id: root - - implicitWidth: 240 - implicitHeight: 150 - - /*! - This property tells the ScrollView if it should render - a frame around its content. - - The default value is \c false. - */ - property bool frameVisible: false - - /*! \qmlproperty enumeration ScrollView::horizontalScrollBarPolicy - \since QtQuick.Controls 1.3 - - This property holds the policy for showing the horizontal scrollbar. - It can be any of the following values: - \list - \li Qt.ScrollBarAsNeeded - \li Qt.ScrollBarAlwaysOff - \li Qt.ScrollBarAlwaysOn - \endlist - - The default policy is \c Qt.ScrollBarAsNeeded. - */ - property alias horizontalScrollBarPolicy: scroller.horizontalScrollBarPolicy - - /*! \qmlproperty enumeration ScrollView::verticalScrollBarPolicy - \since QtQuick.Controls 1.3 - - This property holds the policy for showing the vertical scrollbar. - It can be any of the following values: - \list - \li Qt.ScrollBarAsNeeded - \li Qt.ScrollBarAlwaysOff - \li Qt.ScrollBarAlwaysOn - \endlist - - The default policy is \c Qt.ScrollBarAsNeeded. - */ - property alias verticalScrollBarPolicy: scroller.verticalScrollBarPolicy - - /*! - This property controls if there should be a highlight - around the frame when the ScrollView has input focus. - - The default value is \c false. - - \note This property is only applicable on some platforms, such - as Mac OS. - */ - property bool highlightOnFocus: false - - /*! - \qmlproperty Item ScrollView::viewport - - The viewport determines the current "window" on the contentItem. - In other words, it clips it and the size of the viewport tells you - how much of the content area is visible. - */ - property alias viewport: viewportItem - - /*! - \qmlproperty Item ScrollView::flickableItem - - The flickableItem of the ScrollView. If the contentItem provided - to the ScrollView is a Flickable, it will be the \l contentItem. - */ - readonly property alias flickableItem: internal.flickableItem - - /*! - The contentItem of the ScrollView. This is set by the user. - - Note that the definition of contentItem is somewhat different to that - of a Flickable, where the contentItem is implicitly created. - */ - default property Item contentItem - - /*! \internal */ - property alias __scroller: scroller - /*! \internal */ - property alias __verticalScrollbarOffset: scroller.verticalScrollbarOffset - /*! \internal */ - property alias __wheelAreaScrollSpeed: wheelArea.scrollSpeed - /*! \internal */ - property int __scrollBarTopMargin: 0 - /*! \internal */ - property int __viewTopMargin: 0 - /*! \internal */ - property alias __horizontalScrollBar: scroller.horizontalScrollBar - /*! \internal */ - property alias __verticalScrollBar: scroller.verticalScrollBar - /*! \qmlproperty Component ScrollView::style - - The style Component for this control. - \sa {Qt Quick Controls Styles QML Types} - - */ - property Component style: Settings.styleComponent(Settings.style, "ScrollViewStyle.qml", root) - - /*! \internal */ - property Style __style: styleLoader.item - - activeFocusOnTab: true - - onContentItemChanged: { - - if (contentItem.hasOwnProperty("contentY") && // Check if flickable - contentItem.hasOwnProperty("contentHeight")) { - internal.flickableItem = contentItem // "Use content if it is a flickable - internal.flickableItem.parent = viewportItem - } else { - internal.flickableItem = flickableComponent.createObject(viewportItem) - contentItem.parent = internal.flickableItem.contentItem - } - internal.flickableItem.anchors.fill = viewportItem - if (!Settings.hasTouchScreen) - internal.flickableItem.interactive = false - } - - - children: Item { - id: internal - - property Flickable flickableItem - - Loader { - id: styleLoader - sourceComponent: style - onStatusChanged: { - if (status === Loader.Error) - console.error("Failed to load Style for", root) - } - property alias __control: root - } - - Binding { - target: flickableItem - property: "contentHeight" - when: contentItem !== flickableItem - value: contentItem ? contentItem.height : 0 - } - - Binding { - target: flickableItem - when: contentItem !== flickableItem - property: "contentWidth" - value: contentItem ? contentItem.width : 0 - } - - Connections { - target: flickableItem - - onContentYChanged: { - scroller.blockUpdates = true - scroller.verticalScrollBar.value = flickableItem.contentY - flickableItem.originY - scroller.blockUpdates = false - } - - onContentXChanged: { - scroller.blockUpdates = true - scroller.horizontalScrollBar.value = flickableItem.contentX - flickableItem.originX - scroller.blockUpdates = false - } - - } - - anchors.fill: parent - - Component { - id: flickableComponent - Flickable {} - } - - WheelArea { - id: wheelArea - parent: flickableItem - z: -1 - // ### Note this is needed due to broken mousewheel behavior in Flickable. - - anchors.fill: parent - - property int acceleration: 40 - property int flickThreshold: Settings.dragThreshold - property real speedThreshold: 3 - property real ignored: 0.001 // ## flick() does not work with 0 yVelocity - property int maxFlick: 400 - - property bool horizontalRecursionGuard: false - property bool verticalRecursionGuard: false - - horizontalMinimumValue: 0 - horizontalMaximumValue: flickableItem ? flickableItem.contentWidth - viewport.width : 0 - - verticalMinimumValue: 0 - verticalMaximumValue: flickableItem ? flickableItem.contentHeight - viewport.height + __viewTopMargin : 0 - - // The default scroll speed for typical angle-based mouse wheels. The value - // comes originally from QTextEdit, which sets 20px steps by default, as well as - // QQuickWheelArea. - // TODO: centralize somewhere, QPlatformTheme? - scrollSpeed: 20 * (__style && __style.__wheelScrollLines || 1) - - Connections { - target: flickableItem - - onContentYChanged: { - wheelArea.verticalRecursionGuard = true - wheelArea.verticalValue = flickableItem.contentY - flickableItem.originY - wheelArea.verticalRecursionGuard = false - } - onContentXChanged: { - wheelArea.horizontalRecursionGuard = true - wheelArea.horizontalValue = flickableItem.contentX - flickableItem.originX - wheelArea.horizontalRecursionGuard = false - } - } - - onVerticalValueChanged: { - if (!verticalRecursionGuard) { - var effectiveContentY = flickableItem.contentY - flickableItem.originY - if (effectiveContentY < flickThreshold && verticalDelta > speedThreshold) { - flickableItem.flick(ignored, Math.min(maxFlick, acceleration * verticalDelta)) - } else if (effectiveContentY > flickableItem.contentHeight - flickThreshold - viewport.height - && verticalDelta < -speedThreshold) { - flickableItem.flick(ignored, Math.max(-maxFlick, acceleration * verticalDelta)) - } else { - flickableItem.contentY = verticalValue + flickableItem.originY - } - flickableItem.contentY = Math.min(verticalMaximumValue, Math.max(0, flickableItem.contentY)); - } - } - - onHorizontalValueChanged: { - if (!horizontalRecursionGuard) - flickableItem.contentX = horizontalValue + flickableItem.originX - } - } - - ScrollViewHelper { - id: scroller - anchors.fill: parent - active: wheelArea.active - property bool outerFrame: !frameVisible || !(__style ? __style.__externalScrollBars : 0) - property int scrollBarSpacing: outerFrame ? 0 : (__style ? __style.__scrollBarSpacing : 0) - property int verticalScrollbarOffset: verticalScrollBar.visible && !verticalScrollBar.isTransient ? - verticalScrollBar.width + scrollBarSpacing : 0 - property int horizontalScrollbarOffset: horizontalScrollBar.visible && !horizontalScrollBar.isTransient ? - horizontalScrollBar.height + scrollBarSpacing : 0 - Loader { - id: frameLoader - sourceComponent: __style ? __style.frame : null - anchors.fill: parent - anchors.rightMargin: scroller.outerFrame ? 0 : scroller.verticalScrollbarOffset - anchors.bottomMargin: scroller.outerFrame ? 0 : scroller.horizontalScrollbarOffset - } - - Item { - id: viewportItem - anchors.fill: frameLoader - anchors.topMargin: frameVisible ? __style.padding.top : 0 - anchors.leftMargin: frameVisible ? __style.padding.left : 0 - anchors.rightMargin: (frameVisible ? __style.padding.right : 0) + (scroller.outerFrame ? scroller.verticalScrollbarOffset : 0) - anchors.bottomMargin: (frameVisible ? __style.padding.bottom : 0) + (scroller.outerFrame ? scroller.horizontalScrollbarOffset : 0) - clip: true - } - } - FocusFrame { visible: highlightOnFocus && root.activeFocus } - } -} diff --git a/YACReaderLibrary/qml/YACReaderScrollViewStyle.qml b/YACReaderLibrary/qml/YACReaderScrollViewStyle.qml deleted file mode 100644 index 09bc7da3..00000000 --- a/YACReaderLibrary/qml/YACReaderScrollViewStyle.qml +++ /dev/null @@ -1,403 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Controls module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.2 -import QtQuick.Controls 1.2 -import QtQuick.Controls.Private 1.0 - -/*! - \qmltype ScrollViewStyle - \inqmlmodule QtQuick.Controls.Styles - \since 5.1 - \ingroup viewsstyling - \ingroup controlsstyling - \brief Provides custom styling for ScrollView -*/ -Style { - id: root - - /*! The \l ScrollView this style is attached to. */ - readonly property ScrollView control: __control - - /*! This property controls the frame border padding of the scrollView. */ - padding {left: 1; top: 1; right: 1; bottom: 1} - - /*! This Component paints the corner area between scroll bars */ - property Component corner: Rectangle { color: "#ccc" } - - /*! This component determines if the flickable should reposition itself at the - mouse location when clicked. */ - property bool scrollToClickedPosition: true - - /*! This property holds whether the scroll bars are transient. Transient scroll bars - appear when the content is scrolled and disappear when they are no longer needed. - - The default value is platform dependent. */ - property bool transientScrollBars: Settings.isMobile && Settings.hasTouchScreen - - /*! This Component paints the frame around scroll bars. */ - property Component frame: Rectangle { - color: control["backgroundVisible"] ? "white": "transparent" - border.color: "#999" - border.width: 1 - radius: 1 - visible: control.frameVisible - } - - /*! This is the minimum extent of the scroll bar handle. - - The default value is \c 30. - */ - - property int minimumHandleLength: 30 - - /*! This property controls the edge overlap - between the handle and the increment/decrement buttons. - - The default value is \c 30. - */ - - property int handleOverlap: 1 - - /*! This component controls the appearance of the - scroll bar background. - - You can access the following state properties: - - \table - \row \li property bool \b styleData.hovered - \row \li property bool \b styleData.horizontal - \endtable - */ - - property Component scrollBarBackground: Item { - property bool sticky: false - property bool hovered: styleData.hovered - implicitWidth: Math.round(TextSingleton.implicitHeight) - implicitHeight: Math.round(TextSingleton.implicitHeight) - clip: true - opacity: transientScrollBars ? 0.5 : 1.0 - visible: !Settings.hasTouchScreen && (!transientScrollBars || sticky) - Rectangle { - anchors.fill: parent - color: "#ddd" - border.color: "#aaa" - anchors.rightMargin: styleData.horizontal ? -2 : -1 - anchors.leftMargin: styleData.horizontal ? -2 : 0 - anchors.topMargin: styleData.horizontal ? 0 : -2 - anchors.bottomMargin: styleData.horizontal ? -1 : -2 - } - onHoveredChanged: if (hovered) sticky = true - onVisibleChanged: if (!visible) sticky = false - } - - /*! This component controls the appearance of the - scroll bar handle. - - You can access the following state properties: - - \table - \row \li property bool \b styleData.hovered - \row \li property bool \b styleData.pressed - \row \li property bool \b styleData.horizontal - \endtable - */ - - property Component handle: Item { - property bool sticky: false - property bool hovered: __activeControl !== "none" - implicitWidth: Math.round(TextSingleton.implicitHeight) + 1 - implicitHeight: Math.round(TextSingleton.implicitHeight) + 1 - BorderImage { - id: img - opacity: styleData.pressed && !transientScrollBars ? 0.5 : styleData.hovered ? 1 : 0.8 - source: "images/scrollbar-handle-" + (transientScrollBars ? "transient" : styleData.horizontal ? "horizontal" : "vertical") + ".png" - border.left: transientScrollBars ? 5 : 2 - border.top: transientScrollBars ? 5 : 2 - border.right: transientScrollBars ? 5 : 2 - border.bottom: transientScrollBars ? 5 : 2 - anchors.top: !styleData.horizontal ? parent.top : undefined - anchors.margins: transientScrollBars ? 2 : 0 - anchors.bottom: parent.bottom - anchors.right: parent.right - anchors.left: styleData.horizontal ? parent.left : undefined - width: !styleData.horizontal && transientScrollBars ? sticky ? 13 : 10 : parent.width - height: styleData.horizontal && transientScrollBars ? sticky ? 13 : 10 : parent.height - Behavior on width { enabled: !styleData.horizontal && transientScrollBars; NumberAnimation { duration: 100 } } - Behavior on height { enabled: styleData.horizontal && transientScrollBars; NumberAnimation { duration: 100 } } - } - onHoveredChanged: if (hovered) sticky = true - onVisibleChanged: if (!visible) sticky = false - } - - /*! This component controls the appearance of the - scroll bar increment button. - - You can access the following state properties: - - \table - \row \li property bool \b styleData.hovered - \row \li property bool \b styleData.pressed - \row \li property bool \b styleData.horizontal - \endtable - */ - property Component incrementControl: Rectangle { - visible: !transientScrollBars - implicitWidth: transientScrollBars ? 0 : Math.round(TextSingleton.implicitHeight) - implicitHeight: transientScrollBars ? 0 : Math.round(TextSingleton.implicitHeight) - Rectangle { - anchors.fill: parent - anchors.bottomMargin: -1 - anchors.rightMargin: -1 - border.color: "#aaa" - Rectangle { - anchors.fill: parent - anchors.margins: 1 - color: "transparent" - border.color: "#44ffffff" - } - Image { - source: styleData.horizontal ? "images/arrow-right.png" : "images/arrow-down.png" - anchors.centerIn: parent - opacity: control.enabled ? 0.6 : 0.5 - } - gradient: Gradient { - GradientStop {color: styleData.pressed ? "lightgray" : "white" ; position: 0} - GradientStop {color: styleData.pressed ? "lightgray" : "lightgray" ; position: 1} - } - } - } - - /*! This component controls the appearance of the - scroll bar decrement button. - - You can access the following state properties: - - \table - \row \li property bool \b styleData.hovered - \row \li property bool \b styleData.pressed - \row \li property bool \b styleData.horizontal - \endtable - */ - property Component decrementControl: Rectangle { - visible: !transientScrollBars - implicitWidth: transientScrollBars ? 0 : Math.round(TextSingleton.implicitHeight) - implicitHeight: transientScrollBars ? 0 : Math.round(TextSingleton.implicitHeight) - Rectangle { - anchors.fill: parent - anchors.topMargin: styleData.horizontal ? 0 : -1 - anchors.leftMargin: styleData.horizontal ? -1 : 0 - anchors.bottomMargin: styleData.horizontal ? -1 : 0 - anchors.rightMargin: styleData.horizontal ? 0 : -1 - color: "lightgray" - Rectangle { - anchors.fill: parent - anchors.margins: 1 - color: "transparent" - border.color: "#44ffffff" - } - Image { - source: styleData.horizontal ? "images/arrow-left.png" : "images/arrow-up.png" - anchors.centerIn: parent - anchors.verticalCenterOffset: styleData.horizontal ? 0 : -1 - anchors.horizontalCenterOffset: styleData.horizontal ? -1 : 0 - opacity: control.enabled ? 0.6 : 0.5 - } - gradient: Gradient { - GradientStop {color: styleData.pressed ? "lightgray" : "white" ; position: 0} - GradientStop {color: styleData.pressed ? "lightgray" : "lightgray" ; position: 1} - } - border.color: "#aaa" - } - } - - /*! \internal */ - property Component __scrollbar: Item { - id: panel - property string activeControl: "none" - property bool scrollToClickPosition: true - property bool isTransient: transientScrollBars - - property bool on: false - property bool raised: false - property bool sunken: __styleData.upPressed | __styleData.downPressed | __styleData.handlePressed - - states: State { - name: "out" - when: isTransient - && (!__stickyScrollbars || !flickableItem.moving) - && panel.activeControl === "none" - && !panel.on - && !panel.raised - PropertyChanges { target: panel; opacity: 0 } - } - - transitions: Transition { - to: "out" - SequentialAnimation { - PauseAnimation { duration: root.__scrollBarFadeDelay } - NumberAnimation { properties: "opacity"; duration: root.__scrollBarFadeDuration } - PropertyAction { target: panel; property: "visible"; value: false } - } - } - - implicitWidth: __styleData.horizontal ? 200 : bg.implicitWidth - implicitHeight: __styleData.horizontal ? bg.implicitHeight : 200 - - function pixelMetric(arg) { - if (arg === "scrollbarExtent") - return (__styleData.horizontal ? bg.height : bg.width); - return 0; - } - - function styleHint(arg) { - return false; - } - - function hitTest(argX, argY) { - if (itemIsHit(handleControl, argX, argY)) - return "handle" - else if (itemIsHit(incrementLoader, argX, argY)) - return "up"; - else if (itemIsHit(decrementLoader, argX, argY)) - return "down"; - else if (itemIsHit(bg, argX, argY)) { - if (__styleData.horizontal && argX < handleControl.x || !__styleData.horizontal && argY < handleControl.y) - return "upPage" - else - return "downPage" - } - - return "none"; - } - - function subControlRect(arg) { - if (arg === "handle") { - return Qt.rect(handleControl.x, handleControl.y, handleControl.width, handleControl.height); - } else if (arg === "groove") { - if (__styleData.horizontal) { - return Qt.rect(incrementLoader.width - handleOverlap, - 0, - __control.width - (incrementLoader.width + decrementLoader.width - handleOverlap * 2), - __control.height); - } else { - return Qt.rect(0, - incrementLoader.height - handleOverlap, - __control.width, - __control.height - (incrementLoader.height + decrementLoader.height - handleOverlap * 2)); - } - } - return Qt.rect(0,0,0,0); - } - - function itemIsHit(argItem, argX, argY) { - var pos = argItem.mapFromItem(__control, argX, argY); - return (pos.x >= 0 && pos.x <= argItem.width && pos.y >= 0 && pos.y <= argItem.height); - } - - Loader { - id: incrementLoader - anchors.top: parent.top - anchors.left: parent.left - sourceComponent: decrementControl - property QtObject styleData: QtObject { - readonly property bool hovered: activeControl === "up" - readonly property bool pressed: __styleData.upPressed - readonly property bool horizontal: __styleData.horizontal - } - } - - Loader { - id: bg - anchors.top: __styleData.horizontal ? undefined : incrementLoader.bottom - anchors.bottom: __styleData.horizontal ? undefined : decrementLoader.top - anchors.left: __styleData.horizontal ? incrementLoader.right : undefined - anchors.right: __styleData.horizontal ? decrementLoader.left : undefined - sourceComponent: scrollBarBackground - property QtObject styleData: QtObject { - readonly property bool horizontal: __styleData.horizontal - readonly property bool hovered: activeControl !== "none" - } - } - - Loader { - id: decrementLoader - anchors.bottom: __styleData.horizontal ? undefined : parent.bottom - anchors.right: __styleData.horizontal ? parent.right : undefined - sourceComponent: incrementControl - property QtObject styleData: QtObject { - readonly property bool hovered: activeControl === "down" - readonly property bool pressed: __styleData.downPressed - readonly property bool horizontal: __styleData.horizontal - } - } - - property var flickableItem: control.flickableItem - property int extent: Math.max(minimumHandleLength, __styleData.horizontal ? - (flickableItem ? flickableItem.width/flickableItem.contentWidth : 0 ) * bg.width : - (flickableItem ? flickableItem.height/flickableItem.contentHeight : 0) * bg.height) - readonly property real range: __control.maximumValue - __control.minimumValue - readonly property real begin: __control.value - __control.minimumValue - - Loader { - id: handleControl - height: __styleData.horizontal ? implicitHeight : extent - width: __styleData.horizontal ? extent : implicitWidth - anchors.top: bg.top - anchors.left: bg.left - anchors.topMargin: __styleData.horizontal || range === 0 ? 0 : -handleOverlap + (2 * begin * (bg.height + (2 * handleOverlap) - extent) + range) / (2 * range) - anchors.leftMargin: __styleData.horizontal && range !== 0 ? -handleOverlap + (2 * begin * (bg.width + (2 * handleOverlap) - extent) + range) / (2 * range) : 0 - sourceComponent: handle - property QtObject styleData: QtObject { - readonly property bool hovered: activeControl === "handle" - readonly property bool pressed: __styleData.handlePressed - readonly property bool horizontal: __styleData.horizontal - } - readonly property alias __activeControl: panel.activeControl - } - } - - /*! \internal */ - property bool __externalScrollBars: false - /*! \internal */ - property int __scrollBarSpacing: 4 - /*! \internal */ - property int __scrollBarFadeDelay: 450 - /*! \internal */ - property int __scrollBarFadeDuration: 200 - /*! \internal */ - property bool __stickyScrollbars: false -} From 71b17fe2588546d34240ec9ab546730db1c9da41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sun, 17 Oct 2021 14:51:28 +0200 Subject: [PATCH 84/93] Trivial migrations to QtQuick 2.15 --- YACReaderLibrary/qml/ComicInfoView.qml | 10 ++++------ YACReaderLibrary/qml/FlowView.qml | 4 ++-- YACReaderLibrary/qml/InfoFavorites.qml | 2 +- YACReaderLibrary/qml/InfoRating.qml | 4 +--- YACReaderLibrary/qml/InfoTick.qml | 3 +-- 5 files changed, 9 insertions(+), 14 deletions(-) diff --git a/YACReaderLibrary/qml/ComicInfoView.qml b/YACReaderLibrary/qml/ComicInfoView.qml index 63aa2899..3fae55af 100644 --- a/YACReaderLibrary/qml/ComicInfoView.qml +++ b/YACReaderLibrary/qml/ComicInfoView.qml @@ -1,15 +1,13 @@ -import QtQuick 2.6 +import QtQuick 2.15 -import QtQuick.Controls 1.4 -import QtQuick.Layouts 1.2 - -import QtGraphicalEffects 1.0 +import QtQuick.Controls 2.15 +import QtQuick.Layouts 1.12 import com.yacreader.ComicInfo 1.0 import com.yacreader.ComicDB 1.0 -Rectangle { +Rectangle { color : "transparent" id: mainContainer diff --git a/YACReaderLibrary/qml/FlowView.qml b/YACReaderLibrary/qml/FlowView.qml index 112a01e0..38507d5a 100644 --- a/YACReaderLibrary/qml/FlowView.qml +++ b/YACReaderLibrary/qml/FlowView.qml @@ -1,5 +1,5 @@ -import QtQuick 2.3 -import QtQuick.Controls 1.4 +import QtQuick 2.15 +import QtQuick.Controls 2.15 import QtGraphicalEffects 1.0 diff --git a/YACReaderLibrary/qml/InfoFavorites.qml b/YACReaderLibrary/qml/InfoFavorites.qml index 4b6c436d..57b43a9a 100644 --- a/YACReaderLibrary/qml/InfoFavorites.qml +++ b/YACReaderLibrary/qml/InfoFavorites.qml @@ -1,4 +1,4 @@ -import QtQuick 2.6 +import QtQuick 2.15 import QtGraphicalEffects 1.0 diff --git a/YACReaderLibrary/qml/InfoRating.qml b/YACReaderLibrary/qml/InfoRating.qml index 124ccc8e..fd039701 100644 --- a/YACReaderLibrary/qml/InfoRating.qml +++ b/YACReaderLibrary/qml/InfoRating.qml @@ -1,4 +1,4 @@ -import QtQuick 2.6 +import QtQuick 2.15 import QtGraphicalEffects 1.0 @@ -45,6 +45,4 @@ Row { } } } - - } diff --git a/YACReaderLibrary/qml/InfoTick.qml b/YACReaderLibrary/qml/InfoTick.qml index f7b5f1e1..7bfe4e83 100644 --- a/YACReaderLibrary/qml/InfoTick.qml +++ b/YACReaderLibrary/qml/InfoTick.qml @@ -1,4 +1,4 @@ -import QtQuick 2.6 +import QtQuick 2.15 import QtGraphicalEffects 1.0 @@ -26,4 +26,3 @@ Item { color: read ? readTickCheckedColor : readTickUncheckedColor } } - From 45b94cd8efe9749e2884d51025c014e0cf2c1d2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sun, 17 Oct 2021 14:54:13 +0200 Subject: [PATCH 85/93] Migrate GridComicsView and InfoComicsView to QtQuick and QtQuick.Controls 2.15 --- YACReaderLibrary/qml/GridComicsView.qml | 305 +++++++++++------------- YACReaderLibrary/qml/InfoComicsView.qml | 46 ++-- 2 files changed, 167 insertions(+), 184 deletions(-) diff --git a/YACReaderLibrary/qml/GridComicsView.qml b/YACReaderLibrary/qml/GridComicsView.qml index f09e2049..feb9b350 100644 --- a/YACReaderLibrary/qml/GridComicsView.qml +++ b/YACReaderLibrary/qml/GridComicsView.qml @@ -1,10 +1,12 @@ -import QtQuick 2.9 +import QtQuick 2.15 -import QtQuick.Controls 1.4 -import QtQuick.Layouts 1.3 +import QtQuick.Controls 2.15 +import QtQuick.Layouts 1.12 import QtGraphicalEffects 1.0 -import QtQuick.Controls.Styles 1.4 + + +import Qt.labs.animation 1.0 import com.yacreader.ComicModel 1.0 @@ -12,12 +14,11 @@ import com.yacreader.ComicInfo 1.0 import com.yacreader.ComicDB 1.0 SplitView { - //anchors.fill: parent orientation: Qt.Horizontal - handleDelegate:Rectangle { - width: 1 - height: 1 - color: "#202020" + handle: Rectangle { + border.width : 0 + implicitWidth: 10 + color: info_container.color } Rectangle { @@ -47,8 +48,8 @@ Rectangle { color: backgroundColor width: parent.width - (info_container.visible ? info_container.width : 0) - Layout.fillWidth: true - Layout.minimumWidth: coverWidth + 100 + SplitView.fillWidth: true + SplitView.minimumWidth: coverWidth + 100 height: parent.height anchors.margins: 0 @@ -364,12 +365,24 @@ Rectangle { } Menu { + background: Rectangle { + implicitWidth: 42 + implicitHeight: 100 + //border.color: "#222" + //color: "#444" + } + id: ratingConextMenu - MenuItem { text: "1"; enabled: true; iconSource:"star_menu.png"; onTriggered: comicRatingHelper.rate(index,1) } - MenuItem { text: "2"; enabled: true; iconSource:"star_menu.png"; onTriggered: comicRatingHelper.rate(index,2) } - MenuItem { text: "3"; enabled: true; iconSource:"star_menu.png"; onTriggered: comicRatingHelper.rate(index,3) } - MenuItem { text: "4"; enabled: true; iconSource:"star_menu.png"; onTriggered: comicRatingHelper.rate(index,4) } - MenuItem { text: "5"; enabled: true; iconSource:"star_menu.png"; onTriggered: comicRatingHelper.rate(index,5) } + + Action { text: "1"; enabled: true; icon.source:"star_menu.png"; onTriggered: comicRatingHelper.rate(index,1) } + Action { text: "2"; enabled: true; icon.source:"star_menu.png"; onTriggered: comicRatingHelper.rate(index,2) } + Action { text: "3"; enabled: true; icon.source:"star_menu.png"; onTriggered: comicRatingHelper.rate(index,3) } + Action { text: "4"; enabled: true; icon.source:"star_menu.png"; onTriggered: comicRatingHelper.rate(index,4) } + Action { text: "5"; enabled: true; icon.source:"star_menu.png"; onTriggered: comicRatingHelper.rate(index,5) } + + delegate: MenuItem { + implicitHeight: 30 + } } } @@ -383,41 +396,18 @@ Rectangle { } } - ScrollView { - __wheelAreaScrollSpeed: grid.cellHeight * 0.40 + Rectangle { id: scrollView objectName: "topScrollView" anchors.fill: parent anchors.margins: 0 + children: grid + + color: "transparent" function scrollToOrigin() { - flickableItem.contentY = showCurrentComic ? -270 : -20 - flickableItem.contentX = 0 - } - - style: YACReaderScrollViewStyle { - transientScrollBars: false - incrementControl: Item {} - decrementControl: Item {} - handle: Item { - implicitWidth: 16 - implicitHeight: 26 - Rectangle { - color: "#88424242" - anchors.fill: parent - anchors.topMargin: 6 - anchors.leftMargin: 4 - anchors.rightMargin: 4 - anchors.bottomMargin: 6 - border.color: "#AA313131" - border.width: 1 - radius: 8 - } - } - scrollBarBackground: Item { - implicitWidth: 16 - implicitHeight: 26 - } + grid.contentY = grid.originY + grid.contentX = grid.originX } DropArea { @@ -620,34 +610,13 @@ Rectangle { Layout.maximumHeight: (currentComicVisualView.height * 0.32) Layout.maximumWidth: 960 - contentItem: currentComicInfoSinopsis + ScrollBar.horizontal.policy: ScrollBar.AlwaysOff - horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff + contentItem: currentComicInfoSinopsis id: synopsisScroller - style: ScrollViewStyle { - transientScrollBars: false - incrementControl: Item {} - decrementControl: Item {} - handle: Item { - implicitWidth: 12 - implicitHeight: 26 - Rectangle { - color: "#424246" - anchors.fill: parent - anchors.topMargin: 6 - anchors.leftMargin: 9 - anchors.rightMargin: 0 - anchors.bottomMargin: 6 - radius: 2 - } - } - scrollBarBackground: Item { - implicitWidth: 14 - implicitHeight: 26 - } - } + clip: true Text { Layout.maximumWidth: 960 @@ -680,18 +649,16 @@ Rectangle { anchors.bottomMargin: 15 onClicked: comicOpener.triggerOpenCurrentComic() - - style: ButtonStyle { background: Rectangle { implicitWidth: 100 implicitHeight: 30 - border.width: control.activeFocus ? 2 : 1 + border.width: readButton.activeFocus ? 2 : 1 border.color: "#FFCC00" radius: height / 2 color: "#FFCC00" - } - label: Text { + + contentItem: Text { renderType: Text.NativeRendering verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter @@ -699,9 +666,8 @@ Rectangle { font.pointSize: 12 font.bold: true color: "white" - text: control.text + text: readButton.text } - } } @@ -725,26 +691,21 @@ Rectangle { anchors.fill: parent cellHeight: cellCustomHeight header: currentComicView - //highlight: appHighlight focus: true model: comicsList delegate: appDelegate - anchors.topMargin: 0 //showCurrentComic ? 0 : 20 - anchors.bottomMargin: 20 + anchors.topMargin: 0 + anchors.bottomMargin: 10 anchors.leftMargin: 0 anchors.rightMargin: 0 pixelAligned: true - //flickDeceleration: -2000 - + highlightFollowsCurrentItem: true currentIndex: 0 cacheBuffer: 0 - footer: Rectangle { //fix for the scroll issue, TODO find what causes the issue (some times the bottoms cells are hidden for the toolbar, no full scroll) - height : 25 - width : parent.width - color : "#00000000" - } + //disable flickable behaviour + interactive: false move: Transition { NumberAnimation { properties: "x,y"; duration: 250 } @@ -780,116 +741,130 @@ Rectangle { } function calculateCellWidths(cWidth) { - var wholeCells = Math.floor(width / cWidth); var rest = width - (cWidth * wholeCells) grid.cellWidth = cWidth + Math.floor(rest / wholeCells); - //console.log("cWidth",cWidth,"wholeCells=",wholeCells,"rest=",rest,"cellWidth=",cellWidth,"width=",width); + } + + WheelHandler { + onWheel: { + if (grid.contentHeight <= grid.height) { + return; + } + + var newValue = Math.min((grid.contentHeight - grid.height - (showCurrentComic ? 270 : 20)), (Math.max(grid.originY , grid.contentY - event.angleDelta.y))); + grid.contentY = newValue; + } + } + + ScrollBar.vertical: ScrollBar { + visible: grid.contentHeight > grid.height + + contentItem: Item { + implicitWidth: 12 + implicitHeight: 26 + Rectangle { + color: "#88424242" + anchors.fill: parent + anchors.topMargin: 6 + anchors.leftMargin: 3 + anchors.rightMargin: 2 + anchors.bottomMargin: 6 + border.color: "#AA313131" + border.width: 1 + radius: 3.5 + } + } + } + + Keys.onPressed: { + if (event.modifiers & Qt.ControlModifier || event.modifiers & Qt.ShiftModifier) { + event.accepted = true + return; + } + + var numCells = grid.numCellsPerRow(); + var ci = 0; + if (event.key === Qt.Key_Right) { + ci = Math.min(grid.currentIndex+1,grid.count - 1); + } + else if (event.key === Qt.Key_Left) { + ci = Math.max(0,grid.currentIndex-1); + } + else if (event.key === Qt.Key_Up) { + ci = Math.max(0,grid.currentIndex-numCells); + } + else if (event.key === Qt.Key_Down) { + ci = Math.min(grid.currentIndex+numCells,grid.count - 1); + } else { + return; + } + + event.accepted = true; + grid.currentIndex = -1 + comicsSelectionHelper.clear(); + currentIndexHelper.setCurrentIndex(ci); + grid.currentIndex = ci; } } - - focus: true - Keys.onPressed: { - if (event.modifiers & Qt.ControlModifier || event.modifiers & Qt.ShiftModifier) - return; - var numCells = grid.numCellsPerRow(); - var ci - if (event.key === Qt.Key_Right) { - ci = Math.min(grid.currentIndex+1,grid.count - 1); - } - else if (event.key === Qt.Key_Left) { - ci = Math.max(0,grid.currentIndex-1); - } - else if (event.key === Qt.Key_Up) { - ci = Math.max(0,grid.currentIndex-numCells); - } - else if (event.key === Qt.Key_Down) { - ci = Math.min(grid.currentIndex+numCells,grid.count - 1); - } else { - return; - } - - event.accepted = true; - //var ci = grid.currentIndex; - grid.currentIndex = -1 - comicsSelectionHelper.clear(); - currentIndexHelper.setCurrentIndex(ci); - grid.currentIndex = ci; - } - //} - - /*MouseArea { - anchors.fill: parent - onClicked: { - clicked.accepted = false; - console.log("xx"); - } - - onWheel: { - var newValue = Math.max(0,scrollView.flickableItem.contentY - wheel.angleDelta.y) - scrollView.flickableItem.contentY = newValue - - } - }*/ - /*ScrollBar { - flickable: grid; - } - - PerformanceMeter { - anchors {top: parent.top; left: parent.left; margins: 4} - id: performanceMeter - width: 128 - height: 64 - enabled: (dummyValue || !dummyValue) - }*/ - } } + Rectangle { id: info_container objectName: "infoContainer" - Layout.preferredWidth: 350 - Layout.minimumWidth: 350 - Layout.maximumWidth: 960 + SplitView.preferredWidth: 350 + SplitView.minimumWidth: 350 + SplitView.maximumWidth: 960 height: parent.height color: infoBackgroundColor visible: showInfo - ScrollView { - __wheelAreaScrollSpeed: 75 + Flickable{ + id: infoFlickable anchors.fill: parent anchors.margins: 0 - horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff + contentWidth: infoView.width + contentHeight: infoView.height - style: ScrollViewStyle { - transientScrollBars: false - incrementControl: Item {} - decrementControl: Item {} - handle: Item { - implicitWidth: 10 + ComicInfoView { + id: infoView + width: info_container.width + } + + WheelHandler { + onWheel: { + if (infoFlickable.contentHeight <= infoFlickable.height) { + return; + } + + var newValue = Math.min((infoFlickable.contentHeight - infoFlickable.height), (Math.max(infoFlickable.originY , infoFlickable.contentY - event.angleDelta.y))); + infoFlickable.contentY = newValue; + } + } + + ScrollBar.vertical: ScrollBar { + visible: infoFlickable.contentHeight > infoFlickable.height + + contentItem: Item { + implicitWidth: 12 implicitHeight: 26 Rectangle { color: "#424246" anchors.fill: parent anchors.topMargin: 6 - anchors.leftMargin: 4 + anchors.leftMargin: 5 anchors.rightMargin: 4 anchors.bottomMargin: 6 + radius: 2 } } - scrollBarBackground: Item { - implicitWidth: 14 - implicitHeight: 26 - } - } - - ComicInfoView { - width: info_container.width } } + } } diff --git a/YACReaderLibrary/qml/InfoComicsView.qml b/YACReaderLibrary/qml/InfoComicsView.qml index e1e701dc..df1b3c23 100644 --- a/YACReaderLibrary/qml/InfoComicsView.qml +++ b/YACReaderLibrary/qml/InfoComicsView.qml @@ -1,8 +1,6 @@ -import QtQuick 2.5 +import QtQuick 2.15 -import QtQuick.Controls 1.2 -import QtGraphicalEffects 1.0 -import QtQuick.Controls.Styles 1.4 +import QtQuick.Controls 2.15 import com.yacreader.ComicModel 1.0 @@ -59,39 +57,49 @@ Rectangle { y: flow.height + flow.additionalBottomSpace - 6 height: parent.height - y + clip: true + color: infoBackgroundColor - ScrollView { - __wheelAreaScrollSpeed: 75 + Flickable{ + id: infoFlickable anchors.fill: parent anchors.margins: 0 - horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff + contentWidth: infoView.width + contentHeight: infoView.height - style: ScrollViewStyle { - transientScrollBars: false - incrementControl: Item {} - decrementControl: Item {} - handle: Item { - implicitWidth: 10 + WheelHandler { + onWheel: { + if (infoFlickable.contentHeight <= infoFlickable.height) { + return; + } + + var newValue = Math.min((infoFlickable.contentHeight - infoFlickable.height), (Math.max(infoFlickable.originY , infoFlickable.contentY - event.angleDelta.y))); + infoFlickable.contentY = newValue; + } + } + + ScrollBar.vertical: ScrollBar { + visible: infoFlickable.contentHeight > infoFlickable.height + + contentItem: Item { + implicitWidth: 12 implicitHeight: 26 Rectangle { color: "#424246" anchors.fill: parent anchors.topMargin: 6 - anchors.leftMargin: 4 + anchors.leftMargin: 5 anchors.rightMargin: 4 anchors.bottomMargin: 6 + radius: 2 } } - - scrollBarBackground: Item { - implicitWidth: 14 - implicitHeight: 26 - } } ComicInfoView { + id: infoView width: info_container.width - 14 } } From bac5cfe9c2f3a117c22745a9385cbd316a0d2d49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Wed, 20 Oct 2021 19:19:32 +0200 Subject: [PATCH 86/93] Bump unbuntu image to 20.04 --- azure-pipelines.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 49e3920c..a5218c26 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -30,7 +30,7 @@ jobs: - job: Linux dependsOn: CodeFormatValidation pool: - vmImage: 'ubuntu-18.04' + vmImage: 'ubuntu-20.04' steps: - script: | sudo add-apt-repository 'deb http://download.opensuse.org/repositories/home:/selmf/xUbuntu_18.04/ /' @@ -131,7 +131,7 @@ jobs: variables: - group: artifactory pool: - vmImage: 'ubuntu-18.04' + vmImage: 'ubuntu-20.04' steps: - task: DownloadPipelineArtifact@2 inputs: @@ -159,7 +159,7 @@ jobs: variables: - group: github-releases pool: - vmImage: 'ubuntu-18.04' + vmImage: 'ubuntu-20.04' steps: - task: DownloadPipelineArtifact@2 inputs: From 820e876885be5dbf499816486de1b33ebefcc665 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Wed, 20 Oct 2021 19:25:53 +0200 Subject: [PATCH 87/93] try to get qt5.15 in ubuntu --- azure-pipelines.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a5218c26..e44a18f9 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -34,6 +34,8 @@ jobs: steps: - script: | sudo add-apt-repository 'deb http://download.opensuse.org/repositories/home:/selmf/xUbuntu_18.04/ /' + wget -qO - 'http://archive.neon.kde.org/public.key' | sudo apt-key add - + sudo apt-add-repository http://archive.neon.kde.org/user sudo apt-get update --allow-insecure-repositories sudo apt-get install -y --allow-unauthenticated qt5-default qt5-qmake \ qtbase5-dev qtmultimedia5-dev libpoppler-qt5-dev \ From 3d7f66d327c0ae428825ae387c7f38b419742ee7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Wed, 20 Oct 2021 21:07:00 +0200 Subject: [PATCH 88/93] Try to install the right version of poppler for qt5.15 --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index e44a18f9..2fcd5c26 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -35,7 +35,7 @@ jobs: - script: | sudo add-apt-repository 'deb http://download.opensuse.org/repositories/home:/selmf/xUbuntu_18.04/ /' wget -qO - 'http://archive.neon.kde.org/public.key' | sudo apt-key add - - sudo apt-add-repository http://archive.neon.kde.org/user + sudo apt-add-repository http://archive.neon.kde.org/unstable sudo apt-get update --allow-insecure-repositories sudo apt-get install -y --allow-unauthenticated qt5-default qt5-qmake \ qtbase5-dev qtmultimedia5-dev libpoppler-qt5-dev \ From e1814c5a51383a43b8f5686bf65aa87baa1dc5e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Wed, 20 Oct 2021 22:13:33 +0200 Subject: [PATCH 89/93] Try dev repo to see if fixes compilation when using poppler + qt5.15 --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 2fcd5c26..a320eb43 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -35,7 +35,7 @@ jobs: - script: | sudo add-apt-repository 'deb http://download.opensuse.org/repositories/home:/selmf/xUbuntu_18.04/ /' wget -qO - 'http://archive.neon.kde.org/public.key' | sudo apt-key add - - sudo apt-add-repository http://archive.neon.kde.org/unstable + sudo apt-add-repository http://archive.neon.kde.org/dev sudo apt-get update --allow-insecure-repositories sudo apt-get install -y --allow-unauthenticated qt5-default qt5-qmake \ qtbase5-dev qtmultimedia5-dev libpoppler-qt5-dev \ From fb133fe98c48e8dbc6abeabbd2e55e443f4d3b1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Wed, 20 Oct 2021 22:48:32 +0200 Subject: [PATCH 90/93] Try dev/stable --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a320eb43..7b15be57 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -35,7 +35,7 @@ jobs: - script: | sudo add-apt-repository 'deb http://download.opensuse.org/repositories/home:/selmf/xUbuntu_18.04/ /' wget -qO - 'http://archive.neon.kde.org/public.key' | sudo apt-key add - - sudo apt-add-repository http://archive.neon.kde.org/dev + sudo apt-add-repository http://archive.neon.kde.org/dev/stable sudo apt-get update --allow-insecure-repositories sudo apt-get install -y --allow-unauthenticated qt5-default qt5-qmake \ qtbase5-dev qtmultimedia5-dev libpoppler-qt5-dev \ From ab2de73285aae980838a724a19392c301851e0f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sat, 23 Oct 2021 09:42:21 +0200 Subject: [PATCH 91/93] Try dev/unstable --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 7b15be57..1e369c18 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -35,7 +35,7 @@ jobs: - script: | sudo add-apt-repository 'deb http://download.opensuse.org/repositories/home:/selmf/xUbuntu_18.04/ /' wget -qO - 'http://archive.neon.kde.org/public.key' | sudo apt-key add - - sudo apt-add-repository http://archive.neon.kde.org/dev/stable + sudo apt-add-repository http://archive.neon.kde.org/dev/unstable sudo apt-get update --allow-insecure-repositories sudo apt-get install -y --allow-unauthenticated qt5-default qt5-qmake \ qtbase5-dev qtmultimedia5-dev libpoppler-qt5-dev \ From 4bee29609659e7cf556c80bdf2389ec3c68735a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sat, 23 Oct 2021 17:11:50 +0200 Subject: [PATCH 92/93] Strict qt5.15 breaks poppler --- YACReader/viewer.cpp | 4 ++++ config.pri | 11 ++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/YACReader/viewer.cpp b/YACReader/viewer.cpp index 6b595a70..23ad54db 100644 --- a/YACReader/viewer.cpp +++ b/YACReader/viewer.cpp @@ -775,7 +775,11 @@ void Viewer::mouseMoveEvent(QMouseEvent *event) const QPixmap Viewer::pixmap() { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) return content->pixmap(); +#else + return content->pixmap(Qt::ReturnByValue); +#endif } void Viewer::magnifyingGlassSwitch() diff --git a/config.pri b/config.pri index 0b00b076..6259bd13 100644 --- a/config.pri +++ b/config.pri @@ -36,9 +36,6 @@ defineTest(minQtVersion) { error(YACReader requires Qt 5.15 or newer but $$[QT_VERSION] was detected) } -DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x050F00 -DEFINES += QT_DEPRECATED_WARNINGS - # reduce log pollution CONFIG += silent @@ -81,3 +78,11 @@ unix:!macx:!CONFIG(poppler):!CONFIG(pdfium):!CONFIG(no_pdf) { macx:!CONFIG(pdfkit):!CONFIG(pdfium):!CONFIG(no_pdf) { CONFIG += pdfkit } + +!CONFIG(poppler) { + DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x050F00 +} else { + DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x050900 +} + +DEFINES += QT_DEPRECATED_WARNINGS From 806b5d2462b9edf9412e06ddb7b253d9389c50ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sat, 23 Oct 2021 17:29:37 +0200 Subject: [PATCH 93/93] Install qtquickcontrols2 package in Linux --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 1e369c18..c31e4bdb 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -39,7 +39,7 @@ jobs: sudo apt-get update --allow-insecure-repositories sudo apt-get install -y --allow-unauthenticated qt5-default qt5-qmake \ qtbase5-dev qtmultimedia5-dev libpoppler-qt5-dev \ - libqt5opengl5-dev libunarr-dev qtdeclarative5-dev libqt5svg5-dev + libqt5opengl5-dev libunarr-dev qtdeclarative5-dev libqt5svg5-dev qtquickcontrols2-5-dev displayName: 'Install dependencies' - script: | cd $(Build.SourcesDirectory)