| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- // Copyright (C) 2017 The Qt Company Ltd.
- // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
- // Qt-Security score:significant reason:default
- import QtQuick
- import QtQuick.Controls.impl
- import QtQuick.Templates as T
- T.SpinBox {
- id: control
- // Note: the width of the indicators are calculated into the padding
- implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
- contentItem.implicitWidth + leftPadding + rightPadding)
- implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
- implicitContentHeight + topPadding + bottomPadding,
- up.implicitIndicatorHeight, down.implicitIndicatorHeight)
- leftPadding: padding + (control.mirrored ? (up.indicator ? up.indicator.width : 0) : (down.indicator ? down.indicator.width : 0))
- rightPadding: padding + (control.mirrored ? (down.indicator ? down.indicator.width : 0) : (up.indicator ? up.indicator.width : 0))
- validator: IntValidator {
- locale: control.locale.name
- bottom: Math.min(control.from, control.to)
- top: Math.max(control.from, control.to)
- }
- contentItem: TextInput {
- z: 2
- text: control.displayText
- clip: width < implicitWidth
- padding: 6
- font: control.font
- color: control.palette.text
- selectionColor: control.palette.highlight
- selectedTextColor: control.palette.highlightedText
- horizontalAlignment: Qt.AlignHCenter
- verticalAlignment: Qt.AlignVCenter
- readOnly: !control.editable
- validator: control.validator
- inputMethodHints: control.inputMethodHints
- Rectangle {
- width: parent.width
- height: parent.height
- visible: control.activeFocus
- color: "transparent"
- border.color: control.palette.highlight
- border.width: 2
- }
- }
- up.indicator: Rectangle {
- x: control.mirrored ? 0 : control.width - width
- height: control.height
- implicitWidth: 40
- implicitHeight: 40
- color: control.up.pressed ? control.palette.mid : control.palette.button
- border.color: enabled ? control.palette.text : control.palette.mid
- border.width: Qt.styleHints.accessibility.contrastPreference === Qt.HighContrast ? 1 : 0
- Rectangle {
- x: (parent.width - width) / 2
- y: (parent.height - height) / 2
- width: parent.width / 3
- height: 2
- color: enabled ? control.palette.buttonText : control.palette.mid
- }
- Rectangle {
- x: (parent.width - width) / 2
- y: (parent.height - height) / 2
- width: 2
- height: parent.width / 3
- color: enabled ? control.palette.buttonText : control.palette.mid
- }
- }
- down.indicator: Rectangle {
- x: control.mirrored ? parent.width - width : 0
- height: control.height
- implicitWidth: 40
- implicitHeight: 40
- color: control.down.pressed ? control.palette.mid : control.palette.button
- border.color: enabled ? control.palette.text : control.palette.mid
- border.width: Qt.styleHints.accessibility.contrastPreference === Qt.HighContrast ? 1 : 0
- Rectangle {
- x: (parent.width - width) / 2
- y: (parent.height - height) / 2
- width: parent.width / 3
- height: 2
- color: enabled ? control.palette.buttonText : control.palette.mid
- }
- }
- background: Rectangle {
- implicitWidth: 140
- color: enabled ? control.palette.base : control.palette.button
- border.color: {
- if (Qt.styleHints.accessibility.contrastPreference !== Qt.HighContrast)
- return control.palette.button
- return enabled ? control.palette.text : control.palette.mid
- }
- }
- }
|