diff options
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm index 6c39f1eb5a..efe3269d42 100644 --- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm +++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm @@ -1,6 +1,5 @@ /**************************************************************************** ** -** Copyright (C) 2013 Samuel Gaist <samuel.gaist@edeltech.ch> ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** @@ -79,13 +78,11 @@ #import "qnswindowdelegate.h" #import "qcocoamenuloader.h" #include "qcocoaintegration.h" -#include "qcocoasessionmanager.h" #include <qevent.h> #include <qurl.h> #include <qdebug.h> #include <qguiapplication.h> #include <private/qguiapplication_p.h> -#include <private/qsessionmanager_p.h> #include "qt_mac_p.h" #include <qpa/qwindowsysteminterface.h> @@ -219,17 +216,6 @@ static void cleanupCocoaApplicationDelegate() return NSTerminateNow; } - QGuiApplicationPrivate *qGuiAppPriv = QGuiApplicationPrivate::instance(); - -#ifndef QT_NO_SESSIONMANAGER - QSessionManagerPrivate *managerPrivate = static_cast<QSessionManagerPrivate*>(QObjectPrivate::get(qGuiAppPriv->session_manager)); - QCocoaSessionManager *cocoaSessionManager = static_cast<QCocoaSessionManager *>(managerPrivate->platformSessionManager); - cocoaSessionManager->appCommitData(); - - if (cocoaSessionManager->wasCanceled()) - return NSTerminateCancel; -#endif - if ([self canQuit]) { if (!startedQuit) { startedQuit = true; @@ -253,7 +239,7 @@ static void cleanupCocoaApplicationDelegate() } } - if (qGuiAppPriv->threadData->eventLoops.isEmpty()) { + if (QGuiApplicationPrivate::instance()->threadData->eventLoops.isEmpty()) { // INVARIANT: No event loop is executing. This probably // means that Qt is used as a plugin, or as a part of a native // Cocoa application. In any case it should be fine to @@ -284,6 +270,10 @@ static void cleanupCocoaApplicationDelegate() */ NSAppleEventManager *eventManager = [NSAppleEventManager sharedAppleEventManager]; [eventManager setEventHandler:self + andSelector:@selector(appleEventQuit:withReplyEvent:) + forEventClass:kCoreEventClass + andEventID:kAEQuitApplication]; + [eventManager setEventHandler:self andSelector:@selector(getUrl:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL]; @@ -293,6 +283,7 @@ static void cleanupCocoaApplicationDelegate() - (void) removeAppleEventHandlers { NSAppleEventManager *eventManager = [NSAppleEventManager sharedAppleEventManager]; + [eventManager removeEventHandlerForEventClass:kCoreEventClass andEventID:kAEQuitApplication]; [eventManager removeEventHandlerForEventClass:kInternetEventClass andEventID:kAEGetURL]; } @@ -339,8 +330,7 @@ static void cleanupCocoaApplicationDelegate() && [reflectionDelegate respondsToSelector: @selector(applicationShouldTerminateAfterLastWindowClosed:)]) return [reflectionDelegate applicationShouldTerminateAfterLastWindowClosed:sender]; - - return qApp->quitOnLastWindowClosed(); + return NO; // Someday qApp->quitOnLastWindowClosed(); when QApp and NSApp work closer together. } @@ -446,6 +436,13 @@ static void cleanupCocoaApplicationDelegate() QWindowSystemInterface::handleFileOpenEvent(QUrl(QCFString::toQString(urlString))); } +- (void)appleEventQuit:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent +{ + Q_UNUSED(event); + Q_UNUSED(replyEvent); + [NSApp terminate:self]; +} + - (void)qtDispatcherToQAction:(id)sender { Q_UNUSED(sender); |