Weather: Made the weather effects conditional with a new setting.

This commit is contained in:
ItsLemmy
2025-11-19 08:05:33 -05:00
parent 17810d1d2f
commit 1b4cd35504
14 changed files with 89 additions and 32 deletions
+4
View File
@@ -1425,6 +1425,10 @@
"description": "Bevorzugte Temperatureinheit wählen.",
"label": "Wetter"
},
"show-effects": {
"description": "Zeigt zusätzliche visuelle Effekte (wie Regen, Schnee oder Blitze) auf der Wetterkarte an.",
"label": "Wettereffekte anzeigen"
},
"show-in-calendar": {
"description": "Zeige die tägliche Wettervorhersage direkt in deiner Kalenderansicht an.",
"label": "Wetter im Kalender anzeigen"
+4
View File
@@ -1425,6 +1425,10 @@
"description": "Choose your preferred temperature unit.",
"label": "Weather"
},
"show-effects": {
"description": "Shows additional visual effects (like rain, snow, or lightning) on the weather card.",
"label": "Display weather effects"
},
"show-in-calendar": {
"description": "Show the daily weather forecast directly in your calendar view.",
"label": "Display weather in calendar"
+4
View File
@@ -1425,6 +1425,10 @@
"description": "Elige tu unidad de temperatura preferida.",
"label": "Clima"
},
"show-effects": {
"description": "Muestra efectos visuales adicionales (como lluvia, nieve o relámpagos) en la tarjeta del clima.",
"label": "Mostrar efectos climáticos"
},
"show-in-calendar": {
"description": "Muestra el pronóstico del tiempo diario directamente en la vista de tu calendario.",
"label": "Mostrar el clima en el calendario"
+4
View File
@@ -1425,6 +1425,10 @@
"description": "Choisissez votre unité de température préférée.",
"label": "Météo"
},
"show-effects": {
"description": "Affiche des effets visuels supplémentaires (comme la pluie, la neige ou la foudre) sur la carte météo.",
"label": "Afficher les effets météorologiques"
},
"show-in-calendar": {
"description": "Afficher les prévisions météo quotidiennes directement dans votre vue calendrier.",
"label": "Afficher la météo dans le calendrier"
+4
View File
@@ -1425,6 +1425,10 @@
"description": "Kies je voorkeurseenheid voor temperatuur.",
"label": "Weer"
},
"show-effects": {
"description": "Toont extra visuele effecten (zoals regen, sneeuw of bliksem) op de weerkaart.",
"label": "Weerseffecten weergeven"
},
"show-in-calendar": {
"description": "Toon de dagelijkse weersverwachting direct in je kalenderview.",
"label": "Weer in kalender weergeven"
+4
View File
@@ -1425,6 +1425,10 @@
"description": "Escolha sua unidade de temperatura preferida.",
"label": "Clima"
},
"show-effects": {
"description": "Mostra efeitos visuais adicionais (como chuva, neve ou relâmpagos) no cartão de clima.",
"label": "Exibir efeitos climáticos"
},
"show-in-calendar": {
"description": "Mostre a previsão do tempo diária diretamente na sua visualização de calendário.",
"label": "Exibir clima no calendário"
+4
View File
@@ -1425,6 +1425,10 @@
"description": "Выберите предпочитаемую единицу измерения температуры.",
"label": "Погода"
},
"show-effects": {
"description": "Отображает дополнительные визуальные эффекты (например, дождь, снег или молнию) на карточке погоды.",
"label": "Отображать погодные эффекты"
},
"show-in-calendar": {
"description": "Показывать ежедневный прогноз погоды непосредственно в вашем календаре.",
"label": "Отображать погоду в календаре"
+4
View File
@@ -1425,6 +1425,10 @@
"description": "Tercih ettiğiniz sıcaklık birimini seçin.",
"label": "Hava durumu"
},
"show-effects": {
"description": "Hava durumu kartında ek görsel efektler (yağmur, kar veya şimşek gibi) gösterir.",
"label": "Hava efektlerini göster"
},
"show-in-calendar": {
"description": "Günlük hava durumu tahminini doğrudan takvim görünümünüzde gösterin.",
"label": "Takvimde hava durumunu göster"
+4
View File
@@ -1425,6 +1425,10 @@
"description": "Виберіть бажану одиницю температури.",
"label": "Погода"
},
"show-effects": {
"description": "Показує додаткові візуальні ефекти (наприклад, дощ, сніг або блискавку) на картці погоди.",
"label": "Відображати погодні ефекти"
},
"show-in-calendar": {
"description": "Показувати щоденний прогноз погоди безпосередньо в календарі.",
"label": "Відображати погоду в календарі"
+4
View File
@@ -1425,6 +1425,10 @@
"description": "选择您喜欢的温度单位。",
"label": "天气"
},
"show-effects": {
"description": "在天气卡片上显示额外的视觉效果(如雨、雪或闪电)。",
"label": "显示天气效果"
},
"show-in-calendar": {
"description": "直接在您的日历视图中显示每日天气预报。",
"label": "在日历中显示天气"
+1
View File
@@ -90,6 +90,7 @@
"location": {
"name": "Tokyo",
"weatherEnabled": true,
"weatherShowEffects": true,
"useFahrenheit": false,
"use12hourFormat": false,
"showWeekNumberInCalendar": false,
+1
View File
@@ -239,6 +239,7 @@ Singleton {
property JsonObject location: JsonObject {
property string name: defaultLocation
property bool weatherEnabled: true
property bool weatherShowEffects: true
property bool useFahrenheit: false
property bool use12hourFormat: false
property bool showWeekNumberInCalendar: false
@@ -1,6 +1,6 @@
import QtQuick
import QtQuick.Layouts
import QtQuick.Effects
import QtQuick.Layouts
import Quickshell
import qs.Commons
import qs.Services.Location
@@ -12,51 +12,58 @@ NBox {
property int forecastDays: 6
property bool showLocation: true
property bool showEffects: Settings.data.location.weatherShowEffects
readonly property bool weatherReady: Settings.data.location.weatherEnabled && (LocationService.data.weather !== null)
// Test mode: set to "rain" or "snow"
property string testWeatherEffect: ""
property string testEffects: ""
// Weather condition detection
readonly property int currentWeatherCode: weatherReady ? LocationService.data.weather.current_weather.weathercode : 0
readonly property bool isRaining: testWeatherEffect === "rain" || (testWeatherEffect === "" && currentWeatherCode >= 51 && currentWeatherCode <= 67)
readonly property bool isSnowing: testWeatherEffect === "snow" || (testWeatherEffect === "" && ((currentWeatherCode >= 71 && currentWeatherCode <= 77) || (currentWeatherCode >= 85 && currentWeatherCode <= 86)))
// Animated time for shaders
property real shaderTime: 0
NumberAnimation on shaderTime {
running: root.isRaining || root.isSnowing
loops: Animation.Infinite
from: 0
to: 1000
duration: 100000
}
readonly property bool isRaining: testEffects === "rain" || (testEffects === "" && currentWeatherCode >= 51 && currentWeatherCode <= 67)
readonly property bool isSnowing: testEffects === "snow" || (testEffects === "" && ((currentWeatherCode >= 71 && currentWeatherCode <= 77) || (currentWeatherCode >= 85 && currentWeatherCode <= 86)))
visible: Settings.data.location.weatherEnabled
implicitHeight: Math.max(100 * Style.uiScaleRatio, content.implicitHeight + (Style.marginXL * 2))
// Weather effect layer (rain/snow)
ShaderEffect {
id: weatherEffect
Loader {
id: weatherEffectLoader
anchors.fill: parent
// Snow fills the box, rain matches content margins
anchors.margins: root.isSnowing ? root.border.width : Style.marginXL
visible: root.isRaining || root.isSnowing
active: root.showEffects && (root.isRaining || root.isSnowing)
property var source: ShaderEffectSource {
sourceItem: content
hideSource: root.isRaining // Only hide for rain (distortion), show for snow
sourceComponent: Item {
anchors.fill: parent
// Animated time for shaders
property real shaderTime: 0
NumberAnimation on shaderTime {
loops: Animation.Infinite
from: 0
to: 1000
duration: 100000
}
ShaderEffect {
id: weatherEffect
anchors.fill: parent
// Snow fills the box, rain matches content margins
anchors.margins: root.isSnowing ? root.border.width : Style.marginXL
property var source: ShaderEffectSource {
sourceItem: content
hideSource: root.isRaining // Only hide for rain (distortion), show for snow
}
property real time: parent.shaderTime
property real itemWidth: weatherEffect.width
property real itemHeight: weatherEffect.height
property color bgColor: root.color
property real cornerRadius: root.isSnowing ? (root.radius - root.border.width) : 0
fragmentShader: root.isSnowing ? Qt.resolvedUrl(Quickshell.shellDir + "/Shaders/qsb/weather_snow.frag.qsb") : Qt.resolvedUrl(Quickshell.shellDir + "/Shaders/qsb/weather_rain.frag.qsb")
}
}
property real time: root.shaderTime
property real itemWidth: weatherEffect.width
property real itemHeight: weatherEffect.height
property color bgColor: root.color
property real cornerRadius: root.isSnowing ? (root.radius - root.border.width) : 0
fragmentShader: root.isSnowing ?
Qt.resolvedUrl(Quickshell.shellDir + "/Shaders/qsb/weather_snow.frag.qsb") :
Qt.resolvedUrl(Quickshell.shellDir + "/Shaders/qsb/weather_rain.frag.qsb")
}
ColumnLayout {
@@ -93,6 +93,14 @@ ColumnLayout {
onToggled: checked => Settings.data.location.showCalendarWeather = checked
enabled: Settings.data.location.weatherEnabled
}
NToggle {
label: I18n.tr("settings.location.weather.show-effects.label")
description: I18n.tr("settings.location.weather.show-effects.description")
checked: Settings.data.location.weatherShowEffects
onToggled: checked => Settings.data.location.weatherShowEffects = checked
enabled: Settings.data.location.weatherEnabled
}
}
NDivider {