KNewStuff

EntryDetails.qml
1/*
2 SPDX-FileCopyrightText: 2019 Dan Leinir Turthra Jensen <admin@leinir.dk>
3 SPDX-FileCopyrightText: 2023 ivan tkachenko <me@ratijas.tk>
4
5 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6*/
7
8/**
9 * @brief A Kirigami.Page component used for displaying the details for a single entry
10 *
11 * This component is equivalent to the details view in the old DownloadDialog
12 * @see KNewStuff::DownloadDialog
13 * @since 5.63
14 */
15
16import QtQuick
17import QtQuick.Controls as QQC2
18import QtQuick.Layouts
19
20import org.kde.kirigami as Kirigami
21import org.kde.kcmutils as KCMUtils
22import org.kde.newstuff as NewStuff
23
24import "private" as Private
25
26KCMUtils.SimpleKCM {
27 id: component
28
29 property QtObject newStuffModel
30 property var entry
31
32 property string name
33 property var author
34 property alias shortSummary: shortSummaryItem.text
35 property alias summary: summaryItem.text
36 property alias previews: screenshotsItem.screenshotsModel
37 property string homepage
38 property string donationLink
39 property int status
40 property int commentsCount
41 property int rating
42 property int downloadCount
43 property var downloadLinks
44 property string providerId
45 property int entryType
46
47 Component.onCompleted: {
48 updateContents();
49 newStuffModel.engine.updateEntryContents(component.entry);
50 }
51
52 Connections {
53 target: newStuffModel
55 if (entry === changedEntry) {
56 updateContents();
57 }
58 }
59 }
60
61 function updateContents() {
62 component.providerId = entry.providerId;
63 component.status = entry.status;
64
65 component.author = entry.author;
66 component.name = entry.name;
67 component.shortSummary = entry.shortSummary;
68 component.summary = entry.summary;
69 component.homepage = entry.homepage;
70 component.donationLink = entry.donationLink;
71 component.status = entry.status;
72 component.commentsCount = entry.numberOfComments;
73 component.rating = entry.rating;
74 component.downloadCount = entry.downloadCount;
75
76 const modelIndex = newStuffModel.index(newStuffModel.indexOfEntry(entry), 0);
77 component.previews = newStuffModel.data(modelIndex, NewStuff.ItemsModel.PreviewsRole);
78 component.downloadLinks = newStuffModel.data(modelIndex, NewStuff.ItemsModel.DownloadLinksRole);
79
80 }
81
82 NewStuff.DownloadItemsSheet {
83 id: downloadItemsSheet
84
85 parent: component.QQC2.Overlay.overlay
86
88 const entryName = newStuffModel.data(newStuffModel.index(entryId, 0), NewStuff.ItemsModel.NameRole);
89 applicationWindow().showPassiveNotification(i18ndc("knewstuff6", "A passive notification shown when installation of an item is initiated", "Installing %1 from %2", downloadName, entryName), 1500);
90 newStuffModel.engine.install(component.entry, downloadItemId);
91 }
92 }
93
94 Private.ErrorDisplayer {
95 engine: component.newStuffModel.engine
96 active: component.isCurrentPage
97 }
98
99 NewStuff.Author {
100 id: entryAuthor
101 engine: component.newStuffModel.engine
102 providerId: component.providerId
103 username: author.name
104 }
105
106 title: i18ndc("knewstuff6", "Combined title for the entry details page made of the name of the entry, and the author's name", "%1 by %2", component.name, entryAuthor.name)
107
108 actions: [
109 Kirigami.Action {
110 text: component.downloadLinks.length === 1
111 ? i18ndc("knewstuff6", "Request installation of this item, available when there is exactly one downloadable item", "Install")
112 : i18ndc("knewstuff6", "Show installation options, where there is more than one downloadable item", "Install…")
113
114 icon.name: "install"
115 onTriggered: source => {
116 if (component.downloadLinks.length === 1) {
117 newStuffModel.engine.install(component.entry, NewStuff.ItemsModel.FirstLinkId);
118 } else {
119 downloadItemsSheet.downloadLinks = component.downloadLinks;
120 downloadItemsSheet.entry = component.index;
121 downloadItemsSheet.open();
122 }
123 }
124 enabled: component.status === NewStuff.Entry.Downloadable || component.status === NewStuff.Entry.Deleted
125 visible: enabled
126 },
127 Kirigami.Action {
128 text: i18ndc("knewstuff6", "Request updating of this item", "Update")
129 icon.name: "update-none"
130 onTriggered: source => newStuffModel.update(component.entry, NewStuff.ItemsModel.AutoDetectLinkId)
131 enabled: component.status === NewStuff.Entry.Updateable
132 visible: enabled
133 },
134 Kirigami.Action {
135 text: i18ndc("knewstuff6", "Request uninstallation of this item", "Uninstall")
136 icon.name: "edit-delete"
137 onTriggered: source => newStuffModel.engine.uninstall(component.entry)
138 enabled: component.status === NewStuff.Entry.Installed || component.status === NewStuff.Entry.Updateable
139 visible: enabled
140 }
141 ]
142
143 ColumnLayout {
144 spacing: Kirigami.Units.smallSpacing
145
146 Kirigami.AbstractCard {
147 id: statusCard
148
149 readonly property string message: {
150 switch (component.status) {
151 case NewStuff.Entry.Downloadable:
152 case NewStuff.Entry.Installed:
153 case NewStuff.Entry.Updateable:
154 case NewStuff.Entry.Deleted:
155 return "";
156 case NewStuff.Entry.Installing:
157 return i18ndc("knewstuff6", "Status message to be shown when the entry is in the process of being installed OR uninstalled", "Currently working on the item %1 by %2. Please wait…", component.name, entryAuthor.name);
158 case NewStuff.Entry.Updating:
159 return i18ndc("knewstuff6", "Status message to be shown when the entry is in the process of being updated", "Currently updating the item %1 by %2. Please wait…", component.name, entryAuthor.name);
160 default:
161 return i18ndc("knewstuff6", "Status message which should only be shown when the entry has been given some unknown or invalid status.", "This item is currently in an invalid or unknown state. <a href=\"https://bugs.kde.org/enter_bug.cgi?product=frameworks-knewstuff\">Please report this to the KDE Community in a bug report</a>.");
162 }
163 }
164
165 visible: opacity > 0
166 opacity: message.length > 0 ? 1 : 0
167
168 Behavior on opacity {
170 duration: Kirigami.Units.longDuration
171 }
172 }
173
174 Layout.fillWidth: true
175 Layout.margins: Kirigami.Units.largeSpacing
176
177 contentItem: RowLayout {
178 Layout.fillWidth: true
179 spacing: Kirigami.Units.smallSpacing
180
181 QQC2.Label {
182 Layout.fillWidth: true
183 text: statusCard.message
184 wrapMode: Text.Wrap
185 onLinkActivated: link => Qt.openUrlExternally(link)
186 }
187
188 QQC2.BusyIndicator {
189 running: statusCard.opacity > 0
190 }
191 }
192 }
193
194 Item {
195 Layout.fillWidth: true
196 height: Kirigami.Units.gridUnit * 3
197 }
198
199 Private.EntryScreenshots {
201 Layout.fillWidth: true
202 }
203
204 Kirigami.Heading {
206 wrapMode: Text.Wrap
207 Layout.fillWidth: true
208 }
209
210 Kirigami.FormLayout {
211 Layout.fillWidth: true
212
213 Kirigami.LinkButton {
214 Kirigami.FormData.label: i18nd("knewstuff6", "Comments and Reviews:")
215 enabled: component.commentsCount > 0
216 text: i18ndc("knewstuff6", "A link which, when clicked, opens a new sub page with comments (comments with or without ratings) for this entry", "%1 Reviews and Comments", component.commentsCount)
217 onClicked: mouse => pageStack.push(commentsPage)
218 }
219
220 Private.Rating {
221 id: ratingsItem
222 Kirigami.FormData.label: i18nd("knewstuff6", "Rating:")
223 rating: component.rating
224 }
225
226 Kirigami.UrlButton {
227 Kirigami.FormData.label: i18nd("knewstuff6", "Homepage:")
228 text: i18ndc("knewstuff6", "A link which, when clicked, opens the website associated with the entry (this could be either one specific to the project, the author's homepage, or any other website they have chosen for the purpose)", "Open the homepage for %1", component.name)
229 url: component.homepage
230 visible: url !== ""
231 }
232
233 Kirigami.UrlButton {
234 Kirigami.FormData.label: i18nd("knewstuff6", "How To Donate:")
235 text: i18ndc("knewstuff6", "A link which, when clicked, opens a website with information on donation in support of the entry", "Find out how to donate to this project")
236 url: component.donationLink
237 visible: url !== ""
238 }
239 }
240
241 Kirigami.SelectableLabel {
242 id: summaryItem
243
244 Layout.fillWidth: true
245 Layout.margins: Kirigami.Units.largeSpacing
246
247 textFormat: Text.RichText
248 }
249
250 Component {
251 id: commentsPage
252
253 Private.EntryCommentsPage {
254 itemsModel: component.newStuffModel
255 entry: component.entry
256 entryName: component.name
257 entryAuthorId: component.author.name
258 entryProviderId: component.providerId
259 }
260 }
261 }
262}
Q_SCRIPTABLE CaptureState status()
QString i18ndc(const char *domain, const char *context, const char *text, const TYPE &arg...)
QString i18nd(const char *domain, const char *text, const TYPE &arg...)
T * data() const const
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.