KNewStuff

EntryDetails.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 
30 import QtQuick 2.11
31 import QtQuick.Controls 2.11 as QtControls
32 import QtQuick.Layouts 1.11 as QtLayouts
33 
34 import org.kde.kirigami 2.7 as Kirigami
35 import org.kde.kcm 1.2 as KCM
36 
37 import org.kde.newstuff 1.62 as NewStuff
38 
39 import "private" as Private
40 
41 KCM.SimpleKCM {
42  id: component
43  property QtObject newStuffModel
44  property int index
45  property string name
46  property var author
47  property alias shortSummary: shortSummaryItem.text
48  property alias summary: summaryItem.text;
49  property alias previews: screenshotsItem.screenshotsModel
50  property string homepage
51  property string donationLink
52  property int status
53  property int commentsCount
54  property int rating
55  property int downloadCount
56  property var downloadLinks
57  property string providerId
58 
59  NewStuff.DownloadItemsSheet {
60  id: downloadItemsSheet
61  onItemPicked: {
62  var entryName = newStuffModel.data(newStuffModel.index(entryId, 0), NewStuff.ItemsModel.NameRole);
63  applicationWindow().showPassiveNotification(i18ndc("knewstuff5", "A passive notification shown when installation of an item is initiated", "Installing %1 from %2", downloadName, entryName), 1500);
64  newStuffModel.installItem(entryId, downloadItemId);
65  }
66  }
67  Private.ErrorDisplayer { engine: component.newStuffModel.engine; active: component.isCurrentPage; }
68 
69  Connections {
70  target: newStuffModel
71  onEntryChanged: {
72  var status = newStuffModel.data(newStuffModel.index(index, 0), NewStuff.ItemsModel.StatusRole);
73  if (status == NewStuff.ItemsModel.DownloadableStatus
74  || status == NewStuff.ItemsModel.InstalledStatus
75  || status == NewStuff.ItemsModel.UpdateableStatus
76  || status == NewStuff.ItemsModel.DeletedStatus) {
77  statusCard.message = "";
78  } else if (status == NewStuff.ItemsModel.InstallingStatus) {
79  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);
80  } else if (status == NewStuff.ItemsModel.UpdatingStatus) {
81  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);
82  } else {
83  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>.");
84  }
85  }
86  }
87 
88  NewStuff.Author {
89  id: entryAuthor
90  engine: component.newStuffModel.engine
91  providerId: component.providerId
92  username: author.name
93  }
94  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)
95  actions {
96  contextualActions: [
97  Kirigami.Action {
98  text: component.downloadCount == 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...");
99  icon.name: "install"
100  onTriggered: {
101  if (component.downloadCount == 1) {
102  newStuffModel.installItem(component.index, NewStuff.ItemsModel.FirstLinkId);
103  } else {
104  downloadItemsSheet.downloadLinks = component.downloadLinks;
105  downloadItemsSheet.entryId = component.index;
106  downloadItemsSheet.open();
107  }
108  }
109  enabled: component.status == NewStuff.ItemsModel.DownloadableStatus || component.status == NewStuff.ItemsModel.DeletedStatus;
110  visible: enabled;
111  },
112  Kirigami.Action {
113  text: i18ndc("knewstuff5", "Request updating of this item", "Update");
114  icon.name: "update"
115  onTriggered: { newStuffModel.updateItem(component.index); }
116  enabled: component.status == NewStuff.ItemsModel.UpdateableStatus;
117  visible: enabled;
118  },
119  Kirigami.Action {
120  text: i18ndc("knewstuff5", "Request uninstallation of this item", "Uninstall");
121  icon.name: "uninstall"
122  onTriggered: { newStuffModel.uninstallItem(component.index); }
123  enabled: component.status == NewStuff.ItemsModel.InstalledStatus
124  visible: enabled;
125  }
126  ]
127  }
128  QtLayouts.ColumnLayout {
129  spacing: Kirigami.Units.smallSpacing
130  Item { width: parent.width; height: Kirigami.Units.gridUnit * 3; }
131  Kirigami.AbstractCard {
132  id: statusCard
133  property string message;
134  visible: opacity > 0
135  opacity: message.length > 0 ? 1 : 0
136  Behavior on opacity { NumberAnimation { duration: Kirigami.Units.longDuration; } }
137  QtLayouts.Layout.fillWidth: true
138  QtLayouts.Layout.margins: Kirigami.Units.largeSpacing
139  Item {
140  id: statusContent
141  implicitHeight: statusCard.message.length > 0 ? Math.max(statusBusy.height, statusLabel.height) + Kirigami.Units.largeSpacing * 4 : 0
142  implicitWidth: statusCard.width
143  QtControls.BusyIndicator {
144  id: statusBusy
145  anchors {
146  top: parent.top
147  left: parent.left
148  }
149  running: statusCard.opacity > 0
150  }
151  QtControls.Label {
152  id: statusLabel
153  anchors {
154  top: parent.top
155  left: statusBusy.right
156  leftMargin: Kirigami.Units.largeSpacing
157  right: parent.right
158  }
159  text: statusCard.message
160  wrapMode: Text.Wrap
161  onLinkActivated: Qt.openUrlExternally(link);
162  }
163  }
164  }
165  Private.EntryScreenshots {
166  id: screenshotsItem
167  QtLayouts.Layout.fillWidth: true
168  }
169  Kirigami.Heading {
170  id: shortSummaryItem
171  QtLayouts.Layout.fillWidth: true
172  }
173  Kirigami.FormLayout {
174  QtLayouts.Layout.fillWidth: true
175  Kirigami.LinkButton {
176  Kirigami.FormData.label: i18nd("knewstuff5", "Comments and Reviews:")
177  enabled: component.commentsCount > 0
178  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)
179  onClicked: pageStack.push(commentsPage)
180  }
181  Private.Rating {
182  id: ratingsItem
183  Kirigami.FormData.label: i18nd("knewstuff5", "Rating:")
184  rating: Math.floor(component.rating / 10)
185  }
186  Kirigami.UrlButton {
187  Kirigami.FormData.label: i18nd("knewstuff5", "Homepage:")
188  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)
189  url: component.homepage
190  visible: component.homepage
191  }
192  Kirigami.UrlButton {
193  Kirigami.FormData.label: i18nd("knewstuff5", "How To Donate:")
194  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")
195  url: component.donationLink
196  visible: component.donationLink
197  }
198  }
199  QtControls.Label {
200  id: summaryItem
201  QtLayouts.Layout.fillWidth: true
202  QtLayouts.Layout.margins: Kirigami.Units.largeSpacing
203  wrapMode: Text.Wrap
204  }
205  Component {
206  id: commentsPage
207  Private.EntryCommentsPage {
208  itemsModel: component.newStuffModel
209  entryIndex: component.index
210  entryName: component.name
211  entryAuthorId: component.author.name
212  entryProviderId: component.providerId
213  }
214  }
215  }
216 }
QString i18ndc(const char *domain, const char *context, const char *text, const TYPE &arg...)
QTextStream & left(QTextStream &s)
QTextStream & right(QTextStream &s)
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 Tue Jul 7 2020 22:40:16 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.