forked from qt-creator/qt-creator
To-Do: save the settings only if they've been "apply"d
The colors don't play very well with the theme support. We want to switch the colors according to the current theme if the user doesn't care for them. Not saving the default colors achieves that. Change-Id: Idafc13e561d33736eb21b26944756291449594b5 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -70,6 +70,9 @@ void OptionsPage::apply()
|
||||
{
|
||||
Settings newSettings = m_widget->settings();
|
||||
|
||||
// "apply" itself is interpreted as "use these keywords, also for other themes".
|
||||
newSettings.keywordsEdited = true;
|
||||
|
||||
if (newSettings != m_settings) {
|
||||
m_settings = newSettings;
|
||||
emit settingsChanged(m_settings);
|
||||
|
@@ -36,6 +36,9 @@ namespace Internal {
|
||||
|
||||
void Settings::save(QSettings *settings) const
|
||||
{
|
||||
if (!keywordsEdited)
|
||||
return;
|
||||
|
||||
settings->beginGroup(QLatin1String(Constants::SETTINGS_GROUP));
|
||||
settings->setValue(QLatin1String(Constants::SCANNING_SCOPE), scanningScope);
|
||||
|
||||
@@ -97,6 +100,7 @@ void Settings::load(QSettings *settings)
|
||||
newKeywords << keyword;
|
||||
}
|
||||
keywords = newKeywords;
|
||||
keywordsEdited = true; // Otherwise they wouldn't have been saved
|
||||
}
|
||||
settings->endArray();
|
||||
|
||||
@@ -135,12 +139,15 @@ void Settings::setDefault()
|
||||
keyword.iconType = IconType::Warning;
|
||||
keyword.color = QColor(QLatin1String(Constants::COLOR_WARNING_BG));
|
||||
keywords.append(keyword);
|
||||
|
||||
keywordsEdited = false;
|
||||
}
|
||||
|
||||
bool Settings::equals(const Settings &other) const
|
||||
{
|
||||
return (keywords == other.keywords)
|
||||
&& (scanningScope == other.scanningScope);
|
||||
&& (scanningScope == other.scanningScope)
|
||||
&& (keywordsEdited == other.keywordsEdited);
|
||||
}
|
||||
|
||||
bool operator ==(Settings &s1, Settings &s2)
|
||||
|
@@ -44,6 +44,8 @@ class Settings {
|
||||
public:
|
||||
KeywordList keywords;
|
||||
ScanningScope scanningScope = ScanningScopeCurrentFile;
|
||||
bool keywordsEdited = false;
|
||||
|
||||
void save(QSettings *settings) const;
|
||||
void load(QSettings *settings);
|
||||
void setDefault();
|
||||
|
Reference in New Issue
Block a user