diff --git a/src/plugins/coreplugin/fancyactionbar.cpp b/src/plugins/coreplugin/fancyactionbar.cpp index 35ad9778b245f71695dc41a154f1064be69756a1..fedbc0cf3b9309e97e31b3f16cee84eb282bb0e3 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(); + } +} diff --git a/src/plugins/coreplugin/fancyactionbar.h b/src/plugins/coreplugin/fancyactionbar.h index b7fcca9e9f4032b4ddc471511666adbbc15a1463..4c49f61c5b943e6a083f22a420d0976e87bae217 100644 --- a/src/plugins/coreplugin/fancyactionbar.h +++ b/src/plugins/coreplugin/fancyactionbar.h @@ -64,6 +64,8 @@ public: void paintEvent(QPaintEvent *event); void insertAction(int index, QAction *action, QMenu *menu = 0); +private slots: + void toolButtonContextMenuActionTriggered(QAction*); private: QVBoxLayout *m_actionsLayout; };