Skip to content

Commit

Permalink
WIP: Handle double-click-on-icon when app is running
Browse files Browse the repository at this point in the history
  • Loading branch information
erikjv committed Jul 13, 2021
1 parent dbe9b18 commit 23dc7e1
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/gui/cocoainitializer_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,44 @@
#import <Foundation/NSAutoreleasePool.h>
#import <AppKit/NSApplication.h>

#include <QDebug>
#include <QMessageBox>

@interface OwnAppDelegate : NSObject<NSApplicationDelegate>
- (BOOL)applicationShouldHandleReopen:(NSApplication *)sender hasVisibleWindows:(BOOL)flag;
@end

@implementation OwnAppDelegate {
}

- (BOOL)applicationShouldHandleReopen:(NSApplication *)sender hasVisibleWindows:(BOOL)flag
{
qDebug() << "HERE!";
QMessageBox::information(nullptr, "OwnAppDelegate", QStringLiteral("Yo yo, received a message named: applicationShouldHandleReopen, hasVisibleWindows:%1").arg(flag?"YES":"NO"));
return YES;
}

@end

namespace OCC {
namespace Mac {

class CocoaInitializer::Private {
public:
NSAutoreleasePool* autoReleasePool;
OwnAppDelegate *appDelegate;
};

CocoaInitializer::CocoaInitializer() {
d = new CocoaInitializer::Private();
NSApplicationLoad();
d->autoReleasePool = [[NSAutoreleasePool alloc] init];
d->appDelegate = [[OwnAppDelegate alloc] init];
[[NSApplication sharedApplication] setDelegate:d->appDelegate];
}

CocoaInitializer::~CocoaInitializer() {
[d->appDelegate release];
[d->autoReleasePool release];
delete d;
}
Expand Down

0 comments on commit 23dc7e1

Please sign in to comment.