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>
This commit is contained in:
parent
64836ec256
commit
f72777b969
@ -648,10 +648,16 @@ void QShortcutMap::dispatchEvent(QKeyEvent *e)
|
|||||||
// Find next
|
// Find next
|
||||||
const QShortcutEntry *current = 0, *next = 0;
|
const QShortcutEntry *current = 0, *next = 0;
|
||||||
int i = 0, enabledShortcuts = 0;
|
int i = 0, enabledShortcuts = 0;
|
||||||
|
#if defined(DEBUG_QSHORTCUTMAP)
|
||||||
|
QVector<const QShortcutEntry*> ambiguousShortcuts;
|
||||||
|
#endif
|
||||||
while(i < d->identicals.size()) {
|
while(i < d->identicals.size()) {
|
||||||
current = d->identicals.at(i);
|
current = d->identicals.at(i);
|
||||||
if (current->enabled || !next){
|
if (current->enabled || !next){
|
||||||
++enabledShortcuts;
|
++enabledShortcuts;
|
||||||
|
#if defined(DEBUG_QSHORTCUTMAP)
|
||||||
|
ambiguousShortcuts.append(current);
|
||||||
|
#endif
|
||||||
if (enabledShortcuts > d->ambigCount + 1)
|
if (enabledShortcuts > d->ambigCount + 1)
|
||||||
break;
|
break;
|
||||||
next = current;
|
next = current;
|
||||||
@ -665,6 +671,13 @@ void QShortcutMap::dispatchEvent(QKeyEvent *e)
|
|||||||
return;
|
return;
|
||||||
// Dispatch next enabled
|
// Dispatch next enabled
|
||||||
#if defined(DEBUG_QSHORTCUTMAP)
|
#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()
|
qDebug().nospace()
|
||||||
<< "QShortcutMap::dispatchEvent(): Sending QShortcutEvent(\""
|
<< "QShortcutMap::dispatchEvent(): Sending QShortcutEvent(\""
|
||||||
<< next->keyseq.toString() << "\", " << next->id << ", "
|
<< next->keyseq.toString() << "\", " << next->id << ", "
|
||||||
|
Loading…
Reference in New Issue
Block a user