summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
diff options
context:
space:
mode:
authorBradley T. Hughes <bradley.hughes@nokia.com>2012-04-26 13:32:14 +0200
committerQt by Nokia <qt-info@nokia.com>2012-04-30 14:01:22 +0200
commitb46189c3c3a92c9093bd05bf976b2e7a368511a3 (patch)
tree13b1bbdf18b8542a58b2246071d96e89f174690e /src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
parent842a0b094befeb6f023782da02e1ee649490091e (diff)
Support all modality types in QPlatformDialogHelper
Modality is not a boolean property in Qt. There are 2 types: window modality and application modality. Native dialogs can support both of these types as well (e.g. on Cocoa, a window modal file dialog should be displayed as a Sheet). Remove the QPlatformDialogHelper::ShowFlags enum and instead pass a Qt::WindowModality parameter to QPlatformDialogHelper::show_sys(). The Windows implementation has been updated to check for Qt::ApplicationModal instead of the ShowModal flag (since only Qt::ApplicationModal dialogs are blocking). The Cocoa implementation has been updated to only use non-modal and application modal native color and font dialogs (which restores Qt 4 behavior). These are shared Cocoa panels that cannot be shown as sheets, however. If the programmer asks for window modal color/font dialogs, we use the Qt versions, not the native ones. The file dialog can be shown either as a Sheet (but we need to pass an NSWindow parent for it to work properly) or as an application modal dialog. This change has been tested on Mac OS X with tests/manual/windowmodality. Change-Id: I9064987433895c55f68aac979ef8e8207fb24bbe Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com> Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm')
-rw-r--r--src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
index 1e89270775..515bc2a6ee 100644
--- a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
+++ b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
@@ -400,9 +400,13 @@ void QCocoaFontDialogHelper::deleteNativeDialog_sys()
mDelegate = 0;
}
-bool QCocoaFontDialogHelper::show_sys(QFlags<QPlatformDialogHelper::ShowFlag>, Qt::WindowFlags, QWindow *parent)
+bool QCocoaFontDialogHelper::show_sys(Qt::WindowFlags, Qt::WindowModality windowModality, QWindow *parent)
{
- return showCocoaFontPanel(parent);
+ if (windowModality == Qt::WindowModal) {
+ // Cocoa's shared font panel cannot be shown as a sheet
+ return false;
+ }
+ return showCocoaFontPanel(windowModality, parent);
}
void QCocoaFontDialogHelper::hide_sys()
@@ -466,12 +470,14 @@ void QCocoaFontDialogHelper::createNSFontPanelDelegate()
mDelegate = delegate;
}
-bool QCocoaFontDialogHelper::showCocoaFontPanel(QWindow *parent)
+bool QCocoaFontDialogHelper::showCocoaFontPanel(Qt::WindowModality windowModality, QWindow *parent)
{
Q_UNUSED(parent);
createNSFontPanelDelegate();
QT_MANGLE_NAMESPACE(QNSFontPanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSFontPanelDelegate) *>(mDelegate);
- [delegate showModelessPanel];
+ if (windowModality == Qt::NonModal)
+ [delegate showModelessPanel];
+ // no need to show a Qt::ApplicationModal dialog here, since it will be done in _q_platformRunNativeAppModalPanel()
return true;
}