Commit 255e7d1d authored by mae's avatar mae
Browse files

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
parent 43515f1c
......@@ -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
......
......@@ -153,6 +153,7 @@ private:
QMap<int, QPointer<QAction> > m_contextActionMap;
bool m_active;
bool m_contextInitialized;
QAction m_dummyShortcutEater;
};
} // namespace Internal
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment