InfoCard.qml 4.16 KB
Newer Older
1
2
3
/*
 * SPDX-FileCopyrightText: 2020 Han Young <hanyoung@protonmail.com>
 * SPDX-FileCopyrightText: 2020 Devin Lin <espidev@gmail.com>
4
 * SPDX-FileCopyrightText: 2021 Nicolas Fella <nicolas.fella@gmx.de>
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

import QtQuick 2.12
import QtQuick.Controls 2.4
import QtQuick.Layouts 1.2
import QtCharts 2.3
import org.kde.kirigami 2.13 as Kirigami
import "backgrounds"

Kirigami.Card {

    id: root

    property var textColor: Kirigami.Theme.textColor

    contentItem: Item {
        implicitHeight: column.height
        Column {
            id: column
            spacing: Kirigami.Units.largeSpacing * 2

            // precipitation
            RowLayout {
                spacing: Kirigami.Units.largeSpacing
                Kirigami.Icon {
                    source: "raindrop"
                    Layout.minimumHeight: Kirigami.Theme.defaultFont.pointSize * 2
                    Layout.minimumWidth: Layout.minimumHeight * 1.5
                    color: weatherLocation.iconColor
                }
                Column {
                    spacing: Kirigami.Units.smallSpacing
                    Label {
                        font.weight: Font.Bold
                        text: i18n("Precipitation")
                        color: root.textColor
                    }
                    Label {
                        text: currentDay == null ? "" : currentDay.precipitation.toFixed(1) + "mm"
                        color: root.textColor
                    }
                }
            }

            // Humidity
            RowLayout {
                spacing: Kirigami.Units.largeSpacing
                Kirigami.Icon {
                    source: "compass"
                    Layout.minimumHeight: Kirigami.Theme.defaultFont.pointSize * 2
                    Layout.minimumWidth: Layout.minimumHeight * 1.5
                    color: weatherLocation.iconColor
                }
                Column {
                    spacing: Kirigami.Units.smallSpacing
                    Label {
                        font.weight: Font.Bold
                        text: i18n("Humidity")
                        color: root.textColor
                    }
                    Label {
                        text: currentDay == null ? "" : i18n("%1%", currentDay.humidity.toFixed(1))
                        color: root.textColor
                    }
                }
            }

            // Atmospheric pressure
            RowLayout {
                spacing: Kirigami.Units.largeSpacing
                Kirigami.Icon {
                    source: "speedometer"
                    Layout.minimumHeight: Kirigami.Theme.defaultFont.pointSize * 2
                    Layout.minimumWidth: Layout.minimumHeight * 1.5
                    color: weatherLocation.iconColor
                }
                Column {
                    spacing: Kirigami.Units.smallSpacing
                    Label {
                        font.weight: Font.Bold
                        text: i18n("Pressure")
                        color: root.textColor
                    }
                    Label {
                        text: currentDay == null ? "" : i18n("%1hPa", currentDay.pressure.toFixed(1))
                        color: root.textColor
                    }
                }
            }

            // UV Index
            RowLayout {
                spacing: Kirigami.Units.largeSpacing
                Kirigami.Icon {
                    source: "compass"
                    Layout.minimumHeight: Kirigami.Theme.defaultFont.pointSize * 2
                    Layout.minimumWidth: Layout.minimumHeight * 1.5
                    color: weatherLocation.iconColor
                }
                Column {
                    spacing: Kirigami.Units.smallSpacing
                    Label {
                        font.weight: Font.Bold
                        text: i18n("UV index")
                        color: root.textColor
                    }
                    Label {
                        text: currentDay == null ? "" : currentDay.uvIndex.toFixed(1)
                        color: root.textColor
                    }
                }
            }
        }
    }
}