Fix usage of FileDialog.folder property in QtQuick
authorTobias Koenig <tobias.koenig@kdab.com>
Mon, 6 Jan 2014 08:45:37 +0000 (09:45 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Thu, 16 Jan 2014 18:21:17 +0000 (19:21 +0100)
The content of the FileDialog.folder property has not been applied
to the native QFileDialog, so it was not possible to pre-select a
folder for the file dialog.

Change-Id: Iaadd6aa71bc37739c16a2e7c5bff2d0050f15f3a
Task-number: QTBUG-35973
Reviewed-by: Tobias Koenig <tobias.koenig.qnx@kdab.com>
Reviewed-by: Liang Qi <liang.qi@digia.com>
src/imports/widgets/qquickqfiledialog.cpp

index c3991b4..403577f 100644 (file)
@@ -172,6 +172,10 @@ void QFileDialogHelper::setFilter() {
     m_dialog.setFileMode(QFileDialog::FileMode(QPlatformFileDialogHelper::options()->fileMode()));
     m_dialog.setOptions((QFileDialog::Options)((int)(QPlatformFileDialogHelper::options()->options())));
     m_dialog.setAcceptMode(QFileDialog::AcceptMode(QPlatformFileDialogHelper::options()->acceptMode()));
+
+    const QUrl initialDirectory = QPlatformFileDialogHelper::options()->initialDirectory();
+    if (initialDirectory.isValid() && initialDirectory.isLocalFile())
+        m_dialog.setDirectory(initialDirectory.toLocalFile());
 }
 
 bool QFileDialogHelper::show(Qt::WindowFlags f, Qt::WindowModality m, QWindow *parent) {