From 16f8d6a9361f95d3fe28ad7c77692526c186c876 Mon Sep 17 00:00:00 2001 From: thalieht Date: Fri, 22 Oct 2021 13:51:28 +0300 Subject: [PATCH] Allow deselecting radio buttons in "Torrent options" for mixed torrents --- src/gui/torrentoptionsdialog.cpp | 15 ++++++++++++++- src/gui/torrentoptionsdialog.h | 3 +++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/gui/torrentoptionsdialog.cpp b/src/gui/torrentoptionsdialog.cpp index bd2ce39a1..b348e1a00 100644 --- a/src/gui/torrentoptionsdialog.cpp +++ b/src/gui/torrentoptionsdialog.cpp @@ -276,7 +276,6 @@ TorrentOptionsDialog::TorrentOptionsDialog(QWidget *parent, const QVectorglobalMaxSeedingMinutes(); m_ui->spinRatioLimit->setValue(maxRatio); m_ui->spinTimeLimit->setValue(maxSeedingTime); - handleRatioTypeChanged(); if (!allTorrentsArePrivate) { @@ -338,6 +337,7 @@ TorrentOptionsDialog::TorrentOptionsDialog(QWidget *parent, const QVectorcheckAutoTMM, &QCheckBox::clicked, this, &TorrentOptionsDialog::handleTMMChanged); connect(m_ui->comboCategory, &QComboBox::activated, this, &TorrentOptionsDialog::handleCategoryChanged); @@ -514,6 +514,19 @@ void TorrentOptionsDialog::handleTMMChanged() void TorrentOptionsDialog::handleRatioTypeChanged() { + if ((m_initialValues.ratio == MIXED_SHARE_LIMITS) || (m_initialValues.seedingTime == MIXED_SHARE_LIMITS)) + { + QAbstractButton *currentRadio = m_ui->buttonGroup->checkedButton(); + if (currentRadio && (currentRadio == m_previousRadio)) + { + // Hack to deselect the currently selected radio button programatically because Qt doesn't allow it in exclusive mode + m_ui->buttonGroup->setExclusive(false); + currentRadio->setChecked(false); + m_ui->buttonGroup->setExclusive(true); + } + m_previousRadio = m_ui->buttonGroup->checkedButton(); + } + m_ui->checkMaxRatio->setEnabled(m_ui->radioTorrentLimit->isChecked()); m_ui->checkMaxTime->setEnabled(m_ui->radioTorrentLimit->isChecked()); diff --git a/src/gui/torrentoptionsdialog.h b/src/gui/torrentoptionsdialog.h index 09fbe86cc..a07eaae66 100644 --- a/src/gui/torrentoptionsdialog.h +++ b/src/gui/torrentoptionsdialog.h @@ -34,6 +34,8 @@ #include "base/settingvalue.h" +class QAbstractButton; + namespace BitTorrent { class Torrent; @@ -76,6 +78,7 @@ private: QStringList m_categories; QString m_currentCategoriesString; bool m_allSameCategory = true; + QAbstractButton *m_previousRadio = nullptr; struct { QString savePath;