Fixed undesired "last window closed" quitting on Windows.
This commit is contained in:
parent
f20b5223b3
commit
717238010c
3 changed files with 14 additions and 1 deletions
|
@ -55,6 +55,7 @@ SystemFactory::AutoStartStatus SystemFactory::getAutoStartStatus() {
|
|||
#endif
|
||||
}
|
||||
|
||||
#if defined(Q_OS_LINUX)
|
||||
QString SystemFactory::getAutostartDesktopFileLocation() {
|
||||
QString xdg_config_path(qgetenv("XDG_CONFIG_HOME"));
|
||||
QString desktop_file_location;
|
||||
|
@ -77,6 +78,7 @@ QString SystemFactory::getAutostartDesktopFileLocation() {
|
|||
// No location found, return empty string.
|
||||
return desktop_file_location;
|
||||
}
|
||||
#endif
|
||||
|
||||
// TODO: Finish implementation of SystemFactory auto-start methods.
|
||||
bool SystemFactory::setAutoStartStatus(const AutoStartStatus &new_status) {
|
||||
|
|
|
@ -21,9 +21,11 @@ class SystemFactory {
|
|||
// new status failed.
|
||||
static bool setAutoStartStatus(const SystemFactory::AutoStartStatus &new_status);
|
||||
|
||||
#if defined(Q_OS_LINUX)
|
||||
// Returns standard location where auto-start .desktop files
|
||||
// should be placed.
|
||||
static QString getAutostartDesktopFileLocation();
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // SYSTEMFACTORY_H
|
||||
|
|
|
@ -66,10 +66,19 @@ void SystemTrayIcon::deleteInstance() {
|
|||
qDebug("Disabling tray icon and raising main application window.");
|
||||
static_cast<FormMain*>((*s_trayIcon).parent())->display();
|
||||
delete s_trayIcon.data();
|
||||
|
||||
// Make sure that application quits when last window is closed.
|
||||
qApp->setQuitOnLastWindowClosed(true);
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
qDebug("Tray icon displayed.");
|
||||
}
|
||||
|
@ -78,7 +87,7 @@ void SystemTrayIcon::show() {
|
|||
#if defined(Q_OS_WIN)
|
||||
// Show immediately.
|
||||
qDebug("Showing tray icon immediately.");
|
||||
show_private();
|
||||
showPrivate();
|
||||
#else
|
||||
// Delay avoids race conditions and tray icon is properly displayed.
|
||||
qDebug("Showing tray icon with 1000 ms delay.");
|
||||
|
|
Loading…
Add table
Reference in a new issue