SpinBoxPrice.qml 1.01 KB
Newer Older
1 2
import QtQuick 2.6
import QtQuick.Controls 2.1
3
import App 1.0
4 5 6 7

SpinBoxBase
{
    id: infoSpinBox
8
    to: 100 * 100
9

10 11 12 13 14 15 16
    property int decimals: 2
    property real realValue: value / 100

    validator: DoubleValidator {
        bottom: Math.min(infoSpinBox.from, infoSpinBox.to)
        top:  Math.max(infoSpinBox.from, infoSpinBox.to)
    }
17

18 19 20 21 22
    textFromValue: function(value, locale) {
        var numberValue = Number(value / 100).toLocaleString(locale, 'f', infoSpinBox.decimals)
        if ( ( value / 100 ) <  10 )
            numberValue = "0" +  numberValue
        return numberValue + " \u20ac"
23 24 25
    }

    valueFromText: function(text, locale) {
26
        return Number.fromLocaleString(locale, text.substring(0, text.lenght-2)) * 100
27
    }
28 29 30 31 32 33 34 35 36 37 38

    Rectangle
    {
        color: "transparent"
        anchors.top: parent.top
        anchors.bottom: parent.bottom
        anchors.left: parent.left
        anchors.right: parent.right
        border.color: "#41CD52"
        border.width: Variables.pixelBorderSpinBox
    }
39
}