Warning, /plasma/plank-player/app/qml/FileItemDelegate.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2021 Aditya Mehra <aix.m@outlook.com> 0002 // 0003 // SPDX-License-Identifier: GPL-2.0-or-later 0004 0005 import QtQuick 2.15 0006 import QtQuick.Layouts 1.15 0007 import QtQuick.Controls 2.15 0008 import org.kde.kirigami 2.19 as Kirigami 0009 import Qt5Compat.GraphicalEffects 0010 0011 ItemDelegate { 0012 id: delegate 0013 property int borderSize: Kirigami.Units.smallSpacing 0014 property int baseRadius: 3 0015 0016 readonly property Flickable gridView: { 0017 var candidate = parent; 0018 while (candidate) { 0019 if (candidate instanceof Flickable) { 0020 return candidate; 0021 } 0022 candidate = candidate.parent; 0023 } 0024 return null; 0025 } 0026 0027 readonly property bool isCurrent: { 0028 gridView.currentIndex == index && activeFocus && !gridView.moving 0029 } 0030 0031 leftPadding: Kirigami.Units.largeSpacing * 2 0032 topPadding: Kirigami.Units.largeSpacing * 2 0033 rightPadding: Kirigami.Units.largeSpacing * 2 0034 bottomPadding: Kirigami.Units.largeSpacing * 2 0035 0036 leftInset: Kirigami.Units.largeSpacing 0037 topInset: Kirigami.Units.largeSpacing 0038 rightInset: Kirigami.Units.largeSpacing 0039 bottomInset: Kirigami.Units.largeSpacing 0040 0041 implicitWidth: gridView.cellWidth 0042 height: gridView.cellHeight 0043 0044 background: Item { 0045 id: background 0046 0047 readonly property Item highlight: Rectangle { 0048 parent: delegate 0049 z: 1 0050 anchors { 0051 fill: parent 0052 } 0053 color: "transparent" 0054 border { 0055 width: delegate.borderSize 0056 color: delegate.Kirigami.Theme.highlightColor 0057 } 0058 opacity: delegate.isCurrent || delegate.highlighted 0059 Behavior on opacity { 0060 OpacityAnimator { 0061 duration: Kirigami.Units.longDuration/2 0062 easing.type: Easing.InOutQuad 0063 } 0064 } 0065 } 0066 0067 Rectangle { 0068 id: frame 0069 anchors { 0070 fill: parent 0071 } 0072 radius: delegate.baseRadius 0073 color: delegate.Kirigami.Theme.backgroundColor 0074 layer.enabled: true 0075 layer.effect: DropShadow { 0076 transparentBorder: false 0077 horizontalOffset: 1.25 0078 verticalOffset: 1 0079 } 0080 0081 states: [ 0082 State { 0083 when: delegate.isCurrent 0084 PropertyChanges { 0085 target: delegate 0086 leftInset: 0 0087 rightInset: 0 0088 topInset: 0 0089 bottomInset: 0 0090 } 0091 PropertyChanges { 0092 target: background.highlight.anchors 0093 margins: 0 0094 } 0095 PropertyChanges { 0096 target: frame 0097 // baseRadius + borderSize preserves the original radius for the visible part of frame 0098 radius: delegate.baseRadius + delegate.borderSize 0099 } 0100 PropertyChanges { 0101 target: background.highlight 0102 // baseRadius + borderSize preserves the original radius for the visible part of frame 0103 radius: delegate.baseRadius + delegate.borderSize 0104 } 0105 }, 0106 State { 0107 when: !delegate.isCurrent 0108 PropertyChanges { 0109 target: delegate 0110 leftInset: Kirigami.Units.largeSpacing 0111 rightInset: Kirigami.Units.largeSpacing 0112 topInset: Kirigami.Units.largeSpacing 0113 bottomInset: Kirigami.Units.largeSpacing 0114 } 0115 PropertyChanges { 0116 target: background.highlight.anchors 0117 margins: Kirigami.Units.largeSpacing 0118 } 0119 PropertyChanges { 0120 target: frame 0121 radius: delegate.baseRadius 0122 } 0123 PropertyChanges { 0124 target: background.highlight 0125 radius: delegate.baseRadius 0126 } 0127 } 0128 ] 0129 0130 transitions: Transition { 0131 ParallelAnimation { 0132 NumberAnimation { 0133 property: "leftInset" 0134 duration: Kirigami.Units.longDuration 0135 easing.type: Easing.InOutQuad 0136 } 0137 NumberAnimation { 0138 property: "rightInset" 0139 duration: Kirigami.Units.longDuration 0140 easing.type: Easing.InOutQuad 0141 } 0142 NumberAnimation { 0143 property: "topInset" 0144 duration: Kirigami.Units.longDuration 0145 easing.type: Easing.InOutQuad 0146 } 0147 NumberAnimation { 0148 property: "bottomInset" 0149 duration: Kirigami.Units.longDuration 0150 easing.type: Easing.InOutQuad 0151 } 0152 NumberAnimation { 0153 property: "radius" 0154 duration: Kirigami.Units.longDuration 0155 easing.type: Easing.InOutQuad 0156 } 0157 NumberAnimation { 0158 property: "margins" 0159 duration: Kirigami.Units.longDuration 0160 easing.type: Easing.InOutQuad 0161 } 0162 } 0163 } 0164 } 0165 } 0166 0167 contentItem: ColumnLayout { 0168 spacing: Kirigami.Units.smallSpacing 0169 0170 Item { 0171 id: imgRoot 0172 //clip: true 0173 Layout.alignment: Qt.AlignTop 0174 Layout.fillWidth: true 0175 Layout.topMargin: -delegate.topPadding + delegate.topInset + extraBorder 0176 Layout.leftMargin: -delegate.leftPadding + delegate.leftInset + extraBorder 0177 Layout.rightMargin: -delegate.rightPadding + delegate.rightInset + extraBorder 0178 // Any width times 0.5625 is a 16:9 ratio 0179 // Adding baseRadius is needed to prevent the bottom from being rounded 0180 Layout.preferredHeight: width * 0.5625 + delegate.baseRadius 0181 // FIXME: another thing copied from AbstractDelegate 0182 property real extraBorder: 0 0183 0184 layer.enabled: true 0185 layer.effect: OpacityMask { 0186 cached: true 0187 maskSource: Rectangle { 0188 x: imgRoot.x; 0189 y: imgRoot.y 0190 width: imgRoot.width 0191 height: imgRoot.height 0192 radius: delegate.baseRadius 0193 } 0194 } 0195 0196 Kirigami.Icon { 0197 id: img 0198 source: "kdenlive-show-videothumb" 0199 anchors { 0200 fill: parent 0201 // To not round under 0202 bottomMargin: delegate.baseRadius 0203 } 0204 opacity: 1 0205 } 0206 0207 states: [ 0208 State { 0209 when: delegate.isCurrent 0210 PropertyChanges { 0211 target: imgRoot 0212 extraBorder: delegate.borderSize 0213 } 0214 }, 0215 State { 0216 when: !delegate.isCurrent 0217 PropertyChanges { 0218 target: imgRoot 0219 extraBorder: 0 0220 } 0221 } 0222 ] 0223 transitions: Transition { 0224 onRunningChanged: { 0225 // Optimize when animating the thumbnail 0226 img.smooth = !running 0227 } 0228 NumberAnimation { 0229 property: "extraBorder" 0230 duration: Kirigami.Units.longDuration 0231 easing.type: Easing.InOutQuad 0232 } 0233 } 0234 } 0235 0236 ColumnLayout { 0237 Layout.fillWidth: true 0238 Layout.fillHeight: true 0239 // Compensate for blank space created from not rounding thumbnail bottom corners 0240 Layout.topMargin: -delegate.baseRadius 0241 Layout.alignment: Qt.AlignLeft | Qt.AlignTop 0242 spacing: Kirigami.Units.smallSpacing 0243 0244 Kirigami.Heading { 0245 id: videoLabel 0246 Layout.fillWidth: true 0247 Layout.alignment: Qt.AlignLeft | Qt.AlignTop 0248 wrapMode: Text.Wrap 0249 level: 3 0250 maximumLineCount: 1 0251 elide: Text.ElideRight 0252 color: Kirigami.Theme.textColor 0253 Component.onCompleted: { 0254 text = fileName + (fileIsDir ? "/" : "") 0255 } 0256 } 0257 } 0258 } 0259 0260 Keys.onReturnPressed: (event)=> { 0261 clicked() 0262 } 0263 }