diff --git a/src/app/application.cpp b/src/app/application.cpp index c92146c7d..0a421670a 100644 --- a/src/app/application.cpp +++ b/src/app/application.cpp @@ -151,11 +151,11 @@ Application::Application(const QString &id, int &argc, char **argv) #endif #if defined(Q_OS_WIN) && !defined(DISABLE_GUI) - connect(this, SIGNAL(commitDataRequest(QSessionManager &)), this, SLOT(shutdownCleanup(QSessionManager &)), Qt::DirectConnection); + connect(this, &QGuiApplication::commitDataRequest, this, &Application::shutdownCleanup, Qt::DirectConnection); #endif - connect(this, SIGNAL(messageReceived(const QString &)), SLOT(processMessage(const QString &))); - connect(this, SIGNAL(aboutToQuit()), SLOT(cleanup())); + connect(this, &Application::messageReceived, this, &Application::processMessage); + connect(this, &QCoreApplication::aboutToQuit, this, &Application::cleanup); if (isFileLoggerEnabled()) m_fileLogger = new FileLogger(fileLoggerPath(), isFileLoggerBackup(), fileLoggerMaxSize(), isFileLoggerDeleteOld(), fileLoggerAge(), static_cast(fileLoggerAgeType())); @@ -489,8 +489,8 @@ int Application::exec(const QStringList ¶ms) #endif BitTorrent::Session::initInstance(); - connect(BitTorrent::Session::instance(), SIGNAL(torrentFinished(BitTorrent::TorrentHandle *const)), SLOT(torrentFinished(BitTorrent::TorrentHandle *const))); - connect(BitTorrent::Session::instance(), SIGNAL(allTorrentsFinished()), SLOT(allTorrentsFinished()), Qt::QueuedConnection); + connect(BitTorrent::Session::instance(), &BitTorrent::Session::torrentFinished, this, &Application::torrentFinished); + connect(BitTorrent::Session::instance(), &BitTorrent::Session::allTorrentsFinished, this, &Application::allTorrentsFinished, Qt::QueuedConnection); #ifndef DISABLE_COUNTRIES_RESOLUTION Net::GeoIPManager::initInstance(); diff --git a/src/app/filelogger.cpp b/src/app/filelogger.cpp index b22cde309..9504c6297 100644 --- a/src/app/filelogger.cpp +++ b/src/app/filelogger.cpp @@ -41,7 +41,7 @@ FileLogger::FileLogger(const QString &path, const bool backup, const int maxSize { m_flusher.setInterval(0); m_flusher.setSingleShot(true); - connect(&m_flusher, SIGNAL(timeout()), SLOT(flushLog())); + connect(&m_flusher, &QTimer::timeout, this, &FileLogger::flushLog); changePath(path); if (deleteOld) @@ -51,7 +51,7 @@ FileLogger::FileLogger(const QString &path, const bool backup, const int maxSize foreach (const Log::Msg& msg, logger->getMessages()) addLogMessage(msg); - connect(logger, SIGNAL(newLogMessage(const Log::Msg &)), SLOT(addLogMessage(const Log::Msg &))); + connect(logger, &Logger::newLogMessage, this, &FileLogger::addLogMessage); } FileLogger::~FileLogger() diff --git a/src/base/bittorrent/private/statistics.cpp b/src/base/bittorrent/private/statistics.cpp index eda236606..23abc8351 100644 --- a/src/base/bittorrent/private/statistics.cpp +++ b/src/base/bittorrent/private/statistics.cpp @@ -22,7 +22,7 @@ Statistics::Statistics(Session *session) , m_dirty(false) { load(); - connect(&m_timer, SIGNAL(timeout()), this, SLOT(gather())); + connect(&m_timer, &QTimer::timeout, this, &Statistics::gather); m_timer.start(60 * 1000); } diff --git a/src/base/bittorrent/private/statistics.h b/src/base/bittorrent/private/statistics.h index e99eb2fe8..b88a8dabb 100644 --- a/src/base/bittorrent/private/statistics.h +++ b/src/base/bittorrent/private/statistics.h @@ -9,7 +9,7 @@ namespace BitTorrent class Session; } -class Statistics : QObject +class Statistics : public QObject { Q_OBJECT Q_DISABLE_COPY(Statistics) diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index 30348fb3e..dd70aab54 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -517,13 +517,14 @@ Session::Session(QObject *parent) enableTracker(isTrackerEnabled()); - connect(Net::ProxyConfigurationManager::instance(), SIGNAL(proxyConfigurationChanged()), SLOT(configureDeferred())); + connect(Net::ProxyConfigurationManager::instance(), &Net::ProxyConfigurationManager::proxyConfigurationChanged + , this, &Session::configureDeferred); // Network configuration monitor - connect(&m_networkManager, SIGNAL(onlineStateChanged(bool)), SLOT(networkOnlineStateChanged(bool))); - connect(&m_networkManager, SIGNAL(configurationAdded(const QNetworkConfiguration&)), SLOT(networkConfigurationChange(const QNetworkConfiguration&))); - connect(&m_networkManager, SIGNAL(configurationRemoved(const QNetworkConfiguration&)), SLOT(networkConfigurationChange(const QNetworkConfiguration&))); - connect(&m_networkManager, SIGNAL(configurationChanged(const QNetworkConfiguration&)), SLOT(networkConfigurationChange(const QNetworkConfiguration&))); + connect(&m_networkManager, &QNetworkConfigurationManager::onlineStateChanged, this, &Session::networkOnlineStateChanged); + connect(&m_networkManager, &QNetworkConfigurationManager::configurationAdded, this, &Session::networkConfigurationChange); + connect(&m_networkManager, &QNetworkConfigurationManager::configurationRemoved, this, &Session::networkConfigurationChange); + connect(&m_networkManager, &QNetworkConfigurationManager::configurationChanged, this, &Session::networkConfigurationChange); m_ioThread = new QThread(this); m_resumeDataSavingManager = new ResumeDataSavingManager(m_resumeFolderPath); @@ -2073,9 +2074,10 @@ bool Session::addTorrent(QString source, const AddTorrentParams ¶ms) Logger::instance()->addMessage(tr("Downloading '%1', please wait...", "e.g: Downloading 'xxx.torrent', please wait...").arg(source)); // Launch downloader Net::DownloadHandler *handler = Net::DownloadManager::instance()->downloadUrl(source, true, 10485760 /* 10MB */, true); - connect(handler, SIGNAL(downloadFinished(QString, QString)), this, SLOT(handleDownloadFinished(QString, QString))); - connect(handler, SIGNAL(downloadFailed(QString, QString)), this, SLOT(handleDownloadFailed(QString, QString))); - connect(handler, SIGNAL(redirectedToMagnet(QString, QString)), this, SLOT(handleRedirectedToMagnet(QString, QString))); + connect(handler, static_cast(&Net::DownloadHandler::downloadFinished) + , this, &Session::handleDownloadFinished); + connect(handler, &Net::DownloadHandler::downloadFailed, this, &Session::handleDownloadFailed); + connect(handler, &Net::DownloadHandler::redirectedToMagnet, this, &Session::handleRedirectedToMagnet); m_downloadedTorrents[handler->url()] = params; } else { @@ -3712,8 +3714,8 @@ void Session::enableIPFilter() // set between clearing the old one and setting the new one. if (!m_filterParser) { m_filterParser = new FilterParserThread(this); - connect(m_filterParser.data(), SIGNAL(IPFilterParsed(int)), SLOT(handleIPFilterParsed(int))); - connect(m_filterParser.data(), SIGNAL(IPFilterError()), SLOT(handleIPFilterError())); + connect(m_filterParser.data(), &FilterParserThread::IPFilterParsed, this, &Session::handleIPFilterParsed); + connect(m_filterParser.data(), &FilterParserThread::IPFilterError, this, &Session::handleIPFilterError); } m_filterParser->processFilterFile(IPFilterFile()); } diff --git a/src/base/net/dnsupdater.cpp b/src/base/net/dnsupdater.cpp index 621980b65..7710befa9 100644 --- a/src/base/net/dnsupdater.cpp +++ b/src/base/net/dnsupdater.cpp @@ -52,7 +52,7 @@ DNSUpdater::DNSUpdater(QObject *parent) // Start IP checking timer m_ipCheckTimer.setInterval(IP_CHECK_INTERVAL_MS); - connect(&m_ipCheckTimer, SIGNAL(timeout()), SLOT(checkPublicIP())); + connect(&m_ipCheckTimer, &QTimer::timeout, this, &DNSUpdater::checkPublicIP); m_ipCheckTimer.start(); // Check lastUpdate to avoid flooding @@ -77,8 +77,9 @@ void DNSUpdater::checkPublicIP() DownloadHandler *handler = DownloadManager::instance()->downloadUrl( "http://checkip.dyndns.org", false, 0, false, "qBittorrent/" QBT_VERSION_2); - connect(handler, SIGNAL(downloadFinished(QString, QByteArray)), SLOT(ipRequestFinished(QString, QByteArray))); - connect(handler, SIGNAL(downloadFailed(QString, QString)), SLOT(ipRequestFailed(QString, QString))); + connect(handler, static_cast(&Net::DownloadHandler::downloadFinished) + , this, &DNSUpdater::ipRequestFinished); + connect(handler, &Net::DownloadHandler::downloadFailed, this, &DNSUpdater::ipRequestFailed); m_lastIPCheckTime = QDateTime::currentDateTime(); } @@ -124,8 +125,9 @@ void DNSUpdater::updateDNSService() DownloadHandler *handler = DownloadManager::instance()->downloadUrl( getUpdateUrl(), false, 0, false, "qBittorrent/" QBT_VERSION_2); - connect(handler, SIGNAL(downloadFinished(QString, QByteArray)), SLOT(ipUpdateFinished(QString, QByteArray))); - connect(handler, SIGNAL(downloadFailed(QString, QString)), SLOT(ipUpdateFailed(QString, QString))); + connect(handler, static_cast(&Net::DownloadHandler::downloadFinished) + , this, &DNSUpdater::ipUpdateFinished); + connect(handler, &Net::DownloadHandler::downloadFailed, this, &DNSUpdater::ipUpdateFailed); } QString DNSUpdater::getUpdateUrl() const diff --git a/src/base/net/downloadhandler.cpp b/src/base/net/downloadhandler.cpp index e6c25b370..d03e1b696 100644 --- a/src/base/net/downloadhandler.cpp +++ b/src/base/net/downloadhandler.cpp @@ -124,7 +124,7 @@ void DownloadHandler::checkDownloadSize(qint64 bytesReceived, qint64 bytesTotal) emit downloadFailed(m_url, msg.arg(Utils::Misc::friendlyUnit(bytesTotal), Utils::Misc::friendlyUnit(m_sizeLimit))); } else { - disconnect(m_reply, SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(checkDownloadSize(qint64, qint64))); + disconnect(m_reply, &QNetworkReply::downloadProgress, this, &Net::DownloadHandler::checkDownloadSize); } } else if (bytesReceived > m_sizeLimit) { @@ -137,8 +137,8 @@ void DownloadHandler::init() { m_reply->setParent(this); if (m_sizeLimit > 0) - connect(m_reply, SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(checkDownloadSize(qint64, qint64))); - connect(m_reply, SIGNAL(finished()), this, SLOT(processFinishedDownload())); + connect(m_reply, &QNetworkReply::downloadProgress, this, &Net::DownloadHandler::checkDownloadSize); + connect(m_reply, &QNetworkReply::finished, this, &Net::DownloadHandler::processFinishedDownload); } bool DownloadHandler::saveToFile(const QByteArray &replyData, QString &filePath) diff --git a/src/base/net/downloadmanager.cpp b/src/base/net/downloadmanager.cpp index 50c31639e..c2b37b39f 100644 --- a/src/base/net/downloadmanager.cpp +++ b/src/base/net/downloadmanager.cpp @@ -113,7 +113,7 @@ DownloadManager::DownloadManager(QObject *parent) : QObject(parent) { #ifndef QT_NO_OPENSSL - connect(&m_networkManager, SIGNAL(sslErrors(QNetworkReply *, QList)), this, SLOT(ignoreSslErrors(QNetworkReply *, QList))); + connect(&m_networkManager, &QNetworkAccessManager::sslErrors, this, &Net::DownloadManager::ignoreSslErrors); #endif m_networkManager.setCookieJar(new NetworkCookieJar(this)); } diff --git a/src/base/net/geoipmanager.cpp b/src/base/net/geoipmanager.cpp index a379ab74f..20db4eea7 100644 --- a/src/base/net/geoipmanager.cpp +++ b/src/base/net/geoipmanager.cpp @@ -60,7 +60,7 @@ GeoIPManager::GeoIPManager() , m_geoIPDatabase(nullptr) { configure(); - connect(Preferences::instance(), SIGNAL(changed()), SLOT(configure())); + connect(Preferences::instance(), &Preferences::changed, this, &GeoIPManager::configure); } GeoIPManager::~GeoIPManager() @@ -119,8 +119,9 @@ void GeoIPManager::manageDatabaseUpdate() void GeoIPManager::downloadDatabaseFile() { DownloadHandler *handler = DownloadManager::instance()->downloadUrl(DATABASE_URL); - connect(handler, SIGNAL(downloadFinished(QString, QByteArray)), SLOT(downloadFinished(QString, QByteArray))); - connect(handler, SIGNAL(downloadFailed(QString, QString)), SLOT(downloadFailed(QString, QString))); + connect(handler, static_cast(&Net::DownloadHandler::downloadFinished) + , this, &GeoIPManager::downloadFinished); + connect(handler, &Net::DownloadHandler::downloadFailed, this, &GeoIPManager::downloadFailed); } QString GeoIPManager::lookup(const QHostAddress &hostAddr) const diff --git a/src/base/net/smtp.cpp b/src/base/net/smtp.cpp index 8e2831e8f..605b631dc 100644 --- a/src/base/net/smtp.cpp +++ b/src/base/net/smtp.cpp @@ -111,9 +111,10 @@ Smtp::Smtp(QObject *parent) m_socket = new QTcpSocket(this); #endif - connect(m_socket, SIGNAL(readyRead()), SLOT(readyRead())); - connect(m_socket, SIGNAL(disconnected()), SLOT(deleteLater())); - connect(m_socket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(error(QAbstractSocket::SocketError))); + connect(m_socket, &QIODevice::readyRead, this, &Smtp::readyRead); + connect(m_socket, &QAbstractSocket::disconnected, this, &QObject::deleteLater); + connect(m_socket, static_cast(&QAbstractSocket::error) + , this, &Smtp::error); // Test hmacMD5 function (http://www.faqs.org/rfcs/rfc2202.html) Q_ASSERT(hmacMD5("Jefe", "what do ya want for nothing?").toHex() diff --git a/src/base/scanfoldersmodel.cpp b/src/base/scanfoldersmodel.cpp index 2d327f8bb..429d02de4 100644 --- a/src/base/scanfoldersmodel.cpp +++ b/src/base/scanfoldersmodel.cpp @@ -86,7 +86,7 @@ ScanFoldersModel::ScanFoldersModel(QObject *parent) , m_fsWatcher(nullptr) { configure(); - connect(Preferences::instance(), SIGNAL(changed()), SLOT(configure())); + connect(Preferences::instance(), &Preferences::changed, this, &ScanFoldersModel::configure); } ScanFoldersModel::~ScanFoldersModel() @@ -222,7 +222,7 @@ ScanFoldersModel::PathStatus ScanFoldersModel::addPath(const QString &watchPath, if (!m_fsWatcher) { m_fsWatcher = new FileSystemWatcher(this); - connect(m_fsWatcher, SIGNAL(torrentsAdded(const QStringList &)), this, SLOT(addTorrentsToSession(const QStringList &))); + connect(m_fsWatcher, &FileSystemWatcher::torrentsAdded, this, &ScanFoldersModel::addTorrentsToSession); } beginInsertRows(QModelIndex(), rowCount(), rowCount()); diff --git a/src/base/search/searchhandler.cpp b/src/base/search/searchhandler.cpp index 0cff6df6b..efb14a29e 100644 --- a/src/base/search/searchhandler.cpp +++ b/src/base/search/searchhandler.cpp @@ -76,7 +76,7 @@ SearchHandler::SearchHandler(const QString &pattern, const QString &category, co #if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) connect(m_searchProcess, &QProcess::errorOccurred, this, &SearchHandler::processFailed); #else - connect(m_searchProcess, static_cast(&QProcess::error) + connect(m_searchProcess, static_cast(&QProcess::error) , this, &SearchHandler::processFailed); #endif connect(m_searchProcess, &QProcess::readyReadStandardOutput, this, &SearchHandler::readSearchOutput); diff --git a/src/base/settingsstorage.cpp b/src/base/settingsstorage.cpp index a4c6aa8fb..a184c29db 100644 --- a/src/base/settingsstorage.cpp +++ b/src/base/settingsstorage.cpp @@ -163,7 +163,7 @@ SettingsStorage::SettingsStorage() { m_timer.setSingleShot(true); m_timer.setInterval(5 * 1000); - connect(&m_timer, SIGNAL(timeout()), SLOT(save())); + connect(&m_timer, &QTimer::timeout, this, &SettingsStorage::save); } SettingsStorage::~SettingsStorage() diff --git a/src/gui/addnewtorrentdialog.cpp b/src/gui/addnewtorrentdialog.cpp index b51d7f31b..59190a5e9 100644 --- a/src/gui/addnewtorrentdialog.cpp +++ b/src/gui/addnewtorrentdialog.cpp @@ -146,11 +146,11 @@ AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::AddTorrentParams &inP ui->contentTreeView->header()->setSortIndicator(0, Qt::AscendingOrder); loadState(); // Signal / slots - connect(ui->adv_button, SIGNAL(clicked(bool)), SLOT(showAdvancedSettings(bool))); - connect(ui->doNotDeleteTorrentCheckBox, SIGNAL(clicked(bool)), SLOT(doNotDeleteTorrentClicked(bool))); + connect(ui->adv_button, &QToolButton::clicked, this, &AddNewTorrentDialog::showAdvancedSettings); + connect(ui->doNotDeleteTorrentCheckBox, &QCheckBox::clicked, this, &AddNewTorrentDialog::doNotDeleteTorrentClicked); QShortcut *editHotkey = new QShortcut(Qt::Key_F2, ui->contentTreeView, nullptr, nullptr, Qt::WidgetShortcut); - connect(editHotkey, SIGNAL(activated()), SLOT(renameSelectedFile())); - connect(ui->contentTreeView, SIGNAL(doubleClicked(QModelIndex)), SLOT(renameSelectedFile())); + connect(editHotkey, &QShortcut::activated, this, &AddNewTorrentDialog::renameSelectedFile); + connect(ui->contentTreeView, &QAbstractItemView::doubleClicked, this, &AddNewTorrentDialog::renameSelectedFile); ui->buttonBox->button(QDialogButtonBox::Ok)->setFocus(); } @@ -238,9 +238,10 @@ void AddNewTorrentDialog::show(QString source, const BitTorrent::AddTorrentParam if (Utils::Misc::isUrl(source)) { // Launch downloader Net::DownloadHandler *handler = Net::DownloadManager::instance()->downloadUrl(source, true, 10485760 /* 10MB */, true); - connect(handler, SIGNAL(downloadFinished(QString,QString)), dlg, SLOT(handleDownloadFinished(QString,QString))); - connect(handler, SIGNAL(downloadFailed(QString,QString)), dlg, SLOT(handleDownloadFailed(QString,QString))); - connect(handler, SIGNAL(redirectedToMagnet(QString,QString)), dlg, SLOT(handleRedirectedToMagnet(QString,QString))); + connect(handler, static_cast(&Net::DownloadHandler::downloadFinished) + , dlg, &AddNewTorrentDialog::handleDownloadFinished); + connect(handler, &Net::DownloadHandler::downloadFailed, dlg, &AddNewTorrentDialog::handleDownloadFailed); + connect(handler, &Net::DownloadHandler::redirectedToMagnet, dlg, &AddNewTorrentDialog::handleRedirectedToMagnet); } else { bool ok = false; @@ -349,7 +350,7 @@ bool AddNewTorrentDialog::loadMagnet(const BitTorrent::MagnetUri &magnetUri) return false; } - connect(BitTorrent::Session::instance(), SIGNAL(metadataLoaded(BitTorrent::TorrentInfo)), SLOT(updateMetadata(BitTorrent::TorrentInfo))); + connect(BitTorrent::Session::instance(), &BitTorrent::Session::metadataLoaded, this, &AddNewTorrentDialog::updateMetadata); // Set dialog title QString torrent_name = magnetUri.name(); @@ -742,12 +743,13 @@ void AddNewTorrentDialog::setupTreeview() // Prepare content tree m_contentModel = new TorrentContentFilterModel(this); - connect(m_contentModel->model(), SIGNAL(filteredFilesChanged()), SLOT(updateDiskSpaceLabel())); + connect(m_contentModel->model(), &TorrentContentModel::filteredFilesChanged, this, &AddNewTorrentDialog::updateDiskSpaceLabel); ui->contentTreeView->setModel(m_contentModel); m_contentDelegate = new PropListDelegate(nullptr); ui->contentTreeView->setItemDelegate(m_contentDelegate); - connect(ui->contentTreeView, SIGNAL(clicked(const QModelIndex&)), ui->contentTreeView, SLOT(edit(const QModelIndex&))); - connect(ui->contentTreeView, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayContentTreeMenu(const QPoint&))); + connect(ui->contentTreeView, &QAbstractItemView::clicked, ui->contentTreeView + , static_cast(&QAbstractItemView::edit)); + connect(ui->contentTreeView, &QWidget::customContextMenuRequested, this, &AddNewTorrentDialog::displayContentTreeMenu); // List files in torrent m_contentModel->model()->setupModelData(m_torrentInfo); diff --git a/src/gui/advancedsettings.cpp b/src/gui/advancedsettings.cpp index ff6f15189..192958089 100644 --- a/src/gui/advancedsettings.cpp +++ b/src/gui/advancedsettings.cpp @@ -125,8 +125,10 @@ AdvancedSettings::AdvancedSettings(QWidget *parent) setSelectionMode(QAbstractItemView::NoSelection); setEditTriggers(QAbstractItemView::NoEditTriggers); // Signals - connect(&spin_cache, SIGNAL(valueChanged(int)), SLOT(updateCacheSpinSuffix(int))); - connect(&combo_iface, SIGNAL(currentIndexChanged(int)), SLOT(updateInterfaceAddressCombo())); + connect(&spin_cache, static_cast(&QSpinBox::valueChanged) + , this, &AdvancedSettings::updateCacheSpinSuffix); + connect(&combo_iface, static_cast(&QComboBox::currentIndexChanged) + , this, &AdvancedSettings::updateInterfaceAddressCombo); // Load settings loadAdvancedSettings(); resizeColumnToContents(0); diff --git a/src/gui/categoryfiltermodel.cpp b/src/gui/categoryfiltermodel.cpp index 0da7b059f..85b4bf30f 100644 --- a/src/gui/categoryfiltermodel.cpp +++ b/src/gui/categoryfiltermodel.cpp @@ -174,17 +174,15 @@ CategoryFilterModel::CategoryFilterModel(QObject *parent) : QAbstractItemModel(parent) , m_rootItem(new CategoryModelItem) { - auto session = BitTorrent::Session::instance(); - - connect(session, SIGNAL(categoryAdded(QString)), SLOT(categoryAdded(QString))); - connect(session, SIGNAL(categoryRemoved(QString)), SLOT(categoryRemoved(QString))); - connect(session, SIGNAL(torrentCategoryChanged(BitTorrent::TorrentHandle *const, QString)) - , SLOT(torrentCategoryChanged(BitTorrent::TorrentHandle *const, QString))); - connect(session, SIGNAL(subcategoriesSupportChanged()), SLOT(subcategoriesSupportChanged())); - connect(session, SIGNAL(torrentAdded(BitTorrent::TorrentHandle *const)) - , SLOT(torrentAdded(BitTorrent::TorrentHandle *const))); - connect(session, SIGNAL(torrentAboutToBeRemoved(BitTorrent::TorrentHandle *const)) - , SLOT(torrentAboutToBeRemoved(BitTorrent::TorrentHandle *const))); + using namespace BitTorrent; + auto session = Session::instance(); + + connect(session, &Session::categoryAdded, this, &CategoryFilterModel::categoryAdded); + connect(session, &Session::categoryRemoved, this, &CategoryFilterModel::categoryRemoved); + connect(session, &Session::torrentCategoryChanged, this, &CategoryFilterModel::torrentCategoryChanged); + connect(session, &Session::subcategoriesSupportChanged, this, &CategoryFilterModel::subcategoriesSupportChanged); + connect(session, &Session::torrentAdded, this, &CategoryFilterModel::torrentAdded); + connect(session, &Session::torrentAboutToBeRemoved, this, &CategoryFilterModel::torrentAboutToBeRemoved); populate(); } diff --git a/src/gui/deletionconfirmationdlg.h b/src/gui/deletionconfirmationdlg.h index b369891e0..dfb958234 100644 --- a/src/gui/deletionconfirmationdlg.h +++ b/src/gui/deletionconfirmationdlg.h @@ -59,7 +59,7 @@ class DeletionConfirmationDlg : public QDialog, private Ui::confirmDeletionDlg { rememberBtn->setIconSize(Utils::Gui::mediumIconSize()); checkPermDelete->setChecked(defaultDeleteFiles || Preferences::instance()->deleteTorrentFilesAsDefault()); - connect(checkPermDelete, SIGNAL(clicked()), this, SLOT(updateRememberButtonState())); + connect(checkPermDelete, &QCheckBox::clicked, this, &DeletionConfirmationDlg::updateRememberButtonState); buttonBox->button(QDialogButtonBox::Cancel)->setFocus(); Utils::Gui::resize(this); diff --git a/src/gui/executionlog.cpp b/src/gui/executionlog.cpp index f43634c03..af5ee7773 100644 --- a/src/gui/executionlog.cpp +++ b/src/gui/executionlog.cpp @@ -59,8 +59,8 @@ ExecutionLog::ExecutionLog(QWidget *parent, const Log::MsgTypes &types) addLogMessage(msg); foreach (const Log::Peer& peer, logger->getPeers()) addPeerMessage(peer); - connect(logger, SIGNAL(newLogMessage(const Log::Msg &)), SLOT(addLogMessage(const Log::Msg &))); - connect(logger, SIGNAL(newLogPeer(const Log::Peer &)), SLOT(addPeerMessage(const Log::Peer &))); + connect(logger, &Logger::newLogMessage, this, &ExecutionLog::addLogMessage); + connect(logger, &Logger::newLogPeer, this, &ExecutionLog::addPeerMessage); } ExecutionLog::~ExecutionLog() diff --git a/src/gui/guiiconprovider.cpp b/src/gui/guiiconprovider.cpp index 15d86563e..82c92bc60 100644 --- a/src/gui/guiiconprovider.cpp +++ b/src/gui/guiiconprovider.cpp @@ -40,7 +40,7 @@ GuiIconProvider::GuiIconProvider(QObject *parent) : IconProvider(parent) { configure(); - connect(Preferences::instance(), SIGNAL(changed()), SLOT(configure())); + connect(Preferences::instance(), &Preferences::changed, this, &GuiIconProvider::configure); } GuiIconProvider::~GuiIconProvider() = default; diff --git a/src/gui/loglistwidget.cpp b/src/gui/loglistwidget.cpp index c6a71f65c..59b3d906d 100644 --- a/src/gui/loglistwidget.cpp +++ b/src/gui/loglistwidget.cpp @@ -47,8 +47,8 @@ LogListWidget::LogListWidget(int maxLines, const Log::MsgTypes &types, QWidget * // Context menu QAction *copyAct = new QAction(GuiIconProvider::instance()->getIcon("edit-copy"), tr("Copy"), this); QAction *clearAct = new QAction(GuiIconProvider::instance()->getIcon("edit-clear"), tr("Clear"), this); - connect(copyAct, SIGNAL(triggered()), SLOT(copySelection())); - connect(clearAct, SIGNAL(triggered()), SLOT(clear())); + connect(copyAct, &QAction::triggered, this, &LogListWidget::copySelection); + connect(clearAct, &QAction::triggered, this, &LogListWidget::clear); addAction(copyAct); addAction(clearAct); setContextMenuPolicy(Qt::ActionsContextMenu); diff --git a/src/gui/powermanagement/powermanagement_x11.cpp b/src/gui/powermanagement/powermanagement_x11.cpp index e70889bcf..3e5f4e407 100644 --- a/src/gui/powermanagement/powermanagement_x11.cpp +++ b/src/gui/powermanagement/powermanagement_x11.cpp @@ -86,8 +86,7 @@ void PowerManagementInhibitor::RequestIdle() QDBusPendingCall pcall = QDBusConnection::sessionBus().asyncCall(call, 1000); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pcall, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - this, SLOT(OnAsyncReply(QDBusPendingCallWatcher*))); + connect(watcher, &QDBusPendingCallWatcher::finished, this, &PowerManagementInhibitor::OnAsyncReply); } @@ -124,8 +123,7 @@ void PowerManagementInhibitor::RequestBusy() QDBusPendingCall pcall = QDBusConnection::sessionBus().asyncCall(call, 1000); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pcall, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - this, SLOT(OnAsyncReply(QDBusPendingCallWatcher*))); + connect(watcher, &QDBusPendingCallWatcher::finished, this, &PowerManagementInhibitor::OnAsyncReply); } void PowerManagementInhibitor::OnAsyncReply(QDBusPendingCallWatcher *call) diff --git a/src/gui/programupdater.cpp b/src/gui/programupdater.cpp index e889bcf1a..933a500d9 100644 --- a/src/gui/programupdater.cpp +++ b/src/gui/programupdater.cpp @@ -67,8 +67,9 @@ void ProgramUpdater::checkForUpdates() // Don't change this User-Agent. In case our updater goes haywire, // the filehost can identify it and contact us. "qBittorrent/" QBT_VERSION_2 " ProgramUpdater (www.qbittorrent.org)"); - connect(handler, SIGNAL(downloadFinished(QString,QByteArray)), SLOT(rssDownloadFinished(QString,QByteArray))); - connect(handler, SIGNAL(downloadFailed(QString,QString)), SLOT(rssDownloadFailed(QString,QString))); + connect(handler, static_cast(&Net::DownloadHandler::downloadFinished) + , this, &ProgramUpdater::rssDownloadFinished); + connect(handler, &Net::DownloadHandler::downloadFailed, this, &ProgramUpdater::rssDownloadFailed); } void ProgramUpdater::rssDownloadFinished(const QString &url, const QByteArray &data) diff --git a/src/gui/properties/peerlistwidget.cpp b/src/gui/properties/peerlistwidget.cpp index 61ff67ee1..916ede450 100644 --- a/src/gui/properties/peerlistwidget.cpp +++ b/src/gui/properties/peerlistwidget.cpp @@ -118,7 +118,7 @@ PeerListWidget::PeerListWidget(PropertiesWidget *parent) resizeColumnToContents(i); // Context menu setContextMenuPolicy(Qt::CustomContextMenu); - connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showPeerListMenu(QPoint))); + connect(this, &QWidget::customContextMenuRequested, this, &PeerListWidget::showPeerListMenu); // List delegate m_listDelegate = new PeerListDelegate(this); setItemDelegate(m_listDelegate); @@ -128,10 +128,11 @@ PeerListWidget::PeerListWidget(PropertiesWidget *parent) updatePeerHostNameResolutionState(); // SIGNAL/SLOT header()->setContextMenuPolicy(Qt::CustomContextMenu); - connect(header(), SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayToggleColumnsMenu(const QPoint&))); - connect(header(), SIGNAL(sectionClicked(int)), SLOT(handleSortColumnChanged(int))); + connect(header(), &QWidget::customContextMenuRequested, this, &PeerListWidget::displayToggleColumnsMenu); + connect(header(), &QHeaderView::sectionClicked, this, &PeerListWidget::handleSortColumnChanged); handleSortColumnChanged(header()->sortIndicatorSection()); - m_copyHotkey = new QShortcut(QKeySequence::Copy, this, SLOT(copySelectedPeers()), nullptr, Qt::WidgetShortcut); + m_copyHotkey = new QShortcut(QKeySequence::Copy, this, nullptr, nullptr, Qt::WidgetShortcut); + connect(m_copyHotkey, &QShortcut::activated, this, &PeerListWidget::copySelectedPeers); // This hack fixes reordering of first column with Qt5. // https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777 @@ -192,7 +193,7 @@ void PeerListWidget::updatePeerHostNameResolutionState() if (Preferences::instance()->resolvePeerHostNames()) { if (!m_resolver) { m_resolver = new Net::ReverseResolution(this); - connect(m_resolver, SIGNAL(ipResolved(QString,QString)), SLOT(handleResolved(QString,QString))); + connect(m_resolver.data(), &Net::ReverseResolution::ipResolved, this, &PeerListWidget::handleResolved); loadPeers(m_properties->getCurrentTorrent(), true); } } diff --git a/src/gui/properties/peersadditiondlg.cpp b/src/gui/properties/peersadditiondlg.cpp index 3161d58fc..e1a0609ed 100644 --- a/src/gui/properties/peersadditiondlg.cpp +++ b/src/gui/properties/peersadditiondlg.cpp @@ -38,7 +38,7 @@ PeersAdditionDlg::PeersAdditionDlg(QWidget *parent) , m_ui(new Ui::addPeersDialog()) { m_ui->setupUi(this); - connect(m_ui->buttonBox, SIGNAL(accepted()), this, SLOT(validateInput())); + connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &PeersAdditionDlg::validateInput); } PeersAdditionDlg::~PeersAdditionDlg() diff --git a/src/gui/properties/propertieswidget.cpp b/src/gui/properties/propertieswidget.cpp index 64e79fe96..74c5f4665 100644 --- a/src/gui/properties/propertieswidget.cpp +++ b/src/gui/properties/propertieswidget.cpp @@ -93,25 +93,26 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow *mainWindow, Tran m_contentFilterLine = new LineEdit(this); m_contentFilterLine->setPlaceholderText(tr("Filter files...")); m_contentFilterLine->setFixedWidth(Utils::Gui::scaledSize(this, 300)); - connect(m_contentFilterLine, SIGNAL(textChanged(QString)), this, SLOT(filterText(QString))); + connect(m_contentFilterLine, &LineEdit::textChanged, this, &PropertiesWidget::filterText); m_ui->contentFilterLayout->insertWidget(3, m_contentFilterLine); // SIGNAL/SLOTS - connect(m_ui->filesList, SIGNAL(clicked(const QModelIndex&)), m_ui->filesList, SLOT(edit(const QModelIndex&))); - connect(m_ui->selectAllButton, SIGNAL(clicked()), m_propListModel, SLOT(selectAll())); - connect(m_ui->selectNoneButton, SIGNAL(clicked()), m_propListModel, SLOT(selectNone())); - connect(m_ui->filesList, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayFilesListMenu(const QPoint&))); - connect(m_ui->filesList, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(openDoubleClickedFile(const QModelIndex&))); - connect(m_propListModel, SIGNAL(filteredFilesChanged()), this, SLOT(filteredFilesChanged())); - connect(m_ui->listWebSeeds, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayWebSeedListMenu(const QPoint&))); - connect(transferList, SIGNAL(currentTorrentChanged(BitTorrent::TorrentHandle *const)), this, SLOT(loadTorrentInfos(BitTorrent::TorrentHandle *const))); - connect(m_propListDelegate, SIGNAL(filteredFilesChanged()), this, SLOT(filteredFilesChanged())); - connect(m_ui->stackedProperties, SIGNAL(currentChanged(int)), this, SLOT(loadDynamicData())); - connect(BitTorrent::Session::instance(), SIGNAL(torrentSavePathChanged(BitTorrent::TorrentHandle *const)), this, SLOT(updateSavePath(BitTorrent::TorrentHandle *const))); - connect(BitTorrent::Session::instance(), SIGNAL(torrentMetadataLoaded(BitTorrent::TorrentHandle *const)), this, SLOT(updateTorrentInfos(BitTorrent::TorrentHandle *const))); - connect(m_ui->filesList->header(), SIGNAL(sectionMoved(int,int,int)), this, SLOT(saveSettings())); - connect(m_ui->filesList->header(), SIGNAL(sectionResized(int,int,int)), this, SLOT(saveSettings())); - connect(m_ui->filesList->header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(saveSettings())); + connect(m_ui->filesList, &QAbstractItemView::clicked + , m_ui->filesList, static_cast(&QAbstractItemView::edit)); + connect(m_ui->selectAllButton, &QPushButton::clicked, m_propListModel, &TorrentContentFilterModel::selectAll); + connect(m_ui->selectNoneButton, &QPushButton::clicked, m_propListModel, &TorrentContentFilterModel::selectNone); + connect(m_ui->filesList, &QWidget::customContextMenuRequested, this, &PropertiesWidget::displayFilesListMenu); + connect(m_ui->filesList, &QAbstractItemView::doubleClicked, this, &PropertiesWidget::openDoubleClickedFile); + connect(m_propListModel, &TorrentContentFilterModel::filteredFilesChanged, this, &PropertiesWidget::filteredFilesChanged); + connect(m_ui->listWebSeeds, &QWidget::customContextMenuRequested, this, &PropertiesWidget::displayWebSeedListMenu); + connect(transferList, &TransferListWidget::currentTorrentChanged, this, &PropertiesWidget::loadTorrentInfos); + connect(m_propListDelegate, &PropListDelegate::filteredFilesChanged, this, &PropertiesWidget::filteredFilesChanged); + connect(m_ui->stackedProperties, &QStackedWidget::currentChanged, this, &PropertiesWidget::loadDynamicData); + connect(BitTorrent::Session::instance(), &BitTorrent::Session::torrentSavePathChanged, this, &PropertiesWidget::updateSavePath); + connect(BitTorrent::Session::instance(), &BitTorrent::Session::torrentMetadataLoaded, this, &PropertiesWidget::updateTorrentInfos); + connect(m_ui->filesList->header(), &QHeaderView::sectionMoved, this, &PropertiesWidget::saveSettings); + connect(m_ui->filesList->header(), &QHeaderView::sectionResized, this, &PropertiesWidget::saveSettings); + connect(m_ui->filesList->header(), &QHeaderView::sortIndicatorChanged, this, &PropertiesWidget::saveSettings); // set bar height relative to screen dpi const int barHeight = Utils::Gui::scaledSize(this, 18); @@ -136,8 +137,8 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow *mainWindow, Tran m_ui->trackerUpButton->setIconSize(Utils::Gui::smallIconSize()); m_ui->trackerDownButton->setIcon(GuiIconProvider::instance()->getIcon("go-down")); m_ui->trackerDownButton->setIconSize(Utils::Gui::smallIconSize()); - connect(m_ui->trackerUpButton, SIGNAL(clicked()), m_trackerList, SLOT(moveSelectionUp())); - connect(m_ui->trackerDownButton, SIGNAL(clicked()), m_trackerList, SLOT(moveSelectionDown())); + connect(m_ui->trackerUpButton, &QPushButton::clicked, m_trackerList, &TrackerList::moveSelectionUp); + connect(m_ui->trackerDownButton, &QPushButton::clicked, m_trackerList, &TrackerList::moveSelectionDown); m_ui->horizontalLayout_trackers->insertWidget(0, m_trackerList); connect(m_trackerList->header(), SIGNAL(sectionMoved(int,int,int)), m_trackerList, SLOT(saveSettings())); connect(m_trackerList->header(), SIGNAL(sectionResized(int,int,int)), m_trackerList, SLOT(saveSettings())); @@ -155,23 +156,23 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow *mainWindow, Tran m_tabBar = new PropTabBar(); m_tabBar->setContentsMargins(0, 5, 0, 0); m_ui->verticalLayout->addLayout(m_tabBar); - connect(m_tabBar, SIGNAL(tabChanged(int)), m_ui->stackedProperties, SLOT(setCurrentIndex(int))); - connect(m_tabBar, SIGNAL(tabChanged(int)), this, SLOT(saveSettings())); - connect(m_tabBar, SIGNAL(visibilityToggled(bool)), SLOT(setVisibility(bool))); - connect(m_tabBar, SIGNAL(visibilityToggled(bool)), this, SLOT(saveSettings())); + connect(m_tabBar, &PropTabBar::tabChanged, m_ui->stackedProperties, &QStackedWidget::setCurrentIndex); + connect(m_tabBar, &PropTabBar::tabChanged, this, &PropertiesWidget::saveSettings); + connect(m_tabBar, &PropTabBar::visibilityToggled, this, &PropertiesWidget::setVisibility); + connect(m_tabBar, &PropTabBar::visibilityToggled, this, &PropertiesWidget::saveSettings); // Dynamic data refresher m_refreshTimer = new QTimer(this); - connect(m_refreshTimer, SIGNAL(timeout()), this, SLOT(loadDynamicData())); + connect(m_refreshTimer, &QTimer::timeout, this, &PropertiesWidget::loadDynamicData); m_refreshTimer->start(3000); // 3sec m_editHotkeyFile = new QShortcut(Qt::Key_F2, m_ui->filesList, nullptr, nullptr, Qt::WidgetShortcut); - connect(m_editHotkeyFile, SIGNAL(activated()), SLOT(renameSelectedFile())); + connect(m_editHotkeyFile, &QShortcut::activated, this, &PropertiesWidget::renameSelectedFile); m_editHotkeyWeb = new QShortcut(Qt::Key_F2, m_ui->listWebSeeds, nullptr, nullptr, Qt::WidgetShortcut); - connect(m_editHotkeyWeb, SIGNAL(activated()), SLOT(editWebSeed())); - connect(m_ui->listWebSeeds, SIGNAL(doubleClicked(QModelIndex)), SLOT(editWebSeed())); + connect(m_editHotkeyWeb, &QShortcut::activated, this, &PropertiesWidget::editWebSeed); + connect(m_ui->listWebSeeds, &QListWidget::doubleClicked, this, &PropertiesWidget::editWebSeed); m_deleteHotkeyWeb = new QShortcut(QKeySequence::Delete, m_ui->listWebSeeds, nullptr, nullptr, Qt::WidgetShortcut); - connect(m_deleteHotkeyWeb, SIGNAL(activated()), SLOT(deleteSelectedUrlSeeds())); + connect(m_deleteHotkeyWeb, &QShortcut::activated, this, &PropertiesWidget::deleteSelectedUrlSeeds); m_openHotkeyFile = new QShortcut(Qt::Key_Return, m_ui->filesList, nullptr, nullptr, Qt::WidgetShortcut); - connect(m_openHotkeyFile, SIGNAL(activated()), SLOT(openSelectedFile())); + connect(m_openHotkeyFile, &QShortcut::activated, this, &PropertiesWidget::openSelectedFile); } PropertiesWidget::~PropertiesWidget() diff --git a/src/gui/properties/proptabbar.cpp b/src/gui/properties/proptabbar.cpp index 0418a345f..779283b3b 100644 --- a/src/gui/properties/proptabbar.cpp +++ b/src/gui/properties/proptabbar.cpp @@ -99,7 +99,8 @@ PropTabBar::PropTabBar(QWidget *parent) addWidget(speedButton); m_btnGroup->addButton(speedButton, SpeedTab); // SIGNAL/SLOT - connect(m_btnGroup, SIGNAL(buttonClicked(int)), SLOT(setCurrentIndex(int))); + connect(m_btnGroup, static_cast(&QButtonGroup::buttonClicked) + , this, &PropTabBar::setCurrentIndex); // Disable buttons focus foreach (QAbstractButton *btn, m_btnGroup->buttons()) btn->setFocusPolicy(Qt::NoFocus); diff --git a/src/gui/properties/trackerlist.cpp b/src/gui/properties/trackerlist.cpp index eeeb37ea2..b9c13bb34 100644 --- a/src/gui/properties/trackerlist.cpp +++ b/src/gui/properties/trackerlist.cpp @@ -78,10 +78,10 @@ TrackerList::TrackerList(PropertiesWidget *properties) resizeColumnToContents(i); // Context menu setContextMenuPolicy(Qt::CustomContextMenu); - connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showTrackerListMenu(QPoint))); + connect(this, &QWidget::customContextMenuRequested, this, &TrackerList::showTrackerListMenu); // Header context menu header()->setContextMenuPolicy(Qt::CustomContextMenu); - connect(header(), SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayToggleColumnsMenu(const QPoint&))); + connect(header(), &QWidget::customContextMenuRequested, this, &TrackerList::displayToggleColumnsMenu); // Set DHT, PeX, LSD items m_DHTItem = new QTreeWidgetItem({ "", "** [DHT] **", "", "0", "", "", "0" }); insertTopLevelItem(0, m_DHTItem); @@ -112,10 +112,13 @@ TrackerList::TrackerList(PropertiesWidget *properties) headerItem()->setTextAlignment(COL_PEERS, (Qt::AlignRight | Qt::AlignVCenter)); headerItem()->setTextAlignment(COL_DOWNLOADED, (Qt::AlignRight | Qt::AlignVCenter)); // Set hotkeys - m_editHotkey = new QShortcut(Qt::Key_F2, this, SLOT(editSelectedTracker()), nullptr, Qt::WidgetShortcut); - connect(this, SIGNAL(doubleClicked(QModelIndex)), SLOT(editSelectedTracker())); - m_deleteHotkey = new QShortcut(QKeySequence::Delete, this, SLOT(deleteSelectedTrackers()), nullptr, Qt::WidgetShortcut); - m_copyHotkey = new QShortcut(QKeySequence::Copy, this, SLOT(copyTrackerUrl()), nullptr, Qt::WidgetShortcut); + m_editHotkey = new QShortcut(Qt::Key_F2, this, nullptr, nullptr, Qt::WidgetShortcut); + connect(m_editHotkey, &QShortcut::activated, this, &TrackerList::editSelectedTracker); + connect(this, &QAbstractItemView::doubleClicked, this, &TrackerList::editSelectedTracker); + m_deleteHotkey = new QShortcut(QKeySequence::Delete, this, nullptr, nullptr, Qt::WidgetShortcut); + connect(m_deleteHotkey, &QShortcut::activated, this, &TrackerList::deleteSelectedTrackers); + m_copyHotkey = new QShortcut(QKeySequence::Copy, this, nullptr, nullptr, Qt::WidgetShortcut); + connect(m_copyHotkey, &QShortcut::activated, this, &TrackerList::copyTrackerUrl); // This hack fixes reordering of first column with Qt5. // https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777 diff --git a/src/gui/properties/trackersadditiondlg.cpp b/src/gui/properties/trackersadditiondlg.cpp index 34252a96e..9ec5c53fb 100644 --- a/src/gui/properties/trackersadditiondlg.cpp +++ b/src/gui/properties/trackersadditiondlg.cpp @@ -71,8 +71,9 @@ void TrackersAdditionDlg::on_uTorrentListButton_clicked() { m_ui->uTorrentListButton->setEnabled(false); Net::DownloadHandler *handler = Net::DownloadManager::instance()->downloadUrl(m_ui->list_url->text(), true); - connect(handler, SIGNAL(downloadFinished(QString, QString)), this, SLOT(parseUTorrentList(QString, QString))); - connect(handler, SIGNAL(downloadFailed(QString, QString)), this, SLOT(getTrackerError(QString, QString))); + connect(handler, static_cast(&Net::DownloadHandler::downloadFinished) + , this, &TrackersAdditionDlg::parseUTorrentList); + connect(handler, &Net::DownloadHandler::downloadFailed, this, &TrackersAdditionDlg::getTrackerError); // Just to show that it takes times setCursor(Qt::WaitCursor); } diff --git a/src/gui/rss/htmlbrowser.cpp b/src/gui/rss/htmlbrowser.cpp index 8550bbb04..0242cf510 100644 --- a/src/gui/rss/htmlbrowser.cpp +++ b/src/gui/rss/htmlbrowser.cpp @@ -22,7 +22,7 @@ HtmlBrowser::HtmlBrowser(QWidget *parent) qDebug() << "HtmlBrowser cache path:" << m_diskCache->cacheDirectory() << " max size:" << m_diskCache->maximumCacheSize() / 1024 / 1024 << "MB"; m_netManager->setCache(m_diskCache); - connect(m_netManager, SIGNAL(finished(QNetworkReply *)), this, SLOT(resourceLoaded(QNetworkReply*))); + connect(m_netManager, &QNetworkAccessManager::finished, this, &HtmlBrowser::resourceLoaded); } HtmlBrowser::~HtmlBrowser() diff --git a/src/gui/scanfoldersdelegate.cpp b/src/gui/scanfoldersdelegate.cpp index 56fa993fc..f7b10ec26 100644 --- a/src/gui/scanfoldersdelegate.cpp +++ b/src/gui/scanfoldersdelegate.cpp @@ -71,7 +71,8 @@ QWidget *ScanFoldersDelegate::createEditor(QWidget *parent, const QStyleOptionVi editor->addItem(index.data().toString()); } - connect(editor, SIGNAL(currentIndexChanged(int)), this, SLOT(comboboxIndexChanged(int))); + connect(editor, static_cast(&QComboBox::currentIndexChanged) + , this, &ScanFoldersDelegate::comboboxIndexChanged); return editor; } diff --git a/src/gui/search/searchtab.cpp b/src/gui/search/searchtab.cpp index 2c0fb044e..a75040919 100644 --- a/src/gui/search/searchtab.cpp +++ b/src/gui/search/searchtab.cpp @@ -129,23 +129,23 @@ SearchTab::SearchTab(SearchHandler *searchHandler, QWidget *parent) updateFilter(); - connect(m_ui->filterMode, static_cast(&QComboBox::currentIndexChanged) + connect(m_ui->filterMode, static_cast(&QComboBox::currentIndexChanged) , this, &SearchTab::updateFilter); connect(m_ui->minSeeds, &QAbstractSpinBox::editingFinished, this, &SearchTab::updateFilter); - connect(m_ui->minSeeds, static_cast(&QSpinBox::valueChanged) + connect(m_ui->minSeeds, static_cast(&QSpinBox::valueChanged) , this, &SearchTab::updateFilter); connect(m_ui->maxSeeds, &QAbstractSpinBox::editingFinished, this, &SearchTab::updateFilter); - connect(m_ui->maxSeeds, static_cast(&QSpinBox::valueChanged) + connect(m_ui->maxSeeds, static_cast(&QSpinBox::valueChanged) , this, &SearchTab::updateFilter); connect(m_ui->minSize, &QAbstractSpinBox::editingFinished, this, &SearchTab::updateFilter); - connect(m_ui->minSize, static_cast(&QDoubleSpinBox::valueChanged) + connect(m_ui->minSize, static_cast(&QDoubleSpinBox::valueChanged) , this, &SearchTab::updateFilter); connect(m_ui->maxSize, &QAbstractSpinBox::editingFinished, this, &SearchTab::updateFilter); - connect(m_ui->maxSize, static_cast(&QDoubleSpinBox::valueChanged) + connect(m_ui->maxSize, static_cast(&QDoubleSpinBox::valueChanged) , this, &SearchTab::updateFilter); - connect(m_ui->minSizeUnit, static_cast(&QComboBox::currentIndexChanged) + connect(m_ui->minSizeUnit, static_cast(&QComboBox::currentIndexChanged) , this, &SearchTab::updateFilter); - connect(m_ui->maxSizeUnit, static_cast(&QComboBox::currentIndexChanged) + connect(m_ui->maxSizeUnit, static_cast(&QComboBox::currentIndexChanged) , this, &SearchTab::updateFilter); connect(m_ui->resultsBrowser, &QAbstractItemView::doubleClicked, this, &SearchTab::onItemDoubleClicked); diff --git a/src/gui/shutdownconfirmdlg.cpp b/src/gui/shutdownconfirmdlg.cpp index eaf3a2012..0cccc3f7a 100644 --- a/src/gui/shutdownconfirmdlg.cpp +++ b/src/gui/shutdownconfirmdlg.cpp @@ -66,7 +66,7 @@ ShutdownConfirmDlg::ShutdownConfirmDlg(QWidget *parent, const ShutdownDialogActi move(Utils::Misc::screenCenter(this)); m_timer.setInterval(1000); // 1sec - connect(&m_timer, SIGNAL(timeout()), this, SLOT(updateSeconds())); + connect(&m_timer, &QTimer::timeout, this, &ShutdownConfirmDlg::updateSeconds); Utils::Gui::resize(this); } diff --git a/src/gui/speedlimitdlg.cpp b/src/gui/speedlimitdlg.cpp index 916686154..9f93dc396 100644 --- a/src/gui/speedlimitdlg.cpp +++ b/src/gui/speedlimitdlg.cpp @@ -40,8 +40,9 @@ SpeedLimitDialog::SpeedLimitDialog(QWidget *parent) qDebug("Bandwidth allocation dialog creation"); // Connect to slots - connect(m_ui->bandwidthSlider, SIGNAL(valueChanged(int)), this, SLOT(updateSpinValue(int))); - connect(m_ui->spinBandwidth, SIGNAL(valueChanged(int)), this, SLOT(updateSliderValue(int))); + connect(m_ui->bandwidthSlider, &QSlider::valueChanged, this, &SpeedLimitDialog::updateSpinValue); + connect(m_ui->spinBandwidth, static_cast(&QSpinBox::valueChanged) + , this, &SpeedLimitDialog::updateSliderValue); Utils::Gui::resize(this); } diff --git a/src/gui/torrentcontentfiltermodel.cpp b/src/gui/torrentcontentfiltermodel.cpp index 4bb665804..41419748e 100644 --- a/src/gui/torrentcontentfiltermodel.cpp +++ b/src/gui/torrentcontentfiltermodel.cpp @@ -35,7 +35,7 @@ TorrentContentFilterModel::TorrentContentFilterModel(QObject *parent) : QSortFilterProxyModel(parent) , m_model(new TorrentContentModel(this)) { - connect(m_model, SIGNAL(filteredFilesChanged()), this, SIGNAL(filteredFilesChanged())); + connect(m_model, &TorrentContentModel::filteredFilesChanged, this, &TorrentContentFilterModel::filteredFilesChanged); setSourceModel(m_model); // Filter settings setFilterKeyColumn(TorrentContentModelItem::COL_NAME); diff --git a/src/gui/torrentmodel.cpp b/src/gui/torrentmodel.cpp index 79d916733..9bb9490f0 100644 --- a/src/gui/torrentmodel.cpp +++ b/src/gui/torrentmodel.cpp @@ -61,19 +61,20 @@ TorrentModel::TorrentModel(QObject *parent) : QAbstractListModel(parent) { // Load the torrents - foreach (BitTorrent::TorrentHandle *const torrent, BitTorrent::Session::instance()->torrents()) + using namespace BitTorrent; + foreach (TorrentHandle *const torrent, Session::instance()->torrents()) addTorrent(torrent); // Listen for torrent changes - connect(BitTorrent::Session::instance(), SIGNAL(torrentAdded(BitTorrent::TorrentHandle * const)), SLOT(addTorrent(BitTorrent::TorrentHandle * const))); - connect(BitTorrent::Session::instance(), SIGNAL(torrentAboutToBeRemoved(BitTorrent::TorrentHandle * const)), SLOT(handleTorrentAboutToBeRemoved(BitTorrent::TorrentHandle * const))); - connect(BitTorrent::Session::instance(), SIGNAL(torrentsUpdated()), SLOT(handleTorrentsUpdated())); - - connect(BitTorrent::Session::instance(), SIGNAL(torrentFinished(BitTorrent::TorrentHandle * const)), SLOT(handleTorrentStatusUpdated(BitTorrent::TorrentHandle * const))); - connect(BitTorrent::Session::instance(), SIGNAL(torrentMetadataLoaded(BitTorrent::TorrentHandle * const)), SLOT(handleTorrentStatusUpdated(BitTorrent::TorrentHandle * const))); - connect(BitTorrent::Session::instance(), SIGNAL(torrentResumed(BitTorrent::TorrentHandle * const)), SLOT(handleTorrentStatusUpdated(BitTorrent::TorrentHandle * const))); - connect(BitTorrent::Session::instance(), SIGNAL(torrentPaused(BitTorrent::TorrentHandle * const)), SLOT(handleTorrentStatusUpdated(BitTorrent::TorrentHandle * const))); - connect(BitTorrent::Session::instance(), SIGNAL(torrentFinishedChecking(BitTorrent::TorrentHandle * const)), SLOT(handleTorrentStatusUpdated(BitTorrent::TorrentHandle * const))); + connect(Session::instance(), &Session::torrentAdded, this, &TorrentModel::addTorrent); + connect(Session::instance(), &Session::torrentAboutToBeRemoved, this, &TorrentModel::handleTorrentAboutToBeRemoved); + connect(Session::instance(), &Session::torrentsUpdated, this, &TorrentModel::handleTorrentsUpdated); + + connect(Session::instance(), &Session::torrentFinished, this, &TorrentModel::handleTorrentStatusUpdated); + connect(Session::instance(), &Session::torrentMetadataLoaded, this, &TorrentModel::handleTorrentStatusUpdated); + connect(Session::instance(), &Session::torrentResumed, this, &TorrentModel::handleTorrentStatusUpdated); + connect(Session::instance(), &Session::torrentPaused, this, &TorrentModel::handleTorrentStatusUpdated); + connect(Session::instance(), &Session::torrentFinishedChecking, this, &TorrentModel::handleTorrentStatusUpdated); } int TorrentModel::rowCount(const QModelIndex &index) const diff --git a/src/gui/transferlistwidget.cpp b/src/gui/transferlistwidget.cpp index 9953df02c..45cdc3eed 100644 --- a/src/gui/transferlistwidget.cpp +++ b/src/gui/transferlistwidget.cpp @@ -280,19 +280,24 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *mainWindow) setContextMenuPolicy(Qt::CustomContextMenu); // Listen for list events - connect(this, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(torrentDoubleClicked())); - connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(displayListMenu(const QPoint &))); + connect(this, &QAbstractItemView::doubleClicked, this, &TransferListWidget::torrentDoubleClicked); + connect(this, &QWidget::customContextMenuRequested, this, &TransferListWidget::displayListMenu); header()->setContextMenuPolicy(Qt::CustomContextMenu); - connect(header(), SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(displayDLHoSMenu(const QPoint &))); - connect(header(), SIGNAL(sectionMoved(int, int, int)), this, SLOT(saveSettings())); - connect(header(), SIGNAL(sectionResized(int, int, int)), this, SLOT(saveSettings())); - connect(header(), SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)), this, SLOT(saveSettings())); - - m_editHotkey = new QShortcut(Qt::Key_F2, this, SLOT(renameSelectedTorrent()), nullptr, Qt::WidgetShortcut); - m_deleteHotkey = new QShortcut(QKeySequence::Delete, this, SLOT(softDeleteSelectedTorrents()), nullptr, Qt::WidgetShortcut); - m_permDeleteHotkey = new QShortcut(Qt::SHIFT + Qt::Key_Delete, this, SLOT(permDeleteSelectedTorrents()), nullptr, Qt::WidgetShortcut); - m_doubleClickHotkey = new QShortcut(Qt::Key_Return, this, SLOT(torrentDoubleClicked()), nullptr, Qt::WidgetShortcut); - m_recheckHotkey = new QShortcut(Qt::CTRL + Qt::Key_R, this, SLOT(recheckSelectedTorrents()), nullptr, Qt::WidgetShortcut); + connect(header(), &QWidget::customContextMenuRequested, this, &TransferListWidget::displayDLHoSMenu); + connect(header(), &QHeaderView::sectionMoved, this, &TransferListWidget::saveSettings); + connect(header(), &QHeaderView::sectionResized, this, &TransferListWidget::saveSettings); + connect(header(), &QHeaderView::sortIndicatorChanged, this, &TransferListWidget::saveSettings); + + m_editHotkey = new QShortcut(Qt::Key_F2, this, nullptr, nullptr, Qt::WidgetShortcut); + connect(m_editHotkey, &QShortcut::activated, this, &TransferListWidget::renameSelectedTorrent); + m_deleteHotkey = new QShortcut(QKeySequence::Delete, this, nullptr, nullptr, Qt::WidgetShortcut); + connect(m_deleteHotkey, &QShortcut::activated, this, &TransferListWidget::softDeleteSelectedTorrents); + m_permDeleteHotkey = new QShortcut(Qt::SHIFT + Qt::Key_Delete, this, nullptr, nullptr, Qt::WidgetShortcut); + connect(m_permDeleteHotkey, &QShortcut::activated, this, &TransferListWidget::permDeleteSelectedTorrents); + m_doubleClickHotkey = new QShortcut(Qt::Key_Return, this, nullptr, nullptr, Qt::WidgetShortcut); + connect(m_doubleClickHotkey, &QShortcut::activated, this, &TransferListWidget::torrentDoubleClicked); + m_recheckHotkey = new QShortcut(Qt::CTRL + Qt::Key_R, this, nullptr, nullptr, Qt::WidgetShortcut); + connect(m_recheckHotkey, &QShortcut::activated, this, &TransferListWidget::recheckSelectedTorrents); // This hack fixes reordering of first column with Qt5. // https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777 @@ -861,58 +866,58 @@ void TransferListWidget::displayListMenu(const QPoint&) // Create actions QAction actionStart(GuiIconProvider::instance()->getIcon("media-playback-start"), tr("Resume", "Resume/start the torrent"), nullptr); - connect(&actionStart, SIGNAL(triggered()), this, SLOT(startSelectedTorrents())); + connect(&actionStart, &QAction::triggered, this, &TransferListWidget::startSelectedTorrents); QAction actionPause(GuiIconProvider::instance()->getIcon("media-playback-pause"), tr("Pause", "Pause the torrent"), nullptr); - connect(&actionPause, SIGNAL(triggered()), this, SLOT(pauseSelectedTorrents())); + connect(&actionPause, &QAction::triggered, this, &TransferListWidget::pauseSelectedTorrents); QAction actionForceStart(GuiIconProvider::instance()->getIcon("media-seek-forward"), tr("Force Resume", "Force Resume/start the torrent"), nullptr); - connect(&actionForceStart, SIGNAL(triggered()), this, SLOT(forceStartSelectedTorrents())); + connect(&actionForceStart, &QAction::triggered, this, &TransferListWidget::forceStartSelectedTorrents); QAction actionDelete(GuiIconProvider::instance()->getIcon("edit-delete"), tr("Delete", "Delete the torrent"), nullptr); - connect(&actionDelete, SIGNAL(triggered()), this, SLOT(softDeleteSelectedTorrents())); + connect(&actionDelete, &QAction::triggered, this, &TransferListWidget::softDeleteSelectedTorrents); QAction actionPreview_file(GuiIconProvider::instance()->getIcon("view-preview"), tr("Preview file..."), nullptr); - connect(&actionPreview_file, SIGNAL(triggered()), this, SLOT(previewSelectedTorrents())); + connect(&actionPreview_file, &QAction::triggered, this, &TransferListWidget::previewSelectedTorrents); QAction actionSet_max_ratio(QIcon(QLatin1String(":/icons/skin/ratio.png")), tr("Limit share ratio..."), nullptr); - connect(&actionSet_max_ratio, SIGNAL(triggered()), this, SLOT(setMaxRatioSelectedTorrents())); + connect(&actionSet_max_ratio, &QAction::triggered, this, &TransferListWidget::setMaxRatioSelectedTorrents); QAction actionSet_upload_limit(GuiIconProvider::instance()->getIcon("kt-set-max-upload-speed"), tr("Limit upload rate..."), nullptr); - connect(&actionSet_upload_limit, SIGNAL(triggered()), this, SLOT(setUpLimitSelectedTorrents())); + connect(&actionSet_upload_limit, &QAction::triggered, this, &TransferListWidget::setUpLimitSelectedTorrents); QAction actionSet_download_limit(GuiIconProvider::instance()->getIcon("kt-set-max-download-speed"), tr("Limit download rate..."), nullptr); - connect(&actionSet_download_limit, SIGNAL(triggered()), this, SLOT(setDlLimitSelectedTorrents())); + connect(&actionSet_download_limit, &QAction::triggered, this, &TransferListWidget::setDlLimitSelectedTorrents); QAction actionOpen_destination_folder(GuiIconProvider::instance()->getIcon("inode-directory"), tr("Open destination folder"), nullptr); - connect(&actionOpen_destination_folder, SIGNAL(triggered()), this, SLOT(openSelectedTorrentsFolder())); + connect(&actionOpen_destination_folder, &QAction::triggered, this, &TransferListWidget::openSelectedTorrentsFolder); QAction actionIncreasePriority(GuiIconProvider::instance()->getIcon("go-up"), tr("Move up", "i.e. move up in the queue"), nullptr); - connect(&actionIncreasePriority, SIGNAL(triggered()), this, SLOT(increasePrioSelectedTorrents())); + connect(&actionIncreasePriority, &QAction::triggered, this, &TransferListWidget::increasePrioSelectedTorrents); QAction actionDecreasePriority(GuiIconProvider::instance()->getIcon("go-down"), tr("Move down", "i.e. Move down in the queue"), nullptr); - connect(&actionDecreasePriority, SIGNAL(triggered()), this, SLOT(decreasePrioSelectedTorrents())); + connect(&actionDecreasePriority, &QAction::triggered, this, &TransferListWidget::decreasePrioSelectedTorrents); QAction actionTopPriority(GuiIconProvider::instance()->getIcon("go-top"), tr("Move to top", "i.e. Move to top of the queue"), nullptr); - connect(&actionTopPriority, SIGNAL(triggered()), this, SLOT(topPrioSelectedTorrents())); + connect(&actionTopPriority, &QAction::triggered, this, &TransferListWidget::topPrioSelectedTorrents); QAction actionBottomPriority(GuiIconProvider::instance()->getIcon("go-bottom"), tr("Move to bottom", "i.e. Move to bottom of the queue"), nullptr); - connect(&actionBottomPriority, SIGNAL(triggered()), this, SLOT(bottomPrioSelectedTorrents())); + connect(&actionBottomPriority, &QAction::triggered, this, &TransferListWidget::bottomPrioSelectedTorrents); QAction actionSetTorrentPath(GuiIconProvider::instance()->getIcon("inode-directory"), tr("Set location..."), nullptr); - connect(&actionSetTorrentPath, SIGNAL(triggered()), this, SLOT(setSelectedTorrentsLocation())); + connect(&actionSetTorrentPath, &QAction::triggered, this, &TransferListWidget::setSelectedTorrentsLocation); QAction actionForce_recheck(GuiIconProvider::instance()->getIcon("document-edit-verify"), tr("Force recheck"), nullptr); - connect(&actionForce_recheck, SIGNAL(triggered()), this, SLOT(recheckSelectedTorrents())); + connect(&actionForce_recheck, &QAction::triggered, this, &TransferListWidget::recheckSelectedTorrents); QAction actionForce_reannounce(GuiIconProvider::instance()->getIcon("document-edit-verify"), tr("Force reannounce"), nullptr); - connect(&actionForce_reannounce, SIGNAL(triggered()), this, SLOT(reannounceSelectedTorrents())); + connect(&actionForce_reannounce, &QAction::triggered, this, &TransferListWidget::reannounceSelectedTorrents); QAction actionCopy_magnet_link(GuiIconProvider::instance()->getIcon("kt-magnet"), tr("Copy magnet link"), nullptr); - connect(&actionCopy_magnet_link, SIGNAL(triggered()), this, SLOT(copySelectedMagnetURIs())); + connect(&actionCopy_magnet_link, &QAction::triggered, this, &TransferListWidget::copySelectedMagnetURIs); QAction actionCopy_name(GuiIconProvider::instance()->getIcon("edit-copy"), tr("Copy name"), nullptr); - connect(&actionCopy_name, SIGNAL(triggered()), this, SLOT(copySelectedNames())); + connect(&actionCopy_name, &QAction::triggered, this, &TransferListWidget::copySelectedNames); QAction actionCopyHash(GuiIconProvider::instance()->getIcon("edit-copy"), tr("Copy hash"), nullptr); connect(&actionCopyHash, &QAction::triggered, this, &TransferListWidget::copySelectedHashes); QAction actionSuper_seeding_mode(tr("Super seeding mode"), nullptr); actionSuper_seeding_mode.setCheckable(true); - connect(&actionSuper_seeding_mode, SIGNAL(triggered()), this, SLOT(toggleSelectedTorrentsSuperSeeding())); + connect(&actionSuper_seeding_mode, &QAction::triggered, this, &TransferListWidget::toggleSelectedTorrentsSuperSeeding); QAction actionRename(GuiIconProvider::instance()->getIcon("edit-rename"), tr("Rename..."), nullptr); - connect(&actionRename, SIGNAL(triggered()), this, SLOT(renameSelectedTorrent())); + connect(&actionRename, &QAction::triggered, this, &TransferListWidget::renameSelectedTorrent); QAction actionSequential_download(tr("Download in sequential order"), nullptr); actionSequential_download.setCheckable(true); - connect(&actionSequential_download, SIGNAL(triggered()), this, SLOT(toggleSelectedTorrentsSequentialDownload())); + connect(&actionSequential_download, &QAction::triggered, this, &TransferListWidget::toggleSelectedTorrentsSequentialDownload); QAction actionFirstLastPiece_prio(tr("Download first and last pieces first"), nullptr); actionFirstLastPiece_prio.setCheckable(true); - connect(&actionFirstLastPiece_prio, SIGNAL(triggered()), this, SLOT(toggleSelectedFirstLastPiecePrio())); + connect(&actionFirstLastPiece_prio, &QAction::triggered, this, &TransferListWidget::toggleSelectedFirstLastPiecePrio); QAction actionAutoTMM(tr("Automatic Torrent Management"), nullptr); actionAutoTMM.setCheckable(true); actionAutoTMM.setToolTip(tr("Automatic mode means that various torrent properties(eg save path) will be decided by the associated category")); - connect(&actionAutoTMM, SIGNAL(triggered(bool)), this, SLOT(setSelectedAutoTMMEnabled(bool))); + connect(&actionAutoTMM, &QAction::triggered, this, &TransferListWidget::setSelectedAutoTMMEnabled); // End of actions // Enable/disable pause/start action given the DL state diff --git a/src/gui/updownratiodlg.cpp b/src/gui/updownratiodlg.cpp index f4ba4ed1c..ca9d14825 100644 --- a/src/gui/updownratiodlg.cpp +++ b/src/gui/updownratiodlg.cpp @@ -69,9 +69,10 @@ UpDownRatioDlg::UpDownRatioDlg(bool useDefault, qreal initialRatioValue, m_ui->timeSpinBox->setMaximum(maxTimeValue); m_ui->timeSpinBox->setValue(initialTimeValue); - connect(m_ui->buttonGroup, SIGNAL(buttonClicked(int)), SLOT(handleRatioTypeChanged())); - connect(m_ui->checkMaxRatio, SIGNAL(toggled(bool)), this, SLOT(enableRatioSpin())); - connect(m_ui->checkMaxTime, SIGNAL(toggled(bool)), this, SLOT(enableTimeSpin())); + connect(m_ui->buttonGroup, static_cast(&QButtonGroup::buttonClicked) + , this, &UpDownRatioDlg::handleRatioTypeChanged); + connect(m_ui->checkMaxRatio, &QCheckBox::toggled, this, &UpDownRatioDlg::enableRatioSpin); + connect(m_ui->checkMaxTime, &QCheckBox::toggled, this, &UpDownRatioDlg::enableTimeSpin); handleRatioTypeChanged();