diff --git a/src/dialogs/DefaultFileDialog.qml b/src/dialogs/DefaultFileDialog.qml index 99623d62691e9e94daff7bb5b0013c8a75707ced..7cd87bc9948109031d75d971a4a519c40af1de7f 100644 --- a/src/dialogs/DefaultFileDialog.qml +++ b/src/dialogs/DefaultFileDialog.qml @@ -316,13 +316,14 @@ AbstractFileDialog { sortReversed: view.sortIndicatorOrder === Qt.DescendingOrder } - onActivated: { - if (view.model.isFolder(row)) { + onActivated: if (view.focus) { + if (view.selection.count > 0 && view.model.isFolder(row)) { dirDown(view.model.get(row, "filePath")) } else { root.acceptSelection() } } + onClicked: currentPathField.text = view.model.get(row, "filePath") TableViewColumn { @@ -398,13 +399,14 @@ AbstractFileDialog { TextField { id: currentPathField Layout.fillWidth: true - onAccepted: { + function doAccept() { root.clearSelection() if (root.addSelection(root.pathToUrl(text))) root.accept() else root.folder = root.pathFolder(text) } + onAccepted: doAccept() } } } @@ -454,6 +456,8 @@ AbstractFileDialog { onClicked: { if (view.model.isFolder(view.currentIndex) && !selectFolder) dirDown(view.model.get(view.currentIndex, "filePath")) + else if (!(root.selectExisting)) + currentPathField.doAccept() else root.acceptSelection() } diff --git a/src/dialogs/qquickfiledialog.cpp b/src/dialogs/qquickfiledialog.cpp index 576778e10b2496b0c9a6799968689929b4175d21..8a7c3e5fbb66e70cb6f51861eac58a6efc810b94 100644 --- a/src/dialogs/qquickfiledialog.cpp +++ b/src/dialogs/qquickfiledialog.cpp @@ -176,14 +176,15 @@ void QQuickFileDialog::clearSelection() bool QQuickFileDialog::addSelection(const QUrl &path) { QFileInfo info(path.toLocalFile()); - if (info.exists() && ((info.isDir() && m_selectFolder) || !info.isDir())) { - if (m_selectFolder) - m_selections.append(pathFolder(path.toLocalFile())); - else - m_selections.append(path); - return true; - } - return false; + if (selectExisting() && !info.exists()) + return false; + if (selectFolder() != info.isDir()) + return false; + if (selectFolder()) + m_selections.append(pathFolder(path.toLocalFile())); + else + m_selections.append(path); + return true; } /*!