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

0001 /*
0002  *   SPDX-FileCopyrightText: 2018 Aleix Pol Gonzalez <aleixpol@blue-systems.com>
0003  *
0004  *   SPDX-License-Identifier: LGPL-2.0-or-later
0005  */
0006 
0007 pragma ComponentBehavior: Bound
0008 
0009 import QtQuick
0010 import QtQuick.Layouts
0011 import QtQuick.Controls as QQC2
0012 import org.kde.kirigami as Kirigami
0013 import org.kde.kirigami.delegates as KD
0014 import org.kde.discover as Discover
0015 
0016 QQC2.Button {
0017     id: root
0018 
0019     required property Discover.AbstractResource resource
0020 
0021     text: i18nd("libdiscover", "Channels…")
0022 
0023     onClicked: overlay.open()
0024     visible: resource.isInstalled /*&& view.count > 0*/
0025 
0026     Kirigami.OverlaySheet {
0027         id: overlay
0028 
0029         parent: root.QQC2.Overlay.overlay
0030         title: i18nd("libdiscover", "%1 channels", root.resource.name)
0031 
0032         ListView {
0033             id: view
0034 
0035             model: root.resource.channels(root).channels
0036             delegate: QQC2.ItemDelegate {
0037                 id: delegate
0038 
0039                 required property var modelData
0040 
0041                 readonly property bool current: root.resource.channel === modelData.name
0042 
0043                 text: i18nd("libdiscover", "%1 - %2", modelData.name, modelData.version)
0044 
0045                 contentItem: RowLayout {
0046                     spacing: Kirigami.Units.smallSpacing
0047                     KD.IconTitleSubtitle {
0048                         Layout.fillWidth: true
0049                         icon: icon.fromControlsIcon(delegate.icon)
0050                         title: delegate.text
0051                         selected: delegate.highlighted
0052                         font: delegate.font
0053                     }
0054 
0055                     QQC2.Button {
0056                         text: i18nd("libdiscover", "Switch")
0057                         enabled: !delegate.current
0058                         onClicked: root.resource.channel = delegate.modelData.name
0059                     }
0060                 }
0061             }
0062         }
0063     }
0064 }