mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-30 11:38:50 -07:00
Merge pull request #14121 from Chocobo1/settingsStorage
Improve load data behavior of SettingsStorage class
This commit is contained in:
commit
586bdc0567
12 changed files with 92 additions and 67 deletions
|
@ -120,7 +120,7 @@ AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::AddTorrentParams &inP
|
|||
populateSavePathComboBox();
|
||||
connect(m_ui->savePath, &FileSystemPathEdit::selectedPathChanged, this, &AddNewTorrentDialog::onSavePathChanged);
|
||||
|
||||
const bool rememberLastSavePath = settings()->loadValue(KEY_REMEMBERLASTSAVEPATH, false).toBool();
|
||||
const bool rememberLastSavePath = settings()->loadValue(KEY_REMEMBERLASTSAVEPATH, false);
|
||||
m_ui->checkBoxRememberLastSavePath->setChecked(rememberLastSavePath);
|
||||
|
||||
m_ui->contentLayoutComboBox->setCurrentIndex(
|
||||
|
@ -135,7 +135,7 @@ AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::AddTorrentParams &inP
|
|||
// Load categories
|
||||
QStringList categories = session->categories().keys();
|
||||
std::sort(categories.begin(), categories.end(), Utils::String::naturalLessThan<Qt::CaseInsensitive>);
|
||||
QString defaultCategory = settings()->loadValue(KEY_DEFAULTCATEGORY).toString();
|
||||
auto defaultCategory = settings()->loadValue<QString>(KEY_DEFAULTCATEGORY);
|
||||
|
||||
if (!m_torrentParams.category.isEmpty())
|
||||
m_ui->categoryComboBox->addItem(m_torrentParams.category);
|
||||
|
@ -170,7 +170,7 @@ AddNewTorrentDialog::~AddNewTorrentDialog()
|
|||
|
||||
bool AddNewTorrentDialog::isEnabled()
|
||||
{
|
||||
return SettingsStorage::instance()->loadValue(KEY_ENABLED, true).toBool();
|
||||
return SettingsStorage::instance()->loadValue(KEY_ENABLED, true);
|
||||
}
|
||||
|
||||
void AddNewTorrentDialog::setEnabled(bool value)
|
||||
|
@ -180,7 +180,7 @@ void AddNewTorrentDialog::setEnabled(bool value)
|
|||
|
||||
bool AddNewTorrentDialog::isTopLevel()
|
||||
{
|
||||
return SettingsStorage::instance()->loadValue(KEY_TOPLEVEL, true).toBool();
|
||||
return SettingsStorage::instance()->loadValue(KEY_TOPLEVEL, true);
|
||||
}
|
||||
|
||||
void AddNewTorrentDialog::setTopLevel(bool value)
|
||||
|
@ -191,7 +191,7 @@ void AddNewTorrentDialog::setTopLevel(bool value)
|
|||
int AddNewTorrentDialog::savePathHistoryLength()
|
||||
{
|
||||
const int defaultHistoryLength = 8;
|
||||
const int value = settings()->loadValue(KEY_SAVEPATHHISTORYLENGTH, defaultHistoryLength).toInt();
|
||||
const int value = settings()->loadValue(KEY_SAVEPATHHISTORYLENGTH, defaultHistoryLength);
|
||||
return qBound(minPathHistoryLength, value, maxPathHistoryLength);
|
||||
}
|
||||
|
||||
|
@ -204,14 +204,14 @@ void AddNewTorrentDialog::setSavePathHistoryLength(int value)
|
|||
|
||||
settings()->storeValue(KEY_SAVEPATHHISTORYLENGTH, clampedValue);
|
||||
settings()->storeValue(KEY_SAVEPATHHISTORY
|
||||
, QStringList(settings()->loadValue(KEY_SAVEPATHHISTORY).toStringList().mid(0, clampedValue)));
|
||||
, QStringList(settings()->loadValue<QStringList>(KEY_SAVEPATHHISTORY).mid(0, clampedValue)));
|
||||
}
|
||||
|
||||
void AddNewTorrentDialog::loadState()
|
||||
{
|
||||
Utils::Gui::resize(this, m_storeDialogSize);
|
||||
m_ui->splitter->restoreState(m_storeSplitterState);
|
||||
m_headerState = settings()->loadValue(KEY_TREEHEADERSTATE).toByteArray();
|
||||
m_headerState = settings()->loadValue<QByteArray>(KEY_TREEHEADERSTATE);
|
||||
}
|
||||
|
||||
void AddNewTorrentDialog::saveState()
|
||||
|
@ -371,7 +371,7 @@ void AddNewTorrentDialog::showEvent(QShowEvent *event)
|
|||
void AddNewTorrentDialog::saveSavePathHistory() const
|
||||
{
|
||||
// Get current history
|
||||
QStringList history = settings()->loadValue(KEY_SAVEPATHHISTORY).toStringList();
|
||||
auto history = settings()->loadValue<QStringList>(KEY_SAVEPATHHISTORY);
|
||||
QVector<QDir> historyDirs;
|
||||
for (const QString &path : asConst(history))
|
||||
historyDirs << QDir {path};
|
||||
|
@ -489,11 +489,11 @@ void AddNewTorrentDialog::populateSavePathComboBox()
|
|||
m_ui->savePath->clear();
|
||||
|
||||
// Load save path history
|
||||
const QStringList savePathHistory {settings()->loadValue(KEY_SAVEPATHHISTORY).toStringList()};
|
||||
const auto savePathHistory {settings()->loadValue<QStringList>(KEY_SAVEPATHHISTORY)};
|
||||
for (const QString &savePath : savePathHistory)
|
||||
m_ui->savePath->addItem(savePath);
|
||||
|
||||
const bool rememberLastSavePath {settings()->loadValue(KEY_REMEMBERLASTSAVEPATH, false).toBool()};
|
||||
const bool rememberLastSavePath {settings()->loadValue(KEY_REMEMBERLASTSAVEPATH, false)};
|
||||
const QString defSavePath {BitTorrent::Session::instance()->defaultSavePath()};
|
||||
|
||||
if (!m_torrentParams.savePath.isEmpty())
|
||||
|
|
|
@ -61,9 +61,9 @@ CookiesDialog::CookiesDialog(QWidget *parent)
|
|||
m_cookiesModel->index(0, 0),
|
||||
QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
|
||||
|
||||
Utils::Gui::resize(this, SettingsStorage::instance()->loadValue(KEY_SIZE).toSize());
|
||||
Utils::Gui::resize(this, SettingsStorage::instance()->loadValue<QSize>(KEY_SIZE));
|
||||
m_ui->treeView->header()->restoreState(
|
||||
SettingsStorage::instance()->loadValue(KEY_COOKIESVIEWSTATE).toByteArray());
|
||||
SettingsStorage::instance()->loadValue<QByteArray>(KEY_COOKIESVIEWSTATE));
|
||||
}
|
||||
|
||||
CookiesDialog::~CookiesDialog()
|
||||
|
|
|
@ -489,7 +489,7 @@ MainWindow::~MainWindow()
|
|||
|
||||
bool MainWindow::isExecutionLogEnabled() const
|
||||
{
|
||||
return settings()->loadValue(KEY_EXECUTIONLOG_ENABLED, false).toBool();
|
||||
return settings()->loadValue(KEY_EXECUTIONLOG_ENABLED, false);
|
||||
}
|
||||
|
||||
void MainWindow::setExecutionLogEnabled(bool value)
|
||||
|
@ -501,7 +501,7 @@ int MainWindow::executionLogMsgTypes() const
|
|||
{
|
||||
// as default value we need all the bits set
|
||||
// -1 is considered the portable way to achieve that
|
||||
return settings()->loadValue(KEY_EXECUTIONLOG_TYPES, -1).toInt();
|
||||
return settings()->loadValue(KEY_EXECUTIONLOG_TYPES, -1);
|
||||
}
|
||||
|
||||
void MainWindow::setExecutionLogMsgTypes(const int value)
|
||||
|
@ -512,7 +512,7 @@ void MainWindow::setExecutionLogMsgTypes(const int value)
|
|||
|
||||
bool MainWindow::isNotificationsEnabled() const
|
||||
{
|
||||
return settings()->loadValue(KEY_NOTIFICATIONS_ENABLED, true).toBool();
|
||||
return settings()->loadValue(KEY_NOTIFICATIONS_ENABLED, true);
|
||||
}
|
||||
|
||||
void MainWindow::setNotificationsEnabled(bool value)
|
||||
|
@ -522,7 +522,7 @@ void MainWindow::setNotificationsEnabled(bool value)
|
|||
|
||||
bool MainWindow::isTorrentAddedNotificationsEnabled() const
|
||||
{
|
||||
return settings()->loadValue(KEY_NOTIFICATIONS_TORRENTADDED, false).toBool();
|
||||
return settings()->loadValue(KEY_NOTIFICATIONS_TORRENTADDED, false);
|
||||
}
|
||||
|
||||
void MainWindow::setTorrentAddedNotificationsEnabled(bool value)
|
||||
|
@ -532,7 +532,7 @@ void MainWindow::setTorrentAddedNotificationsEnabled(bool value)
|
|||
|
||||
bool MainWindow::isDownloadTrackerFavicon() const
|
||||
{
|
||||
return settings()->loadValue(KEY_DOWNLOAD_TRACKER_FAVICON, false).toBool();
|
||||
return settings()->loadValue(KEY_DOWNLOAD_TRACKER_FAVICON, false);
|
||||
}
|
||||
|
||||
void MainWindow::setDownloadTrackerFavicon(bool value)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue