Changeset View
Changeset View
Standalone View
Standalone View
src/qtquick/qml/private/entrygriddelegates/BigPreviewDelegate.qml
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright (C) 2019 Dan Leinir Turthra Jensen <admin@leinir.dk> | ||||
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.kirigami 2.7 as Kirigami | ||||
28 | | ||||
29 | import org.kde.newstuff 1.62 as NewStuff | ||||
30 | | ||||
31 | import ".." as Private | ||||
32 | | ||||
33 | Private.GridTileDelegate { | ||||
34 | id: component | ||||
35 | actionsAnchors.topMargin: bigPreview.height + Kirigami.Units.smallSpacing * 2 | ||||
36 | function showDetails() { | ||||
37 | pageStack.push(detailsPage, { | ||||
38 | newStuffModel: GridView.view.model, | ||||
39 | index: model.index, | ||||
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 | status: model.status, | ||||
48 | commentsCount: model.numberOfComments, | ||||
49 | rating: model.rating, | ||||
50 | downloadCount: model.downloadCount, | ||||
51 | downloadLinks: model.downloadLinks, | ||||
52 | providerId: model.providerId | ||||
53 | }); | ||||
54 | } | ||||
55 | actions: [ | ||||
56 | Kirigami.Action { | ||||
57 | text: root.useLabel | ||||
58 | iconName: "dialog-ok-apply" | ||||
59 | onTriggered: { model.adopt(model.index); } | ||||
60 | enabled: (model.status == NewStuff.ItemsModel.InstalledStatus || model.status == NewStuff.ItemsModel.UpdateableStatus) && newStuffEngine.hasAdoptionCommand | ||||
61 | visible: enabled | ||||
62 | }, | ||||
63 | Kirigami.Action { | ||||
64 | text: model.downloadCount == 1 ? i18nc("Request installation of this item, available when there is exactly one downloadable item", "Install") : i18nc("Show installation options, where there is more than one downloadable item", "Install..."); | ||||
65 | iconName: "install" | ||||
66 | onTriggered: { | ||||
67 | if (model.downloadCount == 1) { | ||||
68 | newStuffModel.installItem(model.index, 1); | ||||
69 | } else { | ||||
70 | downloadItemsSheet.downloadLinks = model.downloadLinks; | ||||
71 | downloadItemsSheet.entryId = model.index; | ||||
72 | downloadItemsSheet.open(); | ||||
73 | } | ||||
74 | } | ||||
75 | enabled: model.status == NewStuff.ItemsModel.DownloadableStatus || model.status == NewStuff.ItemsModel.DeletedStatus; | ||||
76 | visible: enabled; | ||||
77 | }, | ||||
78 | Kirigami.Action { | ||||
79 | text: i18nc("Request updating of this item", "Update"); | ||||
80 | iconName: "update" | ||||
81 | onTriggered: { newStuffModel.installItem(model.index); } | ||||
82 | enabled: model.status == NewStuff.ItemsModel.UpdateableStatus; | ||||
83 | visible: enabled; | ||||
84 | }, | ||||
85 | Kirigami.Action { | ||||
86 | text: root.uninstallLabel | ||||
87 | iconName: "uninstall" | ||||
88 | onTriggered: { newStuffModel.uninstallItem(model.index); } | ||||
89 | enabled: model.status == NewStuff.ItemsModel.InstalledStatus | ||||
90 | visible: enabled; | ||||
91 | } | ||||
92 | ] | ||||
93 | thumbnailAvailable: model.previewsSmall.length > 0 | ||||
94 | tile: Item { | ||||
95 | anchors { | ||||
96 | fill: parent | ||||
97 | margins: Kirigami.Units.smallSpacing | ||||
98 | } | ||||
99 | QtLayouts.ColumnLayout { | ||||
100 | anchors.fill: parent; | ||||
101 | Item { | ||||
102 | QtLayouts.Layout.fillWidth: true | ||||
103 | QtLayouts.Layout.minimumHeight: width / 1.8 | ||||
104 | QtLayouts.Layout.maximumHeight: width / 1.8 | ||||
105 | Image { | ||||
106 | id: bigPreview | ||||
107 | asynchronous: true; | ||||
108 | fillMode: Image.PreserveAspectCrop; | ||||
109 | source: thumbnailAvailable ? model.previews[0] : ""; | ||||
110 | anchors.fill: parent | ||||
111 | } | ||||
112 | QtEffects.DropShadow { | ||||
113 | anchors.fill: bigPreview | ||||
114 | horizontalOffset: 0 | ||||
115 | verticalOffset: 0 | ||||
116 | radius: Kirigami.Units.largeSpacing | ||||
117 | samples: radius * 2 | ||||
118 | color: "#80000000" | ||||
119 | source: bigPreview | ||||
120 | } | ||||
121 | Kirigami.Icon { | ||||
122 | id: updateAvailableBadge; | ||||
123 | opacity: (model.status == NewStuff.ItemsModel.UpdateableStatus) ? 1 : 0; | ||||
124 | Behavior on opacity { NumberAnimation { duration: Kirigami.Units.shortDuration; } } | ||||
125 | anchors { | ||||
126 | top: parent.top; | ||||
127 | left: parent.left; | ||||
128 | margins: -Kirigami.Units.smallSpacing; | ||||
129 | } | ||||
130 | height: Kirigami.Units.iconSizes.medium; | ||||
131 | width: height; | ||||
132 | source: "package-installed-outdated"; | ||||
133 | } | ||||
134 | Kirigami.Icon { | ||||
135 | id: installedBadge; | ||||
136 | opacity: (model.status == NewStuff.ItemsModel.InstalledStatus) ? 1 : 0; | ||||
137 | Behavior on opacity { NumberAnimation { duration: Kirigami.Units.shortDuration; } } | ||||
138 | anchors { | ||||
139 | top: parent.top; | ||||
140 | left: parent.left; | ||||
141 | } | ||||
142 | height: Kirigami.Units.iconSizes.medium; | ||||
143 | width: height; | ||||
144 | source: "package-installed-updated"; | ||||
145 | } | ||||
146 | Item { | ||||
147 | anchors { | ||||
148 | top: parent.top; | ||||
149 | right: parent.right; | ||||
150 | } | ||||
151 | height: Kirigami.Units.iconSizes.large; | ||||
152 | width: height; | ||||
153 | Kirigami.Icon { | ||||
154 | id: infoIcon | ||||
155 | source: "documentinfo" | ||||
156 | anchors.fill: parent | ||||
157 | } | ||||
158 | MouseArea { | ||||
159 | anchors.fill: parent | ||||
160 | onClicked: { component.showDetails(); } | ||||
161 | } | ||||
162 | QtEffects.Glow { | ||||
163 | anchors.fill: infoIcon | ||||
164 | radius: 1 | ||||
165 | samples: 2 | ||||
166 | spread: 0.3 | ||||
167 | color: "white" | ||||
168 | source: infoIcon | ||||
169 | } | ||||
170 | } | ||||
171 | } | ||||
172 | Private.Rating { | ||||
173 | QtLayouts.Layout.fillWidth: true | ||||
174 | rating: model.rating / 10 | ||||
175 | } | ||||
176 | Kirigami.Heading { | ||||
177 | QtLayouts.Layout.fillWidth: true | ||||
178 | level: 5 | ||||
179 | elide: Text.ElideRight | ||||
180 | text: i18nc("The number of times the item has been downloaded", "%1 downloads").arg(model.downloadCount) | ||||
181 | } | ||||
182 | Kirigami.Heading { | ||||
183 | QtLayouts.Layout.fillWidth: true | ||||
184 | elide: Text.ElideRight | ||||
185 | level: 3 | ||||
186 | text: model.name | ||||
187 | } | ||||
188 | Kirigami.Heading { | ||||
189 | QtLayouts.Layout.fillWidth: true | ||||
190 | elide: Text.ElideRight | ||||
191 | level: 4 | ||||
192 | textFormat: Text.StyledText | ||||
193 | text: i18nc("Subheading for the tile view, located immediately underneath the name of the item", "By <i>%1</i>").arg(model.author.name) | ||||
194 | } | ||||
195 | QtControls.Label { | ||||
196 | QtLayouts.Layout.fillWidth: true | ||||
197 | QtLayouts.Layout.fillHeight: true | ||||
198 | wrapMode: Text.Wrap | ||||
199 | text: model.shortSummary.length > 0 ? model.shortSummary : model.summary | ||||
200 | elide: Text.ElideRight | ||||
201 | } | ||||
202 | } | ||||
203 | Item { | ||||
204 | anchors.fill: parent | ||||
205 | opacity: (model.status == NewStuff.ItemsModel.InstallingStatus || model.status == NewStuff.ItemsModel.UpdatingStatus) ? 1 : 0 | ||||
206 | Behavior on opacity { NumberAnimation { duration: Kirigami.Units.longDuration; } } | ||||
207 | Rectangle { | ||||
208 | anchors.fill: parent | ||||
209 | color: Kirigami.Theme.backgroundColor | ||||
210 | opacity: 0.5; | ||||
211 | } | ||||
212 | QtControls.BusyIndicator { | ||||
213 | anchors.centerIn: parent | ||||
214 | running: parent.opacity > 0 | ||||
215 | } | ||||
216 | } | ||||
217 | MouseArea { | ||||
218 | anchors.fill: parent; | ||||
219 | onClicked: component.showDetails(); | ||||
220 | } | ||||
221 | } | ||||
222 | } |