From 0a0000a6c4ca5ebfffd33d70f7b7963473be1471 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 22 Oct 2017 11:10:34 +0200 Subject: gui: rename source files only --- gui/main-window.hpp | 4 +- gui/mapping-dialog.cpp | 206 +++++ gui/mapping-dialog.hpp | 35 + gui/mapping-dialog.ui | 547 +++++++++++ gui/mapping-window.cpp | 206 ----- gui/mapping-window.hpp | 35 - gui/mapping-window.ui | 547 ----------- gui/options-dialog.cpp | 241 ----- gui/options-dialog.hpp | 29 - gui/options-dialog.ui | 2390 ------------------------------------------------ gui/settings-dialog.ui | 2390 ++++++++++++++++++++++++++++++++++++++++++++++++ gui/settings.cpp | 241 +++++ gui/settings.hpp | 29 + 13 files changed, 3450 insertions(+), 3450 deletions(-) create mode 100644 gui/mapping-dialog.cpp create mode 100644 gui/mapping-dialog.hpp create mode 100644 gui/mapping-dialog.ui delete mode 100644 gui/mapping-window.cpp delete mode 100644 gui/mapping-window.hpp delete mode 100644 gui/mapping-window.ui delete mode 100644 gui/options-dialog.cpp delete mode 100644 gui/options-dialog.hpp delete mode 100644 gui/options-dialog.ui create mode 100644 gui/settings-dialog.ui create mode 100644 gui/settings.cpp create mode 100644 gui/settings.hpp diff --git a/gui/main-window.hpp b/gui/main-window.hpp index b41c1df9..f992b218 100644 --- a/gui/main-window.hpp +++ b/gui/main-window.hpp @@ -9,8 +9,8 @@ #pragma once #include "api/plugin-support.hpp" -#include "mapping-window.hpp" -#include "options-dialog.hpp" +#include "mapping-dialog.hpp" +#include "settings.hpp" #include "process_detector.h" #include "logic/main-settings.hpp" #include "logic/pipeline.hpp" diff --git a/gui/mapping-dialog.cpp b/gui/mapping-dialog.cpp new file mode 100644 index 00000000..607563a7 --- /dev/null +++ b/gui/mapping-dialog.cpp @@ -0,0 +1,206 @@ +/* Copyright (c) 2014-2015, Stanislaw Halik + + * Permission to use, copy, modify, and/or distribute this + * software for any purpose with or without fee is hereby granted, + * provided that the above copyright notice and this permission + * notice appear in all copies. + */ + +#include "mapping-dialog.hpp" +#include "logic/main-settings.hpp" +#include "spline/spline-widget.hpp" + +MapWidget::MapWidget(Mappings& m) : m(m), widgets{} +{ + ui.setupUi(this); + + QWidget* pages[] = { + ui.tabWidgetPage1, + ui.tabWidgetPage2, + ui.tabWidgetPage3, + ui.tabWidgetPage4, + ui.tabWidgetPage5, + ui.tabWidgetPage6, + }; + + { + QColor bg = palette().background().color(); + + QString tmp; + tmp.reserve(32); + + tmp += QStringLiteral(".QWidget { background-color: #"); + + for (int i : { bg.red(), bg.green(), bg.blue() }) + { + if (i < 0xf0) + tmp += '0'; + tmp += QString::number(i, 16); + } + + tmp += "; }"; + + for (QWidget* w : pages) + w->setStyleSheet(tmp); + } + + load(); + + connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); + connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); + + tie_setting(s.a_yaw.altp, ui.rx_altp); + tie_setting(s.a_pitch.altp, ui.ry_altp); + tie_setting(s.a_roll.altp, ui.rz_altp); + 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); + + tie_setting(s.a_yaw.clamp_x_, ui.max_yaw_rotation); + tie_setting(s.a_pitch.clamp_x_, ui.max_pitch_rotation); + tie_setting(s.a_roll.clamp_x_, ui.max_roll_rotation); + tie_setting(s.a_x.clamp_x_, ui.max_x_translation); + tie_setting(s.a_y.clamp_x_, ui.max_y_translation); + tie_setting(s.a_z.clamp_x_, ui.max_z_translation); + + tie_setting(s.a_pitch.clamp_y_, ui.max_pitch_output); +} + +void MapWidget::load() +{ + struct { + spline_widget* qfc; + Axis axis; + QCheckBox* checkbox; + bool altp; + } qfcs[] = + { + { 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, 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 } + }; + + ui.max_pitch_output->setItemData(0, int(axis_opts::o_r180)); + ui.max_pitch_output->setItemData(1, int(axis_opts::o_r90)); + + using a = axis_opts::max_clamp; + + for (QComboBox* x : { ui.max_yaw_rotation, ui.max_pitch_rotation, ui.max_roll_rotation }) + for (a y : { a::r180, a::r90, a::r60, a::r45, a::r30, a::r25, a::r20, a::r15, a::r10 }) + x->addItem(tr("%1°").arg(y), y); + + for (QComboBox* x : { ui.max_x_translation, ui.max_y_translation, ui.max_z_translation }) + for (a y : { a::t30, a::t20, a::t15, a::t10, a::t100 }) + x->addItem(QStringLiteral("%1 cm").arg(int(y)), y); + + // XXX TODO add tie_setting overload for spline_widget!!! -sh 20171020 + + for (int i = 0; qfcs[i].qfc; i++) + { + const bool altp = qfcs[i].altp; + + Map& axis = m(qfcs[i].axis); + spline& conf = altp ? axis.spline_alt : axis.spline_main; + spline_widget& qfc = *qfcs[i].qfc; + + if (altp) + { + connect(&axis.opts.altp, + base_value::signal_fun(), + this, + [&](bool f) -> void {qfc.setEnabled(f); qfc.force_redraw();}); + qfc.setEnabled(axis.opts.altp); + qfc.force_redraw(); + } + + connect(&axis.opts.clamp_x_, base_value::signal_fun(), + &qfc, [i, &conf, &qfc](int value) { + //qfc.reload_spline(); + qfc.set_x_step(value + 1e-2 >= 90 ? 10 : 5); + + if (i >= 3) + qfc.set_snap(1, 2.5); + else + { + const double x_snap = std::fmax(.5, conf.max_input() / 100.); + qfc.set_snap(x_snap, 1); + } + }); + + // force signal to avoid duplicating the slot's logic + qfc.setConfig(&conf); + axis.opts.clamp_x_.valueChanged(axis.opts.clamp_x_); + + widgets[i % 6][altp ? 1 : 0] = &qfc; + } +} + +void MapWidget::closeEvent(QCloseEvent*) +{ + invalidate_dialog(); +} + +void MapWidget::refresh_tab() +{ + if (!isVisible()) + return; + + const int idx = ui.tabWidget->currentIndex(); + + if (likely(idx >= 0 && idx < 6)) + { + widgets[idx][0]->repaint(); + widgets[idx][1]->repaint(); + } + else + qDebug() << "map-widget: bad index" << idx; +} + +void MapWidget::save_dialog() +{ + s.b_map->save(); + + for (int i = 0; i < 6; i++) + { + m.forall([&](Map& s) + { + s.spline_main.save(); + s.spline_alt.save(); + s.opts.b_mapping_window->save(); + }); + } +} + +void MapWidget::invalidate_dialog() +{ + s.b_map->reload(); + + m.forall([](Map& s) + { + s.spline_main.reload(); + s.spline_alt.reload(); + s.opts.b_mapping_window->reload(); + }); +} + +void MapWidget::doOK() +{ + save_dialog(); + close(); +} + +void MapWidget::doCancel() +{ + invalidate_dialog(); + close(); +} diff --git a/gui/mapping-dialog.hpp b/gui/mapping-dialog.hpp new file mode 100644 index 00000000..ba5d1867 --- /dev/null +++ b/gui/mapping-dialog.hpp @@ -0,0 +1,35 @@ +#pragma once + +#include "logic/mappings.hpp" +#include "ui_mapping-dialog.h" + +#include +#include +#include +#include +#include + +class MapWidget final : public QDialog +{ + Q_OBJECT +public: + MapWidget(Mappings& m); + void refresh_tab(); +private: + Ui::mapping_window ui; + Mappings& m; + main_settings s; + + spline_widget* widgets[6][2]; + + void closeEvent(QCloseEvent*) override; + + void load(); + + void save_dialog(); + void invalidate_dialog(); + +private slots: + void doOK(); + void doCancel(); +}; diff --git a/gui/mapping-dialog.ui b/gui/mapping-dialog.ui new file mode 100644 index 00000000..7db6f425 --- /dev/null +++ b/gui/mapping-dialog.ui @@ -0,0 +1,547 @@ + + + mapping_window + + + + 0 + 0 + 970 + 664 + + + + + 0 + 0 + + + + + 970 + 664 + + + + Mapping properties + + + + images/facetracknoir.pngimages/facetracknoir.png + + + Qt::LeftToRight + + + + + + QTabWidget::North + + + 0 + + + + Yaw + + + + + + + 0 + 0 + + + + QFrame::NoFrame + + + + + + + 0 + 0 + + + + Max input + + + + + + + + 0 + 0 + + + + + + + + + + + + 255 + 0 + 0 + + + + + + + + Asymmetric mapping below + + + + + + + + 255 + 0 + 0 + + + + + + + + + Pitch + + + + + + + 0 + 0 + + + + QFrame::NoFrame + + + + + + + 0 + 0 + + + + Max input + + + + + + + + 0 + 0 + + + + + + + + Max output + + + + + + + + 180° + + + + + 90° + + + + + + + + + + + + 0 + 255 + 0 + + + + + + + + Asymmetric mapping below + + + + + + + + 0 + 255 + 0 + + + + + + + + + Roll + + + + + + + 0 + 0 + + + + QFrame::NoFrame + + + + + + + 0 + 0 + + + + Max input + + + + + + + + 0 + 0 + + + + + + + + + + + + 0 + 0 + 255 + + + + + + + + Asymmetric mapping below + + + + + + + + 0 + 0 + 255 + + + + + + rzconfig + rz_altp + rzconfig_alt + frame_3 + + + + X + + + + + + + 0 + 0 + + + + QFrame::NoFrame + + + + + + + 0 + 0 + + + + Max input + + + + + + + + 0 + 0 + + + + + + + + + + + + 255 + 0 + 255 + + + + + + + + Asymmetric mapping below + + + + + + + + 255 + 0 + 255 + + + + + + + + + Y + + + + + + + 0 + 0 + + + + QFrame::NoFrame + + + + + + + 0 + 0 + + + + Max input + + + + + + + + 0 + 0 + + + + + + + + + + + + 255 + 255 + 0 + + + + + + + + Asymmetric mapping below + + + + + + + + 255 + 255 + 0 + + + + + + + + + Z + + + + + + + 0 + 0 + + + + QFrame::NoFrame + + + + + + + 0 + 0 + + + + Max input + + + + + + + + 0 + 0 + + + + + + + + + + + + 0 + 255 + 255 + + + + + + + + Asymmetric mapping below + + + + + + + + 0 + 255 + 255 + + + + + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + spline_widget + QWidget +
spline/spline-widget.hpp
+
+
+ + tabWidget + rx_altp + ry_altp + rz_altp + tx_altp + ty_altp + tz_altp + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + +
diff --git a/gui/mapping-window.cpp b/gui/mapping-window.cpp deleted file mode 100644 index 629bcd5b..00000000 --- a/gui/mapping-window.cpp +++ /dev/null @@ -1,206 +0,0 @@ -/* Copyright (c) 2014-2015, Stanislaw Halik - - * Permission to use, copy, modify, and/or distribute this - * software for any purpose with or without fee is hereby granted, - * provided that the above copyright notice and this permission - * notice appear in all copies. - */ - -#include "mapping-window.hpp" -#include "logic/main-settings.hpp" -#include "spline/spline-widget.hpp" - -MapWidget::MapWidget(Mappings& m) : m(m), widgets{} -{ - ui.setupUi(this); - - QWidget* pages[] = { - ui.tabWidgetPage1, - ui.tabWidgetPage2, - ui.tabWidgetPage3, - ui.tabWidgetPage4, - ui.tabWidgetPage5, - ui.tabWidgetPage6, - }; - - { - QColor bg = palette().background().color(); - - QString tmp; - tmp.reserve(32); - - tmp += QStringLiteral(".QWidget { background-color: #"); - - for (int i : { bg.red(), bg.green(), bg.blue() }) - { - if (i < 0xf0) - tmp += '0'; - tmp += QString::number(i, 16); - } - - tmp += "; }"; - - for (QWidget* w : pages) - w->setStyleSheet(tmp); - } - - load(); - - connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); - connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); - - tie_setting(s.a_yaw.altp, ui.rx_altp); - tie_setting(s.a_pitch.altp, ui.ry_altp); - tie_setting(s.a_roll.altp, ui.rz_altp); - 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); - - tie_setting(s.a_yaw.clamp_x_, ui.max_yaw_rotation); - tie_setting(s.a_pitch.clamp_x_, ui.max_pitch_rotation); - tie_setting(s.a_roll.clamp_x_, ui.max_roll_rotation); - tie_setting(s.a_x.clamp_x_, ui.max_x_translation); - tie_setting(s.a_y.clamp_x_, ui.max_y_translation); - tie_setting(s.a_z.clamp_x_, ui.max_z_translation); - - tie_setting(s.a_pitch.clamp_y_, ui.max_pitch_output); -} - -void MapWidget::load() -{ - struct { - spline_widget* qfc; - Axis axis; - QCheckBox* checkbox; - bool altp; - } qfcs[] = - { - { 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, 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 } - }; - - ui.max_pitch_output->setItemData(0, int(axis_opts::o_r180)); - ui.max_pitch_output->setItemData(1, int(axis_opts::o_r90)); - - using a = axis_opts::max_clamp; - - for (QComboBox* x : { ui.max_yaw_rotation, ui.max_pitch_rotation, ui.max_roll_rotation }) - for (a y : { a::r180, a::r90, a::r60, a::r45, a::r30, a::r25, a::r20, a::r15, a::r10 }) - x->addItem(tr("%1°").arg(y), y); - - for (QComboBox* x : { ui.max_x_translation, ui.max_y_translation, ui.max_z_translation }) - for (a y : { a::t30, a::t20, a::t15, a::t10, a::t100 }) - x->addItem(QStringLiteral("%1 cm").arg(int(y)), y); - - // XXX TODO add tie_setting overload for spline_widget!!! -sh 20171020 - - for (int i = 0; qfcs[i].qfc; i++) - { - const bool altp = qfcs[i].altp; - - Map& axis = m(qfcs[i].axis); - spline& conf = altp ? axis.spline_alt : axis.spline_main; - spline_widget& qfc = *qfcs[i].qfc; - - if (altp) - { - connect(&axis.opts.altp, - base_value::signal_fun(), - this, - [&](bool f) -> void {qfc.setEnabled(f); qfc.force_redraw();}); - qfc.setEnabled(axis.opts.altp); - qfc.force_redraw(); - } - - connect(&axis.opts.clamp_x_, base_value::signal_fun(), - &qfc, [i, &conf, &qfc](int value) { - //qfc.reload_spline(); - qfc.set_x_step(value + 1e-2 >= 90 ? 10 : 5); - - if (i >= 3) - qfc.set_snap(1, 2.5); - else - { - const double x_snap = std::fmax(.5, conf.max_input() / 100.); - qfc.set_snap(x_snap, 1); - } - }); - - // force signal to avoid duplicating the slot's logic - qfc.setConfig(&conf); - axis.opts.clamp_x_.valueChanged(axis.opts.clamp_x_); - - widgets[i % 6][altp ? 1 : 0] = &qfc; - } -} - -void MapWidget::closeEvent(QCloseEvent*) -{ - invalidate_dialog(); -} - -void MapWidget::refresh_tab() -{ - if (!isVisible()) - return; - - const int idx = ui.tabWidget->currentIndex(); - - if (likely(idx >= 0 && idx < 6)) - { - widgets[idx][0]->repaint(); - widgets[idx][1]->repaint(); - } - else - qDebug() << "map-widget: bad index" << idx; -} - -void MapWidget::save_dialog() -{ - s.b_map->save(); - - for (int i = 0; i < 6; i++) - { - m.forall([&](Map& s) - { - s.spline_main.save(); - s.spline_alt.save(); - s.opts.b_mapping_window->save(); - }); - } -} - -void MapWidget::invalidate_dialog() -{ - s.b_map->reload(); - - m.forall([](Map& s) - { - s.spline_main.reload(); - s.spline_alt.reload(); - s.opts.b_mapping_window->reload(); - }); -} - -void MapWidget::doOK() -{ - save_dialog(); - close(); -} - -void MapWidget::doCancel() -{ - invalidate_dialog(); - close(); -} diff --git a/gui/mapping-window.hpp b/gui/mapping-window.hpp deleted file mode 100644 index ab0da2cc..00000000 --- a/gui/mapping-window.hpp +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once - -#include "logic/mappings.hpp" -#include "ui_mapping-window.h" - -#include -#include -#include -#include -#include - -class MapWidget final : public QDialog -{ - Q_OBJECT -public: - MapWidget(Mappings& m); - void refresh_tab(); -private: - Ui::mapping_window ui; - Mappings& m; - main_settings s; - - spline_widget* widgets[6][2]; - - void closeEvent(QCloseEvent*) override; - - void load(); - - void save_dialog(); - void invalidate_dialog(); - -private slots: - void doOK(); - void doCancel(); -}; diff --git a/gui/mapping-window.ui b/gui/mapping-window.ui deleted file mode 100644 index 7db6f425..00000000 --- a/gui/mapping-window.ui +++ /dev/null @@ -1,547 +0,0 @@ - - - mapping_window - - - - 0 - 0 - 970 - 664 - - - - - 0 - 0 - - - - - 970 - 664 - - - - Mapping properties - - - - images/facetracknoir.pngimages/facetracknoir.png - - - Qt::LeftToRight - - - - - - QTabWidget::North - - - 0 - - - - Yaw - - - - - - - 0 - 0 - - - - QFrame::NoFrame - - - - - - - 0 - 0 - - - - Max input - - - - - - - - 0 - 0 - - - - - - - - - - - - 255 - 0 - 0 - - - - - - - - Asymmetric mapping below - - - - - - - - 255 - 0 - 0 - - - - - - - - - Pitch - - - - - - - 0 - 0 - - - - QFrame::NoFrame - - - - - - - 0 - 0 - - - - Max input - - - - - - - - 0 - 0 - - - - - - - - Max output - - - - - - - - 180° - - - - - 90° - - - - - - - - - - - - 0 - 255 - 0 - - - - - - - - Asymmetric mapping below - - - - - - - - 0 - 255 - 0 - - - - - - - - - Roll - - - - - - - 0 - 0 - - - - QFrame::NoFrame - - - - - - - 0 - 0 - - - - Max input - - - - - - - - 0 - 0 - - - - - - - - - - - - 0 - 0 - 255 - - - - - - - - Asymmetric mapping below - - - - - - - - 0 - 0 - 255 - - - - - - rzconfig - rz_altp - rzconfig_alt - frame_3 - - - - X - - - - - - - 0 - 0 - - - - QFrame::NoFrame - - - - - - - 0 - 0 - - - - Max input - - - - - - - - 0 - 0 - - - - - - - - - - - - 255 - 0 - 255 - - - - - - - - Asymmetric mapping below - - - - - - - - 255 - 0 - 255 - - - - - - - - - Y - - - - - - - 0 - 0 - - - - QFrame::NoFrame - - - - - - - 0 - 0 - - - - Max input - - - - - - - - 0 - 0 - - - - - - - - - - - - 255 - 255 - 0 - - - - - - - - Asymmetric mapping below - - - - - - - - 255 - 255 - 0 - - - - - - - - - Z - - - - - - - 0 - 0 - - - - QFrame::NoFrame - - - - - - - 0 - 0 - - - - Max input - - - - - - - - 0 - 0 - - - - - - - - - - - - 0 - 255 - 255 - - - - - - - - Asymmetric mapping below - - - - - - - - 0 - 255 - 255 - - - - - - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - spline_widget - QWidget -
spline/spline-widget.hpp
-
-
- - tabWidget - rx_altp - ry_altp - rz_altp - tx_altp - ty_altp - tz_altp - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - -
diff --git a/gui/options-dialog.cpp b/gui/options-dialog.cpp deleted file mode 100644 index c35a6b52..00000000 --- a/gui/options-dialog.cpp +++ /dev/null @@ -1,241 +0,0 @@ -/* Copyright (c) 2015, Stanislaw Halik - - * Permission to use, copy, modify, and/or distribute this - * software for any purpose with or without fee is hereby granted, - * provided that the above copyright notice and this permission - * notice appear in all copies. - */ - -#include "options-dialog.hpp" -#include "keyboard.h" -#include "opentrack-library-path.h" -#include -#include -#include -#include - -QString OptionsDialog::kopts_to_string(const key_opts& kopts) -{ - if (static_cast(kopts.guid) != "") - { - const int btn = kopts.button & ~Qt::KeyboardModifierMask; - const int mods = kopts.button & Qt::KeyboardModifierMask; - QString mm; - if (mods & Qt::ControlModifier) mm += "Control+"; - if (mods & Qt::AltModifier) mm += "Alt+"; - if (mods & Qt::ShiftModifier) mm += "Shift+"; - return mm + tr("Joy button %1").arg(QString::number(btn)); - } - if (static_cast(kopts.keycode) == "") - return tr("None"); - return kopts.keycode; -} - -void OptionsDialog::set_disable_translation_state(bool value) -{ - group::with_global_settings_object([&](QSettings& s) - { - s.setValue("disable-translation", value); - }); -} - -OptionsDialog::OptionsDialog(std::function pause_keybindings) : - pause_keybindings(pause_keybindings) -{ - ui.setupUi(this); - - connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); - connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); - - tie_setting(main.tray_enabled, ui.trayp); - tie_setting(main.tray_start, ui.tray_start); - - tie_setting(main.center_at_startup, ui.center_at_startup); - - tie_setting(main.tcomp_p, ui.tcomp_enable); - - tie_setting(main.tcomp_disable_tx, ui.tcomp_tx_disable); - tie_setting(main.tcomp_disable_ty, ui.tcomp_ty_disable); - tie_setting(main.tcomp_disable_tz, ui.tcomp_tz_disable); - - tie_setting(main.tcomp_disable_src_yaw, ui.tcomp_src_yaw_disable); - tie_setting(main.tcomp_disable_src_pitch, ui.tcomp_src_pitch_disable); - tie_setting(main.tcomp_disable_src_roll, ui.tcomp_src_roll_disable); - - tie_setting(main.neck_z, ui.neck_z); - - tie_setting(main.a_x.zero, ui.pos_tx); - tie_setting(main.a_y.zero, ui.pos_ty); - tie_setting(main.a_z.zero, ui.pos_tz); - tie_setting(main.a_yaw.zero, ui.pos_rx); - tie_setting(main.a_pitch.zero, ui.pos_ry); - tie_setting(main.a_roll.zero, ui.pos_rz); - - tie_setting(main.a_yaw.invert, ui.invert_yaw); - tie_setting(main.a_pitch.invert, ui.invert_pitch); - tie_setting(main.a_roll.invert, ui.invert_roll); - tie_setting(main.a_x.invert, ui.invert_x); - tie_setting(main.a_y.invert, ui.invert_y); - tie_setting(main.a_z.invert, ui.invert_z); - - tie_setting(main.a_yaw.src, ui.src_yaw); - tie_setting(main.a_pitch.src, ui.src_pitch); - tie_setting(main.a_roll.src, ui.src_roll); - tie_setting(main.a_x.src, ui.src_x); - tie_setting(main.a_y.src, ui.src_y); - tie_setting(main.a_z.src, ui.src_z); - - tie_setting(main.center_method, ui.center_method); - - tie_setting(main.tracklogging_enabled, ui.tracklogging_enabled); - - tie_setting(main.neck_enable, ui.neck_enable); - - const bool is_translation_disabled = group::with_global_settings_object([] (QSettings& s) { - return s.value("disable-translation", false).toBool(); - }); - ui.disable_translation->setChecked(is_translation_disabled); - - struct tmp - { - key_opts& opt; - QLabel* label; - QPushButton* button; - } tuples[] = - { - { main.key_center1, ui.center_text, ui.bind_center }, - { main.key_center2, ui.center_text_2, ui.bind_center_2 }, - - { main.key_toggle1, ui.toggle_text, ui.bind_toggle }, - { main.key_toggle2, ui.toggle_text_2, ui.bind_toggle_2 }, - - { main.key_toggle_press1, ui.toggle_held_text, ui.bind_toggle_held }, - { main.key_toggle_press2, ui.toggle_held_text_2, ui.bind_toggle_held_2 }, - - { main.key_zero1, ui.zero_text, ui.bind_zero }, - { main.key_zero2, ui.zero_text_2, ui.bind_zero_2 }, - - { main.key_zero_press1, ui.zero_held_text, ui.bind_zero_held }, - { main.key_zero_press2, ui.zero_held_text_2, ui.bind_zero_held_2 }, - - { main.key_start_tracking1, ui.start_tracking_text, ui.bind_start }, - { main.key_start_tracking2, ui.start_tracking_text_2, ui.bind_start_2 }, - - { main.key_stop_tracking1, ui.stop_tracking_text , ui.bind_stop }, - { main.key_stop_tracking2, ui.stop_tracking_text_2 , ui.bind_stop_2 }, - - { main.key_toggle_tracking1, ui.toggle_tracking_text, ui.bind_toggle_tracking }, - { main.key_toggle_tracking2, ui.toggle_tracking_text_2, ui.bind_toggle_tracking_2 }, - - { main.key_restart_tracking1, ui.restart_tracking_text, ui.bind_restart_tracking }, - { main.key_restart_tracking2, ui.restart_tracking_text_2, ui.bind_restart_tracking_2 }, - }; - - for (const tmp& val_ : tuples) - { - tmp val = val_; - val.label->setText(kopts_to_string(val.opt)); - connect(&val.opt.keycode, - static_cast(&base_value::valueChanged), - val.label, - [=](const QString&) -> void { val.label->setText(kopts_to_string(val.opt)); }); - { - connect(val.button, &QPushButton::clicked, this, [=]() -> void { bind_key(val.opt, val.label); }); - } - } -} - -void OptionsDialog::closeEvent(QCloseEvent *) -{ - done(result()); -} - -void OptionsDialog::bind_key(key_opts& kopts, QLabel* label) -{ - kopts.button = -1; - kopts.guid = ""; - kopts.keycode = ""; - auto k = new KeyboardListener; - k->setWindowModality(Qt::ApplicationModal); - k->deleteLater(); - - connect(k, - &KeyboardListener::key_pressed, - this, - [&](const QKeySequence& s) - { - kopts.keycode = s.toString(QKeySequence::PortableText); - kopts.guid = ""; - kopts.button = -1; - k->close(); - }); - connect(k, &KeyboardListener::joystick_button_pressed, - this, - [&](const QString& guid, int idx, bool held) - { - if (!held) - { - kopts.guid = guid; - kopts.keycode = ""; - kopts.button = idx; - k->close(); - } - }); - connect(main.b.get(), &options::detail::bundle::reloading, k, &QDialog::close); - pause_keybindings(true); - k->exec(); - pause_keybindings(false); - const bool is_crap = progn( - for (const QChar& c : kopts.keycode()) - if (!c.isPrint()) - return true; - return false; - ); - if (is_crap) - { - kopts.keycode = QStringLiteral(""); - kopts.guid = QStringLiteral(""); - kopts.button = -1; - label->setText(tr("None")); - } - else - label->setText(kopts_to_string(kopts)); -} - -void OptionsDialog::doOK() -{ - if (isHidden()) // close() can return true twice in a row it seems - return; - hide(); - if (!close()) // dialog was closed already - return; - - main.b->save(); - ui.game_detector->save(); - set_disable_translation_state(ui.disable_translation->isChecked()); - emit closing(); -} - -void OptionsDialog::doCancel() -{ - if (isHidden()) // close() can return true twice in a row it seems - return; - hide(); - if (!close()) // dialog was closed already - return; - - main.b->reload(); - ui.game_detector->revert(); - emit closing(); -} - -void OptionsDialog::done(int res) -{ - if (isVisible()) - { - if (res == QDialog::Accepted) - doOK(); - else - doCancel(); - } -} diff --git a/gui/options-dialog.hpp b/gui/options-dialog.hpp deleted file mode 100644 index dab919ed..00000000 --- a/gui/options-dialog.hpp +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - -#include "ui_options-dialog.h" -#include "logic/shortcuts.h" -#include -#include -#include -#include - -class OptionsDialog : public QDialog -{ - Q_OBJECT -signals: - void closing(); -public: - OptionsDialog(std::function pause_keybindings); -private: - main_settings main; - std::function pause_keybindings; - Ui::options_dialog ui; - void closeEvent(QCloseEvent *) override; - static QString kopts_to_string(const key_opts& opts); -private slots: - void doOK(); - void doCancel(); - void done(int res) override; - void bind_key(key_opts &kopts, QLabel* label); - void set_disable_translation_state(bool value); -}; diff --git a/gui/options-dialog.ui b/gui/options-dialog.ui deleted file mode 100644 index fe5b8864..00000000 --- a/gui/options-dialog.ui +++ /dev/null @@ -1,2390 +0,0 @@ - - - options_dialog - - - - 0 - 0 - 588 - 562 - - - - Options - - - - images/facetracknoir.pngimages/facetracknoir.png - - - Qt::LeftToRight - - - false - - - - 6 - - - - - - 0 - 0 - - - - 0 - - - false - - - - - 0 - 0 - - - - Shortcuts - - - - 6 - - - 6 - - - 0 - - - - - - 0 - 0 - - - - Global shortcuts - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - 3 - - - 6 - - - - - - 0 - 0 - - - - <html><head/><body><p><span style=" font-weight:600;">Center</span> - use current pose as looking perfectly forward.<br/><span style=" font-weight:600;">Toggle</span> - keep looking at same spot until next toggle keypress.<br/><span style=" font-weight:600;">Zero</span> - keep looking forward until next zero keypress.<br/></p></body></html> - - - true - - - - - - - QGroupBox { border: 0; } - - - - 9 - - - 2 - - - 20 - - - - - - 255 - 0 - - - - - 100 - 0 - - - - - - - - - - - - 0 - 0 - - - - Center - - - false - - - - - - - - 0 - 0 - - - - Bind - - - - - - - - 255 - 0 - - - - - 100 - 0 - - - - - - - - - - - - 0 - 0 - - - - Bind - - - - - - - - 0 - 0 - - - - Start tracking - - - false - - - - - - - - 0 - 0 - - - - Bind - - - - - - - - 255 - 0 - - - - - 100 - 0 - - - - - - - - - - - - 255 - 0 - - - - - 100 - 0 - - - - - - - - - - - - 0 - 0 - - - - Stop tracking - - - false - - - - - - - - 255 - 0 - - - - - 100 - 0 - - - - - - - - - - - - 0 - 0 - - - - Zero - - - false - - - - - - - - 0 - 0 - - - - Toggle - - - false - - - - - - - - 0 - 0 - - - - Zero while held - - - - - - - - 0 - 0 - - - - Bind - - - - - - - - 255 - 0 - - - - - 100 - 0 - - - - - - - - - - - - 255 - 0 - - - - - 100 - 0 - - - - - - - - - - - - 0 - 0 - - - - Bind - - - - - - - - 0 - 0 - - - - Bind - - - - - - - - 0 - 0 - - - - Restart tracking - - - false - - - - - - - - 255 - 0 - - - - - 100 - 0 - - - - - - - - - - - - 0 - 0 - - - - Toggle while held - - - - - - - - 0 - 0 - - - - Bind - - - - - - - - 0 - 0 - - - - Bind - - - - - - - - 0 - 0 - - - - Toggle tracking - - - false - - - - - - - - 0 - 0 - - - - Bind - - - - - - - - 0 - 0 - - - - Bind - - - - - - - - 255 - 0 - - - - - 100 - 0 - - - - - - - - - - - - 255 - 0 - - - - - 100 - 0 - - - - - - - - - - - - 255 - 0 - - - - - 100 - 0 - - - - - - - - - - - - 0 - 0 - - - - Bind - - - - - - - - 255 - 0 - - - - - 100 - 0 - - - - - - - - - - - - 0 - 0 - - - - Bind - - - - - - - - 0 - 0 - - - - Bind - - - - - - - - 0 - 0 - - - - Bind - - - - - - - - 255 - 0 - - - - - 100 - 0 - - - - - - - - - - - - 0 - 0 - - - - Bind - - - - - - - - 255 - 0 - - - - - 100 - 0 - - - - - - - - - - - - 255 - 0 - - - - - 100 - 0 - - - - - - - - - - - - 255 - 0 - - - - - 100 - 0 - - - - - - - - - - - - 0 - 0 - - - - Bind - - - - - - - - 255 - 0 - - - - - 100 - 0 - - - - - - - - - - - - 255 - 0 - - - - - 100 - 0 - - - - - - - - - - - - 0 - 0 - - - - Bind - - - - - - - - 0 - 0 - - - - Bind - - - - - - - - - - - - - QFrame::Raised - - - - 2 - - - 2 - - - - - - 0 - 0 - - - - Never translate the application interface - - - - - - - - 0 - 0 - - - - Center at startup - - - - - - - - - - :/images/english.png - - - - - - - - - - QFrame::NoFrame - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - - - 0 - 0 - - - - Minimize to tray - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - 0 - - - 2 - - - 6 - - - - - - 0 - 0 - - - - Enable tray - - - - - - - - 0 - 0 - - - - Minimize to tray on startup when enabled - - - - - - - - - - - - 0 - 0 - - - - Camera - - - - - - - 0 - 0 - - - - Custom center pose - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - Alter the centered position sent to games. - - - true - - - 2 - - - - - - - QGroupBox { - border: 0; -} - - - - - - Qt::AlignCenter - - - false - - - false - - - - - - - 0 - 0 - - - - ° - - - 2 - - - -180.000000000000000 - - - 180.000000000000000 - - - - - - - - 0 - 0 - - - - cm - - - 3 - - - -500.000000000000000 - - - 500.000000000000000 - - - - - - - X - - - - - - - - 0 - 0 - - - - cm - - - 3 - - - -500.000000000000000 - - - 500.000000000000000 - - - - - - - Pitch - - - - - - - Y - - - - - - - - 0 - 0 - - - - ° - - - 2 - - - -180.000000000000000 - - - 180.000000000000000 - - - - - - - Z - - - - - - - Roll - - - - - - - - 0 - 0 - - - - cm - - - 3 - - - -500.000000000000000 - - - 500.000000000000000 - - - - - - - Yaw - - - - - - - - 0 - 0 - - - - ° - - - 2 - - - -180.000000000000000 - - - 180.000000000000000 - - - - - - - - - - - - - - 0 - 0 - - - - Centering method - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - 4 - 0 - - - - Try changing this if centering doesn't perform correctly for your input device. - - - true - - - - - - - QFrame::NoFrame - - - QFrame::Raised - - - - 0 - - - 1 - - - 0 - - - 1 - - - 0 - - - - - Method - - - - - - - - 0 - 0 - - - - - Relative (inertial device) - - - - - Absolute (camera device) - - - - - - - - - - - - - - Qt::Vertical - - - QSizePolicy::Expanding - - - - 20 - 0 - - - - - - - - - - 0 - 0 - - - - Output - - - - - - - 0 - 0 - - - - - true - - - - Output remap - - - Qt::AlignHCenter|Qt::AlignTop - - - false - - - false - - - - QLayout::SetMinAndMaxSize - - - 4 - - - 0 - - - 6 - - - - - - 0 - 0 - - - - QGroupBox -{ - border: 0; -} - - - - 12 - - - 9 - - - - - - 255 - 0 - - - - - - - - - - - - 254 - 0 - - - - Roll - - - - - - - - 254 - 0 - - - - X - - - - - - - - 254 - 0 - - - - Invert - - - - - - - - 0 - 0 - - - - - X - - - - - Y - - - - - Z - - - - - Yaw - - - - - Pitch - - - - - Roll - - - - - Disabled - - - - - - - - - 254 - 0 - - - - Pitch - - - - - - - - 0 - 0 - - - - - X - - - - - Y - - - - - Z - - - - - Yaw - - - - - Pitch - - - - - Roll - - - - - Disabled - - - - - - - - - 0 - 0 - - - - - X - - - - - Y - - - - - Z - - - - - Yaw - - - - - Pitch - - - - - Roll - - - - - Disabled - - - - - - - - - 255 - 0 - - - - - - - - - - - - 254 - 0 - - - - Y - - - - - - - - 254 - 0 - - - - Destination - - - - - - - - 255 - 0 - - - - - - - - - - - - 254 - 0 - - - - Yaw - - - - - - - - 255 - 0 - - - - - - - - - - - - 254 - 0 - - - - Source - - - - - - - - 0 - 0 - - - - - X - - - - - Y - - - - - Z - - - - - Yaw - - - - - Pitch - - - - - Roll - - - - - Disabled - - - - - - - - - 255 - 0 - - - - - - - - - - - - 0 - 0 - - - - - X - - - - - Y - - - - - Z - - - - - Yaw - - - - - Pitch - - - - - Roll - - - - - Disabled - - - - - - - - - 254 - 0 - - - - Z - - - - - - - - 0 - 0 - - - - - X - - - - - Y - - - - - Z - - - - - Yaw - - - - - Pitch - - - - - Roll - - - - - Disabled - - - - - - - - - 255 - 0 - - - - - - - - - label_15 - label_13 - label_14 - src_yaw - invert_yaw - label_7 - src_pitch - label_8 - invert_pitch - label_9 - src_roll - invert_roll - label_10 - src_x - invert_x - label_11 - src_y - invert_y - label_12 - src_z - invert_z - - - - - - Assign input axis to output axis. - - - Qt::AlignJustify|Qt::AlignVCenter - - - true - - - - - - - - - - Qt::Vertical - - - QSizePolicy::Expanding - - - - 20 - 0 - - - - - - - - - 0 - 0 - - - - - 0 - 50 - - - - CSV Data Logging - - - - 11 - - - - - - 0 - 1 - - - - Enable - You will be asked for a filename whenever tracking starts - - - - - - - - - - - - 0 - 0 - - - - Relative translation - - - - - - - 0 - 0 - - - - - - - Relative translation - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - 0 - 0 - - - - With relative mode on, translation is applied after rotation. For example, rotating +180 degrees yaw and moving backwards results in moving forward as a result of that rotation. - - - Qt::AlignJustify|Qt::AlignVCenter - - - true - - - 2 - - - - - - - - - - Enable - - - - - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Raised - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 3 - 0 - - - - - - - Disable for X - - - - - - - - 3 - 0 - - - - - - - Disable for Y - - - - - - - - 3 - 0 - - - - - - - Disable for Z (for zoom on Z axis) - - - - - - - - 2 - 0 - - - - Disable effect by yaw - - - - - - - - 2 - 0 - - - - Disable effect by pitch - - - - - - - - 2 - 0 - - - - Disable effect by roll - - - - - - - - - - - - - - 0 - 0 - - - - Neck displacement - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - 7 - - - - - Eyes will be offset from the pivot of rotation, assumed to be the neck. It also works with relative translation disabled. - - - true - - - 0 - - - - - - - QFrame::NoFrame - - - - 0 - - - 9 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - - - Enable - - - - - - - - 4 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - cm - - - -100 - - - 100 - - - - - - - - 15 - 0 - - - - Forward from center of rotation - - - - - - - - - - - - - Qt::Vertical - - - QSizePolicy::Expanding - - - - 20 - 0 - - - - - - - - - - 0 - 0 - - - - Game detection - - - - - - - 0 - 0 - - - - Game detection - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - 0 - 0 - - - - Start tracking automatically when a game starts with selected profile, and stop when the game exits. - - - true - - - - - - - - 0 - 0 - - - - - - - - - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - process_detector - QWidget -
process_detector.h
-
-
- - tabWidget - bind_center - bind_toggle - bind_toggle_held - bind_zero - bind_zero_held - bind_start - bind_stop - bind_toggle_tracking - bind_restart_tracking - bind_center_2 - bind_toggle_2 - bind_toggle_held_2 - bind_zero_2 - bind_zero_held_2 - bind_start_2 - bind_stop_2 - bind_toggle_tracking_2 - bind_restart_tracking_2 - center_at_startup - disable_translation - trayp - tray_start - pos_rx - pos_ry - pos_rz - pos_tx - pos_ty - pos_tz - center_method - src_yaw - invert_yaw - src_pitch - invert_pitch - src_roll - invert_roll - src_x - invert_x - src_y - invert_y - src_z - invert_z - tracklogging_enabled - tcomp_enable - tcomp_tx_disable - tcomp_ty_disable - tcomp_tz_disable - tcomp_src_yaw_disable - tcomp_src_pitch_disable - tcomp_src_roll_disable - neck_enable - neck_z - - - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - -
diff --git a/gui/settings-dialog.ui b/gui/settings-dialog.ui new file mode 100644 index 00000000..fe5b8864 --- /dev/null +++ b/gui/settings-dialog.ui @@ -0,0 +1,2390 @@ + + + options_dialog + + + + 0 + 0 + 588 + 562 + + + + Options + + + + images/facetracknoir.pngimages/facetracknoir.png + + + Qt::LeftToRight + + + false + + + + 6 + + + + + + 0 + 0 + + + + 0 + + + false + + + + + 0 + 0 + + + + Shortcuts + + + + 6 + + + 6 + + + 0 + + + + + + 0 + 0 + + + + Global shortcuts + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + 3 + + + 6 + + + + + + 0 + 0 + + + + <html><head/><body><p><span style=" font-weight:600;">Center</span> - use current pose as looking perfectly forward.<br/><span style=" font-weight:600;">Toggle</span> - keep looking at same spot until next toggle keypress.<br/><span style=" font-weight:600;">Zero</span> - keep looking forward until next zero keypress.<br/></p></body></html> + + + true + + + + + + + QGroupBox { border: 0; } + + + + 9 + + + 2 + + + 20 + + + + + + 255 + 0 + + + + + 100 + 0 + + + + + + + + + + + + 0 + 0 + + + + Center + + + false + + + + + + + + 0 + 0 + + + + Bind + + + + + + + + 255 + 0 + + + + + 100 + 0 + + + + + + + + + + + + 0 + 0 + + + + Bind + + + + + + + + 0 + 0 + + + + Start tracking + + + false + + + + + + + + 0 + 0 + + + + Bind + + + + + + + + 255 + 0 + + + + + 100 + 0 + + + + + + + + + + + + 255 + 0 + + + + + 100 + 0 + + + + + + + + + + + + 0 + 0 + + + + Stop tracking + + + false + + + + + + + + 255 + 0 + + + + + 100 + 0 + + + + + + + + + + + + 0 + 0 + + + + Zero + + + false + + + + + + + + 0 + 0 + + + + Toggle + + + false + + + + + + + + 0 + 0 + + + + Zero while held + + + + + + + + 0 + 0 + + + + Bind + + + + + + + + 255 + 0 + + + + + 100 + 0 + + + + + + + + + + + + 255 + 0 + + + + + 100 + 0 + + + + + + + + + + + + 0 + 0 + + + + Bind + + + + + + + + 0 + 0 + + + + Bind + + + + + + + + 0 + 0 + + + + Restart tracking + + + false + + + + + + + + 255 + 0 + + + + + 100 + 0 + + + + + + + + + + + + 0 + 0 + + + + Toggle while held + + + + + + + + 0 + 0 + + + + Bind + + + + + + + + 0 + 0 + + + + Bind + + + + + + + + 0 + 0 + + + + Toggle tracking + + + false + + + + + + + + 0 + 0 + + + + Bind + + + + + + + + 0 + 0 + + + + Bind + + + + + + + + 255 + 0 + + + + + 100 + 0 + + + + + + + + + + + + 255 + 0 + + + + + 100 + 0 + + + + + + + + + + + + 255 + 0 + + + + + 100 + 0 + + + + + + + + + + + + 0 + 0 + + + + Bind + + + + + + + + 255 + 0 + + + + + 100 + 0 + + + + + + + + + + + + 0 + 0 + + + + Bind + + + + + + + + 0 + 0 + + + + Bind + + + + + + + + 0 + 0 + + + + Bind + + + + + + + + 255 + 0 + + + + + 100 + 0 + + + + + + + + + + + + 0 + 0 + + + + Bind + + + + + + + + 255 + 0 + + + + + 100 + 0 + + + + + + + + + + + + 255 + 0 + + + + + 100 + 0 + + + + + + + + + + + + 255 + 0 + + + + + 100 + 0 + + + + + + + + + + + + 0 + 0 + + + + Bind + + + + + + + + 255 + 0 + + + + + 100 + 0 + + + + + + + + + + + + 255 + 0 + + + + + 100 + 0 + + + + + + + + + + + + 0 + 0 + + + + Bind + + + + + + + + 0 + 0 + + + + Bind + + + + + + + + + + + + + QFrame::Raised + + + + 2 + + + 2 + + + + + + 0 + 0 + + + + Never translate the application interface + + + + + + + + 0 + 0 + + + + Center at startup + + + + + + + + + + :/images/english.png + + + + + + + + + + QFrame::NoFrame + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + 0 + 0 + + + + Minimize to tray + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + 0 + + + 2 + + + 6 + + + + + + 0 + 0 + + + + Enable tray + + + + + + + + 0 + 0 + + + + Minimize to tray on startup when enabled + + + + + + + + + + + + 0 + 0 + + + + Camera + + + + + + + 0 + 0 + + + + Custom center pose + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + Alter the centered position sent to games. + + + true + + + 2 + + + + + + + QGroupBox { + border: 0; +} + + + + + + Qt::AlignCenter + + + false + + + false + + + + + + + 0 + 0 + + + + ° + + + 2 + + + -180.000000000000000 + + + 180.000000000000000 + + + + + + + + 0 + 0 + + + + cm + + + 3 + + + -500.000000000000000 + + + 500.000000000000000 + + + + + + + X + + + + + + + + 0 + 0 + + + + cm + + + 3 + + + -500.000000000000000 + + + 500.000000000000000 + + + + + + + Pitch + + + + + + + Y + + + + + + + + 0 + 0 + + + + ° + + + 2 + + + -180.000000000000000 + + + 180.000000000000000 + + + + + + + Z + + + + + + + Roll + + + + + + + + 0 + 0 + + + + cm + + + 3 + + + -500.000000000000000 + + + 500.000000000000000 + + + + + + + Yaw + + + + + + + + 0 + 0 + + + + ° + + + 2 + + + -180.000000000000000 + + + 180.000000000000000 + + + + + + + + + + + + + + 0 + 0 + + + + Centering method + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + 4 + 0 + + + + Try changing this if centering doesn't perform correctly for your input device. + + + true + + + + + + + QFrame::NoFrame + + + QFrame::Raised + + + + 0 + + + 1 + + + 0 + + + 1 + + + 0 + + + + + Method + + + + + + + + 0 + 0 + + + + + Relative (inertial device) + + + + + Absolute (camera device) + + + + + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Expanding + + + + 20 + 0 + + + + + + + + + + 0 + 0 + + + + Output + + + + + + + 0 + 0 + + + + + true + + + + Output remap + + + Qt::AlignHCenter|Qt::AlignTop + + + false + + + false + + + + QLayout::SetMinAndMaxSize + + + 4 + + + 0 + + + 6 + + + + + + 0 + 0 + + + + QGroupBox +{ + border: 0; +} + + + + 12 + + + 9 + + + + + + 255 + 0 + + + + + + + + + + + + 254 + 0 + + + + Roll + + + + + + + + 254 + 0 + + + + X + + + + + + + + 254 + 0 + + + + Invert + + + + + + + + 0 + 0 + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + Disabled + + + + + + + + + 254 + 0 + + + + Pitch + + + + + + + + 0 + 0 + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + Disabled + + + + + + + + + 0 + 0 + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + Disabled + + + + + + + + + 255 + 0 + + + + + + + + + + + + 254 + 0 + + + + Y + + + + + + + + 254 + 0 + + + + Destination + + + + + + + + 255 + 0 + + + + + + + + + + + + 254 + 0 + + + + Yaw + + + + + + + + 255 + 0 + + + + + + + + + + + + 254 + 0 + + + + Source + + + + + + + + 0 + 0 + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + Disabled + + + + + + + + + 255 + 0 + + + + + + + + + + + + 0 + 0 + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + Disabled + + + + + + + + + 254 + 0 + + + + Z + + + + + + + + 0 + 0 + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + Disabled + + + + + + + + + 255 + 0 + + + + + + + + + label_15 + label_13 + label_14 + src_yaw + invert_yaw + label_7 + src_pitch + label_8 + invert_pitch + label_9 + src_roll + invert_roll + label_10 + src_x + invert_x + label_11 + src_y + invert_y + label_12 + src_z + invert_z + + + + + + Assign input axis to output axis. + + + Qt::AlignJustify|Qt::AlignVCenter + + + true + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Expanding + + + + 20 + 0 + + + + + + + + + 0 + 0 + + + + + 0 + 50 + + + + CSV Data Logging + + + + 11 + + + + + + 0 + 1 + + + + Enable - You will be asked for a filename whenever tracking starts + + + + + + + + + + + + 0 + 0 + + + + Relative translation + + + + + + + 0 + 0 + + + + + + + Relative translation + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + 0 + 0 + + + + With relative mode on, translation is applied after rotation. For example, rotating +180 degrees yaw and moving backwards results in moving forward as a result of that rotation. + + + Qt::AlignJustify|Qt::AlignVCenter + + + true + + + 2 + + + + + + + + + + Enable + + + + + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Raised + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 3 + 0 + + + + + + + Disable for X + + + + + + + + 3 + 0 + + + + + + + Disable for Y + + + + + + + + 3 + 0 + + + + + + + Disable for Z (for zoom on Z axis) + + + + + + + + 2 + 0 + + + + Disable effect by yaw + + + + + + + + 2 + 0 + + + + Disable effect by pitch + + + + + + + + 2 + 0 + + + + Disable effect by roll + + + + + + + + + + + + + + 0 + 0 + + + + Neck displacement + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + 7 + + + + + Eyes will be offset from the pivot of rotation, assumed to be the neck. It also works with relative translation disabled. + + + true + + + 0 + + + + + + + QFrame::NoFrame + + + + 0 + + + 9 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + + + Enable + + + + + + + + 4 + 0 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + cm + + + -100 + + + 100 + + + + + + + + 15 + 0 + + + + Forward from center of rotation + + + + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Expanding + + + + 20 + 0 + + + + + + + + + + 0 + 0 + + + + Game detection + + + + + + + 0 + 0 + + + + Game detection + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + 0 + 0 + + + + Start tracking automatically when a game starts with selected profile, and stop when the game exits. + + + true + + + + + + + + 0 + 0 + + + + + + + + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + process_detector + QWidget +
process_detector.h
+
+
+ + tabWidget + bind_center + bind_toggle + bind_toggle_held + bind_zero + bind_zero_held + bind_start + bind_stop + bind_toggle_tracking + bind_restart_tracking + bind_center_2 + bind_toggle_2 + bind_toggle_held_2 + bind_zero_2 + bind_zero_held_2 + bind_start_2 + bind_stop_2 + bind_toggle_tracking_2 + bind_restart_tracking_2 + center_at_startup + disable_translation + trayp + tray_start + pos_rx + pos_ry + pos_rz + pos_tx + pos_ty + pos_tz + center_method + src_yaw + invert_yaw + src_pitch + invert_pitch + src_roll + invert_roll + src_x + invert_x + src_y + invert_y + src_z + invert_z + tracklogging_enabled + tcomp_enable + tcomp_tx_disable + tcomp_ty_disable + tcomp_tz_disable + tcomp_src_yaw_disable + tcomp_src_pitch_disable + tcomp_src_roll_disable + neck_enable + neck_z + + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + +
diff --git a/gui/settings.cpp b/gui/settings.cpp new file mode 100644 index 00000000..3105bad9 --- /dev/null +++ b/gui/settings.cpp @@ -0,0 +1,241 @@ +/* Copyright (c) 2015, Stanislaw Halik + + * Permission to use, copy, modify, and/or distribute this + * software for any purpose with or without fee is hereby granted, + * provided that the above copyright notice and this permission + * notice appear in all copies. + */ + +#include "settings.hpp" +#include "keyboard.h" +#include "opentrack-library-path.h" +#include +#include +#include +#include + +QString OptionsDialog::kopts_to_string(const key_opts& kopts) +{ + if (static_cast(kopts.guid) != "") + { + const int btn = kopts.button & ~Qt::KeyboardModifierMask; + const int mods = kopts.button & Qt::KeyboardModifierMask; + QString mm; + if (mods & Qt::ControlModifier) mm += "Control+"; + if (mods & Qt::AltModifier) mm += "Alt+"; + if (mods & Qt::ShiftModifier) mm += "Shift+"; + return mm + tr("Joy button %1").arg(QString::number(btn)); + } + if (static_cast(kopts.keycode) == "") + return tr("None"); + return kopts.keycode; +} + +void OptionsDialog::set_disable_translation_state(bool value) +{ + group::with_global_settings_object([&](QSettings& s) + { + s.setValue("disable-translation", value); + }); +} + +OptionsDialog::OptionsDialog(std::function pause_keybindings) : + pause_keybindings(pause_keybindings) +{ + ui.setupUi(this); + + connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); + connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); + + tie_setting(main.tray_enabled, ui.trayp); + tie_setting(main.tray_start, ui.tray_start); + + tie_setting(main.center_at_startup, ui.center_at_startup); + + tie_setting(main.tcomp_p, ui.tcomp_enable); + + tie_setting(main.tcomp_disable_tx, ui.tcomp_tx_disable); + tie_setting(main.tcomp_disable_ty, ui.tcomp_ty_disable); + tie_setting(main.tcomp_disable_tz, ui.tcomp_tz_disable); + + tie_setting(main.tcomp_disable_src_yaw, ui.tcomp_src_yaw_disable); + tie_setting(main.tcomp_disable_src_pitch, ui.tcomp_src_pitch_disable); + tie_setting(main.tcomp_disable_src_roll, ui.tcomp_src_roll_disable); + + tie_setting(main.neck_z, ui.neck_z); + + tie_setting(main.a_x.zero, ui.pos_tx); + tie_setting(main.a_y.zero, ui.pos_ty); + tie_setting(main.a_z.zero, ui.pos_tz); + tie_setting(main.a_yaw.zero, ui.pos_rx); + tie_setting(main.a_pitch.zero, ui.pos_ry); + tie_setting(main.a_roll.zero, ui.pos_rz); + + tie_setting(main.a_yaw.invert, ui.invert_yaw); + tie_setting(main.a_pitch.invert, ui.invert_pitch); + tie_setting(main.a_roll.invert, ui.invert_roll); + tie_setting(main.a_x.invert, ui.invert_x); + tie_setting(main.a_y.invert, ui.invert_y); + tie_setting(main.a_z.invert, ui.invert_z); + + tie_setting(main.a_yaw.src, ui.src_yaw); + tie_setting(main.a_pitch.src, ui.src_pitch); + tie_setting(main.a_roll.src, ui.src_roll); + tie_setting(main.a_x.src, ui.src_x); + tie_setting(main.a_y.src, ui.src_y); + tie_setting(main.a_z.src, ui.src_z); + + tie_setting(main.center_method, ui.center_method); + + tie_setting(main.tracklogging_enabled, ui.tracklogging_enabled); + + tie_setting(main.neck_enable, ui.neck_enable); + + const bool is_translation_disabled = group::with_global_settings_object([] (QSettings& s) { + return s.value("disable-translation", false).toBool(); + }); + ui.disable_translation->setChecked(is_translation_disabled); + + struct tmp + { + key_opts& opt; + QLabel* label; + QPushButton* button; + } tuples[] = + { + { main.key_center1, ui.center_text, ui.bind_center }, + { main.key_center2, ui.center_text_2, ui.bind_center_2 }, + + { main.key_toggle1, ui.toggle_text, ui.bind_toggle }, + { main.key_toggle2, ui.toggle_text_2, ui.bind_toggle_2 }, + + { main.key_toggle_press1, ui.toggle_held_text, ui.bind_toggle_held }, + { main.key_toggle_press2, ui.toggle_held_text_2, ui.bind_toggle_held_2 }, + + { main.key_zero1, ui.zero_text, ui.bind_zero }, + { main.key_zero2, ui.zero_text_2, ui.bind_zero_2 }, + + { main.key_zero_press1, ui.zero_held_text, ui.bind_zero_held }, + { main.key_zero_press2, ui.zero_held_text_2, ui.bind_zero_held_2 }, + + { main.key_start_tracking1, ui.start_tracking_text, ui.bind_start }, + { main.key_start_tracking2, ui.start_tracking_text_2, ui.bind_start_2 }, + + { main.key_stop_tracking1, ui.stop_tracking_text , ui.bind_stop }, + { main.key_stop_tracking2, ui.stop_tracking_text_2 , ui.bind_stop_2 }, + + { main.key_toggle_tracking1, ui.toggle_tracking_text, ui.bind_toggle_tracking }, + { main.key_toggle_tracking2, ui.toggle_tracking_text_2, ui.bind_toggle_tracking_2 }, + + { main.key_restart_tracking1, ui.restart_tracking_text, ui.bind_restart_tracking }, + { main.key_restart_tracking2, ui.restart_tracking_text_2, ui.bind_restart_tracking_2 }, + }; + + for (const tmp& val_ : tuples) + { + tmp val = val_; + val.label->setText(kopts_to_string(val.opt)); + connect(&val.opt.keycode, + static_cast(&base_value::valueChanged), + val.label, + [=](const QString&) -> void { val.label->setText(kopts_to_string(val.opt)); }); + { + connect(val.button, &QPushButton::clicked, this, [=]() -> void { bind_key(val.opt, val.label); }); + } + } +} + +void OptionsDialog::closeEvent(QCloseEvent *) +{ + done(result()); +} + +void OptionsDialog::bind_key(key_opts& kopts, QLabel* label) +{ + kopts.button = -1; + kopts.guid = ""; + kopts.keycode = ""; + auto k = new KeyboardListener; + k->setWindowModality(Qt::ApplicationModal); + k->deleteLater(); + + connect(k, + &KeyboardListener::key_pressed, + this, + [&](const QKeySequence& s) + { + kopts.keycode = s.toString(QKeySequence::PortableText); + kopts.guid = ""; + kopts.button = -1; + k->close(); + }); + connect(k, &KeyboardListener::joystick_button_pressed, + this, + [&](const QString& guid, int idx, bool held) + { + if (!held) + { + kopts.guid = guid; + kopts.keycode = ""; + kopts.button = idx; + k->close(); + } + }); + connect(main.b.get(), &options::detail::bundle::reloading, k, &QDialog::close); + pause_keybindings(true); + k->exec(); + pause_keybindings(false); + const bool is_crap = progn( + for (const QChar& c : kopts.keycode()) + if (!c.isPrint()) + return true; + return false; + ); + if (is_crap) + { + kopts.keycode = QStringLiteral(""); + kopts.guid = QStringLiteral(""); + kopts.button = -1; + label->setText(tr("None")); + } + else + label->setText(kopts_to_string(kopts)); +} + +void OptionsDialog::doOK() +{ + if (isHidden()) // close() can return true twice in a row it seems + return; + hide(); + if (!close()) // dialog was closed already + return; + + main.b->save(); + ui.game_detector->save(); + set_disable_translation_state(ui.disable_translation->isChecked()); + emit closing(); +} + +void OptionsDialog::doCancel() +{ + if (isHidden()) // close() can return true twice in a row it seems + return; + hide(); + if (!close()) // dialog was closed already + return; + + main.b->reload(); + ui.game_detector->revert(); + emit closing(); +} + +void OptionsDialog::done(int res) +{ + if (isVisible()) + { + if (res == QDialog::Accepted) + doOK(); + else + doCancel(); + } +} diff --git a/gui/settings.hpp b/gui/settings.hpp new file mode 100644 index 00000000..67c0ee54 --- /dev/null +++ b/gui/settings.hpp @@ -0,0 +1,29 @@ +#pragma once + +#include "ui_settings-dialog.h" +#include "logic/shortcuts.h" +#include +#include +#include +#include + +class OptionsDialog : public QDialog +{ + Q_OBJECT +signals: + void closing(); +public: + OptionsDialog(std::function pause_keybindings); +private: + main_settings main; + std::function pause_keybindings; + Ui::options_dialog ui; + void closeEvent(QCloseEvent *) override; + static QString kopts_to_string(const key_opts& opts); +private slots: + void doOK(); + void doCancel(); + void done(int res) override; + void bind_key(key_opts &kopts, QLabel* label); + void set_disable_translation_state(bool value); +}; -- cgit v1.2.3