GitEditor: Simplify reset menu

Change-Id: Id7f8b9e5aa46530dcb32a4f84bd01d8a8fe2dc5b
Reviewed-by: André Hartmann <aha_1980@gmx.de>
This commit is contained in:
Orgad Shaneh
2019-03-28 09:47:39 +02:00
committed by Orgad Shaneh
parent d7929eaf59
commit 03d85e4217

View File

@@ -290,34 +290,27 @@ bool GitEditorWidget::isValidRevision(const QString &revision) const
void GitEditorWidget::addChangeActions(QMenu *menu, const QString &change) void GitEditorWidget::addChangeActions(QMenu *menu, const QString &change)
{ {
m_currentChange = change; m_currentChange = change;
if (contentType() != OtherContent) { if (contentType() == OtherContent)
connect(menu->addAction(tr("Cherr&y-Pick Change %1").arg(change)), &QAction::triggered, return;
this, [this]() {
GitPlugin::client()->synchronousCherryPick(sourceWorkingDirectory(), m_currentChange);
});
connect(menu->addAction(tr("Re&vert Change %1").arg(change)), &QAction::triggered,
this, [this]() {
GitPlugin::client()->synchronousRevert(sourceWorkingDirectory(), m_currentChange);
});
connect(menu->addAction(tr("C&heckout Change %1").arg(change)), &QAction::triggered,
this, [this]() {
GitPlugin::client()->checkout(sourceWorkingDirectory(), m_currentChange);
});
connect(menu->addAction(tr("&Log for Change %1").arg(change)), &QAction::triggered,
this, [this]() {
GitPlugin::client()->log(
sourceWorkingDirectory(), QString(), false, {m_currentChange});
});
QMenu *resetMenu = new QMenu(tr("&Reset to Change %1").arg(change), menu); menu->addAction(tr("Cherr&y-Pick Change %1").arg(change), this, [this] {
connect(resetMenu->addAction(tr("&Hard")), &QAction::triggered, GitPlugin::client()->synchronousCherryPick(sourceWorkingDirectory(), m_currentChange);
this, [this]() { resetChange("hard"); }); });
connect(resetMenu->addAction(tr("&Mixed")), &QAction::triggered, menu->addAction(tr("Re&vert Change %1").arg(change), this, [this] {
this, [this]() { resetChange("mixed"); }); GitPlugin::client()->synchronousRevert(sourceWorkingDirectory(), m_currentChange);
connect(resetMenu->addAction(tr("&Soft")), &QAction::triggered, });
this, [this]() { resetChange("soft"); }); menu->addAction(tr("C&heckout Change %1").arg(change), this, [this] {
menu->addMenu(resetMenu); GitPlugin::client()->checkout(sourceWorkingDirectory(), m_currentChange);
} });
menu->addAction(tr("&Log for Change %1").arg(change), this, [this] {
GitPlugin::client()->log(sourceWorkingDirectory(), QString(), false, {m_currentChange});
});
auto resetMenu = new QMenu(tr("&Reset to Change %1").arg(change), menu);
resetMenu->addAction(tr("&Hard"), this, [this] { resetChange("hard"); });
resetMenu->addAction(tr("&Mixed"), this, [this] { resetChange("mixed"); });
resetMenu->addAction(tr("&Soft"), this, [this] { resetChange("soft"); });
menu->addMenu(resetMenu);
} }
QString GitEditorWidget::revisionSubject(const QTextBlock &inBlock) const QString GitEditorWidget::revisionSubject(const QTextBlock &inBlock) const