forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -62,7 +62,7 @@ CommonVcsSettings::CommonVcsSettings() :
|
||||
{
|
||||
}
|
||||
|
||||
void CommonVcsSettings::toSettings(QSettings *s) const
|
||||
void CommonVcsSettings::toSettings(Utils::QtcSettings *s) const
|
||||
{
|
||||
s->beginGroup(QLatin1String(settingsGroupC));
|
||||
s->setValue(QLatin1String(nickNameMailMapKeyC), nickNameMailMap);
|
||||
@@ -70,11 +70,9 @@ void CommonVcsSettings::toSettings(QSettings *s) const
|
||||
s->setValue(QLatin1String(submitMessageCheckScriptKeyC), submitMessageCheckScript);
|
||||
s->setValue(QLatin1String(lineWrapKeyC), lineWrap);
|
||||
s->setValue(QLatin1String(lineWrapWidthKeyC), lineWrapWidth);
|
||||
// Do not store the default setting to avoid clobbering the environment.
|
||||
if (sshPasswordPrompt != sshPasswordPromptDefault())
|
||||
s->setValue(QLatin1String(sshPasswordPromptKeyC), sshPasswordPrompt);
|
||||
else
|
||||
s->remove(QLatin1String(sshPasswordPromptKeyC));
|
||||
s->setValueWithDefault(QLatin1String(sshPasswordPromptKeyC),
|
||||
sshPasswordPrompt,
|
||||
sshPasswordPromptDefault());
|
||||
s->endGroup();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user