diff --git a/src/qtdesktop/SpinBox.qml b/src/qtdesktop/SpinBox.qml index ef9eb0cc5f294044a6b7df24dda2af77875b948b..fbddf320a3f6a08f33a99dba4871581d91828cac 100644 --- a/src/qtdesktop/SpinBox.qml +++ b/src/qtdesktop/SpinBox.qml @@ -54,10 +54,29 @@ FocusScope { property int minimumWidth: 0 property int minimumHeight: 0 - property real value: 0.0 - property real maximumValue: 99 + /*! + The value of this SpinBox, clamped to \l minimumValue and \l maximumValue. + */ + property real value: 0 + /*! + The minimum value of the SpinBox range. + The \l value is clamped to this value. + */ property real minimumValue: 0 + /*! + The maximum value of the SpinBox range. + The \l value is clamped to this value. + */ + property real maximumValue: 99 + /*! + The amount by which the \l value is incremented/decremented. + */ property real singleStep: 1 + /* + \qmlproperty string inputMask + The inputMask for the text input. + */ + property alias inputMask: input.inputMask property string postfix property var styleHints:[] @@ -80,6 +99,10 @@ FocusScope { implicitWidth: loader.item ? loader.item.implicitWidth : 0 implicitHeight: loader.item ? loader.item.implicitHeight : 0 + /*! + Increments \l value by \l singleStep, clamping to \l maximumValue + if the new value is too large. + */ function increment() { setValue(input.text) value += singleStep @@ -88,6 +111,10 @@ FocusScope { input.text = value } + /*! + Increments \l value by \l singleStep, clamping to \l minimumValue + if the new value is too small. + */ function decrement() { setValue(input.text) value -= singleStep @@ -96,6 +123,10 @@ FocusScope { input.text = value } + /*! + Sets \l value to \a v, clamping to \l minimumValue and \l maximumValue + if \a v is not within this range. + */ function setValue(v) { var newval = parseFloat(v) if (newval > maximumValue) @@ -137,7 +168,8 @@ FocusScope { clip: true - verticalAlignment: Qt.AlignVCenter + horizontalAlignment: styleItem ? styleItem.horizontalTextAlignment : Qt.AlignLeft + verticalAlignment: styleItem ? styleItem.verticalTextAlignment : Qt.AlignVCenter anchors.fill: parent anchors.leftMargin: styleItem ? styleItem.leftMargin : 0 anchors.topMargin: styleItem ? styleItem.topMargin : 0 diff --git a/src/styles/Desktop/SpinBoxStyle.qml b/src/styles/Desktop/SpinBoxStyle.qml index fba04d5d348abf06973792b8de511f026ba3e6f7..ea4cb6f3f21a4daf71331ca2a31d7ed139eb76d4 100644 --- a/src/styles/Desktop/SpinBoxStyle.qml +++ b/src/styles/Desktop/SpinBoxStyle.qml @@ -50,6 +50,8 @@ Item { property int leftMargin: 2 + edit.anchors.leftMargin property int rightMargin: 2 + edit.anchors.rightMargin property int bottomMargin: edit.anchors.bottomMargin + property int horizontalTextAlignment: Qt.AlignLeft + property int verticalTextAlignment: Qt.AlignVCenter property color foregroundColor: syspal.text property color backgroundColor: syspal.base diff --git a/src/styles/SpinBoxStyle.qml b/src/styles/SpinBoxStyle.qml index 03f5d48b180e1f3ea8e18da004bfe1b83da10d67..5b3c2f9be65863255ac7b89e9829f1f4d41f8e06 100644 --- a/src/styles/SpinBoxStyle.qml +++ b/src/styles/SpinBoxStyle.qml @@ -58,6 +58,8 @@ Item { property int leftMargin: 4 property int rightMargin: 12 property int bottomMargin: 0 + property int horizontalTextAlignment: Qt.AlignLeft + property int verticalTextAlignment: Qt.AlignVCenter property color foregroundColor: syspal.text property color backgroundColor: syspal.base