diff --git a/src/plugins/coreplugin/fancyactionbar.cpp b/src/plugins/coreplugin/fancyactionbar.cpp index f14891b64e6..6346a84d8c0 100644 --- a/src/plugins/coreplugin/fancyactionbar.cpp +++ b/src/plugins/coreplugin/fancyactionbar.cpp @@ -1,4 +1,4 @@ -/********************Q****************************************************** +/************************************************************************** ** ** This file is part of Qt Creator ** @@ -33,6 +33,8 @@ #include #include +#include +#include #include #include @@ -47,6 +49,7 @@ #include #include #include +#include using namespace Core; using namespace Internal; @@ -234,6 +237,11 @@ FancyActionBar::FancyActionBar(QWidget *parent) spacerLayout->setSpacing(0); setLayout(spacerLayout); setContentsMargins(0,2,0,0); + + m_runButton = m_debugButton = 0; + + connect(Core::ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode*)), + this, SLOT(modeChanged(Core::IMode*))); } void FancyActionBar::addProjectSelector(QAction *action) @@ -247,11 +255,26 @@ void FancyActionBar::addProjectSelector(QAction *action) void FancyActionBar::insertAction(int index, QAction *action) { FancyToolButton *toolButton = new FancyToolButton(this); + if (action->objectName() == QLatin1String("ProjectExplorer.Run")) + m_runButton = toolButton; + if (action->objectName() == QLatin1String("ProjectExplorer.Debug")) + m_debugButton = toolButton; + toolButton->setDefaultAction(action); connect(action, SIGNAL(changed()), toolButton, SLOT(actionChanged())); m_actionsLayout->insertWidget(index, toolButton); } +void FancyActionBar::modeChanged(Core::IMode *mode) +{ + if (m_runButton && m_debugButton) { + bool inDebugMode = (mode->id() == QLatin1String("Debugger.Mode.Debug")); + m_runButton->setVisible(!inDebugMode); + m_debugButton->setVisible(inDebugMode); + } +} + + QLayout *FancyActionBar::actionsLayout() const { return m_actionsLayout; diff --git a/src/plugins/coreplugin/fancyactionbar.h b/src/plugins/coreplugin/fancyactionbar.h index c6fee53feaf..6879cfa9dd5 100644 --- a/src/plugins/coreplugin/fancyactionbar.h +++ b/src/plugins/coreplugin/fancyactionbar.h @@ -39,6 +39,7 @@ class QVBoxLayout; QT_END_NAMESPACE namespace Core { + class IMode; namespace Internal { class FancyToolButton : public QToolButton @@ -75,8 +76,13 @@ public: void addProjectSelector(QAction *action); QLayout *actionsLayout() const; +private slots: + void modeChanged(Core::IMode *mode); + private: QVBoxLayout *m_actionsLayout; + FancyToolButton *m_runButton; + FancyToolButton *m_debugButton; }; } // namespace Internal