From a27bbc98f9ef0773a4a0edc0cc179da1800d3aaf Mon Sep 17 00:00:00 2001
From: Mitch Curtis <mitch.curtis@digia.com>
Date: Fri, 4 Jan 2013 17:59:30 +0100
Subject: [PATCH] Add some docs and properties to SpinBox.

Change-Id: I217fec885e50cf77d95f84fddc1aeda75b2183a8
Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
---
 src/qtdesktop/SpinBox.qml           | 38 ++++++++++++++++++++++++++---
 src/styles/Desktop/SpinBoxStyle.qml |  2 ++
 src/styles/SpinBoxStyle.qml         |  2 ++
 3 files changed, 39 insertions(+), 3 deletions(-)

diff --git a/src/qtdesktop/SpinBox.qml b/src/qtdesktop/SpinBox.qml
index ef9eb0cc5..fbddf320a 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 fba04d5d3..ea4cb6f3f 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 03f5d48b1..5b3c2f9be 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
-- 
GitLab