|
|
@ -33,8 +33,10 @@ |
|
|
|
#include <objc/message.h> |
|
|
|
#include <objc/message.h> |
|
|
|
#import <Cocoa/Cocoa.h> |
|
|
|
#import <Cocoa/Cocoa.h> |
|
|
|
|
|
|
|
|
|
|
|
QPixmap pixmapForExtension(const QString &ext, const QSize &size) |
|
|
|
namespace MacUtils |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
QPixmap pixmapForExtension(const QString &ext, const QSize &size) |
|
|
|
|
|
|
|
{ |
|
|
|
@autoreleasepool { |
|
|
|
@autoreleasepool { |
|
|
|
NSImage *image = [[NSWorkspace sharedWorkspace] iconForFileType:ext.toNSString()]; |
|
|
|
NSImage *image = [[NSWorkspace sharedWorkspace] iconForFileType:ext.toNSString()]; |
|
|
|
if (image) { |
|
|
|
if (image) { |
|
|
@ -45,10 +47,10 @@ QPixmap pixmapForExtension(const QString &ext, const QSize &size) |
|
|
|
|
|
|
|
|
|
|
|
return QPixmap(); |
|
|
|
return QPixmap(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void overrideDockClickHandler(bool (*dockClickHandler)(id, SEL, ...)) |
|
|
|
void overrideDockClickHandler(bool (*dockClickHandler)(id, SEL, ...)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
NSApplication *appInst = [NSApplication sharedApplication]; |
|
|
|
NSApplication *appInst = [NSApplication sharedApplication]; |
|
|
|
|
|
|
|
|
|
|
|
if (!appInst) |
|
|
|
if (!appInst) |
|
|
@ -69,10 +71,10 @@ void overrideDockClickHandler(bool (*dockClickHandler)(id, SEL, ...)) |
|
|
|
else |
|
|
|
else |
|
|
|
qWarning("Failed to register dock click handler"); |
|
|
|
qWarning("Failed to register dock click handler"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void displayNotification(const QString &title, const QString &message) |
|
|
|
void displayNotification(const QString &title, const QString &message) |
|
|
|
{ |
|
|
|
{ |
|
|
|
@autoreleasepool { |
|
|
|
@autoreleasepool { |
|
|
|
NSUserNotification *notification = [[NSUserNotification alloc] init]; |
|
|
|
NSUserNotification *notification = [[NSUserNotification alloc] init]; |
|
|
|
notification.title = title.toNSString(); |
|
|
|
notification.title = title.toNSString(); |
|
|
@ -81,10 +83,10 @@ void displayNotification(const QString &title, const QString &message) |
|
|
|
|
|
|
|
|
|
|
|
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification]; |
|
|
|
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification]; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void openFiles(const QSet<QString> &pathsList) |
|
|
|
void openFiles(const QSet<QString> &pathsList) |
|
|
|
{ |
|
|
|
{ |
|
|
|
@autoreleasepool { |
|
|
|
@autoreleasepool { |
|
|
|
NSMutableArray *pathURLs = [NSMutableArray arrayWithCapacity:pathsList.size()]; |
|
|
|
NSMutableArray *pathURLs = [NSMutableArray arrayWithCapacity:pathsList.size()]; |
|
|
|
|
|
|
|
|
|
|
@ -93,4 +95,5 @@ void openFiles(const QSet<QString> &pathsList) |
|
|
|
|
|
|
|
|
|
|
|
[[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs:pathURLs]; |
|
|
|
[[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs:pathURLs]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|