diff --git a/qt/AboutDialog.cc b/qt/AboutDialog.cc index 8b91e5911..adf4a48da 100644 --- a/qt/AboutDialog.cc +++ b/qt/AboutDialog.cc @@ -29,10 +29,10 @@ AboutDialog::AboutDialog(QWidget* parent) : QPushButton* b; b = ui_.dialogButtons->addButton(tr("C&redits"), QDialogButtonBox::ActionRole); - connect(b, SIGNAL(clicked()), this, SLOT(showCredits())); + connect(b, &QAbstractButton::clicked, this, &AboutDialog::showCredits); b = ui_.dialogButtons->addButton(tr("&License"), QDialogButtonBox::ActionRole); - connect(b, SIGNAL(clicked()), this, SLOT(showLicense())); + connect(b, &QAbstractButton::clicked, this, &AboutDialog::showLicense); ui_.dialogButtons->button(QDialogButtonBox::Close)->setDefault(true); } diff --git a/qt/Application.cc b/qt/Application.cc index 347fef07d..37bc83bfd 100644 --- a/qt/Application.cc +++ b/qt/Application.cc @@ -337,7 +337,7 @@ Application::Application(int& argc, char** argv) : dialog->setDefaultButton(QMessageBox::Ok); dialog->setModal(true); - connect(dialog, SIGNAL(finished(int)), this, SLOT(consentGiven(int))); + connect(dialog, &QDialog::finished, this, &Application::consentGiven); dialog->setAttribute(Qt::WA_DeleteOnClose); dialog->show(); diff --git a/qt/ColumnResizer.cc b/qt/ColumnResizer.cc index b1da51132..9459b1c18 100644 --- a/qt/ColumnResizer.cc +++ b/qt/ColumnResizer.cc @@ -8,7 +8,6 @@ #include #include -#include #include "ColumnResizer.h" @@ -38,11 +37,10 @@ int itemColumnSpan(QGridLayout* layout, QLayoutItem const* item) } // namespace ColumnResizer::ColumnResizer(QObject* parent) : - QObject(parent), - timer_(new QTimer(this)) + QObject(parent) { - timer_->setSingleShot(true); - connect(timer_, SIGNAL(timeout()), SLOT(update())); + timer_.setSingleShot(true); + connect(&timer_, &QTimer::timeout, this, &ColumnResizer::update); } void ColumnResizer::addLayout(QGridLayout* layout) @@ -88,5 +86,5 @@ void ColumnResizer::update() void ColumnResizer::scheduleUpdate() { - timer_->start(0); + timer_.start(0); } diff --git a/qt/ColumnResizer.h b/qt/ColumnResizer.h index bccdb0e52..320f74821 100644 --- a/qt/ColumnResizer.h +++ b/qt/ColumnResizer.h @@ -10,11 +10,11 @@ #include #include +#include #include "Macros.h" class QGridLayout; -class QTimer; class ColumnResizer : public QObject { @@ -35,6 +35,6 @@ public slots: private: void scheduleUpdate(); - QTimer* timer_ = {}; + QTimer timer_; QSet layouts_; }; diff --git a/qt/FaviconCache.cc b/qt/FaviconCache.cc index 50b2fc9bc..46cb458c4 100644 --- a/qt/FaviconCache.cc +++ b/qt/FaviconCache.cc @@ -24,7 +24,7 @@ FaviconCache::FaviconCache() : nam_(new QNetworkAccessManager(this)) { - connect(nam_, SIGNAL(finished(QNetworkReply*)), this, SLOT(onRequestFinished(QNetworkReply*))); + connect(nam_, &QNetworkAccessManager::finished, this, &FaviconCache::onRequestFinished); } /*** diff --git a/qt/FileTreeView.cc b/qt/FileTreeView.cc index c121b083f..35b03cdc4 100644 --- a/qt/FileTreeView.cc +++ b/qt/FileTreeView.cc @@ -40,15 +40,12 @@ FileTreeView::FileTreeView(QWidget* parent, bool is_editable) : setItemDelegate(delegate_); sortByColumn(FileTreeModel::COL_NAME, Qt::AscendingOrder); - connect(this, SIGNAL(clicked(QModelIndex)), this, SLOT(onClicked(QModelIndex))); + connect(this, &QAbstractItemView::clicked, this, &FileTreeView::onClicked); - connect(model_, SIGNAL(priorityChanged(QSet, int)), this, SIGNAL(priorityChanged(QSet, int))); - - connect(model_, SIGNAL(wantedChanged(QSet, bool)), this, SIGNAL(wantedChanged(QSet, bool))); - - connect(model_, SIGNAL(pathEdited(QString, QString)), this, SIGNAL(pathEdited(QString, QString))); - - connect(model_, SIGNAL(openRequested(QString)), this, SIGNAL(openRequested(QString))); + connect(model_, &FileTreeModel::openRequested, this, &FileTreeView::openRequested); + connect(model_, &FileTreeModel::pathEdited, this, &FileTreeView::pathEdited); + connect(model_, &FileTreeModel::priorityChanged, this, &FileTreeView::priorityChanged); + connect(model_, &FileTreeModel::wantedChanged, this, &FileTreeView::wantedChanged); } void FileTreeView::onClicked(QModelIndex const& proxy_index) @@ -405,7 +402,7 @@ void FileTreeView::initContextMenu() open_action_ = context_menu_->addAction(tr("Open"), this, SLOT(openSelectedItem())); rename_action_ = context_menu_->addAction(tr("Rename..."), this, SLOT(renameSelectedItem())); - connect(context_menu_, SIGNAL(aboutToShow()), SLOT(refreshContextMenuActionsSensitivity())); + connect(context_menu_, &QMenu::aboutToShow, this, &FileTreeView::refreshContextMenuActionsSensitivity); } QModelIndexList FileTreeView::selectedSourceRows(int column) const diff --git a/qt/FilterBar.cc b/qt/FilterBar.cc index 77ae4d4a0..eb4f3532c 100644 --- a/qt/FilterBar.cc +++ b/qt/FilterBar.cc @@ -211,7 +211,6 @@ FilterBar::FilterBar(Prefs& prefs, TorrentModel const& torrents, TorrentFilter c prefs_(prefs), torrents_(torrents), filter_(filter), - recount_timer_(new QTimer(this)), is_bootstrapping_(true) { auto* h = new QHBoxLayout(this); @@ -234,17 +233,17 @@ FilterBar::FilterBar(Prefs& prefs, TorrentModel const& torrents, TorrentFilter c line_edit_->setPlaceholderText(tr("Search...")); line_edit_->setMaximumWidth(250); h->addWidget(line_edit_, 1); - connect(line_edit_, SIGNAL(textChanged(QString)), this, SLOT(onTextChanged(QString))); + connect(line_edit_, &QLineEdit::textChanged, this, &FilterBar::onTextChanged); // listen for changes from the other players - connect(&prefs_, SIGNAL(changed(int)), this, SLOT(refreshPref(int))); - connect(activity_combo_, SIGNAL(currentIndexChanged(int)), this, SLOT(onActivityIndexChanged(int))); - connect(tracker_combo_, SIGNAL(currentIndexChanged(int)), this, SLOT(onTrackerIndexChanged(int))); + connect(&prefs_, &Prefs::changed, this, &FilterBar::refreshPref); + connect(activity_combo_, qOverload(&QComboBox::currentIndexChanged), this, &FilterBar::onActivityIndexChanged); + connect(tracker_combo_, qOverload(&QComboBox::currentIndexChanged), this, &FilterBar::onTrackerIndexChanged); connect(&torrents_, &TorrentModel::modelReset, this, &FilterBar::recountAllSoon); connect(&torrents_, &TorrentModel::rowsInserted, this, &FilterBar::recountAllSoon); connect(&torrents_, &TorrentModel::rowsRemoved, this, &FilterBar::recountAllSoon); connect(&torrents_, &TorrentModel::torrentsChanged, this, &FilterBar::onTorrentsChanged); - connect(recount_timer_, SIGNAL(timeout()), this, SLOT(recount())); + connect(&recount_timer_, &QTimer::timeout, this, &FilterBar::recount); connect(&qApp->faviconCache(), &FaviconCache::pixmapReady, this, &FilterBar::recountTrackersSoon); recountAllSoon(); @@ -357,10 +356,10 @@ void FilterBar::recountSoon(Pending const& pending) { pending_ |= pending; - if (!recount_timer_->isActive()) + if (!recount_timer_.isActive()) { - recount_timer_->setSingleShot(true); - recount_timer_->start(800); + recount_timer_.setSingleShot(true); + recount_timer_.start(800); } } diff --git a/qt/FilterBar.h b/qt/FilterBar.h index 336190e20..ce63fabdc 100644 --- a/qt/FilterBar.h +++ b/qt/FilterBar.h @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include "FaviconCache.h" @@ -22,7 +22,7 @@ class QLabel; class QLineEdit; class QStandardItemModel; -class QTimer; +class QString; class FilterBarComboBox; class Prefs; @@ -64,7 +64,7 @@ private: FilterBarComboBox* tracker_combo_ = {}; QLabel* count_label_ = {}; QStandardItemModel* tracker_model_ = {}; - QTimer* recount_timer_ = {}; + QTimer recount_timer_; QLineEdit* line_edit_ = {}; Pending pending_ = {}; bool is_bootstrapping_ = {}; diff --git a/qt/FreeSpaceLabel.cc b/qt/FreeSpaceLabel.cc index 9c402e31c..143575330 100644 --- a/qt/FreeSpaceLabel.cc +++ b/qt/FreeSpaceLabel.cc @@ -34,7 +34,7 @@ FreeSpaceLabel::FreeSpaceLabel(QWidget* parent) : timer_.setSingleShot(true); timer_.setInterval(IntervalMSec); - connect(&timer_, SIGNAL(timeout()), this, SLOT(onTimer())); + connect(&timer_, &QTimer::timeout, this, &FreeSpaceLabel::onTimer); } void FreeSpaceLabel::setSession(Session& session) diff --git a/qt/MainWindow.cc b/qt/MainWindow.cc index 532bfe9ae..df646d350 100644 --- a/qt/MainWindow.cc +++ b/qt/MainWindow.cc @@ -194,41 +194,41 @@ MainWindow::MainWindow(Session& session, Prefs& prefs, TorrentModel& model, bool pixmap_network_transmit_receive_ = make_network_pixmap(QStringLiteral("network-transmit-receive")); // ui signals - connect(ui_.action_Toolbar, SIGNAL(toggled(bool)), this, SLOT(setToolbarVisible(bool))); - connect(ui_.action_Filterbar, SIGNAL(toggled(bool)), this, SLOT(setFilterbarVisible(bool))); - connect(ui_.action_Statusbar, SIGNAL(toggled(bool)), this, SLOT(setStatusbarVisible(bool))); - connect(ui_.action_CompactView, SIGNAL(toggled(bool)), this, SLOT(setCompactView(bool))); - connect(ui_.action_ReverseSortOrder, SIGNAL(toggled(bool)), this, SLOT(setSortAscendingPref(bool))); - connect(ui_.action_Start, SIGNAL(triggered()), this, SLOT(startSelected())); - connect(ui_.action_QueueMoveTop, SIGNAL(triggered()), this, SLOT(queueMoveTop())); - connect(ui_.action_QueueMoveUp, SIGNAL(triggered()), this, SLOT(queueMoveUp())); - connect(ui_.action_QueueMoveDown, SIGNAL(triggered()), this, SLOT(queueMoveDown())); - connect(ui_.action_QueueMoveBottom, SIGNAL(triggered()), this, SLOT(queueMoveBottom())); - connect(ui_.action_StartNow, SIGNAL(triggered()), this, SLOT(startSelectedNow())); - connect(ui_.action_Pause, SIGNAL(triggered()), this, SLOT(pauseSelected())); - connect(ui_.action_Remove, SIGNAL(triggered()), this, SLOT(removeSelected())); - connect(ui_.action_Delete, SIGNAL(triggered()), this, SLOT(deleteSelected())); - connect(ui_.action_Verify, SIGNAL(triggered()), this, SLOT(verifySelected())); - connect(ui_.action_Announce, SIGNAL(triggered()), this, SLOT(reannounceSelected())); - connect(ui_.action_StartAll, SIGNAL(triggered()), this, SLOT(startAll())); - connect(ui_.action_PauseAll, SIGNAL(triggered()), this, SLOT(pauseAll())); - connect(ui_.action_OpenFile, SIGNAL(triggered()), this, SLOT(openTorrent())); - connect(ui_.action_AddURL, SIGNAL(triggered()), this, SLOT(openURL())); - connect(ui_.action_New, SIGNAL(triggered()), this, SLOT(newTorrent())); - connect(ui_.action_Preferences, SIGNAL(triggered()), this, SLOT(openPreferences())); - connect(ui_.action_Statistics, SIGNAL(triggered()), this, SLOT(openStats())); - connect(ui_.action_Donate, SIGNAL(triggered()), this, SLOT(openDonate())); - connect(ui_.action_About, SIGNAL(triggered()), this, SLOT(openAbout())); - connect(ui_.action_Contents, SIGNAL(triggered()), this, SLOT(openHelp())); - connect(ui_.action_OpenFolder, SIGNAL(triggered()), this, SLOT(openFolder())); - connect(ui_.action_CopyMagnetToClipboard, SIGNAL(triggered()), this, SLOT(copyMagnetLinkToClipboard())); - connect(ui_.action_SetLocation, SIGNAL(triggered()), this, SLOT(setLocation())); - connect(ui_.action_Properties, SIGNAL(triggered()), this, SLOT(openProperties())); - connect(ui_.action_SessionDialog, SIGNAL(triggered()), this, SLOT(openSession())); - connect(ui_.listView, SIGNAL(activated(QModelIndex)), ui_.action_Properties, SLOT(trigger())); - connect(ui_.action_SelectAll, SIGNAL(triggered()), ui_.listView, SLOT(selectAll())); - connect(ui_.action_DeselectAll, SIGNAL(triggered()), ui_.listView, SLOT(clearSelection())); - connect(ui_.action_Quit, SIGNAL(triggered()), qApp, SLOT(quit())); + connect(ui_.action_Toolbar, &QAction::toggled, this, &MainWindow::setToolbarVisible); + connect(ui_.action_Filterbar, &QAction::toggled, this, &MainWindow::setFilterbarVisible); + connect(ui_.action_Statusbar, &QAction::toggled, this, &MainWindow::setStatusbarVisible); + connect(ui_.action_CompactView, &QAction::toggled, this, &MainWindow::setCompactView); + connect(ui_.action_ReverseSortOrder, &QAction::toggled, this, &MainWindow::setSortAscendingPref); + connect(ui_.action_Start, &QAction::triggered, this, &MainWindow::startSelected); + connect(ui_.action_QueueMoveTop, &QAction::triggered, this, &MainWindow::queueMoveTop); + connect(ui_.action_QueueMoveUp, &QAction::triggered, this, &MainWindow::queueMoveUp); + connect(ui_.action_QueueMoveDown, &QAction::triggered, this, &MainWindow::queueMoveDown); + connect(ui_.action_QueueMoveBottom, &QAction::triggered, this, &MainWindow::queueMoveBottom); + connect(ui_.action_StartNow, &QAction::triggered, this, &MainWindow::startSelectedNow); + connect(ui_.action_Pause, &QAction::triggered, this, &MainWindow::pauseSelected); + connect(ui_.action_Remove, &QAction::triggered, this, &MainWindow::removeSelected); + connect(ui_.action_Delete, &QAction::triggered, this, &MainWindow::deleteSelected); + connect(ui_.action_Verify, &QAction::triggered, this, &MainWindow::verifySelected); + connect(ui_.action_Announce, &QAction::triggered, this, &MainWindow::reannounceSelected); + connect(ui_.action_StartAll, &QAction::triggered, this, &MainWindow::startAll); + connect(ui_.action_PauseAll, &QAction::triggered, this, &MainWindow::pauseAll); + connect(ui_.action_OpenFile, &QAction::triggered, this, &MainWindow::openTorrent); + connect(ui_.action_AddURL, &QAction::triggered, this, &MainWindow::openURL); + connect(ui_.action_New, &QAction::triggered, this, &MainWindow::newTorrent); + connect(ui_.action_Preferences, &QAction::triggered, this, &MainWindow::openPreferences); + connect(ui_.action_Statistics, &QAction::triggered, this, &MainWindow::openStats); + connect(ui_.action_Donate, &QAction::triggered, this, &MainWindow::openDonate); + connect(ui_.action_About, &QAction::triggered, this, &MainWindow::openAbout); + connect(ui_.action_Contents, &QAction::triggered, this, &MainWindow::openHelp); + connect(ui_.action_OpenFolder, &QAction::triggered, this, &MainWindow::openFolder); + connect(ui_.action_CopyMagnetToClipboard, &QAction::triggered, this, &MainWindow::copyMagnetLinkToClipboard); + connect(ui_.action_SetLocation, &QAction::triggered, this, &MainWindow::setLocation); + connect(ui_.action_Properties, &QAction::triggered, this, &MainWindow::openProperties); + connect(ui_.action_SessionDialog, &QAction::triggered, this, &MainWindow::openSession); + connect(ui_.listView, &QAbstractItemView::activated, ui_.action_Properties, &QAction::trigger); + connect(ui_.action_SelectAll, &QAction::triggered, ui_.listView, &QAbstractItemView::selectAll); + connect(ui_.action_DeselectAll, &QAction::triggered, ui_.listView, &QAbstractItemView::clearSelection); + connect(ui_.action_Quit, &QAction::triggered, qApp, &QCoreApplication::quit); auto refresh_action_sensitivity_soon = [this]() { refreshSoon(REFRESH_ACTION_SENSITIVITY); }; connect(&filter_model_, &TorrentFilter::rowsInserted, this, refresh_action_sensitivity_soon); @@ -268,13 +268,13 @@ MainWindow::MainWindow(Session& session, Prefs& prefs, TorrentModel& model, bool action_group->addAction(mode.first); } - connect(action_group, SIGNAL(triggered(QAction*)), this, SLOT(onSortModeChanged(QAction*))); + connect(action_group, &QActionGroup::triggered, this, &MainWindow::onSortModeChanged); // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks) alt_speed_action_ = new QAction(tr("Speed Limits"), this); alt_speed_action_->setIcon(ui_.altSpeedButton->icon()); alt_speed_action_->setCheckable(true); - connect(alt_speed_action_, SIGNAL(triggered()), this, SLOT(toggleSpeedMode())); + connect(alt_speed_action_, &QAction::triggered, this, &MainWindow::toggleSpeedMode); auto* menu = new QMenu(this); menu->addAction(ui_.action_OpenFile); @@ -292,23 +292,24 @@ MainWindow::MainWindow(Session& session, Prefs& prefs, TorrentModel& model, bool tray_icon_.setContextMenu(menu); tray_icon_.setIcon(QIcon::fromTheme(QStringLiteral("transmission-tray-icon"), qApp->windowIcon())); - connect(&prefs_, SIGNAL(changed(int)), this, SLOT(refreshPref(int))); - connect(ui_.action_ShowMainWindow, SIGNAL(triggered(bool)), this, SLOT(toggleWindows(bool))); - connect(&tray_icon_, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, - SLOT(trayActivated(QSystemTrayIcon::ActivationReason))); + connect(&prefs_, &Prefs::changed, this, &MainWindow::refreshPref); + connect(ui_.action_ShowMainWindow, &QAction::triggered, this, &MainWindow::toggleWindows); + connect(&tray_icon_, &QSystemTrayIcon::activated, this, &MainWindow::trayActivated); toggleWindows(!minimized); ui_.action_TrayIcon->setChecked(minimized || prefs.getBool(Prefs::SHOW_TRAY_ICON)); initStatusBar(); - ui_.verticalLayout->insertWidget(0, filter_bar_ = new FilterBar(prefs_, model_, filter_model_)); + auto* filter_bar = new FilterBar(prefs_, model_, filter_model_); + ui_.verticalLayout->insertWidget(0, filter_bar); + filter_bar_ = filter_bar; auto refresh_header_soon = [this]() { refreshSoon(REFRESH_TORRENT_VIEW_HEADER); }; connect(&model_, &TorrentModel::rowsInserted, this, refresh_header_soon); connect(&model_, &TorrentModel::rowsRemoved, this, refresh_header_soon); connect(&filter_model_, &TorrentFilter::rowsInserted, this, refresh_header_soon); connect(&filter_model_, &TorrentFilter::rowsRemoved, this, refresh_header_soon); - connect(ui_.listView, SIGNAL(headerDoubleClicked()), filter_bar_, SLOT(clear())); + connect(ui_.listView, &TorrentView::headerDoubleClicked, filter_bar, &FilterBar::clear); static std::array constexpr InitKeys = { @@ -335,13 +336,12 @@ MainWindow::MainWindow(Session& session, Prefs& prefs, TorrentModel& model, bool } auto refresh_status_soon = [this]() { refreshSoon(REFRESH_STATUS_BAR); }; - connect(&session_, SIGNAL(sourceChanged()), this, SLOT(onSessionSourceChanged())); + connect(&session_, &Session::sourceChanged, this, &MainWindow::onSessionSourceChanged); connect(&session_, &Session::statsUpdated, this, refresh_status_soon); - connect(&session_, SIGNAL(dataReadProgress()), this, SLOT(dataReadProgress())); - connect(&session_, SIGNAL(dataSendProgress()), this, SLOT(dataSendProgress())); - connect(&session_, SIGNAL(httpAuthenticationRequired()), this, SLOT(wrongAuthentication())); - connect(&session_, SIGNAL(networkResponse(QNetworkReply::NetworkError, QString)), this, - SLOT(onNetworkResponse(QNetworkReply::NetworkError, QString))); + connect(&session_, &Session::dataReadProgress, this, &MainWindow::dataReadProgress); + connect(&session_, &Session::dataSendProgress, this, &MainWindow::dataSendProgress); + connect(&session_, &Session::httpAuthenticationRequired, this, &MainWindow::wrongAuthentication); + connect(&session_, &Session::networkResponse, this, &MainWindow::onNetworkResponse); if (session_.isServer()) { @@ -396,7 +396,7 @@ void MainWindow::initStatusBar() ui_.statsModeButton->setMenu(createStatsModeMenu()); - connect(ui_.altSpeedButton, SIGNAL(clicked()), this, SLOT(toggleSpeedMode())); + connect(ui_.altSpeedButton, &QAbstractButton::clicked, this, &MainWindow::toggleSpeedMode); } QMenu* MainWindow::createOptionsMenu() @@ -411,24 +411,24 @@ QMenu* MainWindow::createOptionsMenu() off_action = menu->addAction(tr("Unlimited")); off_action->setCheckable(true); - off_action->setProperty(PREF_VARIANTS_KEY, QVariantList() << enabled_pref << false); + off_action->setProperty(PREF_VARIANTS_KEY, QVariantList{ enabled_pref, false }); action_group->addAction(off_action); - connect(off_action, SIGNAL(triggered(bool)), this, SLOT(onSetPrefs(bool))); + connect(off_action, &QAction::triggered, this, qOverload(&MainWindow::onSetPrefs)); on_action = menu->addAction(tr("Limited at %1").arg(Formatter::get().speedToString(Speed::fromKBps(current_value)))); on_action->setCheckable(true); - on_action->setProperty(PREF_VARIANTS_KEY, QVariantList() << pref << current_value << enabled_pref << true); + on_action->setProperty(PREF_VARIANTS_KEY, QVariantList{ pref, current_value, enabled_pref, true }); action_group->addAction(on_action); - connect(on_action, SIGNAL(triggered(bool)), this, SLOT(onSetPrefs(bool))); + connect(on_action, &QAction::triggered, this, qOverload(&MainWindow::onSetPrefs)); menu->addSeparator(); for (int const i : stock_speeds) { QAction* action = menu->addAction(Formatter::get().speedToString(Speed::fromKBps(i))); - action->setProperty(PREF_VARIANTS_KEY, QVariantList() << pref << i << enabled_pref << true); - connect(action, SIGNAL(triggered(bool)), this, SLOT(onSetPrefs())); + action->setProperty(PREF_VARIANTS_KEY, QVariantList{ pref, i, enabled_pref, true }); + connect(action, &QAction::triggered, this, qOverload<>(&MainWindow::onSetPrefs)); } }; @@ -442,23 +442,23 @@ QMenu* MainWindow::createOptionsMenu() off_action = menu->addAction(tr("Seed Forever")); off_action->setCheckable(true); - off_action->setProperty(PREF_VARIANTS_KEY, QVariantList() << enabled_pref << false); + off_action->setProperty(PREF_VARIANTS_KEY, QVariantList{ enabled_pref, false }); action_group->addAction(off_action); - connect(off_action, SIGNAL(triggered(bool)), this, SLOT(onSetPrefs(bool))); + connect(off_action, &QAction::triggered, this, qOverload(&MainWindow::onSetPrefs)); on_action = menu->addAction(tr("Stop at Ratio (%1)").arg(Formatter::get().ratioToString(current_value))); on_action->setCheckable(true); - on_action->setProperty(PREF_VARIANTS_KEY, QVariantList() << pref << current_value << enabled_pref << true); + on_action->setProperty(PREF_VARIANTS_KEY, QVariantList{ pref, current_value, enabled_pref, true }); action_group->addAction(on_action); - connect(on_action, SIGNAL(triggered(bool)), this, SLOT(onSetPrefs(bool))); + connect(on_action, &QAction::triggered, this, qOverload(&MainWindow::onSetPrefs)); menu->addSeparator(); for (double const i : stock_ratios) { QAction* action = menu->addAction(Formatter::get().ratioToString(i)); - action->setProperty(PREF_VARIANTS_KEY, QVariantList() << pref << i << enabled_pref << true); - connect(action, SIGNAL(triggered(bool)), this, SLOT(onSetPrefs())); + action->setProperty(PREF_VARIANTS_KEY, QVariantList{ pref, i, enabled_pref, true }); + connect(action, &QAction::triggered, this, qOverload<>(&MainWindow::onSetPrefs)); } }; @@ -497,7 +497,7 @@ QMenu* MainWindow::createStatsModeMenu() menu->addAction(mode.first); } - connect(action_group, SIGNAL(triggered(QAction*)), this, SLOT(onStatsModeChanged(QAction*))); + connect(action_group, &QActionGroup::triggered, this, &MainWindow::onStatsModeChanged); // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks) return menu; @@ -1276,7 +1276,7 @@ void MainWindow::openTorrent() l->addWidget(b, l->rowCount(), 0, 1, -1, Qt::AlignLeft); } - connect(d, SIGNAL(filesSelected(QStringList)), this, SLOT(addTorrents(QStringList))); + connect(d, &QFileDialog::filesSelected, this, &MainWindow::addTorrents); d->open(); } diff --git a/qt/MakeDialog.cc b/qt/MakeDialog.cc index 0f8f2614b..054deb286 100644 --- a/qt/MakeDialog.cc +++ b/qt/MakeDialog.cc @@ -55,9 +55,9 @@ MakeProgressDialog::MakeProgressDialog(Session& session, tr_metainfo_builder& bu { ui_.setupUi(this); - connect(ui_.dialogButtons, SIGNAL(clicked(QAbstractButton*)), this, SLOT(onButtonBoxClicked(QAbstractButton*))); + connect(ui_.dialogButtons, &QDialogButtonBox::clicked, this, &MakeProgressDialog::onButtonBoxClicked); - connect(&timer_, SIGNAL(timeout()), this, SLOT(onProgress())); + connect(&timer_, &QTimer::timeout, this, &MakeProgressDialog::onProgress); timer_.start(100); onProgress(); @@ -248,13 +248,13 @@ MakeDialog::MakeDialog(Session& session, QWidget* parent) : resize(minimumSizeHint()); - connect(ui_.sourceFolderRadio, SIGNAL(toggled(bool)), this, SLOT(onSourceChanged())); - connect(ui_.sourceFolderButton, SIGNAL(pathChanged(QString)), this, SLOT(onSourceChanged())); - connect(ui_.sourceFileRadio, SIGNAL(toggled(bool)), this, SLOT(onSourceChanged())); - connect(ui_.sourceFileButton, SIGNAL(pathChanged(QString)), this, SLOT(onSourceChanged())); + connect(ui_.sourceFolderRadio, &QAbstractButton::toggled, this, &MakeDialog::onSourceChanged); + connect(ui_.sourceFolderButton, &PathButton::pathChanged, this, &MakeDialog::onSourceChanged); + connect(ui_.sourceFileRadio, &QAbstractButton::toggled, this, &MakeDialog::onSourceChanged); + connect(ui_.sourceFileButton, &PathButton::pathChanged, this, &MakeDialog::onSourceChanged); - connect(ui_.dialogButtons, SIGNAL(accepted()), this, SLOT(makeTorrent())); - connect(ui_.dialogButtons, SIGNAL(rejected()), this, SLOT(close())); + connect(ui_.dialogButtons, &QDialogButtonBox::accepted, this, &MakeDialog::makeTorrent); + connect(ui_.dialogButtons, &QDialogButtonBox::rejected, this, &MakeDialog::close); onSourceChanged(); } diff --git a/qt/OptionsDialog.cc b/qt/OptionsDialog.cc index 60c1c3f4e..e0125ebcc 100644 --- a/qt/OptionsDialog.cc +++ b/qt/OptionsDialog.cc @@ -34,7 +34,6 @@ OptionsDialog::OptionsDialog(Session& session, Prefs const& prefs, AddData addme add_(std::move(addme)), verify_hash_(QCryptographicHash::Sha1), verify_button_(new QPushButton(tr("&Verify Local Data"), this)), - edit_timer_(this), session_(session), is_local_(session_.isLocal()) { @@ -55,7 +54,7 @@ OptionsDialog::OptionsDialog(Session& session, Prefs const& prefs, AddData addme edit_timer_.setInterval(2000); edit_timer_.setSingleShot(true); - connect(&edit_timer_, SIGNAL(timeout()), this, SLOT(onDestinationChanged())); + connect(&edit_timer_, &QTimer::timeout, this, &OptionsDialog::onDestinationChanged); if (add_.type == AddData::FILENAME) { @@ -64,14 +63,14 @@ OptionsDialog::OptionsDialog(Session& session, Prefs const& prefs, AddData addme ui_.sourceButton->setTitle(tr("Open Torrent")); ui_.sourceButton->setNameFilter(tr("Torrent Files (*.torrent);;All Files (*.*)")); ui_.sourceButton->setPath(add_.filename); - connect(ui_.sourceButton, SIGNAL(pathChanged(QString)), this, SLOT(onSourceChanged())); + connect(ui_.sourceButton, &PathButton::pathChanged, this, &OptionsDialog::onSourceChanged); } else { ui_.sourceStack->setCurrentWidget(ui_.sourceEdit); ui_.sourceEdit->setText(add_.readableName()); ui_.sourceEdit->selectAll(); - connect(ui_.sourceEdit, SIGNAL(editingFinished()), this, SLOT(onSourceChanged())); + connect(ui_.sourceEdit, &QLineEdit::editingFinished, this, &OptionsDialog::onSourceChanged); } ui_.sourceStack->setFixedHeight(ui_.sourceStack->currentWidget()->sizeHint().height()); @@ -95,9 +94,9 @@ OptionsDialog::OptionsDialog(Session& session, Prefs const& prefs, AddData addme local_destination_.setPath(download_dir); } - connect(ui_.destinationButton, SIGNAL(pathChanged(QString)), this, SLOT(onDestinationChanged())); - connect(ui_.destinationEdit, SIGNAL(textEdited(QString)), &edit_timer_, SLOT(start())); - connect(ui_.destinationEdit, SIGNAL(editingFinished()), this, SLOT(onDestinationChanged())); + connect(ui_.destinationButton, &PathButton::pathChanged, this, &OptionsDialog::onDestinationChanged); + connect(ui_.destinationEdit, &QLineEdit::textEdited, &edit_timer_, qOverload<>(&QTimer::start)); + connect(ui_.destinationEdit, &QLineEdit::editingFinished, this, &OptionsDialog::onDestinationChanged); ui_.filesView->setEditable(false); @@ -107,20 +106,20 @@ OptionsDialog::OptionsDialog(Session& session, Prefs const& prefs, AddData addme ui_.priorityCombo->setCurrentIndex(1); // Normal ui_.dialogButtons->addButton(verify_button_, QDialogButtonBox::ActionRole); - connect(verify_button_, SIGNAL(clicked(bool)), this, SLOT(onVerify())); + connect(verify_button_, &QAbstractButton::clicked, this, &OptionsDialog::onVerify); ui_.startCheck->setChecked(prefs.getBool(Prefs::START)); ui_.trashCheck->setChecked(prefs.getBool(Prefs::TRASH_ORIGINAL)); - connect(ui_.dialogButtons, SIGNAL(rejected()), this, SLOT(deleteLater())); - connect(ui_.dialogButtons, SIGNAL(accepted()), this, SLOT(onAccepted())); + connect(ui_.dialogButtons, &QDialogButtonBox::rejected, this, &QObject::deleteLater); + connect(ui_.dialogButtons, &QDialogButtonBox::accepted, this, &OptionsDialog::onAccepted); - connect(ui_.filesView, SIGNAL(priorityChanged(QSet, int)), this, SLOT(onPriorityChanged(QSet, int))); - connect(ui_.filesView, SIGNAL(wantedChanged(QSet, bool)), this, SLOT(onWantedChanged(QSet, bool))); + connect(ui_.filesView, &FileTreeView::priorityChanged, this, &OptionsDialog::onPriorityChanged); + connect(ui_.filesView, &FileTreeView::wantedChanged, this, &OptionsDialog::onWantedChanged); - connect(&verify_timer_, SIGNAL(timeout()), this, SLOT(onTimeout())); + connect(&verify_timer_, &QTimer::timeout, this, &OptionsDialog::onTimeout); - connect(&session_, SIGNAL(sessionUpdated()), SLOT(onSessionUpdated())); + connect(&session_, &Session::sessionUpdated, this, &OptionsDialog::onSessionUpdated); updateWidgetsLocality(); reload(); diff --git a/qt/PathButton.cc b/qt/PathButton.cc index 65f48ee04..6ad4d86a2 100644 --- a/qt/PathButton.cc +++ b/qt/PathButton.cc @@ -28,7 +28,7 @@ PathButton::PathButton(QWidget* parent) : updateAppearance(); - connect(this, SIGNAL(clicked()), this, SLOT(onClicked())); + connect(this, &QAbstractButton::clicked, this, &PathButton::onClicked); } void PathButton::setMode(Mode mode) @@ -131,7 +131,7 @@ void PathButton::onClicked() } } - connect(dialog, SIGNAL(fileSelected(QString)), this, SLOT(onFileSelected(QString))); + connect(dialog, &QFileDialog::fileSelected, this, &PathButton::onFileSelected); dialog->setAttribute(Qt::WA_DeleteOnClose); dialog->open(); diff --git a/qt/PrefsDialog.cc b/qt/PrefsDialog.cc index a703db1dc..ea7e9b082 100644 --- a/qt/PrefsDialog.cc +++ b/qt/PrefsDialog.cc @@ -209,25 +209,38 @@ void PrefsDialog::linkWidgetToPref(QWidget* widget, int pref_key) updateWidgetValue(widget, pref_key); widgets_.insert(pref_key, widget); - if (pref_widget.is()) + auto* check_box = qobject_cast(widget); + if (check_box != nullptr) { - connect(widget, SIGNAL(toggled(bool)), SLOT(checkBoxToggled(bool))); + connect(check_box, &QAbstractButton::toggled, this, &PrefsDialog::checkBoxToggled); + return; } - else if (pref_widget.is()) + + auto* time_edit = qobject_cast(widget); + if (time_edit != nullptr) { - connect(widget, SIGNAL(editingFinished()), SLOT(timeEditingFinished())); + connect(time_edit, &QAbstractSpinBox::editingFinished, this, &PrefsDialog::timeEditingFinished); + return; } - else if (pref_widget.is()) + + auto* line_edit = qobject_cast(widget); + if (line_edit != nullptr) { - connect(widget, SIGNAL(editingFinished()), SLOT(lineEditingFinished())); + connect(line_edit, &QLineEdit::editingFinished, this, &PrefsDialog::lineEditingFinished); + return; } - else if (pref_widget.is()) + + auto* path_button = qobject_cast(widget); + if (path_button != nullptr) { - connect(widget, SIGNAL(pathChanged(QString)), SLOT(pathChanged(QString))); + connect(path_button, &PathButton::pathChanged, this, &PrefsDialog::pathChanged); + return; } - else if (pref_widget.is()) + + auto* spin_box = qobject_cast(widget); + if (spin_box != nullptr) { - connect(widget, SIGNAL(editingFinished()), SLOT(spinBoxEditingFinished())); + connect(spin_box, &QAbstractSpinBox::editingFinished, this, &PrefsDialog::spinBoxEditingFinished); } } @@ -309,7 +322,7 @@ void PrefsDialog::initRemoteTab() web_whitelist_widgets_ << ui_.rpcWhitelistLabel << ui_.rpcWhitelistEdit; unsupported_when_remote_ << ui_.enableRpcCheck << web_widgets_ << web_auth_widgets_ << web_whitelist_widgets_; - connect(ui_.openWebClientButton, SIGNAL(clicked()), &session_, SLOT(launchWebInterface())); + connect(ui_.openWebClientButton, &QAbstractButton::clicked, &session_, &Session::launchWebInterface); } /*** @@ -369,7 +382,7 @@ void PrefsDialog::initSpeedTab() cr->addLayout(ui_.altSpeedLimitsSectionLayout); cr->update(); - connect(ui_.altSpeedLimitDaysCombo, SIGNAL(activated(int)), SLOT(altSpeedDaysEdited(int))); + connect(ui_.altSpeedLimitDaysCombo, qOverload(&QComboBox::activated), this, &PrefsDialog::altSpeedDaysEdited); } /*** @@ -424,8 +437,8 @@ void PrefsDialog::initNetworkTab() cr->addLayout(ui_.peerLimitsSectionLayout); cr->update(); - connect(ui_.testPeerPortButton, SIGNAL(clicked()), SLOT(onPortTest())); - connect(&session_, SIGNAL(portTested(bool)), SLOT(onPortTested(bool))); + connect(ui_.testPeerPortButton, &QAbstractButton::clicked, this, &PrefsDialog::onPortTest); + connect(&session_, &Session::portTested, this, &PrefsDialog::onPortTested); } /*** @@ -441,7 +454,7 @@ void PrefsDialog::onBlocklistDialogDestroyed(QObject* o) void PrefsDialog::onUpdateBlocklistCancelled() { - disconnect(&session_, SIGNAL(blocklistUpdated(int)), this, SLOT(onBlocklistUpdated(int))); + disconnect(&session_, &Session::blocklistUpdated, this, &PrefsDialog::onBlocklistUpdated); blocklist_dialog_->deleteLater(); } @@ -455,8 +468,8 @@ void PrefsDialog::onUpdateBlocklistClicked() { blocklist_dialog_ = new QMessageBox(QMessageBox::Information, QString(), tr("Update Blocklist

