From 3508a79cd68dce1c21d5f71514373055a4451517 Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Thu, 16 Jun 2011 16:03:25 +0300 Subject: [PATCH] GUI: Cleanup settings usage. Use local QSettings instead of the one created by MainWindow. --- gui/applicationlist.cpp | 23 ++++++++++++----------- gui/applicationlist.h | 6 ++---- gui/mainwindow.cpp | 4 ++-- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/gui/applicationlist.cpp b/gui/applicationlist.cpp index eacb00be3..9b79d381b 100644 --- a/gui/applicationlist.cpp +++ b/gui/applicationlist.cpp @@ -39,13 +39,13 @@ ApplicationList::~ApplicationList() Clear(); } -bool ApplicationList::LoadSettings(QSettings *programSettings) +bool ApplicationList::LoadSettings() { - - QStringList names = programSettings->value(SETTINGS_APPLICATION_NAMES, QStringList()).toStringList(); - QStringList paths = programSettings->value(SETTINGS_APPLICATION_PATHS, QStringList()).toStringList(); - QStringList params = programSettings->value(SETTINGS_APPLICATION_PARAMS, QStringList()).toStringList(); - int defapp = programSettings->value(SETTINGS_APPLICATION_DEFAULT, -1).toInt(); + QSettings settings; + QStringList names = settings.value(SETTINGS_APPLICATION_NAMES, QStringList()).toStringList(); + QStringList paths = settings.value(SETTINGS_APPLICATION_PATHS, QStringList()).toStringList(); + QStringList params = settings.value(SETTINGS_APPLICATION_PARAMS, QStringList()).toStringList(); + int defapp = settings.value(SETTINGS_APPLICATION_DEFAULT, -1).toInt(); // Params will be empty first time starting with the new setting. // Return false and inform user about problem with application settings. @@ -110,8 +110,9 @@ bool ApplicationList::LoadSettings(QSettings *programSettings) return succeeded; } -void ApplicationList::SaveSettings(QSettings *programSettings) +void ApplicationList::SaveSettings() { + QSettings settings; QStringList names; QStringList paths; QStringList params; @@ -124,10 +125,10 @@ void ApplicationList::SaveSettings(QSettings *programSettings) params << app.getParameters(); } - programSettings->setValue(SETTINGS_APPLICATION_NAMES, names); - programSettings->setValue(SETTINGS_APPLICATION_PATHS, paths); - programSettings->setValue(SETTINGS_APPLICATION_PARAMS, params); - programSettings->setValue(SETTINGS_APPLICATION_DEFAULT, mDefaultApplicationIndex); + settings.setValue(SETTINGS_APPLICATION_NAMES, names); + settings.setValue(SETTINGS_APPLICATION_PATHS, paths); + settings.setValue(SETTINGS_APPLICATION_PARAMS, params); + settings.setValue(SETTINGS_APPLICATION_DEFAULT, mDefaultApplicationIndex); } diff --git a/gui/applicationlist.h b/gui/applicationlist.h index c57051a0c..05936734f 100644 --- a/gui/applicationlist.h +++ b/gui/applicationlist.h @@ -41,18 +41,16 @@ public: /** * @brief Load all applications * - * @param programSettings QSettings to load application list from * @return true if loading succeeded, false if there is problem with * application list. Most probably because of older version settings need * to be upgraded. */ - bool LoadSettings(QSettings *programSettings); + bool LoadSettings(); /** * @brief Save all applications - * @param programSettings QSettings to save applications to */ - void SaveSettings(QSettings *programSettings); + void SaveSettings(); /** * @brief Get the amount of applications in the list diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 41bc32262..86b0e3a20 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -209,7 +209,7 @@ void MainWindow::LoadSettings() SetLanguage(mSettings->value(SETTINGS_LANGUAGE, mTranslation->SuggestLanguage()).toString()); - bool succeeded = mApplications->LoadSettings(mSettings); + bool succeeded = mApplications->LoadSettings(); if (!succeeded) { QString msg = tr("There was a problem with loading the editor application settings.\n\n" @@ -250,7 +250,7 @@ void MainWindow::SaveSettings() mSettings->setValue(SETTINGS_TOOLBARS_VIEW_SHOW, mUI.mToolBarView->isVisible()); mSettings->setValue(SETTINGS_TOOLBARS_FILTER_SHOW, mUI.mToolBarFilter->isVisible()); - mApplications->SaveSettings(mSettings); + mApplications->SaveSettings(); mSettings->setValue(SETTINGS_LANGUAGE, mTranslation->GetCurrentLanguage()); mUI.mResults->SaveSettings(mSettings);