summaryrefslogtreecommitdiff
path: root/src/dialogs
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-10-05 14:42:44 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-10-07 12:49:03 +0000
commit768f70e05ff4d8521f439d1e9410750bdf98b584 (patch)
tree23ad950e1b09ae601b8aed2198b5b535c4ddb339 /src/dialogs
parentb0e16bdd187848df082c7d895f2ca5e78b6f6738 (diff)
downloadqtquickcontrols-768f70e05ff4d8521f439d1e9410750bdf98b584.tar.gz
Make FileDialog remember the folder
Task-number: QTBUG-54310 Change-Id: I9beef4d983c5fcea4e969cae5090686dfc1d37c6 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/dialogs')
-rw-r--r--src/dialogs/qquickabstractfiledialog.cpp16
-rw-r--r--src/dialogs/qquickabstractfiledialog_p.h3
-rw-r--r--src/dialogs/qquickplatformfiledialog.cpp2
3 files changed, 18 insertions, 3 deletions
diff --git a/src/dialogs/qquickabstractfiledialog.cpp b/src/dialogs/qquickabstractfiledialog.cpp
index 26c7218b..4f0cdb9a 100644
--- a/src/dialogs/qquickabstractfiledialog.cpp
+++ b/src/dialogs/qquickabstractfiledialog.cpp
@@ -112,20 +112,32 @@ QUrl QQuickAbstractFileDialog::folder() const
return m_options->initialDirectory();
}
-void QQuickAbstractFileDialog::setFolder(const QUrl &f)
+static QUrl fixupFolder(const QUrl &f)
{
QString lf = f.toLocalFile();
while (lf.startsWith("//"))
lf.remove(0, 1);
if (lf.isEmpty())
lf = QDir::currentPath();
- QUrl u = QUrl::fromLocalFile(lf);
+ return QUrl::fromLocalFile(lf);
+}
+
+void QQuickAbstractFileDialog::setFolder(const QUrl &f)
+{
+ QUrl u = fixupFolder(f);
if (m_dlgHelper)
m_dlgHelper->setDirectory(u);
m_options->setInitialDirectory(u);
emit folderChanged();
}
+void QQuickAbstractFileDialog::updateFolder(const QUrl &f)
+{
+ QUrl u = fixupFolder(f);
+ m_options->setInitialDirectory(u);
+ emit folderChanged();
+}
+
void QQuickAbstractFileDialog::setNameFilters(const QStringList &f)
{
m_options->setNameFilters(f);
diff --git a/src/dialogs/qquickabstractfiledialog_p.h b/src/dialogs/qquickabstractfiledialog_p.h
index 8f094783..f6796d73 100644
--- a/src/dialogs/qquickabstractfiledialog_p.h
+++ b/src/dialogs/qquickabstractfiledialog_p.h
@@ -114,6 +114,9 @@ Q_SIGNALS:
void sidebarVisibleChanged();
void shortcutsChanged();
+protected Q_SLOTS:
+ void updateFolder(const QUrl &f);
+
protected:
void updateModes();
void addShortcut(const QString &name, const QString &visibleName, const QString &path);
diff --git a/src/dialogs/qquickplatformfiledialog.cpp b/src/dialogs/qquickplatformfiledialog.cpp
index 2f200b80..aff0a694 100644
--- a/src/dialogs/qquickplatformfiledialog.cpp
+++ b/src/dialogs/qquickplatformfiledialog.cpp
@@ -210,7 +210,7 @@ QPlatformFileDialogHelper *QQuickPlatformFileDialog::helper()
if (!m_dlgHelper)
return m_dlgHelper;
m_dlgHelper->setOptions(m_options);
- connect(m_dlgHelper, SIGNAL(directoryEntered(QUrl)), this, SIGNAL(folderChanged()));
+ connect(m_dlgHelper, SIGNAL(directoryEntered(QUrl)), this, SLOT(updateFolder(QUrl)));
connect(m_dlgHelper, SIGNAL(filterSelected(QString)), this, SIGNAL(filterSelected()));
connect(m_dlgHelper, SIGNAL(accept()), this, SLOT(accept()));
connect(m_dlgHelper, SIGNAL(reject()), this, SLOT(reject()));