Warning, /maui/mauikit/src/style.5/Tumbler.qml is written in an unsupported language. File is not indexed.
0001 /****************************************************************************
0002 **
0003 ** Copyright (C) 2017 The Qt Company Ltd.
0004 ** Contact: http://www.qt.io/licensing/
0005 **
0006 ** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
0007 **
0008 ** $QT_BEGIN_LICENSE:LGPL3$
0009 ** Commercial License Usage
0010 ** Licensees holding valid commercial Qt licenses may use this file in
0011 ** accordance with the commercial license agreement provided with the
0012 ** Software or, alternatively, in accordance with the terms contained in
0013 ** a written agreement between you and The Qt Company. For licensing terms
0014 ** and conditions see http://www.qt.io/terms-conditions. For further
0015 ** information use the contact form at http://www.qt.io/contact-us.
0016 **
0017 ** GNU Lesser General Public License Usage
0018 ** Alternatively, this file may be used under the terms of the GNU Lesser
0019 ** General Public License version 3 as published by the Free Software
0020 ** Foundation and appearing in the file LICENSE.LGPLv3 included in the
0021 ** packaging of this file. Please review the following information to
0022 ** ensure the GNU Lesser General Public License version 3 requirements
0023 ** will be met: https://www.gnu.org/licenses/lgpl.html.
0024 **
0025 ** GNU General Public License Usage
0026 ** Alternatively, this file may be used under the terms of the GNU
0027 ** General Public License version 2.0 or later as published by the Free
0028 ** Software Foundation and appearing in the file LICENSE.GPL included in
0029 ** the packaging of this file. Please review the following information to
0030 ** ensure the GNU General Public License version 2.0 requirements will be
0031 ** met: http://www.gnu.org/licenses/gpl-2.0.html.
0032 **
0033 ** $QT_END_LICENSE$
0034 **
0035 ****************************************************************************/
0036
0037 import QtQuick 2.12
0038 import QtQuick.Controls.impl 2.12
0039 import QtQuick.Templates 2.12 as T
0040 import org.mauikit.controls 1.3 as Maui
0041
0042 T.Tumbler
0043 {
0044 id: control
0045
0046 padding: Maui.Style.space.medium
0047
0048 implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
0049 implicitContentWidth + leftPadding + rightPadding) || 60 // ### remove 60 in Qt 6
0050 implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
0051 implicitContentHeight + topPadding + bottomPadding) || 200 // ### remove 200 in Qt 6
0052
0053 delegate: Text
0054 {
0055 text: modelData
0056 color: Maui.Theme.textColor
0057 font: control.font
0058 opacity: (1.0 - Math.abs(Tumbler.displacement) / (control.visibleItemCount / 2)) * (control.enabled ? 1 : 0.6)
0059 horizontalAlignment: Text.AlignHCenter
0060 verticalAlignment: Text.AlignVCenter
0061 }
0062
0063 contentItem: TumblerView
0064 {
0065 implicitWidth: 60
0066 implicitHeight: 200
0067 model: control.model
0068 delegate: control.delegate
0069 path: Path
0070 {
0071
0072 startX: control.contentItem.width / 2
0073 startY: -control.contentItem.delegateHeight / 2
0074 PathLine
0075 {
0076 x: control.contentItem.width / 2
0077 y: (control.visibleItemCount + 1) * control.contentItem.delegateHeight - control.contentItem.delegateHeight / 2
0078 }
0079 }
0080
0081 property real delegateHeight: control.availableHeight / control.visibleItemCount
0082 }
0083
0084 background: Rectangle
0085 {
0086 color: Maui.Theme.backgroundColor
0087 radius: Maui.Style.radiusV
0088
0089 MouseArea
0090 {
0091 property int wheelDelta: 0
0092
0093 anchors
0094 {
0095 fill: parent
0096 leftMargin: control.leftPadding
0097 rightMargin: control.rightPadding
0098 }
0099
0100 acceptedButtons: Qt.NoButton
0101
0102 onWheel:
0103 {
0104 var delta = wheel.angleDelta.y || wheel.angleDelta.x
0105 wheelDelta += delta;
0106 // magic number 120 for common "one click"
0107 // See: https://doc.qt.io/qt-5/qml-qtquick-wheelevent.html#angleDelta-prop
0108 while (wheelDelta >= 120) {
0109 wheelDelta -= 120;
0110 control.currentIndex = Math.min(control.count-1, control.currentIndex + 1);
0111 }
0112 while (wheelDelta <= -120) {
0113 wheelDelta += 120;
0114 control.currentIndex = Math.max(0, control.currentIndex -1);
0115 }
0116 }
0117 }
0118 }
0119 }