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,35 +290,28 @@ 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]() {
menu->addAction(tr("Cherr&y-Pick Change %1").arg(change), this, [this] {
GitPlugin::client()->synchronousCherryPick(sourceWorkingDirectory(), m_currentChange); GitPlugin::client()->synchronousCherryPick(sourceWorkingDirectory(), m_currentChange);
}); });
connect(menu->addAction(tr("Re&vert Change %1").arg(change)), &QAction::triggered, menu->addAction(tr("Re&vert Change %1").arg(change), this, [this] {
this, [this]() {
GitPlugin::client()->synchronousRevert(sourceWorkingDirectory(), m_currentChange); GitPlugin::client()->synchronousRevert(sourceWorkingDirectory(), m_currentChange);
}); });
connect(menu->addAction(tr("C&heckout Change %1").arg(change)), &QAction::triggered, menu->addAction(tr("C&heckout Change %1").arg(change), this, [this] {
this, [this]() {
GitPlugin::client()->checkout(sourceWorkingDirectory(), m_currentChange); GitPlugin::client()->checkout(sourceWorkingDirectory(), m_currentChange);
}); });
connect(menu->addAction(tr("&Log for Change %1").arg(change)), &QAction::triggered, menu->addAction(tr("&Log for Change %1").arg(change), this, [this] {
this, [this]() { GitPlugin::client()->log(sourceWorkingDirectory(), QString(), false, {m_currentChange});
GitPlugin::client()->log(
sourceWorkingDirectory(), QString(), false, {m_currentChange});
}); });
QMenu *resetMenu = new QMenu(tr("&Reset to Change %1").arg(change), menu); auto resetMenu = new QMenu(tr("&Reset to Change %1").arg(change), menu);
connect(resetMenu->addAction(tr("&Hard")), &QAction::triggered, resetMenu->addAction(tr("&Hard"), this, [this] { resetChange("hard"); });
this, [this]() { resetChange("hard"); }); resetMenu->addAction(tr("&Mixed"), this, [this] { resetChange("mixed"); });
connect(resetMenu->addAction(tr("&Mixed")), &QAction::triggered, resetMenu->addAction(tr("&Soft"), this, [this] { resetChange("soft"); });
this, [this]() { resetChange("mixed"); });
connect(resetMenu->addAction(tr("&Soft")), &QAction::triggered,
this, [this]() { resetChange("soft"); });
menu->addMenu(resetMenu); menu->addMenu(resetMenu);
} }
}
QString GitEditorWidget::revisionSubject(const QTextBlock &inBlock) const QString GitEditorWidget::revisionSubject(const QTextBlock &inBlock) const
{ {