summaryrefslogtreecommitdiffstats
path: root/src/imports/dialogs
diff options
context:
space:
mode:
Diffstat (limited to 'src/imports/dialogs')
-rw-r--r--src/imports/dialogs/DefaultFileDialog.qml17
-rw-r--r--src/imports/dialogs/plugins.qmltypes7
-rw-r--r--src/imports/dialogs/qquickabstractcolordialog.cpp2
-rw-r--r--src/imports/dialogs/qquickabstractcolordialog_p.h2
-rw-r--r--src/imports/dialogs/qquickabstractdialog_p.h2
-rw-r--r--src/imports/dialogs/qquickabstractfiledialog.cpp17
-rw-r--r--src/imports/dialogs/qquickabstractfiledialog_p.h10
-rw-r--r--src/imports/dialogs/qquickfiledialog.cpp19
-rw-r--r--src/imports/dialogs/qquickfiledialog_p.h4
-rw-r--r--src/imports/dialogs/qquickplatformfiledialog.cpp2
10 files changed, 42 insertions, 40 deletions
diff --git a/src/imports/dialogs/DefaultFileDialog.qml b/src/imports/dialogs/DefaultFileDialog.qml
index a43b493a29..2cdb34cc03 100644
--- a/src/imports/dialogs/DefaultFileDialog.qml
+++ b/src/imports/dialogs/DefaultFileDialog.qml
@@ -53,13 +53,13 @@ AbstractFileDialog {
currentPathField.visible = false
}
}
+ onFolderChanged: view.model.folder = folder
property bool showFocusHighlight: false
property real textX: titleBar.height
property SystemPalette palette
property var selectedIndices: []
property int lastClickedIdx: -1
- folder: urlToPath(view.model.folder)
function dirDown(path) {
view.model.folder = path
@@ -107,10 +107,11 @@ AbstractFileDialog {
selectedIndices.map(function(idx) {
if (view.model.isFolder(idx)) {
if (selectFolder)
- addSelection(view.model.get(idx, "filePath"))
+ // TODO after QTBUG-32039: should not need to convert pathToUrl here
+ addSelection(pathToUrl(view.model.get(idx, "filePath")))
} else {
if (!selectFolder)
- addSelection(view.model.get(idx, "filePath"))
+ addSelection(pathToUrl(view.model.get(idx, "filePath")))
}
})
}
@@ -211,7 +212,12 @@ AbstractFileDialog {
clip: true
x: 0
width: parent.width
- model: FolderListModel { }
+ model: FolderListModel {
+ onFolderChanged: {
+ root.folder = folder
+ currentPathField.text = root.urlToPath(view.model.folder)
+ }
+ }
delegate: folderDelegate
highlight: Rectangle {
color: "transparent"
@@ -305,10 +311,9 @@ AbstractFileDialog {
anchors.leftMargin: textX; anchors.rightMargin: 4
visible: false
focus: visible
- text: root.urlToPath(view.model.folder)
onAccepted: {
root.clearSelection()
- if (root.addSelection(text))
+ if (root.addSelection(root.pathToUrl(text)))
root.accept()
else
view.model.folder = root.pathFolder(text)
diff --git a/src/imports/dialogs/plugins.qmltypes b/src/imports/dialogs/plugins.qmltypes
index 80eb8bd291..4e7090b960 100644
--- a/src/imports/dialogs/plugins.qmltypes
+++ b/src/imports/dialogs/plugins.qmltypes
@@ -39,6 +39,7 @@ Module {
Property { name: "visible"; type: "bool" }
Property { name: "modality"; type: "Qt::WindowModality" }
Property { name: "title"; type: "string" }
+ Property { name: "isWindow"; type: "bool"; isReadonly: true }
Property { name: "x"; type: "int" }
Property { name: "y"; type: "int" }
Property { name: "width"; type: "int" }
@@ -56,7 +57,7 @@ Module {
Property { name: "selectExisting"; type: "bool" }
Property { name: "selectMultiple"; type: "bool" }
Property { name: "selectFolder"; type: "bool" }
- Property { name: "folder"; type: "string" }
+ Property { name: "folder"; type: "QUrl" }
Property { name: "nameFilters"; type: "QStringList" }
Property { name: "selectedNameFilter"; type: "string" }
Property { name: "fileUrl"; type: "QUrl"; isReadonly: true }
@@ -86,7 +87,7 @@ Module {
}
Method {
name: "setFolder"
- Parameter { name: "f"; type: "string" }
+ Parameter { name: "f"; type: "QUrl" }
}
Method {
name: "setNameFilters"
@@ -116,7 +117,7 @@ Module {
Method {
name: "addSelection"
type: "bool"
- Parameter { name: "path"; type: "string" }
+ Parameter { name: "path"; type: "QUrl" }
}
}
}
diff --git a/src/imports/dialogs/qquickabstractcolordialog.cpp b/src/imports/dialogs/qquickabstractcolordialog.cpp
index 9a9f3bc11b..7cfd7ea692 100644
--- a/src/imports/dialogs/qquickabstractcolordialog.cpp
+++ b/src/imports/dialogs/qquickabstractcolordialog.cpp
@@ -91,7 +91,7 @@ bool QQuickAbstractColorDialog::showAlphaChannel() const
return m_options->testOption(QColorDialogOptions::ShowAlphaChannel);
}
-void QQuickAbstractColorDialog::setTitle(QString t)
+void QQuickAbstractColorDialog::setTitle(const QString &t)
{
if (m_options->windowTitle() == t) return;
m_options->setWindowTitle(t);
diff --git a/src/imports/dialogs/qquickabstractcolordialog_p.h b/src/imports/dialogs/qquickabstractcolordialog_p.h
index 3301605c86..46f0f84acb 100644
--- a/src/imports/dialogs/qquickabstractcolordialog_p.h
+++ b/src/imports/dialogs/qquickabstractcolordialog_p.h
@@ -78,7 +78,7 @@ public:
public Q_SLOTS:
void setVisible(bool v);
void setModality(Qt::WindowModality m);
- void setTitle(QString t);
+ void setTitle(const QString &t);
void setColor(QColor arg);
void setShowAlphaChannel(bool arg);
diff --git a/src/imports/dialogs/qquickabstractdialog_p.h b/src/imports/dialogs/qquickabstractdialog_p.h
index ef20333479..5e3d9b43f7 100644
--- a/src/imports/dialogs/qquickabstractdialog_p.h
+++ b/src/imports/dialogs/qquickabstractdialog_p.h
@@ -88,7 +88,7 @@ public:
virtual void setVisible(bool v);
virtual void setModality(Qt::WindowModality m);
- virtual void setTitle(QString t) = 0;
+ virtual void setTitle(const QString &t) = 0;
void setQmlImplementation(QObject* obj);
bool isWindow() const { return m_hasNativeWindows; }
void setX(int arg);
diff --git a/src/imports/dialogs/qquickabstractfiledialog.cpp b/src/imports/dialogs/qquickabstractfiledialog.cpp
index 32442de41f..d8a75feb53 100644
--- a/src/imports/dialogs/qquickabstractfiledialog.cpp
+++ b/src/imports/dialogs/qquickabstractfiledialog.cpp
@@ -78,7 +78,7 @@ QString QQuickAbstractFileDialog::title() const
return m_options->windowTitle();
}
-void QQuickAbstractFileDialog::setTitle(QString t)
+void QQuickAbstractFileDialog::setTitle(const QString &t)
{
if (m_options->windowTitle() == t) return;
m_options->setWindowTitle(t);
@@ -106,18 +106,19 @@ void QQuickAbstractFileDialog::setSelectFolder(bool selectFolder)
updateModes();
}
-QString QQuickAbstractFileDialog::folder()
+QUrl QQuickAbstractFileDialog::folder()
{
if (m_dlgHelper && !m_dlgHelper->directory().isEmpty())
- return m_dlgHelper->directory();
- return m_options->initialDirectory();
+ return QUrl::fromLocalFile(m_dlgHelper->directory());
+ return QUrl::fromLocalFile(m_options->initialDirectory());
}
-void QQuickAbstractFileDialog::setFolder(QString f)
+void QQuickAbstractFileDialog::setFolder(const QUrl &f)
{
+ QString dir = f.path();
if (m_dlgHelper)
- m_dlgHelper->setDirectory(f);
- m_options->setInitialDirectory(f);
+ m_dlgHelper->setDirectory(dir);
+ m_options->setInitialDirectory(dir);
emit folderChanged();
}
@@ -141,7 +142,7 @@ QString QQuickAbstractFileDialog::selectedNameFilter()
return ret;
}
-void QQuickAbstractFileDialog::selectNameFilter(QString f)
+void QQuickAbstractFileDialog::selectNameFilter(const QString &f)
{
// This should work whether the dialog is currently being shown already, or ahead of time.
m_options->setInitiallySelectedNameFilter(f);
diff --git a/src/imports/dialogs/qquickabstractfiledialog_p.h b/src/imports/dialogs/qquickabstractfiledialog_p.h
index 965f1a7029..5ce48e8055 100644
--- a/src/imports/dialogs/qquickabstractfiledialog_p.h
+++ b/src/imports/dialogs/qquickabstractfiledialog_p.h
@@ -67,7 +67,7 @@ class QQuickAbstractFileDialog : public QQuickAbstractDialog
Q_PROPERTY(bool selectExisting READ selectExisting WRITE setSelectExisting NOTIFY fileModeChanged)
Q_PROPERTY(bool selectMultiple READ selectMultiple WRITE setSelectMultiple NOTIFY fileModeChanged)
Q_PROPERTY(bool selectFolder READ selectFolder WRITE setSelectFolder NOTIFY fileModeChanged)
- Q_PROPERTY(QString folder READ folder WRITE setFolder NOTIFY folderChanged)
+ Q_PROPERTY(QUrl folder READ folder WRITE setFolder NOTIFY folderChanged)
Q_PROPERTY(QStringList nameFilters READ nameFilters WRITE setNameFilters NOTIFY nameFiltersChanged)
Q_PROPERTY(QString selectedNameFilter READ selectedNameFilter WRITE selectNameFilter NOTIFY filterSelected)
Q_PROPERTY(QUrl fileUrl READ fileUrl NOTIFY selectionAccepted)
@@ -81,7 +81,7 @@ public:
bool selectExisting() const { return m_selectExisting; }
bool selectMultiple() const { return m_selectMultiple; }
bool selectFolder() const { return m_selectFolder; }
- QString folder();
+ QUrl folder();
QStringList nameFilters() const { return m_options->nameFilters(); }
QString selectedNameFilter();
QUrl fileUrl();
@@ -89,13 +89,13 @@ public:
public Q_SLOTS:
void setVisible(bool v);
- void setTitle(QString t);
+ void setTitle(const QString &t);
void setSelectExisting(bool s);
void setSelectMultiple(bool s);
void setSelectFolder(bool s);
- void setFolder(QString f);
+ void setFolder(const QUrl &f);
void setNameFilters(const QStringList &f);
- void selectNameFilter(QString f);
+ void selectNameFilter(const QString &f);
Q_SIGNALS:
void folderChanged();
diff --git a/src/imports/dialogs/qquickfiledialog.cpp b/src/imports/dialogs/qquickfiledialog.cpp
index f5d1a06d04..2ee4afc5d2 100644
--- a/src/imports/dialogs/qquickfiledialog.cpp
+++ b/src/imports/dialogs/qquickfiledialog.cpp
@@ -105,10 +105,7 @@ QQuickFileDialog::~QQuickFileDialog()
QList<QUrl> QQuickFileDialog::fileUrls()
{
- QList<QUrl> ret;
- foreach (QString path, m_selections)
- ret << QUrl::fromLocalFile(path);
- return ret;
+ return m_selections;
}
/*!
@@ -134,18 +131,16 @@ void QQuickFileDialog::clearSelection()
/*!
\brief Adds one file to \l fileUrls
- \l path should be given as an absolute file system path. If it is given as a
- file:// URL, it will be converted to a path. Returns true on success,
- false if the given path is not valid given the current setting properties.
+ \l path should be given as an absolute file:// path URL.
+ Returns true on success, false if the given path is
+ not valid given the current property settings.
*/
-bool QQuickFileDialog::addSelection(QString path)
+bool QQuickFileDialog::addSelection(const QUrl &path)
{
- if (path.startsWith("file:"))
- path = QUrl(path).toLocalFile();
- QFileInfo info(path);
+ QFileInfo info(path.toLocalFile());
if (info.exists() && ((info.isDir() && m_selectFolder) || !info.isDir())) {
if (m_selectFolder)
- m_selections.append(pathFolder(path).toLocalFile());
+ m_selections.append(pathFolder(path.toLocalFile()));
else
m_selections.append(path);
return true;
diff --git a/src/imports/dialogs/qquickfiledialog_p.h b/src/imports/dialogs/qquickfiledialog_p.h
index 93e11f9e3e..0176bc3fe4 100644
--- a/src/imports/dialogs/qquickfiledialog_p.h
+++ b/src/imports/dialogs/qquickfiledialog_p.h
@@ -72,7 +72,7 @@ signals:
public Q_SLOTS:
void clearSelection();
- bool addSelection(QString path);
+ bool addSelection(const QUrl &path);
protected:
virtual QPlatformFileDialogHelper *helper() { return 0; }
@@ -81,7 +81,7 @@ protected:
Q_INVOKABLE QUrl pathFolder(const QString &path);
private:
- QStringList m_selections;
+ QList<QUrl> m_selections;
Q_DISABLE_COPY(QQuickFileDialog)
};
diff --git a/src/imports/dialogs/qquickplatformfiledialog.cpp b/src/imports/dialogs/qquickplatformfiledialog.cpp
index ec9f935738..3da9f6c3b2 100644
--- a/src/imports/dialogs/qquickplatformfiledialog.cpp
+++ b/src/imports/dialogs/qquickplatformfiledialog.cpp
@@ -252,7 +252,7 @@ QPlatformFileDialogHelper *QQuickPlatformFileDialog::helper()
*/
/*!
- \qmlproperty string FileDialog::folder
+ \qmlproperty url FileDialog::folder
The path to the currently selected folder. Setting this property before
invoking open() will cause the file browser to be initially positioned on