KNewStuff

ThumbDelegate.qml
1 /*
2  * Copyright (C) 2019 Dan Leinir Turthra Jensen <[email protected]>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) version 3, or any
8  * later version accepted by the membership of KDE e.V. (or its
9  * successor approved by the membership of KDE e.V.), which shall
10  * act as a proxy defined in Section 6 of version 3 of the license.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 import QtQuick 2.11
23 import QtQuick.Controls 2.11 as QtControls
24 import QtQuick.Layouts 1.11 as QtLayouts
25 import QtGraphicalEffects 1.11 as QtEffects
26 
27 import org.kde.kcm 1.2 as KCM
28 import org.kde.kirigami 2.7 as Kirigami
29 
30 import org.kde.newstuff 1.62 as NewStuff
31 
32 import ".." as Private
33 
34 KCM.GridDelegate {
35  id: component
36  property string useLabel
37  property string uninstallLabel
38  text: model.name
39 // onClicked: pageStack.push(detailsPage, {
40 // name: model.name,
41 // author: model.author,
42 // previews: model.previews,
43 // shortSummary: model.shortSummary,
44 // summary: model.summary,
45 // homepage: model.homepage,
46 // donationLink: model.donationLink
47 // });
48  actions: [
49  Kirigami.Action {
50  text: component.useLabel
51  iconName: "dialog-ok-apply"
52  onTriggered: { model.adoptItem(model.index); }
53  enabled: (model.status == NewStuff.ItemsModel.InstalledStatus || model.status == NewStuff.ItemsModel.UpdateableStatus) && newStuffEngine.hasAdoptionCommand
54  visible: enabled
55  },
56  Kirigami.Action {
57  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...");
58  iconName: "install"
59  onTriggered: {
60  if (model.downloadLinks.length === 1) {
61  newStuffModel.installItem(model.index, NewStuff.ItemsModel.FirstLinkId);
62  } else {
63  downloadItemsSheet.downloadLinks = model.downloadLinks;
64  downloadItemsSheet.entryId = model.index;
65  downloadItemsSheet.open();
66  }
67  }
68  enabled: model.status == NewStuff.ItemsModel.DownloadableStatus || model.status == NewStuff.ItemsModel.DeletedStatus;
69  visible: enabled;
70  },
71  Kirigami.Action {
72  text: i18ndc("knewstuff5", "Request updating of this item", "Update");
73  iconName: "update-none"
74  onTriggered: { newStuffModel.updateItem(model.index); }
75  enabled: model.status == NewStuff.ItemsModel.UpdateableStatus;
76  visible: enabled;
77  },
78  Kirigami.Action {
79  text: component.uninstallLabel
80  iconName: "edit-delete"
81  onTriggered: { newStuffModel.uninstallItem(model.index); }
82  enabled: model.status == NewStuff.ItemsModel.InstalledStatus || model.status == NewStuff.ItemsModel.UpdateableStatus
83  visible: enabled;
84  }
85  ]
86  thumbnailAvailable: model.previewsSmall.length > 0
87  thumbnail: Image {
88  anchors {
89  fill: parent;
90  margins: Kirigami.Units.smallSpacing;
91  }
92  asynchronous: true;
93  fillMode: Image.PreserveAspectFit;
94  source: thumbnailAvailable ? model.previewsSmall[0] : "";
95  Kirigami.Icon {
96  id: updateAvailableBadge;
97  opacity: (model.status == NewStuff.ItemsModel.UpdateableStatus) ? 1 : 0;
98  Behavior on opacity { NumberAnimation { duration: Kirigami.Units.shortDuration; } }
99  anchors {
100  top: parent.top;
101  right: parent.right;
102  margins: -Kirigami.Units.smallSpacing;
103  }
104  height: Kirigami.Units.iconSizes.smallMedium;
105  width: height;
106  source: "package-installed-outdated";
107  }
108  Kirigami.Icon {
109  id: installedBadge;
110  opacity: (model.status == NewStuff.ItemsModel.InstalledStatus) ? 1 : 0;
111  Behavior on opacity { NumberAnimation { duration: Kirigami.Units.shortDuration; } }
112  anchors {
113  top: parent.top;
114  right: parent.right;
115  margins: -Kirigami.Units.smallSpacing;
116  }
117  height: Kirigami.Units.iconSizes.smallMedium;
118  width: height;
119  source: "package-installed-updated";
120  }
121  FeedbackOverlay {
122  anchors.fill: parent
123  newStuffModel: component.GridView.view.model
124  }
125  MouseArea {
126  anchors.fill: parent;
127  cursorShape: Qt.PointingHandCursor;
128  onClicked: pageStack.push(detailsPage, {
129  newStuffModel: component.GridView.view.model,
130  index: model.index,
131  name: model.name,
132  author: model.author,
133  previews: model.previews,
134  shortSummary: model.shortSummary,
135  summary: model.summary,
136  homepage: model.homepage,
137  donationLink: model.donationLink,
138  status: model.status,
139  commentsCount: model.numberOfComments,
140  rating: model.rating,
141  downloadCount: model.downloadCount,
142  downloadLinks: model.downloadLinks,
143  providerId: model.providerId
144  });
145  }
146  }
147 }
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-2020 The KDE developers.
Generated on Sun Aug 9 2020 22:43:40 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.