summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qshortcut.cpp
diff options
context:
space:
mode:
authorjasplin <qt-info@nokia.com>2009-04-20 12:24:08 (GMT)
committerjasplin <qt-info@nokia.com>2009-04-20 13:02:05 (GMT)
commit031adeaf42ddaef8d01338f6c59ba97170be5d53 (patch)
treee6eb11ed75e2d9015f51000c138399593c6a4af9 /src/gui/kernel/qshortcut.cpp
parentbeb6912526766edd7e8a9f9876d82272f798dbc3 (diff)
downloadQt-031adeaf42ddaef8d01338f6c59ba97170be5d53.zip
Qt-031adeaf42ddaef8d01338f6c59ba97170be5d53.tar.gz
Qt-031adeaf42ddaef8d01338f6c59ba97170be5d53.tar.bz2
Fixed key sequence eating behavior for QShortcut and QAction.
A disabled QShortcut should eat its key sequence even for complex sequences like "Ctrl-E 1". For example, a line edit with such a shortcut should not display 1 after typing "Ctrl-E" and then "1". The patch achieves this essentially by moving more of the decision making (of whether to eat the key secuence) from shortcutmap.cpp to qhortcut.cpp. Moreover, an invisible QAction should not eat any of its key sequences (primary nor alternates). In the example above, the line edit would display 1 when typing this sequence for an invisible action. The patch achieves this by temporarily unregistering all of the action's shortcuts while the action is invisible. Reviewed-by: mariusSO Task-number: 251246
Diffstat (limited to 'src/gui/kernel/qshortcut.cpp')
-rw-r--r--src/gui/kernel/qshortcut.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/gui/kernel/qshortcut.cpp b/src/gui/kernel/qshortcut.cpp
index 50b6e59..f3c93c6 100644
--- a/src/gui/kernel/qshortcut.cpp
+++ b/src/gui/kernel/qshortcut.cpp
@@ -385,19 +385,21 @@ bool QShortcut::event(QEvent *e)
{
Q_D(QShortcut);
bool handled = false;
- if (d->sc_enabled && e->type() == QEvent::Shortcut) {
+ if (e->type() == QEvent::Shortcut) {
QShortcutEvent *se = static_cast<QShortcutEvent *>(e);
if (se->shortcutId() == d->sc_id && se->key() == d->sc_sequence){
+ if (d->sc_enabled) {
#ifndef QT_NO_WHATSTHIS
- if (QWhatsThis::inWhatsThisMode()) {
- QWhatsThis::showText(QCursor::pos(), d->sc_whatsthis);
- handled = true;
- } else
+ if (QWhatsThis::inWhatsThisMode()) {
+ QWhatsThis::showText(QCursor::pos(), d->sc_whatsthis);
+ handled = true;
+ } else
#endif
- if (se->isAmbiguous())
- emit activatedAmbiguously();
- else
- emit activated();
+ if (se->isAmbiguous())
+ emit activatedAmbiguously();
+ else
+ emit activated();
+ }
handled = true;
}
}