diff --git a/src/plugins/coreplugin/fancyactionbar.cpp b/src/plugins/coreplugin/fancyactionbar.cpp
index f14891b64e638e8da02447890b4bb66651e4ca9a..6346a84d8c059d159f4f5970bb92970d2e8ec9bd 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 <utils/stylehelper.h>
 
 #include <coreplugin/icore.h>
+#include <coreplugin/imode.h>
+#include <coreplugin/modemanager.h>
 #include <coreplugin/mainwindow.h>
 
 #include <QtGui/QHBoxLayout>
@@ -47,6 +49,7 @@
 #include <QtGui/QMouseEvent>
 #include <QtCore/QAnimationGroup>
 #include <QtCore/QPropertyAnimation>
+#include <QtCore/QDebug>
 
 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 c6fee53feaf1a8fe1ae9eacdc12cc65b5b3716a9..6879cfa9dd54240d32f85d36137cad085aa803b4 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