When the last window closes if there is no system tray close the app
This commit is contained in:
parent
2080784dd1
commit
00565fa7ea
|
@ -29,6 +29,12 @@ QBarrierApplication::QBarrierApplication(int& argc, char** argv) :
|
|||
m_Translator(NULL)
|
||||
{
|
||||
s_Instance = this;
|
||||
|
||||
// By default do not quit when the last window is closed as we minimise
|
||||
// to the system tray, but listen for the lastWindow closing so that
|
||||
// if the system tray is not available we can quit.
|
||||
setQuitOnLastWindowClosed(false);
|
||||
connect(this, &QApplication::lastWindowClosed, this, &QBarrierApplication::onLastWindowClosed);
|
||||
}
|
||||
|
||||
QBarrierApplication::~QBarrierApplication()
|
||||
|
@ -69,3 +75,12 @@ void QBarrierApplication::setTranslator(QTranslator* translator)
|
|||
m_Translator = translator;
|
||||
installTranslator(m_Translator);
|
||||
}
|
||||
|
||||
void QBarrierApplication::onLastWindowClosed()
|
||||
{
|
||||
// If there is no system tray available then quit when the last window is closed
|
||||
if (!QSystemTrayIcon::isSystemTrayAvailable())
|
||||
{
|
||||
quit();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,9 @@ class QBarrierApplication : public QApplication
|
|||
|
||||
static QBarrierApplication* getInstance();
|
||||
|
||||
private Q_SLOTS:
|
||||
void onLastWindowClosed();
|
||||
|
||||
private:
|
||||
QTranslator* m_Translator;
|
||||
|
||||
|
|
|
@ -88,8 +88,6 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
#endif
|
||||
|
||||
QApplication::setQuitOnLastWindowClosed(false);
|
||||
|
||||
QSettings settings;
|
||||
AppConfig appConfig (&settings);
|
||||
|
||||
|
|
Loading…
Reference in New Issue