summaryrefslogtreecommitdiffhomepage
path: root/gui/options-dialog.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2017-02-24 11:43:34 +0100
committerStanislaw Halik <sthalik@misaki.pl>2017-02-24 11:43:34 +0100
commit4d6e3bad7e38a80375c4888cf630aa71960d2899 (patch)
treeebd0d2185d9479586a944cba758c5d8214e54158 /gui/options-dialog.cpp
parent670e8774705d160b67c0ad8c938d2525316e125b (diff)
gui: simplify keyboard listener dialog
It's now generated from .ui QDialog, not a manually created QDialog from QLabel in .ui.
Diffstat (limited to 'gui/options-dialog.cpp')
-rw-r--r--gui/options-dialog.cpp23
1 files changed, 7 insertions, 16 deletions
diff --git a/gui/options-dialog.cpp b/gui/options-dialog.cpp
index 98953086..b1dfc472 100644
--- a/gui/options-dialog.cpp
+++ b/gui/options-dialog.cpp
@@ -150,31 +150,22 @@ void OptionsDialog::bind_key(key_opts& kopts, QLabel* label)
kopts.button = -1;
kopts.guid = "";
kopts.keycode = "";
- auto d = new QDialog(this, Qt::MSWindowsFixedSizeDialogHint);
- auto l = new QHBoxLayout;
- l->setMargin(0);
auto k = new KeyboardListener;
- l->addWidget(k);
- d->setLayout(l);
- d->setFixedSize(QSize(500, 300));
- d->setWindowModality(Qt::ApplicationModal);
-
- d->deleteLater();
- l->deleteLater();
+ k->setWindowModality(Qt::ApplicationModal);
k->deleteLater();
connect(k,
&KeyboardListener::key_pressed,
- d,
+ this,
[&](QKeySequence s)
{
kopts.keycode = s.toString(QKeySequence::PortableText);
kopts.guid = "";
kopts.button = -1;
- d->close();
+ k->close();
});
connect(k, &KeyboardListener::joystick_button_pressed,
- d,
+ this,
[&](QString guid, int idx, bool held)
{
if (!held)
@@ -182,12 +173,12 @@ void OptionsDialog::bind_key(key_opts& kopts, QLabel* label)
kopts.guid = guid;
kopts.keycode = "";
kopts.button = idx;
- d->close();
+ k->close();
}
});
- connect(main.b.get(), &options::detail::bundle::reloading, d, &QDialog::close);
+ connect(main.b.get(), &options::detail::bundle::reloading, k, &QDialog::close);
pause_keybindings(true);
- d->exec();
+ k->exec();
pause_keybindings(false);
label->setText(kopts_to_string(kopts));
}