1#include "manager.h" 2 3#include <Foundation/Foundation.h> 4#include <QtMac> 5#include <QPixmap> 6 7@interface NSUserNotification (CFIPrivate) 8- (void)set_identityImage:(NSImage*)image; 9@end 10 11NotificationsManager::NotificationsManager(QObject* parent) : QObject(parent) {} 12 13void NotificationsManager::postNotification(const QString& roomId, 14 const QString& eventId, 15 const QString& roomName, 16 const QString& senderName, 17 const QString& text, 18 const QImage& icon) { 19 Q_UNUSED(roomId); 20 Q_UNUSED(eventId); 21 Q_UNUSED(icon); 22 23 NSUserNotification* notif = [[NSUserNotification alloc] init]; 24 25 notif.title = roomName.toNSString(); 26 notif.subtitle = QString("%1 sent a message").arg(senderName).toNSString(); 27 notif.informativeText = text.toNSString(); 28 notif.soundName = NSUserNotificationDefaultSoundName; 29 notif.contentImage = QtMac::toNSImage(QPixmap::fromImage(icon)); 30 31 [[NSUserNotificationCenter defaultUserNotificationCenter] 32 deliverNotification:notif]; 33 [notif autorelease]; 34} 35 36// unused 37void NotificationsManager::actionInvoked(uint, QString) {} 38 39void NotificationsManager::notificationClosed(uint, uint) {} 40