From 193ba6909fe8f43c9edd307495498b989bdd65a5 Mon Sep 17 00:00:00 2001 From: Deve Date: Tue, 20 Mar 2018 00:10:13 +0100 Subject: [PATCH] Represet special keys on screen keyboard by symbols --- src/guiengine/screen_keyboard.cpp | 35 ++++++++++++++++++++++++++++++- src/guiengine/screen_keyboard.hpp | 1 + 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/guiengine/screen_keyboard.cpp b/src/guiengine/screen_keyboard.cpp index fb78653fd..6b105727e 100644 --- a/src/guiengine/screen_keyboard.cpp +++ b/src/guiengine/screen_keyboard.cpp @@ -185,6 +185,37 @@ void ScreenKeyboard::createButtons() addWidgetsRecursively(m_widgets); } // createButtons +// ---------------------------------------------------------------------------- + +std::wstring ScreenKeyboard::getKeyName(std::string key_id) +{ + std::wstring key_name; + + if (key_id == "Enter") + { + key_name = L"\u23CE"; + } + else if (key_id == "Shift") + { + key_name = L"\u21E7"; + } + else if (key_id == "Back") + { + key_name = L"\u232B"; + } + else if (key_id == "Space") + { + key_name = L"\u2423"; + } + else + { + std::wstring tmp(key_id.begin(), key_id.end()); + key_name = tmp; + } + + return key_name; +} + // ---------------------------------------------------------------------------- /** A function that allows to select one of the available buttons layout * \param buttons_type One of the available buttons type @@ -219,9 +250,11 @@ void ScreenKeyboard::assignButtons(ButtonsType buttons_type) for (int j = 0; j < KEYBOARD_COLS_NUM; j++) { std::string key = keys != NULL ? (*keys)[i][j] : "?"; + std::wstring key_name = getKeyName(key); ButtonWidget* button = m_buttons[i * KEYBOARD_COLS_NUM + j]; - button->setText(key.c_str()); + + button->setText(key_name.c_str()); button->m_properties[PROP_ID] = key; } } diff --git a/src/guiengine/screen_keyboard.hpp b/src/guiengine/screen_keyboard.hpp index 1c0b9516b..bbb12fd5c 100644 --- a/src/guiengine/screen_keyboard.hpp +++ b/src/guiengine/screen_keyboard.hpp @@ -95,6 +95,7 @@ namespace GUIEngine void init(); void createButtons(); void assignButtons(ButtonsType buttons_type); + std::wstring getKeyName(std::string key_id); public: LEAK_CHECK()