diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2016-06-29 10:37:15 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2016-06-29 13:18:30 +0200 |
commit | 3657d2c0d9807d6f88378981513a944cce4a1a16 (patch) | |
tree | 37f395ff7ace066ac6cdfaaba08bd200741fff14 | |
parent | ee7dbf946a77450e8bf49ea4b64e9b922a951c1f (diff) |
logic, gui: no need to reference "struct main_settings"
Now that "struct main_settings" doesn't implicitly reload in dtor, we no
longer have to pass it around from the user interface.
Only reload it where it's modified, i.e. in the options dialog. Changing
the filter/dialog/mapping comboboxen implicitly saves the main options
however.
-rw-r--r-- | gui/curve-config.cpp | 4 | ||||
-rw-r--r-- | gui/curve-config.h | 2 | ||||
-rw-r--r-- | gui/ui.cpp | 12 | ||||
-rw-r--r-- | gui/ui.h | 2 | ||||
-rw-r--r-- | opentrack-logic/tracker.cpp | 3 | ||||
-rw-r--r-- | opentrack-logic/tracker.h | 4 | ||||
-rw-r--r-- | opentrack-logic/work.hpp | 8 |
7 files changed, 19 insertions, 16 deletions
diff --git a/gui/curve-config.cpp b/gui/curve-config.cpp index 61459c1c..3b56dbb8 100644 --- a/gui/curve-config.cpp +++ b/gui/curve-config.cpp @@ -8,7 +8,7 @@ #include "curve-config.h" #include "opentrack-logic/main-settings.hpp" -MapWidget::MapWidget(Mappings& m, main_settings& s) : +MapWidget::MapWidget(Mappings& m) : m(m) { ui.setupUi( this ); @@ -68,6 +68,8 @@ MapWidget::MapWidget(Mappings& m, main_settings& s) : connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); + main_settings s; + tie_setting(s.a_x.altp, ui.tx_altp); tie_setting(s.a_y.altp, ui.ty_altp); tie_setting(s.a_z.altp, ui.tz_altp); diff --git a/gui/curve-config.h b/gui/curve-config.h index 9a9475b9..04a25ab4 100644 --- a/gui/curve-config.h +++ b/gui/curve-config.h @@ -7,7 +7,7 @@ class MapWidget: public QWidget { Q_OBJECT public: - MapWidget(Mappings &m, main_settings &s); + MapWidget(Mappings &m); private: Ui::UICCurveConfigurationDialog ui; Mappings& m; @@ -69,7 +69,7 @@ MainWindow::MainWindow() : connect(ui.btnStartTracker, SIGNAL(clicked()), this, SLOT(startTracker())); connect(ui.btnStopTracker, SIGNAL(clicked()), this, SLOT(stopTracker())); - connect(ui.iconcomboProfile, SIGNAL(currentTextChanged(QString)), this, SLOT(profileSelected(QString))); + connect(ui.iconcomboProfile, SIGNAL(currentTextChanged(QString)), this, SLOT(profile_selected(QString))); connect(&pose_update_timer, SIGNAL(timeout()), this, SLOT(showHeadPose())); connect(&kbd_quit, SIGNAL(activated()), this, SLOT(exit())); @@ -172,7 +172,7 @@ void MainWindow::save_mappings() void MainWindow::save() { s.b->save(); - save_mappings(); + //save_mappings(); #if defined(__unix) || defined(__linux) QString currentFile = group::ini_pathname(); @@ -189,6 +189,8 @@ void MainWindow::save() void MainWindow::load_mappings() { pose.load_mappings(); + if (mapping_widget) + mapping_widget->reload(); } void MainWindow::load_settings() @@ -312,7 +314,7 @@ void MainWindow::startTracker() save(); - work = std::make_shared<Work>(s, pose, libs, winId()); + work = std::make_shared<Work>(pose, libs, winId()); reload_options(); @@ -500,7 +502,7 @@ void MainWindow::show_options_dialog() void MainWindow::showCurveConfiguration() { - mk_window(&mapping_widget, pose, s); + mk_window(&mapping_widget, pose); } void MainWindow::exit() @@ -508,7 +510,7 @@ void MainWindow::exit() QCoreApplication::exit(0); } -void MainWindow::profileSelected(QString name) +void MainWindow::profile_selected(const QString& name) { if (name == "" || is_refreshing_profiles) return; @@ -82,7 +82,7 @@ class MainWindow : public QMainWindow, private State private slots: void save(); void exit(); - void profileSelected(QString name); + void profile_selected(const QString& name); void showTrackerSettings(); void showProtocolSettings(); diff --git a/opentrack-logic/tracker.cpp b/opentrack-logic/tracker.cpp index 2ac04d03..3fb5c6fc 100644 --- a/opentrack-logic/tracker.cpp +++ b/opentrack-logic/tracker.cpp @@ -21,8 +21,7 @@ # include <windows.h> #endif -Tracker::Tracker(main_settings& s, Mappings &m, SelectedLibraries &libs) : - s(s), +Tracker::Tracker(Mappings &m, SelectedLibraries &libs) : m(m), newpose {0,0,0, 0,0,0}, centerp(s.center_at_startup), diff --git a/opentrack-logic/tracker.h b/opentrack-logic/tracker.h index 591ca03c..dad955c8 100644 --- a/opentrack-logic/tracker.h +++ b/opentrack-logic/tracker.h @@ -48,7 +48,7 @@ class OPENTRACK_LOGIC_EXPORT Tracker : private QThread Q_OBJECT private: QMutex mtx; - main_settings& s; + main_settings s; Mappings& m; Timer t; @@ -72,7 +72,7 @@ private: void t_compensate(const rmat& rmat, const double* ypr, double* output, bool rz); void run() override; public: - Tracker(main_settings& s, Mappings& m, SelectedLibraries& libs); + Tracker(Mappings& m, SelectedLibraries& libs); ~Tracker(); void get_raw_and_mapped_poses(double* mapped, double* raw) const; diff --git a/opentrack-logic/work.hpp b/opentrack-logic/work.hpp index 2377be5a..37bc58bf 100644 --- a/opentrack-logic/work.hpp +++ b/opentrack-logic/work.hpp @@ -22,7 +22,7 @@ struct Work { - main_settings& s; + main_settings s; SelectedLibraries& libs; mem<Tracker> tracker; mem<Shortcuts> sc; @@ -31,9 +31,9 @@ struct Work using tt = std::tuple<key_opts&, fn, bool>; std::vector<tt> keys; - Work(main_settings& s, Mappings& m, SelectedLibraries& libs, WId handle) : - s(s), libs(libs), - tracker(std::make_shared<Tracker>(s, m, libs)), + Work(Mappings& m, SelectedLibraries& libs, WId handle) : + libs(libs), + tracker(std::make_shared<Tracker>(m, libs)), sc(std::make_shared<Shortcuts>()), handle(handle), keys { |