WIP post system notification

This commit is contained in:
David Kocik 2021-09-29 14:00:22 +02:00
parent 88c701888d
commit 82ed33ea26
3 changed files with 20 additions and 1 deletions

View File

@ -245,6 +245,7 @@ if (APPLE)
GUI/Mouse3DHandlerMac.mm
GUI/InstanceCheckMac.mm
GUI/InstanceCheckMac.h
GUI/SystemNotification.mm
)
FIND_LIBRARY(DISKARBITRATION_LIBRARY DiskArbitration)

View File

@ -368,7 +368,11 @@ public:
void init_notification_manager();
void bring_instance_forward();
#ifdef __APPLE__
void post_mac_notifiacation(const std::string& title, const std::string& message);
#endif //__APPLE__
// ROII wrapper for suppressing the Undo / Redo snapshot to be taken.
class SuppressSnapshots
{

View File

@ -0,0 +1,14 @@
#import <Foundation/Foundation.h>
#import "Plater.hpp"
void Plater::post_mac_notifiacation(const std::string &title, const std::string &message)
{
NSString * ttl_nss = [NSString stringWithCString:title.c_str() encoding:[NSString defaultCStringEncoding]];
NSString * msg_nss = [NSString stringWithCString:message.c_str() encoding:[NSString defaultCStringEncoding]];
NSUserNotification* notification = [[NSUserNotification alloc] init];
notification.title = ttl_nss;
notification.informativeText = msg_nss;
notification.soundName = NSUserNotificationDefaultSoundName; //Will play a default sound
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification: notification];
[notification autorelease];
}