Warning, /frameworks/kcmutils/src/qml/components/PluginDelegate.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2022 Alexander Lohnau <alexander.lohnau@gmx.de>
0003     SPDX-FileCopyrightText: 2023 ivan tkachenko <me@ratijas.tk>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 pragma ComponentBehavior: Bound
0009 
0010 import QtQuick
0011 import QtQuick.Controls as QQC2
0012 import QtQuick.Layouts
0013 import QtQuick.Templates as T
0014 
0015 import org.kde.kirigami as Kirigami
0016 import org.kde.kcmutils as KCM
0017 
0018 /// @since 6.0, this got renamed from KPluginDelegate to PluginDelegate
0019 Kirigami.CheckSubtitleDelegate {
0020     id: listItem
0021 
0022     // Note: when PluginDelegate is embedded in a more complex delegate, model
0023     // object should be passed down explicitly, but it also means that it may
0024     // become null right before delegate's destruction.
0025     required property var model
0026 
0027     property list<T.Action> additionalActions
0028 
0029     property alias leading: leadingProxy.target
0030 
0031     readonly property bool enabledByDefault: model?.enabledByDefault ?? false
0032     readonly property var metaData: model?.metaData
0033     readonly property bool configureVisible: model?.config.isValid ?? false
0034 
0035     signal configTriggered()
0036 
0037     // Let Optional chaining (?.) operator fall back to `undefined` which resets the width to an implicit value.
0038     width: ListView.view?.width
0039 
0040     icon.name: model?.icon ?? ""
0041     text: model?.name ?? ""
0042     subtitle: model?.description ?? ""
0043     checked: model?.enabled ?? false
0044 
0045     // TODO: It should be possible to disable this
0046     onToggled: model.enabled = checked
0047 
0048     contentItem: RowLayout {
0049         spacing: Kirigami.Units.smallSpacing
0050 
0051         // Used by CheckSubtitleDelegate through duck-typing
0052         readonly property alias truncated: titleSubtitle.truncated
0053 
0054         LayoutItemProxy {
0055             id: leadingProxy
0056             visible: target !== null
0057         }
0058 
0059         Kirigami.IconTitleSubtitle {
0060             id: titleSubtitle
0061 
0062             Layout.fillWidth: true
0063             Layout.maximumWidth: Math.ceil(implicitWidth)
0064 
0065             icon: icon.fromControlsIcon(listItem.icon)
0066             title: listItem.text
0067             subtitle: listItem.subtitle
0068             reserveSpaceForSubtitle: true
0069         }
0070 
0071         Kirigami.ActionToolBar {
0072             Layout.fillWidth: true
0073             Layout.alignment: Qt.AlignRight
0074             alignment: Qt.AlignRight
0075             actions: [infoAction, configureAction, ...listItem.additionalActions]
0076         }
0077     }
0078 
0079     KCM.SettingHighlighter {
0080         target: listItem.indicator
0081         highlight: listItem.checked !== listItem.enabledByDefault
0082     }
0083 
0084     // Take care of displaying the actions
0085     readonly property Kirigami.Action __infoAction: Kirigami.Action {
0086         id: infoAction
0087 
0088         icon.name: "dialog-information"
0089         text: i18nc("@info:tooltip", "About")
0090         displayHint: Kirigami.DisplayHint.IconOnly
0091         onTriggered: {
0092             const aboutDialog = (listItem.ListView.view ?? listItem.parent.ListView.view).__aboutDialog;
0093             aboutDialog.metaDataInfo = listItem.metaData;
0094             aboutDialog.open();
0095         }
0096     }
0097 
0098     readonly property Kirigami.Action __configureAction: Kirigami.Action {
0099         id: configureAction
0100 
0101         visible: listItem.configureVisible
0102         enabled: listItem.checked
0103         icon.name: "configure"
0104         text: i18nc("@info:tooltip", "Configureā€¦")
0105         displayHint: Kirigami.DisplayHint.IconOnly
0106         onTriggered: listItem.configTriggered()
0107     }
0108 }