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 
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 
44  NewStuff.DownloadItemsSheet {
45  id: downloadItemsSheet
46  onItemPicked: {
47  var entryName = newStuffModel.data(newStuffModel.index(entryId, 0), NewStuff.ItemsModel.NameRole);
48  applicationWindow().showPassiveNotification(i18ndc("knewstuff5", "A passive notification shown when installation of an item is initiated", "Installing %1 from %2", downloadName, entryName), 1500);
49  newStuffModel.installItem(entryId, downloadItemId);
50  }
51  }
52  Private.ErrorDisplayer { engine: component.newStuffModel.engine; active: component.isCurrentPage; }
53 
54  Connections {
55  target: newStuffModel
56  onEntryChanged: {
57  var status = newStuffModel.data(newStuffModel.index(index, 0), NewStuff.ItemsModel.StatusRole);
58  if (status == NewStuff.ItemsModel.DownloadableStatus
59  || status == NewStuff.ItemsModel.InstalledStatus
60  || status == NewStuff.ItemsModel.UpdateableStatus
61  || status == NewStuff.ItemsModel.DeletedStatus) {
62  statusCard.message = "";
63  } else if (status == NewStuff.ItemsModel.InstallingStatus) {
64  statusCard.message = i18ndc("knewstuff5", "Status message to be shown when the entry is in the process of being installed", "Currently installing the item %1 by %2. Please wait...", component.name, entryAuthor.name);
65  } else if (status == NewStuff.ItemsModel.UpdatingStatus) {
66  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);
67  } else {
68  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>.");
69  }
70  if (component.status != status) {
71  component.status = status;
72  }
73  }
74  }
75 
76  NewStuff.Author {
77  id: entryAuthor
78  engine: component.newStuffModel.engine
79  providerId: component.providerId
80  username: author.name
81  }
82  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)
83  actions {
84  contextualActions: [
85  Kirigami.Action {
86  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...");
87  icon.name: "install"
88  onTriggered: {
89  if (component.downloadLinks.length == 1) {
90  newStuffModel.installItem(component.index, NewStuff.ItemsModel.FirstLinkId);
91  } else {
92  downloadItemsSheet.downloadLinks = component.downloadLinks;
93  downloadItemsSheet.entryId = component.index;
94  downloadItemsSheet.open();
95  }
96  }
97  enabled: component.status == NewStuff.ItemsModel.DownloadableStatus || component.status == NewStuff.ItemsModel.DeletedStatus;
98  visible: enabled;
99  },
100  Kirigami.Action {
101  text: i18ndc("knewstuff5", "Request updating of this item", "Update");
102  icon.name: "update-none"
103  onTriggered: { newStuffModel.updateItem(component.index); }
104  enabled: component.status == NewStuff.ItemsModel.UpdateableStatus;
105  visible: enabled;
106  },
107  Kirigami.Action {
108  text: i18ndc("knewstuff5", "Request uninstallation of this item", "Uninstall");
109  icon.name: "edit-delete"
110  onTriggered: { newStuffModel.uninstallItem(component.index); }
111  enabled: component.status == NewStuff.ItemsModel.InstalledStatus || component.status == NewStuff.ItemsModel.UpdateableStatus
112  visible: enabled;
113  }
114  ]
115  }
116  QtLayouts.ColumnLayout {
117  spacing: Kirigami.Units.smallSpacing
118  Kirigami.AbstractCard {
119  id: statusCard
120  property string message;
121  visible: opacity > 0
122  opacity: message.length > 0 ? 1 : 0
123  Behavior on opacity { NumberAnimation { duration: Kirigami.Units.longDuration; } }
124  QtLayouts.Layout.fillWidth: true
125  QtLayouts.Layout.margins: Kirigami.Units.largeSpacing
126  contentItem: QtLayouts.RowLayout {
127  QtLayouts.Layout.fillWidth: true
128  QtControls.Label {
129  QtLayouts.Layout.fillWidth: true
130  text: statusCard.message
131  wrapMode: Text.Wrap
132  onLinkActivated: Qt.openUrlExternally(link);
133  }
134  QtControls.BusyIndicator {
135  running: statusCard.opacity > 0
136  }
137  }
138  }
139  Item { width: parent.width; height: Kirigami.Units.gridUnit * 3; }
140  Private.EntryScreenshots {
141  id: screenshotsItem
142  QtLayouts.Layout.fillWidth: true
143  }
144  Kirigami.Heading {
145  id: shortSummaryItem
146  QtLayouts.Layout.fillWidth: true
147  }
148  Kirigami.FormLayout {
149  QtLayouts.Layout.fillWidth: true
150  Kirigami.LinkButton {
151  Kirigami.FormData.label: i18nd("knewstuff5", "Comments and Reviews:")
152  enabled: component.commentsCount > 0
153  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)
154  onClicked: pageStack.push(commentsPage)
155  }
156  Private.Rating {
157  id: ratingsItem
158  Kirigami.FormData.label: i18nd("knewstuff5", "Rating:")
159  rating: Math.floor(component.rating / 10)
160  }
161  Kirigami.UrlButton {
162  Kirigami.FormData.label: i18nd("knewstuff5", "Homepage:")
163  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)
164  url: component.homepage
165  visible: component.homepage
166  }
167  Kirigami.UrlButton {
168  Kirigami.FormData.label: i18nd("knewstuff5", "How To Donate:")
169  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")
170  url: component.donationLink
171  visible: component.donationLink
172  }
173  }
174  QtControls.Label {
175  id: summaryItem
176  QtLayouts.Layout.fillWidth: true
177  QtLayouts.Layout.margins: Kirigami.Units.largeSpacing
178  wrapMode: Text.Wrap
179  }
180  Component {
181  id: commentsPage
182  Private.EntryCommentsPage {
183  itemsModel: component.newStuffModel
184  entryIndex: component.index
185  entryName: component.name
186  entryAuthorId: component.author.name
187  entryProviderId: component.providerId
188  }
189  }
190  }
191 }
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...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Nov 30 2020 22:42:21 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.