mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 13:32:50 -05:00
@@ -147,6 +147,7 @@ Singleton {
|
||||
property bool use24HourClock: true
|
||||
property bool showSeconds: false
|
||||
property bool useFahrenheit: false
|
||||
property string windSpeedUnit: "kmh"
|
||||
property bool nightModeEnabled: false
|
||||
property int animationSpeed: SettingsData.AnimationSpeed.Short
|
||||
property int customAnimationDuration: 500
|
||||
|
||||
@@ -33,6 +33,7 @@ var SPEC = {
|
||||
use24HourClock: { def: true },
|
||||
showSeconds: { def: false },
|
||||
useFahrenheit: { def: false },
|
||||
windSpeedUnit: { def: "kmh" },
|
||||
nightModeEnabled: { def: false },
|
||||
animationSpeed: { def: 1 },
|
||||
customAnimationDuration: { def: 500 },
|
||||
|
||||
@@ -47,10 +47,17 @@ Rectangle {
|
||||
readonly property var humidity: WeatherService.formatPercent(root.forecastData?.humidity)
|
||||
readonly property string humidityText: humidity ?? "--"
|
||||
|
||||
readonly property var wind: WeatherService.formatSpeed(root.forecastData?.wind)
|
||||
readonly property var wind: {
|
||||
SettingsData.windSpeedUnit;
|
||||
SettingsData.useFahrenheit;
|
||||
return WeatherService.formatSpeed(root.forecastData?.wind);
|
||||
}
|
||||
readonly property string windText: wind ?? "--"
|
||||
|
||||
readonly property var pressure: WeatherService.formatPressure(root.forecastData?.pressure)
|
||||
readonly property var pressure: {
|
||||
SettingsData.useFahrenheit;
|
||||
return WeatherService.formatPressure(root.forecastData?.pressure);
|
||||
}
|
||||
readonly property string pressureText: pressure ?? "--"
|
||||
|
||||
readonly property var precipitation: root.forecastData?.precipitationProbability
|
||||
|
||||
@@ -229,10 +229,17 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
StyledText {
|
||||
property var feelsLike: SettingsData.useFahrenheit ? (WeatherService.weather.feelsLikeF || WeatherService.weather.tempF) : (WeatherService.weather.feelsLike || WeatherService.weather.temp)
|
||||
text: I18n.tr("Feels Like %1°", "weather feels like temperature").arg(feelsLike)
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.withAlpha(Theme.surfaceText, 0.7)
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: WeatherService.weather.city || ""
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.7)
|
||||
color: Theme.withAlpha(Theme.surfaceText, 0.7)
|
||||
visible: text.length > 0
|
||||
}
|
||||
}
|
||||
@@ -253,7 +260,7 @@ Item {
|
||||
id: sunriseIcon
|
||||
name: "wb_twilight"
|
||||
size: Theme.iconSize - 6
|
||||
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.6)
|
||||
color: Theme.withAlpha(Theme.surfaceText, 0.6)
|
||||
anchors.left: parent.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
@@ -272,7 +279,7 @@ Item {
|
||||
}
|
||||
}
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.6)
|
||||
color: Theme.withAlpha(Theme.surfaceText, 0.6)
|
||||
anchors.left: sunriseIcon.right
|
||||
anchors.leftMargin: Theme.spacingXS
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
@@ -363,6 +363,25 @@ Item {
|
||||
onToggled: checked => SettingsData.set("useFahrenheit", checked)
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
height: 1
|
||||
color: Theme.outline
|
||||
opacity: 0.15
|
||||
visible: !SettingsData.useFahrenheit
|
||||
}
|
||||
|
||||
SettingsToggleRow {
|
||||
tab: "time"
|
||||
tags: ["weather", "wind", "speed", "units", "metric"]
|
||||
settingKey: "windSpeedUnit"
|
||||
text: I18n.tr("Wind Speed in m/s")
|
||||
description: I18n.tr("Use meters per second instead of km/h for wind speed")
|
||||
checked: SettingsData.windSpeedUnit === "ms"
|
||||
onToggled: checked => SettingsData.set("windSpeedUnit", checked ? "ms" : "kmh")
|
||||
visible: !SettingsData.useFahrenheit
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
height: 1
|
||||
@@ -689,6 +708,13 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
StyledText {
|
||||
property var feelsLike: SettingsData.useFahrenheit ? (WeatherService.weather.feelsLikeF || WeatherService.weather.tempF) : (WeatherService.weather.feelsLike || WeatherService.weather.temp)
|
||||
text: I18n.tr("Feels Like %1°").arg(feelsLike)
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.5)
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: WeatherService.weather.city || ""
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
@@ -891,20 +917,24 @@ Item {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
StyledText {
|
||||
id: windText
|
||||
text: {
|
||||
if (!WeatherService.weather.wind)
|
||||
return "--";
|
||||
const windKmh = parseFloat(WeatherService.weather.wind);
|
||||
if (isNaN(windKmh))
|
||||
return WeatherService.weather.wind;
|
||||
if (SettingsData.useFahrenheit)
|
||||
return Math.round(windKmh * 0.621371) + " mph";
|
||||
return WeatherService.weather.wind;
|
||||
SettingsData.windSpeedUnit;
|
||||
SettingsData.useFahrenheit;
|
||||
return WeatherService.formatSpeed(WeatherService.weather.wind) || "--";
|
||||
}
|
||||
font.pixelSize: Theme.fontSizeSmall + 1
|
||||
color: Theme.surfaceText
|
||||
font.weight: Font.Medium
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: SettingsData.useFahrenheit ? Qt.ArrowCursor : Qt.PointingHandCursor
|
||||
enabled: !SettingsData.useFahrenheit
|
||||
onClicked: SettingsData.set("windSpeedUnit", SettingsData.windSpeedUnit === "kmh" ? "ms" : "kmh")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -354,9 +354,15 @@ Singleton {
|
||||
if (kmh == null) {
|
||||
return null;
|
||||
}
|
||||
const value = SettingsData.useFahrenheit ? Math.round(kmh * 0.621371) : kmh;
|
||||
const unit = SettingsData.useFahrenheit ? "mph" : "km/h";
|
||||
return includeUnits ? value + " " + unit : value;
|
||||
if (SettingsData.useFahrenheit) {
|
||||
const value = Math.round(kmh * 0.621371);
|
||||
return includeUnits ? value + " mph" : value;
|
||||
}
|
||||
if (SettingsData.windSpeedUnit === "ms") {
|
||||
const value = (kmh / 3.6).toFixed(1);
|
||||
return includeUnits ? value + " m/s" : value;
|
||||
}
|
||||
return includeUnits ? kmh + " km/h" : kmh;
|
||||
}
|
||||
|
||||
function formatPressure(hpa, includeUnits = true) {
|
||||
@@ -805,7 +811,7 @@ Singleton {
|
||||
"country": root.location?.country || "Unknown",
|
||||
"wCode": current.weather_code || 0,
|
||||
"humidity": Math.round(current.relative_humidity_2m || 0),
|
||||
"wind": Math.round(current.wind_speed_10m || 0) + " " + (currentUnits.wind_speed_10m || 'm/s'),
|
||||
"wind": Math.round(current.wind_speed_10m || 0),
|
||||
"sunrise": formatTime(daily.sunrise?.[0]) || "06:00",
|
||||
"sunset": formatTime(daily.sunset?.[0]) || "18:00",
|
||||
"rawSunrise": daily.sunrise?.[0] || "",
|
||||
|
||||
Reference in New Issue
Block a user