Warning, /plasma/kdeplasma-addons/applets/mediaframe/package/contents/ui/ConfigPaths.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * SPDX-FileCopyrightText: 2015 Lars Pontoppidan <dev.larpon@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 import QtCore 0008 import QtQuick 0009 import QtQuick.Controls as QQC2 0010 import QtQuick.Dialogs 0011 import QtQuick.Layouts 0012 0013 import org.kde.plasma.plasmoid 2.0 0014 import org.kde.kirigami 2.5 as Kirigami 0015 import org.kde.kcmutils as KCM 0016 0017 KCM.ScrollViewKCM { 0018 0019 signal configurationChanged 0020 0021 property var cfg_pathList: [] 0022 0023 function addPath(object) { 0024 pathModel.append( object ) 0025 cfg_pathList.push( JSON.stringify(object) ) 0026 configurationChanged(); 0027 } 0028 0029 function removePath(index) { 0030 if(pathModel.count > 0) { 0031 pathModel.remove(index) 0032 cfg_pathList.splice(index,1) 0033 configurationChanged(); 0034 } 0035 } 0036 0037 Component.onCompleted: { 0038 // Load the list back in 0039 var list = plasmoid.configuration.pathList 0040 cfg_pathList = [] 0041 for(var i in list) { 0042 addPath( JSON.parse(list[i]) ) 0043 } 0044 } 0045 0046 view: ListView { 0047 id: pathsList 0048 0049 model: ListModel { 0050 id: pathModel 0051 } 0052 0053 delegate: Kirigami.SwipeListItem { 0054 id: folderDelegate 0055 0056 width: pathsList.width 0057 0058 contentItem: QQC2.Label { 0059 Layout.fillWidth: true 0060 text: String(model.path).replace("file://", "") 0061 textFormat: Text.PlainText 0062 } 0063 0064 actions: [ 0065 Kirigami.Action { 0066 icon.name: "list-remove" 0067 tooltip: i18nd("plasma_wallpaper_org.kde.image", "Remove path") 0068 onTriggered: removePath(model.index) 0069 } 0070 ] 0071 } 0072 0073 FileDialog { 0074 id: fileDialog 0075 0076 title: i18nc("@title:window", "Choose Files") 0077 currentFolder: StandardPaths.standardLocations(StandardPaths.PicturesLocation)[0] 0078 fileMode: FileDialog.OpenFiles 0079 0080 // TODO get valid filter list from native code? 0081 //nameFilters: [ "Image files (*.png *.jpg)", "All files (*)" ] 0082 //selectedNameFilter: "All files (*)" 0083 0084 onAccepted: { 0085 console.log("Accepted: " + selectedFiles) 0086 0087 for (var i = 0; i < selectedFiles.length; ++i) { 0088 var item = { 'path':selectedFiles[i], 'type':'file' } 0089 addPath(item) 0090 } 0091 } 0092 0093 onRejected: { 0094 console.log("Canceled") 0095 } 0096 } 0097 0098 FolderDialog { 0099 id: folderDialog 0100 0101 visible: false 0102 title: i18nc("@title:window", "Choose a Folder") 0103 currentFolder: StandardPaths.standardLocations(StandardPaths.PicturesLocation)[0] 0104 0105 onAccepted: { 0106 console.log("Accepted: " + selectedFolder) 0107 0108 var item = { 'path':selectedFolder, 'type':'folder' } 0109 addPath(item) 0110 } 0111 0112 onRejected: { 0113 console.log("Canceled") 0114 } 0115 } 0116 } 0117 0118 footer: RowLayout { 0119 QQC2.Button { 0120 icon.name: "folder-new" 0121 onClicked: folderDialog.visible = true 0122 text: i18nc("@action:button", "Add Folder…") 0123 } 0124 0125 QQC2.Button { 0126 icon.name: "document-new" 0127 onClicked: fileDialog.visible = true 0128 text: i18nc("@action:button", "Add Files…") 0129 } 0130 Item { 0131 Layout.fillWidth: true 0132 } 0133 } 0134 }