summaryrefslogtreecommitdiff
path: root/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@nokia.com>2010-01-08 15:32:01 +0100
committerRichard Moe Gustavsen <richard.gustavsen@nokia.com>2010-01-12 13:49:54 +0100
commitaca933dea3858c0b6db4a02063583da24e80b6c3 (patch)
treeb60880ba7c6e0bbb4011fb19fd0be780be7aadfe /src/gui/kernel/qcocoasharedwindowmethods_mac_p.h
parentab2f88e3cfbf43afd536b9946a40e936c3dcee35 (diff)
downloadqt4-tools-aca933dea3858c0b6db4a02063583da24e80b6c3.tar.gz
Cocoa: application will not quit when using dialogs
When creating a single dialog in the main function, and tell it to exec, we run a modal dialog. But there is really no other window on screen to be modal for. So in that case, since this is a rather common pattern for Qt applications, we allow users to quit the application from the dock. But this action is sendt as an apple event. And and that point in time, cocoa has the the apple event handler, and refuses to close down the application because it detects a modal window. Our solution is to install/overwrite the apple event handler for kAEQuit _after_ cocoa has finished its own installation. But in order to do this, we need to wait until [NSApplication run] has started, otherwise it will not take effect. And that is what this patch essentially does.
Diffstat (limited to 'src/gui/kernel/qcocoasharedwindowmethods_mac_p.h')
-rw-r--r--src/gui/kernel/qcocoasharedwindowmethods_mac_p.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h b/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h
index 31d81d97ee..240cfe793d 100644
--- a/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h
+++ b/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h
@@ -160,10 +160,20 @@ QT_END_NAMESPACE
qt_dispatchTabletProximityEvent(tabletEvent);
}
+- (void)qtDispatcherToQAction:(id)sender
+{
+ // If this window is modal, the menu bar will be modally shaddowed.
+ // In that case, since the window will be in the first responder chain,
+ // we can still catch the trigger here and forward it to the menu bar.
+ // This is needed as a single modal dialog on Qt should be able to access
+ // the application menu (e.g. quit).
+ [[NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)] qtDispatcherToQAction:sender];
+}
+
- (void)terminate:(id)sender
{
- // This function is called from the quit item in the
- // menubar, when this window is the first responder
+ // This function is called from the quit item in the menubar when this window
+ // is in the first responder chain (see also qtDispatcherToQAction above)
[NSApp terminate:sender];
}