diff options
author | DeepBlueV7.X <nicolas.werner@hotmail.de> | 2023-02-02 01:07:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-02 01:07:16 +0100 |
commit | 539db70fd5b5447941fa87da9d98504a5152106b (patch) | |
tree | 267c4905737f512e02ee78dbbeb824f2dc42981a /src | |
parent | Merge pull request #1347 from mauke/url-regex-war-crime (diff) | |
parent | chore: Adjust about function closeAllNotification (diff) | |
download | nheko-539db70fd5b5447941fa87da9d98504a5152106b.tar.xz |
Merge pull request #1341 from Decodetalkers/ft_clean_notify
clean all notifications if exit on linux
Diffstat (limited to 'src')
-rw-r--r-- | src/ChatPage.cpp | 8 | ||||
-rw-r--r-- | src/ChatPage.h | 2 | ||||
-rw-r--r-- | src/main.cpp | 1 | ||||
-rw-r--r-- | src/notifications/Manager.h | 3 | ||||
-rw-r--r-- | src/notifications/ManagerLinux.cpp | 9 |
5 files changed, 23 insertions, 0 deletions
diff --git a/src/ChatPage.cpp b/src/ChatPage.cpp index 04523578..7e35044a 100644 --- a/src/ChatPage.cpp +++ b/src/ChatPage.cpp @@ -1648,3 +1648,11 @@ ChatPage::isRoomActive(const QString &room_id) return QGuiApplication::focusWindow() && QGuiApplication::focusWindow()->isActive() && MainWindow::instance()->windowForRoom(room_id) == QGuiApplication::focusWindow(); } + +void +ChatPage::removeAllNotifications() +{ +#if defined (Q_OS_LINUX) + notificationsManager->closeAllNotifications(); +#endif +} diff --git a/src/ChatPage.h b/src/ChatPage.h index 0ac39faa..ffe70496 100644 --- a/src/ChatPage.h +++ b/src/ChatPage.h @@ -84,6 +84,8 @@ public: return pushrules; } + void removeAllNotifications(); + public slots: bool handleMatrixUri(QString uri); bool handleMatrixUri(const QUrl &uri); diff --git a/src/main.cpp b/src/main.cpp index 779c7800..1ecb014d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -350,6 +350,7 @@ main(int argc, char *argv[]) w.show(); QObject::connect(&app, &QApplication::aboutToQuit, &w, [&w]() { + ChatPage::instance()->removeAllNotifications(); w.saveCurrentWindowSize(); if (http::client() != nullptr) { nhlog::net()->debug("shutting down all I/O threads & open connections"); diff --git a/src/notifications/Manager.h b/src/notifications/Manager.h index bf7af29b..70a03345 100644 --- a/src/notifications/Manager.h +++ b/src/notifications/Manager.h @@ -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; diff --git a/src/notifications/ManagerLinux.cpp b/src/notifications/ManagerLinux.cpp index 294df4db..c694d88f 100644 --- a/src/notifications/ManagerLinux.cpp +++ b/src/notifications/ManagerLinux.cpp @@ -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); + } +} |