Allow deselecting radio buttons in "Torrent options" for mixed torrents

This commit is contained in:
thalieht 2021-10-22 13:51:28 +03:00
parent 046d6f3bc1
commit 16f8d6a936
2 changed files with 17 additions and 1 deletions

View File

@ -276,7 +276,6 @@ TorrentOptionsDialog::TorrentOptionsDialog(QWidget *parent, const QVector<BitTor
? firstTorrentSeedingTime : session->globalMaxSeedingMinutes();
m_ui->spinRatioLimit->setValue(maxRatio);
m_ui->spinTimeLimit->setValue(maxSeedingTime);
handleRatioTypeChanged();
if (!allTorrentsArePrivate)
{
@ -338,6 +337,7 @@ TorrentOptionsDialog::TorrentOptionsDialog(QWidget *parent, const QVector<BitTor
// Needs to be called after the initial values struct is initialized
handleTMMChanged();
handleRatioTypeChanged();
connect(m_ui->checkAutoTMM, &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());

View File

@ -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;