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

KDE's Doxygen guidelines are available online.