diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2014-11-04 17:40:44 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2014-11-04 19:20:10 +0100 |
commit | d0d2343b0d296e6998fdfc8420ae3f9317fdfd69 (patch) | |
tree | 5a75929a5af354568ec0ec48df73621401885eda /opentrack/mappings.hpp | |
parent | 6cdd799006fb87f0ab7fd670c5812c60de29aab5 (diff) |
nix copy-pasted QSettings usage
Diffstat (limited to 'opentrack/mappings.hpp')
-rw-r--r-- | opentrack/mappings.hpp | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/opentrack/mappings.hpp b/opentrack/mappings.hpp index 1a64fcd9..c58b5863 100644 --- a/opentrack/mappings.hpp +++ b/opentrack/mappings.hpp @@ -6,8 +6,6 @@ using namespace options; #include "../qfunctionconfigurator/functionconfig.h" #include "main-settings.hpp" -static constexpr const char* settings_group = "opentrack-2.3"; - class Mapping { public: Mapping(QString primary, @@ -20,12 +18,9 @@ public: name1(primary), name2(secondary) { - // XXX TODO move all this qsettings boilerplate into a single header -sh 20141004 - QSettings settings(settings_group); - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QSettings iniFile(currentFile, QSettings::IniFormat); - curve.loadSettings(iniFile, primary); - curveAlt.loadSettings(iniFile, secondary); + mem<QSettings> iniFile = group::ini_file(); + curve.loadSettings(*iniFile, primary); + curveAlt.loadSettings(*iniFile, secondary); } Map curve; Map curveAlt; @@ -53,29 +48,25 @@ public: void load_mappings() { - QSettings settings(settings_group); - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QSettings iniFile( currentFile, QSettings::IniFormat ); + mem<QSettings> iniFile = group::ini_file(); for (int i = 0; i < 6; i++) { - axes[i].curve.loadSettings(iniFile, axes[i].name1); - axes[i].curveAlt.loadSettings(iniFile, axes[i].name2); + axes[i].curve.loadSettings(*iniFile, axes[i].name1); + axes[i].curveAlt.loadSettings(*iniFile, axes[i].name2); } } void save_mappings() { - QSettings settings(settings_group); - QString currentFile = settings.value("SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini").toString(); - QSettings iniFile(currentFile, QSettings::IniFormat); + mem<QSettings> iniFile = group::ini_file(); for (int i = 0; i < 6; i++) { - axes[i].curve.saveSettings(iniFile, axes[i].name1); - axes[i].curveAlt.saveSettings(iniFile, axes[i].name2); + axes[i].curve.saveSettings(*iniFile, axes[i].name1); + axes[i].curveAlt.saveSettings(*iniFile, axes[i].name2); } } - + void invalidate_unsaved() { for (int i = 0; i < 6; i++) |