From b17307f283abd75cfcda4cb7260c189cd6c02aec Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Wed, 12 Jul 2023 05:08:36 +0800 Subject: [PATCH 1/2] Move signal/slot connections out of .ui files This unify the place (.cpp file) where we handle signal/slot connections. --- src/gui/addnewtorrentdialog.cpp | 6 + src/gui/addnewtorrentdialog.ui | 124 ++++------------ src/gui/autoexpandabledialog.cpp | 3 + src/gui/autoexpandabledialog.ui | 35 +---- src/gui/banlistoptionsdialog.cpp | 2 + src/gui/banlistoptionsdialog.ui | 19 +-- src/gui/cookiesdialog.cpp | 9 +- src/gui/cookiesdialog.ui | 71 +--------- src/gui/deletionconfirmationdialog.cpp | 3 + src/gui/deletionconfirmationdialog.ui | 35 +---- src/gui/ipsubnetwhitelistoptionsdialog.cpp | 2 + src/gui/ipsubnetwhitelistoptionsdialog.ui | 21 +-- src/gui/optionsdialog.cpp | 14 +- src/gui/optionsdialog.ui | 133 +----------------- src/gui/properties/peersadditiondialog.cpp | 2 + src/gui/properties/peersadditiondialog.ui | 19 +-- src/gui/properties/trackersadditiondialog.cpp | 5 +- src/gui/properties/trackersadditiondialog.ui | 35 +---- src/gui/rss/automatedrssdownloader.cpp | 4 + src/gui/rss/automatedrssdownloader.ui | 35 +---- src/gui/shutdownconfirmdialog.cpp | 3 + src/gui/shutdownconfirmdialog.ui | 35 +---- src/gui/speedlimitdialog.cpp | 3 + src/gui/speedlimitdialog.ui | 35 +---- src/gui/torrentcategorydialog.cpp | 2 + src/gui/torrentcategorydialog.ui | 35 +---- src/gui/torrentcreatordialog.cpp | 2 + src/gui/torrentcreatordialog.ui | 35 +---- src/gui/torrentoptionsdialog.cpp | 7 +- src/gui/torrentoptionsdialog.ui | 35 +---- src/gui/torrenttagsdialog.cpp | 3 + src/gui/torrenttagsdialog.ui | 35 +---- src/gui/uithemedialog.cpp | 3 + src/gui/uithemedialog.ui | 35 +---- src/gui/watchedfolderoptionsdialog.cpp | 3 + src/gui/watchedfolderoptionsdialog.ui | 35 +---- 36 files changed, 115 insertions(+), 768 deletions(-) diff --git a/src/gui/addnewtorrentdialog.cpp b/src/gui/addnewtorrentdialog.cpp index f811c855b..cf0ee4aaa 100644 --- a/src/gui/addnewtorrentdialog.cpp +++ b/src/gui/addnewtorrentdialog.cpp @@ -300,6 +300,9 @@ AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::AddTorrentParams &inP // TODO: set dialog file properties using m_torrentParams.filePriorities m_ui->setupUi(this); + connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(m_ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); + m_ui->lblMetaLoading->setVisible(false); m_ui->progMetaLoading->setVisible(false); m_ui->buttonSave->setVisible(false); @@ -339,6 +342,7 @@ AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::AddTorrentParams &inP m_ui->comboTTM->blockSignals(true); // the TreeView size isn't correct if the slot does its job at this point m_ui->comboTTM->setCurrentIndex(session->isAutoTMMDisabledByDefault() ? 0 : 1); m_ui->comboTTM->blockSignals(false); + connect(m_ui->comboTTM, &QComboBox::currentIndexChanged, this, &AddNewTorrentDialog::TMMChanged); connect(m_ui->savePath, &FileSystemPathEdit::selectedPathChanged, this, &AddNewTorrentDialog::onSavePathChanged); connect(m_ui->downloadPath, &FileSystemPathEdit::selectedPathChanged, this, &AddNewTorrentDialog::onDownloadPathChanged); @@ -373,6 +377,8 @@ AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::AddTorrentParams &inP m_ui->categoryComboBox->addItem(category); } + connect(m_ui->categoryComboBox, &QComboBox::currentIndexChanged, this, &AddNewTorrentDialog::categoryChanged); + m_ui->tagsLineEdit->setText(m_torrentParams.tags.join(u", "_s)); connect(m_ui->tagsEditButton, &QAbstractButton::clicked, this, [this] { diff --git a/src/gui/addnewtorrentdialog.ui b/src/gui/addnewtorrentdialog.ui index b2d05cd8c..0c9a96e1f 100644 --- a/src/gui/addnewtorrentdialog.ui +++ b/src/gui/addnewtorrentdialog.ui @@ -243,7 +243,7 @@ - + Start torrent @@ -252,35 +252,35 @@ - - - - Stop condition: - - - - - - - 0 - - - None - - - - - Metadata received - + + + Stop condition: + + - - Files checked - + + + 0 + + + + None + + + + + Metadata received + + + + + Files checked + + + - - @@ -664,75 +664,5 @@ - - - buttonBox - accepted() - AddNewTorrentDialog - accept() - - - 928 - 855 - - - 157 - 274 - - - - - buttonBox - rejected() - AddNewTorrentDialog - reject() - - - 928 - 855 - - - 286 - 274 - - - - - comboTTM - currentIndexChanged(int) - AddNewTorrentDialog - TMMChanged(int) - - - 250 - 53 - - - 467 - 249 - - - - - categoryComboBox - currentIndexChanged(int) - AddNewTorrentDialog - categoryChanged(int) - - - 266 - 231 - - - 467 - 249 - - - - - - savingModeChanged(bool) - categoryChanged(int) - TMMChanged(int) - + diff --git a/src/gui/autoexpandabledialog.cpp b/src/gui/autoexpandabledialog.cpp index 3978eb96b..1d98f9d85 100644 --- a/src/gui/autoexpandabledialog.cpp +++ b/src/gui/autoexpandabledialog.cpp @@ -37,6 +37,9 @@ AutoExpandableDialog::AutoExpandableDialog(QWidget *parent) , m_ui(new Ui::AutoExpandableDialog) { m_ui->setupUi(this); + + connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(m_ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); } AutoExpandableDialog::~AutoExpandableDialog() diff --git a/src/gui/autoexpandabledialog.ui b/src/gui/autoexpandabledialog.ui index 43d7daa09..a934bcfa9 100644 --- a/src/gui/autoexpandabledialog.ui +++ b/src/gui/autoexpandabledialog.ui @@ -27,38 +27,5 @@ - - - buttonBox - accepted() - AutoExpandableDialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - AutoExpandableDialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - + diff --git a/src/gui/banlistoptionsdialog.cpp b/src/gui/banlistoptionsdialog.cpp index 12297cf2b..23daee3cf 100644 --- a/src/gui/banlistoptionsdialog.cpp +++ b/src/gui/banlistoptionsdialog.cpp @@ -48,6 +48,8 @@ BanListOptionsDialog::BanListOptionsDialog(QWidget *parent) { m_ui->setupUi(this); + connect(m_ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); + m_sortFilter = new QSortFilterProxyModel(this); m_sortFilter->setDynamicSortFilter(true); m_sortFilter->setSourceModel(m_model); diff --git a/src/gui/banlistoptionsdialog.ui b/src/gui/banlistoptionsdialog.ui index e218b2141..a96b6e34d 100644 --- a/src/gui/banlistoptionsdialog.ui +++ b/src/gui/banlistoptionsdialog.ui @@ -109,22 +109,5 @@ buttonDeleteIP - - - buttonBox - rejected() - BanListOptionsDialog - reject() - - - 179 - 427 - - - 179 - 224 - - - - + diff --git a/src/gui/cookiesdialog.cpp b/src/gui/cookiesdialog.cpp index 3478034e9..db9a91b8d 100644 --- a/src/gui/cookiesdialog.cpp +++ b/src/gui/cookiesdialog.cpp @@ -52,11 +52,18 @@ CookiesDialog::CookiesDialog(QWidget *parent) { m_ui->setupUi(this); + connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(m_ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); + setWindowIcon(UIThemeManager::instance()->getIcon(u"browser-cookies"_s)); + m_ui->buttonAdd->setIcon(UIThemeManager::instance()->getIcon(u"list-add"_s)); - m_ui->buttonDelete->setIcon(UIThemeManager::instance()->getIcon(u"list-remove"_s)); m_ui->buttonAdd->setIconSize(Utils::Gui::mediumIconSize()); + connect(m_ui->buttonAdd, &QToolButton::clicked, this, &CookiesDialog::onButtonAddClicked); + + m_ui->buttonDelete->setIcon(UIThemeManager::instance()->getIcon(u"list-remove"_s)); m_ui->buttonDelete->setIconSize(Utils::Gui::mediumIconSize()); + connect(m_ui->buttonDelete, &QToolButton::clicked, this, &CookiesDialog::onButtonDeleteClicked); m_ui->treeView->setModel(m_cookiesModel); if (m_cookiesModel->rowCount() > 0) diff --git a/src/gui/cookiesdialog.ui b/src/gui/cookiesdialog.ui index 202ee3dd9..536f4e2ac 100644 --- a/src/gui/cookiesdialog.ui +++ b/src/gui/cookiesdialog.ui @@ -96,74 +96,5 @@ - - - buttonBox - accepted() - CookiesDialog - accept() - - - 257 - 406 - - - 157 - 274 - - - - - buttonBox - rejected() - CookiesDialog - reject() - - - 325 - 406 - - - 286 - 274 - - - - - buttonAdd - clicked() - CookiesDialog - onButtonAddClicked() - - - 484 - 174 - - - 486 - 93 - - - - - buttonDelete - clicked() - CookiesDialog - onButtonDeleteClicked() - - - 483 - 226 - - - 485 - 296 - - - - - - onButtonAddClicked() - onButtonDeleteClicked() - + diff --git a/src/gui/deletionconfirmationdialog.cpp b/src/gui/deletionconfirmationdialog.cpp index 27511dba8..e667a4ad3 100644 --- a/src/gui/deletionconfirmationdialog.cpp +++ b/src/gui/deletionconfirmationdialog.cpp @@ -57,6 +57,9 @@ DeletionConfirmationDialog::DeletionConfirmationDialog(QWidget *parent, const in connect(m_ui->checkPermDelete, &QCheckBox::clicked, this, &DeletionConfirmationDialog::updateRememberButtonState); m_ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Remove")); m_ui->buttonBox->button(QDialogButtonBox::Cancel)->setFocus(); + + connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(m_ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); } DeletionConfirmationDialog::~DeletionConfirmationDialog() diff --git a/src/gui/deletionconfirmationdialog.ui b/src/gui/deletionconfirmationdialog.ui index 1a813b8b3..9912e2b44 100644 --- a/src/gui/deletionconfirmationdialog.ui +++ b/src/gui/deletionconfirmationdialog.ui @@ -113,38 +113,5 @@ - - - buttonBox - accepted() - DeletionConfirmationDialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - DeletionConfirmationDialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - + diff --git a/src/gui/ipsubnetwhitelistoptionsdialog.cpp b/src/gui/ipsubnetwhitelistoptionsdialog.cpp index 68897d46a..78af3610f 100644 --- a/src/gui/ipsubnetwhitelistoptionsdialog.cpp +++ b/src/gui/ipsubnetwhitelistoptionsdialog.cpp @@ -47,6 +47,8 @@ IPSubnetWhitelistOptionsDialog::IPSubnetWhitelistOptionsDialog(QWidget *parent) { m_ui->setupUi(this); + connect(m_ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); + QStringList authSubnetWhitelistStringList; for (const Utils::Net::Subnet &subnet : asConst(Preferences::instance()->getWebUiAuthSubnetWhitelist())) authSubnetWhitelistStringList << Utils::Net::subnetToString(subnet); diff --git a/src/gui/ipsubnetwhitelistoptionsdialog.ui b/src/gui/ipsubnetwhitelistoptionsdialog.ui index d353e933c..9c85f79f5 100644 --- a/src/gui/ipsubnetwhitelistoptionsdialog.ui +++ b/src/gui/ipsubnetwhitelistoptionsdialog.ui @@ -50,7 +50,7 @@ - Example: 172.17.32.0/24, fdff:ffff:c8::/40 + Example: 172.17.32.0/24, fdff:ffff:c8::/40 @@ -93,22 +93,5 @@ buttonDeleteIPSubnet - - - buttonBox - rejected() - IPSubnetWhitelistOptionsDialog - reject() - - - 179 - 427 - - - 179 - 224 - - - - + diff --git a/src/gui/optionsdialog.cpp b/src/gui/optionsdialog.cpp index c44e71bce..9df8eb96b 100644 --- a/src/gui/optionsdialog.cpp +++ b/src/gui/optionsdialog.cpp @@ -624,6 +624,8 @@ void OptionsDialog::loadDownloadsTabOptions() connect(m_ui->stopConditionComboBox, qComboBoxCurrentIndexChanged, this, &ThisType::enableApplyButton); connect(m_ui->checkMergeTrackers, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); connect(m_ui->checkConfirmMergeTrackers, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); + connect(m_ui->deleteTorrentBox, &QGroupBox::toggled, m_ui->deleteTorrentWarningIcon, &QWidget::setVisible); + connect(m_ui->deleteTorrentBox, &QGroupBox::toggled, m_ui->deleteTorrentWarningLabel, &QWidget::setVisible); connect(m_ui->deleteTorrentBox, &QGroupBox::toggled, this, &ThisType::enableApplyButton); connect(m_ui->deleteCancelledTorrentBox, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); @@ -844,9 +846,13 @@ void OptionsDialog::loadConnectionTabOptions() connect(m_ui->spinPort, qSpinBoxValueChanged, this, &ThisType::enableApplyButton); connect(m_ui->checkUPnP, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); + connect(m_ui->checkMaxConnections, &QAbstractButton::toggled, m_ui->spinMaxConnec, &QWidget::setEnabled); connect(m_ui->checkMaxConnections, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); + connect(m_ui->checkMaxConnectionsPerTorrent, &QAbstractButton::toggled, m_ui->spinMaxConnecPerTorrent, &QWidget::setEnabled); connect(m_ui->checkMaxConnectionsPerTorrent, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); + connect(m_ui->checkMaxUploads, &QAbstractButton::toggled, m_ui->spinMaxUploads, &QWidget::setEnabled); connect(m_ui->checkMaxUploads, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); + connect(m_ui->checkMaxUploadsPerTorrent, &QAbstractButton::toggled, m_ui->spinMaxUploadsPerTorrent, &QWidget::setEnabled); connect(m_ui->checkMaxUploadsPerTorrent, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); connect(m_ui->spinMaxConnec, qSpinBoxValueChanged, this, &ThisType::enableApplyButton); connect(m_ui->spinMaxConnecPerTorrent, qSpinBoxValueChanged, this, &ThisType::enableApplyButton); @@ -1073,12 +1079,14 @@ void OptionsDialog::loadBittorrentTabOptions() connect(m_ui->spinUploadRateForSlowTorrents, qSpinBoxValueChanged, this, &ThisType::enableApplyButton); connect(m_ui->spinSlowTorrentsInactivityTimer, qSpinBoxValueChanged, this, &ThisType::enableApplyButton); - connect(m_ui->checkMaxRatio, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); + connect(m_ui->checkMaxRatio, &QAbstractButton::toggled, m_ui->spinMaxRatio, &QWidget::setEnabled); connect(m_ui->checkMaxRatio, &QAbstractButton::toggled, this, &ThisType::toggleComboRatioLimitAct); + connect(m_ui->checkMaxRatio, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); connect(m_ui->spinMaxRatio, qOverload(&QDoubleSpinBox::valueChanged),this, &ThisType::enableApplyButton); connect(m_ui->comboRatioLimitAct, qComboBoxCurrentIndexChanged, this, &ThisType::enableApplyButton); - connect(m_ui->checkMaxSeedingMinutes, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); + connect(m_ui->checkMaxSeedingMinutes, &QAbstractButton::toggled, m_ui->spinMaxSeedingMinutes, &QWidget::setEnabled); connect(m_ui->checkMaxSeedingMinutes, &QAbstractButton::toggled, this, &ThisType::toggleComboRatioLimitAct); + connect(m_ui->checkMaxSeedingMinutes, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); connect(m_ui->spinMaxSeedingMinutes, qSpinBoxValueChanged, this, &ThisType::enableApplyButton); connect(m_ui->checkEnableAddTrackers, &QGroupBox::toggled, this, &ThisType::enableApplyButton); @@ -1226,7 +1234,7 @@ void OptionsDialog::loadWebUITabOptions() connect(m_ui->checkBypassLocalAuth, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); connect(m_ui->checkBypassAuthSubnetWhitelist, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); - connect(m_ui->checkBypassAuthSubnetWhitelist, &QAbstractButton::toggled, m_ui->IPSubnetWhitelistButton, &QPushButton::setEnabled); + connect(m_ui->checkBypassAuthSubnetWhitelist, &QAbstractButton::toggled, m_ui->IPSubnetWhitelistButton, &QWidget::setEnabled); connect(m_ui->spinBanCounter, qSpinBoxValueChanged, this, &ThisType::enableApplyButton); connect(m_ui->spinBanDuration, qSpinBoxValueChanged, this, &ThisType::enableApplyButton); connect(m_ui->spinSessionTimeout, qSpinBoxValueChanged, this, &ThisType::enableApplyButton); diff --git a/src/gui/optionsdialog.ui b/src/gui/optionsdialog.ui index 2d032f93b..db85e9477 100644 --- a/src/gui/optionsdialog.ui +++ b/src/gui/optionsdialog.ui @@ -245,7 +245,7 @@ Shows a confirmation dialog upon pausing/resuming all the torrents - Confirm "Pause/Resume all" actions + Confirm "Pause/Resume all" actions true @@ -3910,134 +3910,5 @@ Use ';' to split multiple entries. Can use wildcard '*'. DNSPasswordTxt - - - checkMaxConnections - toggled(bool) - spinMaxConnec - setEnabled(bool) - - - 604 - 205 - - - 677 - 206 - - - - - checkMaxConnectionsPerTorrent - toggled(bool) - spinMaxConnecPerTorrent - setEnabled(bool) - - - 604 - 238 - - - 677 - 239 - - - - - checkMaxUploadsPerTorrent - toggled(bool) - spinMaxUploadsPerTorrent - setEnabled(bool) - - - 604 - 304 - - - 677 - 305 - - - - - checkMaxUploads - toggled(bool) - spinMaxUploads - setEnabled(bool) - - - 547 - 415 - - - 642 - 414 - - - - - checkMaxRatio - toggled(bool) - spinMaxRatio - setEnabled(bool) - - - 395 - 203 - - - 496 - 204 - - - - - checkMaxSeedingMinutes - toggled(bool) - spinMaxSeedingMinutes - setEnabled(bool) - - - 395 - 170 - - - 496 - 171 - - - - - deleteTorrentBox - toggled(bool) - deleteTorrentWarningIcon - setVisible(bool) - - - 554 - 153 - - - 324 - 214 - - - - - deleteTorrentBox - toggled(bool) - deleteTorrentWarningLabel - setVisible(bool) - - - 646 - 158 - - - 629 - 207 - - - - + diff --git a/src/gui/properties/peersadditiondialog.cpp b/src/gui/properties/peersadditiondialog.cpp index 7baff0984..6ef62a7f1 100644 --- a/src/gui/properties/peersadditiondialog.cpp +++ b/src/gui/properties/peersadditiondialog.cpp @@ -40,7 +40,9 @@ PeersAdditionDialog::PeersAdditionDialog(QWidget *parent) , m_ui(new Ui::PeersAdditionDialog()) { m_ui->setupUi(this); + connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &PeersAdditionDialog::validateInput); + connect(m_ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); } PeersAdditionDialog::~PeersAdditionDialog() diff --git a/src/gui/properties/peersadditiondialog.ui b/src/gui/properties/peersadditiondialog.ui index a7aab53c7..3084080fe 100644 --- a/src/gui/properties/peersadditiondialog.ui +++ b/src/gui/properties/peersadditiondialog.ui @@ -47,22 +47,5 @@ - - - buttonBox - rejected() - PeersAdditionDialog - reject() - - - 183 - 251 - - - 183 - 136 - - - - + diff --git a/src/gui/properties/trackersadditiondialog.cpp b/src/gui/properties/trackersadditiondialog.cpp index d15bdbf7c..344bd2fd6 100644 --- a/src/gui/properties/trackersadditiondialog.cpp +++ b/src/gui/properties/trackersadditiondialog.cpp @@ -53,10 +53,13 @@ TrackersAdditionDialog::TrackersAdditionDialog(QWidget *parent, BitTorrent::Torr { m_ui->setupUi(this); - m_ui->downloadButton->setIcon(UIThemeManager::instance()->getIcon(u"downloading"_s, u"download"_s)); m_ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Add")); + connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(m_ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); + m_ui->downloadButton->setIcon(UIThemeManager::instance()->getIcon(u"downloading"_s, u"download"_s)); connect(m_ui->downloadButton, &QAbstractButton::clicked, this, &TrackersAdditionDialog::onDownloadButtonClicked); + connect(this, &QDialog::accepted, this, &TrackersAdditionDialog::onAccepted); loadSettings(); diff --git a/src/gui/properties/trackersadditiondialog.ui b/src/gui/properties/trackersadditiondialog.ui index d737aec6f..4f97142b4 100644 --- a/src/gui/properties/trackersadditiondialog.ui +++ b/src/gui/properties/trackersadditiondialog.ui @@ -65,38 +65,5 @@ - - - buttonBox - accepted() - TrackersAdditionDialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - TrackersAdditionDialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - + diff --git a/src/gui/rss/automatedrssdownloader.cpp b/src/gui/rss/automatedrssdownloader.cpp index 9b6b0607d..7bb5e4eb7 100644 --- a/src/gui/rss/automatedrssdownloader.cpp +++ b/src/gui/rss/automatedrssdownloader.cpp @@ -76,6 +76,10 @@ AutomatedRssDownloader::AutomatedRssDownloader(QWidget *parent) #endif { m_ui->setupUi(this); + + connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(m_ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); + m_ui->torrentParametersGroupBox->layout()->addWidget(m_addTorrentParamsWidget); m_ui->prioritySpinBox->setMinimum(std::numeric_limits::min()); diff --git a/src/gui/rss/automatedrssdownloader.ui b/src/gui/rss/automatedrssdownloader.ui index d03177968..a78b26f3d 100644 --- a/src/gui/rss/automatedrssdownloader.ui +++ b/src/gui/rss/automatedrssdownloader.ui @@ -442,38 +442,5 @@ Supports the formats: S01E01, 1x1, 2017.12.31 and 31.12.2017 (Date formats also exportBtn - - - buttonBox - accepted() - AutomatedRssDownloader - accept() - - - 750 - 483 - - - 157 - 274 - - - - - buttonBox - rejected() - AutomatedRssDownloader - reject() - - - 805 - 483 - - - 286 - 274 - - - - + diff --git a/src/gui/shutdownconfirmdialog.cpp b/src/gui/shutdownconfirmdialog.cpp index dd1f9ecb9..0a787ae1d 100644 --- a/src/gui/shutdownconfirmdialog.cpp +++ b/src/gui/shutdownconfirmdialog.cpp @@ -63,6 +63,9 @@ ShutdownConfirmDialog::ShutdownConfirmDialog(QWidget *parent, const ShutdownDial cancelButton->setFocus(); cancelButton->setDefault(true); + connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(m_ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); + // Always on top setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint); move(Utils::Gui::screenCenter(this)); diff --git a/src/gui/shutdownconfirmdialog.ui b/src/gui/shutdownconfirmdialog.ui index 4f79a3a10..2db098701 100644 --- a/src/gui/shutdownconfirmdialog.ui +++ b/src/gui/shutdownconfirmdialog.ui @@ -90,38 +90,5 @@ - - - buttonBox - accepted() - ShutdownConfirmDialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - ShutdownConfirmDialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - + diff --git a/src/gui/speedlimitdialog.cpp b/src/gui/speedlimitdialog.cpp index 01821ebb5..dfd524064 100644 --- a/src/gui/speedlimitdialog.cpp +++ b/src/gui/speedlimitdialog.cpp @@ -56,6 +56,9 @@ SpeedLimitDialog::SpeedLimitDialog(QWidget *parent) { m_ui->setupUi(this); + connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(m_ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); + m_ui->labelGlobalSpeedIcon->setPixmap( UIThemeManager::instance()->getScaledPixmap(u"slow_off"_s, Utils::Gui::mediumIconSize(this).height())); m_ui->labelAltGlobalSpeedIcon->setPixmap( diff --git a/src/gui/speedlimitdialog.ui b/src/gui/speedlimitdialog.ui index ea680b6a2..e9250793d 100644 --- a/src/gui/speedlimitdialog.ui +++ b/src/gui/speedlimitdialog.ui @@ -177,38 +177,5 @@ - - - buttonBox - rejected() - SpeedLimitDialog - reject() - - - 221 - 73 - - - 221 - 82 - - - - - buttonBox - accepted() - SpeedLimitDialog - accept() - - - 277 - 59 - - - 343 - 80 - - - - + diff --git a/src/gui/torrentcategorydialog.cpp b/src/gui/torrentcategorydialog.cpp index 36fe38d9a..f93b08017 100644 --- a/src/gui/torrentcategorydialog.cpp +++ b/src/gui/torrentcategorydialog.cpp @@ -51,6 +51,8 @@ TorrentCategoryDialog::TorrentCategoryDialog(QWidget *parent) // disable save button m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); + connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(m_ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); connect(m_ui->textCategoryName, &QLineEdit::textChanged, this, &TorrentCategoryDialog::categoryNameChanged); connect(m_ui->comboUseDownloadPath, &QComboBox::currentIndexChanged, this, &TorrentCategoryDialog::useDownloadPathChanged); diff --git a/src/gui/torrentcategorydialog.ui b/src/gui/torrentcategorydialog.ui index 2a9c785ef..ed0c13123 100644 --- a/src/gui/torrentcategorydialog.ui +++ b/src/gui/torrentcategorydialog.ui @@ -180,38 +180,5 @@ comboDownloadPath - - - buttonBox - accepted() - TorrentCategoryDialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - TorrentCategoryDialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - + diff --git a/src/gui/torrentcreatordialog.cpp b/src/gui/torrentcreatordialog.cpp index 10ac7720b..9d816213e 100644 --- a/src/gui/torrentcreatordialog.cpp +++ b/src/gui/torrentcreatordialog.cpp @@ -86,7 +86,9 @@ TorrentCreatorDialog::TorrentCreatorDialog(QWidget *parent, const Path &defaultP connect(m_ui->addFileButton, &QPushButton::clicked, this, &TorrentCreatorDialog::onAddFileButtonClicked); connect(m_ui->addFolderButton, &QPushButton::clicked, this, &TorrentCreatorDialog::onAddFolderButtonClicked); connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &TorrentCreatorDialog::onCreateButtonClicked); + connect(m_ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); connect(m_ui->buttonCalcTotalPieces, &QPushButton::clicked, this, &TorrentCreatorDialog::updatePiecesCount); + connect(m_ui->checkStartSeeding, &QCheckBox::clicked, m_ui->checkIgnoreShareLimits, &QWidget::setEnabled); connect(m_creatorThread, &BitTorrent::TorrentCreatorThread::creationSuccess, this, &TorrentCreatorDialog::handleCreationSuccess); connect(m_creatorThread, &BitTorrent::TorrentCreatorThread::creationFailure, this, &TorrentCreatorDialog::handleCreationFailure); diff --git a/src/gui/torrentcreatordialog.ui b/src/gui/torrentcreatordialog.ui index a0b8b5222..6b446d1ee 100644 --- a/src/gui/torrentcreatordialog.ui +++ b/src/gui/torrentcreatordialog.ui @@ -492,38 +492,5 @@ txtComment - - - checkStartSeeding - clicked(bool) - checkIgnoreShareLimits - setEnabled(bool) - - - 295 - 532 - - - 295 - 555 - - - - - buttonBox - rejected() - TorrentCreatorDialog - reject() - - - 295 - 635 - - - 295 - 328 - - - - + diff --git a/src/gui/torrentoptionsdialog.cpp b/src/gui/torrentoptionsdialog.cpp index 5a73acdcc..0ddca35cb 100644 --- a/src/gui/torrentoptionsdialog.cpp +++ b/src/gui/torrentoptionsdialog.cpp @@ -69,6 +69,9 @@ TorrentOptionsDialog::TorrentOptionsDialog(QWidget *parent, const QVectorsetupUi(this); + connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(m_ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); + m_ui->savePath->setMode(FileSystemPathEdit::Mode::DirectorySave); m_ui->savePath->setDialogCaption(tr("Choose save path")); m_ui->downloadPath->setMode(FileSystemPathEdit::Mode::DirectorySave); @@ -385,8 +388,8 @@ TorrentOptionsDialog::TorrentOptionsDialog(QWidget *parent, const QVectorspinDownloadLimit, qOverload(&QSpinBox::valueChanged) , this, [this](const int value) { updateSliderValue(m_ui->sliderDownloadLimit, value); }); - connect(m_ui->checkMaxRatio, &QCheckBox::toggled, m_ui->spinRatioLimit, &QDoubleSpinBox::setEnabled); - connect(m_ui->checkMaxTime, &QCheckBox::toggled, m_ui->spinTimeLimit, &QSpinBox::setEnabled); + connect(m_ui->checkMaxRatio, &QCheckBox::toggled, m_ui->spinRatioLimit, &QWidget::setEnabled); + connect(m_ui->checkMaxTime, &QCheckBox::toggled, m_ui->spinTimeLimit, &QWidget::setEnabled); connect(m_ui->buttonGroup, &QButtonGroup::idClicked, this, &TorrentOptionsDialog::handleRatioTypeChanged); diff --git a/src/gui/torrentoptionsdialog.ui b/src/gui/torrentoptionsdialog.ui index 05d10121c..65286133f 100644 --- a/src/gui/torrentoptionsdialog.ui +++ b/src/gui/torrentoptionsdialog.ui @@ -326,40 +326,7 @@ - - - buttonBox - rejected() - TorrentOptionsDialog - reject() - - - 221 - 73 - - - 221 - 82 - - - - - buttonBox - accepted() - TorrentOptionsDialog - accept() - - - 277 - 59 - - - 343 - 80 - - - - + diff --git a/src/gui/torrenttagsdialog.cpp b/src/gui/torrenttagsdialog.cpp index 86e99529d..eb4d86168 100644 --- a/src/gui/torrenttagsdialog.cpp +++ b/src/gui/torrenttagsdialog.cpp @@ -49,6 +49,9 @@ TorrentTagsDialog::TorrentTagsDialog(const TagSet &initialTags, QWidget *parent) { m_ui->setupUi(this); + connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(m_ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); + auto *tagsLayout = new FlowLayout(m_ui->scrollArea); for (const QString &tag : asConst(initialTags.united(BitTorrent::Session::instance()->tags()))) { diff --git a/src/gui/torrenttagsdialog.ui b/src/gui/torrenttagsdialog.ui index 86ce8c0a4..c27b683ff 100644 --- a/src/gui/torrenttagsdialog.ui +++ b/src/gui/torrenttagsdialog.ui @@ -44,38 +44,5 @@ - - - buttonBox - accepted() - TorrentTagsDialog - accept() - - - 241 - 291 - - - 241 - 156 - - - - - buttonBox - rejected() - TorrentTagsDialog - reject() - - - 241 - 291 - - - 241 - 156 - - - - + diff --git a/src/gui/uithemedialog.cpp b/src/gui/uithemedialog.cpp index d4b9d2810..3187a0f15 100644 --- a/src/gui/uithemedialog.cpp +++ b/src/gui/uithemedialog.cpp @@ -220,6 +220,9 @@ UIThemeDialog::UIThemeDialog(QWidget *parent) { m_ui->setupUi(this); + connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(m_ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); + loadColors(); loadIcons(); diff --git a/src/gui/uithemedialog.ui b/src/gui/uithemedialog.ui index 00247614b..067905456 100644 --- a/src/gui/uithemedialog.ui +++ b/src/gui/uithemedialog.ui @@ -249,38 +249,5 @@ - - - buttonBox - accepted() - UIThemeDialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - UIThemeDialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - + diff --git a/src/gui/watchedfolderoptionsdialog.cpp b/src/gui/watchedfolderoptionsdialog.cpp index fcd0c71b0..b72eb353d 100644 --- a/src/gui/watchedfolderoptionsdialog.cpp +++ b/src/gui/watchedfolderoptionsdialog.cpp @@ -44,6 +44,9 @@ WatchedFolderOptionsDialog::WatchedFolderOptionsDialog( m_ui->setupUi(this); m_ui->groupBoxParameters->layout()->addWidget(m_addTorrentParamsWidget); + connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(m_ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); + loadState(); } diff --git a/src/gui/watchedfolderoptionsdialog.ui b/src/gui/watchedfolderoptionsdialog.ui index 1633ea342..92a1a5a17 100644 --- a/src/gui/watchedfolderoptionsdialog.ui +++ b/src/gui/watchedfolderoptionsdialog.ui @@ -89,38 +89,5 @@ - - - buttonBox - accepted() - WatchedFolderOptionsDialog - accept() - - - 928 - 855 - - - 157 - 274 - - - - - buttonBox - rejected() - WatchedFolderOptionsDialog - reject() - - - 928 - 855 - - - 286 - 274 - - - - + From 392949b313b89531ce4b4d3990047c1f5eb198ed Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Wed, 12 Jul 2023 06:01:54 +0800 Subject: [PATCH 2/2] Rename variable to avoid name clash --- src/gui/optionsdialog.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/optionsdialog.ui b/src/gui/optionsdialog.ui index db85e9477..cc00cfed3 100644 --- a/src/gui/optionsdialog.ui +++ b/src/gui/optionsdialog.ui @@ -955,7 +955,7 @@ When duplicate torrent is being added - +