summaryrefslogtreecommitdiff
path: root/src/plugins/vcsbase/vcsbaseclientsettings.cpp
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2021-03-16 06:00:25 +0100
committerhjk <hjk@qt.io>2021-03-19 13:39:33 +0000
commitaa69415ac780db4789aa36033b5a1fd0d9c6a2fa (patch)
tree8c4bc90e1f46d0a0ec36d2ce1c44d7d3e438221f /src/plugins/vcsbase/vcsbaseclientsettings.cpp
parentf2c34e51e96a320cf39635ed6dbb1ee1514a091c (diff)
downloadqt-creator-aa69415ac780db4789aa36033b5a1fd0d9c6a2fa.tar.gz
Git: Aspectify settings
Change-Id: I87dfeba360967cc77cc230811bcd9f67b3ea6e38 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Diffstat (limited to 'src/plugins/vcsbase/vcsbaseclientsettings.cpp')
-rw-r--r--src/plugins/vcsbase/vcsbaseclientsettings.cpp70
1 files changed, 70 insertions, 0 deletions
diff --git a/src/plugins/vcsbase/vcsbaseclientsettings.cpp b/src/plugins/vcsbase/vcsbaseclientsettings.cpp
index 42760f77af..7f30e76023 100644
--- a/src/plugins/vcsbase/vcsbaseclientsettings.cpp
+++ b/src/plugins/vcsbase/vcsbaseclientsettings.cpp
@@ -397,4 +397,74 @@ QVariant VcsBaseClientSettings::keyDefaultValue(const QString &key) const
return QVariant(valueType(key));
}
+// VcsBaseSettings
+
+VcsBaseSettings::VcsBaseSettings()
+{
+ setAutoApply(false);
+
+ registerAspect(&binaryPath);
+ binaryPath.setSettingsKey("BinaryPath");
+
+ registerAspect(&userName);
+ userName.setSettingsKey("Username");
+
+ registerAspect(&userEmail);
+ userEmail.setSettingsKey("UserEmail");
+
+ registerAspect(&logCount);
+ logCount.setSettingsKey("LogCount");
+ logCount.setRange(0, 1000 * 1000);
+ logCount.setDefaultValue(100);
+ logCount.setLabelText(tr("Log count:"));
+
+ registerAspect(&path);
+ path.setSettingsKey("Path");
+
+ registerAspect(&promptOnSubmit);
+ promptOnSubmit.setSettingsKey("PromptOnSubmit");
+ promptOnSubmit.setDefaultValue(true);
+ promptOnSubmit.setLabelText(tr("Prompt on submit"));
+
+ registerAspect(&timeout);
+ timeout.setSettingsKey("Timeout");
+ timeout.setRange(0, 3600 * 24 * 365);
+ timeout.setDefaultValue(30);
+ timeout.setLabelText(tr("Timeout:"));
+ timeout.setSuffix(tr("s"));
+}
+
+QStringList VcsBaseSettings::searchPathList() const
+{
+ return path.value().split(HostOsInfo::pathListSeparator(), Qt::SkipEmptyParts);
+}
+
+void VcsBaseSettings::setSettingsGroup(const QString &key)
+{
+ m_settingsGroup = key;
+}
+
+void VcsBaseSettings::writeSettings(QSettings *settings) const
+{
+ QTC_ASSERT(!m_settingsGroup.isEmpty(), return);
+
+ settings->remove(m_settingsGroup);
+ settings->beginGroup(m_settingsGroup);
+ forEachAspect([settings](BaseAspect *aspect) {
+ QtcSettings::setValueWithDefault(settings, aspect->settingsKey(),
+ aspect->value(), aspect->defaultValue());
+ });
+ settings->endGroup();
+}
+
+void VcsBaseSettings::readSettings(const QSettings *settings)
+{
+ const QString keyRoot = m_settingsGroup + '/';
+ forEachAspect([settings, keyRoot](BaseAspect *aspect) {
+ QString key = aspect->settingsKey();
+ const QVariant value = settings->value(keyRoot + key, aspect->defaultValue());
+ aspect->setValue(value);
+ });
+}
+
} // namespace VcsBase