diff --git a/src/app/Application.cpp b/src/app/Application.cpp index 37cc68097..64216bec9 100644 --- a/src/app/Application.cpp +++ b/src/app/Application.cpp @@ -155,7 +155,8 @@ Application::Application(int &argc, char **argv, bool haltOnParseError) // Read translation settings. QSettings settings; - if ((!settings.value("translation/disable", false).toBool()) && + if ((!settings.value(Setting::key(Setting::Id::DontTranslate), false) + .toBool()) && (!parser.isSet("no-translation"))) { // Load translation files. QLocale locale; @@ -230,7 +231,9 @@ Application::Application(int &argc, char **argv, bool haltOnParseError) void Application::autoUpdate() { // Check for updates. - if (Settings::instance()->value("update/check").toBool()) { + if (Settings::instance() + ->value(Setting::Id::CheckForUpdatesAutomatically) + .toBool()) { // Check now. Updater::instance()->update(true); @@ -368,7 +371,9 @@ class CopyDataWindow : public QWindow { #endif bool Application::runSingleInstance() { - if (Settings::instance()->value("singleInstance").toBool()) { + if (Settings::instance() + ->value(Setting::Id::AllowSingleInstanceOnly) + .toBool()) { #if defined(Q_OS_LINUX) QDBusConnection bus = QDBusConnection::sessionBus(); diff --git a/src/app/Theme.cpp b/src/app/Theme.cpp index 91bbabe8a..7a0f7b498 100644 --- a/src/app/Theme.cpp +++ b/src/app/Theme.cpp @@ -236,17 +236,17 @@ QColor Theme::star() { return QPalette().color(QPalette::Highlight); } Theme *Theme::create(const QString &defaultName) { // Upgrade theme key to capital case. Settings *settings = Settings::instance(); - QString key = settings->value("window/theme").toString(); + QString key = settings->value(Setting::Id::ColorTheme).toString(); if (key == "default" || key == "dark" || key == "system") { key[0] = key.at(0).toUpper(); - settings->setValue("window/theme", key); + settings->setValue(Setting::Id::ColorTheme, key); } QString name = !defaultName.isEmpty() ? defaultName : key; if (name.isEmpty() && !Application::isInTest()) { ThemeDialog dialog; dialog.exec(); - name = settings->value("window/theme").toString(); + name = settings->value(Setting::Id::ColorTheme).toString(); } // Load custom theme. diff --git a/src/conf/Setting.cpp b/src/conf/Setting.cpp index 3816493f4..ee0d4c297 100644 --- a/src/conf/Setting.cpp +++ b/src/conf/Setting.cpp @@ -1,15 +1,50 @@ #include "Setting.h" void Setting::initialize(QMap &keys) { + keys[Id::FetchAutomatically] = "global/autofetch/enable"; + keys[Id::AutomaticFetchPeriodInMinutes] = "global/autofetch/minutes"; + keys[Id::PushAfterEachCommit] = "global/autopush/enable"; + keys[Id::UpdateSubmodulesAfterPullAndClone] = "global/autoupdate/enable"; + keys[Id::PruneAfterFetch] = "global/autoprune/enable"; + keys[Id::FontFamily] = "editor/font/family"; + keys[Id::FontSize] = "editor/font/size"; + keys[Id::UseTabsForIndent] = "editor/indent/tabs"; + keys[Id::IndentWidth] = "editor/indent/width"; + keys[Id::TabWidth] = "editor/indent/tabwidth"; + keys[Id::ShowHeatmapInBlameMargin] = "editor/blame/heatmap"; + keys[Id::ColorTheme] = "window/theme"; + keys[Id::ShowFullRepoPath] = "window/path/full"; + keys[Id::HideLogAutomatically] = "window/log/hide"; + keys[Id::OpenSubmodulesInTabs] = "window/tabs/submodule"; + keys[Id::OpenAllReposInTabs] = "window/tabs/repository"; + keys[Id::HideMenuBar] = "window/view/menuBarHidden"; keys[Id::ShowAvatars] = "window/view/avatarsVisible"; + keys[Id::AutoCollapseAddedFiles] = "collapse/added"; + keys[Id::AutoCollapseDeletedFiles] = "collapse/deleted"; + keys[Id::FilemanagerCommand] = "filemanager/command"; + keys[Id::TerminalCommand] = "terminal/command"; + keys[Id::TerminalName] = "terminal/name"; + keys[Id::TerminalPath] = "terminal/path"; + keys[Id::DontTranslate] = "translation/disable"; + keys[Id::StoreCredentials] = "credential/store"; + keys[Id::AllowSingleInstanceOnly] = "singleInstance"; + keys[Id::CheckForUpdatesAutomatically] = "update/check"; + keys[Id::InstallUpdatesAutomatically] = "update/download"; + keys[Id::SkippedUpdates] = "update/skip"; + keys[Id::SshConfigFilePath] = "ssh/configFilePath"; + keys[Id::SshKeyFilePath] = "ssh/keyFilePath"; + keys[Id::CommitMergeImmediately] = "merge/commit"; + keys[Id::ShowCommitsInCompactMode] = "commit/compact"; + keys[Id::ShowChangedFilesAsList] = "doubletreeview/listview"; + keys[Id::ShowChangedFilesInSingleView] = "doubletreeview/single"; } -void Prompt::initialize(QMap &keys) { +void Prompt::initialize(QMap &keys) { const QString root("window/prompt/"); - keys[PromptKind::PromptMerge] = root + "merge"; - keys[PromptKind::PromptStash] = root + "stash"; - keys[PromptKind::PromptRevert] = root + "revert"; - keys[PromptKind::PromptCherryPick] = root + "cherrypick"; - keys[PromptKind::PromptDirectories] = root + "directories"; - keys[PromptKind::PromptLargeFiles] = root + "largeFiles"; + keys[Kind::Merge] = root + "merge"; + keys[Kind::Stash] = root + "stash"; + keys[Kind::Revert] = root + "revert"; + keys[Kind::CherryPick] = root + "cherrypick"; + keys[Kind::Directories] = root + "directories"; + keys[Kind::LargeFiles] = root + "largeFiles"; } diff --git a/src/conf/Setting.h b/src/conf/Setting.h index 0f16d3eb6..f5b25f006 100644 --- a/src/conf/Setting.h +++ b/src/conf/Setting.h @@ -25,7 +25,42 @@ class Setting : public SettingsTempl { public: enum class Id { + FetchAutomatically, + AutomaticFetchPeriodInMinutes, + PushAfterEachCommit, + UpdateSubmodulesAfterPullAndClone, + PruneAfterFetch, + FontFamily, + FontSize, + UseTabsForIndent, + IndentWidth, + TabWidth, + ShowHeatmapInBlameMargin, + ColorTheme, + ShowFullRepoPath, + HideLogAutomatically, + OpenSubmodulesInTabs, + OpenAllReposInTabs, + HideMenuBar, ShowAvatars, + AutoCollapseAddedFiles, + AutoCollapseDeletedFiles, + FilemanagerCommand, + TerminalCommand, + TerminalName, + TerminalPath, + DontTranslate, + StoreCredentials, + AllowSingleInstanceOnly, + CheckForUpdatesAutomatically, + InstallUpdatesAutomatically, + SkippedUpdates, + SshConfigFilePath, + SshKeyFilePath, + CommitMergeImmediately, + ShowCommitsInCompactMode, + ShowChangedFilesAsList, + ShowChangedFilesInSingleView, }; Q_ENUM(Id) @@ -36,18 +71,13 @@ class Setting : public SettingsTempl { }; class Prompt : public SettingsTempl { + Q_GADGET public: - enum class PromptKind { - PromptStash, - PromptMerge, - PromptRevert, - PromptCherryPick, - PromptDirectories, - PromptLargeFiles - }; + enum class Kind { Stash, Merge, Revert, CherryPick, Directories, LargeFiles }; + Q_ENUM(Kind) - static void initialize(QMap &keys); + static void initialize(QMap &keys); }; #endif diff --git a/src/conf/Settings.cpp b/src/conf/Settings.cpp index 7a399f1ab..d03f9050a 100644 --- a/src/conf/Settings.cpp +++ b/src/conf/Settings.cpp @@ -44,7 +44,7 @@ QVariant lookup(const QVariantMap &root, const QString &key) { return QVariant(); } -QString promptKey(Prompt::PromptKind kind) { return Prompt::key(kind); } +QString promptKey(Prompt::Kind kind) { return Prompt::key(kind); } QDir rootDir() { QDir dir(QCoreApplication::applicationDirPath()); @@ -68,16 +68,6 @@ Settings::Settings(QObject *parent) : QObject(parent) { QString Settings::group() const { return mGroup.join("/"); } -void Settings::beginGroup(const QString &prefix) { - mGroup.append(prefix); - mCurrentMap = lookup(mDefaults, group()).toMap(); -} - -void Settings::endGroup() { - mGroup.removeLast(); - mCurrentMap = lookup(mDefaults, group()).toMap(); -} - QVariant Settings::value(const QString &key) const { return value(key, defaultValue(key)); } @@ -117,6 +107,10 @@ QVariant Settings::value(Setting::Id id) const { return value(Setting::key(id)); } +QVariant Settings::value(Setting::Id id, const QVariant &defaultValue) const { + return value(Setting::key(id), defaultValue); +} + void Settings::setValue(Setting::Id id, const QVariant &value) { setValue(Setting::key(id), value); } @@ -162,36 +156,44 @@ QString Settings::kind(const QString &filename) { return lexers.value(key).toMap().value("name").toString(); } -bool Settings::prompt(Prompt::PromptKind kind) const { +bool Settings::prompt(Prompt::Kind kind) const { return value(promptKey(kind)).toBool(); } -void Settings::setPrompt(Prompt::PromptKind kind, bool prompt) { +void Settings::setPrompt(Prompt::Kind kind, bool prompt) { setValue(promptKey(kind), prompt); } -QString Settings::promptDescription(Prompt::PromptKind kind) const { +QString Settings::promptDescription(Prompt::Kind kind) const { switch (kind) { - case Prompt::PromptKind::PromptStash: + case Prompt::Kind::Stash: return tr("Prompt to edit stash message before stashing"); - case Prompt::PromptKind::PromptMerge: + case Prompt::Kind::Merge: return tr("Prompt to edit commit message before merging"); - case Prompt::PromptKind::PromptRevert: + case Prompt::Kind::Revert: return tr("Prompt to edit commit message before reverting"); - case Prompt::PromptKind::PromptCherryPick: + case Prompt::Kind::CherryPick: return tr("Prompt to edit commit message before cherry-picking"); - case Prompt::PromptKind::PromptDirectories: + case Prompt::Kind::Directories: return tr("Prompt to stage directories"); - case Prompt::PromptKind::PromptLargeFiles: + case Prompt::Kind::LargeFiles: return tr("Prompt to stage large files"); } } +void Settings::setHotkey(const QString &action, const QString &hotkey) { + setValue("hotkeys/" + action, hotkey); +} + +QString Settings::hotkey(const QString &action) const { + return value("hotkeys/" + action, "").toString(); +} + bool Settings::isWhitespaceIgnored() const { return value(kIgnoreWsKey).toBool(); } diff --git a/src/conf/Settings.h b/src/conf/Settings.h index 8a279dcde..61b6662d7 100644 --- a/src/conf/Settings.h +++ b/src/conf/Settings.h @@ -20,17 +20,8 @@ class Settings : public QObject { Q_OBJECT public: - QString group() const; - void beginGroup(const QString &prefix); - void endGroup(); - - QVariant value(const QString &key) const; - QVariant value(const QString &key, const QVariant &defaultValue) const; - QVariant defaultValue(const QString &key) const; - void setValue(const QString &key, const QVariant &value, - bool refresh = false); - QVariant value(Setting::Id id) const; + QVariant value(Setting::Id id, const QVariant &defaultValue) const; void setValue(Setting::Id id, const QVariant &value); // Look up lexer name by file name. @@ -38,9 +29,12 @@ class Settings : public QObject { QString kind(const QString &filename); // prompt dialogs - bool prompt(Prompt::PromptKind kind) const; - void setPrompt(Prompt::PromptKind kind, bool prompt); - QString promptDescription(Prompt::PromptKind kind) const; + bool prompt(Prompt::Kind kind) const; + void setPrompt(Prompt::Kind kind, bool prompt); + QString promptDescription(Prompt::Kind kind) const; + + void setHotkey(const QString &action, const QString &hotkey); + QString hotkey(const QString &action) const; // ignore whitespace bool isWhitespaceIgnored() const; @@ -72,6 +66,14 @@ class Settings : public QObject { private: Settings(QObject *parent = nullptr); + QString group() const; + + QVariant value(const QString &key) const; + QVariant value(const QString &key, const QVariant &defaultValue) const; + QVariant defaultValue(const QString &key) const; + void setValue(const QString &key, const QVariant &value, + bool refresh = false); + QStringList mGroup; QVariantMap mDefaults; QVariantMap mCurrentMap; diff --git a/src/cred/CredentialHelper.cpp b/src/cred/CredentialHelper.cpp index 409e56fff..bda260ae8 100644 --- a/src/cred/CredentialHelper.cpp +++ b/src/cred/CredentialHelper.cpp @@ -21,14 +21,13 @@ namespace { const QString kLogKey = "credential/log"; -const QString kStoreKey = "credential/store"; } // namespace CredentialHelper *CredentialHelper::instance() { static QPointer instance; if (!instance) { - if (Settings::instance()->value(kStoreKey).toBool()) { + if (Settings::instance()->value(Setting::Id::StoreCredentials).toBool()) { #if defined(Q_OS_MAC) instance = new GitCredential("osxkeychain"); #elif defined(Q_OS_WIN) diff --git a/src/dialogs/CommitDialog.cpp b/src/dialogs/CommitDialog.cpp index dfed61831..58b4d358b 100644 --- a/src/dialogs/CommitDialog.cpp +++ b/src/dialogs/CommitDialog.cpp @@ -18,31 +18,31 @@ #include #include -CommitDialog::CommitDialog(const QString &message, Prompt::PromptKind kind, +CommitDialog::CommitDialog(const QString &message, Prompt::Kind kind, QWidget *parent) : QDialog(parent) { setAttribute(Qt::WA_DeleteOnClose); QString title; switch (kind) { - case Prompt::PromptKind::PromptMerge: + case Prompt::Kind::Merge: title = tr("Merge commit message"); break; - case Prompt::PromptKind::PromptStash: + case Prompt::Kind::Stash: title = tr("Stash commit message"); break; - case Prompt::PromptKind::PromptRevert: + case Prompt::Kind::Revert: title = tr("Revert commit message"); break; - case Prompt::PromptKind::PromptCherryPick: + case Prompt::Kind::CherryPick: title = tr("Cherry-pick commit message"); break; - case Prompt::PromptKind::PromptDirectories: - case Prompt::PromptKind::PromptLargeFiles: + case Prompt::Kind::Directories: + case Prompt::Kind::LargeFiles: Q_ASSERT(false); break; } @@ -67,28 +67,28 @@ CommitDialog::CommitDialog(const QString &message, Prompt::PromptKind kind, connect(buttons, &QDialogButtonBox::rejected, this, &QDialog::reject); switch (kind) { - case Prompt::PromptKind::PromptMerge: + case Prompt::Kind::Merge: buttons->addButton(tr("Merge"), QDialogButtonBox::AcceptRole); buttons->addButton(tr("Abort"), QDialogButtonBox::RejectRole); break; - case Prompt::PromptKind::PromptStash: + case Prompt::Kind::Stash: buttons->addButton(tr("Stash"), QDialogButtonBox::AcceptRole); buttons->addButton(QDialogButtonBox::Cancel); break; - case Prompt::PromptKind::PromptRevert: + case Prompt::Kind::Revert: buttons->addButton(tr("Revert"), QDialogButtonBox::AcceptRole); buttons->addButton(tr("Abort"), QDialogButtonBox::RejectRole); break; - case Prompt::PromptKind::PromptCherryPick: + case Prompt::Kind::CherryPick: buttons->addButton(tr("Cherry-pick"), QDialogButtonBox::AcceptRole); buttons->addButton(tr("Abort"), QDialogButtonBox::RejectRole); break; - case Prompt::PromptKind::PromptDirectories: - case Prompt::PromptKind::PromptLargeFiles: + case Prompt::Kind::Directories: + case Prompt::Kind::LargeFiles: Q_ASSERT(false); break; } diff --git a/src/dialogs/CommitDialog.h b/src/dialogs/CommitDialog.h index 3e838e3e5..fd2321f64 100644 --- a/src/dialogs/CommitDialog.h +++ b/src/dialogs/CommitDialog.h @@ -19,7 +19,7 @@ class CommitDialog : public QDialog { Q_OBJECT public: - CommitDialog(const QString &message, Prompt::PromptKind kind, + CommitDialog(const QString &message, Prompt::Kind kind, QWidget *parent = nullptr); QString message() const; diff --git a/src/dialogs/ConfigDialog.cpp b/src/dialogs/ConfigDialog.cpp index 623dbef56..eeb21b6cb 100644 --- a/src/dialogs/ConfigDialog.cpp +++ b/src/dialogs/ConfigDialog.cpp @@ -145,16 +145,15 @@ class GeneralPanel : public QWidget { // Read defaults from global settings. Settings *settings = Settings::instance(); - settings->beginGroup("global"); - settings->beginGroup("autofetch"); - bool fetch = settings->value("enable").toBool(); - int minutes = settings->value("minutes").toInt(); - settings->endGroup(); - - bool push = settings->value("autopush/enable").toBool(); - bool update = settings->value("autoupdate/enable").toBool(); - bool prune = settings->value("autoprune/enable").toBool(); - settings->endGroup(); + bool fetch = settings->value(Setting::Id::FetchAutomatically).toBool(); + int minutes = + settings->value(Setting::Id::AutomaticFetchPeriodInMinutes).toInt(); + + bool push = settings->value(Setting::Id::PushAfterEachCommit).toBool(); + bool update = + settings->value(Setting::Id::UpdateSubmodulesAfterPullAndClone) + .toBool(); + bool prune = settings->value(Setting::Id::PruneAfterFetch).toBool(); git::Config app = mRepo.appConfig(); mFetch->setChecked(app.value("autofetch.enable", fetch)); diff --git a/src/dialogs/DiffPanel.cpp b/src/dialogs/DiffPanel.cpp index b17663911..f2183cac7 100644 --- a/src/dialogs/DiffPanel.cpp +++ b/src/dialogs/DiffPanel.cpp @@ -88,15 +88,17 @@ DiffPanel::DiffPanel(const git::Repository &repo, QWidget *parent) // auto collapse Settings *settings = Settings::instance(); QCheckBox *collapseAdded = new QCheckBox(tr("Added files"), this); - collapseAdded->setChecked(settings->value("collapse/added").toBool()); + collapseAdded->setChecked( + settings->value(Setting::Id::AutoCollapseAddedFiles).toBool()); connect(collapseAdded, &QCheckBox::toggled, [settings](bool checked) { - settings->setValue("collapse/added", checked); + settings->setValue(Setting::Id::AutoCollapseAddedFiles, checked); }); QCheckBox *collapseDeleted = new QCheckBox(tr("Deleted files"), this); - collapseDeleted->setChecked(settings->value("collapse/deleted").toBool()); + collapseDeleted->setChecked( + settings->value(Setting::Id::AutoCollapseDeletedFiles).toBool()); connect(collapseDeleted, &QCheckBox::toggled, [settings](bool checked) { - settings->setValue("collapse/deleted", checked); + settings->setValue(Setting::Id::AutoCollapseDeletedFiles, checked); }); layout->addRow(tr("Whitespace:"), ignoreWs); diff --git a/src/dialogs/MergeDialog.cpp b/src/dialogs/MergeDialog.cpp index deb5636b4..1c9f8dd39 100644 --- a/src/dialogs/MergeDialog.cpp +++ b/src/dialogs/MergeDialog.cpp @@ -20,8 +20,6 @@ namespace { -const QString kCommitKey = "merge/commit"; - const ReferenceView::Kinds kRefKinds = ReferenceView::InvalidRef | ReferenceView::LocalBranches | ReferenceView::RemoteBranches | ReferenceView::Tags | @@ -51,9 +49,12 @@ MergeDialog::MergeDialog(RepoView::MergeFlags flags, QLabel *label = new QLabel(labelText(), this); QCheckBox *noCommit = new QCheckBox(tr("No commit"), this); - noCommit->setChecked(!Settings::instance()->value(kCommitKey).toBool()); + noCommit->setChecked(!Settings::instance() + ->value(Setting::Id::CommitMergeImmediately) + .toBool()); connect(noCommit, &QCheckBox::toggled, [](bool checked) { - Settings::instance()->setValue(kCommitKey, !checked); + Settings::instance()->setValue(Setting::Id::CommitMergeImmediately, + !checked); }); noCommit->setVisible(flags & RepoView::Merge); @@ -98,7 +99,9 @@ git::Reference MergeDialog::reference() const { RepoView::MergeFlags MergeDialog::flags() const { int action = mAction->itemData(mAction->currentIndex()).toInt(); RepoView::MergeFlags flags = static_cast(action); - if (!Settings::instance()->value(kCommitKey).toBool()) + if (!Settings::instance() + ->value(Setting::Id::CommitMergeImmediately) + .toBool()) flags |= RepoView::NoCommit; return flags; } diff --git a/src/dialogs/RemoteDialog.cpp b/src/dialogs/RemoteDialog.cpp index f28089e44..ca4c4a7e0 100644 --- a/src/dialogs/RemoteDialog.cpp +++ b/src/dialogs/RemoteDialog.cpp @@ -100,7 +100,7 @@ RemoteDialog::RemoteDialog(Kind kind, RepoView *parent) : QDialog(parent) { } else { bool autoPrune = - Settings::instance()->value("global/autoprune/enable").toBool(); + Settings::instance()->value(Setting::Id::PruneAfterFetch).toBool(); git::Config config = repo.appConfig(); prune = new QCheckBox(tr("Prune references"), this); diff --git a/src/dialogs/SettingsDialog.cpp b/src/dialogs/SettingsDialog.cpp index 0f50eb218..6fe3eb8fc 100644 --- a/src/dialogs/SettingsDialog.cpp +++ b/src/dialogs/SettingsDialog.cpp @@ -149,7 +149,7 @@ class GeneralPanel : public QWidget { }); connect(mFetch, &QCheckBox::toggled, this, [](bool checked) { - Settings::instance()->setValue("global/autofetch/enable", checked); + Settings::instance()->setValue(Setting::Id::FetchAutomatically, checked); foreach (MainWindow *window, MainWindow::windows()) { for (int i = 0; i < window->count(); ++i) window->view(i)->startFetchTimer(); @@ -158,32 +158,35 @@ class GeneralPanel : public QWidget { auto signal = QOverload::of(&QSpinBox::valueChanged); connect(mFetchMinutes, signal, [](int value) { - Settings::instance()->setValue("global/autofetch/minutes", value); + Settings::instance()->setValue(Setting::Id::AutomaticFetchPeriodInMinutes, + value); }); connect(mPushCommit, &QCheckBox::toggled, [](bool checked) { - Settings::instance()->setValue("global/autopush/enable", checked); + Settings::instance()->setValue(Setting::Id::PushAfterEachCommit, checked); }); connect(mPullUpdate, &QCheckBox::toggled, [](bool checked) { - Settings::instance()->setValue("global/autoupdate/enable", checked); + Settings::instance()->setValue( + Setting::Id::UpdateSubmodulesAfterPullAndClone, checked); }); connect(mAutoPrune, &QCheckBox::toggled, [](bool checked) { - Settings::instance()->setValue("global/autoprune/enable", checked); + Settings::instance()->setValue(Setting::Id::PruneAfterFetch, checked); }); connect(mNoTranslation, &QCheckBox::toggled, [](bool checked) { - Settings::instance()->setValue("translation/disable", checked); + Settings::instance()->setValue(Setting::Id::DontTranslate, checked); }); connect(mStoreCredentials, &QCheckBox::toggled, [](bool checked) { - Settings::instance()->setValue("credential/store", checked); + Settings::instance()->setValue(Setting::Id::StoreCredentials, checked); delete CredentialHelper::instance(); }); connect(mSingleInstance, &QCheckBox::toggled, [](bool checked) { - Settings::instance()->setValue("singleInstance", checked); + Settings::instance()->setValue(Setting::Id::AllowSingleInstanceOnly, + checked); }); } @@ -193,21 +196,26 @@ class GeneralPanel : public QWidget { mEmail->setText(config.value("user.email")); Settings *settings = Settings::instance(); - settings->beginGroup("global"); - settings->beginGroup("autofetch"); - mFetch->setChecked(settings->value("enable").toBool()); - mFetchMinutes->setValue(settings->value("minutes").toInt()); - settings->endGroup(); - - mPushCommit->setChecked(settings->value("autopush/enable").toBool()); - mPullUpdate->setChecked(settings->value("autoupdate/enable").toBool()); - mAutoPrune->setChecked(settings->value("autoprune/enable").toBool()); - settings->endGroup(); - - mNoTranslation->setChecked(settings->value("translation/disable").toBool()); - mStoreCredentials->setChecked(settings->value("credential/store").toBool()); - - mSingleInstance->setChecked(settings->value("singleInstance").toBool()); + mFetch->setChecked( + settings->value(Setting::Id::FetchAutomatically).toBool()); + mFetchMinutes->setValue( + settings->value(Setting::Id::AutomaticFetchPeriodInMinutes).toInt()); + + mPushCommit->setChecked( + settings->value(Setting::Id::PushAfterEachCommit).toBool()); + mPullUpdate->setChecked( + settings->value(Setting::Id::UpdateSubmodulesAfterPullAndClone) + .toBool()); + mAutoPrune->setChecked( + settings->value(Setting::Id::PruneAfterFetch).toBool()); + + mNoTranslation->setChecked( + settings->value(Setting::Id::DontTranslate).toBool()); + mStoreCredentials->setChecked( + settings->value(Setting::Id::StoreCredentials).toBool()); + + mSingleInstance->setChecked( + settings->value(Setting::Id::AllowSingleInstanceOnly).toBool()); } private: @@ -263,10 +271,10 @@ class ToolsPanel : public QWidget { QLineEdit *mTerminalCommand = new QLineEdit(this); layout->addRow(tr("Terminal emulator command:"), mTerminalCommand); mTerminalCommand->setText( - Settings::instance()->value("terminal/command").toString()); + Settings::instance()->value(Setting::Id::TerminalCommand).toString()); connect(mTerminalCommand, &QLineEdit::textChanged, [](const QString &text) { - Settings::instance()->setValue("terminal/command", text); + Settings::instance()->setValue(Setting::Id::TerminalCommand, text); }); QLineEdit *mFileManagerCommand = new QLineEdit(this); @@ -275,12 +283,13 @@ class ToolsPanel : public QWidget { fileManagerLayout->addWidget(new QLabel("\"%1\" = Repo Path", this)); layout->addRow(tr("File manager command:"), fileManagerLayout); - connect(mFileManagerCommand, &QLineEdit::textChanged, - [](const QString &text) { - Settings::instance()->setValue("filemanager/command", text); - }); - mFileManagerCommand->setText( - Settings::instance()->value("filemanager/command").toString()); + connect( + mFileManagerCommand, &QLineEdit::textChanged, [](const QString &text) { + Settings::instance()->setValue(Setting::Id::FilemanagerCommand, text); + }); + mFileManagerCommand->setText(Settings::instance() + ->value(Setting::Id::FilemanagerCommand) + .toString()); } private: @@ -330,7 +339,6 @@ class WindowPanel : public QWidget { public: WindowPanel(QWidget *parent = nullptr) : QWidget(parent) { Settings *settings = Settings::instance(); - settings->beginGroup("window"); QComboBox *comboBox = new QComboBox(this); @@ -366,7 +374,8 @@ class WindowPanel : public QWidget { comboBox->insertSeparator(comboBox->count()); - int index = comboBox->findText(settings->value("theme").toString()); + int index = + comboBox->findText(settings->value(Setting::Id::ColorTheme).toString()); // add theme comboBox->addItem(tr("Add New Theme")); @@ -433,7 +442,8 @@ class WindowPanel : public QWidget { } // Save theme - Settings::instance()->setValue("window/theme", comboBox->currentText()); + Settings::instance()->setValue(Setting::Id::ColorTheme, + comboBox->currentText()); QMessageBox mb(QMessageBox::Information, tr("Restart?"), tr("The application must be restarted for " @@ -460,98 +470,88 @@ class WindowPanel : public QWidget { }); QCheckBox *fullPath = new QCheckBox(tr("Show full repository path")); - fullPath->setChecked(settings->value("path/full").toBool()); + fullPath->setChecked( + settings->value(Setting::Id::ShowFullRepoPath).toBool()); connect(fullPath, &QCheckBox::toggled, [](bool checked) { - Settings::instance()->setValue("window/path/full", checked); + Settings::instance()->setValue(Setting::Id::ShowFullRepoPath, checked); }); QCheckBox *hideLog = new QCheckBox(tr("Hide automatically")); - hideLog->setChecked(settings->value("log/hide").toBool()); + hideLog->setChecked( + settings->value(Setting::Id::HideLogAutomatically).toBool()); connect(hideLog, &QCheckBox::toggled, [](bool checked) { - Settings::instance()->setValue("window/log/hide", checked); + Settings::instance()->setValue(Setting::Id::HideLogAutomatically, + checked); }); - settings->beginGroup("tabs"); QCheckBox *smTabs = new QCheckBox(tr("Open submodules in tabs")); - smTabs->setChecked(settings->value("submodule").toBool()); + smTabs->setChecked( + settings->value(Setting::Id::OpenSubmodulesInTabs).toBool()); connect(smTabs, &QCheckBox::toggled, [](bool checked) { - Settings::instance()->setValue("window/tabs/submodule", checked); + Settings::instance()->setValue(Setting::Id::OpenSubmodulesInTabs, + checked); }); QCheckBox *repoTabs = new QCheckBox(tr("Open all repositories in tabs")); - repoTabs->setChecked(settings->value("repository").toBool()); + repoTabs->setChecked( + settings->value(Setting::Id::OpenAllReposInTabs).toBool()); connect(repoTabs, &QCheckBox::toggled, [](bool checked) { - Settings::instance()->setValue("window/tabs/repository", checked); + Settings::instance()->setValue(Setting::Id::OpenAllReposInTabs, checked); }); - settings->endGroup(); // tabs - settings->beginGroup("view"); QCheckBox *hideMenuBar = new QCheckBox(tr("Hide Menubar")); - hideMenuBar->setChecked(settings->value("menuBarHidden").toBool()); + hideMenuBar->setChecked(settings->value(Setting::Id::HideMenuBar).toBool()); connect(hideMenuBar, &QCheckBox::toggled, [](bool checked) { - Settings::instance()->setValue("window/view/menuBarHidden", checked); + Settings::instance()->setValue(Setting::Id::HideMenuBar, checked); }); - settings->endGroup(); // view - settings->endGroup(); // window QCheckBox *showAvatars = new QCheckBox(tr("Show Avatars")); showAvatars->setChecked(settings->value(Setting::Id::ShowAvatars).toBool()); connect(showAvatars, &QCheckBox::toggled, [](bool checked) { Settings::instance()->setValue(Setting::Id::ShowAvatars, checked); }); - QString mergeText = - settings->promptDescription(Prompt::PromptKind::PromptMerge); + QString mergeText = settings->promptDescription(Prompt::Kind::Merge); QCheckBox *merge = new QCheckBox(mergeText, this); - merge->setChecked(settings->prompt(Prompt::PromptKind::PromptMerge)); + merge->setChecked(settings->prompt(Prompt::Kind::Merge)); connect(merge, &QCheckBox::toggled, [](bool checked) { - Settings::instance()->setPrompt(Prompt::PromptKind::PromptMerge, checked); + Settings::instance()->setPrompt(Prompt::Kind::Merge, checked); }); - QString revertText = - settings->promptDescription(Prompt::PromptKind::PromptRevert); + QString revertText = settings->promptDescription(Prompt::Kind::Revert); QCheckBox *revert = new QCheckBox(revertText, this); - revert->setChecked(settings->prompt(Prompt::PromptKind::PromptRevert)); + revert->setChecked(settings->prompt(Prompt::Kind::Revert)); connect(revert, &QCheckBox::toggled, [](bool checked) { - Settings::instance()->setPrompt(Prompt::PromptKind::PromptRevert, - checked); + Settings::instance()->setPrompt(Prompt::Kind::Revert, checked); }); - QString cpText = - settings->promptDescription(Prompt::PromptKind::PromptCherryPick); + QString cpText = settings->promptDescription(Prompt::Kind::CherryPick); QCheckBox *cherryPick = new QCheckBox(cpText, this); - cherryPick->setChecked( - settings->prompt(Prompt::PromptKind::PromptCherryPick)); + cherryPick->setChecked(settings->prompt(Prompt::Kind::CherryPick)); connect(cherryPick, &QCheckBox::toggled, [](bool checked) { - Settings::instance()->setPrompt(Prompt::PromptKind::PromptCherryPick, - checked); + Settings::instance()->setPrompt(Prompt::Kind::CherryPick, checked); }); - QString stashText = - settings->promptDescription(Prompt::PromptKind::PromptStash); + QString stashText = settings->promptDescription(Prompt::Kind::Stash); QCheckBox *stash = new QCheckBox(stashText, this); - stash->setChecked(settings->prompt(Prompt::PromptKind::PromptStash)); + stash->setChecked(settings->prompt(Prompt::Kind::Stash)); connect(stash, &QCheckBox::toggled, [](bool checked) { - Settings::instance()->setPrompt(Prompt::PromptKind::PromptStash, checked); + Settings::instance()->setPrompt(Prompt::Kind::Stash, checked); }); QString largeFilesText = - settings->promptDescription(Prompt::PromptKind::PromptLargeFiles); + settings->promptDescription(Prompt::Kind::LargeFiles); QCheckBox *largeFiles = new QCheckBox(largeFilesText, this); - largeFiles->setChecked( - settings->prompt(Prompt::PromptKind::PromptLargeFiles)); + largeFiles->setChecked(settings->prompt(Prompt::Kind::LargeFiles)); connect(largeFiles, &QCheckBox::toggled, [](bool checked) { - Settings::instance()->setPrompt(Prompt::PromptKind::PromptLargeFiles, - checked); + Settings::instance()->setPrompt(Prompt::Kind::LargeFiles, checked); }); QString directoriesText = - settings->promptDescription(Prompt::PromptKind::PromptDirectories); + settings->promptDescription(Prompt::Kind::Directories); QCheckBox *directories = new QCheckBox(directoriesText, this); - directories->setChecked( - settings->prompt(Prompt::PromptKind::PromptDirectories)); + directories->setChecked(settings->prompt(Prompt::Kind::Directories)); connect(directories, &QCheckBox::toggled, [](bool checked) { - Settings::instance()->setPrompt(Prompt::PromptKind::PromptDirectories, - checked); + Settings::instance()->setPrompt(Prompt::Kind::Directories, checked); }); QFormLayout *layout = new QFormLayout(this); @@ -581,57 +581,53 @@ class EditorPanel : public QWidget { auto combo = QOverload::of(&QComboBox::currentIndexChanged); Settings *settings = Settings::instance(); - settings->beginGroup("editor"); - settings->beginGroup("font"); QFontComboBox *font = new QFontComboBox(this); font->setEditable(false); font->setFontFilters(QFontComboBox::MonospacedFonts); - font->setCurrentText(settings->value("family").toString()); + font->setCurrentText(settings->value(Setting::Id::FontFamily).toString()); connect(font, &QFontComboBox::currentTextChanged, [](const QString &text) { - Settings::instance()->setValue("editor/font/family", text); + Settings::instance()->setValue(Setting::Id::FontFamily, text); }); QSpinBox *fontSize = new QSpinBox(this); fontSize->setRange(2, 32); - fontSize->setValue(settings->value("size").toInt()); + fontSize->setValue(settings->value(Setting::Id::FontSize).toInt()); connect(fontSize, spin, [](int i) { - Settings::instance()->setValue("editor/font/size", i); + Settings::instance()->setValue(Setting::Id::FontSize, i); }); - settings->endGroup(); // font - settings->beginGroup("indent"); QComboBox *indent = new QComboBox(this); indent->addItem(tr("Tabs")); indent->addItem(tr("Spaces")); - indent->setCurrentIndex(settings->value("tabs").toBool() ? 0 : 1); + indent->setCurrentIndex( + settings->value(Setting::Id::UseTabsForIndent).toBool() ? 0 : 1); connect(indent, combo, [](int i) { - Settings::instance()->setValue("editor/indent/tabs", i == 0); + Settings::instance()->setValue(Setting::Id::UseTabsForIndent, i == 0); }); QSpinBox *indentWidth = new QSpinBox(this); indentWidth->setRange(1, 32); - indentWidth->setValue(settings->value("width").toInt()); + indentWidth->setValue(settings->value(Setting::Id::IndentWidth).toInt()); connect(indentWidth, spin, [](int i) { - Settings::instance()->setValue("editor/indent/width", i); + Settings::instance()->setValue(Setting::Id::IndentWidth, i); }); QSpinBox *tabWidth = new QSpinBox(this); tabWidth->setRange(1, 32); - tabWidth->setValue(settings->value("tabwidth").toInt()); + tabWidth->setValue(settings->value(Setting::Id::TabWidth).toInt()); connect(tabWidth, spin, [](int i) { - Settings::instance()->setValue("editor/indent/tabwidth", i); + Settings::instance()->setValue(Setting::Id::TabWidth, i); }); - settings->endGroup(); // indent QCheckBox *blameHeatMap = new QCheckBox(tr("Show heat map"), this); - blameHeatMap->setChecked(settings->value("blame/heatmap").toBool()); + blameHeatMap->setChecked( + settings->value(Setting::Id::ShowHeatmapInBlameMargin).toBool()); connect(blameHeatMap, &QCheckBox::toggled, [](bool checked) { - Settings::instance()->setValue("editor/blame/heatmap", checked); + Settings::instance()->setValue(Setting::Id::ShowHeatmapInBlameMargin, + checked); }); - settings->endGroup(); // editor - QFormLayout *layout = new QFormLayout(this); layout->addRow(tr("Font:"), font); layout->addRow(tr("Font size:"), fontSize); @@ -648,13 +644,14 @@ class UpdatePanel : public QWidget { public: UpdatePanel(QWidget *parent = nullptr) : QWidget(parent) { Settings *settings = Settings::instance(); - settings->beginGroup("update"); QString checkText = tr("Check for updates automatically"); QCheckBox *check = new QCheckBox(checkText, this); - check->setChecked(settings->value("check").toBool()); + check->setChecked( + settings->value(Setting::Id::CheckForUpdatesAutomatically).toBool()); connect(check, &QCheckBox::toggled, [](bool checked) { - Settings::instance()->setValue("update/check", checked); + Settings::instance()->setValue(Setting::Id::CheckForUpdatesAutomatically, + checked); }); #if !defined(Q_OS_LINUX) || defined(FLATPAK) @@ -662,9 +659,11 @@ class UpdatePanel : public QWidget { // no manual download is needed QString downloadText = tr("Automatically download and install updates"); QCheckBox *download = new QCheckBox(downloadText, this); - download->setChecked(settings->value("download").toBool()); + download->setChecked( + settings->value(Setting::Id::InstallUpdatesAutomatically).toBool()); connect(download, &QCheckBox::toggled, [](bool checked) { - Settings::instance()->setValue("update/download", checked); + Settings::instance()->setValue(Setting::Id::InstallUpdatesAutomatically, + checked); }); #endif @@ -678,8 +677,6 @@ class UpdatePanel : public QWidget { layout->addRow(QString(), download); #endif layout->addRow(QString(), button); - - settings->endGroup(); } }; @@ -690,16 +687,16 @@ class MiscPanel : public QWidget { MiscPanel(QWidget *parent = nullptr) : QWidget(parent) { Settings *settings = Settings::instance(); - QLineEdit *sshConfigPathBox = - new QLineEdit(settings->value("ssh/configFilePath").toString(), this); + QLineEdit *sshConfigPathBox = new QLineEdit( + settings->value(Setting::Id::SshConfigFilePath).toString(), this); connect(sshConfigPathBox, &QLineEdit::textChanged, [](const QString &text) { - Settings::instance()->setValue("ssh/configFilePath", text); + Settings::instance()->setValue(Setting::Id::SshConfigFilePath, text); }); - QLineEdit *sshKeyPathBox = - new QLineEdit(settings->value("ssh/keyFilePath").toString(), this); + QLineEdit *sshKeyPathBox = new QLineEdit( + settings->value(Setting::Id::SshKeyFilePath).toString(), this); connect(sshKeyPathBox, &QLineEdit::textChanged, [](const QString &text) { - Settings::instance()->setValue("ssh/keyFilePath", text); + Settings::instance()->setValue(Setting::Id::SshKeyFilePath, text); }); QFormLayout *layout = new QFormLayout(this); @@ -716,22 +713,21 @@ class TerminalPanel : public QWidget { public: TerminalPanel(QWidget *parent = nullptr) : QWidget(parent) { Settings *settings = Settings::instance(); - settings->beginGroup("terminal"); - mNameBox = new QLineEdit(settings->value("name").toString(), this); + mNameBox = new QLineEdit( + settings->value(Setting::Id::TerminalName).toString(), this); connect(mNameBox, &QLineEdit::textChanged, [this](const QString &text) { - Settings::instance()->setValue("terminal/name", text); + Settings::instance()->setValue(Setting::Id::TerminalName, text); updateInstallButton(); }); - mPathBox = new QLineEdit(settings->value("path").toString(), this); + mPathBox = new QLineEdit( + settings->value(Setting::Id::TerminalPath).toString(), this); connect(mPathBox, &QLineEdit::textChanged, [this](const QString &text) { - Settings::instance()->setValue("terminal/path", text); + Settings::instance()->setValue(Setting::Id::TerminalPath, text); updateInstallButton(); }); - settings->endGroup(); - mInstallButton = new QPushButton(tr("Install"), this); connect(mInstallButton, &QPushButton::clicked, [this] { Installer installer(mNameBox->text(), mPathBox->text()); diff --git a/src/dialogs/ThemeDialog.cpp b/src/dialogs/ThemeDialog.cpp index ffaf40cf4..c5ca00cb4 100644 --- a/src/dialogs/ThemeDialog.cpp +++ b/src/dialogs/ThemeDialog.cpp @@ -57,13 +57,13 @@ class ThemeButton : public QPushButton { connect(this, &QPushButton::clicked, [this] { switch (mTheme) { case Theme::System: - Settings::instance()->setValue("window/theme", "System"); + Settings::instance()->setValue(Setting::Id::ColorTheme, "System"); break; case Theme::Dark: - Settings::instance()->setValue("window/theme", "Dark"); + Settings::instance()->setValue(Setting::Id::ColorTheme, "Dark"); break; default: - Settings::instance()->setValue("window/theme", "Default"); + Settings::instance()->setValue(Setting::Id::ColorTheme, "Default"); break; } diff --git a/src/editor/TextEditor.cpp b/src/editor/TextEditor.cpp index bdb4e6f39..c53c0bb5c 100644 --- a/src/editor/TextEditor.cpp +++ b/src/editor/TextEditor.cpp @@ -171,19 +171,13 @@ void TextEditor::contextMenuEvent(QContextMenuEvent *event) { void TextEditor::applySettings() { // Set default font and size. Settings *settings = Settings::instance(); - settings->beginGroup("editor"); - settings->beginGroup("font"); - QString family = settings->value("family").toString(); - int pointSize = settings->value("size").toInt(); + QString family = settings->value(Setting::Id::FontFamily).toString(); + int pointSize = settings->value(Setting::Id::FontSize).toInt(); styleSetFont(STYLE_DEFAULT, QFont(family, pointSize)); - settings->endGroup(); // font - - settings->beginGroup("indent"); - setUseTabs(settings->value("tabs").toBool()); - setIndent(settings->value("width").toInt()); - setTabWidth(settings->value("tabwidth").toInt()); - settings->endGroup(); // indent - settings->endGroup(); // editor + + setUseTabs(settings->value(Setting::Id::UseTabsForIndent).toBool()); + setIndent(settings->value(Setting::Id::IndentWidth).toInt()); + setTabWidth(settings->value(Setting::Id::TabWidth).toInt()); // Initialize markers. QColor background = palette().color(QPalette::Base); diff --git a/src/tools/ShowTool.cpp b/src/tools/ShowTool.cpp index adaaf684c..e2b503d14 100644 --- a/src/tools/ShowTool.cpp +++ b/src/tools/ShowTool.cpp @@ -26,7 +26,7 @@ bool ShowTool::openFileManager(QString path) { QString fileManagerCmd = - Settings::instance()->value("filemanager/command").toString(); + Settings::instance()->value(Setting::Id::FilemanagerCommand).toString(); if (fileManagerCmd.isEmpty()) { #if defined(Q_OS_WIN) diff --git a/src/ui/BlameMargin.cpp b/src/ui/BlameMargin.cpp index 9d96e6b34..c815ddbde 100644 --- a/src/ui/BlameMargin.cpp +++ b/src/ui/BlameMargin.cpp @@ -62,7 +62,9 @@ void BlameMargin::startBlame(const QString &name) { void BlameMargin::setBlame(const git::Repository &repo, const git::Blame &blame) { - if (Settings::instance()->value("editor/blame/heatmap").toBool()) { + if (Settings::instance() + ->value(Setting::Id::ShowHeatmapInBlameMargin) + .toBool()) { git::Commit first = repo.walker(GIT_SORT_TIME | GIT_SORT_REVERSE).next(); git::Commit last = repo.walker(GIT_SORT_TIME).next(); mMinTime = first ? first.committer().date().toTime_t() : -1; diff --git a/src/ui/CommitList.cpp b/src/ui/CommitList.cpp index cd533262e..59c301610 100644 --- a/src/ui/CommitList.cpp +++ b/src/ui/CommitList.cpp @@ -608,7 +608,9 @@ class CommitDelegate : public QStyledItemDelegate { QStyleOptionViewItem opt = option; initStyleOption(&opt, index); - bool compact = Settings::instance()->value("commit/compact").toBool(); + bool compact = Settings::instance() + ->value(Setting::Id::ShowCommitsInCompactMode) + .toBool(); LayoutConstants constants = layoutConstants(compact); // Draw background. @@ -962,7 +964,9 @@ class CommitDelegate : public QStyledItemDelegate { QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override { - bool compact = Settings::instance()->value("commit/compact").toBool(); + bool compact = Settings::instance() + ->value(Setting::Id::ShowCommitsInCompactMode) + .toBool(); LayoutConstants constants = layoutConstants(compact); int lineHeight = constants.lineSpacing + constants.vMargin; @@ -981,7 +985,9 @@ class CommitDelegate : public QStyledItemDelegate { QRect starRect(const QStyleOptionViewItem &option, const QModelIndex &index) const { - bool compact = Settings::instance()->value("commit/compact").toBool(); + bool compact = Settings::instance() + ->value(Setting::Id::ShowCommitsInCompactMode) + .toBool(); LayoutConstants constants = layoutConstants(compact); QRect rect = option.rect; diff --git a/src/ui/CommitToolBar.cpp b/src/ui/CommitToolBar.cpp index 2d0b94de4..c6dc1ebc5 100644 --- a/src/ui/CommitToolBar.cpp +++ b/src/ui/CommitToolBar.cpp @@ -26,7 +26,6 @@ const QString kRefsKey = "commit.refs.all"; const QString kSortKey = "commit.sort.date"; const QString kGraphKey = "commit.graph.visible"; const QString kStatusKey = "commit.status.clean"; -const QString kCompactKey = "commit/compact"; const QString kStyleSheet = "QToolBar {" " border: none" "}" @@ -167,9 +166,12 @@ CommitToolBar::CommitToolBar(QWidget *parent) : QToolBar(parent) { QAction *compact = menu->addAction(tr("Compact Mode")); compact->setCheckable(true); - compact->setChecked(Settings::instance()->value(kCompactKey).toBool()); + compact->setChecked(Settings::instance() + ->value(Setting::Id::ShowCommitsInCompactMode) + .toBool()); connect(compact, &QAction::triggered, [this](bool checked) { - Settings::instance()->setValue(kCompactKey, checked); + Settings::instance()->setValue(Setting::Id::ShowCommitsInCompactMode, + checked); emit settingsChanged(); }); } diff --git a/src/ui/DiffView/FileWidget.cpp b/src/ui/DiffView/FileWidget.cpp index 8d8662ecf..505494de2 100644 --- a/src/ui/DiffView/FileWidget.cpp +++ b/src/ui/DiffView/FileWidget.cpp @@ -433,11 +433,15 @@ FileWidget::FileWidget(DiffView *view, const git::Diff &diff, // Start hidden when the file is checked. bool expand = (mHeader->check()->checkState() == Qt::Unchecked); - if (Settings::instance()->value("collapse/added").toBool() == true && + if (Settings::instance() + ->value(Setting::Id::AutoCollapseAddedFiles) + .toBool() == true && patch.status() == GIT_DELTA_ADDED) expand = false; - if (Settings::instance()->value("collapse/deleted").toBool() == true && + if (Settings::instance() + ->value(Setting::Id::AutoCollapseDeletedFiles) + .toBool() == true && patch.status() == GIT_DELTA_DELETED) expand = false; diff --git a/src/ui/DoubleTreeWidget.cpp b/src/ui/DoubleTreeWidget.cpp index aa9f7de08..e932f2a52 100644 --- a/src/ui/DoubleTreeWidget.cpp +++ b/src/ui/DoubleTreeWidget.cpp @@ -83,17 +83,22 @@ DoubleTreeWidget::DoubleTreeWidget(const git::Repository &repo, QWidget *parent) QAction *singleTree = new QAction(tr("Single Tree View")); singleTree->setCheckable(true); singleTree->setChecked( - Settings::instance()->value("doubletreeview/single", false).toBool()); + Settings::instance() + ->value(Setting::Id::ShowChangedFilesInSingleView, false) + .toBool()); connect(singleTree, &QAction::triggered, this, [this](bool checked) { - Settings::instance()->setValue("doubletreeview/single", checked); + Settings::instance()->setValue(Setting::Id::ShowChangedFilesInSingleView, + checked); RepoView::parentView(this)->refresh(); }); QAction *listView = new QAction(tr("List View")); listView->setCheckable(true); - listView->setChecked( - Settings::instance()->value("doubletreeview/listview", false).toBool()); + listView->setChecked(Settings::instance() + ->value(Setting::Id::ShowChangedFilesAsList, false) + .toBool()); connect(listView, &QAction::triggered, this, [this](bool checked) { - Settings::instance()->setValue("doubletreeview/listview", checked); + Settings::instance()->setValue(Setting::Id::ShowChangedFilesAsList, + checked); RepoView::parentView(this)->refresh(); }); contextMenu->addAction(singleTree); @@ -392,9 +397,12 @@ void DoubleTreeWidget::setDiff(const git::Diff &diff, const QString &file, // Single tree & list view. bool singleTree = - Settings::instance()->value("doubletreeview/single", false).toBool(); - bool listView = - Settings::instance()->value("doubletreeview/listview", false).toBool(); + Settings::instance() + ->value(Setting::Id::ShowChangedFilesInSingleView, false) + .toBool(); + bool listView = Settings::instance() + ->value(Setting::Id::ShowChangedFilesAsList, false) + .toBool(); // Widget modifications. model->enableListView(listView); diff --git a/src/ui/HotkeyManager.cpp b/src/ui/HotkeyManager.cpp index 33c3e0490..8a3d31f60 100644 --- a/src/ui/HotkeyManager.cpp +++ b/src/ui/HotkeyManager.cpp @@ -159,15 +159,10 @@ HotkeyManager::HotkeyManager(Settings *settings) if (!mSettings) mSettings = Settings::instance(); - mSettings->beginGroup("hotkeys"); - for (HotkeyManagerHandle *i = hotkeyRegistry; i; i = i->next) { mHandles[i->index] = i; - mKeys[i->index] = - getKeys(mSettings->value(i->configPath, "").toString(), i); + mKeys[i->index] = getKeys(mSettings->hotkey(i->configPath), i); } - - mSettings->endGroup(); } QVector HotkeyManager::knownHotkeys() const { @@ -186,8 +181,7 @@ QKeySequence HotkeyManager::keys(const HotkeyManagerHandle *handle) const { void HotkeyManager::setKeys(const HotkeyManagerHandle *handle, const QKeySequence &keys) { mKeys[handle->index] = keys; - mSettings->setValue("hotkeys/" + QString(handle->configPath), - keys.toString()); + mSettings->setHotkey(handle->configPath, keys.toString()); emit changed(handle); -} \ No newline at end of file +} diff --git a/src/ui/MainWindow.cpp b/src/ui/MainWindow.cpp index aab64df97..4e0d53bd4 100644 --- a/src/ui/MainWindow.cpp +++ b/src/ui/MainWindow.cpp @@ -95,17 +95,19 @@ MainWindow::MainWindow(const git::Repository &repo, QWidget *parent, }); // Update title and refresh when settings change. - mFullPath = Settings::instance()->value("window/path/full").toBool(); + mFullPath = + Settings::instance()->value(Setting::Id::ShowFullRepoPath).toBool(); connect(Settings::instance(), &Settings::settingsChanged, this, [this](bool refresh) { Settings *settings = Settings::instance(); bool menuBarHidden = - settings->value("window/view/menuBarHidden").toBool(); + settings->value(Setting::Id::HideMenuBar).toBool(); if (mMenuBar->isHidden() != menuBarHidden) mMenuBar->setHidden(menuBarHidden); - bool fullPath = settings->value("window/path/full").toBool(); + bool fullPath = + settings->value(Setting::Id::ShowFullRepoPath).toBool(); if (mFullPath != fullPath) { mFullPath = fullPath; updateWindowTitle(); @@ -253,7 +255,8 @@ RepoView *MainWindow::addTab(const git::Repository &repo) { tabs->setCurrentIndex(tabs->addTab(view, dir.dirName())); Settings *settings = Settings::instance(); - bool enable = settings->value("global/autoupdate/enable").toBool(); + bool enable = + settings->value(Setting::Id::UpdateSubmodulesAfterPullAndClone).toBool(); if (repo.appConfig().value("autoupdate.enable", enable)) { // update submodules view->updateSubmodules(repo.submodules(), true, true, false, nullptr); @@ -365,7 +368,7 @@ MainWindow *MainWindow::open(const QString &path, bool warnOnInvalid) { return nullptr; } - if (Settings::instance()->value("window/tabs/repository").toBool()) { + if (Settings::instance()->value(Setting::Id::OpenAllReposInTabs).toBool()) { if (MainWindow *win = activeWindow()) { win->addTab(repo); return win; diff --git a/src/ui/MenuBar.cpp b/src/ui/MenuBar.cpp index 1b8c2a1f4..f29e3a2a0 100644 --- a/src/ui/MenuBar.cpp +++ b/src/ui/MenuBar.cpp @@ -249,7 +249,7 @@ MenuBar::MenuBar(QWidget *parent) : QMenuBar(parent) { Settings *settings = Settings::instance(); - setHidden(settings->value("window/view/menuBarHidden").toBool()); + setHidden(settings->value(Setting::Id::HideMenuBar).toBool()); // File QMenu *file = addMenu(tr("File")); @@ -526,7 +526,7 @@ MenuBar::MenuBar(QWidget *parent) : QMenuBar(parent) { toggleMenuBarHotkey.use(mToggleMenuBar); connect(mToggleMenuBar, &QAction::triggered, [this] { setHidden(!isHidden()); - Settings::instance()->setValue("window/view/menuBarHidden", isHidden()); + Settings::instance()->setValue(Setting::Id::HideMenuBar, isHidden()); }); // Repository diff --git a/src/ui/RemoteCallbacks.cpp b/src/ui/RemoteCallbacks.cpp index 23e48adac..9d3fdf932 100644 --- a/src/ui/RemoteCallbacks.cpp +++ b/src/ui/RemoteCallbacks.cpp @@ -253,11 +253,11 @@ bool RemoteCallbacks::negotiation( } QString RemoteCallbacks::keyFilePath() const { - return Settings::instance()->value("ssh/keyFilePath").toString(); + return Settings::instance()->value(Setting::Id::SshKeyFilePath).toString(); } QString RemoteCallbacks::configFilePath() const { - return Settings::instance()->value("ssh/configFilePath").toString(); + return Settings::instance()->value(Setting::Id::SshConfigFilePath).toString(); } bool RemoteCallbacks::connectToAgent() const { diff --git a/src/ui/RepoView.cpp b/src/ui/RepoView.cpp index b57cd725a..075f5d65a 100644 --- a/src/ui/RepoView.cpp +++ b/src/ui/RepoView.cpp @@ -308,8 +308,7 @@ RepoView::RepoView(const git::Repository &repo, MainWindow *parent) &RepoView::refresh, Qt::QueuedConnection); connect(notifier, &git::RepositoryNotifier::directoryAboutToBeStaged, this, [this](const QString &dir, int count, bool &allow) { - if (!Settings::instance()->prompt( - Prompt::PromptKind::PromptDirectories)) + if (!Settings::instance()->prompt(Prompt::Kind::Directories)) return; QString title = tr("Stage Directory?"); @@ -330,48 +329,45 @@ RepoView::RepoView(const git::Repository &repo, MainWindow *parent) dialog.exec(); allow = (dialog.clickedButton() == button); if (cb->isChecked()) - Settings::instance()->setPrompt( - Prompt::PromptKind::PromptDirectories, false); + Settings::instance()->setPrompt(Prompt::Kind::Directories, false); }); // large file size warning - connect( - notifier, &git::RepositoryNotifier::largeFileAboutToBeStaged, this, - [this](const QString &file, int size, bool &allow) { - if (!Settings::instance()->prompt(Prompt::PromptKind::PromptLargeFiles)) - return; - - QString title = tr("Stage Large File?"); - QString fmt = - tr("Are you sure you want to stage '%1' with a size of %2?"); - QString text = fmt.arg(file, locale().formattedDataSize(size)); - QMessageBox dialog(QMessageBox::Question, title, text, - QMessageBox::Cancel, this); - QPushButton *stage = - dialog.addButton(tr("Stage"), QMessageBox::AcceptRole); - - QPushButton *track = nullptr; - if (this->repo().lfsIsInitialized()) { - track = - dialog.addButton(tr("Track with LFS"), QMessageBox::RejectRole); - dialog.setInformativeText( - tr("This repository has LFS enabled. Do you " - "want to track the file with LFS instead?")); - } + connect(notifier, &git::RepositoryNotifier::largeFileAboutToBeStaged, this, + [this](const QString &file, int size, bool &allow) { + if (!Settings::instance()->prompt(Prompt::Kind::LargeFiles)) + return; - QString cbText = tr("Stop prompting to stage large files"); - QCheckBox *cb = new QCheckBox(cbText, &dialog); - dialog.setCheckBox(cb); + QString title = tr("Stage Large File?"); + QString fmt = + tr("Are you sure you want to stage '%1' with a size of %2?"); + QString text = fmt.arg(file, locale().formattedDataSize(size)); + QMessageBox dialog(QMessageBox::Question, title, text, + QMessageBox::Cancel, this); + QPushButton *stage = + dialog.addButton(tr("Stage"), QMessageBox::AcceptRole); + + QPushButton *track = nullptr; + if (this->repo().lfsIsInitialized()) { + track = dialog.addButton(tr("Track with LFS"), + QMessageBox::RejectRole); + dialog.setInformativeText( + tr("This repository has LFS enabled. Do you " + "want to track the file with LFS instead?")); + } + + QString cbText = tr("Stop prompting to stage large files"); + QCheckBox *cb = new QCheckBox(cbText, &dialog); + dialog.setCheckBox(cb); - dialog.exec(); - allow = (dialog.clickedButton() == stage); - if (cb->isChecked()) - Settings::instance()->setPrompt(Prompt::PromptKind::PromptLargeFiles, - false); + dialog.exec(); + allow = (dialog.clickedButton() == stage); + if (cb->isChecked()) + Settings::instance()->setPrompt(Prompt::Kind::LargeFiles, false); - if (dialog.clickedButton() == track) - configureSettings(ConfigDialog::Lfs); - }); + if (dialog.clickedButton() == track) + configureSettings(ConfigDialog::Lfs); + }); // Refresh when the workdir changes. RepositoryWatcher *watcher = new RepositoryWatcher(repo, this); @@ -923,16 +919,15 @@ void RepoView::startFetchTimer() { // Read defaults from global settings. Settings *settings = Settings::instance(); - settings->beginGroup("global/autofetch"); - bool enable = settings->value("enable").toBool(); - int minutes = settings->value("minutes").toInt(); - settings->endGroup(); + bool enable = settings->value(Setting::Id::FetchAutomatically).toBool(); + int minutes = + settings->value(Setting::Id::AutomaticFetchPeriodInMinutes).toInt(); git::Config config = mRepo.appConfig(); if (!config.value("autofetch.enable", enable)) return; - bool prune = settings->value("global/autoprune/enable").toBool(); + bool prune = settings->value(Setting::Id::PruneAfterFetch).toBool(); fetch(git::Remote(), false, false, nullptr, nullptr, config.value("autoprune.enable", prune)); @@ -959,7 +954,8 @@ void RepoView::fetchAll() { QFuture RepoView::fetch(const git::Remote &rmt, bool tags, bool interactive, LogEntry *parent, QStringList *submodules) { - bool prune = Settings::instance()->value("global/autoprune/enable").toBool(); + bool prune = + Settings::instance()->value(Setting::Id::PruneAfterFetch).toBool(); return fetch(rmt, tags, interactive, parent, submodules, mRepo.appConfig().value("autoprune.enable", prune)); } @@ -1082,7 +1078,8 @@ void RepoView::pull(MergeFlags flags, const git::Remote &rmt, bool tags, // Read submodule setting. QStringList *submodules = nullptr; Settings *settings = Settings::instance(); - bool enable = settings->value("global/autoupdate/enable").toBool(); + bool enable = + settings->value(Setting::Id::UpdateSubmodulesAfterPullAndClone).toBool(); if (mRepo.appConfig().value("autoupdate.enable", enable)) submodules = new QStringList; @@ -1311,11 +1308,10 @@ void RepoView::merge(MergeFlags flags, const git::AnnotatedCommit &upstream, // Read default message. QString msg = mRepo.message(); - if (Settings::instance()->prompt(Prompt::PromptKind::PromptMerge)) { + if (Settings::instance()->prompt(Prompt::Kind::Merge)) { // Prompt to edit message. bool suspended = suspendLogTimer(); - CommitDialog *dialog = - new CommitDialog(msg, Prompt::PromptKind::PromptMerge, this); + CommitDialog *dialog = new CommitDialog(msg, Prompt::Kind::Merge, this); connect(dialog, &QDialog::rejected, this, [this, parent, suspended] { resumeLogTimer(suspended); mergeAbort(parent); @@ -1540,11 +1536,10 @@ void RepoView::revert(const git::Commit &commit) { QString id = commit.id().toString(); QString summary = commit.summary(); QString msg = tr("Revert \"%1\"\n\nThis reverts commit %2.").arg(summary, id); - if (Settings::instance()->prompt(Prompt::PromptKind::PromptRevert)) { + if (Settings::instance()->prompt(Prompt::Kind::Revert)) { // Prompt to edit message. bool suspended = suspendLogTimer(); - CommitDialog *dialog = - new CommitDialog(msg, Prompt::PromptKind::PromptRevert, this); + CommitDialog *dialog = new CommitDialog(msg, Prompt::Kind::Revert, this); connect(dialog, &QDialog::rejected, this, [this, parent, suspended] { resumeLogTimer(suspended); mergeAbort(parent); @@ -1589,11 +1584,11 @@ void RepoView::cherryPick(const git::Commit &commit) { nullptr, mDetails->overrideUser(), mDetails->overrideEmail()); QString msg = commit.message(); - if (Settings::instance()->prompt(Prompt::PromptKind::PromptCherryPick)) { + if (Settings::instance()->prompt(Prompt::Kind::CherryPick)) { // Prompt to edit message. bool suspended = suspendLogTimer(); CommitDialog *dialog = - new CommitDialog(msg, Prompt::PromptKind::PromptCherryPick, this); + new CommitDialog(msg, Prompt::Kind::CherryPick, this); connect(dialog, &QDialog::rejected, this, [this, parent, suspended] { resumeLogTimer(suspended); mergeAbort(parent); @@ -1869,7 +1864,8 @@ bool RepoView::commit(const git::Signature &author, } // Automatically push if enabled. - bool enable = Settings::instance()->value("global/autopush/enable").toBool(); + bool enable = + Settings::instance()->value(Setting::Id::PushAfterEachCommit).toBool(); if (mRepo.appConfig().value("autopush.enable", enable)) push(); // FIXME: Check for upstream before pushing? @@ -2046,7 +2042,7 @@ void RepoView::promptToDeleteBranch(const git::Reference &ref) { void RepoView::promptToStash() { // Prompt to edit stash commit message. - if (!Settings::instance()->prompt(Prompt::PromptKind::PromptStash)) { + if (!Settings::instance()->prompt(Prompt::Kind::Stash)) { stash(); return; } @@ -2057,8 +2053,7 @@ void RepoView::promptToStash() { QString id = commit.shortId(); QString ref = head.isBranch() ? head.name() : tr("(no branch)"); QString msg = tr("WIP on %1: %2 %3").arg(ref, id, commit.summary()); - CommitDialog *dialog = - new CommitDialog(msg, Prompt::PromptKind::PromptStash, this); + CommitDialog *dialog = new CommitDialog(msg, Prompt::Kind::Stash, this); connect(dialog, &QDialog::accepted, this, [this, msg, dialog] { QString userMsg = dialog->message(); stash(msg != userMsg ? userMsg : QString()); @@ -2525,7 +2520,7 @@ bool RepoView::openSubmodule(const git::Submodule &submodule) { return false; } - if (Settings::instance()->value("window/tabs/submodule").toBool()) + if (Settings::instance()->value(Setting::Id::OpenSubmodulesInTabs).toBool()) return static_cast(window())->addTab(repo); return MainWindow::open(repo); @@ -2539,7 +2534,7 @@ ConfigDialog *RepoView::configureSettings(ConfigDialog::Index index) { void RepoView::openTerminal() { QString terminalCmd = - Settings::instance()->value("terminal/command").toString(); + Settings::instance()->value(Setting::Id::TerminalCommand).toString(); if (terminalCmd.isEmpty()) { #if defined(Q_OS_WIN) @@ -2863,7 +2858,7 @@ void RepoView::startLogTimer() { setLogVisible(true); // Check the hide setting. - if (!Settings::instance()->value("window/log/hide").toBool()) + if (!Settings::instance()->value(Setting::Id::HideLogAutomatically).toBool()) return; resumeLogTimer(); diff --git a/src/update/UpdateDialog.cpp b/src/update/UpdateDialog.cpp index 4d492d867..4e2fbe0f9 100644 --- a/src/update/UpdateDialog.cpp +++ b/src/update/UpdateDialog.cpp @@ -85,9 +85,12 @@ UpdateDialog::UpdateDialog(const QString &platform, const QString &version, #if !defined(Q_OS_LINUX) || defined(FLATPAK) || defined(DEBUG_FLATPAK) QCheckBox *download = new QCheckBox(tr("Automatically download and install updates"), this); - download->setChecked(Settings::instance()->value("update/download").toBool()); + download->setChecked(Settings::instance() + ->value(Setting::Id::InstallUpdatesAutomatically) + .toBool()); connect(download, &QCheckBox::toggled, [](bool checked) { - Settings::instance()->setValue("update/download", checked); + Settings::instance()->setValue(Setting::Id::InstallUpdatesAutomatically, + checked); }); #endif @@ -104,11 +107,10 @@ UpdateDialog::UpdateDialog(const QString &platform, const QString &version, connect(skip, &QPushButton::clicked, [this, version] { Settings *settings = Settings::instance(); - settings->beginGroup("update"); - QStringList skipped = settings->value("skip").toStringList(); + QStringList skipped = + settings->value(Setting::Id::SkippedUpdates).toStringList(); if (!skipped.contains(version)) - settings->setValue("skip", skipped << version); - settings->endGroup(); + settings->setValue(Setting::Id::SkippedUpdates, skipped << version); reject(); }); diff --git a/src/update/Updater.cpp b/src/update/Updater.cpp index 7f26e9b5e..ef454de58 100644 --- a/src/update/Updater.cpp +++ b/src/update/Updater.cpp @@ -77,7 +77,9 @@ Updater::Updater(QObject *parent) : QObject(parent) { QCoreApplication::applicationVersion()); QVersionNumber newVersion = QVersionNumber::fromString(version); - if (Settings::instance()->value("update/download").toBool()) { + if (Settings::instance() + ->value(Setting::Id::InstallUpdatesAutomatically) + .toBool()) { // Skip the update dialog and just start downloading. if (Updater::DownloadRef download = this->download(link)) { DownloadDialog *dialog = new DownloadDialog(download); @@ -141,7 +143,7 @@ void Updater::update(bool spontaneous) { // Check for skipped version. QString version = versions.first(); - QVariant skipped = Settings::instance()->value("update/skip"); + QVariant skipped = Settings::instance()->value(Setting::Id::SkippedUpdates); if (spontaneous && skipped.toStringList().contains(version)) return; diff --git a/test/CommitAuthorCommitter.cpp b/test/CommitAuthorCommitter.cpp index cd13bbbc8..db376f5b8 100644 --- a/test/CommitAuthorCommitter.cpp +++ b/test/CommitAuthorCommitter.cpp @@ -32,16 +32,13 @@ private slots: }; void TestCommitAuthorCommitter::initTestCase() { - promptCherryPick = - Settings::instance()->prompt(Prompt::PromptKind::PromptCherryPick); - promptRevert = Settings::instance()->prompt(Prompt::PromptKind::PromptRevert); + promptCherryPick = Settings::instance()->prompt(Prompt::Kind::CherryPick); + promptRevert = Settings::instance()->prompt(Prompt::Kind::Revert); } void TestCommitAuthorCommitter::cleanupTestCase() { - Settings::instance()->setPrompt(Prompt::PromptKind::PromptCherryPick, - promptCherryPick); - Settings::instance()->setPrompt(Prompt::PromptKind::PromptRevert, - promptRevert); + Settings::instance()->setPrompt(Prompt::Kind::CherryPick, promptCherryPick); + Settings::instance()->setPrompt(Prompt::Kind::Revert, promptRevert); } /*! @@ -59,7 +56,7 @@ void TestCommitAuthorCommitter::testCherryPickAuthorEmailPreservance() { RepoView *view = window->currentView(); // Commit directly - Settings::instance()->setPrompt(Prompt::PromptKind::PromptCherryPick, false); + Settings::instance()->setPrompt(Prompt::Kind::CherryPick, false); view->cherryPick(commit); git::Reference master = repo.lookupRef(QString("refs/heads/master")); @@ -100,7 +97,7 @@ void TestCommitAuthorCommitter::testRevertAuthorEmailPreservance() { QCOMPARE(c.author().name(), "TestAuthor"); // Commit directly - Settings::instance()->setPrompt(Prompt::PromptKind::PromptRevert, false); + Settings::instance()->setPrompt(Prompt::Kind::Revert, false); view->revert(commit); // This lookup is important, because otherwise it is not up to date diff --git a/test/Setting.cpp b/test/Setting.cpp index f1488e706..0a146bbad 100644 --- a/test/Setting.cpp +++ b/test/Setting.cpp @@ -12,46 +12,53 @@ private slots: void defines_each_settings_key_only_once(); private: - QList ids() const; -}; - -void TestSetting::defines_a_non_empty_settings_key_for_each_id() { - QMetaEnum metaEnum = QMetaEnum::fromType(); - - foreach (const Setting::Id id, ids()) { - const QString settingsKey = Setting::key(id); + template QList ids() const { + QList ids; + QMetaEnum metaEnum = QMetaEnum::fromType(); + for (int i = 0; i < metaEnum.keyCount(); i++) { + ids << static_cast(metaEnum.value(i)); + } + return ids; + } - QVERIFY2(!settingsKey.isEmpty(), - qPrintable(QString("no settings key defined for %1::%2::%3") - .arg(metaEnum.scope(), metaEnum.name(), - metaEnum.valueToKey(static_cast(id))))); + template QStringList settingsKeys() { + QStringList settingsKeys; + foreach (const TId id, ids()) { settingsKeys.append(T::key(id)); } + return settingsKeys; } -} -void TestSetting::defines_each_settings_key_only_once() { - QStringList settingsKeys; - foreach (const Setting::Id id, ids()) { - const QString settingsKey = Setting::key(id); + template void verifyNonEmptySettingsKeyForEachId() { + QMetaEnum metaEnum = QMetaEnum::fromType(); - QVERIFY2( - !settingsKeys.contains(settingsKey), - qPrintable( - QString("the settings key '%1' is used for multiple settings ids") - .arg(settingsKey))); + foreach (const TId id, ids()) { + const QString settingsKey = T::key(id); - settingsKeys << settingsKey; + QVERIFY2(!settingsKey.isEmpty(), + qPrintable(QString("no settings key defined for %1::%2::%3") + .arg(metaEnum.scope(), metaEnum.name(), + metaEnum.valueToKey(static_cast(id))))); + } } -} +}; -QList TestSetting::ids() const { - QList ids; +void TestSetting::defines_a_non_empty_settings_key_for_each_id() { + verifyNonEmptySettingsKeyForEachId(); + verifyNonEmptySettingsKeyForEachId(); +} - QMetaEnum metaEnum = QMetaEnum::fromType(); - for (int i = 0; i < metaEnum.keyCount(); i++) { - ids << static_cast(metaEnum.value(i)); +void TestSetting::defines_each_settings_key_only_once() { + QStringList allSettingsKeys; + allSettingsKeys.append(settingsKeys()); + allSettingsKeys.append(settingsKeys()); + + QStringList uniqueSettingsKeys; + foreach (const QString &settingsKey, allSettingsKeys) { + QVERIFY2(!uniqueSettingsKeys.contains(settingsKey), + qPrintable( + QString("the settings key '%1' is used for multiple settings") + .arg(settingsKey))); + uniqueSettingsKeys.append(settingsKey); } - - return ids; } TEST_MAIN(TestSetting) diff --git a/test/Submodule.cpp b/test/Submodule.cpp index 39f080d1d..19f8b2752 100644 --- a/test/Submodule.cpp +++ b/test/Submodule.cpp @@ -56,7 +56,7 @@ void TestSubmodule::updateSubmoduleClone() { QCOMPARE(remote.isEmpty(), false); Settings *settings = Settings::instance(); - settings->setValue("global/autoupdate/enable", true); + settings->setValue(Setting::Id::UpdateSubmodulesAfterPullAndClone, true); CloneDialog *d = new CloneDialog(CloneDialog::Kind::Clone); RepoView *view = nullptr; @@ -97,7 +97,7 @@ void TestSubmodule::noUpdateSubmoduleClone() { QCOMPARE(remote.isEmpty(), false); Settings *settings = Settings::instance(); - settings->setValue("global/autoupdate/enable", false); + settings->setValue(Setting::Id::UpdateSubmodulesAfterPullAndClone, false); CloneDialog *d = new CloneDialog(CloneDialog::Kind::Clone); RepoView *view = nullptr;