KNewStuff

ThumbDelegate.qml
1/*
2 SPDX-FileCopyrightText: 2019 Dan Leinir Turthra Jensen <admin@leinir.dk>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7import QtQuick
8
9import org.kde.kcmutils as KCMUtils
10import org.kde.kirigami as Kirigami
11
12import org.kde.newstuff as NewStuff
13
14import ".." as Private
15
16KCMUtils.GridDelegate {
17 id: component
18
19 property string useLabel
20 property string uninstallLabel
21 property var entry: model.entry
22
23 text: model.name
24
25 actions: [
26 Kirigami.Action {
27 text: component.useLabel
28 icon.name: "dialog-ok-apply"
29 onTriggered: source => {
30 newStuffModel.engine.adoptEntry(entry);
31 }
32 enabled: (entry.status === NewStuff.Entry.Installed || entry.status === NewStuff.Entry.Updateable) && newStuffEngine.hasAdoptionCommand
33 visible: enabled
34 },
36 text: model.downloadLinks.length === 1
37 ? i18ndc("knewstuff6", "Request installation of this item, available when there is exactly one downloadable item", "Install")
38 : i18ndc("knewstuff6", "Show installation options, where there is more than one downloadable item", "Install…")
39 icon.name: "install"
40 onTriggered: source => {
41 if (model.downloadLinks.length === 1) {
42 newStuffModel.engine.install(entry, NewStuff.Entry.FirstLinkId);
43 } else {
44 downloadItemsSheet.downloadLinks = model.downloadLinks;
45 downloadItemsSheet.entry = entry;
46 downloadItemsSheet.open();
47 }
48 }
49 enabled: entry.status === NewStuff.Entry.Downloadable || entry.status === NewStuff.Entry.Deleted
50 visible: enabled
51 },
52 Kirigami.Action {
53 text: i18ndc("knewstuff6", "Request updating of this item", "Update")
54 icon.name: "update-none"
55 onTriggered: source => {
56 newStuffModel.engine.install(entry, NewStuff.ItemsModel.AutoDetectLinkId);
57 }
58 enabled: entry.status === NewStuff.Entry.Updateable
59 visible: enabled
60 },
61 Kirigami.Action {
62 text: component.uninstallLabel
63 icon.name: "edit-delete"
64 onTriggered: source => {
65 newStuffModel.engine.uninstall(entry);
66 }
67 enabled: entry.status === NewStuff.Entry.Installed || entry.status === NewStuff.Entry.Updateable
68 visible: enabled
69 }
70 ]
71 thumbnailAvailable: model.previewsSmall.length > 0
72 thumbnail: Image {
73 anchors {
74 fill: parent
75 margins: Kirigami.Units.smallSpacing
76 }
77 asynchronous: true
78 fillMode: Image.PreserveAspectFit
79 source: thumbnailAvailable ? model.previewsSmall[0] : ""
80 Kirigami.Icon {
82 opacity: (entry.status === NewStuff.Entry.Updateable) ? 1 : 0
83 Behavior on opacity { NumberAnimation { duration: Kirigami.Units.shortDuration } }
84 anchors {
85 top: parent.top
86 right: parent.right
87 margins: -Kirigami.Units.smallSpacing
88 }
89 height: Kirigami.Units.iconSizes.smallMedium
90 width: height
91 source: "package-installed-outdated"
92 }
95 opacity: (entry.status === NewStuff.Entry.Installed) ? 1 : 0
96 Behavior on opacity { NumberAnimation { duration: Kirigami.Units.shortDuration } }
97 anchors {
98 top: parent.top
99 right: parent.right
100 margins: -Kirigami.Units.smallSpacing
101 }
102 height: Kirigami.Units.iconSizes.smallMedium
103 width: height
104 source: "package-installed-updated"
105 }
106 FeedbackOverlay {
107 anchors.fill: parent
108 newStuffModel: component.GridView.view.model
109 }
110 MouseArea {
111 anchors.fill: parent
112 cursorShape: Qt.PointingHandCursor
113 onClicked: mouse => {
114 pageStack.push(detailsPage, {
115 newStuffModel: component.GridView.view.model,
116 entry: entry,
117 });
118 }
119 }
120 }
121}
Q_SCRIPTABLE CaptureState status()
QString i18ndc(const char *domain, const char *context, const char *text, const TYPE &arg...)
QString name(StandardAction id)
PointingHandCursor
QTextStream & right(QTextStream &stream)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 24 2024 11:54:38 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.