diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2018-05-05 14:56:15 +0200 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2018-05-07 12:03:26 +0000 |
commit | f72777b969bd74a1472ce8f028da01a82200d656 (patch) | |
tree | 924ea7ae17c8e68febff6fdd51d89dbcdef6af08 | |
parent | 64836ec256e60a40f408c7ca067e82037d435066 (diff) |
QShortcutMap: print ambiguous shortcuts when DEBUG_QSHORTCUTMAP is defined
This is useful to see why shortcuts (in Qt Widgets and Qt Quick) are
not behaving as expected. For example:
The following shortcuts are about to be activated ambiguously:
- QKeySequence("Esc") (belonging to QQuickShortcut(0x7fcd4c8e6a70,
name = "exploreViewBackOrCloseShortcut"))
- QKeySequence("Esc") (belonging to QQuickPopupItem(0x7fcd4c8e5110))
Change-Id: Id20a3017d69cfe417c2286dccf46b3d5ff0b31b2
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-rw-r--r-- | src/gui/kernel/qshortcutmap.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/gui/kernel/qshortcutmap.cpp b/src/gui/kernel/qshortcutmap.cpp index 6c19eab287..fa1eb6f6bf 100644 --- a/src/gui/kernel/qshortcutmap.cpp +++ b/src/gui/kernel/qshortcutmap.cpp @@ -648,10 +648,16 @@ void QShortcutMap::dispatchEvent(QKeyEvent *e) // Find next const QShortcutEntry *current = 0, *next = 0; int i = 0, enabledShortcuts = 0; +#if defined(DEBUG_QSHORTCUTMAP) + QVector<const QShortcutEntry*> ambiguousShortcuts; +#endif while(i < d->identicals.size()) { current = d->identicals.at(i); if (current->enabled || !next){ ++enabledShortcuts; +#if defined(DEBUG_QSHORTCUTMAP) + ambiguousShortcuts.append(current); +#endif if (enabledShortcuts > d->ambigCount + 1) break; next = current; @@ -665,6 +671,13 @@ void QShortcutMap::dispatchEvent(QKeyEvent *e) return; // Dispatch next enabled #if defined(DEBUG_QSHORTCUTMAP) + if (ambiguousShortcuts.size() > 1) { + qDebug() << "The following shortcuts are about to be activated ambiguously:"; + for (const QShortcutEntry *entry : qAsConst(ambiguousShortcuts)) { + qDebug().nospace() << "- " << entry->keyseq << " (belonging to " << entry->owner << ")"; + } + } + qDebug().nospace() << "QShortcutMap::dispatchEvent(): Sending QShortcutEvent(\"" << next->keyseq.toString() << "\", " << next->id << ", " |