KNewStuff

ThumbDelegate.qml
1 /*
2  SPDX-FileCopyrightText: 2019 Dan Leinir Turthra Jensen <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6 
7 import QtQuick 2.11
8 import QtQuick.Controls 2.11 as QtControls
9 import QtQuick.Layouts 1.11 as QtLayouts
10 import QtGraphicalEffects 1.11 as QtEffects
11 
12 import org.kde.kcm 1.2 as KCM
13 import org.kde.kirigami 2.7 as Kirigami
14 
15 import org.kde.newstuff 1.62 as NewStuff
16 
17 import ".." as Private
18 
19 KCM.GridDelegate {
20  id: component
21  property string useLabel
22  property string uninstallLabel
23  text: model.name
24 // onClicked: pageStack.push(detailsPage, {
25 // name: model.name,
26 // author: model.author,
27 // previews: model.previews,
28 // shortSummary: model.shortSummary,
29 // summary: model.summary,
30 // homepage: model.homepage,
31 // donationLink: model.donationLink
32 // });
33  actions: [
34  Kirigami.Action {
35  text: component.useLabel
36  iconName: "dialog-ok-apply"
37  onTriggered: { newStuffModel.adoptItem(model.index); }
38  enabled: (model.status == NewStuff.ItemsModel.InstalledStatus || model.status == NewStuff.ItemsModel.UpdateableStatus) && newStuffEngine.hasAdoptionCommand
39  visible: enabled
40  },
41  Kirigami.Action {
42  text: model.downloadLinks.length === 1 ? i18ndc("knewstuff5", "Request installation of this item, available when there is exactly one downloadable item", "Install") : i18ndc("knewstuff5", "Show installation options, where there is more than one downloadable item", "Install...");
43  iconName: "install"
44  onTriggered: {
45  if (model.downloadLinks.length === 1) {
46  newStuffModel.installItem(model.index, NewStuff.ItemsModel.FirstLinkId);
47  } else {
48  downloadItemsSheet.downloadLinks = model.downloadLinks;
49  downloadItemsSheet.entryId = model.index;
50  downloadItemsSheet.open();
51  }
52  }
53  enabled: model.status == NewStuff.ItemsModel.DownloadableStatus || model.status == NewStuff.ItemsModel.DeletedStatus;
54  visible: enabled;
55  },
56  Kirigami.Action {
57  text: i18ndc("knewstuff5", "Request updating of this item", "Update");
58  iconName: "update-none"
59  onTriggered: { newStuffModel.updateItem(model.index); }
60  enabled: model.status == NewStuff.ItemsModel.UpdateableStatus;
61  visible: enabled;
62  },
63  Kirigami.Action {
64  text: component.uninstallLabel
65  iconName: "edit-delete"
66  onTriggered: { newStuffModel.uninstallItem(model.index); }
67  enabled: model.status == NewStuff.ItemsModel.InstalledStatus || model.status == NewStuff.ItemsModel.UpdateableStatus
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 {
81  id: updateAvailableBadge;
82  opacity: (model.status == NewStuff.ItemsModel.UpdateableStatus) ? 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  }
93  Kirigami.Icon {
94  id: installedBadge;
95  opacity: (model.status == NewStuff.ItemsModel.InstalledStatus) ? 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: pageStack.push(detailsPage, {
114  newStuffModel: component.GridView.view.model,
115  index: model.index,
116  name: model.name,
117  author: model.author,
118  previews: model.previews,
119  shortSummary: model.shortSummary,
120  summary: model.summary,
121  homepage: model.homepage,
122  donationLink: model.donationLink,
123  status: model.status,
124  commentsCount: model.numberOfComments,
125  rating: model.rating,
126  downloadCount: model.downloadCount,
127  downloadLinks: model.downloadLinks,
128  providerId: model.providerId
129  });
130  }
131  }
132 }
QString name(const QVariant &location)
QTextStream & right(QTextStream &stream)
QString i18ndc(const char *domain, const char *context, const char *text, const TYPE &arg...)
QTextStream & right(QTextStream &s)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Jan 18 2021 22:43:50 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.