From 9a0cb353b8a19b186fe3c9138e058779cd53bd33 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 13 Aug 2015 10:53:19 +0200 Subject: initial broken multi-platform process lister --- facetracknoir/process_detector.cpp | 34 +--------------------------------- facetracknoir/process_detector.h | 17 ----------------- 2 files changed, 1 insertion(+), 50 deletions(-) mode change 100644 => 100755 facetracknoir/process_detector.cpp mode change 100644 => 100755 facetracknoir/process_detector.h (limited to 'facetracknoir') diff --git a/facetracknoir/process_detector.cpp b/facetracknoir/process_detector.cpp old mode 100644 new mode 100755 index df38eb29..19611241 --- a/facetracknoir/process_detector.cpp +++ b/facetracknoir/process_detector.cpp @@ -8,6 +8,7 @@ #include "process_detector.h" #include "facetracknoir/ui.h" +#include "opentrack-compat/process-list.hpp" #include #include #include @@ -153,36 +154,6 @@ void process_detector::remove() ui.tableWidget->removeRow(r); } -#ifdef _WIN32 - -#include -#include - -static QStringList get_all_executable_names() -{ - QStringList ret; - HANDLE h = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); - if (h == INVALID_HANDLE_VALUE) - return ret; - - PROCESSENTRY32 e; - e.dwSize = sizeof(e); - - if (Process32First(h, &e) != TRUE) - { - CloseHandle(h); - return ret; - } - - do { - ret.append(e.szExeFile); - } while (Process32Next(h, &e) == TRUE); - - CloseHandle(h); - - return ret; -} - bool process_detector_worker::should_stop() { if (last_exe_name == "") @@ -237,6 +208,3 @@ bool process_detector_worker::config_to_start(QString& str) return false; } - - -#endif diff --git a/facetracknoir/process_detector.h b/facetracknoir/process_detector.h old mode 100644 new mode 100755 index 792a941f..f6497c90 --- a/facetracknoir/process_detector.h +++ b/facetracknoir/process_detector.h @@ -74,8 +74,6 @@ public slots: void browse(); }; -#ifdef _WIN32 - class process_detector_worker : QObject { Q_OBJECT @@ -86,18 +84,3 @@ public: bool should_stop(); }; -#else - -class process_detector_worker : QObject -{ - Q_OBJECT -public: - bool config_to_start(QString&) - { - return false; - } - bool should_stop() { return false; } - -}; - -#endif -- cgit v1.2.3 From 6296a266c6c4c468c9d35117b31651c065b62dad Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 22 Aug 2015 10:11:17 +0200 Subject: nix header --- facetracknoir/ui.cpp | 1 - 1 file changed, 1 deletion(-) mode change 100644 => 100755 facetracknoir/ui.cpp (limited to 'facetracknoir') diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp old mode 100644 new mode 100755 index 698d4a1a..7d8ae302 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -34,7 +34,6 @@ #include "opentrack/tracker.h" #include "opentrack/options.hpp" #include -#include #ifndef _WIN32 # include -- cgit v1.2.3 From e02d939c269d0a1b0d387b74f1d767e7c65c14b8 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 22 Aug 2015 11:04:33 +0200 Subject: close dialogs on switch to new module Don't preemptively close dialog on tracking stop, that's annoying for users. --- facetracknoir/ui.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 7d8ae302..3f87ca2f 100755 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -80,6 +80,18 @@ MainWindow::MainWindow() : tie_setting(s.protocol_dll, ui.iconcomboProtocol); tie_setting(s.filter_dll, ui.iconcomboFilter); + connect(ui.iconcomboTrackerSource, + static_cast(&QComboBox::currentIndexChanged), + [&](int) -> void { if (pTrackerDialog) pTrackerDialog = nullptr; }); + + connect(ui.iconcomboProtocol, + static_cast(&QComboBox::currentIndexChanged), + [&](int) -> void { if (pProtocolDialog) pProtocolDialog = nullptr; }); + + connect(ui.iconcomboFilter, + static_cast(&QComboBox::currentIndexChanged), + [&](int) -> void { if (pFilterDialog) pFilterDialog = nullptr; }); + connect(ui.btnStartTracker, SIGNAL(clicked()), this, SLOT(startTracker())); connect(ui.btnStopTracker, SIGNAL(clicked()), this, SLOT(stopTracker())); connect(ui.iconcomboProfile, SIGNAL(currentIndexChanged(int)), this, SLOT(profileSelected(int))); @@ -270,22 +282,13 @@ void MainWindow::stopTracker( ) { ui.pose_display->rotateBy(0, 0, 0, 0, 0, 0); if (pTrackerDialog) - { pTrackerDialog->unregister_tracker(); - pTrackerDialog = nullptr; - } if (pProtocolDialog) - { pProtocolDialog->unregister_protocol(); - pProtocolDialog = nullptr; - } if (pFilterDialog) - { pFilterDialog->unregister_filter(); - pFilterDialog = nullptr; - } work = nullptr; libs = SelectedLibraries(); -- cgit v1.2.3 From 4ab33fdfbb23fdfed5327d402989fd53d79f5380 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 22 Aug 2015 19:02:25 +0200 Subject: main, ui: store config files in a predefined directory Settings files are now stored in Documents/opentrack-version. The transition path is to copy all .ini files into that directory, accessible through the "Profile" menu dropdown. Issue: #179 --- facetracknoir/main.ui | 1900 ++++++++++---------- facetracknoir/new_config.ui | 45 + facetracknoir/new_file_dialog.h | 48 + facetracknoir/ui.cpp | 172 +- facetracknoir/ui.h | 15 +- .../ftnoir_tracker_hat_settings.cpp | 21 +- opentrack/options.hpp | 53 +- 7 files changed, 1207 insertions(+), 1047 deletions(-) create mode 100644 facetracknoir/new_config.ui create mode 100644 facetracknoir/new_file_dialog.h mode change 100755 => 100644 facetracknoir/ui.cpp (limited to 'facetracknoir') diff --git a/facetracknoir/main.ui b/facetracknoir/main.ui index 2328be40..f240a510 100644 --- a/facetracknoir/main.ui +++ b/facetracknoir/main.ui @@ -7,8 +7,8 @@ 0 0 - 708 - 504 + 707 + 492 @@ -53,13 +53,7 @@ 0 - - - 0 - - - 0 - + 0 @@ -72,728 +66,755 @@ 0 + + 0 + - - - - 0 - 0 - - - - - 480 - 360 - - - - - 480 - 360 - - - - - - 0 - 0 - 480 - 360 - - - - - 0 - 0 - - - - - - 0 - 0 - 480 - 360 - - - - - 0 - 0 - - - - - 480 - 360 - - - - - 480 - 360 - - - - - - - - - - - + QFrame::NoFrame - - 0 - - + - 12 + 0 - 6 + 0 - 12 + 0 - 8 + 0 - 4 + 0 - + - + 0 0 - + - 80 - 90 + 480 + 360 - - - - - - - 0 - 0 - - - - Raw tracker data + + + 480 + 360 + - - - 0 - - - 0 + + + + 0 + 0 + 480 + 360 + - - 0 - - - 0 + + + 0 + 0 + - - 3 - - - 2 - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Plain - - - 1 - - - true - - - 4 - - - QLCDNumber::Outline - - - - - - - - 0 - 0 - - - - QFrame::Raised - - - yaw - - - - - - - - 0 - 0 - - - - QFrame::Raised - - - roll - - - - - - - true - - - - 0 - 0 - - - - false - - - QFrame::Raised - - - TZ - - - - - - - - 0 - 0 - - - - QFrame::Raised - - - pitch - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Plain - - - 1 - - - true - - - 4 - - - QLCDNumber::Outline - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Plain - - - 1 - - - true - - - 4 - - - QLCDNumber::Outline - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Plain - - - 1 - - - true - - - 4 - - - QLCDNumber::Outline - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Plain - - - 1 - - - true - - - 4 - - - QLCDNumber::Outline - - - - - - - - 0 - 0 - - - - QFrame::Raised - - - TX - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Plain - - - 1 - - - true - - - 4 - - - QLCDNumber::Outline - - - - - - - true - - - - 0 - 0 - - - - false - - - QFrame::Raised - - - TY - - - - + + + + 0 + 0 + 480 + 360 + + + + + 0 + 0 + + + + + 480 + 360 + + + + + 480 + 360 + + + + + + + - - - - 0 - 0 - + + + QFrame::NoFrame - - Game data + + 0 - + + + 12 + - 0 + 6 - 0 - - - 0 - - - 0 - - - 3 - - - 2 - - - - - true - - - - 0 - 0 - - - - false - - - QFrame::Raised - - - TY - - - - - - - - 0 - 0 - - - - QFrame::Raised - - - pitch - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - true - - - 4 - - - QLCDNumber::Flat - - - - - - - - 0 - 0 - - - - QFrame::Raised - - - yaw - - - - - - - - 0 - 0 - - - - QFrame::Raised - - - roll - - - - - - - true - - - - 0 - 0 - - - - false - - - QFrame::Raised - - - TZ - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - true - - - 4 - - - QLCDNumber::Flat - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - true - - - 4 - - - QLCDNumber::Flat - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - true - - - 4 - - - QLCDNumber::Flat - - - - - - - true - + 12 + + + 8 + + + 4 + + + - + 0 0 - - QFrame::NoFrame - - - true - - - 4 - - - QLCDNumber::Flat + + + 80 + 90 + - - + + - + 0 0 - - QFrame::Raised - - - TX - + + Raw tracker data + + + + 0 + + + 0 + + + 0 + + + 0 + + + 3 + + + 2 + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Plain + + + 1 + + + true + + + 4 + + + QLCDNumber::Outline + + + + + + + + 0 + 0 + + + + QFrame::Raised + + + yaw + + + + + + + + 0 + 0 + + + + QFrame::Raised + + + roll + + + + + + + true + + + + 0 + 0 + + + + false + + + QFrame::Raised + + + TZ + + + + + + + + 0 + 0 + + + + QFrame::Raised + + + pitch + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Plain + + + 1 + + + true + + + 4 + + + QLCDNumber::Outline + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Plain + + + 1 + + + true + + + 4 + + + QLCDNumber::Outline + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Plain + + + 1 + + + true + + + 4 + + + QLCDNumber::Outline + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Plain + + + 1 + + + true + + + 4 + + + QLCDNumber::Outline + + + + + + + + 0 + 0 + + + + QFrame::Raised + + + TX + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Plain + + + 1 + + + true + + + 4 + + + QLCDNumber::Outline + + + + + + + true + + + + 0 + 0 + + + + false + + + QFrame::Raised + + + TY + + + + - - - - true - + + - + 0 0 - - QFrame::NoFrame - - - true - - - 4 - - - QLCDNumber::Flat - + + Game data + + + + 0 + + + 0 + + + 0 + + + 0 + + + 3 + + + 2 + + + + + true + + + + 0 + 0 + + + + false + + + QFrame::Raised + + + TY + + + + + + + + 0 + 0 + + + + QFrame::Raised + + + pitch + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + true + + + 4 + + + QLCDNumber::Flat + + + + + + + + 0 + 0 + + + + QFrame::Raised + + + yaw + + + + + + + + 0 + 0 + + + + QFrame::Raised + + + roll + + + + + + + true + + + + 0 + 0 + + + + false + + + QFrame::Raised + + + TZ + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + true + + + 4 + + + QLCDNumber::Flat + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + true + + + 4 + + + QLCDNumber::Flat + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + true + + + 4 + + + QLCDNumber::Flat + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + true + + + 4 + + + QLCDNumber::Flat + + + + + + + + 0 + 0 + + + + QFrame::Raised + + + TX + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + true + + + 4 + + + QLCDNumber::Flat + + + + @@ -802,112 +823,142 @@ - + + + + 0 + 0 + + + + 4 + - 0 + 8 + + + 10 0 - 6 + 4 0 - - + + + + + 4 + 0 + + - Controls + Settings true - + + + 3 + 4 - 12 + 2 - 4 + 0 - 12 + 6 - - - - false - - - - 0 - 0 - - - - Stop - - - - - + + - + 0 - 0 + 2 - - Start - + + + 0 + + + 0 + + + 2 + + + 2 + + + + + true + + + + 0 + 0 + + + + Profile + + + QToolButton::InstantPopup + + + Qt::ToolButtonTextBesideIcon + + + true + + + Qt::DownArrow + + + + + + + + 0 + 0 + + + + 10 + + + + - - - - - - - Settings - - - true - - - - 4 - - - 0 - - - 4 - - - 4 - - - 2 - - - + + - + 0 - 0 + 3 - Options + Mapping - :/images/tools.png:/images/tools.png + :/images/curves.png:/images/curves.png @@ -917,20 +968,20 @@ - - + + - + 0 - 0 + 3 - Mapping + Options - :/images/curves.png:/images/curves.png + :/images/tools.png:/images/tools.png @@ -943,230 +994,225 @@ - - + + + + + 3 + 0 + + - Filter + Controls true - + + + 8 + - 4 + 0 - 0 + 8 - 4 + 0 - 4 - - - 3 - - - 2 + 9 - - - - - - - true + + + + + 0 + 0 + - ... - - - false + Start - - - - - - - Tracker - - - true - - - - 4 - - - 0 - - - 4 - - - 4 - - - 3 - - - 2 - - - - - - + + - true - - - ... - - false - - - - - - - - - Protocol - - - true - - - - 4 - - - 0 - - - 4 - - - 4 - - - 3 - - - 2 - - - - - true + + + 0 + 0 + - ... - - - false + Stop - - - - + - - 0 + + 4 0 - - Profile + + QFrame::NoFrame - - true + + QFrame::Raised - + + + 2 + - 4 + 3 - 0 + 2 - 4 + 3 - 4 + 8 - - 2 - - - - - - 0 - 0 - - - - 10 - - - - - - - - 0 - 0 - - - - Load - + + + + Tracker + + + + 4 + + + 0 + + + 4 + + + 0 + + + 3 + + + 0 + + + + + + + + true + + + ... + + + false + + + + - - - - true - - - - 0 - 0 - - - - Save - + + + + Protocol + + + + 4 + + + 0 + + + 4 + + + 0 + + + 3 + + + 0 + + + + + + + + true + + + ... + + + false + + + + - - - - true - - - - 0 - 0 - - - - Save... - + + + + Filter + + + + 4 + + + 0 + + + 4 + + + 0 + + + 3 + + + 0 + + + + + + + + true + + + ... + + + false + + + + @@ -1197,10 +1243,6 @@ btnShowServerControls iconcomboFilter btnShowFilterControls - iconcomboProfile - btnLoad - btnSave - btnSaveAs btnEditCurves btnShortcuts diff --git a/facetracknoir/new_config.ui b/facetracknoir/new_config.ui new file mode 100644 index 00000000..27dce0f8 --- /dev/null +++ b/facetracknoir/new_config.ui @@ -0,0 +1,45 @@ + + + UI_new_config + + + Qt::ApplicationModal + + + + 0 + 0 + 269 + 67 + + + + Config filename + + + + images/facetracknoir.pngimages/facetracknoir.png + + + + + + New file name: + + + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + diff --git a/facetracknoir/new_file_dialog.h b/facetracknoir/new_file_dialog.h new file mode 100644 index 00000000..dc821592 --- /dev/null +++ b/facetracknoir/new_file_dialog.h @@ -0,0 +1,48 @@ +#pragma once + +#include "ui_new_config.h" +#include "opentrack/options.hpp" +#include +#include +#include +#include + +class new_file_dialog : public QDialog +{ + Q_OBJECT +public: + new_file_dialog(QWidget* parent = 0) : QDialog(parent), ok(false) + { + ui.setupUi(this); + connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(ok_clicked())); + connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(cancel_clicked())); + setFixedSize(size()); + } + bool is_ok(QString& name_) + { + name_ = name; + return ok; + } +private: + Ui::UI_new_config ui; + bool ok; + QString name; +private slots: + void cancel_clicked() { close(); } + void ok_clicked() + { + QString text = ui.lineEdit->text(); + text = text.replace('/', ""); + text = text.replace('\\', ""); + if (text == "" || QFile(options::group::ini_directory() + "/" + text).exists()) + { + QMessageBox::warning(this, + "File exists", "This file already exists. Pick another name.", + QMessageBox::Ok, QMessageBox::NoButton); + return; + } + ok = true; + close(); + name = text; + } +}; diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp old mode 100755 new mode 100644 index 3f87ca2f..958a2439 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -33,7 +33,10 @@ #include "ui.h" #include "opentrack/tracker.h" #include "opentrack/options.hpp" +#include "facetracknoir/new_file_dialog.h" #include +#include +#include #ifndef _WIN32 # include @@ -53,10 +56,6 @@ MainWindow::MainWindow() : updateButtonState(false, false); ui.video_frame_label->setPixmap(no_feed_pixmap); - connect(ui.btnLoad, SIGNAL(clicked()), this, SLOT(open())); - connect(ui.btnSave, SIGNAL(clicked()), this, SLOT(save())); - connect(ui.btnSaveAs, SIGNAL(clicked()), this, SLOT(saveAs())); - connect(ui.btnEditCurves, SIGNAL(clicked()), this, SLOT(showCurveConfiguration())); connect(ui.btnShortcuts, SIGNAL(clicked()), this, SLOT(showKeyboardShortcuts())); connect(ui.btnShowEngineControls, SIGNAL(clicked()), this, SLOT(showTrackerSettings())); @@ -74,7 +73,7 @@ MainWindow::MainWindow() : for (auto x : modules.filters()) ui.iconcomboFilter->addItem(x->icon, x->name); - fill_profile_combobox(); + refresh_config_list(); tie_setting(s.tracker_dll, ui.iconcomboTrackerSource); tie_setting(s.protocol_dll, ui.iconcomboProtocol); @@ -82,15 +81,15 @@ MainWindow::MainWindow() : connect(ui.iconcomboTrackerSource, static_cast(&QComboBox::currentIndexChanged), - [&](int) -> void { if (pTrackerDialog) pTrackerDialog = nullptr; }); + [&](int) -> void { if (pTrackerDialog) pTrackerDialog = nullptr; save(); }); connect(ui.iconcomboProtocol, static_cast(&QComboBox::currentIndexChanged), - [&](int) -> void { if (pProtocolDialog) pProtocolDialog = nullptr; }); + [&](int) -> void { if (pProtocolDialog) pProtocolDialog = nullptr; save(); }); connect(ui.iconcomboFilter, static_cast(&QComboBox::currentIndexChanged), - [&](int) -> void { if (pFilterDialog) pFilterDialog = nullptr; }); + [&](int) -> void { if (pFilterDialog) pFilterDialog = nullptr; save(); }); connect(ui.btnStartTracker, SIGNAL(clicked()), this, SLOT(startTracker())); connect(ui.btnStopTracker, SIGNAL(clicked()), this, SLOT(stopTracker())); @@ -98,14 +97,46 @@ MainWindow::MainWindow() : connect(&pose_update_timer, SIGNAL(timeout()), this, SLOT(showHeadPose())); connect(&kbd_quit, SIGNAL(activated()), this, SLOT(exit())); + + auto menu = new QMenu; + menu->addAction("Create new empty config", this, SLOT(make_empty_config())); + menu->addAction("Create new copied config", this, SLOT(make_copied_config())); + menu->addAction("Open configuration directory", this, SLOT(open_config_directory())); + menu->addAction("Refresh configuration list", this, SLOT(refresh_config_list())); + ui.profile_button->setMenu(menu); + kbd_quit.setEnabled(true); connect(&det_timer, SIGNAL(timeout()), this, SLOT(maybe_start_profile_from_executable())); det_timer.start(1000); ensure_tray(); - set_working_directory(); + + if (!QFile(group::ini_pathname()).exists()) + { + set_profile(OPENTRACK_DEFAULT_CONFIG); + if (!QFile(group::ini_pathname()).exists()) + { + const auto pathname = group::ini_pathname(); + QFile file(pathname); + if (file.open(QFile::ReadWrite)) + { + QTextStream stream(&file); + stream << "\n"; + } + } + } +} + +bool MainWindow::get_new_config_name_from_dialog(QString& ret) +{ + new_file_dialog dlg; + dlg.exec(); + bool b = dlg.is_ok(ret); + if (b && !ret.endsWith(".ini")) + ret += ".ini"; + return b; } MainWindow::~MainWindow() @@ -121,27 +152,6 @@ void MainWindow::set_working_directory() QDir::setCurrent(QCoreApplication::applicationDirPath()); } -void MainWindow::open() { - QFileDialog dialog(this); - dialog.setFileMode(QFileDialog::ExistingFile); - QString dir_path = QFileInfo(group::ini_pathname()).absolutePath(); - QString fileName = dialog.getOpenFileName( - this, - tr("Open the settings file"), - dir_path, - tr("Settings file (*.ini);;All Files (*)")); - set_working_directory(); - - if (!fileName.isEmpty()) { - { - QSettings settings(OPENTRACK_ORG); - settings.setValue(OPENTRACK_CONFIG_FILENAME_KEY, remove_app_path(fileName)); - } - fill_profile_combobox(); - load_settings(); - } -} - void MainWindow::save_mappings() { pose.save_mappings(); } @@ -164,29 +174,6 @@ void MainWindow::save() { #endif } -void MainWindow::saveAs() -{ - QString oldFile = group::ini_pathname(); - QString fileName = QFileDialog::getSaveFileName(this, tr("Save file"), - oldFile, - tr("Settings file (*.ini);;All Files (*)")); - set_working_directory(); - - if (fileName.isEmpty()) - return; - - (void) QFile::remove(fileName); - - { - (void) QFile::copy(oldFile, fileName); - QSettings settings(OPENTRACK_ORG); - settings.setValue (OPENTRACK_CONFIG_FILENAME_KEY, remove_app_path(fileName)); - } - - save(); - fill_profile_combobox(); -} - void MainWindow::load_mappings() { pose.load_mappings(); } @@ -196,10 +183,59 @@ void MainWindow::load_settings() { load_mappings(); } +void MainWindow::make_empty_config() +{ + QString name; + const QString dir = group::ini_directory(); + if (dir != "" && get_new_config_name_from_dialog(name)) + { + QFile filename(dir + "/" + name); + if (filename.open(QFile::ReadWrite)) + { + QTextStream stream(&filename); + stream << "\n"; + refresh_config_list(); + } + } +} + +void MainWindow::make_copied_config() +{ + const QString dir = group::ini_directory(); + const QString cur = group::ini_pathname(); + QString name; + if (cur != "" && dir != "" && get_new_config_name_from_dialog(name)) + { + const QString new_name = dir + "/" + name; + (void) QFile::remove(new_name); + (void) QFile::copy(cur, new_name); + refresh_config_list(); + } +} + +void MainWindow::open_config_directory() +{ + const QString path = group::ini_directory(); + if (path != "") + { + QDesktopServices::openUrl("file:///" + QDir::toNativeSeparators(path)); + } +} + extern "C" volatile const char* opentrack_version; -void MainWindow::fill_profile_combobox() +void MainWindow::refresh_config_list() { + if (group::ini_list().size() == 0) + { + QFile filename(group::ini_directory() + "/" OPENTRACK_DEFAULT_CONFIG); + if (filename.open(QFile::ReadWrite)) + { + QTextStream stream(&filename); + stream << "\n"; + } + } + QStringList ini_list = group::ini_list(); set_title(); QString current = QFileInfo(group::ini_pathname()).fileName(); @@ -219,8 +255,7 @@ void MainWindow::updateButtonState(bool running, bool inertialp) ui.iconcomboFilter->setEnabled ( not_running ); ui.iconcomboTrackerSource->setEnabled(not_running); ui.video_frame_label->setVisible(not_running || inertialp); - ui.btnSaveAs->setEnabled(not_running); - ui.btnLoad->setEnabled(not_running); + ui.profile_button->setEnabled(not_running); } void MainWindow::bindKeyboardShortcuts() @@ -440,26 +475,6 @@ void MainWindow::exit() { QCoreApplication::exit(0); } -QString MainWindow::remove_app_path(const QString full_path) -{ - QFileInfo path_info(full_path); - QString path = path_info.absolutePath(); - - QFileInfo app_path(QCoreApplication::applicationDirPath()); - QString app_prefix(app_path.absoluteFilePath()); - - if (path == app_prefix) - { - path = "."; - } - else if (path.startsWith(app_prefix + "/")) - { - path = "./" + path.mid(app_prefix.size() + 1); - } - - return path + "/" + path_info.fileName(); -} - void MainWindow::profileSelected(int index) { if (index == -1) @@ -467,8 +482,7 @@ void MainWindow::profileSelected(int index) { QSettings settings(OPENTRACK_ORG); - settings.setValue (OPENTRACK_CONFIG_FILENAME_KEY, remove_app_path(QFileInfo(group::ini_pathname()).absolutePath() + "/" + - ui.iconcomboProfile->itemText(index))); + settings.setValue (OPENTRACK_CONFIG_FILENAME_KEY, ui.iconcomboProfile->itemText(index)); } set_title(); @@ -550,5 +564,5 @@ void MainWindow::maybe_start_profile_from_executable() void MainWindow::set_profile(const QString &profile) { QSettings settings(OPENTRACK_ORG); - settings.setValue(OPENTRACK_CONFIG_FILENAME_KEY, MainWindow::remove_app_path(profile)); + settings.setValue(OPENTRACK_CONFIG_FILENAME_KEY, profile); } diff --git a/facetracknoir/ui.h b/facetracknoir/ui.h index 097b2439..0c3063d4 100644 --- a/facetracknoir/ui.h +++ b/facetracknoir/ui.h @@ -93,22 +93,20 @@ class MainWindow : public QMainWindow, private State void changeEvent(QEvent* e) override; - void createIconGroupBox(); void load_settings(); void updateButtonState(bool running, bool inertialp); - void fill_profile_combobox(); void display_pose(const double* mapped, const double* raw); void ensure_tray(); void set_title(const QString& game_title = QStringLiteral("")); + void save(); + static bool get_new_config_name_from_dialog(QString &ret); + static void set_profile(const QString& profile); public slots: void shortcutRecentered(); void shortcutToggled(); void shortcutZeroed(); void bindKeyboardShortcuts(); private slots: - void open(); - void save(); - void saveAs(); void exit(); void profileSelected(int index); @@ -121,6 +119,11 @@ private slots: void restore_from_tray(QSystemTrayIcon::ActivationReason); void maybe_start_profile_from_executable(); + + void make_empty_config(); + void make_copied_config(); + void open_config_directory(); + void refresh_config_list(); public slots: void startTracker(); void stopTracker(); @@ -129,7 +132,5 @@ public: ~MainWindow(); void save_mappings(); void load_mappings(); - static QString remove_app_path(const QString full_path); static void set_working_directory(); - static void set_profile(const QString& profile); }; diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp b/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp index 80543e7a..0a4454e4 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp @@ -35,15 +35,11 @@ void TrackerSettings::load_ini() { -#ifdef OPENTRACK_API +#ifndef OPENTRACK_API QSettings settings(OPENTRACK_ORG); // Registry settings (in HK_USER) + QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); #else - QSettings settings("opentrack"); // Registry settings (in HK_USER) -#endif -#ifdef OPENTRACK_API - QString currentFile = settings.value( OPENTRACK_CONFIG_FILENAME_KEY, QCoreApplication::applicationDirPath() + OPENTRACK_DEFAULT_CONFIG_PATH ).toString(); -#else - QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = options::group::ini_pathname(); #endif QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) @@ -101,19 +97,14 @@ void TrackerSettings::load_ini() iniFile.endGroup(); } - void TrackerSettings::save_ini() const { -#ifdef OPENTRACK_API +#ifndef OPENTRACK_API QSettings settings(OPENTRACK_ORG); // Registry settings (in HK_USER) + QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); #else - QSettings settings("opentrack"); // Registry settings (in HK_USER) -#endif -#ifdef OPENTRACK_API - QString currentFile = settings.value( OPENTRACK_CONFIG_FILENAME_KEY, QCoreApplication::applicationDirPath() + OPENTRACK_DEFAULT_CONFIG_PATH ).toString(); -#else - QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = options::group::ini_pathname(); #endif QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) diff --git a/opentrack/options.hpp b/opentrack/options.hpp index f4deb8a1..8e623092 100644 --- a/opentrack/options.hpp +++ b/opentrack/options.hpp @@ -30,6 +30,7 @@ #include #include #include +#include #include @@ -38,8 +39,8 @@ #include template using mem = std::shared_ptr; -#define OPENTRACK_CONFIG_FILENAME_KEY "settings-file" -#define OPENTRACK_DEFAULT_CONFIG_PATH "/settings/default.ini" +#define OPENTRACK_CONFIG_FILENAME_KEY "settings-filename" +#define OPENTRACK_DEFAULT_CONFIG "default.ini" #define OPENTRACK_ORG "opentrack-2.3" namespace options { @@ -90,30 +91,30 @@ namespace options { public: group(const string& name) : name(name) { - QSettings conf(ini_pathname(), QSettings::IniFormat); + auto conf = ini_file(); auto q_name = QString::fromStdString(name); - conf.beginGroup(q_name); - for (auto& k_ : conf.childKeys()) + conf->beginGroup(q_name); + for (auto& k_ : conf->childKeys()) { auto tmp = k_.toUtf8(); string k(tmp); - kvs[k] = conf.value(k_); + kvs[k] = conf->value(k_); } - conf.endGroup(); + conf->endGroup(); } void save() { - QSettings s(ini_pathname(), QSettings::IniFormat); + auto s = ini_file(); auto q_name = QString::fromStdString(name); - s.beginGroup(q_name); + s->beginGroup(q_name); for (auto& i : kvs) { auto k = QString::fromStdString(i.first); - s.setValue(k, i.second); + s->setValue(k, i.second); } - s.endGroup(); - s.sync(); + s->endGroup(); + s->sync(); } template @@ -132,22 +133,40 @@ namespace options { return kvs.count(s) != 0; } - static const QString ini_pathname() + static QString ini_directory() { + const auto dirs = QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation); + if (dirs.size() == 0) + return ""; + if (QDir(dirs[0]).mkpath(OPENTRACK_ORG)) + return dirs[0] + "/" OPENTRACK_ORG; + return ""; + } + + static QString ini_pathname() + { + const auto dir = ini_directory(); + if (dir == "") + return ""; QSettings settings(OPENTRACK_ORG); - return settings.value(OPENTRACK_CONFIG_FILENAME_KEY, QCoreApplication::applicationDirPath() + OPENTRACK_DEFAULT_CONFIG_PATH).toString(); + return dir + "/" + settings.value(OPENTRACK_CONFIG_FILENAME_KEY, OPENTRACK_DEFAULT_CONFIG).toString(); } static const QStringList ini_list() { - QFileInfo info(group::ini_pathname()); - QDir settings_dir(info.dir()); + const auto dirname = ini_directory(); + if (dirname == "") + return QStringList(); + QDir settings_dir(dirname); return settings_dir.entryList( QStringList { "*.ini" } , QDir::Files, QDir::Name ); } static const mem ini_file() { - return std::make_shared(ini_pathname(), QSettings::IniFormat); + const auto pathname = ini_pathname(); + if (pathname != "") + return std::make_shared(ini_pathname(), QSettings::IniFormat); + return std::make_shared(); } }; -- cgit v1.2.3 From 21cd2c012ef23ec3f4b374d82056f1fa1694d904 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 22 Aug 2015 19:02:57 +0200 Subject: props changed only Some source files had executable bit on. Remove it. --- CMakeLists.txt | 0 bin/NPClient.dll | Bin bin/NPClient64.dll | Bin bin/freetrackclient.dll | Bin clientfiles/make-csv.pl | 0 csv/csv.cpp | 0 facetracknoir/keyboard.h | 0 facetracknoir/process_detector.cpp | 0 facetracknoir/process_detector.h | 0 ftnoir_filter_kalman/ftnoir_filter_kalman.h | 0 ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp | 0 ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 0 ftnoir_tracker_aruco/include/markerdetector.h | 0 ftnoir_tracker_pt/ftnoir_tracker_pt.cpp | 0 ftnoir_tracker_udp/ftnoir_tracker_udp.cpp | 0 opentrack-compat/process-list.hpp | 0 opentrack/simple-mat.hpp | 0 opentrack/tracker.cpp | 0 opentrack/win32-shortcuts.cpp | 0 opentrack/win32-shortcuts.h | 0 pose-widget/glwidget.cpp | 0 pose-widget/glwidget.h | 0 qfunctionconfigurator/functionconfig.cpp | 0 23 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 CMakeLists.txt mode change 100755 => 100644 bin/NPClient.dll mode change 100755 => 100644 bin/NPClient64.dll mode change 100755 => 100644 bin/freetrackclient.dll mode change 100755 => 100644 clientfiles/make-csv.pl mode change 100755 => 100644 csv/csv.cpp mode change 100755 => 100644 facetracknoir/keyboard.h mode change 100755 => 100644 facetracknoir/process_detector.cpp mode change 100755 => 100644 facetracknoir/process_detector.h mode change 100755 => 100644 ftnoir_filter_kalman/ftnoir_filter_kalman.h mode change 100755 => 100644 ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp mode change 100755 => 100644 ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp mode change 100755 => 100644 ftnoir_tracker_aruco/include/markerdetector.h mode change 100755 => 100644 ftnoir_tracker_pt/ftnoir_tracker_pt.cpp mode change 100755 => 100644 ftnoir_tracker_udp/ftnoir_tracker_udp.cpp mode change 100755 => 100644 opentrack-compat/process-list.hpp mode change 100755 => 100644 opentrack/simple-mat.hpp mode change 100755 => 100644 opentrack/tracker.cpp mode change 100755 => 100644 opentrack/win32-shortcuts.cpp mode change 100755 => 100644 opentrack/win32-shortcuts.h mode change 100755 => 100644 pose-widget/glwidget.cpp mode change 100755 => 100644 pose-widget/glwidget.h mode change 100755 => 100644 qfunctionconfigurator/functionconfig.cpp (limited to 'facetracknoir') diff --git a/CMakeLists.txt b/CMakeLists.txt old mode 100755 new mode 100644 diff --git a/bin/NPClient.dll b/bin/NPClient.dll old mode 100755 new mode 100644 diff --git a/bin/NPClient64.dll b/bin/NPClient64.dll old mode 100755 new mode 100644 diff --git a/bin/freetrackclient.dll b/bin/freetrackclient.dll old mode 100755 new mode 100644 diff --git a/clientfiles/make-csv.pl b/clientfiles/make-csv.pl old mode 100755 new mode 100644 diff --git a/csv/csv.cpp b/csv/csv.cpp old mode 100755 new mode 100644 diff --git a/facetracknoir/keyboard.h b/facetracknoir/keyboard.h old mode 100755 new mode 100644 diff --git a/facetracknoir/process_detector.cpp b/facetracknoir/process_detector.cpp old mode 100755 new mode 100644 diff --git a/facetracknoir/process_detector.h b/facetracknoir/process_detector.h old mode 100755 new mode 100644 diff --git a/ftnoir_filter_kalman/ftnoir_filter_kalman.h b/ftnoir_filter_kalman/ftnoir_filter_kalman.h old mode 100755 new mode 100644 diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp old mode 100755 new mode 100644 diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp old mode 100755 new mode 100644 diff --git a/ftnoir_tracker_aruco/include/markerdetector.h b/ftnoir_tracker_aruco/include/markerdetector.h old mode 100755 new mode 100644 diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp old mode 100755 new mode 100644 diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp old mode 100755 new mode 100644 diff --git a/opentrack-compat/process-list.hpp b/opentrack-compat/process-list.hpp old mode 100755 new mode 100644 diff --git a/opentrack/simple-mat.hpp b/opentrack/simple-mat.hpp old mode 100755 new mode 100644 diff --git a/opentrack/tracker.cpp b/opentrack/tracker.cpp old mode 100755 new mode 100644 diff --git a/opentrack/win32-shortcuts.cpp b/opentrack/win32-shortcuts.cpp old mode 100755 new mode 100644 diff --git a/opentrack/win32-shortcuts.h b/opentrack/win32-shortcuts.h old mode 100755 new mode 100644 diff --git a/pose-widget/glwidget.cpp b/pose-widget/glwidget.cpp old mode 100755 new mode 100644 diff --git a/pose-widget/glwidget.h b/pose-widget/glwidget.h old mode 100755 new mode 100644 diff --git a/qfunctionconfigurator/functionconfig.cpp b/qfunctionconfigurator/functionconfig.cpp old mode 100755 new mode 100644 -- cgit v1.2.3 From afe5e0290e361a7f46289b428c7b865694cee520 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 22 Aug 2015 19:12:43 +0200 Subject: ui: simplify condition --- facetracknoir/ui.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 958a2439..258a0e15 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -116,9 +116,9 @@ MainWindow::MainWindow() : if (!QFile(group::ini_pathname()).exists()) { set_profile(OPENTRACK_DEFAULT_CONFIG); - if (!QFile(group::ini_pathname()).exists()) + const auto pathname = group::ini_pathname(); + if (!QFile(pathname).exists()) { - const auto pathname = group::ini_pathname(); QFile file(pathname); if (file.open(QFile::ReadWrite)) { -- cgit v1.2.3 From 8833ef44c0c359812299d5be25ecdd41d7c1b4e4 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 22 Aug 2015 19:14:13 +0200 Subject: ui: remove GNU GPL Nothing copyrightable under GNU GPL remains. We can FINALLY remove previous copyright statement and GNU GPL terms. Issue: #226 --- facetracknoir/ui.cpp | 24 ------------------------ facetracknoir/ui.h | 24 ------------------------ 2 files changed, 48 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 258a0e15..a204f36d 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -1,27 +1,3 @@ -/******************************************************************************* -* FaceTrackNoIR This program is a private project of the some enthusiastic -* gamers from Holland, who don't like to pay much for -* head-tracking. -* -* Copyright (C) 2011 Wim Vriend (Developing) -* Ron Hendriks (Researching and Testing) -* -* Homepage -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 3 of the License, or (at your -* option) any later version. -* -* This program is distributed in the hope that it will be useful, but -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -* more details. -* -* You should have received a copy of the GNU General Public License along -* with this program; if not, see . -*********************************************************************************/ - /* Copyright (c) 2013-2015, Stanislaw Halik * Permission to use, copy, modify, and/or distribute this diff --git a/facetracknoir/ui.h b/facetracknoir/ui.h index 0c3063d4..94b52491 100644 --- a/facetracknoir/ui.h +++ b/facetracknoir/ui.h @@ -1,27 +1,3 @@ -/******************************************************************************* -* MainWindow This program is a private project of the some enthusiastic -* gamers from Holland, who don't like to pay much for -* head-tracking. -* -* Copyright (C) 2010 Wim Vriend (Developing) -* Ron Hendriks (Researching and Testing) -* -* Homepage -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 3 of the License, or (at your -* option) any later version. -* -* This program is distributed in the hope that it will be useful, but -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -* more details. -* -* You should have received a copy of the GNU General Public License along -* with this program; if not, see . -*********************************************************************************/ - /* Copyright (c) 2014-2015, Stanislaw Halik * Permission to use, copy, modify, and/or distribute this -- cgit v1.2.3 From dbefcb3910665cb9a896c7073ae79200ceb67085 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 22 Aug 2015 19:17:34 +0200 Subject: ui: nix wrong headers --- facetracknoir/ui.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/ui.h b/facetracknoir/ui.h index 94b52491..9fefa2f4 100644 --- a/facetracknoir/ui.h +++ b/facetracknoir/ui.h @@ -16,12 +16,6 @@ #include #include -#if !defined(_WIN32) -# include "qxt-mini/QxtGlobalShortcut" -#else -# include -#endif - #include "ui_main.h" #include "opentrack/options.hpp" -- cgit v1.2.3 From b531e71bb9f86990eaa4a01bc6b51c0079f7db3e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 22 Aug 2015 19:19:55 +0200 Subject: ui: these aren't qt slots --- facetracknoir/ui.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/ui.h b/facetracknoir/ui.h index 9fefa2f4..4e89b143 100644 --- a/facetracknoir/ui.h +++ b/facetracknoir/ui.h @@ -69,13 +69,12 @@ class MainWindow : public QMainWindow, private State void ensure_tray(); void set_title(const QString& game_title = QStringLiteral("")); void save(); - static bool get_new_config_name_from_dialog(QString &ret); - static void set_profile(const QString& profile); -public slots: void shortcutRecentered(); void shortcutToggled(); void shortcutZeroed(); void bindKeyboardShortcuts(); + static bool get_new_config_name_from_dialog(QString &ret); + static void set_profile(const QString& profile); private slots: void exit(); void profileSelected(int index); -- cgit v1.2.3 From c15a456ac6df79a001250fc5b877751db4a30875 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 22 Aug 2015 23:00:59 +0200 Subject: ui: append extension in the right place Otherwise, file can be overwritten accidentally --- facetracknoir/new_file_dialog.h | 2 ++ facetracknoir/ui.cpp | 5 +---- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/new_file_dialog.h b/facetracknoir/new_file_dialog.h index dc821592..d72b8741 100644 --- a/facetracknoir/new_file_dialog.h +++ b/facetracknoir/new_file_dialog.h @@ -34,6 +34,8 @@ private slots: QString text = ui.lineEdit->text(); text = text.replace('/', ""); text = text.replace('\\', ""); + if (text != "" && !text.endsWith(".ini")) + text += ".ini"; if (text == "" || QFile(options::group::ini_directory() + "/" + text).exists()) { QMessageBox::warning(this, diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index a204f36d..e22fee7a 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -109,10 +109,7 @@ bool MainWindow::get_new_config_name_from_dialog(QString& ret) { new_file_dialog dlg; dlg.exec(); - bool b = dlg.is_ok(ret); - if (b && !ret.endsWith(".ini")) - ret += ".ini"; - return b; + return dlg.is_ok(ret); } MainWindow::~MainWindow() -- cgit v1.2.3 From 6319cc457adf63c55920963a7a7cbb1398b8bbac Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 24 Aug 2015 08:44:48 +0200 Subject: ui: avoid potential memory leak While not having tested with valgrind, setMenu() doesn't seem to take ownership of QMenu. Ensure it's not leaked. --- facetracknoir/ui.cpp | 12 +++++------- facetracknoir/ui.h | 2 ++ 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index e22fee7a..bd1b88f7 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -12,7 +12,6 @@ #include "facetracknoir/new_file_dialog.h" #include #include -#include #ifndef _WIN32 # include @@ -74,12 +73,11 @@ MainWindow::MainWindow() : connect(&pose_update_timer, SIGNAL(timeout()), this, SLOT(showHeadPose())); connect(&kbd_quit, SIGNAL(activated()), this, SLOT(exit())); - auto menu = new QMenu; - menu->addAction("Create new empty config", this, SLOT(make_empty_config())); - menu->addAction("Create new copied config", this, SLOT(make_copied_config())); - menu->addAction("Open configuration directory", this, SLOT(open_config_directory())); - menu->addAction("Refresh configuration list", this, SLOT(refresh_config_list())); - ui.profile_button->setMenu(menu); + profile_menu.addAction("Create new empty config", this, SLOT(make_empty_config())); + profile_menu.addAction("Create new copied config", this, SLOT(make_copied_config())); + profile_menu.addAction("Open configuration directory", this, SLOT(open_config_directory())); + profile_menu.addAction("Refresh configuration list", this, SLOT(refresh_config_list())); + ui.profile_button->setMenu(&profile_menu); kbd_quit.setEnabled(true); diff --git a/facetracknoir/ui.h b/facetracknoir/ui.h index 4e89b143..9ecc0db9 100644 --- a/facetracknoir/ui.h +++ b/facetracknoir/ui.h @@ -15,6 +15,7 @@ #include #include #include +#include #include "ui_main.h" @@ -47,6 +48,7 @@ class MainWindow : public QMainWindow, private State mem pProtocolDialog; mem pTrackerDialog; process_detector_worker det; + QMenu profile_menu; mem current_tracker() { -- cgit v1.2.3 From c0d1d315a7a62f8d8453a037073b8e95565cf482 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 24 Aug 2015 08:46:50 +0200 Subject: ui: no need to write anything to new empty config --- facetracknoir/ui.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'facetracknoir') diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index bd1b88f7..c77c35b6 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -96,8 +96,10 @@ MainWindow::MainWindow() : QFile file(pathname); if (file.open(QFile::ReadWrite)) { +#if 0 QTextStream stream(&file); stream << "\n"; +#endif } } } @@ -163,8 +165,10 @@ void MainWindow::make_empty_config() QFile filename(dir + "/" + name); if (filename.open(QFile::ReadWrite)) { +#if 0 QTextStream stream(&filename); stream << "\n"; +#endif refresh_config_list(); } } -- cgit v1.2.3 From 588231e71f08df223a54d15391d8263b4bbf5fea Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 24 Aug 2015 08:56:53 +0200 Subject: ui, shortcuts: these are slots, actually --- facetracknoir/ui.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/ui.h b/facetracknoir/ui.h index 9ecc0db9..f5ce6980 100644 --- a/facetracknoir/ui.h +++ b/facetracknoir/ui.h @@ -71,10 +71,6 @@ class MainWindow : public QMainWindow, private State void ensure_tray(); void set_title(const QString& game_title = QStringLiteral("")); void save(); - void shortcutRecentered(); - void shortcutToggled(); - void shortcutZeroed(); - void bindKeyboardShortcuts(); static bool get_new_config_name_from_dialog(QString &ret); static void set_profile(const QString& profile); private slots: @@ -96,6 +92,10 @@ private slots: void open_config_directory(); void refresh_config_list(); public slots: + void shortcutRecentered(); + void shortcutToggled(); + void shortcutZeroed(); + void bindKeyboardShortcuts(); void startTracker(); void stopTracker(); public: -- cgit v1.2.3 From 3390f15bfafc5f6021856fe822abb49f97acd0f7 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 24 Aug 2015 09:01:50 +0200 Subject: ui: move some slots to private --- facetracknoir/ui.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/ui.h b/facetracknoir/ui.h index f5ce6980..b05fa81b 100644 --- a/facetracknoir/ui.h +++ b/facetracknoir/ui.h @@ -91,13 +91,14 @@ private slots: void make_copied_config(); void open_config_directory(); void refresh_config_list(); + + void startTracker(); + void stopTracker(); + void bindKeyboardShortcuts(); public slots: void shortcutRecentered(); void shortcutToggled(); void shortcutZeroed(); - void bindKeyboardShortcuts(); - void startTracker(); - void stopTracker(); public: MainWindow(); ~MainWindow(); -- cgit v1.2.3 From 872acf11a851a3250f2c668af5f30dc3d48ef477 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 24 Aug 2015 09:58:07 +0200 Subject: ui: rename symbol to reflect current usage --- facetracknoir/ui.cpp | 14 +++++++------- facetracknoir/ui.h | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index c77c35b6..d13fff1c 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -32,7 +32,7 @@ MainWindow::MainWindow() : ui.video_frame_label->setPixmap(no_feed_pixmap); connect(ui.btnEditCurves, SIGNAL(clicked()), this, SLOT(showCurveConfiguration())); - connect(ui.btnShortcuts, SIGNAL(clicked()), this, SLOT(showKeyboardShortcuts())); + connect(ui.btnShortcuts, SIGNAL(clicked()), this, SLOT(show_options_dialog())); connect(ui.btnShowEngineControls, SIGNAL(clicked()), this, SLOT(showTrackerSettings())); connect(ui.btnShowServerControls, SIGNAL(clicked()), this, SLOT(showProtocolSettings())); connect(ui.btnShowFilterControls, SIGNAL(clicked()), this, SLOT(showFilterSettings())); @@ -233,7 +233,7 @@ void MainWindow::updateButtonState(bool running, bool inertialp) ui.profile_button->setEnabled(not_running); } -void MainWindow::bindKeyboardShortcuts() +void MainWindow::reload_options() { if (work) work->reload_shortcuts(); @@ -266,8 +266,8 @@ void MainWindow::startTracker() { work = std::make_shared(s, pose, libs, this, winId()); - bindKeyboardShortcuts(); - + reload_options(); + if (pTrackerDialog) pTrackerDialog->register_tracker(libs.pTracker.get()); @@ -437,9 +437,9 @@ bool mk_window(mem* place, Args... params) } } -void MainWindow::showKeyboardShortcuts() { - if (mk_window(&shortcuts_widget)) - connect(shortcuts_widget.get(), SIGNAL(reload()), this, SLOT(bindKeyboardShortcuts())); +void MainWindow::show_options_dialog() { + if (mk_window(&options_widget)) + connect(options_widget.get(), SIGNAL(reload()), this, SLOT(reload_options())); } void MainWindow::showCurveConfiguration() { diff --git a/facetracknoir/ui.h b/facetracknoir/ui.h index b05fa81b..6d15e496 100644 --- a/facetracknoir/ui.h +++ b/facetracknoir/ui.h @@ -40,7 +40,7 @@ class MainWindow : public QMainWindow, private State mem tray; QTimer pose_update_timer; QTimer det_timer; - mem shortcuts_widget; + mem options_widget; mem mapping_widget; QShortcut kbd_quit; QPixmap no_feed_pixmap; @@ -80,7 +80,7 @@ private slots: void showTrackerSettings(); void showProtocolSettings(); void showFilterSettings(); - void showKeyboardShortcuts(); + void show_options_dialog(); void showCurveConfiguration(); void showHeadPose(); @@ -94,7 +94,7 @@ private slots: void startTracker(); void stopTracker(); - void bindKeyboardShortcuts(); + void reload_options(); public slots: void shortcutRecentered(); void shortcutToggled(); -- cgit v1.2.3 From d54481e409d632a7fa29c6ffddc33ebbec089bf7 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 25 Aug 2015 06:14:30 +0200 Subject: ui: create an empty config properly in another code branch Missed in c0d1d315a7a62f8d8453a037073b8e95565cf482 --- facetracknoir/ui.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'facetracknoir') diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index d13fff1c..9fd4a91d 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -206,8 +206,10 @@ void MainWindow::refresh_config_list() QFile filename(group::ini_directory() + "/" OPENTRACK_DEFAULT_CONFIG); if (filename.open(QFile::ReadWrite)) { +#if 0 QTextStream stream(&filename); stream << "\n"; +#endif } } -- cgit v1.2.3 From d85bc9cab41a05c5f64b0e11831287a7626263e3 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 26 Aug 2015 08:39:12 +0200 Subject: ui: display up to 20 profiles w/o scrolling --- facetracknoir/main.ui | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/main.ui b/facetracknoir/main.ui index f240a510..7bcf09e4 100644 --- a/facetracknoir/main.ui +++ b/facetracknoir/main.ui @@ -8,7 +8,7 @@ 0 0 707 - 492 + 494 @@ -938,7 +938,7 @@ - 10 + 20 -- cgit v1.2.3 From 4559bdb44ef9b48d74cbc2e38ecdccd5e92d48e3 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 26 Aug 2015 08:39:41 +0200 Subject: ui: auto-refresh config list --- facetracknoir/ui.cpp | 6 +++++- facetracknoir/ui.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 9fd4a91d..3d768d8b 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -49,6 +49,8 @@ MainWindow::MainWindow() : ui.iconcomboFilter->addItem(x->icon, x->name); refresh_config_list(); + 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); @@ -76,7 +78,6 @@ MainWindow::MainWindow() : profile_menu.addAction("Create new empty config", this, SLOT(make_empty_config())); profile_menu.addAction("Create new copied config", this, SLOT(make_copied_config())); profile_menu.addAction("Open configuration directory", this, SLOT(open_config_directory())); - profile_menu.addAction("Refresh configuration list", this, SLOT(refresh_config_list())); ui.profile_button->setMenu(&profile_menu); kbd_quit.setEnabled(true); @@ -201,6 +202,9 @@ extern "C" volatile const char* opentrack_version; void MainWindow::refresh_config_list() { + if (work) + return; + if (group::ini_list().size() == 0) { QFile filename(group::ini_directory() + "/" OPENTRACK_DEFAULT_CONFIG); diff --git a/facetracknoir/ui.h b/facetracknoir/ui.h index 6d15e496..46a97b3f 100644 --- a/facetracknoir/ui.h +++ b/facetracknoir/ui.h @@ -40,6 +40,7 @@ class MainWindow : public QMainWindow, private State mem tray; QTimer pose_update_timer; QTimer det_timer; + QTimer config_list_timer; mem options_widget; mem mapping_widget; QShortcut kbd_quit; -- cgit v1.2.3 From df9c024b596d74b02341387577fd0ea1d95d6c78 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 26 Aug 2015 08:39:59 +0200 Subject: ui: also bail on new config if its name is ".ini" --- facetracknoir/new_file_dialog.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/new_file_dialog.h b/facetracknoir/new_file_dialog.h index d72b8741..3a35cf71 100644 --- a/facetracknoir/new_file_dialog.h +++ b/facetracknoir/new_file_dialog.h @@ -36,7 +36,7 @@ private slots: text = text.replace('\\', ""); if (text != "" && !text.endsWith(".ini")) text += ".ini"; - if (text == "" || QFile(options::group::ini_directory() + "/" + text).exists()) + if (text == "" || text == ".ini" || QFile(options::group::ini_directory() + "/" + text).exists()) { QMessageBox::warning(this, "File exists", "This file already exists. Pick another name.", -- cgit v1.2.3 From fa374bca7b8e034987e96fa3d3f87c63d36a407f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 26 Aug 2015 08:40:07 +0200 Subject: ui: decruft --- facetracknoir/ui.cpp | 33 +++------------------------------ 1 file changed, 3 insertions(+), 30 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 3d768d8b..9e1d477c 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -95,13 +95,7 @@ MainWindow::MainWindow() : if (!QFile(pathname).exists()) { QFile file(pathname); - if (file.open(QFile::ReadWrite)) - { -#if 0 - QTextStream stream(&file); - stream << "\n"; -#endif - } + (void) file.open(QFile::ReadWrite); } } } @@ -164,14 +158,7 @@ void MainWindow::make_empty_config() if (dir != "" && get_new_config_name_from_dialog(name)) { QFile filename(dir + "/" + name); - if (filename.open(QFile::ReadWrite)) - { -#if 0 - QTextStream stream(&filename); - stream << "\n"; -#endif - refresh_config_list(); - } + (void) filename.open(QFile::ReadWrite); } } @@ -208,13 +195,7 @@ void MainWindow::refresh_config_list() if (group::ini_list().size() == 0) { QFile filename(group::ini_directory() + "/" OPENTRACK_DEFAULT_CONFIG); - if (filename.open(QFile::ReadWrite)) - { -#if 0 - QTextStream stream(&filename); - stream << "\n"; -#endif - } + (void) filename.open(QFile::ReadWrite); } QStringList ini_list = group::ini_list(); @@ -370,14 +351,6 @@ void MainWindow::showHeadPose() work->tracker->get_raw_and_mapped_poses(mapped, raw); display_pose(mapped, raw); - -#if 0 - if (libs.pProtocol) - { - const QString name = libs.pProtocol->game_name(); - ui.game_name->setText(name); - } -#endif } template -- cgit v1.2.3 From 7e7691f67e4e276a40a52f80735ff6875351a218 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 26 Aug 2015 09:41:11 +0200 Subject: ui: switch to newly-created config --- facetracknoir/ui.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'facetracknoir') diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 9e1d477c..6aa47fb6 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -159,6 +159,8 @@ void MainWindow::make_empty_config() { QFile filename(dir + "/" + name); (void) filename.open(QFile::ReadWrite); + refresh_config_list(); + ui.iconcomboProfile->setCurrentText(name); } } @@ -173,6 +175,7 @@ void MainWindow::make_copied_config() (void) QFile::remove(new_name); (void) QFile::copy(cur, new_name); refresh_config_list(); + ui.iconcomboProfile->setCurrentText(name); } } -- cgit v1.2.3 From 8adcd7acc7280c84a959db0da2d79a0ed918a1ca Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 26 Aug 2015 19:53:40 +0200 Subject: options: return .ini basename easier --- facetracknoir/ui.cpp | 4 ++-- opentrack/options.hpp | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 6aa47fb6..15c94bd7 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -203,7 +203,7 @@ void MainWindow::refresh_config_list() QStringList ini_list = group::ini_list(); set_title(); - QString current = QFileInfo(group::ini_pathname()).fileName(); + QString current = group::ini_filename(); ui.iconcomboProfile->clear(); for (auto x : ini_list) ui.iconcomboProfile->addItem(QIcon(":/images/settings16.png"), x); @@ -343,7 +343,7 @@ void MainWindow::set_title(const QString& game_title_) QString game_title; if (game_title_ != "") game_title = " :: " + game_title_; - QString current = QFileInfo(group::ini_pathname()).fileName(); + QString current = group::ini_filename(); setWindowTitle(const_cast(opentrack_version) + QStringLiteral(" :: ") + current + game_title); } diff --git a/opentrack/options.hpp b/opentrack/options.hpp index 8e623092..f8475877 100644 --- a/opentrack/options.hpp +++ b/opentrack/options.hpp @@ -143,6 +143,12 @@ namespace options { return ""; } + static QString ini_filename() + { + QSettings settings(OPENTRACK_ORG); + return settings.value(OPENTRACK_CONFIG_FILENAME_KEY, OPENTRACK_DEFAULT_CONFIG).toString(); + } + static QString ini_pathname() { const auto dir = ini_directory(); -- cgit v1.2.3 From a220e0af0fb7f9a8efdf24d325e5188f14d386f6 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 26 Aug 2015 19:54:02 +0200 Subject: ui: save everything before switching profiles --- facetracknoir/ui.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'facetracknoir') diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 15c94bd7..0befd813 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -195,6 +195,8 @@ void MainWindow::refresh_config_list() if (work) return; + save(); + if (group::ini_list().size() == 0) { QFile filename(group::ini_directory() + "/" OPENTRACK_DEFAULT_CONFIG); -- cgit v1.2.3 From 844d9a6f4d62227fbf22e65614c84693438080bf Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 26 Aug 2015 19:55:01 +0200 Subject: ui: don't reload settings if config wasn't changed Since combobox is reloaded on a timer, the "current" config changes all the time. --- facetracknoir/ui.cpp | 21 +++++++++++++-------- facetracknoir/ui.h | 2 +- 2 files changed, 14 insertions(+), 9 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 0befd813..3c2d8db6 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -70,7 +70,7 @@ MainWindow::MainWindow() : connect(ui.btnStartTracker, SIGNAL(clicked()), this, SLOT(startTracker())); connect(ui.btnStopTracker, SIGNAL(clicked()), this, SLOT(stopTracker())); - connect(ui.iconcomboProfile, SIGNAL(currentIndexChanged(int)), this, SLOT(profileSelected(int))); + connect(ui.iconcomboProfile, SIGNAL(currentIndexChanged(int)), this, SLOT(profileSelected(int)), Qt::QueuedConnection); connect(&pose_update_timer, SIGNAL(timeout()), this, SLOT(showHeadPose())); connect(&kbd_quit, SIGNAL(activated()), this, SLOT(exit())); @@ -438,15 +438,20 @@ void MainWindow::profileSelected(int index) { if (index == -1) return; - - { - QSettings settings(OPENTRACK_ORG); - settings.setValue (OPENTRACK_CONFIG_FILENAME_KEY, ui.iconcomboProfile->itemText(index)); - } - set_title(); + const auto old_name = group::ini_filename(); + const auto new_name = ui.iconcomboProfile->itemText(index); - load_settings(); + if (old_name != new_name) + { + { + QSettings settings(OPENTRACK_ORG); + settings.setValue (OPENTRACK_CONFIG_FILENAME_KEY, new_name); + } + + set_title(); + load_settings(); + } } void MainWindow::shortcutRecentered() diff --git a/facetracknoir/ui.h b/facetracknoir/ui.h index 46a97b3f..021f327d 100644 --- a/facetracknoir/ui.h +++ b/facetracknoir/ui.h @@ -73,7 +73,7 @@ class MainWindow : public QMainWindow, private State void set_title(const QString& game_title = QStringLiteral("")); void save(); static bool get_new_config_name_from_dialog(QString &ret); - static void set_profile(const QString& profile); + void set_profile(const QString& profile); private slots: void exit(); void profileSelected(int index); -- cgit v1.2.3 From 8aac02ae5e90fe39b44f86d17098828aaea29ee8 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 27 Aug 2015 09:51:01 +0200 Subject: ui: save prior to switching configs --- facetracknoir/ui.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 3c2d8db6..04baaf5a 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -195,8 +195,6 @@ void MainWindow::refresh_config_list() if (work) return; - save(); - if (group::ini_list().size() == 0) { QFile filename(group::ini_directory() + "/" OPENTRACK_DEFAULT_CONFIG); @@ -444,6 +442,8 @@ void MainWindow::profileSelected(int index) if (old_name != new_name) { + save(); + { QSettings settings(OPENTRACK_ORG); settings.setValue (OPENTRACK_CONFIG_FILENAME_KEY, new_name); -- cgit v1.2.3 From 5dd01a9a8ba94a61462340446031904629d12792 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 28 Aug 2015 09:04:43 +0200 Subject: ui: really don't switch profiles while refreshing combobox --- facetracknoir/ui.cpp | 9 ++++++--- facetracknoir/ui.h | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 04baaf5a..89b25fe4 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -22,7 +22,8 @@ MainWindow::MainWindow() : pose_update_timer(this), kbd_quit(QKeySequence("Ctrl+Q"), this), - no_feed_pixmap(":/images/no-feed.png") + no_feed_pixmap(":/images/no-feed.png"), + is_refreshing_profiles(false) { ui.setupUi(this); @@ -70,7 +71,7 @@ MainWindow::MainWindow() : connect(ui.btnStartTracker, SIGNAL(clicked()), this, SLOT(startTracker())); connect(ui.btnStopTracker, SIGNAL(clicked()), this, SLOT(stopTracker())); - connect(ui.iconcomboProfile, SIGNAL(currentIndexChanged(int)), this, SLOT(profileSelected(int)), Qt::QueuedConnection); + connect(ui.iconcomboProfile, SIGNAL(currentIndexChanged(int)), this, SLOT(profileSelected(int))); connect(&pose_update_timer, SIGNAL(timeout()), this, SLOT(showHeadPose())); connect(&kbd_quit, SIGNAL(activated()), this, SLOT(exit())); @@ -204,9 +205,11 @@ void MainWindow::refresh_config_list() QStringList ini_list = group::ini_list(); set_title(); QString current = group::ini_filename(); + is_refreshing_profiles = true; ui.iconcomboProfile->clear(); for (auto x : ini_list) ui.iconcomboProfile->addItem(QIcon(":/images/settings16.png"), x); + is_refreshing_profiles = false; ui.iconcomboProfile->setCurrentText(current); } @@ -434,7 +437,7 @@ void MainWindow::exit() { void MainWindow::profileSelected(int index) { - if (index == -1) + if (index == -1 || is_refreshing_profiles) return; const auto old_name = group::ini_filename(); diff --git a/facetracknoir/ui.h b/facetracknoir/ui.h index 021f327d..5d81507f 100644 --- a/facetracknoir/ui.h +++ b/facetracknoir/ui.h @@ -50,6 +50,7 @@ class MainWindow : public QMainWindow, private State mem pTrackerDialog; process_detector_worker det; QMenu profile_menu; + bool is_refreshing_profiles; mem current_tracker() { -- cgit v1.2.3 From 303f621e3091e2bbe12f6a5e2e35310f6e9b0701 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 28 Aug 2015 13:51:41 +0200 Subject: no need to save on tracking start anymore --- facetracknoir/ui.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 89b25fe4..a600543c 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -234,7 +234,6 @@ void MainWindow::reload_options() } void MainWindow::startTracker() { - s.b->save(); load_settings(); // tracker dtor needs run first -- cgit v1.2.3 From be000a8a9aad1d6804ee27b02b12b531029427cb Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 30 Aug 2015 08:46:03 +0200 Subject: ui: save current tracker/filter/proto, not last Current tracker/filter/proto name depends on the currentTextChanged() slot. currentIndexChanged() runs before currentText() is updated, causing the old name to be saved. --- facetracknoir/ui.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index a600543c..7b84de72 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -58,16 +58,16 @@ MainWindow::MainWindow() : tie_setting(s.filter_dll, ui.iconcomboFilter); connect(ui.iconcomboTrackerSource, - static_cast(&QComboBox::currentIndexChanged), - [&](int) -> void { if (pTrackerDialog) pTrackerDialog = nullptr; save(); }); + &QComboBox::currentTextChanged, + [&](QString) -> void { if (pTrackerDialog) pTrackerDialog = nullptr; save(); }); connect(ui.iconcomboProtocol, - static_cast(&QComboBox::currentIndexChanged), - [&](int) -> void { if (pProtocolDialog) pProtocolDialog = nullptr; save(); }); + &QComboBox::currentTextChanged, + [&](QString) -> void { if (pProtocolDialog) pProtocolDialog = nullptr; save(); }); connect(ui.iconcomboFilter, - static_cast(&QComboBox::currentIndexChanged), - [&](int) -> void { if (pFilterDialog) pFilterDialog = nullptr; save(); }); + &QComboBox::currentTextChanged, + [&](QString) -> void { if (pFilterDialog) pFilterDialog = nullptr; save(); }); connect(ui.btnStartTracker, SIGNAL(clicked()), this, SLOT(startTracker())); connect(ui.btnStopTracker, SIGNAL(clicked()), this, SLOT(stopTracker())); -- cgit v1.2.3 From 8b08d5800354a5dcedfd7811447ea76e09c31d03 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 30 Aug 2015 08:48:24 +0200 Subject: ui: save profile when combobox text changes, not merely index --- facetracknoir/ui.cpp | 8 ++++---- facetracknoir/ui.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 7b84de72..0c104553 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -71,7 +71,7 @@ MainWindow::MainWindow() : connect(ui.btnStartTracker, SIGNAL(clicked()), this, SLOT(startTracker())); connect(ui.btnStopTracker, SIGNAL(clicked()), this, SLOT(stopTracker())); - connect(ui.iconcomboProfile, SIGNAL(currentIndexChanged(int)), this, SLOT(profileSelected(int))); + connect(ui.iconcomboProfile, SIGNAL(currentTextChanged(QString)), this, SLOT(profileSelected(QString))); connect(&pose_update_timer, SIGNAL(timeout()), this, SLOT(showHeadPose())); connect(&kbd_quit, SIGNAL(activated()), this, SLOT(exit())); @@ -434,13 +434,13 @@ void MainWindow::exit() { QCoreApplication::exit(0); } -void MainWindow::profileSelected(int index) +void MainWindow::profileSelected(QString name) { - if (index == -1 || is_refreshing_profiles) + if (name == "" || is_refreshing_profiles) return; const auto old_name = group::ini_filename(); - const auto new_name = ui.iconcomboProfile->itemText(index); + const auto new_name = name; if (old_name != new_name) { diff --git a/facetracknoir/ui.h b/facetracknoir/ui.h index 5d81507f..65a7647a 100644 --- a/facetracknoir/ui.h +++ b/facetracknoir/ui.h @@ -77,7 +77,7 @@ class MainWindow : public QMainWindow, private State void set_profile(const QString& profile); private slots: void exit(); - void profileSelected(int index); + void profileSelected(QString name); void showTrackerSettings(); void showProtocolSettings(); -- cgit v1.2.3 From 1dae49c90d62d7f0f627e1ac2401b94a2c67775a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 30 Aug 2015 08:46:18 +0200 Subject: ui: no need to reset settings on tracking start --- facetracknoir/ui.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 0c104553..32ca3e4b 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -234,8 +234,6 @@ void MainWindow::reload_options() } void MainWindow::startTracker() { - load_settings(); - // tracker dtor needs run first work = nullptr; -- cgit v1.2.3 From f281b514b060a2225702b2e7c9420b73d0b2bb72 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 30 Aug 2015 09:27:33 +0200 Subject: ui: show a warning if configuration directory can't be used --- facetracknoir/ui.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'facetracknoir') diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 32ca3e4b..0876c848 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -99,6 +99,12 @@ MainWindow::MainWindow() : (void) file.open(QFile::ReadWrite); } } + + if (group::ini_directory() == "") + QMessageBox::warning(this, + "Configuration not saved.", + "Can't create configuration directory! Expect major malfunction.", + QMessageBox::Ok, QMessageBox::NoButton); } bool MainWindow::get_new_config_name_from_dialog(QString& ret) -- cgit v1.2.3 From 77542be46d3b56c48735f72d7345a1f1034a0a90 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 30 Aug 2015 09:28:22 +0200 Subject: ui: save settings on a timer The QSettings IO is damn slow on Windows. Save only after five seconds have elapsed with nothing being changed. --- facetracknoir/ui.cpp | 15 +++++++++++++-- facetracknoir/ui.h | 4 +++- 2 files changed, 16 insertions(+), 3 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 0876c848..6437b9d1 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -76,6 +76,9 @@ MainWindow::MainWindow() : connect(&pose_update_timer, SIGNAL(timeout()), this, SLOT(showHeadPose())); connect(&kbd_quit, SIGNAL(activated()), this, SLOT(exit())); + save_timer.setSingleShot(true); + connect(&save_timer, SIGNAL(timeout()), this, SLOT(_save())); + profile_menu.addAction("Create new empty config", this, SLOT(make_empty_config())); profile_menu.addAction("Create new copied config", this, SLOT(make_copied_config())); profile_menu.addAction("Open configuration directory", this, SLOT(open_config_directory())); @@ -116,10 +119,12 @@ bool MainWindow::get_new_config_name_from_dialog(QString& ret) MainWindow::~MainWindow() { + save_timer.stop(); + if (tray) tray->hide(); stopTracker(); - save(); + _save(); } void MainWindow::set_working_directory() @@ -131,7 +136,13 @@ void MainWindow::save_mappings() { pose.save_mappings(); } -void MainWindow::save() { +void MainWindow::save() +{ + save_timer.stop(); + save_timer.start(5000); +} + +void MainWindow::_save() { s.b->save(); save_mappings(); mem settings = group::ini_file(); diff --git a/facetracknoir/ui.h b/facetracknoir/ui.h index 65a7647a..cfaf47cb 100644 --- a/facetracknoir/ui.h +++ b/facetracknoir/ui.h @@ -51,6 +51,7 @@ class MainWindow : public QMainWindow, private State process_detector_worker det; QMenu profile_menu; bool is_refreshing_profiles; + QTimer save_timer; mem current_tracker() { @@ -72,10 +73,11 @@ class MainWindow : public QMainWindow, private State void display_pose(const double* mapped, const double* raw); void ensure_tray(); void set_title(const QString& game_title = QStringLiteral("")); - void save(); static bool get_new_config_name_from_dialog(QString &ret); void set_profile(const QString& profile); private slots: + void _save(); + void save(); void exit(); void profileSelected(QString name); -- cgit v1.2.3 From 66054ee6ccd0e86534c42167d9e93704f7995db8 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 3 Sep 2015 09:33:19 +0200 Subject: ui: force saving if saving timer is pending Force saving when tracking is stopping at least. Due to "struct work" being destroyed, unsaved settings revert to last saved. So before "struct work" destruction need to save if save is pending. Issue: #179 --- facetracknoir/ui.cpp | 13 ++++++++++++- facetracknoir/ui.h | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 6437b9d1..4d93f3b2 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -124,7 +124,7 @@ MainWindow::~MainWindow() if (tray) tray->hide(); stopTracker(); - _save(); + maybe_save(); } void MainWindow::set_working_directory() @@ -142,6 +142,15 @@ void MainWindow::save() save_timer.start(5000); } +void MainWindow::maybe_save() +{ + if (save_timer.isActive()) + { + save_timer.stop(); + _save(); + } +} + void MainWindow::_save() { s.b->save(); save_mappings(); @@ -307,6 +316,8 @@ void MainWindow::stopTracker( ) { if (pFilterDialog) pFilterDialog->unregister_filter(); + maybe_save(); + work = nullptr; libs = SelectedLibraries(); diff --git a/facetracknoir/ui.h b/facetracknoir/ui.h index cfaf47cb..91e4ebbf 100644 --- a/facetracknoir/ui.h +++ b/facetracknoir/ui.h @@ -75,6 +75,7 @@ class MainWindow : public QMainWindow, private State void set_title(const QString& game_title = QStringLiteral("")); static bool get_new_config_name_from_dialog(QString &ret); void set_profile(const QString& profile); + void maybe_save(); private slots: void _save(); void save(); -- cgit v1.2.3 From 3bce28ee28b3266c2a8cd871a3a891d477621ce2 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 3 Sep 2015 09:35:22 +0200 Subject: also save if save pending when start tracking Just to be safe. Issue: #179 --- facetracknoir/ui.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'facetracknoir') diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 4d93f3b2..984901f6 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -299,6 +299,8 @@ void MainWindow::startTracker() { // trackers take care of layout state updates const bool is_inertial = ui.video_frame->layout() == nullptr; updateButtonState(true, is_inertial); + + maybe_save(); } void MainWindow::stopTracker( ) { -- cgit v1.2.3 From a1783d425448394e6962f75f7aadd22b85318c59 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 5 Sep 2015 08:10:29 +0200 Subject: qfc, mapping: disallow editing and change color when checkbox disabled Sponsored-by: TrackHat --- facetracknoir/curve-config.cpp | 36 +++++++++++++++---------- qfunctionconfigurator/qfunctionconfigurator.cpp | 3 +++ qfunctionconfigurator/qfunctionconfigurator.h | 5 ++++ 3 files changed, 30 insertions(+), 14 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/curve-config.cpp b/facetracknoir/curve-config.cpp index e199d005..2e9065b4 100644 --- a/facetracknoir/curve-config.cpp +++ b/facetracknoir/curve-config.cpp @@ -20,23 +20,24 @@ MapWidget::MapWidget(Mappings& m, main_settings& s) : struct { QFunctionConfigurator* qfc; Axis axis; + QCheckBox* checkbox; bool altp; } qfcs[] = { - { ui.rxconfig, Yaw, false }, - { ui.ryconfig, Pitch, false}, - { ui.rzconfig, Roll, false }, - { ui.txconfig, TX, false }, - { ui.tyconfig, TY, false }, - { ui.tzconfig, TZ, false }, + { ui.rxconfig, Yaw, nullptr, false }, + { ui.ryconfig, Pitch, nullptr, false }, + { ui.rzconfig, Roll, nullptr, false }, + { ui.txconfig, TX, nullptr, false }, + { ui.tyconfig, TY, nullptr, false }, + { ui.tzconfig, TZ, nullptr, false }, - { ui.rxconfig_alt, Yaw, true }, - { ui.ryconfig_alt, Pitch, true}, - { ui.rzconfig_alt, Roll, true }, - { ui.txconfig_alt, TX, true }, - { ui.tyconfig_alt, TY, true }, - { ui.tzconfig_alt, TZ, true }, - { nullptr, Yaw, false } + { ui.rxconfig_alt, Yaw, ui.rx_altp, true }, + { ui.ryconfig_alt, Pitch, ui.ry_altp, true }, + { ui.rzconfig_alt, Roll, ui.rz_altp, true }, + { ui.txconfig_alt, TX, ui.tx_altp, true }, + { ui.tyconfig_alt, TY, ui.ty_altp, true }, + { ui.tzconfig_alt, TZ, ui.tz_altp, true }, + { nullptr, Yaw, nullptr, false } }; for (int i = 0; qfcs[i].qfc; i++) @@ -45,7 +46,14 @@ MapWidget::MapWidget(Mappings& m, main_settings& s) : Mapping& axis = m(qfcs[i].axis); Map* conf = altp ? &axis.curveAlt : &axis.curve; const auto& name = qfcs[i].altp ? axis.name2 : axis.name1; - + if (altp) + { + QFunctionConfigurator& qfc = *qfcs[i].qfc; + connect(qfcs[i].checkbox, &QCheckBox::toggled, + [&](bool f) -> void {qfc.setEnabled(f); qfc.force_redraw();}); + qfc.setEnabled(qfcs[i].checkbox->isChecked()); + qfc.force_redraw(); + } qfcs[i].qfc->setConfig(conf, name); } } diff --git a/qfunctionconfigurator/qfunctionconfigurator.cpp b/qfunctionconfigurator/qfunctionconfigurator.cpp index 144b69e1..8a61c8f6 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.cpp +++ b/qfunctionconfigurator/qfunctionconfigurator.cpp @@ -151,7 +151,10 @@ void QFunctionConfigurator::paintEvent(QPaintEvent *e) QPainter p(this); if (_background.isNull()) + { + _draw_function = true; drawBackground(); + } if (_draw_function) { _draw_function = false; diff --git a/qfunctionconfigurator/qfunctionconfigurator.h b/qfunctionconfigurator/qfunctionconfigurator.h index 59c8ffeb..845dd29c 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.h +++ b/qfunctionconfigurator/qfunctionconfigurator.h @@ -34,6 +34,11 @@ public: spline_color = color; update(); } + void force_redraw() + { + _background = QPixmap(); + update(); + } protected slots: void paintEvent(QPaintEvent *e); void mousePressEvent(QMouseEvent *e); -- cgit v1.2.3