Warning, /plasma/discover/discover/qml/AddonsView.qml is written in an unsupported language. File is not indexed.
0001 /*
0002 * SPDX-FileCopyrightText: 2012-2023 Aleix Pol Gonzalez <aleixpol@blue-systems.com>
0003 * SPDX-FileCopyrightText: 2020-2022 Nate Graham <nate@kde.org>
0004 * SPDX-FileCopyrightText: 2023-2024 ivan tkachenko <me@ratijas.tk>
0005 *
0006 * SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008
0009 pragma ComponentBehavior: Bound
0010
0011 import QtQuick
0012 import QtQuick.Controls as QQC2
0013 import QtQuick.Layouts
0014 import org.kde.discover as Discover
0015 import org.kde.kirigami as Kirigami
0016 import org.kde.kirigami.delegates as KD
0017
0018 Kirigami.OverlaySheet {
0019 id: root
0020
0021 property alias application: addonsModel.application
0022 property bool isInstalling: false
0023
0024 readonly property alias addonsCount: listview.count
0025 readonly property bool containsAddons: listview.count > 0 || isExtended
0026 readonly property bool isExtended: Discover.ResourcesModel.isExtended(application.appstreamId)
0027
0028 title: i18n("Addons for %1", application.name)
0029
0030 onOpened: {
0031 listview.forceActiveFocus(Qt.PopupFocusReason);
0032 }
0033
0034 ListView {
0035 id: listview
0036
0037 implicitWidth: Kirigami.Units.gridUnit * 25
0038
0039 visible: root.containsAddons
0040 enabled: !root.isInstalling
0041
0042 activeFocusOnTab: true
0043 keyNavigationEnabled: true
0044 keyNavigationWraps: false
0045
0046 model: Discover.ApplicationAddonsModel {
0047 id: addonsModel
0048 }
0049
0050 delegate: KD.CheckSubtitleDelegate {
0051 required property int index
0052 required property var model
0053
0054 width: ListView.view.width
0055
0056 enabled: !root.isInstalling
0057
0058 icon.width: 0
0059 text: model.display
0060 subtitle: model.toolTip
0061
0062 checked: model.checked
0063 highlighted: ListView.isCurrentItem
0064
0065 onToggled: {
0066 addonsModel.changeState(model.packageName, checked);
0067 ListView.view.currentIndex = index;
0068 }
0069 }
0070 }
0071
0072 footer: RowLayout {
0073 id: footer
0074
0075 spacing: Kirigami.Units.smallSpacing
0076
0077 readonly property bool active: addonsModel.hasChanges && !root.isInstalling
0078
0079 QQC2.Button {
0080 text: i18n("Moreā¦")
0081 visible: root.application.appstreamId.length > 0 && root.isExtended
0082 onClicked: Navigation.openExtends(root.application.appstreamId, root.application.name)
0083 }
0084
0085 Item { Layout.fillWidth: true }
0086
0087 QQC2.Button {
0088 icon.name: "dialog-ok"
0089 text: i18n("Apply Changes")
0090 onClicked: addonsModel.applyChanges()
0091
0092 enabled: footer.active
0093 }
0094
0095 QQC2.Button {
0096 icon.name: "document-revert"
0097 text: i18n("Reset")
0098 onClicked: addonsModel.discardChanges()
0099
0100 enabled: footer.active
0101 }
0102 }
0103 }