summaryrefslogtreecommitdiffhomepage
path: root/gui
diff options
context:
space:
mode:
Diffstat (limited to 'gui')
-rw-r--r--gui/ui.cpp57
-rw-r--r--gui/ui.h8
2 files changed, 32 insertions, 33 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();
};