Getting new blocklist..."), QMessageBox::Close, this); - connect(blocklist_dialog_, SIGNAL(rejected()), this, SLOT(onUpdateBlocklistCancelled())); - connect(&session_, SIGNAL(blocklistUpdated(int)), this, SLOT(onBlocklistUpdated(int))); + connect(blocklist_dialog_, &QDialog::rejected, this, &PrefsDialog::onUpdateBlocklistCancelled); + connect(&session_, &Session::blocklistUpdated, this, &PrefsDialog::onBlocklistUpdated); blocklist_dialog_->show(); session_.updateBlocklist(); } @@ -486,8 +499,8 @@ void PrefsDialog::initPrivacyTab() cr->addLayout(ui_.blocklistSectionLayout); cr->update(); - connect(ui_.encryptionModeCombo, SIGNAL(activated(int)), SLOT(encryptionEdited(int))); - connect(ui_.updateBlocklistButton, SIGNAL(clicked()), SLOT(onUpdateBlocklistClicked())); + connect(ui_.updateBlocklistButton, &QAbstractButton::clicked, this, &PrefsDialog::onUpdateBlocklistClicked); + connect(ui_.encryptionModeCombo, qOverload(&QComboBox::activated), this, &PrefsDialog::encryptionEdited); updateBlocklistLabel(); } @@ -514,7 +527,7 @@ void PrefsDialog::initSeedingTab() linkWidgetToPref(ui_.idleLimitCheck, Prefs::IDLE_LIMIT_ENABLED); linkWidgetToPref(ui_.idleLimitSpin, Prefs::IDLE_LIMIT); - connect(ui_.idleLimitSpin, SIGNAL(valueChanged(int)), SLOT(onIdleLimitChanged())); + connect(ui_.idleLimitSpin, qOverload(&QSpinBox::valueChanged), this, &PrefsDialog::onIdleLimitChanged); onIdleLimitChanged(); } @@ -572,7 +585,8 @@ void PrefsDialog::initDownloadingTab() cr->addLayout(ui_.incompleteSectionLayout); cr->update(); - connect(ui_.queueStalledMinutesSpin, SIGNAL(valueChanged(int)), SLOT(onQueueStalledMinutesChanged())); + connect(ui_.queueStalledMinutesSpin, qOverload( + &QSpinBox::valueChanged), this, &PrefsDialog::onQueueStalledMinutesChanged); updateDownloadingWidgetsLocality(); onQueueStalledMinutesChanged(); @@ -615,7 +629,7 @@ PrefsDialog::PrefsDialog(Session& session, Prefs& prefs, QWidget* parent) : initDesktopTab(); initRemoteTab(); - connect(&session_, SIGNAL(sessionUpdated()), SLOT(sessionUpdated())); + connect(&session_, &Session::sessionUpdated, this, &PrefsDialog::sessionUpdated); static std::array constexpr InitKeys = { diff --git a/qt/RelocateDialog.cc b/qt/RelocateDialog.cc index d13327c6b..364d55a4b 100644 --- a/qt/RelocateDialog.cc +++ b/qt/RelocateDialog.cc @@ -85,9 +85,9 @@ RelocateDialog::RelocateDialog(Session& session, TorrentModel const& model, torr ui_.findDataRadio->setChecked(true); } - connect(ui_.moveDataRadio, SIGNAL(toggled(bool)), this, SLOT(onMoveToggled(bool))); - connect(ui_.dialogButtons, SIGNAL(rejected()), this, SLOT(close())); - connect(ui_.dialogButtons, SIGNAL(accepted()), this, SLOT(onSetLocation())); + connect(ui_.moveDataRadio, &QAbstractButton::toggled, this, &RelocateDialog::onMoveToggled); + connect(ui_.dialogButtons, &QDialogButtonBox::rejected, this, &RelocateDialog::close); + connect(ui_.dialogButtons, &QDialogButtonBox::accepted, this, &RelocateDialog::onSetLocation); } QString RelocateDialog::newLocation() const diff --git a/qt/RpcClient.cc b/qt/RpcClient.cc index 293d18110..8e806576d 100644 --- a/qt/RpcClient.cc +++ b/qt/RpcClient.cc @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -152,8 +153,8 @@ void RpcClient::sendNetworkRequest(TrVariantPtr json, QFutureInterfacesetProperty(RequestDataPropertyKey, QVariant::fromValue(json)); reply->setProperty(RequestFutureinterfacePropertyKey, QVariant::fromValue(promise)); - connect(reply, SIGNAL(downloadProgress(qint64, qint64)), this, SIGNAL(dataReadProgress())); - connect(reply, SIGNAL(uploadProgress(qint64, qint64)), this, SIGNAL(dataSendProgress())); + connect(reply, &QNetworkReply::downloadProgress, this, &RpcClient::dataReadProgress); + connect(reply, &QNetworkReply::uploadProgress, this, &RpcClient::dataSendProgress); if (Verbose) { @@ -203,10 +204,9 @@ QNetworkAccessManager* RpcClient::networkAccessManager() { nam_ = new QNetworkAccessManager(); - connect(nam_, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkRequestFinished(QNetworkReply*))); + connect(nam_, &QNetworkAccessManager::finished, this, &RpcClient::networkRequestFinished); - connect(nam_, SIGNAL(authenticationRequired(QNetworkReply*, QAuthenticator*)), this, - SIGNAL(httpAuthenticationRequired())); + connect(nam_, &QNetworkAccessManager::authenticationRequired, this, &RpcClient::httpAuthenticationRequired); } return nam_; diff --git a/qt/RpcQueue.cc b/qt/RpcQueue.cc index 619a80e93..19a398e30 100644 --- a/qt/RpcQueue.cc +++ b/qt/RpcQueue.cc @@ -17,7 +17,7 @@ RpcQueue::RpcQueue(QObject* parent) : QObject(parent), tag_(next_tag++) { - connect(&future_watcher_, SIGNAL(finished()), SLOT(stepFinished())); + connect(&future_watcher_, &QFutureWatcher::finished, this, &RpcQueue::stepFinished); } void RpcQueue::stepFinished() diff --git a/qt/Session.cc b/qt/Session.cc index 327b60dd3..a40e13efa 100644 --- a/qt/Session.cc +++ b/qt/Session.cc @@ -301,12 +301,11 @@ Session::Session(QString config_dir, Prefs& prefs) : stats_.ratio = TR_RATIO_NA; cumulative_stats_ = stats_; - connect(&prefs_, SIGNAL(changed(int)), this, SLOT(updatePref(int))); - connect(&rpc_, SIGNAL(httpAuthenticationRequired()), this, SIGNAL(httpAuthenticationRequired())); - connect(&rpc_, SIGNAL(dataReadProgress()), this, SIGNAL(dataReadProgress())); - connect(&rpc_, SIGNAL(dataSendProgress()), this, SIGNAL(dataSendProgress())); - connect(&rpc_, SIGNAL(networkResponse(QNetworkReply::NetworkError, QString)), this, - SIGNAL(networkResponse(QNetworkReply::NetworkError, QString))); + connect(&prefs_, &Prefs::changed, this, &Session::updatePref); + connect(&rpc_, &RpcClient::httpAuthenticationRequired, this, &Session::httpAuthenticationRequired); + connect(&rpc_, &RpcClient::dataReadProgress, this, &Session::dataReadProgress); + connect(&rpc_, &RpcClient::dataSendProgress, this, &Session::dataSendProgress); + connect(&rpc_, &RpcClient::networkResponse, this, &Session::networkResponse); duplicates_timer_.setSingleShot(true); connect(&duplicates_timer_, &QTimer::timeout, this, &Session::onDuplicatesTimer); @@ -905,7 +904,7 @@ void Session::updateStats(tr_variant* d) void Session::updateInfo(tr_variant* d) { - disconnect(&prefs_, SIGNAL(changed(int)), this, SLOT(updatePref(int))); + disconnect(&prefs_, &Prefs::changed, this, &Session::updatePref); for (int i = Prefs::FIRST_CORE_PREF; i <= Prefs::LAST_CORE_PREF; ++i) { @@ -1044,7 +1043,7 @@ void Session::updateInfo(tr_variant* d) } // std::cerr << "Session::updateInfo end" << std::endl; - connect(&prefs_, SIGNAL(changed(int)), this, SLOT(updatePref(int))); + connect(&prefs_, &Prefs::changed, this, &Session::updatePref); emit sessionUpdated(); } diff --git a/qt/SessionDialog.cc b/qt/SessionDialog.cc index 27984b5df..befb9447b 100644 --- a/qt/SessionDialog.cc +++ b/qt/SessionDialog.cc @@ -54,10 +54,10 @@ SessionDialog::SessionDialog(Session& session, Prefs& prefs, QWidget* parent) : ui_.setupUi(this); ui_.localSessionRadio->setChecked(!prefs.get(Prefs::SESSION_IS_REMOTE)); - connect(ui_.localSessionRadio, SIGNAL(toggled(bool)), this, SLOT(resensitize())); + connect(ui_.localSessionRadio, &QAbstractButton::toggle, this, &SessionDialog::resensitize); ui_.remoteSessionRadio->setChecked(prefs.get(Prefs::SESSION_IS_REMOTE)); - connect(ui_.remoteSessionRadio, SIGNAL(toggled(bool)), this, SLOT(resensitize())); + connect(ui_.remoteSessionRadio, &QAbstractButton::toggle, this, &SessionDialog::resensitize); ui_.hostEdit->setText(prefs.get(Prefs::SESSION_REMOTE_HOST)); remote_widgets_ << ui_.hostLabel << ui_.hostEdit; @@ -66,7 +66,7 @@ SessionDialog::SessionDialog(Session& session, Prefs& prefs, QWidget* parent) : remote_widgets_ << ui_.portLabel << ui_.portSpin; ui_.authCheck->setChecked(prefs.get(Prefs::SESSION_REMOTE_AUTH)); - connect(ui_.authCheck, SIGNAL(toggled(bool)), this, SLOT(resensitize())); + connect(ui_.authCheck, &QAbstractButton::toggled, this, &SessionDialog::resensitize); remote_widgets_ << ui_.authCheck; ui_.usernameEdit->setText(prefs.get(Prefs::SESSION_REMOTE_USERNAME)); diff --git a/qt/StatsDialog.cc b/qt/StatsDialog.cc index 84bf1a4fb..cde28276d 100644 --- a/qt/StatsDialog.cc +++ b/qt/StatsDialog.cc @@ -20,8 +20,7 @@ enum StatsDialog::StatsDialog(Session& session, QWidget* parent) : BaseDialog(parent), - session_(session), - timer_(new QTimer(this)) + session_(session) { ui_.setupUi(this); @@ -30,21 +29,20 @@ StatsDialog::StatsDialog(Session& session, QWidget* parent) : cr->addLayout(ui_.totalSectionLayout); cr->update(); - timer_->setSingleShot(false); - connect(timer_, SIGNAL(timeout()), &session_, SLOT(refreshSessionStats())); - - connect(&session_, SIGNAL(statsUpdated()), this, SLOT(updateStats())); + timer_.setSingleShot(false); + connect(&timer_, &QTimer::timeout, &session_, &Session::refreshSessionStats); + connect(&session_, &Session::statsUpdated, this, &StatsDialog::updateStats); updateStats(); session_.refreshSessionStats(); } void StatsDialog::setVisible(bool visible) { - timer_->stop(); + timer_.stop(); if (visible) { - timer_->start(REFRESH_INTERVAL_MSEC); + timer_.start(REFRESH_INTERVAL_MSEC); } BaseDialog::setVisible(visible); diff --git a/qt/StatsDialog.h b/qt/StatsDialog.h index 4e1487522..0197dfb7b 100644 --- a/qt/StatsDialog.h +++ b/qt/StatsDialog.h @@ -12,7 +12,7 @@ #include "Macros.h" #include "ui_StatsDialog.h" -class QTimer; +#include class Session; @@ -22,7 +22,7 @@ class StatsDialog : public BaseDialog TR_DISABLE_COPY_MOVE(StatsDialog) public: - StatsDialog(Session&, QWidget* parent = nullptr); + explicit StatsDialog(Session&, QWidget* parent = nullptr); // QWidget void setVisible(bool visible) override; @@ -35,5 +35,5 @@ private: Ui::StatsDialog ui_ = {}; - QTimer* timer_ = {}; + QTimer timer_; }; diff --git a/qt/WatchDir.cc b/qt/WatchDir.cc index a16202c83..0f1fa0b62 100644 --- a/qt/WatchDir.cc +++ b/qt/WatchDir.cc @@ -87,7 +87,7 @@ void WatchDir::setPath(QString const& path, bool is_enabled) if (is_enabled) { watcher_ = std::make_unique(QStringList{ path }); - connect(watcher_.get(), SIGNAL(directoryChanged(QString)), this, SLOT(watcherActivated(QString))); + connect(watcher_.get(), &QFileSystemWatcher::directoryChanged, this, &WatchDir::watcherActivated); QTimer::singleShot(0, this, SLOT(rescanAllWatchedDirectories())); // trigger the watchdir for .torrent files in there already } } @@ -105,7 +105,7 @@ void WatchDir::watcherActivated(QString const& path) } // try to add any new files which end in .torrent - QSet const new_files(files - watch_dir_files_); + auto const new_files = files - watch_dir_files_; auto const torrent_suffix = QStringLiteral(".torrent"); for (QString const& name : new_files) @@ -129,7 +129,7 @@ void WatchDir::watcherActivated(QString const& path) auto* t = new QTimer(this); t->setObjectName(dir.absoluteFilePath(name)); t->setSingleShot(true); - connect(t, SIGNAL(timeout()), this, SLOT(onTimeout())); + connect(t, &QTimer::timeout, this, &WatchDir::onTimeout); t->start(5000); } }