diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2023-04-26 16:25:26 +0800 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2023-04-27 09:38:15 +0800 |
commit | 2cd7e34fa09c034f8a538b94299c275599620745 (patch) | |
tree | f466e6bdca19691e54d1d3028dd802e9d1bd4b91 /src/gui/kernel/qshortcutmap.cpp | |
parent | 4ff074a67e8f3193a789eb437a6549b181b8dc95 (diff) |
Add more shortcutmap categorized logging output
Show more detail about the checks made against each entry to show why
a shortcut might not get delivered. Specifically, it's useful to know
if the contextMatcher returned true. In the case of Qt Quick Controls,
it can return false if the Shortcut is blocked by a modal popup, or
a popup with a CloseOnEscape policy.
With this patch, combining qt.gui.shortcutmap with
qt.quick.controls.shortcutcontext.matcher makes it possible to see
which popup blocks a shortcut. With only the former enabled, it's
already quite useful:
qt.gui.shortcutmap: Possible shortcut key sequences: QList(QKeySequence("Ctrl+N"))
qt.gui.shortcutmap: - checking entry 0 QKeySequence("Ctrl+N")
qt.gui.shortcutmap: - matches returned 2 for QKeySequence("Ctrl+N") QKeySequence("Ctrl+N") - correctContext()? false
qt.gui.shortcutmap: - matches returned 0 for QKeySequence("Ctrl+N") QKeySequence("Ctrl+O") - correctContext()? false
qt.gui.shortcutmap: Found better match ( QList(QKeySequence("Ctrl+N")) ), clearing key sequence list
qt.gui.shortcutmap: Added ok key sequence QList(QKeySequence("Ctrl+N"))
qt.gui.shortcutmap: Returning shortcut match == 0
qt.gui.shortcutmap: QShortcutMap::nextState(QKeyEvent(ShortcutOverride, Key_N, ControlModifier, text="N")) = 0
Change-Id: I6e96c94a8b62823553837eda3ef2764ca21775c4
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/gui/kernel/qshortcutmap.cpp')
-rw-r--r-- | src/gui/kernel/qshortcutmap.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/gui/kernel/qshortcutmap.cpp b/src/gui/kernel/qshortcutmap.cpp index ed03f00542..1849419372 100644 --- a/src/gui/kernel/qshortcutmap.cpp +++ b/src/gui/kernel/qshortcutmap.cpp @@ -410,6 +410,7 @@ QKeySequence::SequenceMatch QShortcutMap::find(QKeyEvent *e, int ignoredModifier int result = QKeySequence::NoMatch; for (int i = d->newEntries.size()-1; i >= 0 ; --i) { QShortcutEntry entry(d->newEntries.at(i)); // needed for searching + qCDebug(lcShortcutMap) << "- checking entry" << entry.id << entry.keyseq; const auto itEnd = d->sequences.constEnd(); auto it = std::lower_bound(d->sequences.constBegin(), itEnd, entry); @@ -420,6 +421,8 @@ QKeySequence::SequenceMatch QShortcutMap::find(QKeyEvent *e, int ignoredModifier break; tempRes = matches(entry.keyseq, (*it).keyseq); oneKSResult = qMax(oneKSResult, tempRes); + qCDebug(lcShortcutMap) << " - matches returned" << tempRes << "for" << entry.keyseq << it->keyseq + << "- correctContext()?" << it->correctContext(); if (tempRes != QKeySequence::NoMatch && (*it).correctContext()) { if (tempRes == QKeySequence::ExactMatch) { if ((*it).enabled) |