Warning, /plasma/discover/libdiscover/backends/PackageKitBackend/qml/DependenciesButton.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  *   SPDX-FileCopyrightText: 2018 Aleix Pol Gonzalez <aleixpol@blue-systems.com>
0003  *   SPDX-FileCopyrightText: 2022 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.Templates as T
0012 import org.kde.discover as Discover
0013 import org.kde.kirigami as Kirigami
0014 import org.kde.kirigami.delegates as KD
0015 
0016 Kirigami.LinkButton {
0017     id: root
0018 
0019     required property Discover.AbstractResource resource
0020 
0021     property Kirigami.OverlaySheet __overlay
0022 
0023     function __open() {
0024         if (!__overlay) {
0025             __overlay = overlaySheetComponent.createObject(this);
0026         }
0027         __overlay.open();
0028     }
0029 
0030     text: i18nd("libdiscover", "Show Dependencies…")
0031 
0032     visible: dependenciesModel.count > 0
0033 
0034     onClicked: __open()
0035 
0036     Connections {
0037         target: root.resource
0038         function onDependenciesFound(dependencies) {
0039             dependenciesModel.clear()
0040             for (const dependency of dependencies) {
0041                 dependenciesModel.append(dependency)
0042             }
0043         }
0044     }
0045 
0046     ListModel {
0047         id: dependenciesModel
0048     }
0049 
0050     Component {
0051         id: overlaySheetComponent
0052 
0053         Kirigami.OverlaySheet {
0054             parent: root.T.Overlay.overlay
0055 
0056             title: i18nd("libdiscover", "Dependencies for package: %1", root.resource.packageName)
0057 
0058             focus: true
0059 
0060             ListView {
0061                 id: view
0062 
0063                 implicitWidth: Kirigami.Units.gridUnit * 26
0064 
0065                 // During initialization and initial section and row delegates
0066                 // creation, contentHeight may vary wildly. And it is also a
0067                 // subject to changes when scrolling away from a
0068                 // differently-sized section delegate. Meanwhile, if the
0069                 // height changes, the ListView would reset scroll position
0070                 // to top, which is not only inconvenient but also in turn
0071                 // affects contentHeight estimations again. So we only let it
0072                 // bind until Component.completed hook: since the list isn't
0073                 // expected to change at runtime, we should not worry about
0074                 // layout size changes on the fly.
0075                 implicitHeight: contentHeight
0076 
0077                 Component.onCompleted: {
0078                     // Break the binding
0079                     implicitHeight = implicitHeight;
0080                 }
0081 
0082                 model: dependenciesModel
0083 
0084                 section.property: "packageInfo"
0085                 section.delegate: Kirigami.ListSectionHeader {
0086                     required property string section
0087 
0088                     width: ListView.view.width
0089                     text: section
0090                 }
0091 
0092                 delegate: KD.SubtitleDelegate {
0093                     required property string packageName
0094                     required property string packageDescription
0095 
0096                     width: ListView.view.width
0097                     icon.width: 0
0098 
0099                     text: packageName
0100                     subtitle: packageDescription
0101 
0102                     // No need to offer a hover/selection effect since these list
0103                     // items are non-interactive and non-selectable
0104                     hoverEnabled: false
0105                     down: false
0106                 }
0107             }
0108         }
0109     }
0110 }