forked from qt-creator/qt-creator
Fixed disabled action shortcuts
The patch introduces a dummy action which eats the respective shortcuts when the real action is disabled. This works around an issue on X11, where some Ctrl-shortcuts do insert printable text, for example Ctrl+. for the next bookmark. Without the patch, Ctrl+. would insert an unexpected '.' into the text when there are no bookmarks. Reviewed-by: con
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user