Warning, /frameworks/knewstuff/src/qtquick/qml/private/entrygriddelegates/TileDelegate.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2019 Dan Leinir Turthra Jensen <admin@leinir.dk> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 import QtQuick 2.11 0008 import QtQuick.Controls 2.11 as QtControls 0009 import QtQuick.Layouts 1.11 as QtLayouts 0010 import Qt5Compat.GraphicalEffects 6.0 as QtEffects 0011 0012 import org.kde.kirigami 2.12 as Kirigami 0013 0014 import org.kde.newstuff as NewStuff 0015 0016 import ".." as Private 0017 0018 Private.GridTileDelegate { 0019 id: component 0020 property var entry: model.entry 0021 property string useLabel 0022 property string uninstallLabel 0023 function showDetails() { 0024 if (entry.entryType == NewStuff.Entry.GroupEntry) { 0025 newStuffEngine.storeSearch(); 0026 newStuffEngine.searchTerm = model.payload; 0027 } else { 0028 pageStack.push(detailsPage, { 0029 newStuffModel: GridView.view.model, 0030 entry, 0031 }); 0032 } 0033 } 0034 actions: [ 0035 Kirigami.Action { 0036 text: component.useLabel 0037 icon.name: "dialog-ok-apply" 0038 onTriggered: { newStuffModel.adoptItem(model.index); } 0039 enabled: (entry.status == NewStuff.Entry.Installed || entry.status == NewStuff.Entry.Updateable) && newStuffEngine.hasAdoptionCommand 0040 visible: enabled 0041 }, 0042 Kirigami.Action { 0043 text: entry.downloadLinks.length === 1 ? i18ndc("knewstuff6", "Request installation of this item, available when there is exactly one downloadable item", "Install") : i18ndc("knewstuff6", "Show installation options, where there is more than one downloadable item", "Install…"); 0044 icon.name: "install" 0045 onTriggered: { 0046 if (entry.downloadLinks.length === 1) { 0047 newStuffEngine.install(entry.entry, NewStuff.ItemsModel.FirstLinkId); 0048 } else { 0049 downloadItemsSheet.downloadLinks = entry.downloadLinks; 0050 downloadItemsSheet.entry = entry; 0051 downloadItemsSheet.open(); 0052 } 0053 } 0054 enabled: entry.status == NewStuff.Entry.Downloadable || entry.status == NewStuff.Entry.Deleted; 0055 visible: enabled; 0056 }, 0057 Kirigami.Action { 0058 text: i18ndc("knewstuff6", "Request updating of this item", "Update"); 0059 icon.name: "update-none" 0060 onTriggered: { newStuffEngine.install(entry, NewStuff.ItemsModel.AutoDetectLinkId); } 0061 enabled: entry.status == NewStuff.Entry.Updateable 0062 visible: enabled 0063 }, 0064 Kirigami.Action { 0065 text: component.uninstallLabel 0066 icon.name: "edit-delete" 0067 onTriggered: { newStuffEngine.uninstall(model.entry); } 0068 enabled: entry.status == NewStuff.Entry.Installed|| entry.status == NewStuff.Entry.Updateable 0069 visible: enabled && hovered 0070 } 0071 ] 0072 thumbnailArea: tilePreview 0073 thumbnailAvailable: model.previewsSmall.length > 0 0074 tile: Item { 0075 anchors { 0076 fill: parent 0077 margins: Kirigami.Units.smallSpacing 0078 } 0079 QtLayouts.GridLayout { 0080 anchors.fill: parent; 0081 columns: 2 0082 QtLayouts.ColumnLayout { 0083 QtLayouts.Layout.minimumWidth: view.implicitCellWidth / 5 0084 QtLayouts.Layout.maximumWidth: view.implicitCellWidth / 5 0085 Item { 0086 QtLayouts.Layout.fillWidth: true 0087 QtLayouts.Layout.minimumHeight: width 0088 QtLayouts.Layout.maximumHeight: width 0089 Kirigami.ShadowedRectangle { 0090 visible: tilePreview.status == Image.Ready 0091 anchors.centerIn: tilePreview; 0092 width: Math.min(tilePreview.paintedWidth, tilePreview.width); 0093 height: Math.min(tilePreview.paintedHeight, tilePreview.height); 0094 Kirigami.Theme.colorSet: Kirigami.Theme.View 0095 shadow.size: Kirigami.Units.largeSpacing 0096 shadow.color: Qt.rgba(0, 0, 0, 0.3) 0097 } 0098 Image { 0099 id: tilePreview 0100 asynchronous: true; 0101 fillMode: Image.PreserveAspectFit; 0102 source: thumbnailAvailable ? model.previewsSmall[0] : ""; 0103 anchors { 0104 fill: parent 0105 margins: Kirigami.Units.smallSpacing 0106 } 0107 verticalAlignment: Image.AlignTop 0108 } 0109 Kirigami.Icon { 0110 id: updateAvailableBadge; 0111 opacity: (entry.status == NewStuff.Entry.Updateable) ? 1 : 0; 0112 Behavior on opacity { NumberAnimation { duration: Kirigami.Units.shortDuration; } } 0113 anchors { 0114 top: parent.top; 0115 left: parent.left; 0116 margins: -Kirigami.Units.smallSpacing; 0117 } 0118 height: Kirigami.Units.iconSizes.smallMedium; 0119 width: height; 0120 source: "package-installed-outdated"; 0121 } 0122 Kirigami.Icon { 0123 id: installedBadge; 0124 opacity: (entry.status == NewStuff.Entry.Installed) ? 1 : 0; 0125 Behavior on opacity { NumberAnimation { duration: Kirigami.Units.shortDuration; } } 0126 anchors { 0127 top: parent.top; 0128 left: parent.left; 0129 margins: -Kirigami.Units.smallSpacing; 0130 } 0131 height: Kirigami.Units.iconSizes.smallMedium; 0132 width: height; 0133 source: "package-installed-updated"; 0134 } 0135 } 0136 Item { 0137 QtLayouts.Layout.fillHeight: true 0138 } 0139 } 0140 QtLayouts.ColumnLayout { 0141 QtLayouts.Layout.fillWidth: true 0142 QtLayouts.Layout.fillHeight: true 0143 Kirigami.Heading { 0144 QtLayouts.Layout.fillWidth: true 0145 elide: Text.ElideRight 0146 level: 3 0147 text: entry.name 0148 } 0149 Kirigami.Heading { 0150 QtLayouts.Layout.fillWidth: true 0151 elide: Text.ElideRight 0152 level: 4 0153 textFormat: Text.StyledText 0154 text: i18ndc("knewstuff6", "Subheading for the tile view, located immediately underneath the name of the item", "By <i>%1</i>", entry.author.name) 0155 } 0156 QtControls.Label { 0157 QtLayouts.Layout.fillWidth: true 0158 QtLayouts.Layout.fillHeight: true 0159 wrapMode: Text.Wrap 0160 text: entry.shortSummary.length > 0 ? entry.shortSummary : entry.summary 0161 elide: Text.ElideRight 0162 clip: true // We are dealing with content over which we have very little control. Sometimes that means being a bit abrupt. 0163 } 0164 } 0165 Private.Rating { 0166 QtLayouts.Layout.fillWidth: true 0167 rating: entry.rating 0168 visible: entry.entryType == NewStuff.Entry.CatalogEntry; 0169 } 0170 Kirigami.Heading { 0171 QtLayouts.Layout.fillWidth: true 0172 horizontalAlignment: Text.AlignRight 0173 level: 5 0174 elide: Text.ElideRight 0175 text: i18ndc("knewstuff6", "The number of times the item has been downloaded", "%1 downloads", entry.downloadCount) 0176 visible: entry.entryType == NewStuff.Entry.CatalogEntry 0177 } 0178 } 0179 FeedbackOverlay { 0180 anchors.fill: parent 0181 newStuffModel: component.GridView.view.model 0182 } 0183 MouseArea { 0184 anchors.fill: parent; 0185 cursorShape: Qt.PointingHandCursor; 0186 onClicked: component.showDetails(); 0187 } 0188 } 0189 }