KNewStuff

EntryDetails.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 /**
8  * @brief A Kirigami.Page component used for displaying the details for a single entry
9  *
10  * This component is equivalent to the details view in the old DownloadDialog
11  * @see KNewStuff::DownloadDialog
12  * @since 5.63
13  */
14 
15 import QtQuick 2.11
16 import QtQuick.Controls 2.11 as QtControls
17 import QtQuick.Layouts 1.11 as QtLayouts
18 
19 import org.kde.kirigami 2.7 as Kirigami
20 import org.kde.kcm 1.2 as KCM
21 
22 import org.kde.newstuff 1.62 as NewStuff
23 
24 import "private" as Private
25 
26 KCM.SimpleKCM {
27  id: component
28  property QtObject newStuffModel
29  property int index
30  property string name
31  property var author
32  property alias shortSummary: shortSummaryItem.text
33  property alias summary: summaryItem.text;
34  property alias previews: screenshotsItem.screenshotsModel
35  property string homepage
36  property string donationLink
37  property int status
38  property int commentsCount
39  property int rating
40  property int downloadCount
41  property var downloadLinks
42  property string providerId
43  property int entryType
44 
45  NewStuff.DownloadItemsSheet {
46  id: downloadItemsSheet
47  onItemPicked: {
48  var entryName = newStuffModel.data(newStuffModel.index(entryId, 0), NewStuff.ItemsModel.NameRole);
49  applicationWindow().showPassiveNotification(i18ndc("knewstuff5", "A passive notification shown when installation of an item is initiated", "Installing %1 from %2", downloadName, entryName), 1500);
50  newStuffModel.installItem(entryId, downloadItemId);
51  }
52  }
53  Private.ErrorDisplayer { engine: component.newStuffModel.engine; active: component.isCurrentPage; }
54 
55  Connections {
56  target: newStuffModel
57  function onEntryChanged(index) {
58  var status = newStuffModel.data(newStuffModel.index(index, 0), NewStuff.ItemsModel.StatusRole);
59  if (status == NewStuff.ItemsModel.DownloadableStatus
60  || status == NewStuff.ItemsModel.InstalledStatus
61  || status == NewStuff.ItemsModel.UpdateableStatus
62  || status == NewStuff.ItemsModel.DeletedStatus) {
63  statusCard.message = "";
64  } else if (status == NewStuff.ItemsModel.InstallingStatus) {
65  statusCard.message = i18ndc("knewstuff5", "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);
66  } else if (status == NewStuff.ItemsModel.UpdatingStatus) {
67  statusCard.message = i18ndc("knewstuff5", "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);
68  } else {
69  statusCard.message = i18ndc("knewstuff5", "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>.");
70  }
71  if (component.status != status) {
72  component.status = status;
73  }
74  }
75  }
76 
77  NewStuff.Author {
78  id: entryAuthor
79  engine: component.newStuffModel.engine
80  providerId: component.providerId
81  username: author.name
82  }
83  title: i18ndc("knewstuff5", "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)
84  actions {
85  contextualActions: [
86  Kirigami.Action {
87  text: component.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...");
88  icon.name: "install"
89  onTriggered: {
90  if (component.downloadLinks.length == 1) {
91  newStuffModel.installItem(component.index, NewStuff.ItemsModel.FirstLinkId);
92  } else {
93  downloadItemsSheet.downloadLinks = component.downloadLinks;
94  downloadItemsSheet.entryId = component.index;
95  downloadItemsSheet.open();
96  }
97  }
98  enabled: component.status == NewStuff.ItemsModel.DownloadableStatus || component.status == NewStuff.ItemsModel.DeletedStatus;
99  visible: enabled;
100  },
101  Kirigami.Action {
102  text: i18ndc("knewstuff5", "Request updating of this item", "Update");
103  icon.name: "update-none"
104  onTriggered: { newStuffModel.updateItem(component.index); }
105  enabled: component.status == NewStuff.ItemsModel.UpdateableStatus;
106  visible: enabled;
107  },
108  Kirigami.Action {
109  text: i18ndc("knewstuff5", "Request uninstallation of this item", "Uninstall");
110  icon.name: "edit-delete"
111  onTriggered: { newStuffModel.uninstallItem(component.index); }
112  enabled: component.status == NewStuff.ItemsModel.InstalledStatus || component.status == NewStuff.ItemsModel.UpdateableStatus
113  visible: enabled;
114  }
115  ]
116  }
117  QtLayouts.ColumnLayout {
118  spacing: Kirigami.Units.smallSpacing
119  Kirigami.AbstractCard {
120  id: statusCard
121  property string message;
122  visible: opacity > 0
123  opacity: message.length > 0 ? 1 : 0
124  Behavior on opacity { NumberAnimation { duration: Kirigami.Units.longDuration; } }
125  QtLayouts.Layout.fillWidth: true
126  QtLayouts.Layout.margins: Kirigami.Units.largeSpacing
127  contentItem: QtLayouts.RowLayout {
128  QtLayouts.Layout.fillWidth: true
129  QtControls.Label {
130  QtLayouts.Layout.fillWidth: true
131  text: statusCard.message
132  wrapMode: Text.Wrap
133  onLinkActivated: Qt.openUrlExternally(link);
134  }
135  QtControls.BusyIndicator {
136  running: statusCard.opacity > 0
137  }
138  }
139  }
140  Item { width: parent.width; height: Kirigami.Units.gridUnit * 3; }
141  Private.EntryScreenshots {
142  id: screenshotsItem
143  QtLayouts.Layout.fillWidth: true
144  }
145  Kirigami.Heading {
146  id: shortSummaryItem
147  wrapMode: Text.Wrap
148  QtLayouts.Layout.fillWidth: true
149  }
150  Kirigami.FormLayout {
151  QtLayouts.Layout.fillWidth: true
152  Kirigami.LinkButton {
153  Kirigami.FormData.label: i18nd("knewstuff5", "Comments and Reviews:")
154  enabled: component.commentsCount > 0
155  text: i18ndc("knewstuff5", "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)
156  onClicked: pageStack.push(commentsPage)
157  }
158  Private.Rating {
159  id: ratingsItem
160  Kirigami.FormData.label: i18nd("knewstuff5", "Rating:")
161  rating: component.rating
162  }
163  Kirigami.UrlButton {
164  Kirigami.FormData.label: i18nd("knewstuff5", "Homepage:")
165  text: i18ndc("knewstuff5", "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)
166  url: component.homepage
167  visible: component.homepage
168  }
169  Kirigami.UrlButton {
170  Kirigami.FormData.label: i18nd("knewstuff5", "How To Donate:")
171  text: i18ndc("knewstuff5", "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")
172  url: component.donationLink
173  visible: component.donationLink
174  }
175  }
176  QtControls.Label {
177  id: summaryItem
178  QtLayouts.Layout.fillWidth: true
179  QtLayouts.Layout.margins: Kirigami.Units.largeSpacing
180  wrapMode: Text.Wrap
181  }
182  Component {
183  id: commentsPage
184  Private.EntryCommentsPage {
185  itemsModel: component.newStuffModel
186  entryIndex: component.index
187  entryName: component.name
188  entryAuthorId: component.author.name
189  entryProviderId: component.providerId
190  }
191  }
192  }
193 }
QString i18ndc(const char *domain, const char *context, const char *text, const TYPE &arg...)
const QLatin1String name
QString i18nd(const char *domain, const char *text, const TYPE &arg...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sun Dec 5 2021 22:37:41 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.