Warning, /frameworks/knewstuff/src/qtquick/qml/private/EntryScreenshots.qml is written in an unsupported language. File is not indexed.
0001 /*
0002 SPDX-FileCopyrightText: 2012 Aleix Pol Gonzalez <aleixpol@blue-systems.com>
0003 SPDX-FileCopyrightText: 2019 Dan Leinir Turthra Jensen <admin@leinir.dk>
0004
0005 SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007
0008 import QtQuick
0009 import QtQuick.Controls
0010 import QtQuick.Layouts
0011 import Qt5Compat.GraphicalEffects
0012
0013 import org.kde.kirigami as Kirigami
0014
0015 Flickable {
0016 id: root
0017 property alias screenshotsModel: screenshotsRep.model
0018 readonly property alias count: screenshotsRep.count
0019 property int currentIndex: -1
0020 property Item currentItem: screenshotsRep.itemAt(currentIndex)
0021 Layout.preferredHeight: Kirigami.Units.gridUnit * 13
0022 contentHeight: height
0023 contentWidth: screenshotsLayout.width
0024
0025 Popup {
0026 id: overlay
0027 parent: applicationWindow().Overlay.overlay
0028 modal: true
0029 clip: false
0030
0031 x: (parent.width - width)/2
0032 y: (parent.height - height)/2
0033 readonly property real proportion: overlayImage.sourceSize.width>1 ? overlayImage.sourceSize.height/overlayImage.sourceSize.width : 1
0034 height: overlayImage.status == Image.Loading ? Kirigami.Units.gridUnit * 5 : Math.min(parent.height * 0.9, (parent.width * 0.9) * proportion, overlayImage.sourceSize.height)
0035 width: height/proportion
0036
0037 BusyIndicator {
0038 id: indicator
0039 visible: running
0040 running: overlayImage.status == Image.Loading
0041 anchors.fill: parent
0042 }
0043
0044 // Only animate the images in the detail view; in the overview it would be irritating and not useful anyway due to the small previews
0045 AnimatedImage {
0046 id: overlayImage
0047 anchors.fill: parent
0048 source: root.currentItem ? root.currentItem.imageSource : ""
0049 fillMode: Image.PreserveAspectFit
0050 smooth: true
0051 }
0052
0053 Button {
0054 anchors {
0055 right: parent.left
0056 verticalCenter: parent.verticalCenter
0057 }
0058 action: leftAction
0059 visible: leftAction.visible
0060 }
0061
0062 Button {
0063 anchors {
0064 left: parent.right
0065 verticalCenter: parent.verticalCenter
0066 }
0067 action: rightAction
0068 visible: rightAction.visible
0069 }
0070
0071 Kirigami.Action {
0072 id: leftAction
0073 icon.name: "arrow-left"
0074 enabled: overlay.visible && visible
0075 visible: root.currentIndex >= 1 && !indicator.running
0076 onTriggered: root.currentIndex = (root.currentIndex - 1) % root.count
0077 }
0078
0079 Kirigami.Action {
0080 id: rightAction
0081 icon.name: "arrow-right"
0082 enabled: overlay.visible && visible
0083 visible: root.currentIndex < (root.count - 1) && !indicator.running
0084 onTriggered: root.currentIndex = (root.currentIndex + 1) % root.count
0085 }
0086 }
0087
0088 Row {
0089 id: screenshotsLayout
0090 height: root.contentHeight
0091 spacing: Kirigami.Units.largeSpacing
0092 leftPadding: spacing
0093 rightPadding: spacing
0094 focus: overlay.visible
0095
0096 Keys.onLeftPressed: if (leftAction.visible) leftAction.trigger()
0097 Keys.onRightPressed: if (rightAction.visible) rightAction.trigger()
0098
0099 Repeater {
0100 id: screenshotsRep
0101
0102 delegate: MouseArea {
0103 readonly property url imageSource: modelData
0104 readonly property real proportion: thumbnail.sourceSize.width>1 ? thumbnail.sourceSize.height/thumbnail.sourceSize.width : 1
0105 anchors.verticalCenter: parent.verticalCenter
0106 width: Math.max(50, height/proportion)
0107 height: screenshotsLayout.height - 2 * Kirigami.Units.largeSpacing
0108
0109 hoverEnabled: true
0110 cursorShape: Qt.PointingHandCursor
0111
0112 onClicked: {
0113 root.currentIndex = index
0114 overlay.open()
0115 }
0116
0117 Kirigami.ShadowedRectangle {
0118 visible: thumbnail.status == Image.Ready
0119 anchors.fill: thumbnail
0120 Kirigami.Theme.colorSet: Kirigami.Theme.View
0121 shadow.size: Kirigami.Units.largeSpacing
0122 shadow.color: Qt.rgba(0, 0, 0, 0.3)
0123 }
0124
0125 BusyIndicator {
0126 visible: running
0127 running: thumbnail.status == Image.Loading
0128 anchors.centerIn: parent
0129 }
0130
0131 AnimatedImage {
0132 id: thumbnail
0133 source: modelData
0134 height: parent.height
0135 fillMode: Image.PreserveAspectFit
0136 smooth: true
0137 }
0138 }
0139 }
0140 }
0141 clip: true
0142 readonly property var leftShadow: Shadow {
0143 parent: root
0144 anchors {
0145 left: parent.left
0146 top: parent.top
0147 bottom: parent.bottom
0148 }
0149 edge: Qt.LeftEdge
0150 width: Math.max(0, Math.min(root.width/5, root.contentX))
0151 }
0152
0153 readonly property var rightShadow: Shadow {
0154 parent: root
0155 anchors {
0156 right: parent.right
0157 top: parent.top
0158 bottom: parent.bottom
0159 }
0160 edge: Qt.RightEdge
0161 width: Math.max(0, Math.min(root.contentWidth - root.contentX - root.width)/5)
0162 }
0163 }