From 47324e7f2293ff095c0536f471e3af49028b7028 Mon Sep 17 00:00:00 2001 From: Felix Kauselmann Date: Fri, 11 Jun 2021 11:46:54 +0200 Subject: [PATCH] Comic/Render: Use overloads refactor some SIGNAL/SLOT connections to new syntax --- YACReader/render.cpp | 22 +++++++++---------- YACReader/viewer.cpp | 14 +++++------- .../server/controllers/v1/comiccontroller.cpp | 4 ++-- .../controllers/v2/comiccontroller_v2.cpp | 4 ++-- .../v2/comiccontrollerinreadinglist_v2.cpp | 4 ++-- common/comic.cpp | 4 ++-- 6 files changed, 25 insertions(+), 27 deletions(-) diff --git a/YACReader/render.cpp b/YACReader/render.cpp index 69f06b78..e7e7caaa 100644 --- a/YACReader/render.cpp +++ b/YACReader/render.cpp @@ -710,16 +710,16 @@ void Render::createComic(const QString &path) return; } - connect(comic, SIGNAL(errorOpening()), this, SIGNAL(errorOpening()), Qt::QueuedConnection); - connect(comic, SIGNAL(errorOpening(QString)), this, SIGNAL(errorOpening(QString)), Qt::QueuedConnection); + connect(comic, QOverload<>::of(&Comic::errorOpening), this, QOverload<>::of(&Render::errorOpening), Qt::QueuedConnection); + connect(comic, QOverload::of(&Comic::errorOpening), this, QOverload::of(&Render::errorOpening), Qt::QueuedConnection); connect(comic, &Comic::crcErrorFound, this, &Render::crcError, Qt::QueuedConnection); - connect(comic, SIGNAL(errorOpening()), this, SLOT(reset()), Qt::QueuedConnection); - connect(comic, SIGNAL(imageLoaded(int)), this, SLOT(pageRawDataReady(int)), Qt::QueuedConnection); - connect(comic, SIGNAL(imageLoaded(int)), this, SIGNAL(imageLoaded(int)), Qt::QueuedConnection); + connect(comic, QOverload<>::of(&Comic::errorOpening), this, &Render::reset, Qt::QueuedConnection); + connect(comic, QOverload::of(&Comic::imageLoaded), this, &Render::pageRawDataReady, Qt::QueuedConnection); + connect(comic, QOverload::of(&Comic::imageLoaded), this, QOverload::of(&Render::imageLoaded), Qt::QueuedConnection); connect(comic, &Comic::openAt, this, &Render::renderAt, Qt::QueuedConnection); - connect(comic, SIGNAL(numPages(unsigned int)), this, SIGNAL(numPages(unsigned int)), Qt::QueuedConnection); - connect(comic, SIGNAL(numPages(unsigned int)), this, SLOT(setNumPages(unsigned int)), Qt::QueuedConnection); - connect(comic, SIGNAL(imageLoaded(int, QByteArray)), this, SIGNAL(imageLoaded(int, QByteArray)), Qt::QueuedConnection); + connect(comic, QOverload::of(&Comic::numPages), this, QOverload::of(&Render::numPages), Qt::QueuedConnection); + connect(comic, QOverload::of(&Comic::numPages), this, QOverload::of(&Render::setNumPages), Qt::QueuedConnection); + connect(comic, QOverload::of(&Comic::imageLoaded), this, QOverload::of(&Render::imageLoaded), Qt::QueuedConnection); connect(comic, &Comic::isBookmark, this, &Render::currentPageIsBookmark, Qt::QueuedConnection); connect(comic, &Comic::bookmarksUpdated, this, &Render::bookmarksUpdated, Qt::QueuedConnection); @@ -746,10 +746,10 @@ void Render::startLoad() comic->moveToThread(thread); - connect(comic, SIGNAL(errorOpening()), thread, SLOT(quit()), Qt::QueuedConnection); - connect(comic, SIGNAL(errorOpening(QString)), thread, SLOT(quit()), Qt::QueuedConnection); + connect(comic, QOverload<>::of(&Comic::errorOpening), thread, &QThread::quit, Qt::QueuedConnection); + connect(comic, QOverload::of(&Comic::errorOpening), thread, &QThread::quit, Qt::QueuedConnection); connect(comic, &Comic::imagesLoaded, thread, &QThread::quit, Qt::QueuedConnection); - connect(comic, SIGNAL(destroyed()), thread, SLOT(quit()), Qt::QueuedConnection); + connect(comic, &Comic::destroyed, thread, &QThread::quit, Qt::QueuedConnection); connect(comic, &Comic::invalidated, thread, &QThread::quit, Qt::QueuedConnection); connect(thread, &QThread::started, comic, &Comic::process); connect(thread, &QThread::finished, thread, &QObject::deleteLater); diff --git a/YACReader/viewer.cpp b/YACReader/viewer.cpp index 9161d1a2..92c7071f 100644 --- a/YACReader/viewer.cpp +++ b/YACReader/viewer.cpp @@ -172,19 +172,17 @@ void Viewer::createConnections() connect(bd, &BookmarksDialog::goToPage, this, &Viewer::goTo); //render - connect(render, SIGNAL(errorOpening()), this, SLOT(resetContent())); - connect(render, SIGNAL(errorOpening()), this, SLOT(showMessageErrorOpening())); - connect(render, SIGNAL(errorOpening(QString)), this, SLOT(showMessageErrorOpening(QString))); + connect(render, QOverload<>::of(&Render::errorOpening), this, &Viewer::resetContent); + connect(render, QOverload<>::of(&Render::errorOpening), this, QOverload<>::of(&Viewer::showMessageErrorOpening)); + connect(render, QOverload::of(&Render::errorOpening), this, QOverload::of(&Viewer::showMessageErrorOpening)); connect(render, &Render::crcError, this, &Viewer::processCRCError); - connect(render, SIGNAL(numPages(unsigned int)), goToFlow, SLOT(setNumSlides(unsigned int))); - connect(render, SIGNAL(numPages(unsigned int)), goToDialog, SLOT(setNumPages(unsigned int))); - //connect(render,SIGNAL(numPages(unsigned int)),this,SLOT(updateInformation())); - connect(render, SIGNAL(imageLoaded(int, QByteArray)), goToFlow, SLOT(setImageReady(int, QByteArray))); + connect(render, QOverload::of(&Render::numPages), goToFlow, &GoToFlowWidget::setNumSlides); + connect(render, QOverload::of(&Render::numPages), goToDialog, &GoToDialog::setNumPages); + connect(render, QOverload::of(&Render::imageLoaded), goToFlow, &GoToFlowWidget::setImageReady); connect(render, &Render::currentPageReady, this, &Viewer::updatePage); connect(render, &Render::processingPage, this, &Viewer::setLoadingMessage); connect(render, &Render::currentPageIsBookmark, this, &Viewer::pageIsBookmark); connect(render, &Render::pageChanged, this, &Viewer::updateInformation); - //connect(render,SIGNAL(bookmarksLoaded(Bookmarks)),this,SLOT(setBookmarks(Bookmarks))); connect(render, &Render::isLast, this, &Viewer::showIsLastMessage); connect(render, &Render::isCover, this, &Viewer::showIsCoverMessage); diff --git a/YACReaderLibrary/server/controllers/v1/comiccontroller.cpp b/YACReaderLibrary/server/controllers/v1/comiccontroller.cpp index 3fb5f8b3..e97e34aa 100644 --- a/YACReaderLibrary/server/controllers/v1/comiccontroller.cpp +++ b/YACReaderLibrary/server/controllers/v1/comiccontroller.cpp @@ -61,8 +61,8 @@ void ComicController::service(HttpRequest &request, HttpResponse &response) comicFile->moveToThread(thread); - connect(comicFile, SIGNAL(errorOpening()), thread, SLOT(quit())); - connect(comicFile, SIGNAL(errorOpening(QString)), thread, SLOT(quit())); + connect(comicFile, QOverload<>::of(&Comic::errorOpening), thread, &QThread::quit); + connect(comicFile, QOverload::of(&Comic::errorOpening), thread, &QThread::quit); connect(comicFile, &Comic::imagesLoaded, thread, &QThread::quit); connect(thread, &QThread::started, comicFile, &Comic::process); connect(thread, &QThread::finished, thread, &QObject::deleteLater); diff --git a/YACReaderLibrary/server/controllers/v2/comiccontroller_v2.cpp b/YACReaderLibrary/server/controllers/v2/comiccontroller_v2.cpp index 3440b0ea..92e3d863 100644 --- a/YACReaderLibrary/server/controllers/v2/comiccontroller_v2.cpp +++ b/YACReaderLibrary/server/controllers/v2/comiccontroller_v2.cpp @@ -66,8 +66,8 @@ void ComicControllerV2::service(HttpRequest &request, HttpResponse &response) comicFile->moveToThread(thread); - connect(comicFile, SIGNAL(errorOpening()), thread, SLOT(quit())); - connect(comicFile, SIGNAL(errorOpening(QString)), thread, SLOT(quit())); + connect(comicFile, QOverload<>::of(&Comic::errorOpening), thread, &QThread::quit); + connect(comicFile, QOverload::of(&Comic::errorOpening), thread, &QThread::quit); connect(comicFile, &Comic::imagesLoaded, thread, &QThread::quit); connect(thread, &QThread::started, comicFile, &Comic::process); connect(thread, &QThread::finished, thread, &QObject::deleteLater); diff --git a/YACReaderLibrary/server/controllers/v2/comiccontrollerinreadinglist_v2.cpp b/YACReaderLibrary/server/controllers/v2/comiccontrollerinreadinglist_v2.cpp index 9cd697e1..b97235f6 100644 --- a/YACReaderLibrary/server/controllers/v2/comiccontrollerinreadinglist_v2.cpp +++ b/YACReaderLibrary/server/controllers/v2/comiccontrollerinreadinglist_v2.cpp @@ -53,8 +53,8 @@ void ComicControllerInReadingListV2::service(HttpRequest &request, HttpResponse comicFile->moveToThread(thread); - connect(comicFile, SIGNAL(errorOpening()), thread, SLOT(quit())); - connect(comicFile, SIGNAL(errorOpening(QString)), thread, SLOT(quit())); + connect(comicFile, QOverload<>::of(&Comic::errorOpening), thread, &QThread::quit); + connect(comicFile, QOverload::of(&Comic::errorOpening), thread, &QThread::quit); connect(comicFile, &Comic::imagesLoaded, thread, &QThread::quit); connect(thread, &QThread::started, comicFile, &Comic::process); connect(thread, &QThread::finished, thread, &QObject::deleteLater); diff --git a/common/comic.cpp b/common/comic.cpp index 9d21b6b9..cec0fbe5 100644 --- a/common/comic.cpp +++ b/common/comic.cpp @@ -127,8 +127,8 @@ Comic::~Comic() void Comic::setup() { connect(this, &Comic::pageChanged, this, &Comic::checkIsBookmark); - connect(this, SIGNAL(imageLoaded(int)), this, SLOT(updateBookmarkImage(int))); - connect(this, SIGNAL(imageLoaded(int)), this, SLOT(setPageLoaded(int))); + connect(this, QOverload::of(&Comic::imageLoaded), this, &Comic::updateBookmarkImage); + connect(this, QOverload::of(&Comic::imageLoaded), this, &Comic::setPageLoaded); auto l = [&]() { _errorOpening = true; };