Warning, /plasma/plasma-bigscreen/kcms/bigscreen-settings/ui/delegates/Digit.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  *   SPDX-FileCopyrightText: 2021 Aditya Mehra <aix.m@outlook.com>
0003  *   SPDX-FileCopyrightText: 2011 Marco Martin <mart@kde.org>
0004  *
0005  *   SPDX-License-Identifier: LGPL-2.0-or-later
0006  */
0007 
0008 import QtQuick 2.14
0009 import org.kde.kirigami as Kirigami
0010 
0011 Item {
0012     id: root
0013 
0014     property alias model: spinnerView.model
0015     property alias currentIndex: spinnerView.currentIndex
0016     property alias delegate: spinnerView.delegate
0017     property alias moving: spinnerView.moving
0018     property int selectedIndex: -1
0019     property int fontSize: 14
0020 
0021     width: parent.width / 3
0022     height: parent.height
0023 
0024     Text {
0025         id: placeHolder
0026         visible: false
0027         font.pointSize: root.fontSize
0028         text: "00"
0029     }
0030 
0031     Keys.onUpPressed: {
0032         spinnerView.incrementCurrentIndex()
0033         selectedIndex = spinnerView.ownIndex
0034     }
0035 
0036     Keys.onDownPressed: {
0037         spinnerView.decrementCurrentIndex()
0038         selectedIndex = spinnerView.ownIndex
0039     }
0040 
0041     PathView {
0042         id: spinnerView
0043         anchors.fill: parent
0044         model: 60
0045         clip: true
0046         pathItemCount: 5
0047         dragMargin: 800
0048         preferredHighlightBegin: 0.5
0049         preferredHighlightEnd: 0.5
0050         property int ownIndex: currentIndex
0051 
0052         delegate: Text {
0053             horizontalAlignment: Text.AlignHCenter
0054             width: spinnerView.width
0055             text: index < 10 ? "0"+index : index
0056             color: root.focus && root.currentIndex == index ? Kirigami.Theme.linkColor : Kirigami.Theme.textColor
0057             font.pointSize: root.fontSize
0058             opacity: PathView.itemOpacity
0059         }
0060 
0061         onMovingChanged: {
0062             userConfiguring = true
0063             if (!moving) {
0064                 selectedIndex = spinnerView.ownIndex
0065             }
0066         }
0067 
0068         path: Path {
0069             startX: spinnerView.width/2
0070             startY: spinnerView.height + 1.5*placeHolder.height
0071             PathAttribute { name: "itemOpacity"; value: 0 }
0072             PathLine {
0073                 x: spinnerView.width/2
0074                 y: spinnerView.height/2
0075             }
0076             PathAttribute { name: "itemOpacity"; value: 1 }
0077             PathLine {
0078                 x: spinnerView.width/2
0079                 y: -1.5*placeHolder.height
0080             }
0081             PathAttribute { name: "itemOpacity"; value: 0 }
0082         }
0083     }
0084 }
0085