summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2023-05-15 14:23:01 +0200
committerhjk <hjk@qt.io>2023-05-15 13:09:47 +0000
commit545a105634057a6c0f7af11425ac26383ed5c7f5 (patch)
treed3479d2d4191103da670de5de42a3245366dc2eb
parentc82d7ccdcde982b40ecb6690af2dd182fd8dba75 (diff)
downloadqt-creator-545a105634057a6c0f7af11425ac26383ed5c7f5.tar.gz
Git: Also use the latest settings setup approach
Change-Id: I34a210575d02d18927c1e0f6d8ea6cb9924c563d Reviewed-by: Orgad Shaneh <orgads@gmail.com>
-rw-r--r--src/plugins/git/branchmodel.cpp4
-rw-r--r--src/plugins/git/branchview.cpp4
-rw-r--r--src/plugins/git/gitclient.cpp56
-rw-r--r--src/plugins/git/gitclient.h5
-rw-r--r--src/plugins/git/giteditor.cpp2
-rw-r--r--src/plugins/git/gitplugin.cpp30
-rw-r--r--src/plugins/git/gitplugin.h3
-rw-r--r--src/plugins/git/gitsettings.cpp14
-rw-r--r--src/plugins/git/gitsettings.h4
-rw-r--r--src/plugins/git/logchangedialog.cpp4
10 files changed, 63 insertions, 63 deletions
diff --git a/src/plugins/git/branchmodel.cpp b/src/plugins/git/branchmodel.cpp
index 859f177845..8a495a8d8f 100644
--- a/src/plugins/git/branchmodel.cpp
+++ b/src/plugins/git/branchmodel.cpp
@@ -428,7 +428,7 @@ void BranchModel::refresh(const FilePath &workingDirectory, ShowError showError)
"%(*objectname)\t%(committerdate:raw)\t%(*committerdate:raw)",
"refs/heads/**",
"refs/remotes/**"};
- if (d->client->settings().showTags.value())
+ if (settings().showTags())
args << "refs/tags/**";
d->client->setupCommand(process, workingDirectory, args);
};
@@ -805,7 +805,7 @@ void BranchModel::Private::parseOutputLine(const QString &line, bool force)
const qint64 age = dateTime.daysTo(QDateTime::currentDateTime());
isOld = age > Constants::OBSOLETE_COMMIT_AGE_IN_DAYS;
}
- const bool showTags = client->settings().showTags.value();
+ const bool showTags = settings().showTags();
// insert node into tree:
QStringList nameParts = fullName.split('/');
diff --git a/src/plugins/git/branchview.cpp b/src/plugins/git/branchview.cpp
index 3915d20ab8..ff428b1b90 100644
--- a/src/plugins/git/branchview.cpp
+++ b/src/plugins/git/branchview.cpp
@@ -115,7 +115,7 @@ BranchView::BranchView()
connect(m_includeOldEntriesAction, &QAction::toggled,
this, &BranchView::setIncludeOldEntries);
m_includeTagsAction->setCheckable(true);
- m_includeTagsAction->setChecked(GitClient::settings().showTags.value());
+ m_includeTagsAction->setChecked(settings().showTags.value());
connect(m_includeTagsAction, &QAction::toggled,
this, &BranchView::setIncludeTags);
@@ -319,7 +319,7 @@ void BranchView::setIncludeOldEntries(bool filter)
void BranchView::setIncludeTags(bool includeTags)
{
- GitClient::settings().showTags.setValue(includeTags);
+ settings().showTags.setValue(includeTags);
refreshCurrentRepository();
}
diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp
index fa42a2565e..53268c9742 100644
--- a/src/plugins/git/gitclient.cpp
+++ b/src/plugins/git/gitclient.cpp
@@ -491,16 +491,16 @@ class BaseGitDiffArgumentsWidget : public VcsBaseEditorConfig
Q_OBJECT
public:
- BaseGitDiffArgumentsWidget(GitSettings &settings, QToolBar *toolBar) :
- VcsBaseEditorConfig(toolBar)
+ explicit BaseGitDiffArgumentsWidget(QToolBar *toolBar)
+ : VcsBaseEditorConfig(toolBar)
{
m_patienceButton
= addToggleButton("--patience", Tr::tr("Patience"),
Tr::tr("Use the patience algorithm for calculating the differences."));
- mapSetting(m_patienceButton, &settings.diffPatience);
+ mapSetting(m_patienceButton, &settings().diffPatience);
m_ignoreWSButton = addToggleButton("--ignore-space-change", Tr::tr("Ignore Whitespace"),
Tr::tr("Ignore whitespace only changes."));
- mapSetting(m_ignoreWSButton, &settings.ignoreSpaceChangesInDiff);
+ mapSetting(m_ignoreWSButton, &settings().ignoreSpaceChangesInDiff);
}
protected:
@@ -513,15 +513,15 @@ class GitBlameArgumentsWidget : public VcsBaseEditorConfig
Q_OBJECT
public:
- GitBlameArgumentsWidget(GitSettings &settings, QToolBar *toolBar) :
- VcsBaseEditorConfig(toolBar)
+ explicit GitBlameArgumentsWidget(QToolBar *toolBar)
+ : VcsBaseEditorConfig(toolBar)
{
mapSetting(addToggleButton(QString(), Tr::tr("Omit Date"),
Tr::tr("Hide the date of a change from the output.")),
- &settings.omitAnnotationDate);
+ &settings().omitAnnotationDate);
mapSetting(addToggleButton("-w", Tr::tr("Ignore Whitespace"),
Tr::tr("Ignore whitespace only changes.")),
- &settings.ignoreSpaceChangesInBlame);
+ &settings().ignoreSpaceChangesInBlame);
const QList<ChoiceItem> logChoices = {
ChoiceItem(Tr::tr("No Move Detection"), ""),
@@ -530,7 +530,7 @@ public:
ChoiceItem(Tr::tr("Detect Moves and Copies Between Files"), "-M -C -C")
};
mapSetting(addChoices(Tr::tr("Move detection"), {}, logChoices),
- &settings.blameMoveDetection);
+ &settings().blameMoveDetection);
addReloadButton();
}
@@ -541,13 +541,13 @@ class BaseGitLogArgumentsWidget : public BaseGitDiffArgumentsWidget
Q_OBJECT
public:
- BaseGitLogArgumentsWidget(GitSettings &settings, GitEditorWidget *editor) :
- BaseGitDiffArgumentsWidget(settings, editor->toolBar())
+ BaseGitLogArgumentsWidget(GitEditorWidget *editor)
+ : BaseGitDiffArgumentsWidget(editor->toolBar())
{
QToolBar *toolBar = editor->toolBar();
QAction *diffButton = addToggleButton(patchOption, Tr::tr("Diff"),
Tr::tr("Show difference."));
- mapSetting(diffButton, &settings.logDiff);
+ mapSetting(diffButton, &settings().logDiff);
connect(diffButton, &QAction::toggled, m_patienceButton, &QAction::setVisible);
connect(diffButton, &QAction::toggled, m_ignoreWSButton, &QAction::setVisible);
m_patienceButton->setVisible(diffButton->isChecked());
@@ -582,27 +582,27 @@ class GitLogArgumentsWidget : public BaseGitLogArgumentsWidget
Q_OBJECT
public:
- GitLogArgumentsWidget(GitSettings &settings, bool fileRelated, GitEditorWidget *editor) :
- BaseGitLogArgumentsWidget(settings, editor)
+ GitLogArgumentsWidget(bool fileRelated, GitEditorWidget *editor)
+ : BaseGitLogArgumentsWidget(editor)
{
QAction *firstParentButton =
addToggleButton({"-m", "--first-parent"},
Tr::tr("First Parent"),
Tr::tr("Follow only the first parent on merge commits."));
- mapSetting(firstParentButton, &settings.firstParent);
+ mapSetting(firstParentButton, &settings().firstParent);
QAction *graphButton = addToggleButton(graphArguments(), Tr::tr("Graph"),
Tr::tr("Show textual graph log."));
- mapSetting(graphButton, &settings.graphLog);
+ mapSetting(graphButton, &settings().graphLog);
QAction *colorButton = addToggleButton(QStringList{colorOption},
Tr::tr("Color"), Tr::tr("Use colors in log."));
- mapSetting(colorButton, &settings.colorLog);
+ mapSetting(colorButton, &settings().colorLog);
if (fileRelated) {
QAction *followButton = addToggleButton(
"--follow", Tr::tr("Follow"),
Tr::tr("Show log also for previous names of the file."));
- mapSetting(followButton, &settings.followRenames);
+ mapSetting(followButton, &settings().followRenames);
}
addReloadButton();
@@ -641,14 +641,14 @@ class GitRefLogArgumentsWidget : public BaseGitLogArgumentsWidget
Q_OBJECT
public:
- GitRefLogArgumentsWidget(GitSettings &settings, GitEditorWidget *editor) :
- BaseGitLogArgumentsWidget(settings, editor)
+ explicit GitRefLogArgumentsWidget(GitEditorWidget *editor)
+ : BaseGitLogArgumentsWidget(editor)
{
QAction *showDateButton =
addToggleButton("--date=iso",
Tr::tr("Show Date"),
Tr::tr("Show date instead of sequence."));
- mapSetting(showDateButton, &settings.refLogShowDate);
+ mapSetting(showDateButton, &settings().refLogShowDate);
addReloadButton();
}
@@ -736,8 +736,8 @@ static inline void msgCannotRun(const QStringList &args, const FilePath &working
// ---------------- GitClient
-GitClient::GitClient(GitSettings *settings)
- : VcsBase::VcsBaseClientImpl(settings)
+GitClient::GitClient()
+ : VcsBase::VcsBaseClientImpl(&Internal::settings())
{
m_instance = this;
m_gitQtcEditor = QString::fromLatin1("\"%1\" -client -block -pid %2")
@@ -752,7 +752,7 @@ GitClient *GitClient::instance()
GitSettings &GitClient::settings()
{
- return static_cast<GitSettings &>(m_instance->VcsBaseClientImpl::settings());
+ return Internal::settings();
}
FilePath GitClient::findRepositoryForDirectory(const FilePath &directory) const
@@ -1075,7 +1075,7 @@ void GitClient::log(const FilePath &workingDirectory, const QString &fileName,
encoding(EncodingLogOutput), "logTitle", msgArg));
VcsBaseEditorConfig *argWidget = editor->editorConfig();
if (!argWidget) {
- argWidget = new GitLogArgumentsWidget(settings(), !fileName.isEmpty(), editor);
+ argWidget = new GitLogArgumentsWidget(!fileName.isEmpty(), editor);
argWidget->setBaseArguments(args);
connect(argWidget, &VcsBaseEditorConfig::commandExecutionRequested, this,
[=] { this->log(workingDir, fileName, enableAnnotationContextMenu, args); });
@@ -1131,7 +1131,7 @@ void GitClient::reflog(const FilePath &workingDirectory, const QString &ref)
"reflogRepository", workingDir.toString()));
VcsBaseEditorConfig *argWidget = editor->editorConfig();
if (!argWidget) {
- argWidget = new GitRefLogArgumentsWidget(settings(), editor);
+ argWidget = new GitRefLogArgumentsWidget(editor);
if (!ref.isEmpty())
argWidget->setBaseArguments({ref});
connect(argWidget, &VcsBaseEditorConfig::commandExecutionRequested, this,
@@ -1243,7 +1243,7 @@ void GitClient::annotate(const Utils::FilePath &workingDir, const QString &file,
encoding(EncodingSource, sourceFile), "blameFileName", id);
VcsBaseEditorConfig *argWidget = editor->editorConfig();
if (!argWidget) {
- argWidget = new GitBlameArgumentsWidget(settings(), editor->toolBar());
+ argWidget = new GitBlameArgumentsWidget(editor->toolBar());
argWidget->setBaseArguments(extraOptions);
connect(argWidget, &VcsBaseEditorConfig::commandExecutionRequested, this, [=] {
const int line = VcsBaseEditor::lineNumberOfCurrentEditor();
@@ -2574,7 +2574,7 @@ bool GitClient::launchGitBash(const FilePath &workingDirectory)
FilePath GitClient::vcsBinary() const
{
bool ok;
- Utils::FilePath binary = static_cast<GitSettings &>(settings()).gitExecutable(&ok);
+ Utils::FilePath binary = settings().gitExecutable(&ok);
if (!ok)
return Utils::FilePath();
return binary;
diff --git a/src/plugins/git/gitclient.h b/src/plugins/git/gitclient.h
index fb3a06b355..88c2f3870f 100644
--- a/src/plugins/git/gitclient.h
+++ b/src/plugins/git/gitclient.h
@@ -115,9 +115,8 @@ public:
PushAction m_pushAction = NoPush;
};
- explicit GitClient(GitSettings *settings);
+ GitClient();
static GitClient *instance();
- static GitSettings &settings();
Utils::FilePath vcsBinary() const override;
QFuture<unsigned> gitVersion() const;
@@ -350,6 +349,8 @@ public:
QTextCodec *encoding(EncodingType encodingType, const Utils::FilePath &source = {}) const;
private:
+ static GitSettings &settings();
+
void finishSubmoduleUpdate();
void chunkActionsRequested(DiffEditor::DiffEditorController *controller,
QMenu *menu, int fileIndex, int chunkIndex,
diff --git a/src/plugins/git/giteditor.cpp b/src/plugins/git/giteditor.cpp
index 7f73842cb0..c7078dc2ba 100644
--- a/src/plugins/git/giteditor.cpp
+++ b/src/plugins/git/giteditor.cpp
@@ -132,7 +132,7 @@ static QString sanitizeBlameOutput(const QString &b)
if (b.isEmpty())
return b;
- const bool omitDate = GitClient::instance()->settings().omitAnnotationDate.value();
+ const bool omitDate = settings().omitAnnotationDate.value();
const QChar space(' ');
const int parenPos = b.indexOf(')');
if (parenPos == -1)
diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp
index a9d1cb0c6f..0401eb835e 100644
--- a/src/plugins/git/gitplugin.cpp
+++ b/src/plugins/git/gitplugin.cpp
@@ -420,8 +420,7 @@ public:
ParameterAction *m_applyCurrentFilePatchAction = nullptr;
Gerrit::Internal::GerritPlugin m_gerritPlugin;
- GitSettings m_settings;
- GitClient m_gitClient{&m_settings};
+ GitClient m_gitClient;
QPointer<StashDialog> m_stashDialog;
BranchViewFactory m_branchViewFactory;
QPointer<RemoteDialog> m_remoteDialog;
@@ -434,7 +433,7 @@ public:
std::unique_ptr<BlameMark> m_blameMark;
QMetaObject::Connection m_blameCursorPosConn;
- GitSettingsPage settingPage{&m_settings};
+ GitSettingsPage settingPage;
GitGrep gitGrep{&m_gitClient};
@@ -524,7 +523,7 @@ void GitPluginPrivate::onApplySettings()
updateRepositoryBrowserAction();
bool gitFoundOk;
QString errorMessage;
- m_settings.gitExecutable(&gitFoundOk, &errorMessage);
+ settings().gitExecutable(&gitFoundOk, &errorMessage);
if (!gitFoundOk) {
QTimer::singleShot(0, this, [errorMessage] {
AsynchronousMessageBox::warning(Tr::tr("Git Settings"), errorMessage);
@@ -555,11 +554,6 @@ IVersionControl *GitPlugin::versionControl()
return dd;
}
-const GitSettings &GitPlugin::settings()
-{
- return dd->m_settings;
-}
-
const VcsBasePluginState &GitPlugin::currentState()
{
return dd->currentState();
@@ -1069,7 +1063,7 @@ GitPluginPrivate::GitPluginPrivate()
m_gerritPlugin.updateActions(currentState());
m_gerritPlugin.addToLocator(m_commandLocator);
- connect(&m_settings, &AspectContainer::applied, this, &GitPluginPrivate::onApplySettings);
+ connect(&settings(), &AspectContainer::applied, this, &GitPluginPrivate::onApplySettings);
setupInstantBlame();
}
@@ -1439,7 +1433,7 @@ void GitPluginPrivate::setupInstantBlame()
return;
}
- if (!GitClient::instance()->settings().instantBlame.value()) {
+ if (!settings().instantBlame.value()) {
m_lastVisitedEditorLine = -1;
stopInstantBlame();
return;
@@ -1459,7 +1453,7 @@ void GitPluginPrivate::setupInstantBlame()
m_blameCursorPosConn = connect(widget, &QPlainTextEdit::cursorPositionChanged, this,
[this] {
- if (!GitClient::instance()->settings().instantBlame.value()) {
+ if (!settings().instantBlame.value()) {
disconnect(m_blameCursorPosConn);
return;
}
@@ -1470,8 +1464,8 @@ void GitPluginPrivate::setupInstantBlame()
instantBlame();
};
- connect(&GitClient::instance()->settings().instantBlame,
- &BoolAspect::valueChanged, this, [this, setupBlameForEditor](bool enabled) {
+ connect(&settings().instantBlame, &BoolAspect::valueChanged, this,
+ [this, setupBlameForEditor](bool enabled) {
if (enabled)
setupBlameForEditor(EditorManager::currentEditor());
else
@@ -1520,7 +1514,7 @@ CommitInfo parseBlameOutput(const QStringList &blame, const Utils::FilePath &fil
void GitPluginPrivate::instantBlameOnce()
{
- if (!GitClient::instance()->settings().instantBlame.value()) {
+ if (!settings().instantBlame.value()) {
const TextEditorWidget *widget = TextEditorWidget::currentTextEditorWidget();
if (!widget)
return;
@@ -1682,7 +1676,7 @@ void GitPluginPrivate::pull()
const VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasTopLevel(), return);
FilePath topLevel = state.topLevel();
- bool rebase = m_settings.pullRebase.value();
+ bool rebase = settings().pullRebase.value();
if (!rebase) {
QString currentBranch = m_gitClient.synchronousCurrentLocalBranch(topLevel);
@@ -1993,7 +1987,7 @@ QObject *GitPlugin::remoteCommand(const QStringList &options, const QString &wor
void GitPluginPrivate::updateRepositoryBrowserAction()
{
const bool repositoryEnabled = currentState().hasTopLevel();
- const bool hasRepositoryBrowserCmd = !m_settings.repositoryBrowserCmd.value().isEmpty();
+ const bool hasRepositoryBrowserCmd = !settings().repositoryBrowserCmd.value().isEmpty();
m_repositoryBrowserAction->setEnabled(repositoryEnabled && hasRepositoryBrowserCmd);
}
@@ -2099,7 +2093,7 @@ GitPluginPrivate::RepoUrl GitPluginPrivate::getRepoUrl(const QString &location)
FilePaths GitPluginPrivate::additionalToolsPath() const
{
- FilePaths res = m_gitClient.settings().searchPathList();
+ FilePaths res = settings().searchPathList();
const FilePath binaryPath = m_gitClient.gitBinDirectory();
if (!binaryPath.isEmpty() && !res.contains(binaryPath))
res << binaryPath;
diff --git a/src/plugins/git/gitplugin.h b/src/plugins/git/gitplugin.h
index 0b0e751801..59d9a87fde 100644
--- a/src/plugins/git/gitplugin.h
+++ b/src/plugins/git/gitplugin.h
@@ -3,7 +3,6 @@
#pragma once
-#include "gitsettings.h"
#include "git_global.h"
#include <coreplugin/iversioncontrol.h>
@@ -36,7 +35,6 @@ public:
static GitClient *client();
static Core::IVersionControl *versionControl();
- static const GitSettings &settings();
static const VcsBase::VcsBasePluginState &currentState();
static QString msgRepositoryLabel(const Utils::FilePath &repository);
@@ -63,7 +61,6 @@ private slots:
void testGitRemote_data();
void testGitRemote();
#endif
-
};
} // Git::Internal
diff --git a/src/plugins/git/gitsettings.cpp b/src/plugins/git/gitsettings.cpp
index 25a8f77988..965a62c728 100644
--- a/src/plugins/git/gitsettings.cpp
+++ b/src/plugins/git/gitsettings.cpp
@@ -148,15 +148,15 @@ FilePath GitSettings::gitExecutable(bool *ok, QString *errorMessage) const
// GitSettingsPage
-GitSettingsPage::GitSettingsPage(GitSettings *settings)
+GitSettingsPage::GitSettingsPage()
{
setId(VcsBase::Constants::VCS_ID_GIT);
setDisplayName(Tr::tr("Git"));
setCategory(VcsBase::Constants::VCS_SETTINGS_CATEGORY);
- setSettings(settings);
+ setSettings(&settings());
- setLayouter([settings](QWidget *widget) {
- GitSettings &s = *settings;
+ setLayouter([](QWidget *widget) {
+ GitSettings &s = settings();
using namespace Layouting;
Column {
@@ -196,4 +196,10 @@ GitSettingsPage::GitSettingsPage(GitSettings *settings)
});
}
+GitSettings &settings()
+{
+ static GitSettings theSettings;
+ return theSettings;
+}
+
} // Git::Internal
diff --git a/src/plugins/git/gitsettings.h b/src/plugins/git/gitsettings.h
index c03deadeb9..d9976de838 100644
--- a/src/plugins/git/gitsettings.h
+++ b/src/plugins/git/gitsettings.h
@@ -46,10 +46,12 @@ public:
Utils::FilePath gitExecutable(bool *ok = nullptr, QString *errorMessage = nullptr) const;
};
+GitSettings &settings();
+
class GitSettingsPage final : public Core::IOptionsPage
{
public:
- explicit GitSettingsPage(GitSettings *settings);
+ GitSettingsPage();
};
} // Git::Internal
diff --git a/src/plugins/git/logchangedialog.cpp b/src/plugins/git/logchangedialog.cpp
index 7e61b133de..75660c1189 100644
--- a/src/plugins/git/logchangedialog.cpp
+++ b/src/plugins/git/logchangedialog.cpp
@@ -224,7 +224,7 @@ LogChangeDialog::LogChangeDialog(bool isReset, QWidget *parent) :
m_resetTypeComboBox->addItem(Tr::tr("Hard"), "--hard");
m_resetTypeComboBox->addItem(Tr::tr("Mixed"), "--mixed");
m_resetTypeComboBox->addItem(Tr::tr("Soft"), "--soft");
- m_resetTypeComboBox->setCurrentIndex(GitClient::settings().lastResetIndex());
+ m_resetTypeComboBox->setCurrentIndex(settings().lastResetIndex());
popUpLayout->addWidget(m_resetTypeComboBox);
popUpLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Ignored));
}
@@ -250,7 +250,7 @@ bool LogChangeDialog::runDialog(const FilePath &repository,
if (QDialog::exec() == QDialog::Accepted) {
if (m_resetTypeComboBox)
- GitClient::settings().lastResetIndex.setValue(m_resetTypeComboBox->currentIndex());
+ settings().lastResetIndex.setValue(m_resetTypeComboBox->currentIndex());
return true;
}
return false;