summaryrefslogtreecommitdiffstats
path: root/app/qml/InfoWindow.qml
blob: 4acba5d97534cc707bab0fa80180802acc6d9215 (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import QtQuick 2.9
import QtQuick.Layouts 1.1
import QtQuick.Controls 2.0

Rectangle {
    id: infoWindow

    anchors.fill: parent
    color: "black"

    property date now: new Date
    Timer {
        interval: 100; running: true; repeat: true;
        onTriggered: parent.now = new Date
    }

    ColumnLayout {
        anchors.fill: parent
        spacing: 0

        Text {
            Layout.fillWidth: true
            Layout.fillHeight: false
            Layout.alignment: Qt.AlignHCenter
            Layout.topMargin: parent.height / 10

            text: now.toLocaleString(Qt.locale("en_US"), 'h:mm A')
            font.pixelSize: 40
            color: "white"
            horizontalAlignment: Text.AlignHCenter
            verticalAlignment: Text.AlignVCenter
            padding: 0
        }

        Text {
            id: speedText
            Layout.fillWidth: true
            Layout.alignment: Qt.AlignHCenter
            Layout.topMargin: parent.height / 10

            text: tbtnavi.vehicleSpeed.toFixed(0)
            color: "white"
            font.pixelSize: 280
            // Slight hack to shrink the border around the text by tweaking
            // the line height, note that it is font size dependent
            lineHeight: 0.8
            horizontalAlignment: Text.AlignHCenter
            verticalAlignment: Text.AlignVCenter
            padding: 0
        }
        Text {
            id: speedLabel
            Layout.fillWidth: true
            Layout.alignment: Qt.AlignHCenter

            text: "MPH"
            color: "white"
            font.pixelSize: 32
            font.bold: true
            horizontalAlignment: Text.AlignHCenter
            verticalAlignment: Text.AlignVCenter
            padding: 0
        }

        Text {
            id: rpmText
            Layout.fillWidth: true
            Layout.alignment: Qt.AlignHCenter
            Layout.topMargin: parent.height / 16

            text: tbtnavi.engineSpeed.toFixed(0)
            color: "white"
            font.pixelSize: 64
            font.bold: true
            horizontalAlignment: Text.AlignHCenter
            verticalAlignment: Text.AlignVCenter
            padding: 0
        }
        Text {
            id: rpmLabel
            Layout.fillWidth: true
            Layout.alignment: Qt.AlignHCenter

            text: "RPM"
            color: "white"
            font.pixelSize: 32
            font.bold: true
            horizontalAlignment: Text.AlignHCenter
            verticalAlignment: Text.AlignVCenter
            padding: 0
        }

        // Use height filling rectangle to push things together,
        // saving tinkering with minimum/preferred heights
        Rectangle {
            Layout.fillWidth: true
            Layout.fillHeight: true
            color: "black"
        }
    }
}