From 8e3c6f165b613c92131f2929a2c2c83054ecce72 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 19 Jan 2018 14:56:32 +0100 Subject: [PATCH] Improve debug formatting of QInputMethodQueryEvent Add more queries, output the query enumeration value and output the hints as flags. Change-Id: Icfc648a8d6e144074455ecebae1b25c3c3e1063e Reviewed-by: Shawn Rutledge --- src/gui/kernel/qevent.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index be8ce1a011..50d9bbb2cc 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -3761,14 +3761,25 @@ static inline void formatInputMethodEvent(QDebug d, const QInputMethodEvent *e) static inline void formatInputMethodQueryEvent(QDebug d, const QInputMethodQueryEvent *e) { + QDebugStateSaver saver(d); + d.noquote(); const Qt::InputMethodQueries queries = e->queries(); d << "QInputMethodQueryEvent(queries=" << showbase << hex << int(queries) << noshowbase << dec << ", {"; - for (unsigned mask = 1; mask <= Qt::ImTextAfterCursor; mask<<=1) { + for (unsigned mask = 1; mask <= Qt::ImInputItemClipRectangle; mask<<=1) { if (queries & mask) { - const QVariant value = e->value(static_cast(mask)); - if (value.isValid()) - d << '[' << showbase << hex << mask << noshowbase << dec << '=' << value << "],"; + const Qt::InputMethodQuery query = static_cast(mask); + const QVariant value = e->value(query); + if (value.isValid()) { + d << '['; + QtDebugUtils::formatQEnum(d, query); + d << '='; + if (query == Qt::ImHints) + QtDebugUtils::formatQFlags(d, Qt::InputMethodHints(value.toInt())); + else + d << value.toString(); + d << "],"; + } } } d << "})";