diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2016-05-15 12:30:35 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2016-05-15 12:30:35 +0200 |
commit | 7ed453de4a77266e7e29f2f944b285b4fe3b248b (patch) | |
tree | c03ef2cee93ee78c259542ad2fdc8594ae0c7264 /gui/ui.cpp | |
parent | 2ab0343a75e165684dba64aea4b54a5abbe8086c (diff) |
api,gui: disable all keyboard shortcuts while binding a key
Previous disallowed binding an already-bound key on Unix since Qxt
doesn't pass through bound keys unlike the Windows implementation.
Refactor some common code.
The Windows implementation isn't even compile-tested.
Diffstat (limited to 'gui/ui.cpp')
-rwxr-xr-x | gui/ui.cpp | 33 |
1 files changed, 23 insertions, 10 deletions
@@ -22,8 +22,7 @@ MainWindow::MainWindow() : pose_update_timer(this), kbd_quit(QKeySequence("Ctrl+Q"), this), - is_refreshing_profiles(false), - keys_paused(false) + is_refreshing_profiles(false) { ui.setupUi(this); @@ -109,19 +108,19 @@ MainWindow::MainWindow() : QMessageBox::Ok, QMessageBox::NoButton); connect(this, &MainWindow::emit_start_tracker, - this, [&]() -> void { if (keys_paused) return; qDebug() << "start tracker"; startTracker(); }, + this, [&]() -> void { qDebug() << "start tracker"; startTracker(); }, Qt::QueuedConnection); connect(this, &MainWindow::emit_stop_tracker, - this, [&]() -> void { if (keys_paused) return; qDebug() << "stop tracker"; stopTracker(); }, + this, [&]() -> void { qDebug() << "stop tracker"; stopTracker(); }, Qt::QueuedConnection); connect(this, &MainWindow::emit_toggle_tracker, - this, [&]() -> void { if (keys_paused) return; qDebug() << "toggle tracker"; if (work) stopTracker(); else startTracker(); }, + this, [&]() -> void { qDebug() << "toggle tracker"; if (work) stopTracker(); else startTracker(); }, Qt::QueuedConnection); connect(this, &MainWindow::emit_restart_tracker, - this, [&]() -> void { if (keys_paused) return; qDebug() << "retart tracker"; stopTracker(); startTracker(); }, + this, [&]() -> void { qDebug() << "restart tracker"; stopTracker(); startTracker(); }, Qt::QueuedConnection); register_shortcuts(); @@ -504,11 +503,10 @@ bool mk_window(mem<t>* place, Args&&... params) } void MainWindow::show_options_dialog() { - if (mk_window(&options_widget, - s, - [&]() -> void { register_shortcuts(); }, - [&](bool flag) -> void { keys_paused = flag; })) + if (mk_window(&options_widget, s, [&](bool flag) -> void { set_keys_enabled(!flag); })) + { connect(options_widget.get(), SIGNAL(reload()), this, SLOT(reload_options())); + } } void MainWindow::showCurveConfiguration() { @@ -606,6 +604,21 @@ void MainWindow::maybe_start_profile_from_executable() } } +void MainWindow::set_keys_enabled(bool flag) +{ + if (!flag) + { + if (work) + work->sc->reload({}); + global_shortcuts.reload({}); + } + else + { + register_shortcuts(); + } + qDebug() << "keybindings set to" << flag; +} + void MainWindow::set_profile(const QString &profile) { QSettings settings(OPENTRACK_ORG); |