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 2.11 0009 import QtQuick.Controls 2.11 0010 import QtQuick.Layouts 1.11 0011 import QtGraphicalEffects 1.11 0012 0013 import org.kde.kirigami 2.12 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 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 visible: leftAction.visible 0059 icon.name: leftAction.iconName 0060 onClicked: leftAction.triggered(null) 0061 } 0062 0063 Button { 0064 anchors { 0065 left: parent.right 0066 verticalCenter: parent.verticalCenter 0067 } 0068 visible: rightAction.visible 0069 icon.name: rightAction.iconName 0070 onClicked: rightAction.triggered(null) 0071 } 0072 0073 Kirigami.Action { 0074 id: leftAction 0075 icon.name: "arrow-left" 0076 enabled: overlay.visible && visible 0077 visible: root.currentIndex >= 1 && !indicator.running 0078 onTriggered: root.currentIndex = (root.currentIndex - 1) % root.count 0079 } 0080 0081 Kirigami.Action { 0082 id: rightAction 0083 icon.name: "arrow-right" 0084 enabled: overlay.visible && visible 0085 visible: root.currentIndex < (root.count - 1) && !indicator.running 0086 onTriggered: root.currentIndex = (root.currentIndex + 1) % root.count 0087 } 0088 } 0089 0090 Row { 0091 id: screenshotsLayout 0092 height: root.contentHeight 0093 spacing: Kirigami.Units.largeSpacing 0094 leftPadding: spacing 0095 rightPadding: spacing 0096 focus: overlay.visible 0097 0098 Keys.onLeftPressed: if (leftAction.visible) leftAction.trigger() 0099 Keys.onRightPressed: if (rightAction.visible) rightAction.trigger() 0100 0101 Repeater { 0102 id: screenshotsRep 0103 0104 delegate: MouseArea { 0105 readonly property url imageSource: modelData 0106 readonly property real proportion: thumbnail.sourceSize.width>1 ? thumbnail.sourceSize.height/thumbnail.sourceSize.width : 1 0107 anchors.verticalCenter: parent.verticalCenter 0108 width: Math.max(50, height/proportion) 0109 height: screenshotsLayout.height - 2 * Kirigami.Units.largeSpacing 0110 0111 hoverEnabled: true 0112 cursorShape: Qt.PointingHandCursor 0113 0114 onClicked: { 0115 root.currentIndex = index 0116 overlay.open() 0117 } 0118 0119 Kirigami.ShadowedRectangle { 0120 visible: thumbnail.status == Image.Ready 0121 anchors.fill: thumbnail 0122 Kirigami.Theme.colorSet: Kirigami.Theme.View 0123 shadow.size: Kirigami.Units.largeSpacing 0124 shadow.color: Qt.rgba(0, 0, 0, 0.3) 0125 } 0126 0127 BusyIndicator { 0128 visible: running 0129 running: thumbnail.status == Image.Loading 0130 anchors.centerIn: parent 0131 } 0132 0133 AnimatedImage { 0134 id: thumbnail 0135 source: modelData 0136 height: parent.height 0137 fillMode: Image.PreserveAspectFit 0138 smooth: true 0139 } 0140 } 0141 } 0142 } 0143 clip: true 0144 readonly property var leftShadow: Shadow { 0145 parent: root 0146 anchors { 0147 left: parent.left 0148 top: parent.top 0149 bottom: parent.bottom 0150 } 0151 edge: Qt.LeftEdge 0152 width: Math.max(0, Math.min(root.width/5, root.contentX)) 0153 } 0154 0155 readonly property var rightShadow: Shadow { 0156 parent: root 0157 anchors { 0158 right: parent.right 0159 top: parent.top 0160 bottom: parent.bottom 0161 } 0162 edge: Qt.RightEdge 0163 width: Math.max(0, Math.min(root.contentWidth - root.contentX - root.width)/5) 0164 } 0165 }