Git: Add config widget to reflog

Change-Id: I04a9bd86c38ab27537c2d6981179a667bc36e61b
Reviewed-by: André Hartmann <aha_1980@gmx.de>
This commit is contained in:
Orgad Shaneh
2020-02-18 22:34:43 +02:00
committed by Orgad Shaneh
parent e886c13abc
commit c9f1d84db7
3 changed files with 42 additions and 2 deletions

View File

@@ -560,12 +560,12 @@ public:
}
};
class GitLogArgumentsWidget : public BaseGitDiffArgumentsWidget
class BaseGitLogArgumentsWidget : public BaseGitDiffArgumentsWidget
{
Q_OBJECT
public:
GitLogArgumentsWidget(VcsBaseClientSettings &settings, bool fileRelated, QToolBar *toolBar) :
BaseGitLogArgumentsWidget(VcsBaseClientSettings &settings, QToolBar *toolBar) :
BaseGitDiffArgumentsWidget(settings, toolBar)
{
QAction *diffButton = addToggleButton("--patch", tr("Diff"),
@@ -575,6 +575,17 @@ public:
connect(diffButton, &QAction::toggled, m_ignoreWSButton, &QAction::setVisible);
m_patienceButton->setVisible(diffButton->isChecked());
m_ignoreWSButton->setVisible(diffButton->isChecked());
}
};
class GitLogArgumentsWidget : public BaseGitLogArgumentsWidget
{
Q_OBJECT
public:
GitLogArgumentsWidget(VcsBaseClientSettings &settings, bool fileRelated, QToolBar *toolBar) :
BaseGitLogArgumentsWidget(settings, toolBar)
{
QAction *firstParentButton =
addToggleButton({"-m", "--first-parent"},
tr("First Parent"),
@@ -599,6 +610,24 @@ public:
}
};
class GitRefLogArgumentsWidget : public BaseGitLogArgumentsWidget
{
Q_OBJECT
public:
GitRefLogArgumentsWidget(VcsBaseClientSettings &settings, QToolBar *toolBar) :
BaseGitLogArgumentsWidget(settings, toolBar)
{
QAction *showDateButton =
addToggleButton("--date=iso",
tr("Show Date"),
tr("Show date instead of sequence"));
mapSetting(showDateButton, settings.boolPointer(GitSettings::refLogShowDateKey));
addReloadButton();
}
};
class ConflictHandler final : public QObject
{
Q_OBJECT
@@ -1039,9 +1068,17 @@ void GitClient::reflog(const QString &workingDirectory)
const Id editorId = Git::Constants::GIT_LOG_EDITOR_ID;
VcsBaseEditorWidget *editor = createVcsEditor(editorId, title, workingDirectory, codecFor(CodecLogOutput),
"reflogRepository", workingDirectory);
VcsBaseEditorConfig *argWidget = editor->editorConfig();
if (!argWidget) {
argWidget = new GitRefLogArgumentsWidget(settings(), editor->toolBar());
connect(argWidget, &VcsBaseEditorConfig::commandExecutionRequested, this,
[=] { this->reflog(workingDirectory); });
editor->setEditorConfig(argWidget);
}
editor->setWorkingDirectory(workingDirectory);
QStringList arguments = {"reflog", noColorOption, decorateOption};
arguments << argWidget->arguments();
int logCount = settings().intValue(GitSettings::logCountKey);
if (logCount > 0)
arguments << "-n" << QString::number(logCount);

View File

@@ -47,6 +47,7 @@ const QLatin1String GitSettings::graphLogKey("GraphLog");
const QLatin1String GitSettings::firstParentKey("FirstParent");
const QLatin1String GitSettings::followRenamesKey("FollowRenames");
const QLatin1String GitSettings::lastResetIndexKey("LastResetIndex");
const QLatin1String GitSettings::refLogShowDateKey("RefLogShowDate");
GitSettings::GitSettings()
{
@@ -69,6 +70,7 @@ GitSettings::GitSettings()
declareKey(firstParentKey, false);
declareKey(followRenamesKey, true);
declareKey(lastResetIndexKey, 0);
declareKey(refLogShowDateKey, false);
}
Utils::FilePath GitSettings::gitExecutable(bool *ok, QString *errorMessage) const

View File

@@ -58,6 +58,7 @@ public:
static const QLatin1String firstParentKey;
static const QLatin1String followRenamesKey;
static const QLatin1String lastResetIndexKey;
static const QLatin1String refLogShowDateKey;
Utils::FilePath gitExecutable(bool *ok = nullptr, QString *errorMessage = nullptr) const;