Commit ed0d6968 authored by Karel Slaný's avatar Karel Slaný

Minor adjustments in file dialogue code.

parent 6f8c4907
......@@ -43,8 +43,8 @@ Dialog {
}
AccessibleButton {
text: qsTr("OK")
enabled: (onlyDir || selectedFileIndex != -1)
visible: (onlyDir || selectedFileIndex != -1)
enabled: ((root.showDirs && !root.showFiles) || (selectedFileIndex != -1))
visible: ((root.showDirs && !root.showFiles) || (selectedFileIndex != -1))
DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole
}
}
......@@ -60,15 +60,19 @@ Dialog {
property bool multiSelect: false
property int selectedFileIndex: -1
property bool onlyDir: false
property bool showDirs: true
property bool showFiles: true
signal finished(variant pathListModel)
function directoryOnly() {
return (root.showDirs && !root.showFiles);
}
function raise(title, filters, showFiles) {
root.title = title
folderModel.folder = folderModel.folder
folderModel.showFiles = showFiles
onlyDir = !showFiles
root.showFiles = showFiles
if (filters !== "") {
folderModel.nameFilters = [filters]
}
......@@ -79,7 +83,7 @@ Dialog {
for (fileList.currentIndex = 0; fileList.currentIndex < fileList.count; ++fileList.currentIndex) {
fileList.currentItem.color = datovkaPalette.window
}
if (onlyDir) {
if (directoryOnly()) {
var path = stripUrlPrefix(folderModel.folder)
pathListModel.clear()
pathListModel.append({path: path})
......@@ -192,6 +196,8 @@ Dialog {
Layout.fillWidth: true
FolderListModel {
id: folderModel
showDirs: root.showDirs
showFiles: root.showFiles
showDirsFirst: true
nameFilters: ["*.*"]
folder: standardLocationUrl(InteractionFilesystem.DESKTOP_LOCATION)
......@@ -248,7 +254,7 @@ Dialog {
if (fileIsDir) {
/* Navigate to selected directory. */
folderModel.folder = fileURL
if (onlyDir) {
if (directoryOnly()) {
pathListModel.clear()
path = stripUrlPrefix(folderModel.folder)
pathListModel.append({path: path})
......
Markdown is supported
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