Fixed undesired "last window closed" quitting on Windows.

This commit is contained in:
Martin Rotter 2013-06-25 20:10:49 +02:00
parent f20b5223b3
commit 717238010c
3 changed files with 14 additions and 1 deletions

View file

@ -55,6 +55,7 @@ SystemFactory::AutoStartStatus SystemFactory::getAutoStartStatus() {
#endif #endif
} }
#if defined(Q_OS_LINUX)
QString SystemFactory::getAutostartDesktopFileLocation() { QString SystemFactory::getAutostartDesktopFileLocation() {
QString xdg_config_path(qgetenv("XDG_CONFIG_HOME")); QString xdg_config_path(qgetenv("XDG_CONFIG_HOME"));
QString desktop_file_location; QString desktop_file_location;
@ -77,6 +78,7 @@ QString SystemFactory::getAutostartDesktopFileLocation() {
// No location found, return empty string. // No location found, return empty string.
return desktop_file_location; return desktop_file_location;
} }
#endif
// TODO: Finish implementation of SystemFactory auto-start methods. // TODO: Finish implementation of SystemFactory auto-start methods.
bool SystemFactory::setAutoStartStatus(const AutoStartStatus &new_status) { bool SystemFactory::setAutoStartStatus(const AutoStartStatus &new_status) {

View file

@ -21,9 +21,11 @@ class SystemFactory {
// new status failed. // new status failed.
static bool setAutoStartStatus(const SystemFactory::AutoStartStatus &new_status); static bool setAutoStartStatus(const SystemFactory::AutoStartStatus &new_status);
#if defined(Q_OS_LINUX)
// Returns standard location where auto-start .desktop files // Returns standard location where auto-start .desktop files
// should be placed. // should be placed.
static QString getAutostartDesktopFileLocation(); static QString getAutostartDesktopFileLocation();
#endif
}; };
#endif // SYSTEMFACTORY_H #endif // SYSTEMFACTORY_H

View file

@ -66,10 +66,19 @@ void SystemTrayIcon::deleteInstance() {
qDebug("Disabling tray icon and raising main application window."); qDebug("Disabling tray icon and raising main application window.");
static_cast<FormMain*>((*s_trayIcon).parent())->display(); static_cast<FormMain*>((*s_trayIcon).parent())->display();
delete s_trayIcon.data(); delete s_trayIcon.data();
// Make sure that application quits when last window is closed.
qApp->setQuitOnLastWindowClosed(true);
} }
} }
void SystemTrayIcon::showPrivate() { void SystemTrayIcon::showPrivate() {
// Make sure that application does not exit some window (for example
// the settings window) gets closed. Behavior for main window
// is handled explicitly by FormMain::closeEvent() method.
qApp->setQuitOnLastWindowClosed(false);
// Display the tray icon.
QSystemTrayIcon::show(); QSystemTrayIcon::show();
qDebug("Tray icon displayed."); qDebug("Tray icon displayed.");
} }
@ -78,7 +87,7 @@ void SystemTrayIcon::show() {
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
// Show immediately. // Show immediately.
qDebug("Showing tray icon immediately."); qDebug("Showing tray icon immediately.");
show_private(); showPrivate();
#else #else
// Delay avoids race conditions and tray icon is properly displayed. // Delay avoids race conditions and tray icon is properly displayed.
qDebug("Showing tray icon with 1000 ms delay."); qDebug("Showing tray icon with 1000 ms delay.");