Warning, /plasma/plasma-bigscreen/kcms/audio-device-chooser/ui/views/TileView.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 QtQuick.Controls 2.14 as Controls 0011 import QtQuick.Window 2.14 0012 import org.kde.plasma.components 3.0 as PlasmaComponents 0013 import org.kde.kirigami 2.12 as Kirigami 0014 0015 0016 ListView { 0017 id: view 0018 property int columns: 3//Math.max(3, Math.floor(width / (units.gridUnit * 15))) 0019 0020 readonly property int cellWidth: Math.floor(width / columns ) 0021 0022 property Item navigationUp 0023 property Item navigationDown 0024 0025 Layout.fillWidth: true 0026 //Layout.fillHeight: true 0027 Layout.preferredHeight: Math.floor(cellWidth/screenRatio) 0028 readonly property real screenRatio: 0.95 //view.Window.window ? 0.9 : 1.6 0029 z: activeFocus ? 10: 1 0030 keyNavigationEnabled: true 0031 //Centering disabled as experiment 0032 //highlightRangeMode: ListView.ApplyRange 0033 highlightFollowsCurrentItem: true 0034 snapMode: ListView.SnapToItem 0035 cacheBuffer: width 0036 //preferredHighlightBegin: width/view.columns 0037 //preferredHighlightEnd: width/view.columns * 2 0038 0039 displayMarginBeginning: rotation.angle != 0 ? width*2 : 0 0040 displayMarginEnd: rotation.angle != 0 ? width*2 : 0 0041 highlightMoveDuration: Kirigami.Units.longDuration 0042 0043 transform: Rotation { 0044 id: rotation 0045 axis { x: 0; y: 1; z: 0 } 0046 angle: 0 0047 property real targetAngle: 30 0048 Behavior on angle { 0049 SmoothedAnimation { 0050 duration: Kirigami.Units.longDuration * 10 0051 } 0052 } 0053 origin.x: width/2 0054 } 0055 0056 Timer { 0057 id: rotateTimeOut 0058 interval: 25 0059 } 0060 Timer { 0061 id: rotateTimer 0062 interval: 500 0063 onTriggered: { 0064 if (rotateTimeOut.running) { 0065 rotation.angle = rotation.targetAngle; 0066 restart(); 0067 } else { 0068 rotation.angle = 0; 0069 } 0070 } 0071 } 0072 spacing: 0 0073 orientation: ListView.Horizontal 0074 0075 opacity: Kirigami.ScenePosition.y >= 0 0076 Behavior on opacity { 0077 OpacityAnimator { 0078 duration: Kirigami.Units.longDuration * 2 0079 easing.type: Easing.InOutQuad 0080 } 0081 } 0082 0083 property real oldContentX 0084 onContentXChanged: { 0085 if (oldContentX < contentX) { 0086 rotation.targetAngle = 30; 0087 } else { 0088 rotation.targetAngle = -30; 0089 } 0090 PlasmaComponents.ScrollBar.horizontal.opacity = 1; 0091 if (!rotateTimeOut.running) { 0092 rotateTimer.restart(); 0093 } 0094 rotateTimeOut.restart(); 0095 oldContentX = contentX; 0096 } 0097 PlasmaComponents.ScrollBar.horizontal: PlasmaComponents.ScrollBar { 0098 id: scrollBar 0099 opacity: 0 0100 interactive: false 0101 onOpacityChanged: disappearTimer.restart() 0102 Timer { 0103 id: disappearTimer 0104 interval: 1000 0105 onTriggered: scrollBar.opacity = 0; 0106 } 0107 Behavior on opacity { 0108 OpacityAnimator { 0109 duration: Kirigami.Units.longDuration 0110 easing.type: Easing.InOutQuad 0111 } 0112 } 0113 } 0114 0115 0116 move: Transition { 0117 SmoothedAnimation { 0118 property: "x" 0119 duration: Kirigami.Units.longDuration 0120 } 0121 } 0122 0123 Behavior on x { 0124 //Can't be an Animator 0125 NumberAnimation { 0126 duration: Kirigami.Units.longDuration * 2 0127 easing.type: Easing.InOutQuad 0128 } 0129 } 0130 0131 0132 Keys.onDownPressed: { 0133 if (!navigationDown) { 0134 return; 0135 } 0136 0137 if (navigationDown instanceof TileView) { 0138 navigationDown.currentIndex = navigationDown.indexAt(navigationDown.contentItem.mapFromItem(currentItem, cellWidth/2, height/2).x, height/2); 0139 } 0140 0141 navigationDown.forceActiveFocus(); 0142 } 0143 0144 Keys.onUpPressed: { 0145 if (!navigationUp) { 0146 return; 0147 } 0148 0149 if (navigationUp instanceof TileView) { 0150 navigationUp.currentIndex = navigationUp.indexAt(navigationUp.contentItem.mapFromItem(currentItem, cellWidth/2, height/2).x, height/2); 0151 } 0152 0153 navigationUp.forceActiveFocus(); 0154 } 0155 0156 }