diff options
| author | Tor Arne Vestbø <[email protected]> | 2025-10-13 17:36:41 +0200 |
|---|---|---|
| committer | Tor Arne Vestbø <[email protected]> | 2025-10-15 14:35:39 +0200 |
| commit | a6cc78f4e26ef2e16ae65540be0d53f9e9fdbc2a (patch) | |
| tree | 62f8534d441a4cc77d92666e96d9a48673f404b9 /src/gui/kernel | |
| parent | 0f3793fea21b17e540265e0f802fdf7b1a6340fe (diff) | |
Teach QKeySequence::toString(Native) about C0 Control Pictures
The Unicode C0 control codes correspond to the 32 control characters
in ASCII from 0x00 and 0x1f. Since these are unprintable in their
basic form, it makes sense to represent them as something printable
via toString(). The Unicode Control Pictures block provides exactly
that.
We skip 0x0 (Null) as we don't distinguish between a missing key
and the null character in Qt.
Although there are also Control Pictures for space (0x20), del
(0x7f), and others, we ignore these as they are not in C0.
[ChangeLog][QtCore] QKeySequence::toString() now maps the C0
control characters to their equivialent in the Unicode Control
Pictures block, if using QKeySequence::SequenceFormat::NativeText.
Change-Id: I4525d08478ebeb2a321b035c96029a22fa5ed749
Reviewed-by: Edward Welbourne <[email protected]>
Diffstat (limited to 'src/gui/kernel')
| -rw-r--r-- | src/gui/kernel/qkeysequence.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp index c7b6e4ebff3..bb71f8fb6fc 100644 --- a/src/gui/kernel/qkeysequence.cpp +++ b/src/gui/kernel/qkeysequence.cpp @@ -1298,7 +1298,10 @@ QString QKeySequencePrivate::keyName(Qt::Key key, QKeySequence::SequenceFormat f bool nativeText = (format == QKeySequence::NativeText); QString p; - if (key && key < Qt::Key_Escape && key != Qt::Key_Space) { + if (nativeText && (key > 0x00 && key <= 0x1f)) { + // Map C0 control codes to the corresponding Control Pictures + p = QChar::fromUcs2(0x2400 + key); + } else if (key && key < Qt::Key_Escape && key != Qt::Key_Space) { if (!QChar::requiresSurrogates(key)) { p = QChar::fromUcs2(key).toUpper(); } else { |
