diff --git a/src/plugins/coreplugin/actionmanager/command.cpp b/src/plugins/coreplugin/actionmanager/command.cpp index 653009203b78866386d24fed6c1eab8c60f6c7c2..4c7b2c3f303bbbc11152ac8edf7acd64e123ac1d 100644 --- a/src/plugins/coreplugin/actionmanager/command.cpp +++ b/src/plugins/coreplugin/actionmanager/command.cpp @@ -37,6 +37,7 @@ #include <QtGui/QAction> #include <QtGui/QShortcut> +#include <QtGui/QMainWindow> /*! \class Core::Command @@ -424,8 +425,11 @@ QKeySequence Action::keySequence() const OverrideableAction::OverrideableAction(int id) : Action(id), m_currentAction(0), m_active(false), - m_contextInitialized(false) + m_contextInitialized(false), + m_dummyShortcutEater(this) { + Core::ICore::instance()->mainWindow()->addAction(&m_dummyShortcutEater); + m_dummyShortcutEater.setEnabled(false); } void OverrideableAction::setAction(QAction *action) @@ -465,9 +469,11 @@ bool OverrideableAction::setCurrentContext(const QList<int> &context) m_active = true; return true; } + // no active/delegate action, "visible" action is not enabled/visible if (hasAttribute(CA_Hide)) m_action->setVisible(false); m_action->setEnabled(false); + m_dummyShortcutEater.setEnabled(false); m_active = false; return false; } @@ -521,6 +527,9 @@ void OverrideableAction::actionChanged() m_action->setEnabled(m_currentAction->isEnabled()); m_action->setVisible(m_currentAction->isVisible()); + + m_dummyShortcutEater.setShortcuts(m_action->shortcuts()); + m_dummyShortcutEater.setEnabled(!m_action->isEnabled()); } bool OverrideableAction::isActive() const diff --git a/src/plugins/coreplugin/actionmanager/command_p.h b/src/plugins/coreplugin/actionmanager/command_p.h index 176866dfeeb7a3ffc48621f5c8188a591e661922..1c89fd7b7fb0af5bcd0a9107c2918f58da4a7941 100644 --- a/src/plugins/coreplugin/actionmanager/command_p.h +++ b/src/plugins/coreplugin/actionmanager/command_p.h @@ -153,6 +153,7 @@ private: QMap<int, QPointer<QAction> > m_contextActionMap; bool m_active; bool m_contextInitialized; + QAction m_dummyShortcutEater; }; } // namespace Internal