From 82ed33ea263242abb890b1d3291a2aafc4b3065a Mon Sep 17 00:00:00 2001 From: David Kocik Date: Wed, 29 Sep 2021 14:00:22 +0200 Subject: [PATCH] WIP post system notification --- src/slic3r/CMakeLists.txt | 1 + src/slic3r/GUI/Plater.hpp | 6 +++++- src/slic3r/GUI/SystemNotification.mm | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 src/slic3r/GUI/SystemNotification.mm diff --git a/src/slic3r/CMakeLists.txt b/src/slic3r/CMakeLists.txt index 29d1fae293..8500f72242 100644 --- a/src/slic3r/CMakeLists.txt +++ b/src/slic3r/CMakeLists.txt @@ -245,6 +245,7 @@ if (APPLE) GUI/Mouse3DHandlerMac.mm GUI/InstanceCheckMac.mm GUI/InstanceCheckMac.h + GUI/SystemNotification.mm ) FIND_LIBRARY(DISKARBITRATION_LIBRARY DiskArbitration) diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index 8a8255514a..14eaa7db51 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -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 { diff --git a/src/slic3r/GUI/SystemNotification.mm b/src/slic3r/GUI/SystemNotification.mm new file mode 100644 index 0000000000..1c3eba6406 --- /dev/null +++ b/src/slic3r/GUI/SystemNotification.mm @@ -0,0 +1,14 @@ +#import +#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]; +} \ No newline at end of file