Commit 41e66ea6 authored by Shawn Rutledge's avatar Shawn Rutledge
Browse files

Dialogs: FileDialog can only be modal on Windows


The autotest has been failing on Windows because of this.

Change-Id: I6ec42a256455d7a71a522fa7e75dc44f93b741ea
Reviewed-by: default avatarFriedemann Kleint <Friedemann.Kleint@digia.com>
Showing with 20 additions and 0 deletions
...@@ -172,6 +172,21 @@ QQuickPlatformFileDialog::~QQuickPlatformFileDialog() ...@@ -172,6 +172,21 @@ QQuickPlatformFileDialog::~QQuickPlatformFileDialog()
delete m_dlgHelper; 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() QPlatformFileDialogHelper *QQuickPlatformFileDialog::helper()
{ {
QQuickItem *parentItem = qobject_cast<QQuickItem *>(parent()); QQuickItem *parentItem = qobject_cast<QQuickItem *>(parent());
......
...@@ -56,6 +56,7 @@ class QQuickPlatformFileDialog : public QQuickAbstractFileDialog ...@@ -56,6 +56,7 @@ class QQuickPlatformFileDialog : public QQuickAbstractFileDialog
public: public:
QQuickPlatformFileDialog(QObject *parent = 0); QQuickPlatformFileDialog(QObject *parent = 0);
virtual ~QQuickPlatformFileDialog(); virtual ~QQuickPlatformFileDialog();
virtual void setModality(Qt::WindowModality m) Q_DECL_OVERRIDE;
protected: protected:
QPlatformFileDialogHelper *helper(); QPlatformFileDialogHelper *helper();
......
...@@ -124,7 +124,11 @@ void tst_dialogs::fileDialogNonModal() ...@@ -124,7 +124,11 @@ void tst_dialogs::fileDialogNonModal()
QTest::mouseClick(window, Qt::LeftButton, 0, QPoint(1000, 100)); // hide QTest::mouseClick(window, Qt::LeftButton, 0, QPoint(1000, 100)); // hide
QTRY_VERIFY(spyVisibilityChanged.count() > visibilityChangedCount); QTRY_VERIFY(spyVisibilityChanged.count() > visibilityChangedCount);
QCOMPARE(dlg->property("visible").toBool(), false); 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); QCOMPARE(dlg->property("modality").toInt(), (int)Qt::NonModal);
#endif
} }
void tst_dialogs::fileDialogNameFilters() void tst_dialogs::fileDialogNameFilters()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment