Commit a84979bc authored by Luis Javier Merino's avatar Luis Javier Merino Committed by Harald Sitter
Browse files

[kcms/keyboard] tastenbrett: fix diacritics display in keyboard preview

In the keyboard preview, most diacritics from the internal
QHash<unsigned long, char> deadMap don't show up, since their values
don't fit on a char.

On my system, non-spacing diacritics still don't show up after fixing
that.  Unicode recommends applying them to NBSP to exhibit them in
isolation.  However, doing that, I get the diacritic applied to what
appears to be the replacement character (the enclosed interrogation
thingie).  So apply them to a SPACE character (not recommended since
Unicode 4.1).

While we're at it, change the handakuten from its non-spacing mark to
its spacing symbol variant for good measure.

Also "_" doesn't appear, since it is turned to a blank by the logic to
turn "Control_L" to "Control L".

BUG: 433728
parent 0a7c9a07
......@@ -62,7 +62,7 @@ static QString keySymToString(KeySym keysym)
// Strangely enough xkbcommons's UTF map is incomplete with regards to
// dead keys. Extend it a bit.
static QHash<unsigned long, char> deadMap{
static QHash<unsigned long, uint> deadMap{
{XK_dead_grave, 0x0060},
{XK_dead_acute, 0x00b4},
{XK_dead_circumflex, 0x02c6},
......@@ -78,7 +78,7 @@ static QString keySymToString(KeySym keysym)
{XK_dead_ogonek, 0x02DB},
{XK_dead_iota, 0x0269},
{XK_dead_voiced_sound, 0x309B},
{XK_dead_semivoiced_sound, 0x309A},
{XK_dead_semivoiced_sound, 0x309C},
{XK_dead_belowdot, 0x0323},
{XK_dead_hook, 0x0309},
{XK_dead_horn, 0x031b},
......@@ -151,10 +151,28 @@ static QString keySymToString(KeySym keysym)
if (deadMap.contains(keysym)) {
str = QChar(deadMap[keysym]);
QChar c = QChar(deadMap[keysym]);
// Make sure non-spacing diacritics are rendered
if (c.category() == QChar::Mark_NonSpacing
|| c.category() == QChar::Mark_Enclosing) {
// FIXME: should really be NBSP, but it doesn't seem to
// render properly, so use SPACE which is not recommended
// since Unicode 4.1
str = QString("\x20") + c;
} else {
str = c;
// X11 keys can be of the form "Control_L".
// Split them so they are easier on the eyes.
// But only do that on strings of 3 chars of more to not lose "_"
if (str.size() > 2) {
str.replace('_', ' ');
return str.replace('_', ' ');
return str;
KeyCap::KeyCap(const QString symbols[], QObject *parent)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment