Implement gateway for adding new torrents

PR #19355.
This commit is contained in:
Vladimir Golovnev 2023-08-14 18:17:56 +03:00 committed by GitHub
parent e4313d6651
commit dcf3e97291
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
42 changed files with 933 additions and 639 deletions

View file

@ -2086,6 +2086,50 @@ void Preferences::setSpeedWidgetGraphEnable(const int id, const bool enable)
setValue(u"SpeedWidget/graph_enable_%1"_s.arg(id), enable);
}
bool Preferences::isAddNewTorrentDialogEnabled() const
{
return value(u"AddNewTorrentDialog/Enabled"_s, true);
}
void Preferences::setAddNewTorrentDialogEnabled(const bool value)
{
if (value == isAddNewTorrentDialogEnabled())
return;
setValue(u"AddNewTorrentDialog/Enabled"_s, value);
}
bool Preferences::isAddNewTorrentDialogTopLevel() const
{
return value(u"AddNewTorrentDialog/TopLevel"_s, true);
}
void Preferences::setAddNewTorrentDialogTopLevel(const bool value)
{
if (value == isAddNewTorrentDialogTopLevel())
return;
setValue(u"AddNewTorrentDialog/TopLevel"_s, value);
}
int Preferences::addNewTorrentDialogSavePathHistoryLength() const
{
const int defaultHistoryLength = 8;
const int val = value(u"AddNewTorrentDialog/SavePathHistoryLength"_s, defaultHistoryLength);
return std::clamp(val, 0, 99);
}
void Preferences::setAddNewTorrentDialogSavePathHistoryLength(const int value)
{
const int clampedValue = qBound(0, value, 99);
const int oldValue = addNewTorrentDialogSavePathHistoryLength();
if (clampedValue == oldValue)
return;
setValue(u"AddNewTorrentDialog/SavePathHistoryLength"_s, clampedValue);
}
void Preferences::apply()
{
if (SettingsStorage::instance()->save())