GUI: Cleanup settings usage.
Use local QSettings instead of the one created by MainWindow.
This commit is contained in:
parent
b66b8a31cc
commit
3508a79cd6
|
@ -39,13 +39,13 @@ ApplicationList::~ApplicationList()
|
||||||
Clear();
|
Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ApplicationList::LoadSettings(QSettings *programSettings)
|
bool ApplicationList::LoadSettings()
|
||||||
{
|
{
|
||||||
|
QSettings settings;
|
||||||
QStringList names = programSettings->value(SETTINGS_APPLICATION_NAMES, QStringList()).toStringList();
|
QStringList names = settings.value(SETTINGS_APPLICATION_NAMES, QStringList()).toStringList();
|
||||||
QStringList paths = programSettings->value(SETTINGS_APPLICATION_PATHS, QStringList()).toStringList();
|
QStringList paths = settings.value(SETTINGS_APPLICATION_PATHS, QStringList()).toStringList();
|
||||||
QStringList params = programSettings->value(SETTINGS_APPLICATION_PARAMS, QStringList()).toStringList();
|
QStringList params = settings.value(SETTINGS_APPLICATION_PARAMS, QStringList()).toStringList();
|
||||||
int defapp = programSettings->value(SETTINGS_APPLICATION_DEFAULT, -1).toInt();
|
int defapp = settings.value(SETTINGS_APPLICATION_DEFAULT, -1).toInt();
|
||||||
|
|
||||||
// Params will be empty first time starting with the new setting.
|
// Params will be empty first time starting with the new setting.
|
||||||
// Return false and inform user about problem with application settings.
|
// Return false and inform user about problem with application settings.
|
||||||
|
@ -110,8 +110,9 @@ bool ApplicationList::LoadSettings(QSettings *programSettings)
|
||||||
return succeeded;
|
return succeeded;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplicationList::SaveSettings(QSettings *programSettings)
|
void ApplicationList::SaveSettings()
|
||||||
{
|
{
|
||||||
|
QSettings settings;
|
||||||
QStringList names;
|
QStringList names;
|
||||||
QStringList paths;
|
QStringList paths;
|
||||||
QStringList params;
|
QStringList params;
|
||||||
|
@ -124,10 +125,10 @@ void ApplicationList::SaveSettings(QSettings *programSettings)
|
||||||
params << app.getParameters();
|
params << app.getParameters();
|
||||||
}
|
}
|
||||||
|
|
||||||
programSettings->setValue(SETTINGS_APPLICATION_NAMES, names);
|
settings.setValue(SETTINGS_APPLICATION_NAMES, names);
|
||||||
programSettings->setValue(SETTINGS_APPLICATION_PATHS, paths);
|
settings.setValue(SETTINGS_APPLICATION_PATHS, paths);
|
||||||
programSettings->setValue(SETTINGS_APPLICATION_PARAMS, params);
|
settings.setValue(SETTINGS_APPLICATION_PARAMS, params);
|
||||||
programSettings->setValue(SETTINGS_APPLICATION_DEFAULT, mDefaultApplicationIndex);
|
settings.setValue(SETTINGS_APPLICATION_DEFAULT, mDefaultApplicationIndex);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,18 +41,16 @@ public:
|
||||||
/**
|
/**
|
||||||
* @brief Load all applications
|
* @brief Load all applications
|
||||||
*
|
*
|
||||||
* @param programSettings QSettings to load application list from
|
|
||||||
* @return true if loading succeeded, false if there is problem with
|
* @return true if loading succeeded, false if there is problem with
|
||||||
* application list. Most probably because of older version settings need
|
* application list. Most probably because of older version settings need
|
||||||
* to be upgraded.
|
* to be upgraded.
|
||||||
*/
|
*/
|
||||||
bool LoadSettings(QSettings *programSettings);
|
bool LoadSettings();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Save all applications
|
* @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
|
* @brief Get the amount of applications in the list
|
||||||
|
|
|
@ -209,7 +209,7 @@ void MainWindow::LoadSettings()
|
||||||
|
|
||||||
SetLanguage(mSettings->value(SETTINGS_LANGUAGE, mTranslation->SuggestLanguage()).toString());
|
SetLanguage(mSettings->value(SETTINGS_LANGUAGE, mTranslation->SuggestLanguage()).toString());
|
||||||
|
|
||||||
bool succeeded = mApplications->LoadSettings(mSettings);
|
bool succeeded = mApplications->LoadSettings();
|
||||||
if (!succeeded)
|
if (!succeeded)
|
||||||
{
|
{
|
||||||
QString msg = tr("There was a problem with loading the editor application settings.\n\n"
|
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_VIEW_SHOW, mUI.mToolBarView->isVisible());
|
||||||
mSettings->setValue(SETTINGS_TOOLBARS_FILTER_SHOW, mUI.mToolBarFilter->isVisible());
|
mSettings->setValue(SETTINGS_TOOLBARS_FILTER_SHOW, mUI.mToolBarFilter->isVisible());
|
||||||
|
|
||||||
mApplications->SaveSettings(mSettings);
|
mApplications->SaveSettings();
|
||||||
|
|
||||||
mSettings->setValue(SETTINGS_LANGUAGE, mTranslation->GetCurrentLanguage());
|
mSettings->setValue(SETTINGS_LANGUAGE, mTranslation->GetCurrentLanguage());
|
||||||
mUI.mResults->SaveSettings(mSettings);
|
mUI.mResults->SaveSettings(mSettings);
|
||||||
|
|
Loading…
Reference in New Issue