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/YACReader/bookmarks_dialog.cpp b/YACReader/bookmarks_dialog.cpp index aebfd574..75bfac04 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; @@ -85,7 +90,7 @@ BookmarksDialog::BookmarksDialog(QWidget *parent) QPalette Pal(palette()); // set black background - Pal.setColor(QPalette::Background, QColor("#454545")); + Pal.setColor(QPalette::Window, QColor(0x454545)); this->setAutoFillBackground(true); this->setPalette(Pal); @@ -133,7 +138,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 +147,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.cpp b/YACReader/goto_flow.cpp index 97a8f4e0..325a5259 100644 --- a/YACReader/goto_flow.cpp +++ b/YACReader/goto_flow.cpp @@ -195,14 +195,14 @@ void GoToFlow::updateImageData() void GoToFlow::wheelEvent(QWheelEvent *event) { - if (event->delta() < 0) + if (event->angleDelta().y() < 0) flow->showNext(); else flow->showPrevious(); 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; }; 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: diff --git a/YACReader/goto_flow_toolbar.cpp b/YACReader/goto_flow_toolbar.cpp index 183f7dc9..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(setPage(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); @@ -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); @@ -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) @@ -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/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/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(); diff --git a/YACReader/magnifying_glass.cpp b/YACReader/magnifying_glass.cpp index 49e3dab4..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)); } @@ -144,28 +144,28 @@ void MagnifyingGlass::wheelEvent(QWheelEvent *event) switch (event->modifiers()) { // size case Qt::NoModifier: - if (event->delta() < 0) + if (event->angleDelta().y() < 0) sizeUp(); else sizeDown(); break; // size height case Qt::ControlModifier: - if (event->delta() < 0) + if (event->angleDelta().y() < 0) heightUp(); else heightDown(); break; // size width case Qt::AltModifier: - if (event->delta() < 0) + if (event->angleDelta().y() < 0) widthUp(); else widthDown(); break; // zoom level case Qt::ShiftModifier: - if (event->delta() < 0) + if (event->angleDelta().y() < 0) zoomIn(); else zoomOut(); diff --git a/YACReader/main_window_viewer.cpp b/YACReader/main_window_viewer.cpp index c00c8216..9bd53f53 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); @@ -854,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; @@ -974,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/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(); diff --git a/YACReader/notifications_label_widget.cpp b/YACReader/notifications_label_widget.cpp index 4e601d83..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); @@ -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/options_dialog.cpp b/YACReader/options_dialog.cpp index 8ba99c40..5ea3890a 100644 --- a/YACReader/options_dialog.cpp +++ b/YACReader/options_dialog.cpp @@ -137,10 +137,10 @@ 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()); + emit changedImageOptions(); }); scaleLayout->addWidget(scaleCheckbox); @@ -150,10 +150,10 @@ 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()); + 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/page_label_widget.cpp b/YACReader/page_label_widget.cpp index bab7106e..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; @@ -82,7 +87,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/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); } 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/YACReader/translator.cpp b/YACReader/translator.cpp index f35ddfc0..dcae81c0 100644 --- a/YACReader/translator.cpp +++ b/YACReader/translator.cpp @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -51,7 +50,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); @@ -144,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); @@ -289,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) @@ -353,7 +339,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))); @@ -368,11 +354,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(); } } @@ -396,7 +382,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))); @@ -411,10 +397,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/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; diff --git a/YACReader/viewer.cpp b/YACReader/viewer.cpp index 8e4a743e..23ad54db 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(); @@ -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->orientation() == Qt::Horizontal) { - animateScroll(*horizontalScroller, *horizontalScrollBar(), event->delta()); + if (delta.x() != 0) { + animateScroll(*horizontalScroller, *horizontalScrollBar(), delta.x()); return; } - if ((event->delta() < 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->delta() > 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->delta()); + animateScroll(*verticalScroller, *verticalScrollBar(), delta.y()); } } @@ -763,17 +765,21 @@ 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(); } } } -const QPixmap *Viewer::pixmap() +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() @@ -955,7 +961,7 @@ void Viewer::setLoadingMessage() hideMagnifyingGlass(); restoreMagnifyingGlass = true; } - emit(pageAvailable(false)); + emit pageAvailable(false); configureContent(tr("Loading...please wait!")); } @@ -965,7 +971,7 @@ void Viewer::setPageUnavailableMessage() hideMagnifyingGlass(); restoreMagnifyingGlass = true; } - emit(pageAvailable(false)); + emit pageAvailable(false); configureContent(tr("Page not available!")); } @@ -1107,7 +1113,7 @@ void Viewer::showIsCoverMessage() shouldOpenPrevious = true; } else { shouldOpenPrevious = false; - emit(openPreviousComic()); + emit openPreviousComic(); } shouldOpenNext = false; // single page comic @@ -1121,7 +1127,7 @@ void Viewer::showIsLastMessage() shouldOpenNext = true; } else { shouldOpenNext = false; - emit(openNextComic()); + emit openNextComic(); } shouldOpenPrevious = false; // single page comic 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] diff --git a/YACReader/width_slider.cpp b/YACReader/width_slider.cpp index 9915742d..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); @@ -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/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; 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 { diff --git a/YACReaderLibrary/YACReaderLibrary.pro b/YACReaderLibrary/YACReaderLibrary.pro index 0ff05782..d5994578 100644 --- a/YACReaderLibrary/YACReaderLibrary.pro +++ b/YACReaderLibrary/YACReaderLibrary.pro @@ -69,7 +69,9 @@ macx { #CONFIG += release CONFIG -= flat -QT += sql network widgets svg +QT += sql network widgets svg quickcontrols2 + +greaterThan(QT_MAJOR_VERSION, 5): QT += openglwidgets core5compat # Input HEADERS += comic_flow.h \ 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 c10cebb9..0896ebf2 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); @@ -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.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(); diff --git a/YACReaderLibrary/comic_flow_widget.cpp b/YACReaderLibrary/comic_flow_widget.cpp index e515e8f3..372bb46f 100644 --- a/YACReaderLibrary/comic_flow_widget.cpp +++ b/YACReaderLibrary/comic_flow_widget.cpp @@ -20,12 +20,12 @@ 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); // config - QMatrix m; + QTransform m; m.rotate(-90); m.scale(-1, 1); QImage image(":/images/setRead.png"); @@ -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); } diff --git a/YACReaderLibrary/comic_vine/comic_vine_dialog.cpp b/YACReaderLibrary/comic_vine/comic_vine_dialog.cpp index fd8a1130..8e568f48 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 @@ -155,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 } } @@ -203,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; @@ -521,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; @@ -600,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; @@ -614,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..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,15 +58,13 @@ 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(); 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); 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; } 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) { diff --git a/YACReaderLibrary/empty_folder_widget.cpp b/YACReaderLibrary/empty_folder_widget.cpp index 2b07b479..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()); } }; @@ -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..4a266268 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); @@ -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); @@ -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); 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(); } diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp index 8a5e80a1..a1088e99 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 @@ -285,7 +283,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(); @@ -457,8 +455,6 @@ void LibraryWindow::doModels() // lists listsModel = new ReadingListModel(this); listsModelProxy = new ReadingListModelProxy(this); - - // setSearchFilter(YACReader::NoModifiers, ""); //clear search filter } void LibraryWindow::createActions() @@ -1584,7 +1580,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) { @@ -2379,7 +2375,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)); diff --git a/YACReaderLibrary/no_libraries_widget.cpp b/YACReaderLibrary/no_libraries_widget.cpp index 15530470..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); @@ -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/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); 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/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/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 } } 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 } } - 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 -} 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; diff --git a/YACReaderLibrary/server_config_dialog.cpp b/YACReaderLibrary/server_config_dialog.cpp index 1e110a65..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); @@ -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/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(); } 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(); } } 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/YACReaderLibraryServer/YACReaderLibraryServer.pro b/YACReaderLibraryServer/YACReaderLibraryServer.pro index e84ab29a..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 @@ -37,6 +39,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/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") { diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 49e3920c..c31e4bdb 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -30,14 +30,16 @@ 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/ /' + wget -qO - 'http://archive.neon.kde.org/public.key' | sudo apt-key add - + 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 \ - 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) @@ -131,7 +133,7 @@ jobs: variables: - group: artifactory pool: - vmImage: 'ubuntu-18.04' + vmImage: 'ubuntu-20.04' steps: - task: DownloadPipelineArtifact@2 inputs: @@ -159,7 +161,7 @@ jobs: variables: - group: github-releases pool: - vmImage: 'ubuntu-18.04' + vmImage: 'ubuntu-20.04' steps: - task: DownloadPipelineArtifact@2 inputs: diff --git a/common/bookmarks.cpp b/common/bookmarks.cpp index b016ed58..4db72435 100644 --- a/common/bookmarks.cpp +++ b/common/bookmarks.cpp @@ -142,8 +142,8 @@ 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++) { + auto date = QDate().endOfDay(); + for (QMap::const_iterator itr = list.constBegin(); itr != list.constEnd(); itr++) { if (itr->added < date) { comic = itr.key(); date = itr->added; diff --git a/common/check_new_version.cpp b/common/check_new_version.cpp index 5c046650..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" @@ -27,7 +28,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 +37,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()) { diff --git a/common/comic.cpp b/common/comic.cpp index ee4aa890..0349bf93 100644 --- a/common/comic.cpp +++ b/common/comic.cpp @@ -1,7 +1,7 @@ #include "comic.h" #include -#include +#include #include #include #include @@ -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; @@ -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() @@ -604,7 +604,7 @@ void FileComic::process() } _index = _firstPage; - emit(openAt(_index)); + emit openAt(_index); int sectionIndex; QList> sections = getSections(sectionIndex); @@ -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() @@ -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()); @@ -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() @@ -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; @@ -994,15 +994,16 @@ 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; } } - QRegExp allNumberRegExp("\\d+"); - if (allNumberRegExp.exactMatch(common_prefix)) { + QRegularExpression allNumberRegExp("\\A\\d+\\z"); + if (allNumberRegExp.match(common_prefix).hasMatch()) { return ""; } 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: 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 &); diff --git a/common/gl/yacreader_flow_gl.cpp b/common/gl/yacreader_flow_gl.cpp index ba61a2b7..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(); @@ -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(); diff --git a/common/gl/yacreader_flow_gl.h b/common/gl/yacreader_flow_gl.h index bc6bb6e2..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 @@ -252,9 +260,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(); diff --git a/common/pictureflow.cpp b/common/pictureflow.cpp index bcd222e6..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 { @@ -1338,7 +1340,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 +1358,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); diff --git a/common/scroll_management.cpp b/common/scroll_management.cpp index 8b4674f4..a9573037 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; } @@ -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)) { 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; }; 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) 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" diff --git a/compressed_archive/compressed_archive.cpp b/compressed_archive/compressed_archive.cpp index 830531ff..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 } @@ -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); @@ -443,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; @@ -466,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); diff --git a/config.pri b/config.pri index 3b14f8c2..6259bd13 100644 --- a/config.pri +++ b/config.pri @@ -2,7 +2,8 @@ # default values if they're not set on build time # for a more detailed description, see INSTALL.TXT -CONFIG += c++11 +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 @@ -31,17 +32,10 @@ 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) } -minQtVersion(6, 0, 0) { - error(YACReader does not support building with Qt6 (yet)) -} - -DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x050900 -DEFINES += QT_DEPRECATED_WARNINGS - # reduce log pollution CONFIG += silent @@ -84,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 diff --git a/custom_widgets/help_about_dialog.cpp b/custom_widgets/help_about_dialog.cpp index 9e6d745d..d2ff2286 100644 --- a/custom_widgets/help_about_dialog.cpp +++ b/custom_widgets/help_about_dialog.cpp @@ -6,8 +6,11 @@ #include #include #include +#include + +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) #include -#include +#endif #include "yacreader_global.h" @@ -31,7 +34,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() @@ -56,7 +67,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); } @@ -72,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/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. 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(); 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_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(); } 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 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 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;}"; diff --git a/shortcuts_management/actions_shortcuts_model.cpp b/shortcuts_management/actions_shortcuts_model.cpp index 91447231..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) @@ -59,7 +60,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(); 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(); } 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"