-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmacos_helpers.mm
33 lines (26 loc) · 1.02 KB
/
macos_helpers.mm
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
#include "macos_helpers.h"
#include <Cocoa/Cocoa.h>
#include <iostream>
@interface AppDelegateHelper : NSObject <NSApplicationDelegate>
@property (nonatomic, assign) MainWindow *mainWindow;
@end
@implementation AppDelegateHelper
- (void)applicationDidFinishLaunching:(NSNotification *)notification {
// Application finished launching
}
- (void)applicationDidBecomeActive:(NSNotification *)notification {
// Application became active (e.g., clicked from Dock)
if (self.mainWindow) {
QMetaObject::invokeMethod(self.mainWindow, "restoreWindow", Qt::QueuedConnection);
}
}
- (BOOL)applicationShouldHandleReopen:(NSApplication *)sender hasVisibleWindows:(BOOL)flag {
QMetaObject::invokeMethod(self.mainWindow, "restoreWindow", Qt::QueuedConnection);
return YES;
}
@end
void MacOSHelpers::registerForAppEvents(MainWindow *mainWindow) {
AppDelegateHelper *appDelegate = [[AppDelegateHelper alloc] init];
appDelegate.mainWindow = mainWindow;
[NSApplication sharedApplication].delegate = appDelegate;
}