summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2018-11-01 15:19:05 +0100
committerAlexandru Croitor <alexandru.croitor@qt.io>2018-11-08 15:28:37 +0000
commite74366bbeace4d29d87ee7401c7665f17ebd5dea (patch)
tree2ae9fd0df773d16e83b04f49e3930d4fb7f23b18 /share
parentde32a631c3b80bb8d444e7c505eb7dc1a909a5af (diff)
downloadqt-creator-e74366bbeace4d29d87ee7401c7665f17ebd5dea.tar.gz
[Debugger] Add dumpers for QEvent and QKeyEvent
QEvent dumper will now show an additional [type] field with the enum name representing the event type (aka the value of QEvent::type()). For example: 'QEvent::KeyPress (0x0006)'. QKeyEvent dumper will now show a value similar to: "Pressed 'F' (key:70 vKey:3 mods:Shift)" as the initial non-expanded value. A new additional field called [Qt::Key] will show the enum value of the key pressed, for example: Qt::Key_F (0x0046) Change-Id: Id91431d0e3d3adeb89d6b74ea341a335ff37efdc Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'share')
-rw-r--r--share/qtcreator/debugger/qttypes.py111
1 files changed, 111 insertions, 0 deletions
diff --git a/share/qtcreator/debugger/qttypes.py b/share/qtcreator/debugger/qttypes.py
index dd339042bf..2aa107429e 100644
--- a/share/qtcreator/debugger/qttypes.py
+++ b/share/qtcreator/debugger/qttypes.py
@@ -24,6 +24,7 @@
############################################################################
import platform
+import re
from dumper import *
@@ -485,6 +486,116 @@ def qdump__QDir(d, value):
d.putFields(value)
+def qdump__QEvent(d, value):
+ d.putNumChild(1)
+ if d.isExpanded():
+ with Children(d):
+ # Add a sub-item with the event type.
+ with SubItem(d, '[type]'):
+ (vtable, privateD, t) = value.split("pp{ushort}")
+ event_type_name = "QEvent::Type"
+ type_value = t.cast(event_type_name)
+ d.putValue(type_value.displayEnum('0x%04x'))
+ d.putType(event_type_name)
+ d.putNumChild(0)
+
+ # Show the rest of the class fields as usual.
+ d.putFields(value, dumpBase=True)
+
+def qdump__QKeyEvent(d, value):
+ # QEvent fields
+ # virtual table pointer
+ # QEventPrivate *d;
+ # ushort t;
+ # ushort posted : 1;
+ # ushort spont : 1;
+ # ushort m_accept : 1;
+ # ushort reserved : 13;
+ # QInputEvent fields
+ # Qt::KeyboardModifiers modState;
+ # ulong ts;
+ # QKeyEvent fields
+ # QString txt;
+ # int k;
+ # quint32 nScanCode;
+ # quint32 nVirtualKey;
+ # quint32 nModifiers; <- nativeModifiers
+ # ushort c;
+ # ushort autor:1;
+ # ushort reserved:15;
+ (vtable, privateD, t, flags, modState, ts, txt, k, scanCode,
+ virtualKey, modifiers,
+ c, autor) = value.split("ppHHiQ{QString}{int}IIIHH")
+
+ #d.putStringValue(txt)
+ #data = d.encodeString(txt)
+ key_txt_utf8 = d.encodeStringUtf8(txt)
+
+ k_type_name = "Qt::Key"
+ k_casted_to_enum_value = k.cast(k_type_name)
+ k_name = k_casted_to_enum_value.displayEnum()
+ matches = re.search(r'Key_(\w+)', k_name)
+ if matches:
+ k_name = matches.group(1)
+
+ if t == 6:
+ key_event_type = "Pressed"
+ elif t == 7:
+ key_event_type = "Released"
+ else:
+ key_event_type = ""
+
+ data = ""
+
+ if key_event_type:
+ data += "{} ".format(key_event_type)
+
+ # Try to use the name of the enum value, otherwise the value
+ # of txt in QKeyEvent.
+ if k_name:
+ data += "'{}'".format(k_name)
+ elif key_txt_utf8:
+ data += "'{}'".format(key_txt_utf8)
+ else:
+ data += "<non-ascii>"
+
+ k_int = k.integer()
+ data += " (key:{} vKey:{}".format(k_int, virtualKey)
+
+ modifier_list = []
+ modifier_list.append(("Shift", 0x02000000))
+ modifier_list.append(("Control", 0x04000000))
+ modifier_list.append(("Alt", 0x08000000))
+ modifier_list.append(("Meta", 0x10000000))
+ # modifier_map.append(("KeyPad", 0x20000000)) Is this useful?
+ modifier_list.append(("Grp", 0x40000000))
+
+ modifiers = []
+ for modifier_name, mask in modifier_list:
+ if modState & mask:
+ modifiers.append(modifier_name)
+
+ if modifiers:
+ data += " mods:" + "+".join(modifiers)
+
+ data += ")"
+
+ d.putValue(d.hexencode(data), 'utf8')
+
+ d.putNumChild(1)
+ if d.isExpanded():
+ with Children(d):
+ # Add a sub-item with the enum name and value.
+ with SubItem(d, '[{}]'.format(k_type_name)):
+ k_casted_to_enum_value = k.cast(k_type_name)
+ d.putValue(k_casted_to_enum_value.displayEnum('0x%04x'))
+ d.putType(k_type_name)
+ d.putNumChild(0)
+
+ # Show the rest of the class fields as usual.
+ d.putFields(value, dumpBase=True)
+
+
def qdump__QFile(d, value):
# 9fc0965 and a373ffcd change the layout of the private structure
qtVersion = d.qtVersion()