aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/coreplugin/fancyactionbar.cpp
diff options
context:
space:
mode:
authormae <qt-info@nokia.com>2009-08-20 18:44:02 +0200
committermae <qt-info@nokia.com>2009-08-20 18:46:15 +0200
commit79bdbfa9652fa4711c85978f40b0df4e35c6d523 (patch)
tree39ee28478ac99f2aa1210210f28161d97ee7eaa4 /src/plugins/coreplugin/fancyactionbar.cpp
parent2f69bedc5f078064b112aa2b5790e5fd625980b3 (diff)
In the FancyActionBar, trigger a button's default action
also when a context menu action is selected. This allows the user e.g. to select and run a specific run configuration with one click.
Diffstat (limited to 'src/plugins/coreplugin/fancyactionbar.cpp')
-rw-r--r--src/plugins/coreplugin/fancyactionbar.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/plugins/coreplugin/fancyactionbar.cpp b/src/plugins/coreplugin/fancyactionbar.cpp
index 35ad9778b2..fedbc0cf3b 100644
--- a/src/plugins/coreplugin/fancyactionbar.cpp
+++ b/src/plugins/coreplugin/fancyactionbar.cpp
@@ -34,6 +34,7 @@
#include <QtGui/QPicture>
#include <QtGui/QVBoxLayout>
#include <QtSvg/QSvgRenderer>
+#include <QtGui/QAction>
using namespace Core;
using namespace Internal;
@@ -154,6 +155,24 @@ void FancyActionBar::insertAction(int index, QAction *action, QMenu *menu)
if (menu) {
toolButton->setMenu(menu);
toolButton->setPopupMode(QToolButton::DelayedPopup);
+
+ // execute action also if a context menu item is select
+ connect(toolButton, SIGNAL(triggered(QAction*)),
+ this, SLOT(toolButtonContextMenuActionTriggered(QAction*)));
}
m_actionsLayout->insertWidget(index, toolButton);
}
+
+/*
+ This slot is invoked when a context menu action of a tool button is triggered.
+ In this case we also want to trigger the default action of the button.
+
+ This allows the user e.g. to select and run a specific run configuration with one click.
+ */
+void FancyActionBar::toolButtonContextMenuActionTriggered(QAction* action)
+{
+ if (QToolButton *button = qobject_cast<QToolButton*>(sender())) {
+ if (action != button->defaultAction())
+ button->defaultAction()->trigger();
+ }
+}