From e81152acd59c1118f740a9ad97156f7d458694f5 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh <orgad.shaneh@audiocodes.com> Date: Mon, 30 Sep 2013 11:30:13 +0300 Subject: [PATCH] Git: Set default button for change-related actions by triggering action Change-Id: I536618e9b80f3ed213c6c54dd6c2becbb64c709b Reviewed-by: Tobias Hunger <tobias.hunger@digia.com> --- src/plugins/git/changeselectiondialog.cpp | 11 ++++++++++- src/plugins/git/changeselectiondialog.h | 4 +++- src/plugins/git/gitplugin.cpp | 5 ++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/plugins/git/changeselectiondialog.cpp b/src/plugins/git/changeselectiondialog.cpp index cc5dc40b22f..8dc3dba6c6f 100644 --- a/src/plugins/git/changeselectiondialog.cpp +++ b/src/plugins/git/changeselectiondialog.cpp @@ -45,7 +45,7 @@ namespace Git { namespace Internal { -ChangeSelectionDialog::ChangeSelectionDialog(const QString &workingDirectory, QWidget *parent) +ChangeSelectionDialog::ChangeSelectionDialog(const QString &workingDirectory, Core::Id id, QWidget *parent) : QDialog(parent) , m_process(0) , m_workingDirEdit(new QLineEdit(workingDirectory, this)) @@ -107,6 +107,15 @@ ChangeSelectionDialog::ChangeSelectionDialog(const QString &workingDirectory, QW connect(m_checkoutButton, SIGNAL(clicked()), this, SLOT(acceptCheckout())); connect(m_closeButton, SIGNAL(clicked()), this, SLOT(reject())); + QByteArray idName = id.name(); + if (idName == "Git.Revert") + m_revertButton->setDefault(true); + else if (idName == "Git.CherryPick") + m_cherryPickButton->setDefault(true); + else if (idName == "Git.Checkout") + m_checkoutButton->setDefault(true); + else + m_showButton->setDefault(true); recalculateDetails(); } diff --git a/src/plugins/git/changeselectiondialog.h b/src/plugins/git/changeselectiondialog.h index e850570369b..9035ec7c19d 100644 --- a/src/plugins/git/changeselectiondialog.h +++ b/src/plugins/git/changeselectiondialog.h @@ -30,6 +30,8 @@ #ifndef CHANGESELECTIONDIALOG_H #define CHANGESELECTIONDIALOG_H +#include <coreplugin/id.h> + #include <QDialog> #include <QProcessEnvironment> @@ -56,7 +58,7 @@ class ChangeSelectionDialog : public QDialog { Q_OBJECT public: - ChangeSelectionDialog(const QString &workingDirectory, QWidget *parent); + ChangeSelectionDialog(const QString &workingDirectory, Core::Id id, QWidget *parent); ~ChangeSelectionDialog(); QString change() const; diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp index be6a2ba82dc..bc730a339c9 100644 --- a/src/plugins/git/gitplugin.cpp +++ b/src/plugins/git/gitplugin.cpp @@ -249,6 +249,7 @@ ActionCommandPair { const ActionCommandPair rc = createRepositoryAction(ac, text, id, context, addToLocator); connect(rc.first, SIGNAL(triggered()), this, pluginSlot); + rc.first->setData(id.uniqueIdentifier()); return rc; } @@ -852,7 +853,9 @@ void GitPlugin::startChangeRelatedAction() if (!state.hasTopLevel()) return; - ChangeSelectionDialog dialog(state.topLevel(), Core::ICore::mainWindow()); + QAction *action = qobject_cast<QAction *>(sender()); + Core::Id id = action ? Core::Id::fromUniqueIdentifier(action->data().toInt()) : Core::Id(); + ChangeSelectionDialog dialog(state.topLevel(), id, Core::ICore::mainWindow()); int result = dialog.exec(); -- GitLab