diff options
-rw-r--r-- | variant/trackmouse/lang/nl_NL.ts | 8 | ||||
-rw-r--r-- | variant/trackmouse/lang/ru_RU.ts | 8 | ||||
-rw-r--r-- | variant/trackmouse/lang/stub.ts | 8 | ||||
-rw-r--r-- | variant/trackmouse/lang/zh_CN.ts | 8 | ||||
-rw-r--r-- | variant/trackmouse/window.cpp | 33 | ||||
-rw-r--r-- | variant/trackmouse/window.hpp | 8 | ||||
-rw-r--r-- | variant/trackmouse/window.ui | 5 |
7 files changed, 61 insertions, 17 deletions
diff --git a/variant/trackmouse/lang/nl_NL.ts b/variant/trackmouse/lang/nl_NL.ts index 239c183e..92f790af 100644 --- a/variant/trackmouse/lang/nl_NL.ts +++ b/variant/trackmouse/lang/nl_NL.ts @@ -47,10 +47,6 @@ Exiting now.</source> <translation type="unfinished"></translation> </message> <message> - <source>freeze</source> - <translation type="unfinished"></translation> - </message> - <message> <source>Alt+F12</source> <translation type="unfinished"></translation> </message> @@ -70,5 +66,9 @@ Exiting now.</source> <source>Stop</source> <translation type="unfinished"></translation> </message> + <message> + <source>freeze toggle</source> + <translation type="unfinished"></translation> + </message> </context> </TS> diff --git a/variant/trackmouse/lang/ru_RU.ts b/variant/trackmouse/lang/ru_RU.ts index 611b59ab..dd9011c4 100644 --- a/variant/trackmouse/lang/ru_RU.ts +++ b/variant/trackmouse/lang/ru_RU.ts @@ -47,10 +47,6 @@ Exiting now.</source> <translation type="unfinished"></translation> </message> <message> - <source>freeze</source> - <translation type="unfinished"></translation> - </message> - <message> <source>Alt+F12</source> <translation type="unfinished"></translation> </message> @@ -70,5 +66,9 @@ Exiting now.</source> <source>Stop</source> <translation type="unfinished"></translation> </message> + <message> + <source>freeze toggle</source> + <translation type="unfinished"></translation> + </message> </context> </TS> diff --git a/variant/trackmouse/lang/stub.ts b/variant/trackmouse/lang/stub.ts index 5a3dd52d..968e31c5 100644 --- a/variant/trackmouse/lang/stub.ts +++ b/variant/trackmouse/lang/stub.ts @@ -47,10 +47,6 @@ Exiting now.</source> <translation type="unfinished"></translation> </message> <message> - <source>freeze</source> - <translation type="unfinished"></translation> - </message> - <message> <source>Alt+F12</source> <translation type="unfinished"></translation> </message> @@ -70,5 +66,9 @@ Exiting now.</source> <source>Stop</source> <translation type="unfinished"></translation> </message> + <message> + <source>freeze toggle</source> + <translation type="unfinished"></translation> + </message> </context> </TS> diff --git a/variant/trackmouse/lang/zh_CN.ts b/variant/trackmouse/lang/zh_CN.ts index 5a3dd52d..968e31c5 100644 --- a/variant/trackmouse/lang/zh_CN.ts +++ b/variant/trackmouse/lang/zh_CN.ts @@ -47,10 +47,6 @@ Exiting now.</source> <translation type="unfinished"></translation> </message> <message> - <source>freeze</source> - <translation type="unfinished"></translation> - </message> - <message> <source>Alt+F12</source> <translation type="unfinished"></translation> </message> @@ -70,5 +66,9 @@ Exiting now.</source> <source>Stop</source> <translation type="unfinished"></translation> </message> + <message> + <source>freeze toggle</source> + <translation type="unfinished"></translation> + </message> </context> </TS> 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(); diff --git a/variant/trackmouse/window.hpp b/variant/trackmouse/window.hpp index af3a3043..dc335148 100644 --- a/variant/trackmouse/window.hpp +++ b/variant/trackmouse/window.hpp @@ -10,6 +10,8 @@ #pragma once +#include "proto-mouse/mouse-settings.hpp" + #include "api/plugin-support.hpp" #include "logic/main-settings.hpp" #include "logic/pipeline.hpp" @@ -36,13 +38,17 @@ class main_window final : public QMainWindow, private State Ui::window ui; + QTimer save_settings_timer { this }; + Shortcuts global_shortcuts; module_settings m; + mouse_settings mouse; QShortcut kbd_quit { QKeySequence("Ctrl+Q"), this }; std::unique_ptr<IFilterDialog> pFilterDialog; std::unique_ptr<IProtocolDialog> pProtocolDialog; std::unique_ptr<ITrackerDialog> pTrackerDialog; + bool exiting_already { false }; using dylib_ptr = Modules::dylib_ptr; using dylib_list = Modules::dylib_list; @@ -65,6 +71,8 @@ class main_window final : public QMainWindow, private State bool maybe_die_on_config_not_writable(const QString& current); void die_on_config_not_writable(); + static constexpr inline int save_settings_interval_ms = 2500; + private slots: void save_modules(); void exit(int status = EXIT_SUCCESS); diff --git a/variant/trackmouse/window.ui b/variant/trackmouse/window.ui index f9a45daf..be3efd35 100644 --- a/variant/trackmouse/window.ui +++ b/variant/trackmouse/window.ui @@ -350,6 +350,9 @@ <verstretch>0</verstretch> </sizepolicy> </property> + <property name="maximum"> + <number>475</number> + </property> <property name="pageStep"> <number>1</number> </property> @@ -360,7 +363,7 @@ <enum>QSlider::TicksAbove</enum> </property> <property name="tickInterval"> - <number>10</number> + <number>50</number> </property> </widget> </item> |