summaryrefslogtreecommitdiffhomepage
path: root/facetracknoir
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-08-30 09:28:22 +0200
committerStanislaw Halik <sthalik@misaki.pl>2015-08-30 09:28:31 +0200
commit77542be46d3b56c48735f72d7345a1f1034a0a90 (patch)
treecce871bdbd22830f892c7ea9f79a774489463384 /facetracknoir
parentf281b514b060a2225702b2e7c9420b73d0b2bb72 (diff)
ui: save settings on a timer
The QSettings IO is damn slow on Windows. Save only after five seconds have elapsed with nothing being changed.
Diffstat (limited to 'facetracknoir')
-rw-r--r--facetracknoir/ui.cpp15
-rw-r--r--facetracknoir/ui.h4
2 files changed, 16 insertions, 3 deletions
diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp
index 0876c848..6437b9d1 100644
--- a/facetracknoir/ui.cpp
+++ b/facetracknoir/ui.cpp
@@ -76,6 +76,9 @@ MainWindow::MainWindow() :
connect(&pose_update_timer, SIGNAL(timeout()), this, SLOT(showHeadPose()));
connect(&kbd_quit, SIGNAL(activated()), this, SLOT(exit()));
+ save_timer.setSingleShot(true);
+ connect(&save_timer, SIGNAL(timeout()), this, SLOT(_save()));
+
profile_menu.addAction("Create new empty config", this, SLOT(make_empty_config()));
profile_menu.addAction("Create new copied config", this, SLOT(make_copied_config()));
profile_menu.addAction("Open configuration directory", this, SLOT(open_config_directory()));
@@ -116,10 +119,12 @@ bool MainWindow::get_new_config_name_from_dialog(QString& ret)
MainWindow::~MainWindow()
{
+ save_timer.stop();
+
if (tray)
tray->hide();
stopTracker();
- save();
+ _save();
}
void MainWindow::set_working_directory()
@@ -131,7 +136,13 @@ void MainWindow::save_mappings() {
pose.save_mappings();
}
-void MainWindow::save() {
+void MainWindow::save()
+{
+ save_timer.stop();
+ save_timer.start(5000);
+}
+
+void MainWindow::_save() {
s.b->save();
save_mappings();
mem<QSettings> settings = group::ini_file();
diff --git a/facetracknoir/ui.h b/facetracknoir/ui.h
index 65a7647a..cfaf47cb 100644
--- a/facetracknoir/ui.h
+++ b/facetracknoir/ui.h
@@ -51,6 +51,7 @@ class MainWindow : public QMainWindow, private State
process_detector_worker det;
QMenu profile_menu;
bool is_refreshing_profiles;
+ QTimer save_timer;
mem<dylib> current_tracker()
{
@@ -72,10 +73,11 @@ class MainWindow : public QMainWindow, private State
void display_pose(const double* mapped, const double* raw);
void ensure_tray();
void set_title(const QString& game_title = QStringLiteral(""));
- void save();
static bool get_new_config_name_from_dialog(QString &ret);
void set_profile(const QString& profile);
private slots:
+ void _save();
+ void save();
void exit();
void profileSelected(QString name);