mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-29 05:48:47 +03:00
Merge pull request #9161 from Chocobo1/save
Revise resume data save interval
This commit is contained in:
commit
553bd8e22c
5 changed files with 39 additions and 19 deletions
|
@ -330,7 +330,7 @@ Session::Session(QObject *parent)
|
||||||
, m_altGlobalUploadSpeedLimit(BITTORRENT_SESSION_KEY("AlternativeGlobalUPSpeedLimit"), 10, lowerLimited(0))
|
, m_altGlobalUploadSpeedLimit(BITTORRENT_SESSION_KEY("AlternativeGlobalUPSpeedLimit"), 10, lowerLimited(0))
|
||||||
, m_isAltGlobalSpeedLimitEnabled(BITTORRENT_SESSION_KEY("UseAlternativeGlobalSpeedLimit"), false)
|
, m_isAltGlobalSpeedLimitEnabled(BITTORRENT_SESSION_KEY("UseAlternativeGlobalSpeedLimit"), false)
|
||||||
, m_isBandwidthSchedulerEnabled(BITTORRENT_SESSION_KEY("BandwidthSchedulerEnabled"), false)
|
, m_isBandwidthSchedulerEnabled(BITTORRENT_SESSION_KEY("BandwidthSchedulerEnabled"), false)
|
||||||
, m_saveResumeDataInterval(BITTORRENT_SESSION_KEY("SaveResumeDataInterval"), 3)
|
, m_saveResumeDataInterval(BITTORRENT_SESSION_KEY("SaveResumeDataInterval"), 60)
|
||||||
, m_port(BITTORRENT_SESSION_KEY("Port"), 8999)
|
, m_port(BITTORRENT_SESSION_KEY("Port"), 8999)
|
||||||
, m_useRandomPort(BITTORRENT_SESSION_KEY("UseRandomPort"), false)
|
, m_useRandomPort(BITTORRENT_SESSION_KEY("UseRandomPort"), false)
|
||||||
, m_networkInterface(BITTORRENT_SESSION_KEY("Interface"))
|
, m_networkInterface(BITTORRENT_SESSION_KEY("Interface"))
|
||||||
|
@ -510,11 +510,6 @@ Session::Session(QObject *parent)
|
||||||
connect(m_refreshTimer, &QTimer::timeout, this, &Session::refresh);
|
connect(m_refreshTimer, &QTimer::timeout, this, &Session::refresh);
|
||||||
m_refreshTimer->start();
|
m_refreshTimer->start();
|
||||||
|
|
||||||
// Regular saving of fastresume data
|
|
||||||
m_resumeDataTimer = new QTimer(this);
|
|
||||||
m_resumeDataTimer->setInterval(saveResumeDataInterval() * 60 * 1000);
|
|
||||||
connect(m_resumeDataTimer, &QTimer::timeout, this, [this]() { generateResumeData(); });
|
|
||||||
|
|
||||||
m_statistics = new Statistics(this);
|
m_statistics = new Statistics(this);
|
||||||
|
|
||||||
updateSeedingLimitTimer();
|
updateSeedingLimitTimer();
|
||||||
|
@ -536,7 +531,15 @@ Session::Session(QObject *parent)
|
||||||
m_resumeDataSavingManager->moveToThread(m_ioThread);
|
m_resumeDataSavingManager->moveToThread(m_ioThread);
|
||||||
connect(m_ioThread, &QThread::finished, m_resumeDataSavingManager, &QObject::deleteLater);
|
connect(m_ioThread, &QThread::finished, m_resumeDataSavingManager, &QObject::deleteLater);
|
||||||
m_ioThread->start();
|
m_ioThread->start();
|
||||||
m_resumeDataTimer->start();
|
|
||||||
|
// Regular saving of fastresume data
|
||||||
|
m_resumeDataTimer = new QTimer(this);
|
||||||
|
connect(m_resumeDataTimer, &QTimer::timeout, this, [this]() { generateResumeData(); });
|
||||||
|
const uint saveInterval = saveResumeDataInterval();
|
||||||
|
if (saveInterval > 0) {
|
||||||
|
m_resumeDataTimer->setInterval(saveInterval * 60 * 1000);
|
||||||
|
m_resumeDataTimer->start();
|
||||||
|
}
|
||||||
|
|
||||||
// initialize PortForwarder instance
|
// initialize PortForwarder instance
|
||||||
Net::PortForwarder::initInstance(m_nativeSession);
|
Net::PortForwarder::initInstance(m_nativeSession);
|
||||||
|
@ -2704,11 +2707,19 @@ uint Session::saveResumeDataInterval() const
|
||||||
return m_saveResumeDataInterval;
|
return m_saveResumeDataInterval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::setSaveResumeDataInterval(uint value)
|
void Session::setSaveResumeDataInterval(const uint value)
|
||||||
{
|
{
|
||||||
if (value != saveResumeDataInterval()) {
|
if (value == m_saveResumeDataInterval)
|
||||||
m_saveResumeDataInterval = value;
|
return;
|
||||||
|
|
||||||
|
m_saveResumeDataInterval = value;
|
||||||
|
|
||||||
|
if (value > 0) {
|
||||||
m_resumeDataTimer->setInterval(value * 60 * 1000);
|
m_resumeDataTimer->setInterval(value * 60 * 1000);
|
||||||
|
m_resumeDataTimer->start();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_resumeDataTimer->stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -450,8 +450,6 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
<resources>
|
<resources/>
|
||||||
<include location="../icons.qrc"/>
|
|
||||||
</resources>
|
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
|
|
||||||
#include "advancedsettings.h"
|
#include "advancedsettings.h"
|
||||||
|
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QHostAddress>
|
#include <QHostAddress>
|
||||||
|
@ -129,6 +131,8 @@ AdvancedSettings::AdvancedSettings(QWidget *parent)
|
||||||
, this, &AdvancedSettings::updateCacheSpinSuffix);
|
, this, &AdvancedSettings::updateCacheSpinSuffix);
|
||||||
connect(&comboBoxInterface, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged)
|
connect(&comboBoxInterface, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged)
|
||||||
, this, &AdvancedSettings::updateInterfaceAddressCombo);
|
, this, &AdvancedSettings::updateInterfaceAddressCombo);
|
||||||
|
connect(&spinBoxSaveResumeDataInterval, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged)
|
||||||
|
, this, &AdvancedSettings::updateSaveResumeDataIntervalSuffix);
|
||||||
// Load settings
|
// Load settings
|
||||||
loadAdvancedSettings();
|
loadAdvancedSettings();
|
||||||
resizeColumnToContents(0);
|
resizeColumnToContents(0);
|
||||||
|
@ -241,6 +245,14 @@ void AdvancedSettings::updateCacheSpinSuffix(int value)
|
||||||
spinBoxCache.setSuffix(tr(" MiB"));
|
spinBoxCache.setSuffix(tr(" MiB"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AdvancedSettings::updateSaveResumeDataIntervalSuffix(const int value)
|
||||||
|
{
|
||||||
|
if (value > 0)
|
||||||
|
spinBoxSaveResumeDataInterval.setSuffix(tr(" min", " minutes"));
|
||||||
|
else
|
||||||
|
spinBoxSaveResumeDataInterval.setSuffix(tr(" (disabled)"));
|
||||||
|
}
|
||||||
|
|
||||||
void AdvancedSettings::updateInterfaceAddressCombo()
|
void AdvancedSettings::updateInterfaceAddressCombo()
|
||||||
{
|
{
|
||||||
// Try to get the currently selected interface name
|
// Try to get the currently selected interface name
|
||||||
|
@ -346,10 +358,10 @@ void AdvancedSettings::loadAdvancedSettings()
|
||||||
spinBoxSendBufferWatermarkFactor.setValue(session->sendBufferWatermarkFactor());
|
spinBoxSendBufferWatermarkFactor.setValue(session->sendBufferWatermarkFactor());
|
||||||
addRow(SEND_BUF_WATERMARK_FACTOR, tr("Send buffer watermark factor"), &spinBoxSendBufferWatermarkFactor);
|
addRow(SEND_BUF_WATERMARK_FACTOR, tr("Send buffer watermark factor"), &spinBoxSendBufferWatermarkFactor);
|
||||||
// Save resume data interval
|
// Save resume data interval
|
||||||
spinBoxSaveResumeDataInterval.setMinimum(1);
|
spinBoxSaveResumeDataInterval.setMinimum(0);
|
||||||
spinBoxSaveResumeDataInterval.setMaximum(1440);
|
spinBoxSaveResumeDataInterval.setMaximum(std::numeric_limits<int>::max());
|
||||||
spinBoxSaveResumeDataInterval.setValue(session->saveResumeDataInterval());
|
spinBoxSaveResumeDataInterval.setValue(session->saveResumeDataInterval());
|
||||||
spinBoxSaveResumeDataInterval.setSuffix(tr(" m", " minutes"));
|
updateSaveResumeDataIntervalSuffix(spinBoxSaveResumeDataInterval.value());
|
||||||
addRow(SAVE_RESUME_DATA_INTERVAL, tr("Save resume data interval", "How often the fastresume file is saved."), &spinBoxSaveResumeDataInterval);
|
addRow(SAVE_RESUME_DATA_INTERVAL, tr("Save resume data interval", "How often the fastresume file is saved."), &spinBoxSaveResumeDataInterval);
|
||||||
// Outgoing port Min
|
// Outgoing port Min
|
||||||
spinBoxOutgoingPortsMin.setMinimum(0);
|
spinBoxOutgoingPortsMin.setMinimum(0);
|
||||||
|
|
|
@ -51,6 +51,7 @@ signals:
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updateCacheSpinSuffix(int value);
|
void updateCacheSpinSuffix(int value);
|
||||||
|
void updateSaveResumeDataIntervalSuffix(int value);
|
||||||
void updateInterfaceAddressCombo();
|
void updateInterfaceAddressCombo();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -3460,9 +3460,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.</string>
|
||||||
<tabstop>DNSUsernameTxt</tabstop>
|
<tabstop>DNSUsernameTxt</tabstop>
|
||||||
<tabstop>DNSPasswordTxt</tabstop>
|
<tabstop>DNSPasswordTxt</tabstop>
|
||||||
</tabstops>
|
</tabstops>
|
||||||
<resources>
|
<resources/>
|
||||||
<include location="../icons.qrc"/>
|
|
||||||
</resources>
|
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
<connection>
|
||||||
<sender>checkUploadLimit</sender>
|
<sender>checkUploadLimit</sender>
|
||||||
|
|
Loading…
Reference in a new issue