summaryrefslogtreecommitdiffhomepage
path: root/variant/trackmouse/window.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2018-10-27 06:30:57 +0000
committerStanislaw Halik <sthalik@misaki.pl>2018-10-27 10:53:21 +0000
commitfff6c5d9b7dce04eaee2b3639f2711d70b7bf6e1 (patch)
tree1ea06b4e33b1337bcbd0ce84ebeac33a73179138 /variant/trackmouse/window.cpp
parentde08c69d0c66f06bd165e3b6bd63b71ac83db9a9 (diff)
trackmouse: connect slider to mouse sensitivity
Diffstat (limited to 'variant/trackmouse/window.cpp')
-rw-r--r--variant/trackmouse/window.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/variant/trackmouse/window.cpp b/variant/trackmouse/window.cpp
index bb94f1da..d893b5c1 100644
--- a/variant/trackmouse/window.cpp
+++ b/variant/trackmouse/window.cpp
@@ -83,6 +83,39 @@ main_window::main_window() : State(OPENTRACK_BASE_PATH + OPENTRACK_LIBRARY_PATH)
connect(ui.btnStartTracker, SIGNAL(clicked()), this, SLOT(start_tracker_()));
connect(ui.btnStopTracker, SIGNAL(clicked()), this, SLOT(stop_tracker_()));
+ {
+ tie_setting(mouse.sensitivity_x, ui.sensitivity_slider);
+ tie_setting(mouse.sensitivity_x, ui.sensitivity_label,
+ [](double x) { return QString::number(x) + QStringLiteral("%"); });
+ // one-way only
+ tie_setting(mouse.sensitivity_x, this,
+ [this](double x) { mouse.sensitivity_y = *mouse.sensitivity_x; });
+
+ // no "ok" button, gotta save on timer
+ auto save = [this] {
+ qDebug() << "trackmouse: saving settings";
+ mouse.b->save();
+ save_settings_timer.stop();
+ };
+
+ auto start_save_timer = [this](double) {
+ save_settings_timer.start();
+ };
+
+ save_settings_timer.setInterval(save_settings_interval_ms);
+ save_settings_timer.setSingleShot(true);
+
+ ui.sensitivity_slider->setTracking(false);
+ connect(&save_settings_timer, &QTimer::timeout, this, save, Qt::DirectConnection);
+#if 1
+ // this doesn't fire the timer on application load
+ connect(ui.sensitivity_slider, &QSlider::valueChanged, this, start_save_timer, Qt::DirectConnection);
+#else
+ // but this does so let's not not use it
+ tie_setting(mouse.sensitivity_x, this, start_save_timer);
+#endif
+ }
+
force_trackmouse_settings();
register_shortcuts();