feat: clean all notifications if exit on linux
This commit is contained in:
parent
3abb49c4a2
commit
919ec2a5e3
@ -1640,3 +1640,11 @@ ChatPage::isRoomActive(const QString &room_id)
|
||||
return QGuiApplication::focusWindow() && QGuiApplication::focusWindow()->isActive() &&
|
||||
MainWindow::instance()->windowForRoom(room_id) == QGuiApplication::focusWindow();
|
||||
}
|
||||
|
||||
#if defined (Q_OS_LINUX)
|
||||
void
|
||||
ChatPage::removeAllNotifications()
|
||||
{
|
||||
notificationsManager->closeAllNotifications();
|
||||
}
|
||||
#endif
|
||||
|
@ -84,6 +84,10 @@ public:
|
||||
return pushrules;
|
||||
}
|
||||
|
||||
#if defined(Q_OS_LINUX)
|
||||
void removeAllNotifications();
|
||||
#endif
|
||||
|
||||
public slots:
|
||||
bool handleMatrixUri(QString uri);
|
||||
bool handleMatrixUri(const QUrl &uri);
|
||||
|
@ -15,6 +15,9 @@
|
||||
|
||||
#include "TrayIcon.h"
|
||||
|
||||
#if defined(Q_OS_LINUX)
|
||||
#include "ChatPage.h"
|
||||
#endif
|
||||
#if defined(Q_OS_MAC)
|
||||
#include <QtMacExtras>
|
||||
#endif
|
||||
@ -119,7 +122,12 @@ TrayIcon::TrayIcon(const QString &filename, QWindow *parent)
|
||||
quitAction_ = new QAction(tr("Quit"), this);
|
||||
|
||||
connect(viewAction_, &QAction::triggered, parent, &QWindow::show);
|
||||
connect(quitAction_, &QAction::triggered, this, QApplication::quit);
|
||||
connect(quitAction_, &QAction::triggered, this, [=] {
|
||||
#if defined(Q_OS_LINUX)
|
||||
ChatPage::instance()->removeAllNotifications();
|
||||
#endif
|
||||
QApplication::quit();
|
||||
});
|
||||
|
||||
menu->addAction(viewAction_);
|
||||
menu->addAction(quitAction_);
|
||||
|
@ -55,6 +55,9 @@ public slots:
|
||||
#if defined(NHEKO_DBUS_SYS)
|
||||
public:
|
||||
void closeNotifications(QString roomId);
|
||||
#if defined(Q_OS_LINUX)
|
||||
void closeAllNotifications();
|
||||
#endif
|
||||
|
||||
private:
|
||||
QDBusInterface dbus;
|
||||
|
@ -271,3 +271,12 @@ NotificationsManager::notificationClosed(uint id, uint reason)
|
||||
Q_UNUSED(reason);
|
||||
notificationIds.remove(id);
|
||||
}
|
||||
|
||||
void
|
||||
NotificationsManager::closeAllNotifications()
|
||||
{
|
||||
for (auto id : notificationIds.keys()) {
|
||||
closeNotification(id);
|
||||
notificationIds.remove(id);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user