From 65bad699fc8472b49189a412f730409eb2e96311 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 22 May 2015 15:55:31 +0200 Subject: all: implicitly cancel on form dialog close --- opentrack/main-settings.hpp | 5 ++--- opentrack/options.hpp | 24 +++++++++++++++++++++++- opentrack/shortcuts.h | 5 ++--- 3 files changed, 27 insertions(+), 7 deletions(-) (limited to 'opentrack') diff --git a/opentrack/main-settings.hpp b/opentrack/main-settings.hpp index 0468aeb1..27f9ee06 100644 --- a/opentrack/main-settings.hpp +++ b/opentrack/main-settings.hpp @@ -22,8 +22,7 @@ private: } }; -struct main_settings { - pbundle b; +struct main_settings : opts { value tracker_dll, tracker2_dll, filter_dll, protocol_dll; axis_opts a_x, a_y, a_z, a_yaw, a_pitch, a_roll; value tcomp_p, tcomp_tz; @@ -31,7 +30,7 @@ struct main_settings { value camera_yaw, camera_pitch; value center_at_startup; main_settings() : - b(bundle("opentrack-ui")), + opts("opentrack-ui"), tracker_dll(b, "tracker-dll", ""), tracker2_dll(b, "tracker2-dll", ""), filter_dll(b, "filter-dll", ""), diff --git a/opentrack/options.hpp b/opentrack/options.hpp index 23ce6f7b..c33c2f53 100644 --- a/opentrack/options.hpp +++ b/opentrack/options.hpp @@ -28,6 +28,8 @@ #include #include #include +#include +#include #include @@ -135,6 +137,14 @@ namespace options { QSettings settings(group::org); return settings.value(filename_key, QCoreApplication::applicationDirPath() + default_path).toString(); } + + static const QStringList ini_list() + { + QFileInfo info(group::ini_pathname()); + QDir settings_dir(info.dir()); + return settings_dir.entryList( QStringList { "*.ini" } , QDir::Files, QDir::Name ); + } + static const mem ini_file() { return std::make_shared(ini_pathname(), QSettings::IniFormat); @@ -351,7 +361,19 @@ namespace options { *this = static_cast(*this); } }; - + + struct opts + { + pbundle b; + + opts(const std::string& name) : b(bundle(name)) {} + + ~opts() + { + b->reload(); + } + }; + template inline void tie_setting(value&, q*); diff --git a/opentrack/shortcuts.h b/opentrack/shortcuts.h index 4d4b19d3..d0aedec0 100644 --- a/opentrack/shortcuts.h +++ b/opentrack/shortcuts.h @@ -104,12 +104,11 @@ public: mem keybindingWorker; #endif - struct settings { - pbundle b; + struct settings : opts { key_opts center, toggle, zero; main_settings s_main; settings() : - b(bundle("keyboard-shortcuts")), + opts("keyboard-shortcuts"), center(b, "center"), toggle(b, "toggle"), zero(b, "zero") -- cgit v1.2.3