Warning, /plasma/xdg-desktop-portal-kde/src/kirigami-filepicker/declarative/FilePickerWindow.qml is written in an unsupported language. File is not indexed.

0001 // SPDX-FileCopyrightText: 2019-2020 Jonah BrĂ¼chert <jbb@kaidan.im>
0002 // SPDX-FileCopyrightText: 2019 Linus Jahn <lnj@kaidan.im>
0003 //
0004 // SPDX-License-Identifier: LGPL-2.0-or-later
0005 
0006 import QtQuick
0007 import QtQuick.Controls as QQC2
0008 import QtQuick.Layouts
0009 import org.kde.kirigami as Kirigami
0010 import org.kde.kirigamifilepicker
0011 
0012 /**
0013  * The FilePickerWindow type is used by the C++ MobileFileDialog class.
0014  * It should not be used from QML,
0015  * its only purpose is to create an integration with C++ using its FileChooserCallback.
0016  */
0017 Kirigami.ApplicationWindow {
0018     id: root
0019 
0020     title: callback.title
0021     visible: false
0022 
0023     globalDrawer: PlacesGlobalDrawer {
0024         onPlaceOpenRequested: {
0025             filePicker.folder = place;
0026             close()
0027         }
0028     }
0029 
0030     contextDrawer: Kirigami.ContextDrawer {}
0031 
0032     onVisibleChanged: {
0033         // File picker was opened
0034         if (root.visible) {
0035             // reset old data
0036             filePicker.fileUrls = []
0037         }
0038     }
0039 
0040     onClosing: close => {
0041         close.accepted = false
0042 
0043         // Always make sure to exit the while loop in the filechooser portal
0044         callback.cancel()
0045         close.accepted = true
0046     }
0047 
0048     FileChooserCallback {
0049         id: callback
0050         objectName: "callback"
0051 
0052         Component.onCompleted: console.log(JSON.stringify(callback))
0053     }
0054 
0055     pageStack.initialPage: FilePicker {
0056         id: filePicker
0057 
0058         actions: [
0059             Kirigami.Action {
0060                 icon.name: "folder"
0061                 text: i18n("Create Folder")
0062                 visible: !root.selectExisting
0063 
0064                 onTriggered: filePicker.createDirectorySheet.open()
0065             },
0066             Kirigami.Action {
0067                 id: filterAction
0068                 icon.name: "view-filter"
0069                 checkable: true
0070                 checked: true
0071                 text: i18n("Filter Filetype")
0072             },
0073             Kirigami.Action {
0074                 icon.name: "view-hidden"
0075                 text: i18n("Show Hidden Files")
0076                 checkable: true
0077                 checked: filePicker.showHiddenFiles
0078 
0079                 onToggled: filePicker.showHiddenFiles = checked
0080             }
0081         ]
0082 
0083         onAccepted: urls => {
0084             callback.accepted(urls)
0085         }
0086 
0087         selectMultiple: callback.selectMultiple
0088         selectExisting: callback.selectExisting
0089         nameFilters: callback.nameFilters
0090         mimeTypeFilters: filterAction.checked ? callback.mimeTypeFilters : undefined
0091         currentFile: callback.currentFile
0092         acceptLabel: callback.acceptLabel
0093         selectFolder: callback.selectFolder
0094         folder: callback.folder
0095         title: callback.title
0096     }
0097 }