Clean up notification.
This commit is contained in:
parent
316d1429fa
commit
ec43131a10
|
@ -30,7 +30,7 @@ Item {
|
||||||
|
|
||||||
connection: controller.connection
|
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 {
|
SortFilterProxyModel {
|
||||||
|
|
|
@ -234,10 +234,9 @@ void Controller::playAudio(QUrl localFile) {
|
||||||
void Controller::postNotification(const QString& roomId, const QString& eventId,
|
void Controller::postNotification(const QString& roomId, const QString& eventId,
|
||||||
const QString& roomName,
|
const QString& roomName,
|
||||||
const QString& senderName,
|
const QString& senderName,
|
||||||
const QString& text, const QImage& icon,
|
const QString& text, const QImage& icon) {
|
||||||
const QUrl& iconPath) {
|
|
||||||
notificationsManager.postNotification(roomId, eventId, roomName, senderName,
|
notificationsManager.postNotification(roomId, eventId, roomName, senderName,
|
||||||
text, icon, iconPath);
|
text, icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Controller::dpi() {
|
int Controller::dpi() {
|
||||||
|
|
|
@ -101,8 +101,7 @@ class Controller : public QObject {
|
||||||
void playAudio(QUrl localFile);
|
void playAudio(QUrl localFile);
|
||||||
void postNotification(const QString& roomId, const QString& eventId,
|
void postNotification(const QString& roomId, const QString& eventId,
|
||||||
const QString& roomName, const QString& senderName,
|
const QString& roomName, const QString& senderName,
|
||||||
const QString& text, const QImage& icon,
|
const QString& text, const QImage& icon);
|
||||||
const QUrl& iconPath);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CONTROLLER_H
|
#endif // CONTROLLER_H
|
||||||
|
|
|
@ -23,7 +23,7 @@ class NotificationsManager : public QObject {
|
||||||
|
|
||||||
void postNotification(const QString &roomId, const QString &eventId,
|
void postNotification(const QString &roomId, const QString &eventId,
|
||||||
const QString &roomName, const QString &senderName,
|
const QString &roomName, const QString &senderName,
|
||||||
const QString &text, const QImage &icon, const QUrl &iconPath);
|
const QString &text, const QImage &icon);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void notificationClicked(const QString roomId, const QString eventId);
|
void notificationClicked(const QString roomId, const QString eventId);
|
||||||
|
|
|
@ -25,8 +25,7 @@ NotificationsManager::NotificationsManager(QObject *parent)
|
||||||
|
|
||||||
void NotificationsManager::postNotification(
|
void NotificationsManager::postNotification(
|
||||||
const QString &roomid, const QString &eventid, const QString &roomname,
|
const QString &roomid, const QString &eventid, const QString &roomname,
|
||||||
const QString &sender, const QString &text, const QImage &icon,
|
const QString &sender, const QString &text, const QImage &icon) {
|
||||||
const QUrl &iconPath) {
|
|
||||||
uint id = showNotification(roomname, sender + ": " + text, icon);
|
uint id = showNotification(roomname, sender + ": " + text, icon);
|
||||||
notificationIds[id] = roomEventId{roomid, eventid};
|
notificationIds[id] = roomEventId{roomid, eventid};
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,13 +19,11 @@ NotificationsManager::postNotification(
|
||||||
const QString &roomName,
|
const QString &roomName,
|
||||||
const QString &senderName,
|
const QString &senderName,
|
||||||
const QString &text,
|
const QString &text,
|
||||||
const QImage &icon,
|
const QImage &icon)
|
||||||
const QUrl &iconPath)
|
|
||||||
{
|
{
|
||||||
Q_UNUSED(roomId);
|
Q_UNUSED(roomId);
|
||||||
Q_UNUSED(eventId);
|
Q_UNUSED(eventId);
|
||||||
Q_UNUSED(icon);
|
Q_UNUSED(icon);
|
||||||
Q_UNUSED(iconPath);
|
|
||||||
|
|
||||||
NSUserNotification * notif = [[NSUserNotification alloc] init];
|
NSUserNotification * notif = [[NSUserNotification alloc] init];
|
||||||
|
|
||||||
|
|
|
@ -46,8 +46,7 @@ NotificationsManager::NotificationsManager(QObject *parent) : QObject(parent) {}
|
||||||
|
|
||||||
void NotificationsManager::postNotification(
|
void NotificationsManager::postNotification(
|
||||||
const QString &room_id, const QString &event_id, const QString &room_name,
|
const QString &room_id, const QString &event_id, const QString &room_name,
|
||||||
const QString &sender, const QString &text, const QImage &icon,
|
const QString &sender, const QString &text, const QImage &icon) {
|
||||||
const QUrl &iconPath) {
|
|
||||||
Q_UNUSED(room_id)
|
Q_UNUSED(room_id)
|
||||||
Q_UNUSED(event_id)
|
Q_UNUSED(event_id)
|
||||||
Q_UNUSED(icon)
|
Q_UNUSED(icon)
|
||||||
|
@ -65,9 +64,6 @@ void NotificationsManager::postNotification(
|
||||||
templ.setTextField(QString("%1").arg(text).toStdWString(),
|
templ.setTextField(QString("%1").arg(text).toStdWString(),
|
||||||
WinToastTemplate::SecondLine);
|
WinToastTemplate::SecondLine);
|
||||||
|
|
||||||
templ.setImagePath(
|
|
||||||
reinterpret_cast<const wchar_t *>(QDir::toNativeSeparators(iconPath.toLocalFile()).utf16()));
|
|
||||||
|
|
||||||
count++;
|
count++;
|
||||||
CustomHandler *customHandler = new CustomHandler(count, this);
|
CustomHandler *customHandler = new CustomHandler(count, this);
|
||||||
notificationIds[count] = roomEventId{room_id, event_id};
|
notificationIds[count] = roomEventId{room_id, event_id};
|
||||||
|
|
|
@ -86,11 +86,7 @@ void RoomListModel::connectRoomSignals(SpectralRoom* room) {
|
||||||
emit newMessage(
|
emit newMessage(
|
||||||
room->id(), event->id(), room->displayName(),
|
room->id(), event->id(), room->displayName(),
|
||||||
sender->displayname(), utils::eventToString(*event),
|
sender->displayname(), utils::eventToString(*event),
|
||||||
room->avatar(128),
|
room->avatar(128));
|
||||||
QUrl::fromLocalFile(QStandardPaths::writableLocation(
|
|
||||||
QStandardPaths::CacheLocation) +
|
|
||||||
"/avatar/" + _url.authority() + '_' +
|
|
||||||
_url.fileName() + ".png"));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ class RoomListModel : public QAbstractListModel {
|
||||||
void roomAdded(SpectralRoom* room);
|
void roomAdded(SpectralRoom* room);
|
||||||
void newMessage(const QString& roomId, const QString& eventId,
|
void newMessage(const QString& roomId, const QString& eventId,
|
||||||
const QString& roomName, const QString& senderName,
|
const QString& roomName, const QString& senderName,
|
||||||
const QString& text, const QImage& icon, const QUrl& iconPath);
|
const QString& text, const QImage& icon);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ROOMLISTMODEL_H
|
#endif // ROOMLISTMODEL_H
|
||||||
|
|
Loading…
Reference in New Issue