mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 19:08:58 +03:00
Display notifications for emote messages properly
This commit is contained in:
parent
7ddcab3902
commit
299c486a2b
5 changed files with 37 additions and 12 deletions
|
@ -691,13 +691,20 @@ ChatPage::sendNotifications(const mtx::responses::Notifications &res)
|
||||||
this,
|
this,
|
||||||
[this, room_id, event_id, item, user_id, info](
|
[this, room_id, event_id, item, user_id, info](
|
||||||
QPixmap image) {
|
QPixmap image) {
|
||||||
|
bool isEmote = false;
|
||||||
|
auto ev = cache::client()->getEvent(
|
||||||
|
room_id.toStdString(), event_id);
|
||||||
|
if (ev && mtx::accessors::msg_type(ev->data) ==
|
||||||
|
mtx::events::MessageType::Emote)
|
||||||
|
isEmote = true;
|
||||||
notificationsManager.postNotification(
|
notificationsManager.postNotification(
|
||||||
room_id,
|
room_id,
|
||||||
QString::fromStdString(event_id),
|
QString::fromStdString(event_id),
|
||||||
QString::fromStdString(info.name),
|
QString::fromStdString(info.name),
|
||||||
cache::displayName(room_id, user_id),
|
cache::displayName(room_id, user_id),
|
||||||
utils::event_body(item.event),
|
utils::event_body(item.event),
|
||||||
image.toImage());
|
image.toImage(),
|
||||||
|
isEmote);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,8 @@ public:
|
||||||
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 bool &isEmoteMsg = false);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void notificationClicked(const QString roomId, const QString eventId);
|
void notificationClicked(const QString roomId, const QString eventId);
|
||||||
|
|
|
@ -50,7 +50,8 @@ NotificationsManager::postNotification(const QString &roomid,
|
||||||
const QString &roomname,
|
const QString &roomname,
|
||||||
const QString &sender,
|
const QString &sender,
|
||||||
const QString &text,
|
const QString &text,
|
||||||
const QImage &icon)
|
const QImage &icon,
|
||||||
|
const bool &isEmoteMessage)
|
||||||
{
|
{
|
||||||
QVariantMap hints;
|
QVariantMap hints;
|
||||||
hints["image-data"] = icon;
|
hints["image-data"] = icon;
|
||||||
|
@ -60,7 +61,12 @@ NotificationsManager::postNotification(const QString &roomid,
|
||||||
argumentList << (uint)0; // replace_id
|
argumentList << (uint)0; // replace_id
|
||||||
argumentList << ""; // app_icon
|
argumentList << ""; // app_icon
|
||||||
argumentList << roomname; // summary
|
argumentList << roomname; // summary
|
||||||
argumentList << sender + ": " + text; // body
|
|
||||||
|
// body
|
||||||
|
if (isEmoteMessage)
|
||||||
|
argumentList << "* " + sender + " " + text;
|
||||||
|
else
|
||||||
|
argumentList << sender + ": " + text;
|
||||||
// The list of actions has always the action name and then a localized version of that
|
// The list of actions has always the action name and then a localized version of that
|
||||||
// action. Currently we just use an empty string for that.
|
// action. Currently we just use an empty string for that.
|
||||||
// TODO(Nico): Look into what to actually put there.
|
// TODO(Nico): Look into what to actually put there.
|
||||||
|
|
|
@ -19,7 +19,8 @@ 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 bool &isEmoteMessage)
|
||||||
{
|
{
|
||||||
Q_UNUSED(roomId);
|
Q_UNUSED(roomId);
|
||||||
Q_UNUSED(eventId);
|
Q_UNUSED(eventId);
|
||||||
|
@ -29,6 +30,9 @@ NotificationsManager::postNotification(
|
||||||
|
|
||||||
notif.title = roomName.toNSString();
|
notif.title = roomName.toNSString();
|
||||||
notif.subtitle = QString("%1 sent a message").arg(senderName).toNSString();
|
notif.subtitle = QString("%1 sent a message").arg(senderName).toNSString();
|
||||||
|
if (isEmoteMessage)
|
||||||
|
notif.informativeText = QString("* ").append(senderName).append(" ").append(text).toNSString();
|
||||||
|
else
|
||||||
notif.informativeText = text.toNSString();
|
notif.informativeText = text.toNSString();
|
||||||
notif.soundName = NSUserNotificationDefaultSoundName;
|
notif.soundName = NSUserNotificationDefaultSoundName;
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,8 @@ NotificationsManager::postNotification(const QString &room_id,
|
||||||
const QString &room_name,
|
const QString &room_name,
|
||||||
const QString &sender,
|
const QString &sender,
|
||||||
const QString &text,
|
const QString &text,
|
||||||
const QImage &icon)
|
const QImage &icon,
|
||||||
|
const bool &isEmoteMessage)
|
||||||
{
|
{
|
||||||
Q_UNUSED(room_id)
|
Q_UNUSED(room_id)
|
||||||
Q_UNUSED(event_id)
|
Q_UNUSED(event_id)
|
||||||
|
@ -53,7 +54,13 @@ NotificationsManager::postNotification(const QString &room_id,
|
||||||
else
|
else
|
||||||
templ.setTextField(QString("%1").arg(sender).toStdWString(),
|
templ.setTextField(QString("%1").arg(sender).toStdWString(),
|
||||||
WinToastTemplate::FirstLine);
|
WinToastTemplate::FirstLine);
|
||||||
templ.setTextField(QString("%1").arg(text).toStdWString(), WinToastTemplate::SecondLine);
|
if (isEmoteMessage)
|
||||||
|
templ.setTextField(
|
||||||
|
QString("* ").append(sender).append(" ").append(text).toStdWString(),
|
||||||
|
WinToastTemplate::SecondLine);
|
||||||
|
else
|
||||||
|
templ.setTextField(QString("%1").arg(text).toStdWString(),
|
||||||
|
WinToastTemplate::SecondLine);
|
||||||
// TODO: implement room or user avatar
|
// TODO: implement room or user avatar
|
||||||
// templ.setImagePath(L"C:/example.png");
|
// templ.setImagePath(L"C:/example.png");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue