summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-06-29 13:05:30 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-06-29 13:18:32 +0200
commit6482a7e2582867d51c19bb12d513bc52dde2cc66 (patch)
tree51f02c20e6601404330c9ea7610ce044dfbbac74
parent2dd8064c20d88c26a11240c6a871f670b5109d71 (diff)
compat/options: separate module dll names from rest of settings
The other settings are modified by the options dialog. These are in the main ui. We need to be able to save modules without saving the options dialog.
-rw-r--r--gui/ui.cpp57
-rw-r--r--gui/ui.h8
-rw-r--r--opentrack-compat/options.hpp26
-rw-r--r--opentrack-logic/main-settings.hpp20
-rw-r--r--opentrack-logic/state.hpp4
5 files changed, 63 insertions, 52 deletions
diff --git a/gui/ui.cpp b/gui/ui.cpp
index ca66104f..9e81d137 100644
--- a/gui/ui.cpp
+++ b/gui/ui.cpp
@@ -51,21 +51,21 @@ MainWindow::MainWindow() :
connect(&config_list_timer, SIGNAL(timeout()), this, SLOT(refresh_config_list()));
config_list_timer.start(1000 * 3);
- tie_setting(s.tracker_dll, ui.iconcomboTrackerSource);
- tie_setting(s.protocol_dll, ui.iconcomboProtocol);
- tie_setting(s.filter_dll, ui.iconcomboFilter);
+ tie_setting(m.tracker_dll, ui.iconcomboTrackerSource);
+ tie_setting(m.protocol_dll, ui.iconcomboProtocol);
+ tie_setting(m.filter_dll, ui.iconcomboFilter);
connect(ui.iconcomboTrackerSource,
&QComboBox::currentTextChanged,
- [&](QString) -> void { if (pTrackerDialog) pTrackerDialog = nullptr; save(); });
+ [&](QString) -> void { if (pTrackerDialog) pTrackerDialog = nullptr; save_modules(); });
connect(ui.iconcomboProtocol,
&QComboBox::currentTextChanged,
- [&](QString) -> void { if (pProtocolDialog) pProtocolDialog = nullptr; save(); });
+ [&](QString) -> void { if (pProtocolDialog) pProtocolDialog = nullptr; save_modules(); });
connect(ui.iconcomboFilter,
&QComboBox::currentTextChanged,
- [&](QString) -> void { if (pFilterDialog) pFilterDialog = nullptr; save(); });
+ [&](QString) -> void { if (pFilterDialog) pFilterDialog = nullptr; save_modules(); });
connect(ui.btnStartTracker, SIGNAL(clicked()), this, SLOT(startTracker()));
connect(ui.btnStopTracker, SIGNAL(clicked()), this, SLOT(stopTracker()));
@@ -146,6 +146,20 @@ void MainWindow::register_shortcuts()
work->reload_shortcuts();
}
+void MainWindow::warn_on_config_not_writable()
+{
+#if defined(__unix) || defined(__linux)
+ QString currentFile = group::ini_pathname();
+ QByteArray bytes = QFile::encodeName(currentFile);
+ const char* filename_as_asciiz = bytes.constData();
+
+ if (access(filename_as_asciiz, R_OK | W_OK))
+ {
+ QMessageBox::warning(this, "Something went wrong", "Check permissions and ownership for your .ini file!", QMessageBox::Ok, QMessageBox::NoButton);
+ }
+#endif
+}
+
bool MainWindow::get_new_config_name_from_dialog(QString& ret)
{
new_file_dialog dlg;
@@ -158,7 +172,7 @@ MainWindow::~MainWindow()
if (tray)
tray->hide();
stopTracker();
- save();
+ save_modules();
}
void MainWindow::set_working_directory()
@@ -166,26 +180,10 @@ void MainWindow::set_working_directory()
QDir::setCurrent(QCoreApplication::applicationDirPath());
}
-void MainWindow::save_mappings()
+void MainWindow::save_modules()
{
- pose.save_mappings();
-}
-
-void MainWindow::save()
-{
- s.b->save();
- //save_mappings();
-
-#if defined(__unix) || defined(__linux)
- QString currentFile = group::ini_pathname();
- QByteArray bytes = QFile::encodeName(currentFile);
- const char* filename_as_asciiz = bytes.constData();
-
- if (access(filename_as_asciiz, R_OK | W_OK))
- {
- QMessageBox::warning(this, "Something went wrong", "Check permissions and ownership for your .ini file!", QMessageBox::Ok, QMessageBox::NoButton);
- }
-#endif
+ m.b->save();
+ warn_on_config_not_writable();
}
void MainWindow::load_mappings()
@@ -197,6 +195,7 @@ void MainWindow::load_mappings()
void MainWindow::load_settings()
{
+ m.b->reload();
s.b->reload();
load_mappings();
}
@@ -314,7 +313,7 @@ void MainWindow::startTracker()
return;
}
- save();
+ save_modules();
work = std::make_shared<Work>(pose, libs, winId());
@@ -358,7 +357,7 @@ void MainWindow::stopTracker()
if (pFilterDialog)
pFilterDialog->unregister_filter();
- save();
+ save_modules();
work = nullptr;
libs = SelectedLibraries();
@@ -522,7 +521,7 @@ void MainWindow::profile_selected(const QString& name)
if (old_name != new_name)
{
- save();
+ save_modules();
{
QSettings settings(OPENTRACK_ORG);
diff --git a/gui/ui.h b/gui/ui.h
index 8fab64ed..b6b87a93 100644
--- a/gui/ui.h
+++ b/gui/ui.h
@@ -72,6 +72,7 @@ class MainWindow : public QMainWindow, private State
void changeEvent(QEvent* e) override;
void load_settings();
+ void load_mappings();
void updateButtonState(bool running, bool inertialp);
void display_pose(const double* mapped, const double* raw);
void ensure_tray();
@@ -79,8 +80,9 @@ class MainWindow : public QMainWindow, private State
static bool get_new_config_name_from_dialog(QString &ret);
void set_profile(const QString& profile);
void register_shortcuts();
+ void set_keys_enabled(bool flag);
private slots:
- void save();
+ void save_modules();
void exit();
void profile_selected(const QString& name);
@@ -113,8 +115,6 @@ signals:
public:
MainWindow();
~MainWindow();
- void save_mappings();
- void load_mappings();
static void set_working_directory();
- void set_keys_enabled(bool flag);
+ static void warn_on_config_not_writable();
};
diff --git a/opentrack-compat/options.hpp b/opentrack-compat/options.hpp
index d7101674..d1173894 100644
--- a/opentrack-compat/options.hpp
+++ b/opentrack-compat/options.hpp
@@ -203,8 +203,8 @@ namespace options {
return detail::singleton().bundle(name);
}
-#define DEFINE_SLOT(t) void setValue(t datum) { store(datum); }
-#define DEFINE_SIGNAL(t) void valueChanged(t)
+#define OPENTRACK_DEFINE_SLOT(t) void setValue(t datum) { store(datum); }
+#define OPENTRACK_DEFINE_SIGNAL(t) void valueChanged(t)
class OPENTRACK_COMPAT_EXPORT base_value : public QObject
{
@@ -213,12 +213,12 @@ namespace options {
QString name() const { return self_name; }
base_value(pbundle b, const QString& name);
signals:
- DEFINE_SIGNAL(double);
- DEFINE_SIGNAL(float);
- DEFINE_SIGNAL(int);
- DEFINE_SIGNAL(bool);
- DEFINE_SIGNAL(QString);
- DEFINE_SIGNAL(slider_value);
+ OPENTRACK_DEFINE_SIGNAL(double);
+ OPENTRACK_DEFINE_SIGNAL(float);
+ OPENTRACK_DEFINE_SIGNAL(int);
+ OPENTRACK_DEFINE_SIGNAL(bool);
+ OPENTRACK_DEFINE_SIGNAL(const QString&);
+ OPENTRACK_DEFINE_SIGNAL(const slider_value&);
protected:
pbundle b;
QString self_name;
@@ -235,11 +235,11 @@ namespace options {
}
public slots:
- DEFINE_SLOT(double)
- DEFINE_SLOT(int)
- DEFINE_SLOT(QString)
- DEFINE_SLOT(bool)
- DEFINE_SLOT(slider_value)
+ OPENTRACK_DEFINE_SLOT(double)
+ OPENTRACK_DEFINE_SLOT(int)
+ OPENTRACK_DEFINE_SLOT(QString)
+ OPENTRACK_DEFINE_SLOT(bool)
+ OPENTRACK_DEFINE_SLOT(slider_value)
public slots:
virtual void reload() = 0;
};
diff --git a/opentrack-logic/main-settings.hpp b/opentrack-logic/main-settings.hpp
index 34997ea0..1aa0d38c 100644
--- a/opentrack-logic/main-settings.hpp
+++ b/opentrack-logic/main-settings.hpp
@@ -47,9 +47,22 @@ struct key_opts
{}
};
-struct main_settings
+struct module_settings
{
+ pbundle b;
value<QString> tracker_dll, filter_dll, protocol_dll;
+ module_settings() :
+ b(bundle("modules")),
+ tracker_dll(b, "tracker-dll", ""),
+ filter_dll(b, "filter-dll", "Accela"),
+ protocol_dll(b, "protocol-dll", "freetrack 2.0 Enhanced")
+ {
+ }
+};
+
+struct main_settings
+{
+ pbundle b;
axis_opts a_x, a_y, a_z, a_yaw, a_pitch, a_roll;
value<bool> tcomp_p, tcomp_tz;
value<bool> tray_enabled;
@@ -60,10 +73,7 @@ struct main_settings
key_opts key_center, key_toggle, key_zero;
key_opts key_toggle_press, key_zero_press;
main_settings() :
- opts("opentrack-ui"),
- tracker_dll(b, "tracker-dll", ""),
- filter_dll(b, "filter-dll", "Accela"),
- protocol_dll(b, "protocol-dll", "freetrack 2.0 Enhanced"),
+ b(bundle("opentrack-ui")),
a_x(b, "x", TX),
a_y(b, "y", TY),
a_z(b, "z", TZ),
diff --git a/opentrack-logic/state.hpp b/opentrack-logic/state.hpp
index ff46cc36..f9bb82c0 100644
--- a/opentrack-logic/state.hpp
+++ b/opentrack-logic/state.hpp
@@ -17,13 +17,15 @@ using namespace options;
#include "selected-libraries.hpp"
#include "work.hpp"
-struct State {
+struct State
+{
State() :
pose(std::vector<axis_opts*>{&s.a_x, &s.a_y, &s.a_z, &s.a_yaw, &s.a_pitch, &s.a_roll})
{}
Modules modules;
SelectedLibraries libs;
main_settings s;
+ module_settings m;
Mappings pose;
mem<Work> work;
};