diff --git a/src/AppDelegate.mm b/src/AppDelegate.mm index 355ba5cdb94c2a2be0b837b3f5c60fb2b075ff2e..197b320bb18f9dc377bfbba606b154151cd006dc 100644 --- a/src/AppDelegate.mm +++ b/src/AppDelegate.mm @@ -30,7 +30,7 @@ #import "AppDelegate.h" #import <callmodel.h> - +#import <qapplication.h> #import <accountmodel.h> #import <protocolmodel.h> #import <QItemSelectionModel> @@ -54,6 +54,9 @@ [[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:self]; + NSAppleEventManager* appleEventManager = [NSAppleEventManager sharedAppleEventManager]; + [appleEventManager setEventHandler:self andSelector:@selector(handleQuitEvent:withReplyEvent:) forEventClass:kCoreEventClass andEventID:kAEQuitApplication]; + if([self checkForRingAccount]) { [self showMainWindow]; } else { @@ -133,4 +136,16 @@ return YES; } +- (void)handleQuitEvent:(NSAppleEventDescriptor*)event withReplyEvent:(NSAppleEventDescriptor*)replyEvent +{ + delete CallModel::instance()->QObject::parent(); + [[NSApplication sharedApplication] terminate:self]; +} + +-(void)applicationWillTerminate:(NSNotification *)notification +{ + delete CallModel::instance()->QObject::parent(); + [[NSApplication sharedApplication] terminate:self]; +} + @end