From 02f2779611e717701bdac557180ed669de0a5a22 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 25 Feb 2017 14:09:50 +0100 Subject: gui/options-dialog: prevent crap key text from being saved Unprintable characters won't work in addition to not displaying right. This happens with altgr diacritics on the Polish keyboard on Linux. Skip all key text with unprintable characters, as if the key was getting unbound. --- gui/options-dialog.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'gui') diff --git a/gui/options-dialog.cpp b/gui/options-dialog.cpp index 42b5cc52..18b434c4 100644 --- a/gui/options-dialog.cpp +++ b/gui/options-dialog.cpp @@ -180,7 +180,21 @@ void OptionsDialog::bind_key(key_opts& kopts, QLabel* label) pause_keybindings(true); k->exec(); pause_keybindings(false); - label->setText(kopts_to_string(kopts)); + const bool is_crap = progn( + for (const QChar& c : kopts.keycode()) + if (!c.isPrint()) + return true; + return false; + ); + if (is_crap) + { + kopts.keycode = QStringLiteral(""); + kopts.guid = QStringLiteral(""); + kopts.button = -1; + label->setText(tr("None")); + } + else + label->setText(kopts_to_string(kopts)); } void OptionsDialog::doOK() -- cgit v1.2.3