aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2017-01-06 17:44:51 +0100
committerUlf Hermann <ulf.hermann@qt.io>2017-01-09 09:58:16 +0000
commit58f754bb6623990d603779a7a40620b90dfcf98c (patch)
treeb9ec1999469abdb55b042271109a177848b38e34
parentb872a380407985fb7c4d7ab319cfb9a3e85787de (diff)
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>
-rw-r--r--src/plugins/todo/optionspage.cpp3
-rw-r--r--src/plugins/todo/settings.cpp9
-rw-r--r--src/plugins/todo/settings.h2
3 files changed, 13 insertions, 1 deletions
diff --git a/src/plugins/todo/optionspage.cpp b/src/plugins/todo/optionspage.cpp
index 5c2c7d084db..d449c5b7ac7 100644
--- a/src/plugins/todo/optionspage.cpp
+++ b/src/plugins/todo/optionspage.cpp
@@ -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);
diff --git a/src/plugins/todo/settings.cpp b/src/plugins/todo/settings.cpp
index 654165b6411..b61d106812a 100644
--- a/src/plugins/todo/settings.cpp
+++ b/src/plugins/todo/settings.cpp
@@ -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)
diff --git a/src/plugins/todo/settings.h b/src/plugins/todo/settings.h
index 69ac06c0cca..e7bedd2cae2 100644
--- a/src/plugins/todo/settings.h
+++ b/src/plugins/todo/settings.h
@@ -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();