Enable customizing the save statistics time interval

This change extends the Advanced section of the Preferences menu with a new field, allowing changing the time statistics save interval. A zero value will prevent recurrent saving.

This aims to provide the feature requested in issue #21285.

PR #21291.
This commit is contained in:
Burnerelu
2024-09-16 12:16:59 +03:00
committed by GitHub
parent 0ea35c54a3
commit e06b7f8f4d
7 changed files with 50 additions and 5 deletions

View File

@@ -364,6 +364,8 @@ void AppController::preferencesAction()
data[u"current_interface_address"_s] = session->networkInterfaceAddress();
// Save resume data interval
data[u"save_resume_data_interval"_s] = session->saveResumeDataInterval();
// Save statistics interval
data[u"save_statistics_interval"_s] = static_cast<int>(session->saveStatisticsInterval().count());
// .torrent file size limit
data[u"torrent_file_size_limit"_s] = pref->getTorrentFileSizeLimit();
// Recheck completed torrents
@@ -969,6 +971,9 @@ void AppController::setPreferencesAction()
// Save resume data interval
if (hasKey(u"save_resume_data_interval"_s))
session->setSaveResumeDataInterval(it.value().toInt());
// Save statistics interval
if (hasKey(u"save_statistics_interval"_s))
session->setSaveStatisticsInterval(std::chrono::minutes(it.value().toInt()));
// .torrent file size limit
if (hasKey(u"torrent_file_size_limit"_s))
pref->setTorrentFileSizeLimit(it.value().toLongLong());

View File

@@ -1152,6 +1152,14 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
<input type="text" id="saveResumeDataInterval" style="width: 15em;">&nbsp;&nbsp;QBT_TR(min)QBT_TR[CONTEXT=OptionsDialog]
</td>
</tr>
<tr>
<td>
<label for="saveStatisticsInterval">QBT_TR(Save statistics interval:)QBT_TR[CONTEXT=OptionsDialog]</label>
</td>
<td>
<input type="text" id="saveStatisticsInterval" style="width: 15em;">&nbsp;&nbsp;QBT_TR(min)QBT_TR[CONTEXT=OptionsDialog]
</td>
</tr>
<tr>
<td>
<label for="torrentFileSizeLimit">QBT_TR(.torrent file size limit:)QBT_TR[CONTEXT=OptionsDialog]</label>
@@ -2454,6 +2462,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
updateNetworkInterfaces(pref.current_network_interface, pref.current_interface_name);
updateInterfaceAddresses(pref.current_network_interface, pref.current_interface_address);
$("saveResumeDataInterval").value = pref.save_resume_data_interval;
$("saveStatisticsInterval").value = pref.save_statistics_interval;
$("torrentFileSizeLimit").value = (pref.torrent_file_size_limit / 1024 / 1024);
$("recheckTorrentsOnCompletion").checked = pref.recheck_completed_torrents;
$("appInstanceName").value = pref.app_instance_name;
@@ -2909,6 +2918,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
settings["current_network_interface"] = $("networkInterface").value;
settings["current_interface_address"] = $("optionalIPAddressToBind").value;
settings["save_resume_data_interval"] = Number($("saveResumeDataInterval").value);
settings["save_statistics_interval"] = Number($("saveStatisticsInterval").value);
settings["torrent_file_size_limit"] = ($("torrentFileSizeLimit").value * 1024 * 1024);
settings["recheck_completed_torrents"] = $("recheckTorrentsOnCompletion").checked;
settings["app_instance_name"] = $("appInstanceName").value;