Implemented share limit by seeding time

This commit is contained in:
Naikel Aparicio
2016-02-07 13:01:50 -04:30
parent f4a6242711
commit 9ba00d7035
16 changed files with 661 additions and 162 deletions

View File

@@ -298,9 +298,14 @@ OptionsDialog::OptionsDialog(QWidget *parent)
connect(m_ui->checkLSD, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
connect(m_ui->comboEncryption, qComboBoxCurrentIndexChanged, this, &ThisType::enableApplyButton);
connect(m_ui->checkMaxRatio, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
connect(m_ui->checkMaxRatio, &QAbstractButton::toggled, this, &ThisType::toggleComboRatioLimitAct);
connect(m_ui->spinMaxRatio, static_cast<void (QDoubleSpinBox::*)(double)>(&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, this, &ThisType::toggleComboRatioLimitAct);
connect(m_ui->spinMaxSeedingMinutes, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
this, &ThisType::enableApplyButton);
// Proxy tab
connect(m_ui->comboProxyType, qComboBoxCurrentIndexChanged, this, &ThisType::enableApplyButton);
connect(m_ui->textProxyIP, &QLineEdit::textChanged, this, &ThisType::enableApplyButton);
@@ -601,6 +606,7 @@ void OptionsDialog::saveOptions()
session->setAddTrackersEnabled(m_ui->checkEnableAddTrackers->isChecked());
session->setAdditionalTrackers(m_ui->textTrackers->toPlainText());
session->setGlobalMaxRatio(getMaxRatio());
session->setGlobalMaxSeedingMinutes(getMaxSeedingMinutes());
session->setMaxRatioAction(static_cast<MaxRatioAction>(m_ui->comboRatioLimitAct->currentIndex()));
// End Bittorrent preferences
@@ -990,8 +996,19 @@ void OptionsDialog::loadOptions()
// Disable
m_ui->checkMaxRatio->setChecked(false);
m_ui->spinMaxRatio->setEnabled(false);
m_ui->comboRatioLimitAct->setEnabled(false);
}
if (session->globalMaxSeedingMinutes() >= 0) {
// Enable
m_ui->checkMaxSeedingMinutes->setChecked(true);
m_ui->spinMaxSeedingMinutes->setEnabled(true);
m_ui->spinMaxSeedingMinutes->setValue(session->globalMaxSeedingMinutes());
}
else {
// Disable
m_ui->checkMaxSeedingMinutes->setChecked(false);
m_ui->spinMaxSeedingMinutes->setEnabled(false);
}
m_ui->comboRatioLimitAct->setEnabled((session->globalMaxSeedingMinutes() >= 0) || (session->globalMaxRatio() >= 0.));
m_ui->comboRatioLimitAct->setCurrentIndex(session->maxRatioAction());
// End Bittorrent preferences
@@ -1122,6 +1139,14 @@ qreal OptionsDialog::getMaxRatio() const
return -1;
}
// Return Seeding Minutes
int OptionsDialog::getMaxSeedingMinutes() const
{
if (m_ui->checkMaxSeedingMinutes->isChecked())
return m_ui->spinMaxSeedingMinutes->value();
return -1;
}
// Return max connections number
int OptionsDialog::getMaxConnecs() const
{
@@ -1211,6 +1236,12 @@ void OptionsDialog::enableApplyButton()
applyButton->setEnabled(true);
}
void OptionsDialog::toggleComboRatioLimitAct()
{
// Verify if the share action button must be enabled
m_ui->comboRatioLimitAct->setEnabled(m_ui->checkMaxRatio->isChecked() || m_ui->checkMaxSeedingMinutes->isChecked());
}
void OptionsDialog::enableProxy(int index)
{
if (index) {

View File

@@ -90,6 +90,7 @@ private slots:
void on_buttonBox_rejected();
void applySettings(QAbstractButton* button);
void enableApplyButton();
void toggleComboRatioLimitAct();
void changePage(QListWidgetItem*, QListWidgetItem*);
void loadWindowState();
void saveWindowState() const;
@@ -145,6 +146,7 @@ private:
bool isLSDEnabled() const;
int getEncryptionSetting() const;
qreal getMaxRatio() const;
int getMaxSeedingMinutes() const;
// Proxy options
bool isProxyEnabled() const;
bool isProxyAuthEnabled() const;

View File

@@ -1852,9 +1852,6 @@
<property name="wrapping">
<bool>true</bool>
</property>
<property name="displayFormat">
<string notr="true">hh:mm</string>
</property>
<property name="time">
<time>
<hour>20</hour>
@@ -1862,6 +1859,9 @@
<second>0</second>
</time>
</property>
<property name="displayFormat">
<string notr="true">hh:mm</string>
</property>
</widget>
</item>
<item row="0" column="2">
@@ -1876,12 +1876,6 @@
<property name="wrapping">
<bool>true</bool>
</property>
<property name="displayFormat">
<string notr="true">hh:mm</string>
</property>
<property name="calendarPopup">
<bool>false</bool>
</property>
<property name="time">
<time>
<hour>8</hour>
@@ -1889,6 +1883,12 @@
<second>0</second>
</time>
</property>
<property name="displayFormat">
<string notr="true">hh:mm</string>
</property>
<property name="calendarPopup">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="0">
@@ -2374,66 +2374,144 @@
<property name="title">
<string>Share Ratio Limiting</string>
</property>
<layout class="QVBoxLayout">
<property name="bottomMargin">
<number>9</number>
</property>
<item>
<layout class="QHBoxLayout">
<layout class="QGridLayout" name="gridLayout_91">
<item row="0" column="0" rowspan="3" colspan="3">
<widget class="QCheckBox" name="checkMaxRatio">
<property name="text">
<string>Seed torrents until their ratio reaches</string>
</property>
</widget>
</item>
<item row="1" column="6" rowspan="2">
<spacer name="horizontalSpacer_161">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>109</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="5" column="2">
<widget class="QLabel" name="label">
<property name="text">
<string>then</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="5" column="4" colspan="2">
<widget class="QComboBox" name="comboRatioLimitAct">
<property name="enabled">
<bool>false</bool>
</property>
<item>
<widget class="QCheckBox" name="checkMaxRatio">
<property name="text">
<string>Seed torrents until their ratio reaches</string>
</property>
</widget>
<property name="text">
<string>Pause them</string>
</property>
</item>
<item>
<widget class="QDoubleSpinBox" name="spinMaxRatio">
<property name="enabled">
<bool>false</bool>
</property>
<property name="alignment">
<set>Qt::AlignHCenter</set>
</property>
<property name="minimum">
<double>0.000000000000000</double>
</property>
<property name="maximum">
<double>9998.000000000000000</double>
</property>
<property name="singleStep">
<double>0.050000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
<property name="text">
<string>Remove them</string>
</property>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>then</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboRatioLimitAct">
<property name="enabled">
<bool>false</bool>
</property>
<item>
<property name="text">
<string>Pause them</string>
</property>
</item>
<item>
<property name="text">
<string>Remove them</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
<item row="5" column="6">
<spacer name="horizontalSpacer_20">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>121</width>
<height>28</height>
</size>
</property>
</spacer>
</item>
<item row="5" column="1">
<spacer name="horizontalSpacer_171">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>100</width>
<height>42</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="6">
<spacer name="horizontalSpacer_191">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="4">
<widget class="QSpinBox" name="spinMaxSeedingMinutes">
<property name="enabled">
<bool>false</bool>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="maximum">
<number>9999999</number>
</property>
<property name="value">
<number>1440</number>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QDoubleSpinBox" name="spinMaxRatio">
<property name="enabled">
<bool>false</bool>
</property>
<property name="alignment">
<set>Qt::AlignHCenter</set>
</property>
<property name="minimum">
<double>0.000000000000000</double>
</property>
<property name="maximum">
<double>9998.000000000000000</double>
</property>
<property name="singleStep">
<double>0.050000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item row="3" column="5">
<widget class="QLabel" name="label_11">
<property name="text">
<string>minutes</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="4">
<widget class="QCheckBox" name="checkMaxSeedingMinutes">
<property name="text">
<string>Seed torrents until their seeding time reaches</string>
</property>
</widget>
</item>
</layout>
</widget>
@@ -2506,7 +2584,7 @@
<item>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<widget class="QLabel" name="label_11">
<widget class="QLabel" name="label_111">
<property name="text">
<string>Feeds refresh interval:</string>
</property>
@@ -3035,16 +3113,129 @@
<tabstops>
<tabstop>tabOption</tabstop>
<tabstop>comboI18n</tabstop>
<tabstop>browseSaveDirButton</tabstop>
<tabstop>checkStartPaused</tabstop>
<tabstop>spinPort</tabstop>
<tabstop>checkUPnP</tabstop>
<tabstop>textWebUiUsername</tabstop>
<tabstop>checkWebUi</tabstop>
<tabstop>textSavePath</tabstop>
<tabstop>scrollArea_7</tabstop>
<tabstop>scrollArea_2</tabstop>
<tabstop>spinWebUiPort</tabstop>
<tabstop>textWebUiPassword</tabstop>
<tabstop>buttonBox</tabstop>
<tabstop>tabSelection</tabstop>
<tabstop>scrollArea</tabstop>
<tabstop>confirmDeletion</tabstop>
<tabstop>checkAltRowColors</tabstop>
<tabstop>actionTorrentDlOnDblClBox</tabstop>
<tabstop>actionTorrentFnOnDblClBox</tabstop>
<tabstop>checkStartup</tabstop>
<tabstop>checkShowSplash</tabstop>
<tabstop>checkStartMinimized</tabstop>
<tabstop>checkProgramExitConfirm</tabstop>
<tabstop>checkShowSystray</tabstop>
<tabstop>checkMinimizeToSysTray</tabstop>
<tabstop>checkCloseToSystray</tabstop>
<tabstop>comboTrayIcon</tabstop>
<tabstop>checkAssociateTorrents</tabstop>
<tabstop>checkAssociateMagnetLinks</tabstop>
<tabstop>checkPreventFromSuspend</tabstop>
<tabstop>checkAdditionDialog</tabstop>
<tabstop>checkAdditionDialogFront</tabstop>
<tabstop>checkPreallocateAll</tabstop>
<tabstop>checkTempFolder</tabstop>
<tabstop>textTempPath</tabstop>
<tabstop>browseTempDirButton</tabstop>
<tabstop>checkAppendqB</tabstop>
<tabstop>scanFoldersView</tabstop>
<tabstop>addScanFolderButton</tabstop>
<tabstop>removeScanFolderButton</tabstop>
<tabstop>checkExportDir</tabstop>
<tabstop>textExportDir</tabstop>
<tabstop>browseExportDirButton</tabstop>
<tabstop>checkExportDirFin</tabstop>
<tabstop>textExportDirFin</tabstop>
<tabstop>browseExportDirFinButton</tabstop>
<tabstop>groupMailNotification</tabstop>
<tabstop>dest_email_txt</tabstop>
<tabstop>smtp_server_txt</tabstop>
<tabstop>groupMailNotifAuth</tabstop>
<tabstop>mailNotifUsername</tabstop>
<tabstop>mailNotifPassword</tabstop>
<tabstop>checkSmtpSSL</tabstop>
<tabstop>autoRunBox</tabstop>
<tabstop>autoRun_txt</tabstop>
<tabstop>scrollArea_3</tabstop>
<tabstop>randomButton</tabstop>
<tabstop>checkRandomPort</tabstop>
<tabstop>checkMaxConnecs</tabstop>
<tabstop>spinMaxConnec</tabstop>
<tabstop>checkMaxConnecsPerTorrent</tabstop>
<tabstop>spinMaxConnecPerTorrent</tabstop>
<tabstop>checkMaxUploadsPerTorrent</tabstop>
<tabstop>spinMaxUploadsPerTorrent</tabstop>
<tabstop>checkMaxUploads</tabstop>
<tabstop>spinMaxUploads</tabstop>
<tabstop>comboProxyType</tabstop>
<tabstop>textProxyIP</tabstop>
<tabstop>spinProxyPort</tabstop>
<tabstop>checkProxyPeerConnecs</tabstop>
<tabstop>checkForceProxy</tabstop>
<tabstop>isProxyOnlyForTorrents</tabstop>
<tabstop>checkProxyAuth</tabstop>
<tabstop>textProxyUsername</tabstop>
<tabstop>textProxyPassword</tabstop>
<tabstop>checkIPFilter</tabstop>
<tabstop>textFilterPath</tabstop>
<tabstop>browseFilterButton</tabstop>
<tabstop>IpFilterRefreshBtn</tabstop>
<tabstop>checkIpFilterTrackers</tabstop>
<tabstop>scrollArea_9</tabstop>
<tabstop>spinUploadLimit</tabstop>
<tabstop>checkUploadLimit</tabstop>
<tabstop>spinDownloadLimit</tabstop>
<tabstop>checkDownloadLimit</tabstop>
<tabstop>check_schedule</tabstop>
<tabstop>schedule_to</tabstop>
<tabstop>schedule_from</tabstop>
<tabstop>schedule_days</tabstop>
<tabstop>checkUploadLimitAlt</tabstop>
<tabstop>checkDownloadLimitAlt</tabstop>
<tabstop>spinUploadLimitAlt</tabstop>
<tabstop>spinDownloadLimitAlt</tabstop>
<tabstop>checkLimitLocalPeerRate</tabstop>
<tabstop>checkLimitTransportOverhead</tabstop>
<tabstop>checkuTP</tabstop>
<tabstop>checkLimituTPConnections</tabstop>
<tabstop>scrollArea_4</tabstop>
<tabstop>checkDHT</tabstop>
<tabstop>checkPeX</tabstop>
<tabstop>checkLSD</tabstop>
<tabstop>comboEncryption</tabstop>
<tabstop>checkAnonymousMode</tabstop>
<tabstop>checkEnableQueueing</tabstop>
<tabstop>spinMaxActiveDownloads</tabstop>
<tabstop>spinMaxActiveUploads</tabstop>
<tabstop>spinMaxActiveTorrents</tabstop>
<tabstop>checkIgnoreSlowTorrentsForQueueing</tabstop>
<tabstop>checkMaxRatio</tabstop>
<tabstop>spinMaxRatio</tabstop>
<tabstop>spinWebUiPort</tabstop>
<tabstop>textWebUiUsername</tabstop>
<tabstop>textWebUiPassword</tabstop>
<tabstop>checkMaxSeedingMinutes</tabstop>
<tabstop>spinMaxSeedingMinutes</tabstop>
<tabstop>comboRatioLimitAct</tabstop>
<tabstop>checkWebUIUPnP</tabstop>
<tabstop>checkWebUiHttps</tabstop>
<tabstop>btnWebUiCrt</tabstop>
<tabstop>btnWebUiKey</tabstop>
<tabstop>checkBypassLocalAuth</tabstop>
<tabstop>checkDynDNS</tabstop>
<tabstop>comboDNSService</tabstop>
<tabstop>registerDNSBtn</tabstop>
<tabstop>domainNameTxt</tabstop>
<tabstop>DNSUsernameTxt</tabstop>
<tabstop>DNSPasswordTxt</tabstop>
</tabstops>
<resources>
<include location="../icons.qrc"/>
@@ -3131,9 +3322,9 @@
</hints>
</connection>
<connection>
<sender>checkMaxRatio</sender>
<sender>checkMaxUploads</sender>
<signal>toggled(bool)</signal>
<receiver>spinMaxRatio</receiver>
<receiver>spinMaxUploads</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
@@ -3147,9 +3338,9 @@
</hints>
</connection>
<connection>
<sender>checkMaxRatio</sender>
<sender>checkDownloadLimitAlt</sender>
<signal>toggled(bool)</signal>
<receiver>comboRatioLimitAct</receiver>
<receiver>spinDownloadLimitAlt</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
@@ -3163,9 +3354,9 @@
</hints>
</connection>
<connection>
<sender>checkMaxUploads</sender>
<sender>checkUploadLimitAlt</sender>
<signal>toggled(bool)</signal>
<receiver>spinMaxUploads</receiver>
<receiver>spinUploadLimitAlt</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
@@ -3179,9 +3370,9 @@
</hints>
</connection>
<connection>
<sender>checkDownloadLimitAlt</sender>
<sender>checkMaxRatio</sender>
<signal>toggled(bool)</signal>
<receiver>spinDownloadLimitAlt</receiver>
<receiver>spinMaxRatio</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
@@ -3195,9 +3386,9 @@
</hints>
</connection>
<connection>
<sender>checkUploadLimitAlt</sender>
<sender>checkMaxSeedingMinutes</sender>
<signal>toggled(bool)</signal>
<receiver>spinUploadLimitAlt</receiver>
<receiver>spinMaxSeedingMinutes</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">

View File

@@ -169,7 +169,7 @@ void TorrentCreatorDlg::handleCreationSuccess(QString path, QString branch_path)
BitTorrent::AddTorrentParams params;
params.savePath = branch_path;
params.skipChecking = true;
params.ignoreShareRatio = checkIgnoreShareLimits->isChecked();
params.ignoreShareLimits = checkIgnoreShareLimits->isChecked();
BitTorrent::Session::instance()->addTorrent(t, params);
}

View File

@@ -487,16 +487,24 @@ void TransferListWidget::setMaxRatioSelectedTorrents()
if (torrents.isEmpty()) return;
bool useGlobalValue = true;
qreal currentMaxRatio = BitTorrent::Session::instance()->globalMaxRatio();;
qreal currentMaxRatio = BitTorrent::Session::instance()->globalMaxRatio();
if (torrents.count() == 1)
currentMaxRatio = torrents[0]->maxRatio(&useGlobalValue);
UpDownRatioDlg dlg(useGlobalValue, currentMaxRatio, BitTorrent::TorrentHandle::MAX_RATIO, this);
int currentMaxSeedingTime = BitTorrent::Session::instance()->globalMaxSeedingMinutes();
if (torrents.count() == 1)
currentMaxSeedingTime = torrents[0]->maxSeedingTime(&useGlobalValue);
UpDownRatioDlg dlg(useGlobalValue, currentMaxRatio, BitTorrent::TorrentHandle::MAX_RATIO,
currentMaxSeedingTime, BitTorrent::TorrentHandle::MAX_SEEDING_TIME, this);
if (dlg.exec() != QDialog::Accepted) return;
foreach (BitTorrent::TorrentHandle *const torrent, torrents) {
qreal ratio = (dlg.useDefault() ? BitTorrent::TorrentHandle::USE_GLOBAL_RATIO : dlg.ratio());
torrent->setRatioLimit(ratio);
int seedingTime = (dlg.useDefault() ? BitTorrent::TorrentHandle::USE_GLOBAL_SEEDING_TIME : dlg.seedingTime());
torrent->setSeedingTimeLimit(seedingTime);
}
}

View File

@@ -30,11 +30,15 @@
#include "updownratiodlg.h"
#include <QMessageBox>
#include "base/bittorrent/session.h"
#include "ui_updownratiodlg.h"
UpDownRatioDlg::UpDownRatioDlg(bool useDefault, qreal initialValue,
qreal maxValue, QWidget *parent)
UpDownRatioDlg::UpDownRatioDlg(bool useDefault, qreal initialRatioValue,
qreal maxRatioValue, int initialTimeValue,
int maxTimeValue, QWidget *parent)
: QDialog(parent)
, ui(new Ui::UpDownRatioDlg)
{
@@ -43,21 +47,45 @@ UpDownRatioDlg::UpDownRatioDlg(bool useDefault, qreal initialValue,
if (useDefault) {
ui->useDefaultButton->setChecked(true);
}
else if (initialValue == -1) {
else if ((initialRatioValue == -1) && (initialTimeValue == -1)) {
ui->noLimitButton->setChecked(true);
initialValue = BitTorrent::Session::instance()->globalMaxRatio();
initialRatioValue = BitTorrent::Session::instance()->globalMaxRatio();
initialTimeValue = BitTorrent::Session::instance()->globalMaxSeedingMinutes();
}
else {
ui->torrentLimitButton->setChecked(true);
if (initialRatioValue >= 0)
ui->checkMaxRatio->setChecked(true);
if (initialTimeValue >= 0)
ui->checkMaxTime->setChecked(true);
}
ui->ratioSpinBox->setMinimum(0);
ui->ratioSpinBox->setMaximum(maxValue);
ui->ratioSpinBox->setValue(initialValue);
ui->ratioSpinBox->setMaximum(maxRatioValue);
ui->ratioSpinBox->setValue(initialRatioValue);
ui->timeSpinBox->setMinimum(0);
ui->timeSpinBox->setMaximum(maxTimeValue);
ui->timeSpinBox->setValue(initialTimeValue);
connect(ui->buttonGroup, SIGNAL(buttonClicked(int)), SLOT(handleRatioTypeChanged()));
connect(ui->checkMaxRatio, SIGNAL(toggled(bool)), this, SLOT(enableRatioSpin()));
connect(ui->checkMaxTime, SIGNAL(toggled(bool)), this, SLOT(enableTimeSpin()));
handleRatioTypeChanged();
}
void UpDownRatioDlg::accept()
{
if (ui->torrentLimitButton->isChecked() && !ui->checkMaxRatio->isChecked() && !ui->checkMaxTime->isChecked())
QMessageBox::critical(this, tr("No share limit method selected"),
tr("Please select a limit method first"));
else
QDialog::accept();
}
bool UpDownRatioDlg::useDefault() const
{
return ui->useDefaultButton->isChecked();
@@ -65,12 +93,32 @@ bool UpDownRatioDlg::useDefault() const
qreal UpDownRatioDlg::ratio() const
{
return ui->noLimitButton->isChecked() ? -1 : ui->ratioSpinBox->value();
return (ui->noLimitButton->isChecked() || !ui->checkMaxRatio->isChecked()) ? -1 : ui->ratioSpinBox->value();
}
int UpDownRatioDlg::seedingTime() const
{
return (ui->noLimitButton->isChecked() || !ui->checkMaxTime->isChecked()) ? -1 : ui->timeSpinBox->value();
}
void UpDownRatioDlg::handleRatioTypeChanged()
{
ui->ratioSpinBox->setEnabled(ui->torrentLimitButton->isChecked());
// ui->ratioSpinBox->setEnabled(ui->torrentLimitButton->isChecked());
ui->checkMaxRatio->setEnabled(ui->torrentLimitButton->isChecked());
ui->checkMaxTime->setEnabled(ui->torrentLimitButton->isChecked());
ui->ratioSpinBox->setEnabled(ui->torrentLimitButton->isChecked() && ui->checkMaxRatio->isChecked());
ui->timeSpinBox->setEnabled(ui->torrentLimitButton->isChecked() && ui->checkMaxTime->isChecked());
}
void UpDownRatioDlg::enableRatioSpin()
{
ui->ratioSpinBox->setEnabled(ui->checkMaxRatio->isChecked());
}
void UpDownRatioDlg::enableTimeSpin()
{
ui->timeSpinBox->setEnabled(ui->checkMaxTime->isChecked());
}
UpDownRatioDlg::~UpDownRatioDlg()

View File

@@ -45,14 +45,21 @@ class UpDownRatioDlg : public QDialog
public:
explicit UpDownRatioDlg(bool useDefault, qreal initialValue, qreal maxValue,
int initialTimeValue, int maxTimeValue,
QWidget *parent = 0);
~UpDownRatioDlg();
bool useDefault() const;
qreal ratio() const;
int seedingTime() const;
public slots:
void accept();
private slots:
void handleRatioTypeChanged();
void enableRatioSpin();
void enableTimeSpin();
private:
Ui::UpDownRatioDlg *ui;

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>317</width>
<height>152</height>
<width>399</width>
<height>195</height>
</rect>
</property>
<property name="windowTitle">
@@ -17,7 +17,7 @@
<item>
<widget class="QRadioButton" name="useDefaultButton">
<property name="text">
<string>Use global ratio limit</string>
<string>Use global share limit</string>
</property>
<attribute name="buttonGroup">
<string>buttonGroup</string>
@@ -27,7 +27,7 @@
<item>
<widget class="QRadioButton" name="noLimitButton">
<property name="text">
<string>Set no ratio limit</string>
<string>Set no share limit</string>
</property>
<attribute name="buttonGroup">
<string>buttonGroup</string>
@@ -35,18 +35,18 @@
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QRadioButton" name="torrentLimitButton">
<property name="text">
<string>Set ratio limit to</string>
<string>Set share limit to</string>
</property>
<attribute name="buttonGroup">
<string>buttonGroup</string>
</attribute>
</widget>
</item>
<item>
<item row="0" column="2">
<widget class="QDoubleSpinBox" name="ratioSpinBox">
<property name="maximum">
<double>9998.000000000000000</double>
@@ -59,7 +59,29 @@
</property>
</widget>
</item>
<item>
<item row="2" column="2">
<widget class="QDoubleSpinBox" name="timeSpinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="decimals">
<number>0</number>
</property>
<property name="maximum">
<double>525600.000000000000000</double>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
</property>
<property name="value">
<double>1440.000000000000000</double>
</property>
</widget>
</item>
<item row="2" column="3">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@@ -72,6 +94,20 @@
</property>
</spacer>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="checkMaxRatio">
<property name="text">
<string>ratio</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="checkMaxTime">
<property name="text">
<string>minutes</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
@@ -135,6 +171,7 @@
</connection>
</connections>
<buttongroups>
<buttongroup name="shareButtonGroup"/>
<buttongroup name="buttonGroup"/>
</buttongroups>
</ui>