Git: Set default button for change-related actions by triggering action

Change-Id: I536618e9b80f3ed213c6c54dd6c2becbb64c709b
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
Orgad Shaneh
2013-09-30 11:30:13 +03:00
committed by Orgad Shaneh
parent 63e7fe19b9
commit e81152acd5
3 changed files with 17 additions and 3 deletions

View File

@@ -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();
}

View File

@@ -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;

View File

@@ -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();