diff options
Diffstat (limited to 'src/plugins/git/gitsettings.cpp')
-rw-r--r-- | src/plugins/git/gitsettings.cpp | 123 |
1 files changed, 51 insertions, 72 deletions
diff --git a/src/plugins/git/gitsettings.cpp b/src/plugins/git/gitsettings.cpp index 25a8f77988e..4ebf7debeed 100644 --- a/src/plugins/git/gitsettings.cpp +++ b/src/plugins/git/gitsettings.cpp @@ -17,43 +17,46 @@ using namespace VcsBase; namespace Git::Internal { +static GitSettings *theSettings; + +GitSettings &settings() +{ + return *theSettings; +} + GitSettings::GitSettings() { + theSettings = this; + + setId(VcsBase::Constants::VCS_ID_GIT); + setDisplayName(Tr::tr("Git")); + setCategory(VcsBase::Constants::VCS_SETTINGS_CATEGORY); setSettingsGroup("Git"); path.setDisplayStyle(StringAspect::LineEditDisplay); path.setLabelText(Tr::tr("Prepend to PATH:")); - registerAspect(&binaryPath); binaryPath.setDefaultValue("git"); - registerAspect(&pullRebase); pullRebase.setSettingsKey("PullRebase"); pullRebase.setLabelText(Tr::tr("Pull with rebase")); - registerAspect(&showTags); showTags.setSettingsKey("ShowTags"); - registerAspect(&omitAnnotationDate); omitAnnotationDate.setSettingsKey("OmitAnnotationDate"); - registerAspect(&ignoreSpaceChangesInDiff); ignoreSpaceChangesInDiff.setSettingsKey("SpaceIgnorantDiff"); ignoreSpaceChangesInDiff.setDefaultValue(true); - registerAspect(&ignoreSpaceChangesInBlame); ignoreSpaceChangesInBlame.setSettingsKey("SpaceIgnorantBlame"); ignoreSpaceChangesInBlame.setDefaultValue(true); - registerAspect(&blameMoveDetection); blameMoveDetection.setSettingsKey("BlameDetectMove"); blameMoveDetection.setDefaultValue(0); - registerAspect(&diffPatience); diffPatience.setSettingsKey("DiffPatience"); diffPatience.setDefaultValue(true); - registerAspect(&winSetHomeEnvironment); winSetHomeEnvironment.setSettingsKey("WinSetHomeEnvironment"); winSetHomeEnvironment.setDefaultValue(true); winSetHomeEnvironment.setLabelText(Tr::tr("Set \"HOME\" environment variable")); @@ -71,129 +74,105 @@ GitSettings::GitSettings() winSetHomeEnvironment.setVisible(false); } - registerAspect(&gitkOptions); gitkOptions.setDisplayStyle(StringAspect::LineEditDisplay); gitkOptions.setSettingsKey("GitKOptions"); gitkOptions.setLabelText(Tr::tr("Arguments:")); - registerAspect(&logDiff); logDiff.setSettingsKey("LogDiff"); logDiff.setToolTip(Tr::tr("Note that huge amount of commits might take some time.")); - registerAspect(&repositoryBrowserCmd); - repositoryBrowserCmd.setDisplayStyle(StringAspect::PathChooserDisplay); repositoryBrowserCmd.setSettingsKey("RepositoryBrowserCmd"); repositoryBrowserCmd.setExpectedKind(PathChooser::ExistingCommand); repositoryBrowserCmd.setHistoryCompleter("Git.RepoCommand.History"); repositoryBrowserCmd.setDisplayName(Tr::tr("Git Repository Browser Command")); repositoryBrowserCmd.setLabelText(Tr::tr("Command:")); - registerAspect(&instantBlame); instantBlame.setSettingsKey("Git Instant"); instantBlame.setDefaultValue(true); instantBlame.setLabelText(Tr::tr("Add instant blame annotations to editor")); - instantBlame.setToolTip(Tr::tr("Directly annotate each line in the editor " - "when scrolling through the document.")); + instantBlame.setToolTip( + Tr::tr("Annotate the current line in the editor with Git \"blame\" output.")); - registerAspect(&graphLog); graphLog.setSettingsKey("GraphLog"); - registerAspect(&colorLog); colorLog.setSettingsKey("ColorLog"); colorLog.setDefaultValue(true); - registerAspect(&firstParent); firstParent.setSettingsKey("FirstParent"); - registerAspect(&followRenames); followRenames.setSettingsKey("FollowRenames"); followRenames.setDefaultValue(true); - registerAspect(&lastResetIndex); lastResetIndex.setSettingsKey("LastResetIndex"); - registerAspect(&refLogShowDate); refLogShowDate.setSettingsKey("RefLogShowDate"); timeout.setDefaultValue(Utils::HostOsInfo::isWindowsHost() ? 60 : 30); - connect(&binaryPath, &StringAspect::valueChanged, this, [this] { tryResolve = true; }); - connect(&path, &StringAspect::valueChanged, this, [this] { tryResolve = true; }); -} - -FilePath GitSettings::gitExecutable(bool *ok, QString *errorMessage) const -{ - // Locate binary in path if one is specified, otherwise default to pathless binary. - if (ok) - *ok = true; - if (errorMessage) - errorMessage->clear(); - - if (tryResolve) { - resolvedBinPath = binaryPath.filePath(); - if (!resolvedBinPath.isAbsolutePath()) - resolvedBinPath = resolvedBinPath.searchInPath({path.filePath()}, FilePath::PrependToPath); - tryResolve = false; - } - - if (resolvedBinPath.isEmpty()) { - if (ok) - *ok = false; - if (errorMessage) - *errorMessage = Tr::tr("The binary \"%1\" could not be located in the path \"%2\"") - .arg(binaryPath.value(), path.value()); - } - return resolvedBinPath; -} - -// GitSettingsPage - -GitSettingsPage::GitSettingsPage(GitSettings *settings) -{ - setId(VcsBase::Constants::VCS_ID_GIT); - setDisplayName(Tr::tr("Git")); - setCategory(VcsBase::Constants::VCS_SETTINGS_CATEGORY); - setSettings(settings); - - setLayouter([settings](QWidget *widget) { - GitSettings &s = *settings; + setLayouter([this] { using namespace Layouting; - - Column { + return Column { Group { title(Tr::tr("Configuration")), Column { - Row { s.path }, - s.winSetHomeEnvironment, + Row { path }, + winSetHomeEnvironment, } }, Group { title(Tr::tr("Miscellaneous")), Column { - Row { s.logCount, s.timeout, st }, - s.pullRebase + Row { logCount, timeout, st }, + pullRebase } }, Group { title(Tr::tr("Gitk")), - Row { s.gitkOptions } + Row { gitkOptions } }, Group { title(Tr::tr("Repository Browser")), - Row { s.repositoryBrowserCmd } + Row { repositoryBrowserCmd } }, Group { title(Tr::tr("Instant Blame")), - Row { s.instantBlame } + Row { instantBlame } }, st - }.attachTo(widget); + }; }); + connect(&binaryPath, &StringAspect::valueChanged, this, [this] { tryResolve = true; }); + connect(&path, &StringAspect::valueChanged, this, [this] { tryResolve = true; }); +} + +FilePath GitSettings::gitExecutable(bool *ok, QString *errorMessage) const +{ + // Locate binary in path if one is specified, otherwise default to pathless binary. + if (ok) + *ok = true; + if (errorMessage) + errorMessage->clear(); + + if (tryResolve) { + resolvedBinPath = binaryPath(); + if (!resolvedBinPath.isAbsolutePath()) + resolvedBinPath = resolvedBinPath.searchInPath({path.filePath()}, FilePath::PrependToPath); + tryResolve = false; + } + + if (resolvedBinPath.isEmpty()) { + if (ok) + *ok = false; + if (errorMessage) + *errorMessage = Tr::tr("The binary \"%1\" could not be located in the path \"%2\"") + .arg(binaryPath.value(), path.value()); + } + return resolvedBinPath; } } // Git::Internal |