summaryrefslogtreecommitdiffhomepage
path: root/gui
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-04-29 09:21:10 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-04-29 09:21:23 +0200
commit3a7011ff73cce39ecacb4c5651c1a2dbda8eb10e (patch)
tree84d21d48998aaacbad9cb27b7e5edf29b0dd1396 /gui
parent69cc802722c8264c0fd8b138a298d4820c11f1d8 (diff)
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
Diffstat (limited to 'gui')
-rwxr-xr-x[-rw-r--r--]gui/options-dialog.cpp7
-rwxr-xr-x[-rw-r--r--]gui/settings.ui147
-rwxr-xr-xgui/ui.cpp13
-rwxr-xr-x[-rw-r--r--]gui/ui.h3
4 files changed, 118 insertions, 52 deletions
diff --git a/gui/options-dialog.cpp b/gui/options-dialog.cpp
index e1324ccc..c99bc730 100644..100755
--- 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
index 3a5de399..4c166a08 100644..100755
--- a/gui/settings.ui
+++ b/gui/settings.ui
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>381</width>
- <height>603</height>
+ <width>384</width>
+ <height>639</height>
</rect>
</property>
<property name="windowTitle">
@@ -62,14 +62,59 @@
<string notr="true">QGroupBox { border: 0; }</string>
</property>
<layout class="QGridLayout" name="gridLayout_8">
- <item row="8" column="2">
- <widget class="QPushButton" name="bind_stop">
+ <item row="11" column="2">
+ <widget class="QPushButton" name="bind_toggle_tracking">
<property name="text">
<string>Bind</string>
</property>
</widget>
</item>
- <item row="7" column="0">
+ <item row="11" column="0">
+ <widget class="QLabel" name="textLabel2_9">
+ <property name="text">
+ <string>Toggle tracking</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="0">
+ <widget class="QLabel" name="label_27">
+ <property name="text">
+ <string>Toggle while held</string>
+ </property>
+ </widget>
+ </item>
+ <item row="9" column="1">
+ <widget class="QLabel" name="start_tracking_text">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="9" column="2">
+ <widget class="QPushButton" name="bind_start">
+ <property name="text">
+ <string>Bind</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="2">
+ <widget class="QPushButton" name="bind_toggle">
+ <property name="text">
+ <string>Bind</string>
+ </property>
+ </widget>
+ </item>
+ <item row="10" column="1">
+ <widget class="QLabel" name="stop_tracking_text">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="9" column="0">
<widget class="QLabel" name="textLabel2_7">
<property name="text">
<string>Start tracking</string>
@@ -79,7 +124,21 @@
</property>
</widget>
</item>
- <item row="8" column="0">
+ <item row="11" column="1">
+ <widget class="QLabel" name="toggle_tracking_text">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="10" column="2">
+ <widget class="QPushButton" name="bind_stop">
+ <property name="text">
+ <string>Bind</string>
+ </property>
+ </widget>
+ </item>
+ <item row="10" column="0">
<widget class="QLabel" name="textLabel2_8">
<property name="text">
<string>Stop tracking</string>
@@ -106,21 +165,21 @@
</property>
</widget>
</item>
- <item row="5" column="1">
- <widget class="QLabel" name="toggle_text">
+ <item row="7" column="1">
+ <widget class="QLabel" name="zero_text">
<property name="text">
<string/>
</property>
</widget>
</item>
- <item row="6" column="1">
- <widget class="QLabel" name="zero_text">
+ <item row="5" column="1">
+ <widget class="QLabel" name="toggle_text">
<property name="text">
<string/>
</property>
</widget>
</item>
- <item row="6" column="0">
+ <item row="7" column="0">
<widget class="QLabel" name="textLabel2_6">
<property name="text">
<string>Zero</string>
@@ -130,6 +189,13 @@
</property>
</widget>
</item>
+ <item row="8" column="0">
+ <widget class="QLabel" name="label_28">
+ <property name="text">
+ <string>Zero while held</string>
+ </property>
+ </widget>
+ </item>
<item row="0" column="2">
<widget class="QPushButton" name="bind_center">
<property name="text">
@@ -147,62 +213,62 @@
</property>
</widget>
</item>
- <item row="6" column="2">
+ <item row="7" column="2">
<widget class="QPushButton" name="bind_zero">
<property name="text">
<string>Bind</string>
</property>
</widget>
</item>
- <item row="5" column="2">
- <widget class="QPushButton" name="bind_toggle">
+ <item row="6" column="2">
+ <widget class="QPushButton" name="bind_toggle_held">
<property name="text">
<string>Bind</string>
</property>
</widget>
</item>
- <item row="7" column="2">
- <widget class="QPushButton" name="bind_start">
+ <item row="8" column="1">
+ <widget class="QLabel" name="zero_held_text">
<property name="text">
- <string>Bind</string>
+ <string/>
</property>
</widget>
</item>
- <item row="9" column="0">
- <widget class="QLabel" name="textLabel2_9">
+ <item row="8" column="2">
+ <widget class="QPushButton" name="bind_zero_held">
<property name="text">
- <string>Toggle tracking</string>
- </property>
- <property name="wordWrap">
- <bool>false</bool>
+ <string>Bind</string>
</property>
</widget>
</item>
- <item row="9" column="2">
- <widget class="QPushButton" name="bind_toggle_tracking">
+ <item row="6" column="1">
+ <widget class="QLabel" name="toggle_held_text">
<property name="text">
- <string>Bind</string>
+ <string/>
</property>
</widget>
</item>
- <item row="7" column="1">
- <widget class="QLabel" name="start_tracking_text">
+ <item row="12" column="0">
+ <widget class="QLabel" name="textLabel2_10">
<property name="text">
- <string/>
+ <string>Restart tracking</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
</property>
</widget>
</item>
- <item row="8" column="1">
- <widget class="QLabel" name="stop_tracking_text">
+ <item row="12" column="1">
+ <widget class="QLabel" name="restart_tracking_text">
<property name="text">
<string/>
</property>
</widget>
</item>
- <item row="9" column="1">
- <widget class="QLabel" name="toggle_tracking_text">
+ <item row="12" column="2">
+ <widget class="QPushButton" name="bind_restart_tracking">
<property name="text">
- <string/>
+ <string>Bind</string>
</property>
</widget>
</item>
@@ -266,19 +332,6 @@
</property>
</widget>
</item>
- <item>
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
</layout>
</widget>
<widget class="QWidget" name="tab_3">
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<key_opts&, Shortcuts::fun>;
+ using t_shortcut = std::tuple<key_opts&, Shortcuts::fun, bool>;
std::vector<t_shortcut> 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
index 6dbcf962..9adb69a2 100644..100755
--- 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();