summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/cocoa')
-rw-r--r--src/plugins/platforms/cocoa/qcocoacolordialoghelper.h4
-rw-r--r--src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm14
-rw-r--r--src/plugins/platforms/cocoa/qcocoafiledialoghelper.h4
-rw-r--r--src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm20
-rw-r--r--src/plugins/platforms/cocoa/qcocoafontdialoghelper.h4
-rw-r--r--src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm14
6 files changed, 36 insertions, 24 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.h b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.h
index 505fd4f111..4b901f3ef3 100644
--- a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.h
+++ b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.h
@@ -56,7 +56,7 @@ public:
void platformNativeDialogModalHelp();
void _q_platformRunNativeAppModalPanel();
void deleteNativeDialog_sys();
- bool show_sys(QFlags<QPlatformDialogHelper::ShowFlag>, Qt::WindowFlags, QWindow*);
+ bool show_sys(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent);
void hide_sys();
DialogCode dialogResultCode_sys();
@@ -64,7 +64,7 @@ public:
QColor currentColor_sys() const;
public:
- bool showCocoaColorPanel(QWindow *parent);
+ bool showCocoaColorPanel(Qt::WindowModality windowModality, QWindow *parent);
bool hideCocoaColorPanel();
void createNSColorPanelDelegate();
diff --git a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
index 405cacee01..9f4446b32e 100644
--- a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
+++ b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
@@ -381,9 +381,13 @@ void QCocoaColorDialogHelper::deleteNativeDialog_sys()
mDelegate = 0;
}
-bool QCocoaColorDialogHelper::show_sys(QFlags<QPlatformDialogHelper::ShowFlag>, Qt::WindowFlags, QWindow *parent)
+bool QCocoaColorDialogHelper::show_sys(Qt::WindowFlags, Qt::WindowModality windowModality, QWindow *parent)
{
- return showCocoaColorPanel(parent);
+ if (windowModality == Qt::WindowModal) {
+ // Cocoa's shared color panel cannot be shown as a sheet
+ return false;
+ }
+ return showCocoaColorPanel(windowModality, parent);
}
void QCocoaColorDialogHelper::hide_sys()
@@ -447,13 +451,15 @@ void QCocoaColorDialogHelper::createNSColorPanelDelegate()
mDelegate = delegate;
}
-bool QCocoaColorDialogHelper::showCocoaColorPanel(QWindow *parent)
+bool QCocoaColorDialogHelper::showCocoaColorPanel(Qt::WindowModality windowModality, QWindow *parent)
{
Q_UNUSED(parent);
createNSColorPanelDelegate();
QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) *>(mDelegate);
[delegate->mColorPanel setShowsAlpha:options()->testOption(QColorDialogOptions::ShowAlphaChannel)];
- [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;
}
diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.h b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.h
index 7d4da019c2..9768d3e6f9 100644
--- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.h
+++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.h
@@ -62,7 +62,7 @@ public:
bool defaultNameFilterDisables() const;
void deleteNativeDialog_sys();
- bool show_sys(ShowFlags flags, Qt::WindowFlags windowFlags, QWindow *parent);
+ bool show_sys(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent);
void hide_sys();
QPlatformFileDialogHelper::DialogCode dialogResultCode_sys();
void setDirectory_sys(const QString &directory);
@@ -74,7 +74,7 @@ public:
QString selectedNameFilter_sys() const;
public:
- bool showCocoaFilePanel(QWindow *parent);
+ bool showCocoaFilePanel(Qt::WindowModality windowModality, QWindow *parent);
bool hideCocoaFilePanel();
void createNSOpenSavePanelDelegate();
diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
index c333e3ac1f..9bc7df02fb 100644
--- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
+++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
@@ -244,18 +244,18 @@ typedef QSharedPointer<QFileDialogOptions> SharedPointerFileDialogOptions;
return (mReturnCode == NSOKButton) ? QT_PREPEND_NAMESPACE(QPlatformDialogHelper::Accepted) : QT_PREPEND_NAMESPACE(QPlatformDialogHelper::Rejected);
}
-- (void)showWindowModalSheet:(QWindow *)docWidget
+- (void)showWindowModalSheet:(QWindow *)parent
{
- Q_UNUSED(docWidget);
QFileInfo info(*mCurrentSelection);
NSString *filename = QT_PREPEND_NAMESPACE(QCFString::toNSString)(info.fileName());
NSString *filepath = QT_PREPEND_NAMESPACE(QCFString::toNSString)(info.filePath());
bool selectable = (mOptions->acceptMode() == QFileDialogOptions::AcceptSave)
|| [self panel:nil shouldShowFilename:filepath];
+ NSWindow *nsparent = static_cast<NSWindow *>(qGuiApp->platformNativeInterface()->nativeResourceForWindow("nswindow", parent));
[mSavePanel
beginSheetForDirectory:mCurrentDir
file:selectable ? filename : nil
- modalForWindow:nil
+ modalForWindow:nsparent
modalDelegate:self
didEndSelector:@selector(openPanelDidEnd:returnCode:contextInfo:)
contextInfo:nil];
@@ -613,7 +613,7 @@ void QCocoaFileDialogHelper::hide_sys()
hideCocoaFilePanel();
}
-bool QCocoaFileDialogHelper::show_sys(ShowFlags /* flags */, Qt::WindowFlags windowFlags, QWindow *parent)
+bool QCocoaFileDialogHelper::show_sys(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent)
{
// Q_Q(QFileDialog);
if (windowFlags & Qt::WindowStaysOnTopHint) {
@@ -624,7 +624,7 @@ bool QCocoaFileDialogHelper::show_sys(ShowFlags /* flags */, Qt::WindowFlags win
return false;
}
- return showCocoaFilePanel(parent);
+ return showCocoaFilePanel(windowModality, parent);
}
void QCocoaFileDialogHelper::createNSOpenSavePanelDelegate()
@@ -645,15 +645,15 @@ void QCocoaFileDialogHelper::createNSOpenSavePanelDelegate()
mDelegate = delegate;
}
-bool QCocoaFileDialogHelper::showCocoaFilePanel(QWindow *parent)
+bool QCocoaFileDialogHelper::showCocoaFilePanel(Qt::WindowModality windowModality, QWindow *parent)
{
-// Q_Q(QFileDialog);
createNSOpenSavePanelDelegate();
QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate);
- if (0 /*qt_mac_is_macsheet(qtFileDialog)*/) // ### sheet support.
- [delegate showWindowModalSheet:parent];
- else
+ if (windowModality == Qt::NonModal)
[delegate showModelessPanel];
+ else if (windowModality == Qt::WindowModal && parent)
+ [delegate showWindowModalSheet:parent];
+ // no need to show a Qt::ApplicationModal dialog here, since it will be done in _q_platformRunNativeAppModalPanel()
return true;
}
diff --git a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.h b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.h
index 8a914bf632..f9dd4357a5 100644
--- a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.h
+++ b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.h
@@ -60,7 +60,7 @@ public:
void _q_platformRunNativeAppModalPanel();
void deleteNativeDialog_sys();
- bool show_sys(ShowFlags showFlags, Qt::WindowFlags windowFlags, QWindow *parent);
+ bool show_sys(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent);
void hide_sys();
QPlatformDialogHelper::DialogCode dialogResultCode_sys();
@@ -70,7 +70,7 @@ public:
protected:
void createNSFontPanelDelegate();
- bool showCocoaFontPanel(QWindow *parent);
+ bool showCocoaFontPanel(Qt::WindowModality windowModality, QWindow *parent);
bool hideCocoaFontPanel();
private:
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;
}