Warning, /plasma/plasma-desktop/kcms/desktoppaths/ui/main.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2023 Fushan Wen <qydwhotmail@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 import QtQuick 2.15 0008 import QtQuick.Layouts 0009 import QtQuick.Controls as QQC2 0010 import org.kde.kirigami 2.20 as Kirigami 0011 import org.kde.kcmutils as KCM 0012 0013 KCM.SimpleKCM { 0014 id: root 0015 0016 KCM.ConfigModule.buttons: KCM.ConfigModule.Default | KCM.ConfigModule.Apply 0017 0018 implicitWidth: Kirigami.Units.gridUnit * 30 0019 implicitHeight: Kirigami.Units.gridUnit * 20 0020 0021 // FIXME: get actual scrollbar width, 0022 // don't assume gridUnit is right 0023 readonly property int availableSpace: root.width - (__flickableOverflows ? Kirigami.Units.gridUnit : 0) 0024 - buttonMetrics.implicitWidth 0025 - desktop.spacing 0026 - leftPadding 0027 - rightPadding 0028 0029 readonly property int commonFieldWidth: Math.min(availableSpace, 0030 Math.max(desktop.implicitTextFieldWidth, 0031 documents.implicitTextFieldWidth, 0032 downloads.implicitTextFieldWidth, 0033 videos.implicitTextFieldWidth, 0034 pictures.implicitTextFieldWidth, 0035 music.implicitTextFieldWidth, 0036 publicPath.implicitTextFieldWidth, 0037 templates.implicitTextFieldWidth)) 0038 0039 // Need to get the width of a standard button since UrlRequester includes one, 0040 // so we can subtract it from the available width for the text field.Otherwise 0041 // the layout overflows in FormLayout's narrow mode 0042 QQC2.Button { 0043 id: buttonMetrics 0044 visible: false 0045 icon.name: "document-open" 0046 } 0047 0048 Kirigami.FormLayout { 0049 UrlRequester { 0050 id: desktop 0051 0052 Kirigami.FormData.label: i18n("Desktop path:") 0053 0054 textFieldWidth: root.commonFieldWidth 0055 0056 location: kcm.settings.desktopLocation 0057 defaultLocation: kcm.settings.defaultDesktopLocation 0058 Accessible.description: i18n("This folder contains all the files which you see on your desktop. You can change the location of this folder if you want to, and the contents will move automatically to the new location as well.") 0059 0060 onNewLocationSelected: (newLocation) => kcm.settings.desktopLocation = newLocation 0061 } 0062 0063 UrlRequester { 0064 id: documents 0065 0066 Kirigami.FormData.label: i18n("Documents path:") 0067 0068 textFieldWidth: root.commonFieldWidth 0069 0070 location: kcm.settings.documentsLocation 0071 defaultLocation: kcm.settings.defaultDocumentsLocation 0072 Accessible.description: i18n("This folder will be used by default to load or save documents from or to.") 0073 0074 onNewLocationSelected: (newLocation) => kcm.settings.documentsLocation = newLocation 0075 } 0076 0077 UrlRequester { 0078 id: downloads 0079 0080 Kirigami.FormData.label: i18n("Downloads path:") 0081 0082 textFieldWidth: root.commonFieldWidth 0083 0084 location: kcm.settings.downloadsLocation 0085 defaultLocation: kcm.settings.defaultDownloadsLocation 0086 Accessible.description: i18n("This folder will be used by default to save your downloaded items.") 0087 0088 onNewLocationSelected: (newLocation) => kcm.settings.downloadsLocation = newLocation 0089 } 0090 0091 UrlRequester { 0092 id: videos 0093 0094 Kirigami.FormData.label: i18n("Videos path:") 0095 0096 textFieldWidth: root.commonFieldWidth 0097 0098 location: kcm.settings.videosLocation 0099 defaultLocation: kcm.settings.defaultVideosLocation 0100 Accessible.description: i18n("This folder will be used by default to load or save movies from or to.") 0101 0102 onNewLocationSelected: (newLocation) => kcm.settings.videosLocation = newLocation 0103 } 0104 0105 UrlRequester { 0106 id: pictures 0107 0108 Kirigami.FormData.label: i18n("Pictures path:") 0109 0110 textFieldWidth: root.commonFieldWidth 0111 0112 location: kcm.settings.picturesLocation 0113 defaultLocation: kcm.settings.defaultPicturesLocation 0114 Accessible.description: i18n("This folder will be used by default to load or save pictures from or to.") 0115 0116 onNewLocationSelected: (newLocation) => kcm.settings.picturesLocation = newLocation 0117 } 0118 0119 UrlRequester { 0120 id: music 0121 0122 Kirigami.FormData.label: i18n("Music path:") 0123 0124 textFieldWidth: root.commonFieldWidth 0125 0126 location: kcm.settings.musicLocation 0127 defaultLocation: kcm.settings.defaultMusicLocation 0128 Accessible.description: i18n("This folder will be used by default to load or save music from or to.") 0129 0130 onNewLocationSelected: (newLocation) => kcm.settings.musicLocation = newLocation 0131 } 0132 0133 UrlRequester { 0134 id: publicPath 0135 0136 Kirigami.FormData.label: i18n("Public path:") 0137 0138 textFieldWidth: root.commonFieldWidth 0139 0140 location: kcm.settings.publicLocation 0141 defaultLocation: kcm.settings.defaultPublicLocation 0142 Accessible.description: i18n("This folder will be used by default to load or save movies from or to.") 0143 0144 onNewLocationSelected: (newLocation) => kcm.settings.publicLocation = newLocation 0145 } 0146 0147 UrlRequester { 0148 id: templates 0149 0150 Kirigami.FormData.label: i18n("Templates path:") 0151 0152 textFieldWidth: root.commonFieldWidth 0153 0154 location: kcm.settings.templatesLocation 0155 defaultLocation: kcm.settings.defaultTemplatesLocation 0156 Accessible.description: i18n("This folder will be used by default to load or save templates from or to.") 0157 0158 onNewLocationSelected: (newLocation) => kcm.settings.templatesLocation = newLocation 0159 } 0160 } 0161 }