aboutsummaryrefslogtreecommitdiffstats
path: root/ProgressNextCross.qml
blob: 89a2b7b33826544ce9c12ec59f4e5bc1c6fc06d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// SPDX-License-Identifier: GPL-3.0+
// Copyright (C) 2021 AISIN CORPORATION
import QtQuick 2.0
import QtQuick.Controls 1.5
import QtQuick.Controls.Styles 1.4

Item {
	id: progress_next_cross

    visible: false

    // val [Input]
    //   distance to next cross. (unit = meter)
    //   when over the ProgressBar.maximumValue/m, progress bar indicates max (same as ProgressBar.maximumValue/m)
    function setProgress(val) {
        if (val > bar.value ) {
            bar.maximumValue = val
        }

        if ( 0 < val ) {
            bar.value = val
        }else{
            bar.value = 0
        }
	}

	ProgressBar {
		id: bar
        width: 800
        height: 20
        orientation: Qt.Horizontal
        value: 0
        minimumValue: 0
        maximumValue: 800

        style: ProgressBarStyle {
            progress: Rectangle {
                color: "green"
            }
        }
	}
    states: [
        State {
            name: "visible"; PropertyChanges { target: progress_next_cross; visible: true }},
        State {
            name: "invisible"; PropertyChanges { target: progress_next_cross; visible: false }}
    ]

}