From ec43131a10b08517c7e98fcec4e1e9d93b07825a Mon Sep 17 00:00:00 2001 From: Black Hat Date: Mon, 24 Dec 2018 20:31:40 +0800 Subject: [PATCH] Clean up notification. --- imports/Spectral/Panel/RoomListPanel.qml | 2 +- src/controller.cpp | 5 ++--- src/controller.h | 3 +-- src/notifications/manager.h | 2 +- src/notifications/managerlinux.cpp | 3 +-- src/notifications/managermac.mm | 4 +--- src/notifications/managerwin.cpp | 6 +----- src/roomlistmodel.cpp | 6 +----- src/roomlistmodel.h | 2 +- 9 files changed, 10 insertions(+), 23 deletions(-) diff --git a/imports/Spectral/Panel/RoomListPanel.qml b/imports/Spectral/Panel/RoomListPanel.qml index 9bcd0f6..dcd62c4 100644 --- a/imports/Spectral/Panel/RoomListPanel.qml +++ b/imports/Spectral/Panel/RoomListPanel.qml @@ -30,7 +30,7 @@ Item { connection: controller.connection - onNewMessage: if (!window.active && MSettings.showNotification) spectralController.postNotification(roomId, eventId, roomName, senderName, text, icon, iconPath) + onNewMessage: if (!window.active && MSettings.showNotification) spectralController.postNotification(roomId, eventId, roomName, senderName, text, icon) } SortFilterProxyModel { diff --git a/src/controller.cpp b/src/controller.cpp index 4c87a97..c600a4a 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -234,10 +234,9 @@ void Controller::playAudio(QUrl localFile) { void Controller::postNotification(const QString& roomId, const QString& eventId, const QString& roomName, const QString& senderName, - const QString& text, const QImage& icon, - const QUrl& iconPath) { + const QString& text, const QImage& icon) { notificationsManager.postNotification(roomId, eventId, roomName, senderName, - text, icon, iconPath); + text, icon); } int Controller::dpi() { diff --git a/src/controller.h b/src/controller.h index 0300c78..32fc031 100644 --- a/src/controller.h +++ b/src/controller.h @@ -101,8 +101,7 @@ class Controller : public QObject { void playAudio(QUrl localFile); void postNotification(const QString& roomId, const QString& eventId, const QString& roomName, const QString& senderName, - const QString& text, const QImage& icon, - const QUrl& iconPath); + const QString& text, const QImage& icon); }; #endif // CONTROLLER_H diff --git a/src/notifications/manager.h b/src/notifications/manager.h index b55eac2..0115713 100644 --- a/src/notifications/manager.h +++ b/src/notifications/manager.h @@ -23,7 +23,7 @@ class NotificationsManager : public QObject { void postNotification(const QString &roomId, const QString &eventId, const QString &roomName, const QString &senderName, - const QString &text, const QImage &icon, const QUrl &iconPath); + const QString &text, const QImage &icon); signals: void notificationClicked(const QString roomId, const QString eventId); diff --git a/src/notifications/managerlinux.cpp b/src/notifications/managerlinux.cpp index 3a09b08..cd5c7d0 100644 --- a/src/notifications/managerlinux.cpp +++ b/src/notifications/managerlinux.cpp @@ -25,8 +25,7 @@ NotificationsManager::NotificationsManager(QObject *parent) void NotificationsManager::postNotification( const QString &roomid, const QString &eventid, const QString &roomname, - const QString &sender, const QString &text, const QImage &icon, - const QUrl &iconPath) { + const QString &sender, const QString &text, const QImage &icon) { uint id = showNotification(roomname, sender + ": " + text, icon); notificationIds[id] = roomEventId{roomid, eventid}; } diff --git a/src/notifications/managermac.mm b/src/notifications/managermac.mm index 2ddc939..782be1f 100644 --- a/src/notifications/managermac.mm +++ b/src/notifications/managermac.mm @@ -19,13 +19,11 @@ NotificationsManager::postNotification( const QString &roomName, const QString &senderName, const QString &text, - const QImage &icon, - const QUrl &iconPath) + const QImage &icon) { Q_UNUSED(roomId); Q_UNUSED(eventId); Q_UNUSED(icon); - Q_UNUSED(iconPath); NSUserNotification * notif = [[NSUserNotification alloc] init]; diff --git a/src/notifications/managerwin.cpp b/src/notifications/managerwin.cpp index 70d943c..b6bf61a 100644 --- a/src/notifications/managerwin.cpp +++ b/src/notifications/managerwin.cpp @@ -46,8 +46,7 @@ NotificationsManager::NotificationsManager(QObject *parent) : QObject(parent) {} void NotificationsManager::postNotification( const QString &room_id, const QString &event_id, const QString &room_name, - const QString &sender, const QString &text, const QImage &icon, - const QUrl &iconPath) { + const QString &sender, const QString &text, const QImage &icon) { Q_UNUSED(room_id) Q_UNUSED(event_id) Q_UNUSED(icon) @@ -65,9 +64,6 @@ void NotificationsManager::postNotification( templ.setTextField(QString("%1").arg(text).toStdWString(), WinToastTemplate::SecondLine); - templ.setImagePath( - reinterpret_cast(QDir::toNativeSeparators(iconPath.toLocalFile()).utf16())); - count++; CustomHandler *customHandler = new CustomHandler(count, this); notificationIds[count] = roomEventId{room_id, event_id}; diff --git a/src/roomlistmodel.cpp b/src/roomlistmodel.cpp index 6247f4b..01696d2 100644 --- a/src/roomlistmodel.cpp +++ b/src/roomlistmodel.cpp @@ -86,11 +86,7 @@ void RoomListModel::connectRoomSignals(SpectralRoom* room) { emit newMessage( room->id(), event->id(), room->displayName(), sender->displayname(), utils::eventToString(*event), - room->avatar(128), - QUrl::fromLocalFile(QStandardPaths::writableLocation( - QStandardPaths::CacheLocation) + - "/avatar/" + _url.authority() + '_' + - _url.fileName() + ".png")); + room->avatar(128)); }); } diff --git a/src/roomlistmodel.h b/src/roomlistmodel.h index 40b0f04..9da486d 100644 --- a/src/roomlistmodel.h +++ b/src/roomlistmodel.h @@ -76,7 +76,7 @@ class RoomListModel : public QAbstractListModel { void roomAdded(SpectralRoom* room); void newMessage(const QString& roomId, const QString& eventId, const QString& roomName, const QString& senderName, - const QString& text, const QImage& icon, const QUrl& iconPath); + const QString& text, const QImage& icon); }; #endif // ROOMLISTMODEL_H