mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 21:42:51 -05:00
@@ -20,7 +20,19 @@ Rectangle {
|
||||
}
|
||||
}
|
||||
|
||||
readonly property string dateText: (daily ? root.forecastData?.day : root.forecastData?.time) ?? "--"
|
||||
readonly property string dateText: {
|
||||
if (daily)
|
||||
return root.forecastData?.day ?? "--";
|
||||
if (!root.forecastData?.rawTime)
|
||||
return root.forecastData?.time ?? "--";
|
||||
try {
|
||||
const date = new Date(root.forecastData.rawTime);
|
||||
const format = SettingsData.use24HourClock ? "HH:mm" : "h:mm AP";
|
||||
return date.toLocaleTimeString(Qt.locale(), format);
|
||||
} catch (e) {
|
||||
return root.forecastData?.time ?? "--";
|
||||
}
|
||||
}
|
||||
|
||||
readonly property var minTemp: WeatherService.formatTemp(root.forecastData?.tempMin)
|
||||
readonly property var maxTemp: WeatherService.formatTemp(root.forecastData?.tempMax)
|
||||
@@ -4,7 +4,6 @@ import QtQuick.Shapes
|
||||
import qs.Common
|
||||
import qs.Services
|
||||
import qs.Widgets
|
||||
import qs.Modules.DankBar.Widgets
|
||||
|
||||
Item {
|
||||
id: root
|
||||
@@ -261,7 +260,17 @@ Item {
|
||||
|
||||
StyledText {
|
||||
id: sunriseText
|
||||
text: WeatherService.weather.sunrise || ""
|
||||
text: {
|
||||
if (!WeatherService.weather.rawSunrise)
|
||||
return WeatherService.weather.sunrise || "";
|
||||
try {
|
||||
const date = new Date(WeatherService.weather.rawSunrise);
|
||||
const format = SettingsData.use24HourClock ? "HH:mm" : "h:mm AP";
|
||||
return date.toLocaleTimeString(Qt.locale(), format);
|
||||
} catch (e) {
|
||||
return WeatherService.weather.sunrise || "";
|
||||
}
|
||||
}
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.6)
|
||||
anchors.left: sunriseIcon.right
|
||||
@@ -285,7 +294,17 @@ Item {
|
||||
|
||||
StyledText {
|
||||
id: sunsetText
|
||||
text: WeatherService.weather.sunset || ""
|
||||
text: {
|
||||
if (!WeatherService.weather.rawSunset)
|
||||
return WeatherService.weather.sunset || "";
|
||||
try {
|
||||
const date = new Date(WeatherService.weather.rawSunset);
|
||||
const format = SettingsData.use24HourClock ? "HH:mm" : "h:mm AP";
|
||||
return date.toLocaleTimeString(Qt.locale(), format);
|
||||
} catch (e) {
|
||||
return WeatherService.weather.sunset || "";
|
||||
}
|
||||
}
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.6)
|
||||
anchors.left: sunsetIcon.right
|
||||
@@ -324,14 +343,14 @@ Item {
|
||||
break;
|
||||
}
|
||||
}
|
||||
readonly property var splitDate: Qt.formatDateTime(dateStepper.currentDate, "yyyy.MM.dd.hh.mm.AP").split('.')
|
||||
readonly property var splitDate: Qt.formatDateTime(dateStepper.currentDate, SettingsData.use24HourClock ? "yyyy.MM.dd.HH.mm" : "yyyy.MM.dd.hh.mm.AP").split('.')
|
||||
|
||||
Item {
|
||||
id: dateStepperInner
|
||||
anchors.fill: parent
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
readonly property var space: Theme.spacingXS
|
||||
width: yearStepper.width + monthStepper.width + dayStepper.width + hourStepper.width + minuteStepper.width + suffix.width + 10.5 * space + 2 * dateStepperInnerPadding.width
|
||||
width: yearStepper.width + monthStepper.width + dayStepper.width + hourStepper.width + minuteStepper.width + (suffix.visible ? suffix.width : 0) + 10.5 * space + 2 * dateStepperInnerPadding.width
|
||||
|
||||
Item {
|
||||
id: dateStepperInnerPadding
|
||||
@@ -420,13 +439,14 @@ Item {
|
||||
}
|
||||
Rectangle {
|
||||
id: suffix
|
||||
visible: !SettingsData.use24HourClock
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.left: minuteStepper.right
|
||||
anchors.leftMargin: 2 * parent.space
|
||||
StyledText {
|
||||
isMonospace: true
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: dateStepper.splitDate[5]
|
||||
text: dateStepper.splitDate[5] ?? ""
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
x: -Theme.fontSizeSmall / 2
|
||||
y: -Theme.fontSizeSmall / 2
|
||||
|
||||
@@ -745,6 +745,7 @@ Singleton {
|
||||
|
||||
hourly_forecast.push({
|
||||
"time": formatTime(hourly.time[i]),
|
||||
"rawTime": hourly.time[i],
|
||||
"temp": Math.round(tempC),
|
||||
"tempF": Math.round(tempF),
|
||||
"feelsLike": Math.round(feelsLikeC),
|
||||
@@ -778,7 +779,9 @@ Singleton {
|
||||
"tempMaxF": Math.round(tempMaxF),
|
||||
"precipitationProbability": Math.round(daily.precipitation_probability_max?.[i] || 0),
|
||||
"sunrise": daily.sunrise?.[i] ? formatTime(daily.sunrise[i]) : "",
|
||||
"sunset": daily.sunset?.[i] ? formatTime(daily.sunset[i]) : ""
|
||||
"sunset": daily.sunset?.[i] ? formatTime(daily.sunset[i]) : "",
|
||||
"rawSunrise": daily.sunrise?.[i] || "",
|
||||
"rawSunset": daily.sunset?.[i] || ""
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -805,6 +808,8 @@ Singleton {
|
||||
"wind": Math.round(current.wind_speed_10m || 0) + " " + (currentUnits.wind_speed_10m || 'm/s'),
|
||||
"sunrise": formatTime(daily.sunrise?.[0]) || "06:00",
|
||||
"sunset": formatTime(daily.sunset?.[0]) || "18:00",
|
||||
"rawSunrise": daily.sunrise?.[0] || "",
|
||||
"rawSunset": daily.sunset?.[0] || "",
|
||||
"uv": 0,
|
||||
"pressure": Math.round(current.surface_pressure || 0),
|
||||
"precipitationProbability": Math.round(daily.precipitation_probability_max?.[0] || 0),
|
||||
|
||||
Reference in New Issue
Block a user