Fix quitting without tray icon
Setting KSNI status to Passive doesn't *disable* the tray icon, it just moves it to the overflow menu. This causes the application to not quit when closing the app even when disabling the tray icon
This commit is contained in:
@@ -70,19 +70,21 @@ Controller::Controller(QObject *parent)
|
|||||||
Connection::setUserType<NeoChatUser>();
|
Connection::setUserType<NeoChatUser>();
|
||||||
|
|
||||||
#ifndef Q_OS_ANDROID
|
#ifndef Q_OS_ANDROID
|
||||||
TrayIcon *trayIcon = new TrayIcon(this);
|
|
||||||
if (NeoChatConfig::self()->systemTray()) {
|
if (NeoChatConfig::self()->systemTray()) {
|
||||||
trayIcon->show();
|
m_trayIcon = new TrayIcon(this);
|
||||||
connect(trayIcon, &TrayIcon::showWindow, this, &Controller::showWindow);
|
m_trayIcon->show();
|
||||||
|
connect(m_trayIcon, &TrayIcon::showWindow, this, &Controller::showWindow);
|
||||||
QGuiApplication::setQuitOnLastWindowClosed(false);
|
QGuiApplication::setQuitOnLastWindowClosed(false);
|
||||||
}
|
}
|
||||||
connect(NeoChatConfig::self(), &NeoChatConfig::SystemTrayChanged, this, [this, trayIcon]() {
|
connect(NeoChatConfig::self(), &NeoChatConfig::SystemTrayChanged, this, [this]() {
|
||||||
if (NeoChatConfig::self()->systemTray()) {
|
if (NeoChatConfig::self()->systemTray()) {
|
||||||
trayIcon->show();
|
m_trayIcon = new TrayIcon(this);
|
||||||
connect(trayIcon, &TrayIcon::showWindow, this, &Controller::showWindow);
|
m_trayIcon->show();
|
||||||
|
connect(m_trayIcon, &TrayIcon::showWindow, this, &Controller::showWindow);
|
||||||
} else {
|
} else {
|
||||||
trayIcon->hide();
|
disconnect(m_trayIcon, &TrayIcon::showWindow, this, &Controller::showWindow);
|
||||||
disconnect(trayIcon, &TrayIcon::showWindow, this, &Controller::showWindow);
|
delete m_trayIcon;
|
||||||
|
m_trayIcon = nullptr;
|
||||||
}
|
}
|
||||||
QGuiApplication::setQuitOnLastWindowClosed(!NeoChatConfig::self()->systemTray());
|
QGuiApplication::setQuitOnLastWindowClosed(!NeoChatConfig::self()->systemTray());
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ class QKeySequences;
|
|||||||
|
|
||||||
class NeoChatRoom;
|
class NeoChatRoom;
|
||||||
class NeoChatUser;
|
class NeoChatUser;
|
||||||
|
class TrayIcon;
|
||||||
class QQuickWindow;
|
class QQuickWindow;
|
||||||
|
|
||||||
namespace QKeychain
|
namespace QKeychain
|
||||||
@@ -100,6 +101,7 @@ private:
|
|||||||
|
|
||||||
QPointer<Connection> m_connection;
|
QPointer<Connection> m_connection;
|
||||||
bool m_busy = false;
|
bool m_busy = false;
|
||||||
|
TrayIcon *m_trayIcon = nullptr;
|
||||||
|
|
||||||
static QByteArray loadAccessTokenFromFile(const AccountSettings &account);
|
static QByteArray loadAccessTokenFromFile(const AccountSettings &account);
|
||||||
QKeychain::ReadPasswordJob *loadAccessTokenFromKeyChain(const AccountSettings &account);
|
QKeychain::ReadPasswordJob *loadAccessTokenFromKeyChain(const AccountSettings &account);
|
||||||
|
|||||||
Reference in New Issue
Block a user