2023-11-30 18:28:55 +00:00
|
|
|
// Copyright (C) 2023 The Qt Company Ltd.
|
2022-05-13 13:12:05 +00:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
2016-12-17 03:20:45 +00:00
|
|
|
|
2020-03-26 16:01:51 +00:00
|
|
|
import QtQuick
|
2023-05-11 02:27:08 +00:00
|
|
|
import WearableStyle
|
2016-12-17 03:20:45 +00:00
|
|
|
import "weather.js" as WeatherData
|
|
|
|
|
2017-03-13 07:34:08 +00:00
|
|
|
Item {
|
2023-11-30 18:28:55 +00:00
|
|
|
Flickable {
|
|
|
|
id: flick
|
|
|
|
anchors.fill:parent
|
|
|
|
anchors.margins: 15
|
|
|
|
anchors.topMargin: 40 + 15
|
|
|
|
contentWidth: width
|
|
|
|
contentHeight: column.height
|
|
|
|
|
|
|
|
Column {
|
|
|
|
id: column
|
|
|
|
spacing: 10
|
|
|
|
|
|
|
|
Item {
|
|
|
|
width: flick.contentWidth
|
|
|
|
height: 100
|
2017-03-13 11:56:17 +00:00
|
|
|
|
2023-11-30 18:28:55 +00:00
|
|
|
Row {
|
|
|
|
id: townName
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.top: parent.top
|
|
|
|
width: childrenRect.width
|
|
|
|
height: childrenRect.height
|
2017-03-13 11:56:17 +00:00
|
|
|
|
2023-11-30 18:28:55 +00:00
|
|
|
spacing: 10
|
|
|
|
Image {
|
|
|
|
id: sunIcon
|
|
|
|
source: (wDataCntr.weatherData
|
|
|
|
&& wDataCntr.weatherData.weather
|
|
|
|
&& wDataCntr.weatherData.weather[0]
|
|
|
|
&& wDataCntr.weatherData.weather[0].icon) ?
|
|
|
|
UIStyle.iconPath("weather-" + WeatherData.iconSelect(wDataCntr.weatherData.weather[0].icon)) : ""
|
|
|
|
width: 64
|
|
|
|
height: width
|
|
|
|
sourceSize.width: width
|
|
|
|
sourceSize.height: height
|
|
|
|
}
|
|
|
|
Text {
|
|
|
|
text: (wDataCntr.weatherData
|
|
|
|
&& wDataCntr.weatherData.name) ?
|
|
|
|
wDataCntr.weatherData.name : ""
|
|
|
|
anchors.verticalCenter: sunIcon.verticalCenter
|
|
|
|
color: UIStyle.textColor
|
|
|
|
font: UIStyle.h1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Text {
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.top: townName.bottom
|
|
|
|
text: (wDataCntr.weatherData
|
|
|
|
&& wDataCntr.weatherData.weather
|
|
|
|
&& wDataCntr.weatherData.weather[0]
|
|
|
|
&& wDataCntr.weatherData.weather[0].main) ?
|
|
|
|
wDataCntr.weatherData.weather[0].main : ""
|
|
|
|
color: UIStyle.textColor
|
|
|
|
font: UIStyle.h3
|
|
|
|
}
|
|
|
|
}
|
2017-03-13 11:56:17 +00:00
|
|
|
|
2023-11-30 18:28:55 +00:00
|
|
|
ListItem {
|
|
|
|
width: flick.contentWidth
|
|
|
|
height: 92
|
2017-03-13 11:56:17 +00:00
|
|
|
|
|
|
|
Image {
|
2023-11-30 18:28:55 +00:00
|
|
|
id: thermoimage
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.leftMargin: 20
|
|
|
|
anchors.topMargin: 17
|
|
|
|
source: UIStyle.iconPath("thermometer")
|
2017-03-13 11:56:17 +00:00
|
|
|
}
|
2016-12-17 03:20:45 +00:00
|
|
|
|
2023-11-30 18:28:55 +00:00
|
|
|
Text {
|
|
|
|
anchors.left: thermoimage.right
|
|
|
|
anchors.verticalCenter: thermoimage.verticalCenter
|
|
|
|
anchors.leftMargin: 5
|
|
|
|
text: qsTr("Temperature")
|
|
|
|
font: UIStyle.h4
|
|
|
|
color: UIStyle.textColor
|
|
|
|
}
|
2017-03-13 11:56:17 +00:00
|
|
|
|
2023-11-30 18:28:55 +00:00
|
|
|
Text {
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.verticalCenter: thermoimage.verticalCenter
|
|
|
|
anchors.rightMargin: 20
|
|
|
|
text: (wDataCntr.weatherData
|
|
|
|
&& wDataCntr.weatherData.main
|
|
|
|
&& wDataCntr.weatherData.main.temp) ?
|
|
|
|
WeatherData.formatTemp(wDataCntr.weatherData.main.temp) : ""
|
|
|
|
font: UIStyle.h3
|
|
|
|
color: UIStyle.textColor
|
|
|
|
}
|
2017-03-13 13:42:17 +00:00
|
|
|
|
2023-11-30 18:28:55 +00:00
|
|
|
Text {
|
|
|
|
id: maxtxt
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.leftMargin: 20
|
|
|
|
anchors.bottomMargin: 17
|
|
|
|
text: qsTr("Max")
|
|
|
|
font: UIStyle.h4
|
|
|
|
color: UIStyle.textColor
|
|
|
|
}
|
2017-03-13 13:42:17 +00:00
|
|
|
|
2023-11-30 18:28:55 +00:00
|
|
|
Text {
|
|
|
|
anchors.left: maxtxt.right
|
|
|
|
anchors.verticalCenter: maxtxt.verticalCenter
|
|
|
|
anchors.leftMargin: 10
|
|
|
|
text: (wDataCntr.weatherData
|
|
|
|
&& wDataCntr.weatherData.main
|
|
|
|
&& wDataCntr.weatherData.main.temp_max) ?
|
|
|
|
WeatherData.formatTemp(wDataCntr.weatherData.main.temp_max) : ""
|
|
|
|
font: UIStyle.h3
|
|
|
|
color: UIStyle.textColor
|
2017-03-13 11:56:17 +00:00
|
|
|
}
|
2016-12-17 03:20:45 +00:00
|
|
|
|
2023-11-30 18:28:55 +00:00
|
|
|
Text {
|
|
|
|
id: mintxt
|
|
|
|
anchors.horizontalCenter: maxtxt.horizontalCenter
|
|
|
|
anchors.verticalCenter: maxtxt.verticalCenter
|
|
|
|
anchors.horizontalCenterOffset: parent.width / 2
|
|
|
|
text: qsTr("Min")
|
|
|
|
font: UIStyle.h4
|
|
|
|
color: UIStyle.textColor
|
|
|
|
}
|
2016-12-17 03:20:45 +00:00
|
|
|
|
2023-11-30 18:28:55 +00:00
|
|
|
Text {
|
|
|
|
anchors.left: mintxt.right
|
|
|
|
anchors.verticalCenter: mintxt.verticalCenter
|
|
|
|
anchors.leftMargin: 10
|
|
|
|
text: (wDataCntr.weatherData
|
|
|
|
&& wDataCntr.weatherData.main
|
|
|
|
&& wDataCntr.weatherData.main.temp_min) ?
|
|
|
|
WeatherData.formatTemp(wDataCntr.weatherData.main.temp_min) : ""
|
|
|
|
font: UIStyle.h3
|
|
|
|
color: UIStyle.textColor
|
|
|
|
}
|
|
|
|
}
|
2016-12-17 03:20:45 +00:00
|
|
|
|
2023-11-30 18:28:55 +00:00
|
|
|
ListItem {
|
|
|
|
width: flick.contentWidth
|
|
|
|
height: 50
|
2016-12-17 03:20:45 +00:00
|
|
|
|
2023-11-30 18:28:55 +00:00
|
|
|
Image {
|
|
|
|
id: sunriseIcon
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.leftMargin: 20
|
|
|
|
anchors.topMargin: 17
|
|
|
|
source: UIStyle.iconPath("sunrise")
|
|
|
|
}
|
2016-12-17 03:20:45 +00:00
|
|
|
|
2023-11-30 18:28:55 +00:00
|
|
|
Text {
|
|
|
|
id: sunriseText
|
|
|
|
anchors.left: sunriseIcon.right
|
|
|
|
anchors.verticalCenter: sunriseIcon.verticalCenter
|
|
|
|
anchors.leftMargin: 5
|
|
|
|
text: qsTr("Sunrise")
|
|
|
|
font: UIStyle.h4
|
|
|
|
color: UIStyle.textColor
|
|
|
|
}
|
|
|
|
Text {
|
|
|
|
anchors.left: sunriseText.right
|
|
|
|
anchors.verticalCenter: sunriseText.verticalCenter
|
|
|
|
anchors.leftMargin: 15
|
|
|
|
text: (wDataCntr.weatherData
|
|
|
|
&& wDataCntr.weatherData.sys
|
|
|
|
&& wDataCntr.weatherData.sys.sunrise) ?
|
|
|
|
WeatherData.getTimeHMS(wDataCntr.weatherData.sys.sunrise) : ""
|
|
|
|
font: UIStyle.h3
|
|
|
|
color: UIStyle.textColor
|
2017-03-13 11:56:17 +00:00
|
|
|
}
|
2017-03-13 13:42:17 +00:00
|
|
|
|
2023-11-30 18:28:55 +00:00
|
|
|
Image {
|
|
|
|
id: sunsetIcon
|
|
|
|
anchors.right: sunsetText.left
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.rightMargin: 5
|
|
|
|
source: UIStyle.iconPath("sunset")
|
|
|
|
}
|
2016-12-17 03:20:45 +00:00
|
|
|
|
2023-11-30 18:28:55 +00:00
|
|
|
Text {
|
|
|
|
id: sunsetText
|
|
|
|
anchors.right: sunsetValue.left
|
|
|
|
anchors.verticalCenter: sunsetIcon.verticalCenter
|
|
|
|
anchors.rightMargin: 15
|
|
|
|
text: qsTr("Sunset")
|
|
|
|
font: UIStyle.h4
|
|
|
|
color: UIStyle.textColor
|
|
|
|
}
|
2017-03-13 13:42:17 +00:00
|
|
|
|
2023-11-30 18:28:55 +00:00
|
|
|
Text {
|
|
|
|
id: sunsetValue
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.verticalCenter: sunsetText.verticalCenter
|
|
|
|
anchors.rightMargin: 20
|
|
|
|
text: (wDataCntr.weatherData
|
|
|
|
&& wDataCntr.weatherData.sys
|
|
|
|
&& wDataCntr.weatherData.sys.sunset) ?
|
|
|
|
WeatherData.getTimeHMS(wDataCntr.weatherData.sys.sunset) : ""
|
|
|
|
font: UIStyle.h3
|
|
|
|
color: UIStyle.textColor
|
2016-12-17 03:20:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-30 18:28:55 +00:00
|
|
|
ListItem {
|
|
|
|
width: flick.contentWidth
|
|
|
|
height: 50
|
2016-12-17 03:20:45 +00:00
|
|
|
|
2017-03-13 11:56:17 +00:00
|
|
|
Image {
|
2023-11-30 18:28:55 +00:00
|
|
|
id: windIcon
|
|
|
|
anchors.left: parent.left
|
2017-03-13 11:56:17 +00:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2023-11-30 18:28:55 +00:00
|
|
|
anchors.leftMargin: 20
|
|
|
|
anchors.topMargin: 17
|
|
|
|
source: UIStyle.iconPath("wind")
|
2017-03-13 11:56:17 +00:00
|
|
|
}
|
2016-12-17 03:20:45 +00:00
|
|
|
|
2023-11-30 18:28:55 +00:00
|
|
|
Text {
|
|
|
|
id: windText
|
|
|
|
anchors.left: windIcon.right
|
2017-03-13 11:56:17 +00:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2023-11-30 18:28:55 +00:00
|
|
|
anchors.leftMargin: 5
|
|
|
|
text: qsTr("Wind")
|
|
|
|
font: UIStyle.h4
|
|
|
|
color: UIStyle.textColor
|
|
|
|
}
|
2017-03-13 13:42:17 +00:00
|
|
|
|
2023-11-30 18:28:55 +00:00
|
|
|
Text {
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.rightMargin: 20
|
|
|
|
text: (wDataCntr.weatherData
|
|
|
|
&& wDataCntr.weatherData.wind
|
|
|
|
&& wDataCntr.weatherData.wind.speed) ?
|
|
|
|
Math.round(wDataCntr.weatherData.wind.speed * 1.61) + " km/h" : ""
|
|
|
|
font: UIStyle.h3
|
|
|
|
color: UIStyle.textColor
|
2016-12-17 03:20:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-30 18:28:55 +00:00
|
|
|
ListItem {
|
|
|
|
width: flick.contentWidth
|
|
|
|
height: 50
|
2016-12-17 03:20:45 +00:00
|
|
|
|
2023-11-30 18:28:55 +00:00
|
|
|
Image {
|
|
|
|
id: humidityIcon
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.leftMargin: 20
|
|
|
|
anchors.topMargin: 17
|
|
|
|
source: UIStyle.iconPath("drop")
|
|
|
|
}
|
2016-12-17 03:20:45 +00:00
|
|
|
|
2023-11-30 18:28:55 +00:00
|
|
|
Text {
|
|
|
|
id: humidityText
|
|
|
|
anchors.left: humidityIcon.right
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.leftMargin: 5
|
|
|
|
text: qsTr("Humidity")
|
|
|
|
font: UIStyle.h4
|
|
|
|
color: UIStyle.textColor
|
|
|
|
}
|
2016-12-17 03:20:45 +00:00
|
|
|
|
2023-11-30 18:28:55 +00:00
|
|
|
Text {
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.rightMargin: 20
|
|
|
|
text: (wDataCntr.weatherData
|
|
|
|
&& wDataCntr.weatherData.main
|
|
|
|
&& wDataCntr.weatherData.main.humidity) ?
|
|
|
|
wDataCntr.weatherData.main.humidity + " %" : ""
|
|
|
|
font: UIStyle.h3
|
|
|
|
color: UIStyle.textColor
|
2016-12-17 03:20:45 +00:00
|
|
|
}
|
2023-11-30 18:28:55 +00:00
|
|
|
}
|
2016-12-17 03:20:45 +00:00
|
|
|
|
2023-11-30 18:28:55 +00:00
|
|
|
ListItem {
|
|
|
|
width: flick.contentWidth
|
|
|
|
height: 50
|
2016-12-17 03:20:45 +00:00
|
|
|
|
2023-11-30 18:28:55 +00:00
|
|
|
Image {
|
|
|
|
id: pressureIcon
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.leftMargin: 20
|
|
|
|
anchors.topMargin: 17
|
|
|
|
source: UIStyle.iconPath("pressure")
|
|
|
|
}
|
2016-12-17 03:20:45 +00:00
|
|
|
|
2023-11-30 18:28:55 +00:00
|
|
|
Text {
|
|
|
|
id: pressureText
|
|
|
|
anchors.left: pressureIcon.right
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.leftMargin: 5
|
|
|
|
text: qsTr("HPA")
|
|
|
|
font: UIStyle.h4
|
|
|
|
color: UIStyle.textColor
|
|
|
|
}
|
|
|
|
|
|
|
|
Text {
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.rightMargin: 20
|
|
|
|
text: (wDataCntr.weatherData
|
|
|
|
&& wDataCntr.weatherData.main
|
|
|
|
&& wDataCntr.weatherData.main.pressure) ?
|
|
|
|
Math.round(wDataCntr.weatherData.main.pressure) + " hpa" : ""
|
|
|
|
font: UIStyle.h3
|
|
|
|
color: UIStyle.textColor
|
2016-12-17 03:20:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-03-13 11:56:17 +00:00
|
|
|
}
|
2016-12-17 03:20:45 +00:00
|
|
|
|
2017-03-13 11:56:17 +00:00
|
|
|
QtObject {
|
|
|
|
id: wDataCntr
|
|
|
|
property var weatherData
|
|
|
|
}
|
|
|
|
Component.onCompleted: {
|
|
|
|
WeatherData.requestWeatherData(wDataCntr)
|
2016-12-17 03:20:45 +00:00
|
|
|
}
|
|
|
|
}
|