diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2016-11-18 15:49:34 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2016-11-18 15:49:34 +0100 |
commit | f5306deba717fea6416ada88592b9c12aecd67a0 (patch) | |
tree | 02b1160ba03fc924cd6ceaec4e139a8d8250b33a | |
parent | 603c96bbe8cf0b409ab91aa5039b94204c30b290 (diff) |
gui/options: allow for translating keyboard modifiers
-rw-r--r-- | gui/options-dialog.cpp | 23 | ||||
-rw-r--r-- | 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 <QDialog> #include <QFileDialog> -static QString kopts_to_string(const key_opts& kopts) +QString OptionsDialog::kopts_to_string(const key_opts& kopts) { - if (static_cast<QString>(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<QString>(kopts.keycode) == "") - return "None"; - return kopts.keycode; + else + return tr("None"); } OptionsDialog::OptionsDialog(std::function<void(bool)> 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<void(bool)> 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(); |