Warning, /maui/mauikit/src/style.5/SpinBox.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.Templates 2.12 as T
0039
0040 import org.mauikit.controls 1.2 as Maui
0041 import QtQuick.Window 2.1
0042
0043
0044 T.SpinBox
0045 {
0046 id: control
0047 opacity: control.enabled ? 1 : 0.5
0048
0049 Maui.Theme.colorSet: Maui.Theme.Button
0050 Maui.Theme.inherit: false
0051 hoverEnabled: !Maui.Handy.isMobile
0052
0053 property int preferredWidth : 100
0054
0055 implicitWidth: Math.max(preferredWidth, contentItem.implicitWidth +
0056 up.implicitIndicatorWidth +
0057 down.implicitIndicatorWidth + leftPadding + rightPadding)
0058 implicitHeight: Math.max(implicitContentHeight + topPadding + bottomPadding,
0059 up.implicitIndicatorHeight,
0060 down.implicitIndicatorHeight)
0061
0062
0063 editable: true
0064
0065 padding: Maui.Style.defaultPadding
0066 spacing: Maui.Style.space.small
0067
0068 leftPadding: (control.mirrored ? (up.indicator ? up.indicator.width : 0) : (down.indicator ? down.indicator.width : 0))
0069 rightPadding: (control.mirrored ? (down.indicator ? down.indicator.width : 0) : (up.indicator ? up.indicator.width : 0))
0070
0071 validator: IntValidator
0072 {
0073 locale: control.locale.name
0074 bottom: Math.min(control.from, control.to)
0075 top: Math.max(control.from, control.to)
0076 }
0077
0078 contentItem: TextInput
0079 {
0080 text: control.textFromValue(control.value, control.locale)
0081 opacity: control.enabled ? 1 : 0.3
0082
0083 font: control.font
0084 color: Maui.Theme.textColor
0085 selectionColor: Maui.Theme.highlightColor
0086 selectedTextColor: Maui.Theme.highlightedTextColor
0087 horizontalAlignment: Qt.AlignHCenter
0088 verticalAlignment: Qt.AlignVCenter
0089
0090 readOnly: !control.editable
0091 validator: control.validator
0092 inputMethodHints: Qt.ImhFormattedNumbersOnly
0093 renderType: Screen.devicePixelRatio % 1 !== 0 ? Text.QtRendering : Text.NativeRendering
0094 Behavior on color
0095 {
0096 Maui.ColorTransition{}
0097
0098 }
0099 MouseArea
0100 {
0101 anchors.fill: parent
0102 onPressed: mouse.accepted = false;
0103 onExited: wheelDelta = 0
0104 onWheel:
0105 {
0106 wheelDelta += wheel.angleDelta.y;
0107 // magic number 120 for common "one click"
0108 // See: http://qt-project.org/doc/qt-5/qml-qtquick-wheelevent.html#angleDelta-prop
0109 while (wheelDelta >= 120) {
0110 wheelDelta -= 120;
0111 controlRoot.increase();
0112 controlRoot.valueModified();
0113 }
0114 while (wheelDelta <= -120) {
0115 wheelDelta += 120;
0116 controlRoot.decrease();
0117 controlRoot.valueModified();
0118 }
0119 }
0120 cursorShape: Qt.IBeamCursor
0121 }
0122 }
0123
0124 up.indicator: Item
0125 {
0126 x: control.mirrored ? 0 : parent.width - width
0127 height: control.height
0128 width: height
0129
0130 Maui.Icon
0131 {
0132 source: "list-add"
0133 anchors.centerIn: parent
0134 width: Maui.Style.iconSizes.small
0135 height: width
0136 color: Maui.Theme.textColor
0137 }
0138 }
0139
0140 down.indicator: Item
0141 {
0142 x: control.mirrored ? parent.width - width : 0
0143 height: control.height
0144 width: height
0145
0146 Maui.Icon
0147 {
0148 source: "list-remove"
0149 anchors.centerIn: parent
0150 width: Maui.Style.iconSizes.small
0151 height: width
0152 color: Maui.Theme.textColor
0153 Behavior on color
0154 {
0155 Maui.ColorTransition{}
0156 }
0157
0158 }
0159 }
0160
0161 background: Rectangle
0162 {
0163 radius: Maui.Style.radiusV
0164
0165 color: control.hovered ? Maui.Theme.hoverColor : Maui.Theme.backgroundColor
0166
0167 Behavior on color
0168 {
0169 Maui.ColorTransition{}
0170
0171 }
0172 }
0173 }