summaryrefslogtreecommitdiffhomepage
path: root/gui
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-12-06 05:14:07 +0100
committerStanislaw Halik <sthalik@misaki.pl>2015-12-06 05:14:07 +0100
commit4e74d6edef94e4f2f7caae76088f91e9ee993fba (patch)
tree47f6eaf6bc8950b610483df90a4824b4365ae478 /gui
parent0bd32bf56d5b31e7d7e8288b33f536158903e95e (diff)
gui/keys: allow for pausing global keystrokes for options dialog
Toggling tracking while prompting for toggle tracking key causes a deadlock somewhere.
Diffstat (limited to 'gui')
-rw-r--r--gui/options-dialog.cpp10
-rw-r--r--gui/options-dialog.hpp3
-rw-r--r--gui/ui.cpp12
-rw-r--r--gui/ui.h1
4 files changed, 18 insertions, 8 deletions
diff --git a/gui/options-dialog.cpp b/gui/options-dialog.cpp
index 1edf069d..65407184 100644
--- a/gui/options-dialog.cpp
+++ b/gui/options-dialog.cpp
@@ -29,8 +29,12 @@ static QString kopts_to_string(const key_opts& kopts)
return kopts.keycode;
}
-OptionsDialog::OptionsDialog(main_settings& main, std::function<void()> register_global_keys)
- : main(main), register_global_keys(register_global_keys)
+OptionsDialog::OptionsDialog(main_settings& main,
+ std::function<void()> register_global_keys,
+ std::function<void(bool)> pause_keybindings) :
+ main(main),
+ register_global_keys(register_global_keys),
+ pause_keybindings(pause_keybindings)
{
ui.setupUi(this);
@@ -115,7 +119,9 @@ void OptionsDialog::bind_key(key_opts& kopts, QLabel* label)
d.close();
}
});
+ pause_keybindings(true);
d.exec();
+ pause_keybindings(false);
register_global_keys();
label->setText(kopts_to_string(kopts));
delete k;
diff --git a/gui/options-dialog.hpp b/gui/options-dialog.hpp
index 72ae3c30..7700162b 100644
--- a/gui/options-dialog.hpp
+++ b/gui/options-dialog.hpp
@@ -12,10 +12,11 @@ class OptionsDialog: public QWidget
signals:
void reload();
public:
- OptionsDialog(main_settings& main, std::function<void()> register_global_keys);
+ OptionsDialog(main_settings& main, std::function<void()> register_global_keys, std::function<void(bool)> pause_keybindings);
private:
main_settings& main;
std::function<void()> register_global_keys;
+ std::function<void(bool)> pause_keybindings;
Ui::UI_Settings ui;
void closeEvent(QCloseEvent *) override { doCancel(); }
private slots:
diff --git a/gui/ui.cpp b/gui/ui.cpp
index 26fcd9ed..e59b1c23 100644
--- a/gui/ui.cpp
+++ b/gui/ui.cpp
@@ -23,7 +23,8 @@ MainWindow::MainWindow() :
pose_update_timer(this),
kbd_quit(QKeySequence("Ctrl+Q"), this),
no_feed_pixmap(":/images/no-feed.png"),
- is_refreshing_profiles(false)
+ is_refreshing_profiles(false),
+ keys_paused(false)
{
ui.setupUi(this);
@@ -110,15 +111,15 @@ MainWindow::MainWindow() :
QMessageBox::Ok, QMessageBox::NoButton);
connect(this, &MainWindow::emit_start_tracker,
- this, [&]() -> void { qDebug() << "start tracker"; startTracker(); },
+ this, [&]() -> void { if (keys_paused) return; qDebug() << "start tracker"; startTracker(); },
Qt::QueuedConnection);
connect(this, &MainWindow::emit_stop_tracker,
- this, [&]() -> void { qDebug() << "stop tracker"; stopTracker(); },
+ this, [&]() -> void { if (keys_paused) return; qDebug() << "stop tracker"; stopTracker(); },
Qt::QueuedConnection);
connect(this, &MainWindow::emit_toggle_tracker,
- this, [&]() -> void { qDebug() << "toggle tracker"; if (work) stopTracker(); else startTracker(); },
+ this, [&]() -> void { if (keys_paused) return; qDebug() << "toggle tracker"; if (work) stopTracker(); else startTracker(); },
Qt::QueuedConnection);
register_shortcuts();
@@ -493,7 +494,8 @@ bool mk_window(mem<t>* place, Args&&... params)
void MainWindow::show_options_dialog() {
if (mk_window(&options_widget,
s,
- [&]() -> void { register_shortcuts(); }))
+ [&]() -> void { register_shortcuts(); },
+ [&](bool flag) -> void { keys_paused = flag; }))
connect(options_widget.get(), SIGNAL(reload()), this, SLOT(reload_options()));
}
diff --git a/gui/ui.h b/gui/ui.h
index 12ef1f24..ee0a3ce7 100644
--- a/gui/ui.h
+++ b/gui/ui.h
@@ -56,6 +56,7 @@ class MainWindow : public QMainWindow, private State
process_detector_worker det;
QMenu profile_menu;
bool is_refreshing_profiles;
+ volatile bool keys_paused;
QTimer save_timer;
mem<dylib> current_tracker()