gui: Fix auto hide behavior (#140)

* 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.
This commit is contained in:
Christopher N. Hesse 2018-10-13 07:52:45 +02:00 committed by Adrian Lucrèce Céleste
parent a58cdf625e
commit ab887a4e90
1 changed files with 9 additions and 5 deletions

View File

@ -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);