Init Windows notification image.

This commit is contained in:
Black Hat
2018-10-20 14:59:37 +08:00
parent 6339fd78a2
commit 2e4fed72fe
9 changed files with 41 additions and 31 deletions

View File

@@ -4,6 +4,7 @@
#include "events/roomevent.h"
#include <QStandardPaths>
#include <QtCore/QDebug>
#include <QtGui/QBrush>
#include <QtGui/QColor>
@@ -74,17 +75,22 @@ void RoomListModel::connectRoomSignals(SpectralRoom* room) {
[=] { refresh(room, {AvatarRole}); });
connect(room, &Room::addedMessages, this,
[=] { refresh(room, {LastEventRole}); });
connect(room, &Room::aboutToAddNewMessages, this,
[=](QMatrixClient::RoomEventsRange eventsRange) {
RoomEvent* event = (eventsRange.end() - 1)->get();
if (event->isStateEvent()) return;
User* sender = room->user(event->senderId());
if (sender == room->localUser()) return;
emit newMessage(room->id(), event->id(), room->displayName(),
sender->displayname(),
event->contentJson().value("body").toString(),
room->avatar(128));
});
connect(
room, &Room::aboutToAddNewMessages, this,
[=](QMatrixClient::RoomEventsRange eventsRange) {
RoomEvent* event = (eventsRange.end() - 1)->get();
if (event->isStateEvent()) return;
User* sender = room->user(event->senderId());
if (sender == room->localUser()) return;
QUrl _url = room->avatarUrl();
qDebug() << QStandardPaths::writableLocation(QStandardPaths::CacheLocation) +
"/avatar/" + _url.authority() + '_' + _url.fileName() + ".png";
emit newMessage(
room->id(), event->id(), room->displayName(), sender->displayname(),
event->contentJson().value("body").toString(), room->avatar(128),
QStandardPaths::writableLocation(QStandardPaths::CacheLocation) +
"/avatar/" + _url.authority() + '_' + _url.fileName() + ".png");
});
}
void RoomListModel::updateRoom(Room* room, Room* prev) {