From 7b86eccf02ab4a37b3a6f97ceabcb4660bfc3b02 Mon Sep 17 00:00:00 2001 From: "Christopher N. Hesse" Date: Mon, 1 Oct 2018 20:39:13 +0200 Subject: [PATCH] gui: Fix auto hide behavior * make waitForTray() report a proper status - the return value was not used until now anyway (it would always return true) * depend on the system tray availability for auto hide On my system (Fedora 29 with Pantheon Desktop), on a clean install the GUI would auto hide itself on startup, but due to no system tray being available I could never make the GUI appear again. This change disallows auto hide if the system tray is not available. Users who don't want the GUI can just start barriers/barrierc instead of the main barrier executable, so this should not break existing workflows. --- src/gui/src/main.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/gui/src/main.cpp b/src/gui/src/main.cpp index 76a7d1a2..b00ab7f1 100644 --- a/src/gui/src/main.cpp +++ b/src/gui/src/main.cpp @@ -88,16 +88,20 @@ int main(int argc, char* argv[]) } #endif - if (!waitForTray()) - { - return -1; - } + int trayAvailable = waitForTray(); QApplication::setQuitOnLastWindowClosed(false); QSettings settings; AppConfig appConfig (&settings); + if (appConfig.getAutoHide() && !trayAvailable) + { + // 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"); + appConfig.setAutoHide(false); + } + app.switchTranslator(appConfig.language()); MainWindow mainWindow(settings, appConfig); @@ -131,7 +135,7 @@ int waitForTray() { QMessageBox::critical(NULL, "Barrier", QObject::tr("System tray is unavailable, don't close your window.")); - return true; + return false; } QThreadImpl::msleep(TRAY_RETRY_WAIT);