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)
{
m_currentChange = change;
if (contentType() != OtherContent) {
connect(menu->addAction(tr("Cherr&y-Pick Change %1").arg(change)), &QAction::triggered,
this, [this]() {
if (contentType() == OtherContent)
return;
menu->addAction(tr("Cherr&y-Pick Change %1").arg(change), this, [this] {
GitPlugin::client()->synchronousCherryPick(sourceWorkingDirectory(), m_currentChange);
});
connect(menu->addAction(tr("Re&vert Change %1").arg(change)), &QAction::triggered,
this, [this]() {
menu->addAction(tr("Re&vert Change %1").arg(change), this, [this] {
GitPlugin::client()->synchronousRevert(sourceWorkingDirectory(), m_currentChange);
});
connect(menu->addAction(tr("C&heckout Change %1").arg(change)), &QAction::triggered,
this, [this]() {
menu->addAction(tr("C&heckout Change %1").arg(change), 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});
menu->addAction(tr("&Log for Change %1").arg(change), this, [this] {
GitPlugin::client()->log(sourceWorkingDirectory(), QString(), false, {m_currentChange});
});
QMenu *resetMenu = new QMenu(tr("&Reset to Change %1").arg(change), menu);
connect(resetMenu->addAction(tr("&Hard")), &QAction::triggered,
this, [this]() { resetChange("hard"); });
connect(resetMenu->addAction(tr("&Mixed")), &QAction::triggered,
this, [this]() { resetChange("mixed"); });
connect(resetMenu->addAction(tr("&Soft")), &QAction::triggered,
this, [this]() { resetChange("soft"); });
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
{