SnapToDefaultButton
};
enum DialogCode { Rejected, Accepted };
- enum ShowFlag {
- ShowModal = 0x00000001
- };
-
- Q_DECLARE_FLAGS(ShowFlags, ShowFlag)
QPlatformDialogHelper();
virtual ~QPlatformDialogHelper();
virtual void _q_platformRunNativeAppModalPanel() = 0;
virtual void deleteNativeDialog_sys() = 0;
- virtual bool show_sys(ShowFlags showFlags,
- Qt::WindowFlags windowFlags,
+ virtual bool show_sys(Qt::WindowFlags windowFlags,
+ Qt::WindowModality windowModality,
QWindow *parent) = 0;
virtual void hide_sys() = 0;
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();
QColor currentColor_sys() const;
public:
- bool showCocoaColorPanel(QWindow *parent);
+ bool showCocoaColorPanel(Qt::WindowModality windowModality, QWindow *parent);
bool hideCocoaColorPanel();
void createNSColorPanelDelegate();
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()
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;
}
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);
QString selectedNameFilter_sys() const;
public:
- bool showCocoaFilePanel(QWindow *parent);
+ bool showCocoaFilePanel(Qt::WindowModality windowModality, QWindow *parent);
bool hideCocoaFilePanel();
void createNSOpenSavePanelDelegate();
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];
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) {
return false;
}
- return showCocoaFilePanel(parent);
+ return showCocoaFilePanel(windowModality, parent);
}
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;
}
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();
protected:
void createNSFontPanelDelegate();
- bool showCocoaFontPanel(QWindow *parent);
+ bool showCocoaFontPanel(Qt::WindowModality windowModality, QWindow *parent);
bool hideCocoaFontPanel();
private:
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()
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;
}
}
template <class BaseClass>
-bool QWindowsDialogHelperBase<BaseClass>::show_sys(QPlatformDialogHelper::ShowFlags flags,
- Qt::WindowFlags,
+bool QWindowsDialogHelperBase<BaseClass>::show_sys(Qt::WindowFlags,
+ Qt::WindowModality windowModality,
QWindow *parent)
{
- const bool modal = flags & QPlatformDialogHelper::ShowModal;
+ const bool modal = (windowModality == Qt::ApplicationModal);
if (parent) {
m_ownerWindow = QWindowsWindow::handleOf(parent);
} else {
virtual void platformNativeDialogModalHelp();
virtual void _q_platformRunNativeAppModalPanel();
virtual void deleteNativeDialog_sys();
- virtual bool show_sys(QPlatformDialogHelper::ShowFlags flags,
- Qt::WindowFlags windowFlags,
+ virtual bool show_sys(Qt::WindowFlags windowFlags,
+ Qt::WindowModality windowModality,
QWindow *parent);
virtual void hide_sys();
virtual QVariant styleHint(QPlatformDialogHelper::StyleHint) const;
{
if (QPlatformDialogHelper *helper = platformHelper()) {
if (visible) {
+ Q_Q(QDialog);
helperPrepareShow(helper);
- QPlatformDialogHelper::ShowFlags flags(0);
- if (q_func()->isModal())
- flags |= QPlatformDialogHelper::ShowModal;
- nativeDialogInUse = helper->show_sys(flags, q_func()->windowFlags(), parentWindow());
+ nativeDialogInUse = helper->show_sys(q->windowFlags(), q->windowModality(), parentWindow());
} else {
helper->hide_sys();
}