summaryrefslogtreecommitdiffhomepage
path: root/opentrack/work.hpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-12-05 23:32:43 +0100
committerStanislaw Halik <sthalik@misaki.pl>2015-12-05 23:32:43 +0100
commit86708a2311c1a3efd975798ff42d934eea0078ed (patch)
treefc13ca166c346fd30dbd01d712bb30d66d78feb4 /opentrack/work.hpp
parent578749c5b7f245aac08c4e514d2767dba059c4db (diff)
api/shortcuts: no longer keep shortcuts hardcoded
Diffstat (limited to 'opentrack/work.hpp')
-rw-r--r--opentrack/work.hpp32
1 files changed, 18 insertions, 14 deletions
diff --git a/opentrack/work.hpp b/opentrack/work.hpp
index e338e9f4..a3c0e014 100644
--- a/opentrack/work.hpp
+++ b/opentrack/work.hpp
@@ -16,6 +16,9 @@
#include <QObject>
#include <QFrame>
#include <memory>
+#include <vector>
+#include <functional>
+#include <tuple>
struct Work
{
@@ -24,28 +27,29 @@ struct Work
mem<Tracker> tracker;
mem<Shortcuts> sc;
WId handle;
-
- Work(main_settings& s, Mappings& m, SelectedLibraries& libs, QObject* recv, WId handle) :
+ using fn = std::function<void(void)>;
+ using key_opts = Shortcuts::key_opts;
+ using tt = std::tuple<key_opts&, fn>;
+ std::vector<std::tuple<key_opts&, fn>> keys;
+
+ Work(main_settings& s, Mappings& m, SelectedLibraries& libs, WId handle) :
s(s), libs(libs),
tracker(std::make_shared<Tracker>(s, m, libs)),
sc(std::make_shared<Shortcuts>()),
- handle(handle)
+ handle(handle),
+ keys {
+ tt(sc->s.center, [&]() -> void { tracker->center(); }),
+ tt(sc->s.toggle, [&]() -> void { tracker->toggle_enabled(); }),
+ tt(sc->s.zero, [&]() -> void { tracker->zero(); }),
+ }
{
-#ifndef _WIN32
- QObject::connect(sc->keyCenter.get(), SIGNAL(activated()), recv, SLOT(shortcutRecentered()));
- QObject::connect(sc->keyToggle.get(), SIGNAL(activated()), recv, SLOT(shortcutToggled()));
- QObject::connect(sc->keyZero.get(), SIGNAL(activated()), recv, SLOT(shortcutZeroed()));
-#else
- QObject::connect(sc.get(), SIGNAL(center()), recv, SLOT(shortcutRecentered()));
- QObject::connect(sc.get(), SIGNAL(toggle()), recv, SLOT(shortcutToggled()));
- QObject::connect(sc.get(), SIGNAL(zero()), recv, SLOT(shortcutZeroed()));
-#endif
- tracker->start();
+ reload_shortcuts();
+ tracker->start();
}
void reload_shortcuts()
{
- sc->reload();
+ sc->reload(keys);
}
~Work()