Warning, /maui/nomad-style/SpinBox.qml is written in an unsupported language. File is not indexed.
0001 /*
0002 * Copyright 2017 Marco Martin <mart@kde.org>
0003 * Copyright 2017 The Qt Company Ltd.
0004 *
0005 * GNU Lesser General Public License Usage
0006 * Alternatively, this file may be used under the terms of the GNU Lesser
0007 * General Public License version 3 as published by the Free Software
0008 * Foundation and appearing in the file LICENSE.LGPLv3 included in the
0009 * packaging of this file. Please review the following information to
0010 * ensure the GNU Lesser General Public License version 3 requirements
0011 * will be met: https://www.gnu.org/licenses/lgpl.html.
0012 *
0013 * GNU General Public License Usage
0014 * Alternatively, this file may be used under the terms of the GNU
0015 * General Public License version 2.0 or later as published by the Free
0016 * Software Foundation and appearing in the file LICENSE.GPL included in
0017 * the packaging of this file. Please review the following information to
0018 * ensure the GNU General Public License version 2.0 requirements will be
0019 * met: http://www.gnu.org/licenses/gpl-2.0.html.
0020 */
0021
0022
0023 import QtQuick 2.6
0024 import QtQuick.Templates 2.3 as T
0025 import org.kde.kirigami 2.2 as Kirigami
0026 import org.kde.qqc2desktopstyle.private 1.0 as StylePrivate
0027
0028 T.SpinBox {
0029 id: controlRoot
0030 Kirigami.Theme.colorSet: Kirigami.Theme.View
0031 Kirigami.Theme.inherit: false
0032
0033 implicitWidth: Math.max(48, contentItem.implicitWidth + 2 * padding + up.indicator.implicitWidth)
0034 implicitHeight: contentItem.implicitHeight + topPadding + bottomPadding
0035
0036 padding: 6
0037 leftPadding: padding + (controlRoot.mirrored ? (up.indicator ? up.indicator.width : 0) : 0)
0038 rightPadding: padding + (controlRoot.mirrored ? 0 : (up.indicator ? up.indicator.width : 0))
0039
0040
0041 hoverEnabled: true
0042
0043 validator: IntValidator {
0044 locale: controlRoot.locale.name
0045 bottom: Math.min(controlRoot.from, controlRoot.to)
0046 top: Math.max(controlRoot.from, controlRoot.to)
0047 }
0048
0049 contentItem: TextInput {
0050 z: 2
0051 text: controlRoot.textFromValue(controlRoot.value, controlRoot.locale)
0052 opacity: controlRoot.enabled ? 1 : 0.3
0053
0054 font: controlRoot.font
0055 color: Kirigami.Theme.textColor
0056 selectionColor: Kirigami.Theme.highlightColor
0057 selectedTextColor: Kirigami.Theme.highlightedTextColor
0058 horizontalAlignment: Qt.AlignHCenter
0059 verticalAlignment: Qt.AlignVCenter
0060
0061 readOnly: !controlRoot.editable
0062 validator: controlRoot.validator
0063 inputMethodHints: Qt.ImhFormattedNumbersOnly
0064
0065 MouseArea {
0066 anchors.fill: parent
0067 onPressed: mouse.accepted = false;
0068 onWheel: {
0069 if (wheel.pixelDelta.y < 0 || wheel.angleDelta.y < 0) {
0070 controlRoot.decrease();
0071 } else {
0072 controlRoot.increase();
0073 }
0074 }
0075 }
0076 }
0077
0078 up.indicator: Item {
0079 implicitWidth: parent.height/2
0080 implicitHeight: implicitWidth
0081 x: controlRoot.mirrored ? 0 : parent.width - width
0082 }
0083 down.indicator: Item {
0084 implicitWidth: parent.height/2
0085 implicitHeight: implicitWidth
0086
0087 x: controlRoot.mirrored ? 0 : parent.width - width
0088 y: parent.height - height
0089 }
0090
0091
0092 background: StylePrivate.StyleItem {
0093 id: styleitem
0094 control: controlRoot
0095 elementType: "spinbox"
0096 anchors.fill: parent
0097 hover: controlRoot.hovered
0098 hasFocus: controlRoot.activeFocus
0099 enabled: controlRoot.enabled
0100
0101 value: (controlRoot.up.pressed ? 1 : 0) |
0102 (controlRoot.down.pressed ? 1<<1 : 0) |
0103 ( controlRoot.value != controlRoot.to ? (1<<2) : 0) |
0104 (controlRoot.value != controlRoot.from ? (1<<3) : 0) |
0105 (controlRoot.up.hovered ? 0x1 : 0) |
0106 (controlRoot.down.hovered ? (1<<1) : 0)
0107 }
0108 }