summaryrefslogtreecommitdiffhomepage
path: root/gui
diff options
context:
space:
mode:
Diffstat (limited to 'gui')
-rw-r--r--gui/CMakeLists.txt1
-rw-r--r--gui/main-window.cpp35
-rw-r--r--gui/main-window.hpp4
-rw-r--r--gui/main.cpp9
4 files changed, 31 insertions, 18 deletions
diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt
index c793a65f..f33e2a3d 100644
--- a/gui/CMakeLists.txt
+++ b/gui/CMakeLists.txt
@@ -13,6 +13,7 @@ opentrack_boilerplate(opentrack EXECUTABLE BIN ${console})
set_target_properties(opentrack PROPERTIES SUFFIX "${opentrack-binary-suffix}")
target_link_libraries(opentrack
+ opentrack-migration
opentrack-logic
opentrack-spline-widget
opentrack-pose-widget
diff --git a/gui/main-window.cpp b/gui/main-window.cpp
index 94034bd6..30211128 100644
--- a/gui/main-window.cpp
+++ b/gui/main-window.cpp
@@ -11,6 +11,7 @@
#include "options/options.hpp"
#include "opentrack-library-path.h"
#include "new_file_dialog.h"
+#include "migration/migration.hpp"
#include <QFile>
#include <QFileDialog>
#include <QDesktopServices>
@@ -42,7 +43,7 @@ MainWindow::MainWindow() :
setFixedSize(size());
updateButtonState(false, false);
- refresh_config_list();
+ refresh_config_list(true);
connect(ui.btnEditCurves, SIGNAL(clicked()), this, SLOT(showCurveConfiguration()));
connect(ui.btnShortcuts, SIGNAL(clicked()), this, SLOT(show_options_dialog()));
@@ -87,7 +88,7 @@ MainWindow::MainWindow() :
}
// timers
- connect(&config_list_timer, SIGNAL(timeout()), this, SLOT(refresh_config_list()));
+ connect(&config_list_timer, &QTimer::timeout, this, [this]() { refresh_config_list(false); });
connect(&pose_update_timer, SIGNAL(timeout()), this, SLOT(showHeadPose()));
connect(&det_timer, SIGNAL(timeout()), this, SLOT(maybe_start_profile_from_executable()));
@@ -112,6 +113,8 @@ MainWindow::MainWindow() :
(void) file.open(QFile::ReadWrite);
}
}
+ else
+ set_profile(group::ini_filename());
connect(this, &MainWindow::emit_start_tracker,
this, [&]() -> void { qDebug() << "start tracker"; startTracker(); },
@@ -228,7 +231,7 @@ void MainWindow::register_shortcuts()
work->reload_shortcuts();
}
-void MainWindow::warn_on_config_not_writable()
+bool MainWindow::warn_on_config_not_writable()
{
QString current_file = group::ini_pathname();
QFile f(current_file);
@@ -237,7 +240,10 @@ void MainWindow::warn_on_config_not_writable()
if (!f.isOpen())
{
QMessageBox::warning(this, "Something went wrong", "Check permissions and ownership for your .ini file!", QMessageBox::Ok, QMessageBox::NoButton);
+ return false;
}
+
+ return true;
}
bool MainWindow::get_new_config_name_from_dialog(QString& ret)
@@ -273,8 +279,9 @@ void MainWindow::make_empty_config()
{
QFile filename(dir + "/" + name);
(void) filename.open(QFile::ReadWrite);
- refresh_config_list();
+ refresh_config_list(true);
ui.iconcomboProfile->setCurrentText(name);
+ mark_config_as_not_needing_migration();
}
}
@@ -288,8 +295,9 @@ void MainWindow::make_copied_config()
const QString new_name = dir + "/" + name;
(void) QFile::remove(new_name);
(void) QFile::copy(cur, new_name);
- refresh_config_list();
+ refresh_config_list(true);
ui.iconcomboProfile->setCurrentText(name);
+ mark_config_as_not_needing_migration();
}
}
@@ -302,7 +310,7 @@ void MainWindow::open_config_directory()
}
}
-void MainWindow::refresh_config_list()
+void MainWindow::refresh_config_list(bool warn)
{
if (work)
return;
@@ -357,7 +365,8 @@ void MainWindow::refresh_config_list()
}
set_title();
- warn_on_config_not_writable();
+ if (warn)
+ warn_on_config_not_writable();
}
void MainWindow::updateButtonState(bool running, bool inertialp)
@@ -776,7 +785,13 @@ bool MainWindow::is_tray_enabled()
void MainWindow::set_profile(const QString &profile)
{
- QSettings settings(OPENTRACK_ORG);
- settings.setValue(OPENTRACK_CONFIG_FILENAME_KEY, profile);
- warn_on_config_not_writable();
+ {
+ QSettings settings(OPENTRACK_ORG);
+ settings.setValue(OPENTRACK_CONFIG_FILENAME_KEY, profile);
+ }
+ const bool ok = warn_on_config_not_writable();
+ if (ok)
+ // migrations are for config layout changes and other user-visible
+ // incompatibilities in future versions
+ run_migrations();
}
diff --git a/gui/main-window.hpp b/gui/main-window.hpp
index 75a66b0e..7cd94e93 100644
--- a/gui/main-window.hpp
+++ b/gui/main-window.hpp
@@ -112,7 +112,7 @@ private slots:
void make_empty_config();
void make_copied_config();
void open_config_directory();
- void refresh_config_list();
+ void refresh_config_list(bool warn);
void startTracker();
void stopTracker();
@@ -128,6 +128,6 @@ public:
MainWindow();
~MainWindow();
static void set_working_directory();
- void warn_on_config_not_writable();
+ bool warn_on_config_not_writable();
bool is_tray_enabled();
};
diff --git a/gui/main.cpp b/gui/main.cpp
index e452b781..7ac822dc 100644
--- a/gui/main.cpp
+++ b/gui/main.cpp
@@ -7,6 +7,7 @@
# include <QString>
#endif
+#include "migration/migration.hpp"
#include "main-window.hpp"
#include "options/options.hpp"
#include "compat/win32-com.hpp"
@@ -23,8 +24,7 @@ using namespace options;
void set_qt_style()
{
#if defined(_WIN32) || defined(__APPLE__)
- // qt5 designer-made controls look like shit on 'doze -sh 20140921
- // also our OSX look leaves a lot to be desired -sh 20150726
+ // our layouts on OSX make some control wrongly sized -sh 20160908
{
const QStringList preferred { "fusion", "windowsvista", "macintosh" };
for (const auto& style_name : preferred)
@@ -176,10 +176,7 @@ main(int argc, char** argv)
#ifdef _MSC_VER
int WINAPI
-WinMain (struct HINSTANCE__ *hInstance,
- struct HINSTANCE__ *hPrevInstance,
- char *lpszCmdLine,
- int nCmdShow)
+WinMain (struct HINSTANCE__*, struct HINSTANCE__*, char*, int)
{
return main (__argc, __argv);
}