From 3a7011ff73cce39ecacb4c5651c1a2dbda8eb10e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 29 Apr 2016 09:21:10 +0200 Subject: api, main: implement new keybindings The following keybindings are now implemented: - restart tracking. if not started, starts. - toggle (keep position) while key held - zero (keep zero) while key held The latter two options only work for Windows as libqxt doesn't support them. Closes #291 --- gui/options-dialog.cpp | 7 +++ gui/settings.ui | 147 +++++++++++++++++++++++++++++++++---------------- gui/ui.cpp | 13 +++-- gui/ui.h | 3 +- 4 files changed, 118 insertions(+), 52 deletions(-) mode change 100644 => 100755 gui/options-dialog.cpp mode change 100644 => 100755 gui/settings.ui mode change 100644 => 100755 gui/ui.h (limited to 'gui') diff --git a/gui/options-dialog.cpp b/gui/options-dialog.cpp old mode 100644 new mode 100755 index e1324ccc..c99bc730 --- a/gui/options-dialog.cpp +++ b/gui/options-dialog.cpp @@ -78,17 +78,24 @@ OptionsDialog::OptionsDialog(main_settings& main, connect(ui.bind_center, &QPushButton::pressed, [&]() -> void { bind_key(main.key_center, ui.center_text); }); connect(ui.bind_zero, &QPushButton::pressed, [&]() -> void { bind_key(main.key_zero, ui.zero_text); }); connect(ui.bind_toggle, &QPushButton::pressed, [&]() -> void { bind_key(main.key_toggle, ui.toggle_text); }); + connect(ui.bind_toggle_held, &QPushButton::pressed, [&]() -> void { bind_key(main.key_toggle_press, ui.toggle_held_text); }); + connect(ui.bind_zero_held, &QPushButton::pressed, [&]() -> void { bind_key(main.key_zero_press, ui.zero_held_text); }); + connect(ui.bind_start, &QPushButton::pressed, [&]() -> void { bind_key(main.key_start_tracking, ui.start_tracking_text); }); connect(ui.bind_stop, &QPushButton::pressed, [&]() -> void { bind_key(main.key_stop_tracking, ui.stop_tracking_text); }); connect(ui.bind_toggle_tracking, &QPushButton::pressed, [&]() -> void { bind_key(main.key_toggle_tracking, ui.toggle_tracking_text); }); + connect(ui.bind_restart_tracking, &QPushButton::pressed, [&]() -> void { bind_key(main.key_restart_tracking, ui.restart_tracking_text); }); ui.center_text->setText(kopts_to_string(main.key_center)); ui.toggle_text->setText(kopts_to_string(main.key_toggle)); + ui.toggle_held_text->setText(kopts_to_string(main.key_toggle_press)); ui.zero_text->setText(kopts_to_string(main.key_zero)); + ui.zero_held_text->setText(kopts_to_string(main.key_zero_press)); ui.start_tracking_text->setText(kopts_to_string(main.key_start_tracking)); ui.stop_tracking_text->setText(kopts_to_string(main.key_stop_tracking)); ui.toggle_tracking_text->setText(kopts_to_string(main.key_toggle_tracking)); + ui.restart_tracking_text->setText(kopts_to_string(main.key_restart_tracking)); } void OptionsDialog::bind_key(key_opts& kopts, QLabel* label) diff --git a/gui/settings.ui b/gui/settings.ui old mode 100644 new mode 100755 index 3a5de399..4c166a08 --- a/gui/settings.ui +++ b/gui/settings.ui @@ -6,8 +6,8 @@ 0 0 - 381 - 603 + 384 + 639 @@ -62,14 +62,59 @@ QGroupBox { border: 0; } - - + + Bind - + + + + Toggle tracking + + + false + + + + + + + Toggle while held + + + + + + + + + + + + + + Bind + + + + + + + Bind + + + + + + + + + + + Start tracking @@ -79,7 +124,21 @@ - + + + + + + + + + + + Bind + + + + Stop tracking @@ -106,21 +165,21 @@ - - + + - - + + - + Zero @@ -130,6 +189,13 @@ + + + + Zero while held + + + @@ -147,62 +213,62 @@ - + Bind - - + + Bind - - + + - Bind + - - + + - Toggle tracking - - - false + Bind - - + + - Bind + - - + + - + Restart tracking + + + false - - + + - - + + - + Bind @@ -266,19 +332,6 @@ - - - - Qt::Vertical - - - - 20 - 40 - - - - diff --git a/gui/ui.cpp b/gui/ui.cpp index a136f2aa..2832126b 100755 --- a/gui/ui.cpp +++ b/gui/ui.cpp @@ -119,6 +119,10 @@ MainWindow::MainWindow() : connect(this, &MainWindow::emit_toggle_tracker, this, [&]() -> void { if (keys_paused) return; 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(); }, + Qt::QueuedConnection); register_shortcuts(); @@ -129,12 +133,13 @@ MainWindow::MainWindow() : void MainWindow::register_shortcuts() { - using t_shortcut = std::tuple; + using t_shortcut = std::tuple; std::vector keys { - t_shortcut(s.key_start_tracking, [&]() -> void { emit_start_tracker(); }), - t_shortcut(s.key_stop_tracking, [&]() -> void { emit_stop_tracker(); }), - t_shortcut(s.key_toggle_tracking, [&]() -> void { emit_toggle_tracker(); }), + t_shortcut(s.key_start_tracking, [&](bool) -> void { emit_start_tracker(); }, true), + t_shortcut(s.key_stop_tracking, [&](bool) -> void { emit_stop_tracker(); }, true), + t_shortcut(s.key_toggle_tracking, [&](bool) -> void { emit_toggle_tracker(); }, true), + t_shortcut(s.key_restart_tracking, [&](bool) -> void { emit_restart_tracker(); }, true), }; global_shortcuts.reload(keys); diff --git a/gui/ui.h b/gui/ui.h old mode 100644 new mode 100755 index 6dbcf962..9adb69a2 --- a/gui/ui.h +++ b/gui/ui.h @@ -111,7 +111,8 @@ signals: void emit_start_tracker(); void emit_stop_tracker(); void emit_toggle_tracker(); - + void emit_restart_tracker(); + void emit_minimized(bool); public: MainWindow(); -- cgit v1.2.3