Warning, /plasma/plasma-bigscreen/components/qml/AbstractDelegate.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2019 Aditya Mehra <aix.m@outlook.com> 0003 SPDX-FileCopyrightText: 2019 Marco Martin <mart@kde.org> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 import QtQuick 2.14 0009 import QtQuick.Layouts 1.14 0010 import QtGraphicalEffects 1.14 0011 0012 import org.kde.plasma.core 2.0 as PlasmaCore 0013 import org.kde.plasma.components 3.0 as PlasmaComponents 0014 import org.kde.kirigami 2.12 as Kirigami 0015 import org.kde.mycroft.bigscreen 1.0 as BigScreen 0016 0017 PlasmaComponents.ItemDelegate { 0018 id: delegate 0019 0020 readonly property Flickable listView: { 0021 var candidate = parent; 0022 while (candidate) { 0023 if (candidate instanceof Flickable) { 0024 return candidate; 0025 } 0026 candidate = candidate.parent; 0027 } 0028 return null; 0029 } 0030 readonly property bool isCurrent: {//print(text+index+" "+listView.currentIndex+activeFocus+" "+listView.moving) 0031 listView.currentIndex == index && activeFocus && !listView.moving 0032 } 0033 0034 highlighted: isCurrent 0035 property int borderSize: Kirigami.Units.smallSpacing 0036 property int baseRadius: 3 0037 0038 z: isCurrent ? 2 : 0 0039 0040 onClicked: { 0041 listView.forceActiveFocus() 0042 listView.currentIndex = index 0043 } 0044 0045 leftPadding: Kirigami.Units.largeSpacing * 2 0046 topPadding: Kirigami.Units.largeSpacing * 2 0047 rightPadding: Kirigami.Units.largeSpacing * 2 0048 bottomPadding: Kirigami.Units.largeSpacing * 2 0049 0050 leftInset: Kirigami.Units.largeSpacing 0051 topInset: Kirigami.Units.largeSpacing 0052 rightInset: Kirigami.Units.largeSpacing 0053 bottomInset: Kirigami.Units.largeSpacing 0054 0055 0056 Keys.onReturnPressed: { 0057 clicked(); 0058 } 0059 0060 contentItem: Item {} 0061 0062 background: Item { 0063 id: background 0064 0065 readonly property Item highlight: Rectangle { 0066 parent: delegate 0067 z: 1 0068 anchors { 0069 fill: parent 0070 } 0071 color: "transparent" 0072 border { 0073 width: delegate.borderSize 0074 color: delegate.Kirigami.Theme.highlightColor 0075 } 0076 opacity: delegate.isCurrent || delegate.highlighted 0077 Behavior on opacity { 0078 OpacityAnimator { 0079 duration: Kirigami.Units.longDuration/2 0080 easing.type: Easing.InOutQuad 0081 } 0082 } 0083 } 0084 0085 Kirigami.ShadowedRectangle { 0086 id: frame 0087 anchors { 0088 fill: parent 0089 } 0090 radius: delegate.baseRadius 0091 color: delegate.Kirigami.Theme.backgroundColor 0092 shadow { 0093 size: Kirigami.Units.largeSpacing * 2 0094 } 0095 0096 states: [ 0097 State { 0098 when: delegate.isCurrent 0099 PropertyChanges { 0100 target: delegate 0101 leftInset: 0 0102 rightInset: 0 0103 topInset: 0 0104 bottomInset: 0 0105 } 0106 PropertyChanges { 0107 target: background.highlight.anchors 0108 margins: 0 0109 } 0110 PropertyChanges { 0111 target: frame 0112 // baseRadius + borderSize preserves the original radius for the visible part of frame 0113 radius: delegate.baseRadius + delegate.borderSize 0114 } 0115 PropertyChanges { 0116 target: background.highlight 0117 // baseRadius + borderSize preserves the original radius for the visible part of frame 0118 radius: delegate.baseRadius + delegate.borderSize 0119 } 0120 }, 0121 State { 0122 when: !delegate.isCurrent 0123 PropertyChanges { 0124 target: delegate 0125 leftInset: Kirigami.Units.largeSpacing 0126 rightInset: Kirigami.Units.largeSpacing 0127 topInset: Kirigami.Units.largeSpacing 0128 bottomInset: Kirigami.Units.largeSpacing 0129 } 0130 PropertyChanges { 0131 target: background.highlight.anchors 0132 margins: Kirigami.Units.largeSpacing 0133 } 0134 PropertyChanges { 0135 target: frame 0136 radius: delegate.baseRadius 0137 } 0138 PropertyChanges { 0139 target: background.highlight 0140 radius: delegate.baseRadius 0141 } 0142 } 0143 ] 0144 0145 transitions: Transition { 0146 ParallelAnimation { 0147 NumberAnimation { 0148 property: "leftInset" 0149 duration: Kirigami.Units.longDuration 0150 easing.type: Easing.InOutQuad 0151 } 0152 NumberAnimation { 0153 property: "rightInset" 0154 duration: Kirigami.Units.longDuration 0155 easing.type: Easing.InOutQuad 0156 } 0157 NumberAnimation { 0158 property: "topInset" 0159 duration: Kirigami.Units.longDuration 0160 easing.type: Easing.InOutQuad 0161 } 0162 NumberAnimation { 0163 property: "bottomInset" 0164 duration: Kirigami.Units.longDuration 0165 easing.type: Easing.InOutQuad 0166 } 0167 NumberAnimation { 0168 property: "radius" 0169 duration: Kirigami.Units.longDuration 0170 easing.type: Easing.InOutQuad 0171 } 0172 NumberAnimation { 0173 property: "margins" 0174 duration: Kirigami.Units.longDuration 0175 easing.type: Easing.InOutQuad 0176 } 0177 } 0178 } 0179 } 0180 } 0181 }