Changeset View
Changeset View
Standalone View
Standalone View
src/qtquick/qml/private/entrygriddelegates/ThumbDelegate.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.kcm 1.2 as KCM | ||||
28 | import org.kde.kirigami 2.7 as Kirigami | ||||
29 | | ||||
30 | import org.kde.newstuff 1.62 as NewStuff | ||||
31 | | ||||
32 | import ".." as Private | ||||
33 | | ||||
34 | KCM.GridDelegate { | ||||
35 | id: component | ||||
36 | property string useLabel | ||||
37 | property string uninstallLabel | ||||
38 | text: model.name | ||||
39 | // onClicked: pageStack.push(detailsPage, { | ||||
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 | // }); | ||||
48 | actions: [ | ||||
49 | Kirigami.Action { | ||||
50 | text: component.useLabel | ||||
51 | iconName: "dialog-ok-apply" | ||||
52 | onTriggered: { model.adopt(model.index); } | ||||
53 | enabled: (model.status == NewStuff.ItemsModel.InstalledStatus || model.status == NewStuff.ItemsModel.UpdateableStatus) && newStuffEngine.hasAdoptionCommand | ||||
54 | visible: enabled | ||||
55 | }, | ||||
56 | Kirigami.Action { | ||||
57 | 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..."); | ||||
58 | iconName: "install" | ||||
59 | onTriggered: { | ||||
60 | if (model.downloadCount == 1) { | ||||
61 | newStuffModel.installItem(model.index); | ||||
62 | } else { | ||||
63 | downloadItemsSheet.downloadLinks = model.downloadLinks; | ||||
64 | downloadItemsSheet.entryId = model.index; | ||||
65 | downloadItemsSheet.open(); | ||||
66 | } | ||||
67 | } | ||||
68 | enabled: model.status == NewStuff.ItemsModel.DownloadableStatus || model.status == NewStuff.ItemsModel.DeletedStatus; | ||||
69 | visible: enabled; | ||||
70 | }, | ||||
71 | Kirigami.Action { | ||||
72 | text: i18nc("Request updating of this item", "Update"); | ||||
73 | iconName: "update" | ||||
74 | onTriggered: { newStuffModel.installItem(model.index); } | ||||
75 | enabled: model.status == NewStuff.ItemsModel.UpdateableStatus; | ||||
76 | visible: enabled; | ||||
77 | }, | ||||
78 | Kirigami.Action { | ||||
79 | text: component.uninstallLabel | ||||
80 | iconName: "uninstall" | ||||
81 | onTriggered: { newStuffModel.uninstallItem(model.index); } | ||||
82 | enabled: model.status == NewStuff.ItemsModel.InstalledStatus | ||||
83 | visible: enabled; | ||||
84 | } | ||||
85 | ] | ||||
86 | thumbnailAvailable: model.previewsSmall.length > 0 | ||||
87 | thumbnail: Image { | ||||
88 | anchors { | ||||
89 | fill: parent; | ||||
90 | margins: Kirigami.Units.smallSpacing; | ||||
91 | } | ||||
92 | asynchronous: true; | ||||
93 | fillMode: Image.PreserveAspectFit; | ||||
94 | source: thumbnailAvailable ? model.previewsSmall[0] : ""; | ||||
95 | Kirigami.Icon { | ||||
96 | id: updateAvailableBadge; | ||||
97 | opacity: (model.status == NewStuff.ItemsModel.UpdateableStatus) ? 1 : 0; | ||||
98 | Behavior on opacity { NumberAnimation { duration: Kirigami.Units.shortDuration; } } | ||||
99 | anchors { | ||||
100 | top: parent.top; | ||||
101 | right: parent.right; | ||||
102 | margins: -Kirigami.Units.smallSpacing; | ||||
103 | } | ||||
104 | height: Kirigami.Units.iconSizes.smallMedium; | ||||
105 | width: height; | ||||
106 | source: "package-installed-outdated"; | ||||
107 | } | ||||
108 | Kirigami.Icon { | ||||
109 | id: installedBadge; | ||||
110 | opacity: (model.status == NewStuff.ItemsModel.InstalledStatus) ? 1 : 0; | ||||
111 | Behavior on opacity { NumberAnimation { duration: Kirigami.Units.shortDuration; } } | ||||
112 | anchors { | ||||
113 | top: parent.top; | ||||
114 | right: parent.right; | ||||
115 | margins: -Kirigami.Units.smallSpacing; | ||||
116 | } | ||||
117 | height: Kirigami.Units.iconSizes.smallMedium; | ||||
118 | width: height; | ||||
119 | source: "package-installed-updated"; | ||||
120 | } | ||||
121 | Item { | ||||
122 | anchors.fill: parent | ||||
123 | opacity: (model.status == NewStuff.ItemsModel.InstallingStatus || model.status == NewStuff.ItemsModel.UpdatingStatus) ? 1 : 0 | ||||
124 | Behavior on opacity { NumberAnimation { duration: Kirigami.Units.longDuration; } } | ||||
125 | Rectangle { | ||||
126 | anchors.fill: parent | ||||
127 | color: Kirigami.Theme.backgroundColor | ||||
128 | opacity: 0.5; | ||||
129 | } | ||||
130 | QtControls.BusyIndicator { | ||||
131 | anchors.centerIn: parent | ||||
132 | running: parent.opacity > 0 | ||||
133 | } | ||||
134 | } | ||||
135 | MouseArea { | ||||
136 | anchors.fill: parent; | ||||
137 | onClicked: pageStack.push(detailsPage, { | ||||
138 | newStuffModel: GridView.view.model, | ||||
139 | index: model.index, | ||||
140 | name: model.name, | ||||
141 | author: model.author, | ||||
142 | previews: model.previews, | ||||
143 | shortSummary: model.shortSummary, | ||||
144 | summary: model.summary, | ||||
145 | homepage: model.homepage, | ||||
146 | donationLink: model.donationLink, | ||||
147 | status: model.status, | ||||
148 | commentsCount: model.numberOfComments, | ||||
149 | rating: model.rating, | ||||
150 | downloadCount: model.downloadCount, | ||||
151 | downloadLinks: model.downloadLinks, | ||||
152 | providerId: model.providerId | ||||
153 | }); | ||||
154 | } | ||||
155 | } | ||||
156 | } |