Clean up notification.

This commit is contained in:
Black Hat 2018-12-24 20:31:40 +08:00
parent 316d1429fa
commit ec43131a10
9 changed files with 10 additions and 23 deletions

View File

@ -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 {

View File

@ -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() {

View File

@ -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

View File

@ -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);

View File

@ -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};
}

View File

@ -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];

View File

@ -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<const wchar_t *>(QDir::toNativeSeparators(iconPath.toLocalFile()).utf16()));
count++;
CustomHandler *customHandler = new CustomHandler(count, this);
notificationIds[count] = roomEventId{room_id, event_id};

View File

@ -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));
});
}

View File

@ -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