diff options
-rw-r--r-- | facetracknoir/ui.cpp | 22 | ||||
-rw-r--r-- | facetracknoir/ui.h | 7 | ||||
-rw-r--r-- | opentrack/keyboard.ui | 335 | ||||
-rw-r--r-- | opentrack/main-settings.hpp | 2 | ||||
-rw-r--r-- | opentrack/shortcuts.cpp | 2 | ||||
-rw-r--r-- | opentrack/shortcuts.h | 7 |
6 files changed, 210 insertions, 165 deletions
diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index edd3a818..44eff98e 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -81,11 +81,13 @@ MainWindow::MainWindow() : ensure_tray(); if (s.tray_enabled) - hide(); + setWindowState(Qt::WindowMinimized); } MainWindow::~MainWindow() { + if (tray) + tray->hide(); stopTracker(); save(); _exit(0); @@ -413,12 +415,28 @@ void MainWindow::shortcutToggled() void MainWindow::ensure_tray() { + if (tray) + tray->hide(); tray = nullptr; if (s.tray_enabled) { tray = std::make_shared<QSystemTrayIcon>(this); tray->setIcon(QIcon(":/images/facetracknoir.png")); tray->show(); - connect(tray.get(), SIGNAL(activated()), this, SLOT(show())); + connect(tray.get(), SIGNAL(activated(QSystemTrayIcon::ActivationReason)), + this, SLOT(restore_from_tray(QSystemTrayIcon::ActivationReason))); } } + +void MainWindow::restore_from_tray(QSystemTrayIcon::ActivationReason) +{ + show(); + setWindowState(Qt::WindowNoState); +} + +void MainWindow::changeEvent(QEvent* e) +{ + if (e->type() == QEvent::WindowStateChange && (windowState() & Qt::WindowMinimized)) + hide(); + QMainWindow::changeEvent(e); +} diff --git a/facetracknoir/ui.h b/facetracknoir/ui.h index 9419936f..4158e29e 100644 --- a/facetracknoir/ui.h +++ b/facetracknoir/ui.h @@ -44,7 +44,7 @@ # include <windows.h> #endif -#include "ui_facetracknoir.h" +#include "ui_main.h" #include "opentrack/options.hpp" #include "opentrack/main-settings.hpp" @@ -85,13 +85,14 @@ class MainWindow : public QMainWindow, private State return modules.filters().value(ui.iconcomboFilter->currentIndex(), nullptr); } + 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(); - public slots: void shortcutRecentered(); void shortcutToggled(); @@ -112,6 +113,8 @@ private slots: void startTracker(); void stopTracker(); + + void restore_from_tray(QSystemTrayIcon::ActivationReason); public: MainWindow(); ~MainWindow(); diff --git a/opentrack/keyboard.ui b/opentrack/keyboard.ui index f576d8fb..321992e2 100644 --- a/opentrack/keyboard.ui +++ b/opentrack/keyboard.ui @@ -7,7 +7,7 @@ <x>0</x> <y>0</y> <width>415</width> - <height>143</height> + <height>332</height> </rect> </property> <property name="sizePolicy"> @@ -29,175 +29,194 @@ <property name="autoFillBackground"> <bool>false</bool> </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="2" column="0"> - <widget class="QLabel" name="textLabel2_5"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Toggle</string> - </property> - <property name="wordWrap"> - <bool>false</bool> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="textLabel2_3"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Center</string> - </property> - <property name="wordWrap"> - <bool>false</bool> - </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QFrame" name="frame"> + <property name="frameShape"> + <enum>QFrame::StyledPanel</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Plain</enum> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="4"> + <widget class="QLabel" name="textLabel2_4"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Keyboard</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="textLabel2_3"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Center</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QCheckBox" name="chkCenterShift"> + <property name="maximumSize"> + <size> + <width>50</width> + <height>16777215</height> + </size> + </property> + <property name="text"> + <string>Shift</string> + </property> + </widget> + </item> + <item row="1" column="2"> + <widget class="QCheckBox" name="chkCenterCtrl"> + <property name="maximumSize"> + <size> + <width>50</width> + <height>16777215</height> + </size> + </property> + <property name="text"> + <string>Ctrl</string> + </property> + </widget> + </item> + <item row="1" column="3"> + <widget class="QCheckBox" name="chkCenterAlt"> + <property name="maximumSize"> + <size> + <width>50</width> + <height>16777215</height> + </size> + </property> + <property name="text"> + <string>Alt</string> + </property> + </widget> + </item> + <item row="1" column="4"> + <widget class="QComboBox" name="cbxCenterKey"> + <property name="minimumSize"> + <size> + <width>90</width> + <height>0</height> + </size> + </property> + <property name="toolTip"> + <string>Select Number</string> + </property> + <property name="insertPolicy"> + <enum>QComboBox::InsertAlphabetically</enum> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="textLabel2_5"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Toggle</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QCheckBox" name="chkToggleShift"> + <property name="maximumSize"> + <size> + <width>50</width> + <height>16777215</height> + </size> + </property> + <property name="text"> + <string>Shift</string> + </property> + </widget> + </item> + <item row="2" column="2"> + <widget class="QCheckBox" name="chkToggleCtrl"> + <property name="maximumSize"> + <size> + <width>50</width> + <height>16777215</height> + </size> + </property> + <property name="text"> + <string>Ctrl</string> + </property> + </widget> + </item> + <item row="2" column="3"> + <widget class="QCheckBox" name="chkToggleAlt"> + <property name="maximumSize"> + <size> + <width>50</width> + <height>16777215</height> + </size> + </property> + <property name="text"> + <string>Alt</string> + </property> + </widget> + </item> + <item row="2" column="4"> + <widget class="QComboBox" name="cbxToggleKey"> + <property name="minimumSize"> + <size> + <width>90</width> + <height>0</height> + </size> + </property> + <property name="toolTip"> + <string>Select Number</string> + </property> + <property name="insertPolicy"> + <enum>QComboBox::InsertAlphabetically</enum> + </property> + </widget> + </item> + </layout> </widget> </item> - <item row="2" column="1"> - <widget class="QCheckBox" name="chkToggleShift"> - <property name="maximumSize"> - <size> - <width>50</width> - <height>16777215</height> - </size> - </property> + <item> + <widget class="QCheckBox" name="trayp"> <property name="text"> - <string>Shift</string> + <string>Start in tray, minimize to tray</string> </property> </widget> </item> - <item row="2" column="4"> - <widget class="QComboBox" name="cbxToggleKey"> - <property name="minimumSize"> - <size> - <width>90</width> - <height>0</height> - </size> - </property> - <property name="toolTip"> - <string>Select Number</string> - </property> - <property name="insertPolicy"> - <enum>QComboBox::InsertAlphabetically</enum> - </property> - </widget> - </item> - <item row="1" column="3"> - <widget class="QCheckBox" name="chkCenterAlt"> - <property name="maximumSize"> - <size> - <width>50</width> - <height>16777215</height> - </size> - </property> - <property name="text"> - <string>Alt</string> - </property> - </widget> - </item> - <item row="2" column="2"> - <widget class="QCheckBox" name="chkToggleCtrl"> - <property name="maximumSize"> - <size> - <width>50</width> - <height>16777215</height> - </size> - </property> - <property name="text"> - <string>Ctrl</string> - </property> - </widget> - </item> - <item row="0" column="4"> - <widget class="QLabel" name="textLabel2_4"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Keyboard</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <property name="wordWrap"> - <bool>false</bool> - </property> - </widget> - </item> - <item row="2" column="3"> - <widget class="QCheckBox" name="chkToggleAlt"> - <property name="maximumSize"> - <size> - <width>50</width> - <height>16777215</height> - </size> - </property> - <property name="text"> - <string>Alt</string> - </property> - </widget> - </item> - <item row="3" column="3" colspan="2"> + <item> <widget class="QDialogButtonBox" name="buttonBox"> <property name="standardButtons"> <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> </property> </widget> </item> - <item row="1" column="2"> - <widget class="QCheckBox" name="chkCenterCtrl"> - <property name="maximumSize"> - <size> - <width>50</width> - <height>16777215</height> - </size> - </property> - <property name="text"> - <string>Ctrl</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QCheckBox" name="chkCenterShift"> - <property name="maximumSize"> - <size> - <width>50</width> - <height>16777215</height> - </size> - </property> - <property name="text"> - <string>Shift</string> - </property> - </widget> - </item> - <item row="1" column="4"> - <widget class="QComboBox" name="cbxCenterKey"> - <property name="minimumSize"> - <size> - <width>90</width> - <height>0</height> - </size> - </property> - <property name="toolTip"> - <string>Select Number</string> - </property> - <property name="insertPolicy"> - <enum>QComboBox::InsertAlphabetically</enum> - </property> - </widget> - </item> </layout> </widget> <resources/> diff --git a/opentrack/main-settings.hpp b/opentrack/main-settings.hpp index 83ec8968..4f1eff31 100644 --- a/opentrack/main-settings.hpp +++ b/opentrack/main-settings.hpp @@ -42,6 +42,6 @@ struct main_settings { a_roll(b, "roll", Roll), tcomp_p(b, "compensate-translation", true), tcomp_tz(b, "compensate-translation-disable-z-axis", false), - tray_enabled(false, "use-system-tray", true) + tray_enabled(b, "use-system-tray", false) {} }; diff --git a/opentrack/shortcuts.cpp b/opentrack/shortcuts.cpp index 851c5826..75b86a29 100644 --- a/opentrack/shortcuts.cpp +++ b/opentrack/shortcuts.cpp @@ -21,6 +21,8 @@ KeyboardShortcutDialog::KeyboardShortcutDialog() tie_setting(s.toggle.alt, ui.chkToggleAlt); tie_setting(s.toggle.shift, ui.chkToggleShift); tie_setting(s.toggle.ctrl, ui.chkToggleCtrl); + + tie_setting(s.s_main.tray_enabled, ui.trayp); } void KeyboardShortcutDialog::doOK() { diff --git a/opentrack/shortcuts.h b/opentrack/shortcuts.h index 298907c7..523bc7b2 100644 --- a/opentrack/shortcuts.h +++ b/opentrack/shortcuts.h @@ -10,7 +10,8 @@ #include "qxt-mini/QxtGlobalShortcut" #include "opentrack/plugin-support.h" #include "opentrack/options.hpp" -#include "ui_ftnoir_keyboardshortcuts.h" +#include "opentrack/main-settings.hpp" +#include "ui_keyboard.h" using namespace options; @@ -95,10 +96,12 @@ struct Shortcuts { struct settings { pbundle b; key_opts center, toggle; + main_settings s_main; settings() : b(bundle("keyboard-shortcuts")), center(b, "center"), - toggle(b, "toggle") + toggle(b, "toggle"), + s_main(bundle("opentrack-ui")) {} } s; |