diff --git a/src/dialogs/qquickplatformfiledialog.cpp b/src/dialogs/qquickplatformfiledialog.cpp index 7ed4e3fbc28062e89dd02dc0ecd647ef28980514..141f701d13bbe32ee46019cb595cefcefd34aabb 100644 --- a/src/dialogs/qquickplatformfiledialog.cpp +++ b/src/dialogs/qquickplatformfiledialog.cpp @@ -172,6 +172,21 @@ QQuickPlatformFileDialog::~QQuickPlatformFileDialog() delete m_dlgHelper; } +void QQuickPlatformFileDialog::setModality(Qt::WindowModality m) +{ +#ifdef Q_OS_WIN + // A non-modal native file dialog is not possible on Windows, so + // be stubborn about it. Emit modalityChanged() whether it changed + // or not, to ensure that anything which depends on the property + // will re-read the actual current value. + if (m != Qt::ApplicationModal) + m = Qt::ApplicationModal; + if (m == m_modality) + emit modalityChanged(); +#endif + QQuickAbstractFileDialog::setModality(m); +} + QPlatformFileDialogHelper *QQuickPlatformFileDialog::helper() { QQuickItem *parentItem = qobject_cast<QQuickItem *>(parent()); diff --git a/src/dialogs/qquickplatformfiledialog_p.h b/src/dialogs/qquickplatformfiledialog_p.h index 411a78242cc9a139122b83d296227f829c8eeff4..f21d01406883fcdfcfa76b835ecbb40abc2c0667 100644 --- a/src/dialogs/qquickplatformfiledialog_p.h +++ b/src/dialogs/qquickplatformfiledialog_p.h @@ -56,6 +56,7 @@ class QQuickPlatformFileDialog : public QQuickAbstractFileDialog public: QQuickPlatformFileDialog(QObject *parent = 0); virtual ~QQuickPlatformFileDialog(); + virtual void setModality(Qt::WindowModality m) Q_DECL_OVERRIDE; protected: QPlatformFileDialogHelper *helper(); diff --git a/tests/auto/dialogs/tst_dialogs.cpp b/tests/auto/dialogs/tst_dialogs.cpp index 34af7e0c03bc3838f329ea67c6bb6a35991a4c5c..acf04c5c18f7a2c6ecaeb402c133ac75457d1e98 100644 --- a/tests/auto/dialogs/tst_dialogs.cpp +++ b/tests/auto/dialogs/tst_dialogs.cpp @@ -124,7 +124,11 @@ void tst_dialogs::fileDialogNonModal() QTest::mouseClick(window, Qt::LeftButton, 0, QPoint(1000, 100)); // hide QTRY_VERIFY(spyVisibilityChanged.count() > visibilityChangedCount); QCOMPARE(dlg->property("visible").toBool(), false); +#ifdef Q_OS_WIN + QCOMPARE(dlg->property("modality").toInt(), (int)Qt::ApplicationModal); +#else QCOMPARE(dlg->property("modality").toInt(), (int)Qt::NonModal); +#endif } void tst_dialogs::fileDialogNameFilters()