Warning, /plasma/plasma-desktop/kcms/desktoppaths/ui/UrlRequester.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 QtCore
0008 import QtQuick 2.15
0009 import QtQuick.Controls 2.15 as QQC2
0010 import QtQuick.Dialogs 6.3
0011 import org.kde.kirigami 2.20 as Kirigami
0012 import org.kde.kcmutils as KCM
0013
0014 Row {
0015 id: urlRequester
0016
0017 required property url location
0018 required property url defaultLocation
0019 required property int textFieldWidth
0020
0021 readonly property int implicitTextFieldWidth: metrics.width + textField.leftPadding + textField.rightPadding
0022
0023 /**
0024 * Emitted when the user selects a new folder
0025 */
0026 signal newLocationSelected(url newLocation)
0027
0028 spacing: Kirigami.Units.smallSpacing
0029
0030 TextMetrics {
0031 id: metrics
0032 text: textField.text
0033 }
0034
0035 Component {
0036 id: fileDialogComponent
0037
0038 FolderDialog {
0039 id: fileDialog
0040 currentFolder: StandardPaths.standardLocations(StandardPaths.HomeLocation)[0]
0041
0042 onAccepted: {
0043 urlRequester.newLocationSelected(selectedFolder);
0044 destroy();
0045 }
0046 onRejected: destroy()
0047 Component.onCompleted: open()
0048 }
0049 }
0050
0051 KCM.SettingHighlighter {
0052 highlight: location !== defaultLocation
0053 }
0054
0055 QQC2.TextField {
0056 id: textField
0057 width: urlRequester.textFieldWidth
0058 height: Math.max(fileDialogButton.implicitHeight, textField.implicitHeight)
0059 text: location.toString().substr(7)
0060 readOnly: true
0061
0062 Accessible.description: urlRequester.Accessible.description
0063 QQC2.ToolTip.text: urlRequester.Accessible.description
0064 QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
0065 QQC2.ToolTip.visible: textField.hovered
0066 }
0067
0068 QQC2.Button {
0069 id: fileDialogButton
0070 anchors.verticalCenter: textField.verticalCenter
0071
0072 display: QQC2.AbstractButton.IconOnly
0073 icon.name: "document-open"
0074 text: i18nc("@action:button", "Choose new location")
0075
0076 Accessible.description: text
0077 QQC2.ToolTip.text: text
0078 QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
0079 QQC2.ToolTip.visible: fileDialogButton.hovered
0080
0081 onClicked: fileDialogComponent.incubateObject(urlRequester)
0082 }
0083 }