aboutsummaryrefslogtreecommitdiffstats
path: root/src/app/main.cpp
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2020-11-19 15:34:59 +0100
committerEike Ziller <eike.ziller@qt.io>2020-12-04 08:25:17 +0000
commit41b73594ad749ff167ce78d1dfc91b5bc4f3c525 (patch)
treefd0061499eb16785cb9df3da65def82b61310475 /src/app/main.cpp
parent8ad9c0111ccfbac9a06513fa5c9baa6dc4e48970 (diff)
Add API for saving settings with default value
We should never actually write default values into the settings, because - if the default value changes in a later Qt Creator version, the new default should automatically take effect if the user didn't change the value - it senselessly grows the settings file Add a QtcSettings class that extends QSettings by a "setValueWithDefault" method, which does not write default values to the settings, and actually removes the settingskey if the user switches back to the default. Use it at the places where we already do this manually. Task-number: QTCREATORBUG-24762 Change-Id: Ia76414cb21e8521f3aeed1e37b43ae4fb3393ea3 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Diffstat (limited to 'src/app/main.cpp')
-rw-r--r--src/app/main.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/app/main.cpp b/src/app/main.cpp
index 9f540e7279d..52c176c0572 100644
--- a/src/app/main.cpp
+++ b/src/app/main.cpp
@@ -37,6 +37,7 @@
#include <utils/fileutils.h>
#include <utils/hostosinfo.h>
#include <utils/optional.h>
+#include <utils/qtcsettings.h>
#include <utils/temporarydirectory.h>
#include <QDebug>
@@ -44,7 +45,6 @@
#include <QFontDatabase>
#include <QFileInfo>
#include <QLibraryInfo>
-#include <QSettings>
#include <QStyle>
#include <QTextStream>
#include <QThreadPool>
@@ -274,16 +274,17 @@ static void setupInstallSettings(QString &installSettingspath)
}
}
-static QSettings *createUserSettings()
+static Utils::QtcSettings *createUserSettings()
{
- return new QSettings(QSettings::IniFormat, QSettings::UserScope,
- QLatin1String(Core::Constants::IDE_SETTINGSVARIANT_STR),
- QLatin1String(Core::Constants::IDE_CASED_ID));
+ return new Utils::QtcSettings(QSettings::IniFormat,
+ QSettings::UserScope,
+ QLatin1String(Core::Constants::IDE_SETTINGSVARIANT_STR),
+ QLatin1String(Core::Constants::IDE_CASED_ID));
}
-static inline QSettings *userSettings()
+static inline Utils::QtcSettings *userSettings()
{
- QSettings *settings = createUserSettings();
+ Utils::QtcSettings *settings = createUserSettings();
const QString fromVariant = QLatin1String(Core::Constants::IDE_COPY_SETTINGS_FROM_VARIANT_STR);
if (fromVariant.isEmpty())
return settings;
@@ -534,10 +535,12 @@ int main(int argc, char **argv)
/*Initialize global settings and resetup install settings with QApplication::applicationDirPath */
setupInstallSettings(options.installSettingsPath);
- QSettings *settings = userSettings();
- QSettings *globalSettings = new QSettings(QSettings::IniFormat, QSettings::SystemScope,
- QLatin1String(Core::Constants::IDE_SETTINGSVARIANT_STR),
- QLatin1String(Core::Constants::IDE_CASED_ID));
+ Utils::QtcSettings *settings = userSettings();
+ Utils::QtcSettings *globalSettings
+ = new Utils::QtcSettings(QSettings::IniFormat,
+ QSettings::SystemScope,
+ QLatin1String(Core::Constants::IDE_SETTINGSVARIANT_STR),
+ QLatin1String(Core::Constants::IDE_CASED_ID));
loadFonts();
if (Utils::HostOsInfo::isWindowsHost()