PageCharging.qml 2.52 KB
Newer Older
1 2 3 4 5 6
import QtQuick 2.8
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3
import App 1.0

Page {
7 8 9
    id: root
    property alias batteryInfo: battery

10 11 12
    function initializeValues()
    {
        infoText.text = qsTr( "Charging" )
13
        spinBoxes.chargingText = qsTr( "Charging in progress" )
14 15 16
        battery.initializeValues();
    }

17 18 19 20 21
    signal signalChargeCompleted();

    Component.onCompleted:
    {
        spinBoxes.indicatorText = false;
22
        spinBoxes.chargingVisible = false;
23 24
    }

25 26 27
    background: RowLayout  {
        spacing: 40
        anchors.centerIn: parent
28

29
        Image {
30 31 32
            Layout.alignment: Qt.AlignCenter
            Layout.preferredHeight: 240
            Layout.preferredWidth: 240
33
            fillMode: Image.PreserveAspectFit
34
            source: "Assets/Select/dial_outside_top_240x240.png"
35

36 37
            Text
            {
38 39
                id: infoText
                anchors.centerIn: parent
40
                color: "#42cc53"
41 42 43 44
                text: "00%"
                font.pixelSize: Variables.fontChargingPercentage
                verticalAlignment: Text.AlignVCenter
                horizontalAlignment: Text.AlignHCenter
45
            }
46 47
        }

48

49 50 51 52 53 54
        InfoSpinBoxes
        {
            id: spinBoxes
            Layout.preferredWidth: Variables.pixelSpinBoxWidth
            Layout.preferredHeight: 180
            Layout.alignment: Qt.AlignCenter
55 56 57 58 59
        }

        Battery
        {
            id: battery
60 61 62
            Layout.preferredWidth: 100
            Layout.preferredHeight: 280
            Layout.alignment: Qt.AlignCenter
63 64 65

            onChargedPercentageChanged :
            {
66
                updateSpinBoxes( chargedPercentage )
67
                azureEvent.charging = chargedPercentage;
68 69 70 71
            }

            onSignalChargeCompleted:
            {
72
                updateSpinBoxes( chargedPercentage )
73
                spinBoxes.chargingText = qsTr( "Charging Complete" )
74 75
                root.signalChargeCompleted();
            }
76 77 78 79 80 81 82 83 84 85 86

            function updateSpinBoxes( value )
            {
                var strvalue = Number(Math.floor(value)).toLocaleString(locale, 'f', 0) + "%";
                if ( value < 10 )
                    strvalue = "0" + strvalue;
                infoText.text = strvalue;
                spinBoxes.setChargeValue( value * 100 )
                spinBoxes.setTimeValue( ( battery.topUpCharge - value ) * Variables.timeOnePercent * 100 )
                spinBoxes.setPriceValue( ( value - battery.initialCharge) * Variables.priceOnePercent * 100 )
            }
87 88
        }
    }
89
}