From f5306deba717fea6416ada88592b9c12aecd67a0 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 18 Nov 2016 15:49:34 +0100 Subject: gui/options: allow for translating keyboard modifiers --- gui/options-dialog.cpp | 23 ++++++++++++++--------- gui/options-dialog.hpp | 1 + 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/gui/options-dialog.cpp b/gui/options-dialog.cpp index 2f40e39f..8f248dcf 100644 --- a/gui/options-dialog.cpp +++ b/gui/options-dialog.cpp @@ -14,21 +14,26 @@ #include #include -static QString kopts_to_string(const key_opts& kopts) +QString OptionsDialog::kopts_to_string(const key_opts& kopts) { - if (static_cast(kopts.guid) != "") + const QString str = kopts.keycode; + if (!str.isEmpty()) { + if (str.startsWith("Num+")) + return tr("Num+") + str.left(4); + const int btn = kopts.button & ~Qt::KeyboardModifierMask; const int mods = kopts.button & Qt::KeyboardModifierMask; QString mm; - if (mods & Qt::ControlModifier) mm += "Control+"; - if (mods & Qt::AltModifier) mm += "Alt+"; - if (mods & Qt::ShiftModifier) mm += "Shift+"; - return mm + "Joy button " + QString::number(btn); + + if (mods & Qt::ControlModifier) mm += tr("Control+"); + if (mods & Qt::AltModifier) mm += tr("Alt+"); + if (mods & Qt::ShiftModifier) mm += tr("Shift+"); + + return mm + tr("Joy button %1").arg(QString::number(btn)); } - if (static_cast(kopts.keycode) == "") - return "None"; - return kopts.keycode; + else + return tr("None"); } OptionsDialog::OptionsDialog(std::function pause_keybindings) : diff --git a/gui/options-dialog.hpp b/gui/options-dialog.hpp index b0e285e8..d98cc4d5 100644 --- a/gui/options-dialog.hpp +++ b/gui/options-dialog.hpp @@ -18,6 +18,7 @@ private: std::function pause_keybindings; Ui::options_dialog ui; void closeEvent(QCloseEvent *) override { doCancel(); } + static QString kopts_to_string(const key_opts& opts); private slots: void doOK(); void doCancel(); -- cgit v1.2.3