forked from qt-creator/qt-creator
Git: Also use the latest settings setup approach
Change-Id: I34a210575d02d18927c1e0f6d8ea6cb9924c563d Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -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('/');
|
||||
|
@@ -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();
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -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,
|
||||
|
@@ -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)
|
||||
|
@@ -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;
|
||||
|
@@ -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 ¤tState();
|
||||
|
||||
static QString msgRepositoryLabel(const Utils::FilePath &repository);
|
||||
@@ -63,7 +61,6 @@ private slots:
|
||||
void testGitRemote_data();
|
||||
void testGitRemote();
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
} // Git::Internal
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user