Warning, /frameworks/knewstuff/src/qtquick/qml/private/entrygriddelegates/BigPreviewDelegate.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 actionsAnchors.topMargin: bigPreview.height + Kirigami.Units.smallSpacing * 2 0022 function showDetails() { 0023 pageStack.push(detailsPage, { 0024 newStuffModel: GridView.view.model, 0025 entry: model.entry, 0026 }); 0027 } 0028 actions: [ 0029 Kirigami.Action { 0030 text: root.useLabel 0031 icon.name: "dialog-ok-apply" 0032 onTriggered: { newStuffModel.adoptEntry(model.entry); } 0033 enabled: (entry.status === NewStuff.Entry.Installed || entry.status === NewStuff.Entry.Updateable) && newStuffEngine.hasAdoptionCommand 0034 visible: enabled 0035 }, 0036 Kirigami.Action { 0037 text: model.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…"); 0038 icon.name: "install" 0039 onTriggered: { 0040 if (model.downloadLinks.length === 1) { 0041 newStuffModel.engine.install(model.entry, NewStuff.ItemsModel.FirstLinkId); 0042 } else { 0043 downloadItemsSheet.downloadLinks = model.downloadLinks; 0044 downloadItemsSheet.entry = model.entry; 0045 downloadItemsSheet.open(); 0046 } 0047 } 0048 enabled: entry.status === NewStuff.Entry.Downloadable || entry.status === NewStuff.Entry.Deleted 0049 visible: enabled 0050 }, 0051 Kirigami.Action { 0052 text: i18ndc("knewstuff6", "Request updating of this item", "Update"); 0053 icon.name: "update-none" 0054 onTriggered: { newStuffModel.engine.install(model.index, NewStuff.ItemsModel.AutoDetectLinkId); } 0055 enabled: entry.status === NewStuff.Entry.Updateable 0056 visible: enabled 0057 }, 0058 Kirigami.Action { 0059 text: root.uninstallLabel 0060 icon.name: "edit-delete" 0061 onTriggered: { newStuffModel.engine.uninstall(model.entry); } 0062 enabled: entry.status === NewStuff.Entry.Installed || entry.status === NewStuff.Entry.Updateable 0063 visible: enabled 0064 } 0065 ] 0066 thumbnailArea: bigPreview 0067 thumbnailAvailable: model.previewsSmall.length > 0 0068 tile: Item { 0069 anchors { 0070 fill: parent 0071 margins: Kirigami.Units.smallSpacing 0072 } 0073 QtLayouts.ColumnLayout { 0074 anchors.fill: parent; 0075 Item { 0076 QtLayouts.Layout.fillWidth: true 0077 QtLayouts.Layout.fillHeight: true 0078 QtLayouts.Layout.minimumHeight: width / 5 0079 QtLayouts.Layout.maximumHeight: width / 1.8 0080 Kirigami.ShadowedRectangle { 0081 visible: bigPreview.status == Image.Ready 0082 anchors.centerIn: bigPreview; 0083 width: Math.min(bigPreview.paintedWidth, bigPreview.width); 0084 height: Math.min(bigPreview.paintedHeight, bigPreview.height); 0085 Kirigami.Theme.colorSet: Kirigami.Theme.View 0086 shadow.size: 10 0087 shadow.color: Qt.rgba(0, 0, 0, 0.3) 0088 } 0089 Image { 0090 id: bigPreview 0091 asynchronous: true; 0092 fillMode: Image.PreserveAspectCrop; 0093 source: thumbnailAvailable ? model.previews[0] : ""; 0094 anchors.fill: parent 0095 } 0096 Kirigami.Icon { 0097 id: updateAvailableBadge; 0098 opacity: (entry.status == NewStuff.Entry.Updateable) ? 1 : 0; 0099 Behavior on opacity { NumberAnimation { duration: Kirigami.Units.shortDuration; } } 0100 anchors { 0101 top: parent.top; 0102 left: parent.left; 0103 } 0104 height: Kirigami.Units.iconSizes.medium; 0105 width: height; 0106 source: "package-installed-outdated"; 0107 } 0108 Kirigami.Icon { 0109 id: installedBadge; 0110 opacity: (entry.status === NewStuff.Entry.Installed) ? 1 : 0; 0111 Behavior on opacity { NumberAnimation { duration: Kirigami.Units.shortDuration; } } 0112 anchors { 0113 top: parent.top; 0114 left: parent.left; 0115 } 0116 height: Kirigami.Units.iconSizes.medium; 0117 width: height; 0118 source: "package-installed-updated"; 0119 } 0120 } 0121 Private.Rating { 0122 QtLayouts.Layout.fillWidth: true 0123 rating: model.rating 0124 } 0125 Kirigami.Heading { 0126 QtLayouts.Layout.fillWidth: true 0127 level: 5 0128 elide: Text.ElideRight 0129 text: i18ndc("knewstuff6", "The number of times the item has been downloaded", "%1 downloads", model.downloadCount) 0130 } 0131 Kirigami.Heading { 0132 QtLayouts.Layout.fillWidth: true 0133 elide: Text.ElideRight 0134 level: 3 0135 text: model.name 0136 } 0137 Kirigami.Heading { 0138 QtLayouts.Layout.fillWidth: true 0139 elide: Text.ElideRight 0140 level: 4 0141 textFormat: Text.StyledText 0142 text: i18ndc("knewstuff6", "Subheading for the tile view, located immediately underneath the name of the item", "By <i>%1</i>", model.author.name) 0143 } 0144 QtControls.Label { 0145 QtLayouts.Layout.fillWidth: true 0146 QtLayouts.Layout.fillHeight: true 0147 QtLayouts.Layout.minimumHeight: Kirigami.Units.gridUnit 0148 QtLayouts.Layout.maximumHeight: Kirigami.Units.gridUnit * 3 0149 wrapMode: Text.Wrap 0150 text: model.shortSummary.length > 0 ? model.shortSummary : model.summary 0151 elide: Text.ElideRight 0152 } 0153 clip: true // We are dealing with content over which we have very little control. Sometimes that means being a bit abrupt. 0154 } 0155 FeedbackOverlay { 0156 anchors.fill: parent 0157 newStuffModel: component.GridView.view.model 0158 } 0159 MouseArea { 0160 anchors.fill: parent; 0161 cursorShape: Qt.PointingHandCursor; 0162 onClicked: component.showDetails(); 0163 } 0164 } 0165 }