Init Windows notification image.
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include <QMap>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QUrl>
|
||||
|
||||
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
|
||||
#include <QtDBus/QDBusArgument>
|
||||
@@ -22,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 QString &text, const QImage &icon, const QUrl &iconPath);
|
||||
|
||||
signals:
|
||||
void notificationClicked(const QString roomId, const QString eventId);
|
||||
|
||||
@@ -25,7 +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 QString &sender, const QString &text, const QImage &icon, const QUrl &iconPath) {
|
||||
uint id = showNotification(roomname, sender + ": " + text, icon);
|
||||
notificationIds[id] = roomEventId{roomid, eventid};
|
||||
}
|
||||
|
||||
@@ -19,11 +19,13 @@ NotificationsManager::postNotification(
|
||||
const QString &roomName,
|
||||
const QString &senderName,
|
||||
const QString &text,
|
||||
const QImage &icon)
|
||||
const QImage &icon,
|
||||
const QUrl &iconPath)
|
||||
{
|
||||
Q_UNUSED(roomId);
|
||||
Q_UNUSED(eventId);
|
||||
Q_UNUSED(icon);
|
||||
Q_UNUSED(iconPath);
|
||||
|
||||
NSUserNotification * notif = [[NSUserNotification alloc] init];
|
||||
|
||||
|
||||
@@ -5,24 +5,24 @@ using namespace WinToastLib;
|
||||
|
||||
class CustomHandler : public IWinToastHandler {
|
||||
public:
|
||||
CustomHandler(NotificationsManager* parent) : notificationsManager(parent) {}
|
||||
CustomHandler(uint id, NotificationsManager *parent)
|
||||
: notificationID(id), notificationsManager(parent) {}
|
||||
void toastActivated() {
|
||||
notificationsManager->actionInvoked(notificationID, "");
|
||||
notificationsManager->actionInvoked(notificationID, "");
|
||||
}
|
||||
void toastActivated(int) {
|
||||
notificationsManager->actionInvoked(notificationID, "");
|
||||
notificationsManager->actionInvoked(notificationID, "");
|
||||
}
|
||||
void toastFailed() {
|
||||
std::wcout << L"Error showing current toast" << std::endl;
|
||||
}
|
||||
void toastDismissed(WinToastDismissalReason) {
|
||||
notificationsManager->notificationClosed(notificationID, 0);
|
||||
notificationsManager->notificationClosed(notificationID, 0);
|
||||
}
|
||||
|
||||
private:
|
||||
uint notificationID;
|
||||
|
||||
private:
|
||||
NotificationsManager* notificationsManager;
|
||||
NotificationsManager *notificationsManager;
|
||||
};
|
||||
|
||||
namespace {
|
||||
@@ -44,7 +44,8 @@ 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 QString &sender, const QString &text, const QImage &icon,
|
||||
const QUrl &iconPath) {
|
||||
Q_UNUSED(room_id)
|
||||
Q_UNUSED(event_id)
|
||||
Q_UNUSED(icon)
|
||||
@@ -61,12 +62,11 @@ void NotificationsManager::postNotification(
|
||||
WinToastTemplate::FirstLine);
|
||||
templ.setTextField(QString("%1").arg(text).toStdWString(),
|
||||
WinToastTemplate::SecondLine);
|
||||
// TODO: implement room or user avatar
|
||||
// templ.setImagePath(L"C:/example.png");
|
||||
templ.setImagePath(
|
||||
reinterpret_cast<const wchar_t *>(iconPath.toLocalFile().utf16()));
|
||||
|
||||
CustomHandler *customHandler = new CustomHandler(this);
|
||||
count++;
|
||||
customHandler->notificationID = count;
|
||||
CustomHandler *customHandler = new CustomHandler(count, this);
|
||||
notificationIds[count] = roomEventId{room_id, event_id};
|
||||
|
||||
WinToast::instance()->showToast(templ, customHandler);
|
||||
|
||||
Reference in New Issue
Block a user