From 2080784dd109179adfae2aabe484c0830ac285ac Mon Sep 17 00:00:00 2001 From: Andrew Hayzen Date: Tue, 2 Mar 2021 22:48:14 +0000 Subject: [PATCH] Do not wait for tray to become available Closes #1024 --- src/gui/src/main.cpp | 32 +------------------------------- 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/src/gui/src/main.cpp b/src/gui/src/main.cpp index 73251d52..5bf5898c 100644 --- a/src/gui/src/main.cpp +++ b/src/gui/src/main.cpp @@ -16,9 +16,6 @@ * along with this program. If not, see . */ -#define TRAY_RETRY_COUNT 5 -#define TRAY_RETRY_WAIT 2000 - #include "QBarrierApplication.h" #include "MainWindow.h" #include "AppConfig.h" @@ -47,8 +44,6 @@ public: } }; -int waitForTray(); - #if defined(Q_OS_MAC) bool checkMacAssistiveDevices(); #endif @@ -93,14 +88,12 @@ int main(int argc, char* argv[]) } #endif - int trayAvailable = waitForTray(); - QApplication::setQuitOnLastWindowClosed(false); QSettings settings; AppConfig appConfig (&settings); - if (appConfig.getAutoHide() && !trayAvailable) + if (appConfig.getAutoHide() && !QSystemTrayIcon::isSystemTrayAvailable()) { // force auto hide to false - otherwise there is no way to get the GUI back fprintf(stdout, "System tray not available, force disabling auto hide!\n"); @@ -124,29 +117,6 @@ int main(int argc, char* argv[]) return app.exec(); } -int waitForTray() -{ - // on linux, the system tray may not be available immediately after logging in, - // so keep retrying but give up after a short time. - int trayAttempts = 0; - while (true) - { - if (QSystemTrayIcon::isSystemTrayAvailable()) - { - break; - } - - if (++trayAttempts > TRAY_RETRY_COUNT) - { - fprintf(stdout, "System tray is unavailable.\n"); - return false; - } - - QThreadImpl::msleep(TRAY_RETRY_WAIT); - } - return true; -} - #if defined(Q_OS_MAC) bool checkMacAssistiveDevices() {