summary refs log tree commit diff
path: root/src/notifications/ManagerMac.mm
blob: 33b7b6aff146a4327346114aef1dfc829a3d307e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "notifications/Manager.h"

#import <Foundation/Foundation.h>
#import <AppKit/NSImage.h>

#include <QtMac>
#include <QImage>

@interface NSUserNotification (CFIPrivate)
- (void)set_identityImage:(NSImage *)image;
@end

NotificationsManager::NotificationsManager(QObject *parent): QObject(parent)
{

}

void
NotificationsManager::objCxxPostNotification(const QString &title,
                                             const QString &subtitle,
                                             const QString &informativeText,
                                             const QImage &bodyImage)
{

    NSUserNotification *notif = [[NSUserNotification alloc] init];

    notif.title           = title.toNSString();
    notif.subtitle        = subtitle.toNSString();
    notif.informativeText = informativeText.toNSString();
    notif.soundName       = NSUserNotificationDefaultSoundName;

    if (!bodyImage.isNull())
        notif.contentImage = [[NSImage alloc] initWithCGImage: bodyImage.toCGImage() size: NSZeroSize];

    [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification: notif];
    [notif autorelease];
}

//unused
void
NotificationsManager::actionInvoked(uint, QString)
{
}

void
NotificationsManager::notificationReplied(uint, QString)
{
}

void
NotificationsManager::notificationClosed(uint, uint)
{
}

void
NotificationsManager::removeNotification(const QString &, const QString &)
{}