parent
12024b9a5d
commit
2080784dd1
|
@ -16,9 +16,6 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define TRAY_RETRY_COUNT 5
|
|
||||||
#define TRAY_RETRY_WAIT 2000
|
|
||||||
|
|
||||||
#include "QBarrierApplication.h"
|
#include "QBarrierApplication.h"
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
#include "AppConfig.h"
|
#include "AppConfig.h"
|
||||||
|
@ -47,8 +44,6 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
int waitForTray();
|
|
||||||
|
|
||||||
#if defined(Q_OS_MAC)
|
#if defined(Q_OS_MAC)
|
||||||
bool checkMacAssistiveDevices();
|
bool checkMacAssistiveDevices();
|
||||||
#endif
|
#endif
|
||||||
|
@ -93,14 +88,12 @@ int main(int argc, char* argv[])
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int trayAvailable = waitForTray();
|
|
||||||
|
|
||||||
QApplication::setQuitOnLastWindowClosed(false);
|
QApplication::setQuitOnLastWindowClosed(false);
|
||||||
|
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
AppConfig appConfig (&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
|
// 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");
|
fprintf(stdout, "System tray not available, force disabling auto hide!\n");
|
||||||
|
@ -124,29 +117,6 @@ int main(int argc, char* argv[])
|
||||||
return app.exec();
|
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)
|
#if defined(Q_OS_MAC)
|
||||||
bool checkMacAssistiveDevices()
|
bool checkMacAssistiveDevices()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue