diff options
author | mae <qt-info@nokia.com> | 2010-03-18 14:08:25 +0100 |
---|---|---|
committer | mae <qt-info@nokia.com> | 2010-03-18 14:08:45 +0100 |
commit | f4add2b852704059333a3d047916ba577d3c431d (patch) | |
tree | 0b6aeef421b22f08637cd6fa0e45efc169115852 /src/plugins/coreplugin/fancyactionbar.cpp | |
parent | 2933f41b195e10789741d45909c75c97f7fe999a (diff) |
On Mac, toggle run/debug with the open button (Qt::Key_Alt)
Diffstat (limited to 'src/plugins/coreplugin/fancyactionbar.cpp')
-rw-r--r-- | src/plugins/coreplugin/fancyactionbar.cpp | 47 |
1 files changed, 39 insertions, 8 deletions
diff --git a/src/plugins/coreplugin/fancyactionbar.cpp b/src/plugins/coreplugin/fancyactionbar.cpp index 707ad14e95..51e1875cab 100644 --- a/src/plugins/coreplugin/fancyactionbar.cpp +++ b/src/plugins/coreplugin/fancyactionbar.cpp @@ -45,8 +45,9 @@ #include <QtGui/QStatusBar> #include <QtGui/QStyle> #include <QtGui/QStyleOption> -#include <QtCore/QEvent> #include <QtGui/QMouseEvent> +#include <QtGui/QApplication> +#include <QtCore/QEvent> #include <QtCore/QAnimationGroup> #include <QtCore/QPropertyAnimation> #include <QtCore/QDebug> @@ -267,11 +268,29 @@ FancyActionBar::FancyActionBar(QWidget *parent) setContentsMargins(0,2,0,0); m_runButton = m_debugButton = 0; + m_inDebugMode = false; connect(Core::ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode*)), this, SLOT(modeChanged(Core::IMode*))); + +#ifdef Q_WS_MAC + qApp->installEventFilter(this); +#endif + } +#ifdef Q_WS_MAC +bool FancyActionBar::eventFilter(QObject *, QEvent *e) +{ + if (e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease) { + if (static_cast<QKeyEvent *>(e)->key() == Qt::Key_Alt) + updateRunDebug(); + } else if (e->type() == QEvent::WindowDeactivate) + updateRunDebug(); + return false; +} +#endif + void FancyActionBar::addProjectSelector(QAction *action) { FancyToolButton* toolButton = new FancyToolButton(this); @@ -295,15 +314,27 @@ void FancyActionBar::insertAction(int index, QAction *action) void FancyActionBar::modeChanged(Core::IMode *mode) { - if (m_runButton && m_debugButton) { - bool inDebugMode = (mode->id() == QLatin1String("Debugger.Mode.Debug")); - layout()->setEnabled(false); - m_runButton->forceVisible(!inDebugMode); - m_debugButton->forceVisible(inDebugMode); - layout()->setEnabled(true); - } + m_inDebugMode = (mode->id() == QLatin1String("Debugger.Mode.Debug")); + updateRunDebug(); } +void FancyActionBar::updateRunDebug() +{ + if (!m_runButton || !m_debugButton) + return; + + bool doDebug = m_inDebugMode; +#ifdef Q_WS_MAC + if (QApplication::keyboardModifiers() && Qt::AltModifier) + doDebug = !doDebug; +#endif + + layout()->setEnabled(false); + m_runButton->forceVisible(!doDebug); + m_debugButton->forceVisible(doDebug); + layout()->setEnabled(true); + +} QLayout *FancyActionBar::actionsLayout() const { |