diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2019-05-15 05:58:47 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2019-05-15 05:58:47 +0200 |
commit | da9a7a32cbce280283883c6332484ec2358346c2 (patch) | |
tree | e5b52579669afc686d996087adb3100a35d663a6 /opentrack | |
parent | 36b5237d4d3088e5cd344b552dfe70169e7dee42 (diff) |
opentrack: try fix main window not showing
Diffstat (limited to 'opentrack')
-rw-r--r-- | opentrack/main-window.cpp | 54 |
1 files changed, 23 insertions, 31 deletions
diff --git a/opentrack/main-window.cpp b/opentrack/main-window.cpp index 139795d5..006d78ed 100644 --- a/opentrack/main-window.cpp +++ b/opentrack/main-window.cpp @@ -38,23 +38,23 @@ main_window::main_window() : State(OPENTRACK_BASE_PATH + OPENTRACK_LIBRARY_PATH) annoy_if_root(); #endif + setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | windowFlags()); + setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + init_profiles(); init_buttons(); - init_tray_menu(); init_dylibs(); init_shortcuts(); - - setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | windowFlags()); - setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - adjustSize(); - - setVisible(!start_in_tray()); + init_tray_menu(); connect(&pose_update_timer, &QTimer::timeout, this, &main_window::show_pose, Qt::DirectConnection); connect(&det_timer, &QTimer::timeout, this, &main_window::maybe_start_profile_from_executable); det_timer.start(1000); + + adjustSize(); + ensure_tray(); // calls QWidget::show() } void main_window::init_shortcuts() @@ -216,8 +216,6 @@ void main_window::init_tray_menu() connect(&s.tray_enabled, value_::value_changed<bool>(), this, &main_window::ensure_tray); - - ensure_tray(); } void main_window::init_buttons() @@ -688,13 +686,25 @@ void main_window::set_profile(const QString& new_name_, bool migrate) void main_window::ensure_tray() { - if (!QSystemTrayIcon::isSystemTrayAvailable()) + if (!tray_enabled()) { + if (!isVisible()) + { + show(); + +#ifdef __APPLE__ + raise(); // for OSX +#endif + activateWindow(); // for Windows + } + + if (tray) + tray->hide(); + tray = nullptr; + QApplication::setQuitOnLastWindowClosed(true); - return; } - - if (s.tray_enabled) + else { if (!tray) { @@ -711,24 +721,6 @@ void main_window::ensure_tray() QApplication::setQuitOnLastWindowClosed(false); } - else - { - if (!isVisible()) - { - show(); - -#ifdef __APPLE__ - raise(); // for OSX -#endif - activateWindow(); // for Windows - } - - if (tray) - tray->hide(); - tray = nullptr; - - QApplication::setQuitOnLastWindowClosed(true); - } } void main_window::toggle_restore_from_tray(QSystemTrayIcon::ActivationReason e) |