summaryrefslogtreecommitdiff
path: root/modules/lock/WeatherInfo.qml
blob: 7ed64dc53ad97cc8e3adbbd21a57dea74c3bafda (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
import "root:/widgets"
import "root:/services"
import "root:/config"
import QtQuick
import QtQuick.Layouts

RowLayout {
    id: root

    Timer {
        running: true
        triggeredOnStart: true
        repeat: true
        interval: 900000 // 15 minutes
        onTriggered: Weather.reload()
    }

    spacing: Appearance.spacing.large

    MaterialIcon {
        id: icon

        Layout.alignment: Qt.AlignVCenter
        Layout.topMargin: Config.lock.sizes.border / 4

        animate: true
        text: Weather.icon || "cloud_alert"
        color: Colours.palette.m3secondary
        font.pointSize: Appearance.font.size.extraLarge * 2.5
    }

    ColumnLayout {
        Layout.alignment: Qt.AlignVCenter
        Layout.topMargin: Config.lock.sizes.border / 4
        Layout.rightMargin: Config.lock.sizes.border / 2

        spacing: Appearance.spacing.small

        StyledText {
            Layout.fillWidth: true

            animate: true
            text: Config.dashboard.useFahrenheit ? Weather.tempF : Weather.tempC
            color: Colours.palette.m3primary
            horizontalAlignment: Text.AlignHCenter
            font.pointSize: Appearance.font.size.extraLarge
            font.weight: 500
        }

        StyledText {
            Layout.fillWidth: true
            Layout.maximumWidth: Config.lock.sizes.weatherWidth - icon.implicitWidth

            animate: true
            text: Weather.description || qsTr("No weather")
            horizontalAlignment: Text.AlignHCenter
            font.pointSize: Appearance.font.size.large
            elide: Text.ElideRight
        }
    }
}