Browse Source

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

adaptive-webui-19844
thalieht 3 years ago
parent
commit
16f8d6a936
  1. 15
      src/gui/torrentoptionsdialog.cpp
  2. 3
      src/gui/torrentoptionsdialog.h

15
src/gui/torrentoptionsdialog.cpp

@ -276,7 +276,6 @@ TorrentOptionsDialog::TorrentOptionsDialog(QWidget *parent, const QVector<BitTor
? firstTorrentSeedingTime : session->globalMaxSeedingMinutes(); ? firstTorrentSeedingTime : session->globalMaxSeedingMinutes();
m_ui->spinRatioLimit->setValue(maxRatio); m_ui->spinRatioLimit->setValue(maxRatio);
m_ui->spinTimeLimit->setValue(maxSeedingTime); m_ui->spinTimeLimit->setValue(maxSeedingTime);
handleRatioTypeChanged();
if (!allTorrentsArePrivate) if (!allTorrentsArePrivate)
{ {
@ -338,6 +337,7 @@ TorrentOptionsDialog::TorrentOptionsDialog(QWidget *parent, const QVector<BitTor
// Needs to be called after the initial values struct is initialized // Needs to be called after the initial values struct is initialized
handleTMMChanged(); handleTMMChanged();
handleRatioTypeChanged();
connect(m_ui->checkAutoTMM, &QCheckBox::clicked, this, &TorrentOptionsDialog::handleTMMChanged); connect(m_ui->checkAutoTMM, &QCheckBox::clicked, this, &TorrentOptionsDialog::handleTMMChanged);
connect(m_ui->comboCategory, &QComboBox::activated, this, &TorrentOptionsDialog::handleCategoryChanged); connect(m_ui->comboCategory, &QComboBox::activated, this, &TorrentOptionsDialog::handleCategoryChanged);
@ -514,6 +514,19 @@ void TorrentOptionsDialog::handleTMMChanged()
void TorrentOptionsDialog::handleRatioTypeChanged() 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->checkMaxRatio->setEnabled(m_ui->radioTorrentLimit->isChecked());
m_ui->checkMaxTime->setEnabled(m_ui->radioTorrentLimit->isChecked()); m_ui->checkMaxTime->setEnabled(m_ui->radioTorrentLimit->isChecked());

3
src/gui/torrentoptionsdialog.h

@ -34,6 +34,8 @@
#include "base/settingvalue.h" #include "base/settingvalue.h"
class QAbstractButton;
namespace BitTorrent namespace BitTorrent
{ {
class Torrent; class Torrent;
@ -76,6 +78,7 @@ private:
QStringList m_categories; QStringList m_categories;
QString m_currentCategoriesString; QString m_currentCategoriesString;
bool m_allSameCategory = true; bool m_allSameCategory = true;
QAbstractButton *m_previousRadio = nullptr;
struct struct
{ {
QString savePath; QString savePath;

Loading…
Cancel
Save