Warning, /plasma/qqc2-breeze-style/style/qtquickcontrols/SpinBox.qml is written in an unsupported language. File is not indexed.
0001 /* SPDX-FileCopyrightText: 2020 Noah Davis <noahadvs@gmail.com> 0002 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0003 */ 0004 0005 import QtQuick 0006 import QtQuick.Controls as Controls 0007 import QtQuick.Templates as T 0008 import org.kde.kirigami as Kirigami 0009 import org.kde.breeze.impl as Impl 0010 0011 T.SpinBox { 0012 id: control 0013 property real __downIndicatorWidth: down.indicator ? down.indicator.width : 0 0014 property real __upIndicatorWidth: up.indicator ? up.indicator.width : 0 0015 property real __leftIndicatorWidth: control.mirrored ? __upIndicatorWidth : __downIndicatorWidth 0016 property real __rightIndicatorWidth: control.mirrored ? __downIndicatorWidth : __upIndicatorWidth 0017 0018 implicitWidth: Math.max( 0019 implicitBackgroundWidth + leftInset + rightInset, 0020 implicitContentWidth + leftPadding + rightPadding, 0021 up.implicitIndicatorWidth + down.implicitIndicatorWidth 0022 ) 0023 implicitHeight: Math.max( 0024 implicitBackgroundHeight + topInset + bottomInset, 0025 implicitContentHeight + topPadding + bottomPadding, 0026 up.implicitIndicatorHeight, 0027 down.implicitIndicatorHeight 0028 ) 0029 0030 hoverEnabled: Qt.styleHints.useHoverEffects 0031 0032 Kirigami.Theme.colorSet: control.editable ? Kirigami.Theme.View : Kirigami.Theme.Button 0033 Kirigami.Theme.inherit: !Boolean(background) 0034 0035 editable: true 0036 inputMethodHints: Qt.ImhDigitsOnly 0037 wheelEnabled: true 0038 0039 padding: Kirigami.Units.mediumSpacing 0040 leftPadding: __leftIndicatorWidth 0041 rightPadding: __rightIndicatorWidth 0042 spacing: Kirigami.Units.mediumSpacing 0043 0044 validator: IntValidator { 0045 locale: control.locale.name 0046 bottom: Math.min(control.from, control.to) 0047 top: Math.max(control.from, control.to) 0048 } 0049 0050 down.indicator: Impl.SpinBoxIndicator { 0051 button: control.down 0052 alignment: Qt.AlignLeft 0053 mirrored: control.mirrored 0054 } 0055 0056 /* NOTE: There is a flaw in QQC2 SpinBox with how focus is handled. 0057 * Unless you make the TextInput unfocusable (not what you want), 0058 * you can't detect whether or not a spinbox has activeFocus or visualFocus. 0059 * This is because the TextInput takes the focus. 0060 * In order to detect if a SpinBox is focused, you must trust that the 0061 * contentItem will be the part that takes the focus. 0062 */ 0063 0064 contentItem: Controls.TextField { 0065 palette: control.palette 0066 leftPadding: control.spacing 0067 rightPadding: control.spacing 0068 topPadding: 0 0069 bottomPadding: 0 0070 // Intentionally using anchors so that left/right 0071 // control padding can be used like it normally would 0072 text: control.displayText 0073 font: control.font 0074 color: Kirigami.Theme.textColor 0075 selectionColor: Kirigami.Theme.highlightColor 0076 selectedTextColor: Kirigami.Theme.highlightedTextColor 0077 horizontalAlignment: Qt.AlignHCenter 0078 verticalAlignment: Qt.AlignVCenter 0079 0080 readOnly: !control.editable 0081 validator: control.validator 0082 inputMethodHints: control.inputMethodHints 0083 selectByMouse: true // Should this be disabled for mobile? 0084 background: null 0085 0086 // Since the contentItem receives focus (we make them editable by default), 0087 // the screen reader reads its Accessible properties instead of the SpinBox's 0088 Accessible.name: control.Accessible.name 0089 Accessible.description: control.Accessible.description 0090 } 0091 0092 up.indicator: Impl.SpinBoxIndicator { 0093 button: control.up 0094 alignment: Qt.AlignRight 0095 mirrored: control.mirrored 0096 } 0097 0098 background:Impl.TextEditBackground { 0099 control: control 0100 implicitWidth: Impl.Units.mediumControlHeight * 3 - Impl.Units.smallBorder * 2 0101 implicitHeight: Impl.Units.mediumControlHeight 0102 // Work around SpinBox focus handling flaw 0103 visualFocus: control.visualFocus || (control.contentItem.activeFocus && ( 0104 control.contentItem.focusReason == Qt.TabFocusReason || 0105 control.contentItem.focusReason == Qt.BacktabFocusReason || 0106 control.contentItem.focusReason == Qt.ShortcutFocusReason 0107 )) 0108 } 0109 }