77 #ifdef QT_MAC_USE_COCOA 79 #import <private/qcocoaapplicationdelegate_mac_p.h> 80 #import <private/qcocoamenuloader_mac_p.h> 81 #import <private/qcocoaapplication_mac_p.h> 82 #include <private/qapplication_p.h> 83 #include <private/qt_mac_p.h> 84 #include <private/qt_cocoa_helpers_mac_p.h> 85 #include <private/qdesktopwidget_mac_p.h> 102 static QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) *sharedCocoaApplicationDelegate = nil;
104 static void cleanupCocoaApplicationDelegate()
106 [sharedCocoaApplicationDelegate release];
109 @implementation QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate)
121 sharedCocoaApplicationDelegate = nil;
123 [qtMenuLoader release];
124 if (reflectionDelegate) {
125 [NSApp setDelegate:reflectionDelegate];
126 [reflectionDelegate release];
131 + (id)allocWithZone:(NSZone *)zone
133 @
synchronized(
self) {
134 if (sharedCocoaApplicationDelegate == nil) {
135 sharedCocoaApplicationDelegate = [
super allocWithZone:zone];
136 return sharedCocoaApplicationDelegate;
145 @
synchronized(
self) {
146 if (sharedCocoaApplicationDelegate == nil)
149 return [[sharedCocoaApplicationDelegate retain] autorelease];
152 - (void)setDockMenu:(NSMenu*)newMenu
159 - (NSMenu *)applicationDockMenu
161 return [[dockMenu retain] autorelease];
177 [qtMenuLoader release];
178 qtMenuLoader = menuLoader;
183 return [[qtMenuLoader retain] autorelease];
189 - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
193 if (reflectionDelegate
194 && [reflectionDelegate respondsToSelector:
@selector(applicationShouldTerminate:)]) {
195 return [reflectionDelegate applicationShouldTerminate:sender];
198 if (qtPrivate->canQuit()) {
206 if (qtPrivate->threadData->eventLoops.size() == 0) {
211 return NSTerminateNow;
214 return NSTerminateCancel;
217 - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
224 - (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames
226 for (NSString *
fileName in filenames) {
233 if (
qApp->arguments().contains(qtFileName))
240 if (reflectionDelegate &&
241 [reflectionDelegate respondsToSelector:
@selector(application:openFiles:)])
242 [reflectionDelegate application:sender openFiles:filenames];
245 - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender
248 if (reflectionDelegate
249 && [reflectionDelegate respondsToSelector:
250 @selector(applicationShouldTerminateAfterLastWindowClosed:)])
251 return [reflectionDelegate applicationShouldTerminateAfterLastWindowClosed:sender];
256 - (void)applicationDidBecomeActive:(NSNotification *)notification
258 if (reflectionDelegate
259 && [reflectionDelegate respondsToSelector:
@selector(applicationDidBecomeActive:)])
260 [reflectionDelegate applicationDidBecomeActive:notification];
271 qt_last_mouse_receiver = widgetUnderMouse;
272 qt_last_native_mouse_receiver = widgetUnderMouse ?
277 - (void)applicationDidResignActive:(NSNotification *)notification
279 if (reflectionDelegate
280 && [reflectionDelegate respondsToSelector:
@selector(applicationDidResignActive:)])
281 [reflectionDelegate applicationDidResignActive:notification];
287 qt_last_mouse_receiver = 0;
288 qt_last_native_mouse_receiver = 0;
292 - (void)applicationDidChangeScreenParameters:(NSNotification *)notification
298 - (void)setReflectionDelegate:(NSObject <NSApplicationDelegate> *)oldDelegate
300 [oldDelegate retain];
301 [reflectionDelegate release];
302 reflectionDelegate = oldDelegate;
305 - (NSMethodSignature *)methodSignatureForSelector:(
SEL)aSelector
307 NSMethodSignature *result = [
super methodSignatureForSelector:aSelector];
308 if (!result && reflectionDelegate) {
309 result = [reflectionDelegate methodSignatureForSelector:aSelector];
314 - (BOOL)respondsToSelector:(
SEL)aSelector
316 BOOL result = [
super respondsToSelector:aSelector];
317 if (!result && reflectionDelegate)
318 result = [reflectionDelegate respondsToSelector:aSelector];
322 - (void)forwardInvocation:(NSInvocation *)invocation
324 SEL invocationSelector = [invocation selector];
325 if (reflectionDelegate && [reflectionDelegate respondsToSelector:invocationSelector])
326 [invocation invokeWithTarget:reflectionDelegate];
328 [
self doesNotRecognizeSelector:invocationSelector];
331 - (void)getUrl:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent
335 NSString *urlString = [[event paramDescriptorForKeyword:keyDirectObject] stringValue];
336 QUrl url(qt_mac_NSStringToQString(urlString));
341 - (void)appleEventQuit:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent
345 [NSApp terminate:self];
348 - (void)qtDispatcherToQAction:(
id)sender
350 [[NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)] qtDispatcherToQAction:sender];
#define QT_END_NAMESPACE
This macro expands to.
void qAddPostRoutine(QtCleanUpFunction p)
The QUrl class provides a convenient interface for working with URLs.
The QString class provides a Unicode character string.
QPointer< QWidget > qt_last_mouse_receiver
static void quit()
Tells the application to exit with return code 0 (success).
#define QT_FORWARD_DECLARE_CLASS(name)
#define QT_BEGIN_NAMESPACE
This macro expands to.
QApplication * qAppInstance()
void onApplicationChangedActivation(bool activated)
#define QT_MANGLE_NAMESPACE(name)
bool qt_sendSpontaneousEvent(QObject *, QEvent *)
The QPoint class defines a point in the plane using integer precision.
static void dispatchEnterLeave(QWidget *enter, QWidget *leave)
#define QT_USE_NAMESPACE
This macro expands to using QT_NAMESPACE if QT_NAMESPACE is defined and nothing otherwise.
void qt_release_apple_event_handler()
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
static QString fileName(const QString &fileUrl)
qt_mac_getTargetForMouseEvent(event, QEvent::Gesture, qlocal, qglobal, 0, &widgetToGetTouch)
The QFileOpenEvent class provides an event that will be sent when there is a request to open a file o...