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

0001 // SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0002 // SPDX-FileCopyrightText: 2022 Harald Sitter <sitter@kde.org>
0003 
0004 import QtQuick
0005 import QtQuick.Layouts
0006 import QtQuick.Controls as QQC2
0007 import org.kde.kirigami as Kirigami
0008 import org.kde.plasma.workspace.dialogs as PWD
0009 import org.kde.iconthemes as KIconThemes
0010 
0011 PWD.SystemDialog {
0012     id: root
0013 
0014     property var dialog
0015     property string appID
0016     property url launcherURL: ""
0017     property bool edit: false
0018 
0019     readonly property Component displayComponent: Component {
0020         ColumnLayout {
0021             Kirigami.Icon {
0022                 id: icon
0023                 Layout.alignment: Qt.AlignHCenter
0024                 implicitWidth: Kirigami.Units.iconSizes.enormous
0025                 implicitHeight: implicitWidth
0026                 source: dialog.icon
0027             }
0028 
0029             Kirigami.Heading {
0030                 Layout.alignment: Qt.AlignHCenter
0031                 Layout.fillWidth: true
0032                 level: 3
0033                 wrapMode: Text.Wrap
0034                 text: dialog.name
0035                 verticalAlignment: Qt.AlignTop
0036             }
0037 
0038             Kirigami.LinkButton {
0039                 Layout.fillWidth: true
0040                 visible: text.length > 0
0041                 Layout.alignment: Qt.AlignHCenter
0042                 elide: Text.ElideMiddle
0043                 text: launcherURL
0044                 onClicked: Qt.openUrlExternally(launcherURL)
0045             }
0046         }
0047     }
0048 
0049     readonly property Component editComponent: Component {
0050         ColumnLayout {
0051             QQC2.Button {
0052                 Layout.alignment: Qt.AlignHCenter
0053                 contentItem: Kirigami.Icon {
0054                     id: icon
0055                     implicitHeight: implicitWidth
0056                     implicitWidth: Kirigami.Units.iconSizes.enormous
0057                     source: dialog.icon
0058 
0059                     KIconThemes.IconDialog {
0060                         id: iconDialog
0061                         onIconNameChanged: dialog.icon = iconName
0062                     }
0063 
0064                     TapHandler {
0065                         onTapped: iconDialog.open()
0066                     }
0067                 }
0068             }
0069 
0070             QQC2.Label {
0071                 text: i18nc("@label name of a launcher/application", "Name")
0072                 Layout.fillWidth: true
0073             }
0074             QQC2.TextField {
0075                 verticalAlignment: Qt.AlignTop
0076                 Layout.alignment: Qt.AlignHCenter
0077                 Layout.fillWidth: true
0078                 onTextChanged: dialog.name = text
0079                 Component.onCompleted: text = dialog.name
0080             }
0081         }
0082     }
0083 
0084     Loader {
0085         sourceComponent: root.edit ? editComponent : displayComponent
0086     }
0087 
0088     actions: [
0089         Kirigami.Action {
0090             text: i18nc("@action edit launcher name/icon", "Edit Info…")
0091             icon.name: "document-edit"
0092             onCheckedChanged: root.edit = checked
0093             checkable: true
0094         },
0095         Kirigami.Action {
0096             text: i18nc("@action accept dialog and create launcher", "Accept")
0097             icon.name: "dialog-ok"
0098             onTriggered: accept()
0099         },
0100         Kirigami.Action {
0101             text: i18nc("@action", "Cancel")
0102             icon.name: "dialog-cancel"
0103             onTriggered: reject()
0104         }
0105     ]
0106 }