From f1e4396dc52d305492da2f0c561a956242dee910 Mon Sep 17 00:00:00 2001 From: Felix Kauselmann Date: Tue, 22 Jun 2021 12:37:27 +0200 Subject: [PATCH] YACReaderLibrary: Convert a bunch of widgets/dialogs to new slot syntax --- YACReaderLibrary/import_widget.cpp | 8 ++++---- YACReaderLibrary/library_window.cpp | 20 +++++++++++--------- YACReaderLibrary/package_manager.cpp | 3 ++- YACReaderLibrary/server_config_dialog.cpp | 2 +- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/YACReaderLibrary/import_widget.cpp b/YACReaderLibrary/import_widget.cpp index 9cfa0d3f..d33f6ae3 100644 --- a/YACReaderLibrary/import_widget.cpp +++ b/YACReaderLibrary/import_widget.cpp @@ -59,14 +59,14 @@ YACReaderActivityIndicatorWidget::YACReaderActivityIndicatorWidget(QWidget *pare auto effect = new QGraphicsOpacityEffect(); //effect->setOpacity(1.0); - QPropertyAnimation *animation = new QPropertyAnimation(effect, "opacity"); + auto *animation = new QPropertyAnimation(effect, "opacity", this); animation->setDuration(1000); animation->setStartValue(1); animation->setEndValue(0); //animation->setEasingCurve(QEasingCurve::InQuint); - QPropertyAnimation *animation2 = new QPropertyAnimation(effect, "opacity"); + auto *animation2 = new QPropertyAnimation(effect, "opacity", this); animation2->setDuration(1000); animation2->setStartValue(0); @@ -75,8 +75,8 @@ YACReaderActivityIndicatorWidget::YACReaderActivityIndicatorWidget(QWidget *pare glow->setGraphicsEffect(effect); - connect(animation, SIGNAL(finished()), animation2, SLOT(start())); - connect(animation2, SIGNAL(finished()), animation, SLOT(start())); + connect(animation, &QPropertyAnimation::finished, animation2, [=] { animation2->start(); }); + connect(animation2, &QPropertyAnimation::finished, animation, [=] { animation->start(); }); animation->start(); } diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp index d7335ba4..9d9e8e3b 100644 --- a/YACReaderLibrary/library_window.cpp +++ b/YACReaderLibrary/library_window.cpp @@ -1067,13 +1067,13 @@ void LibraryWindow::createConnections() //connect(foldersView, SIGNAL(clicked(QModelIndex)), historyController, SLOT(updateHistory(QModelIndex))); //libraryCreator connections - connect(createLibraryDialog, SIGNAL(createLibrary(QString, QString, QString)), this, SLOT(create(QString, QString, QString))); + connect(createLibraryDialog, &CreateLibraryDialog::createLibrary, this, QOverload::of(&LibraryWindow::create)); connect(createLibraryDialog, &CreateLibraryDialog::libraryExists, this, &LibraryWindow::libraryAlreadyExists); connect(importComicsInfoDialog, &QDialog::finished, this, &LibraryWindow::reloadCurrentLibrary); //connect(libraryCreator,SIGNAL(coverExtracted(QString)),createLibraryDialog,SLOT(showCurrentFile(QString))); //connect(libraryCreator,SIGNAL(coverExtracted(QString)),updateLibraryDialog,SLOT(showCurrentFile(QString))); - connect(libraryCreator, SIGNAL(finished()), this, SLOT(showRootWidget())); + connect(libraryCreator, &LibraryCreator::finished, this, &LibraryWindow::showRootWidget); connect(libraryCreator, &LibraryCreator::updated, this, &LibraryWindow::reloadCurrentLibrary); connect(libraryCreator, &LibraryCreator::created, this, &LibraryWindow::openLastCreated); //connect(libraryCreator,SIGNAL(updatedCurrentFolder()), this, SLOT(showRootWidget())); @@ -1089,7 +1089,7 @@ void LibraryWindow::createConnections() //packageManager connections connect(exportLibraryDialog, &ExportLibraryDialog::exportPath, this, &LibraryWindow::exportLibrary); connect(exportLibraryDialog, &QDialog::rejected, packageManager, &PackageManager::cancel); - connect(packageManager, SIGNAL(exported()), exportLibraryDialog, SLOT(close())); + connect(packageManager, &PackageManager::exported, exportLibraryDialog, &ExportLibraryDialog::close); connect(importLibraryDialog, &ImportLibraryDialog::unpackCLC, this, &LibraryWindow::importLibrary); connect(importLibraryDialog, &QDialog::rejected, packageManager, &PackageManager::cancel); connect(importLibraryDialog, &QDialog::rejected, this, &LibraryWindow::deleteCurrentLibrary); @@ -1114,13 +1114,15 @@ void LibraryWindow::createConnections() //connect(foldersView, SIGNAL(clicked(QModelIndex)), this, SLOT(loadCovers(QModelIndex))); //drops in folders view - connect(foldersView, SIGNAL(copyComicsToFolder(QList>, QModelIndex)), this, SLOT(copyAndImportComicsToFolder(QList>, QModelIndex))); - connect(foldersView, SIGNAL(moveComicsToFolder(QList>, QModelIndex)), this, SLOT(moveAndImportComicsToFolder(QList>, QModelIndex))); + connect(foldersView, QOverload>, QModelIndex>::of(&YACReaderFoldersView::copyComicsToFolder), + this, &LibraryWindow::copyAndImportComicsToFolder); + connect(foldersView, QOverload>, QModelIndex>::of(&YACReaderFoldersView::moveComicsToFolder), + this, &LibraryWindow::moveAndImportComicsToFolder); connect(foldersView, &QWidget::customContextMenuRequested, this, &LibraryWindow::showFoldersContextMenu); //actions connect(createLibraryAction, &QAction::triggered, this, &LibraryWindow::createLibrary); - connect(exportLibraryAction, &QAction::triggered, exportLibraryDialog, &QDialog::open); + connect(exportLibraryAction, &QAction::triggered, exportLibraryDialog, &ExportLibraryDialog::open); connect(importLibraryAction, &QAction::triggered, this, &LibraryWindow::importLibraryPackage); connect(openLibraryAction, &QAction::triggered, this, &LibraryWindow::showAddLibrary); @@ -1217,9 +1219,9 @@ void LibraryWindow::createConnections() connect(addLabelAction, &QAction::triggered, this, &LibraryWindow::showAddNewLabelDialog); connect(renameListAction, &QAction::triggered, this, &LibraryWindow::showRenameCurrentList); - connect(listsModel, SIGNAL(addComicsToFavorites(QList)), comicsModel, SLOT(addComicsToFavorites(QList))); - connect(listsModel, SIGNAL(addComicsToLabel(QList, qulonglong)), comicsModel, SLOT(addComicsToLabel(QList, qulonglong))); - connect(listsModel, SIGNAL(addComicsToReadingList(QList, qulonglong)), comicsModel, SLOT(addComicsToReadingList(QList, qulonglong))); + connect(listsModel, &ReadingListModel::addComicsToFavorites, comicsModel, QOverload &>::of(&ComicModel::addComicsToFavorites)); + connect(listsModel, &ReadingListModel::addComicsToLabel, comicsModel, QOverload &, qulonglong>::of(&ComicModel::addComicsToLabel)); + connect(listsModel, &ReadingListModel::addComicsToReadingList, comicsModel, QOverload &, qulonglong>::of(&ComicModel::addComicsToReadingList)); //-- connect(addToFavoritesAction, &QAction::triggered, this, &LibraryWindow::addSelectedComicsToFavorites); diff --git a/YACReaderLibrary/package_manager.cpp b/YACReaderLibrary/package_manager.cpp index dc22107d..a1acb225 100644 --- a/YACReaderLibrary/package_manager.cpp +++ b/YACReaderLibrary/package_manager.cpp @@ -13,8 +13,9 @@ void PackageManager::createPackage(const QString &libraryPath, const QString &de << "-y" << "-ttar" << dest + ".clc" << libraryPath; _7z = new QProcess(); + //TODO: Missing slot for openingError!!! connect(_7z, SIGNAL(error(QProcess::ProcessError)), this, SLOT(openingError(QProcess::ProcessError))); - connect(_7z, SIGNAL(finished(int, QProcess::ExitStatus)), this, SIGNAL(exported())); + connect(_7z, QOverload::of(&QProcess::finished), this, &PackageManager::exported); #if defined Q_OS_UNIX && !defined Q_OS_MAC _7z->start("7z", attributes); //TODO: use 7z.so #else diff --git a/YACReaderLibrary/server_config_dialog.cpp b/YACReaderLibrary/server_config_dialog.cpp index fd30d2b0..6238aed5 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, SIGNAL(activated(const QString &)), this, SLOT(regenerateQR(const QString &))); + connect(ip, QOverload::of(&QComboBox::activated), this, &ServerConfigDialog::regenerateQR); ip->setFixedWidth(200); ip->move(332, 153);