mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
Merge pull request #1506 from turannul/pr/weather-night-icons
Adds moon and moon-stars, cloud-off icons
This commit is contained in:
@@ -98,6 +98,9 @@ Singleton {
|
||||
"volume-low": "volume-2",
|
||||
"volume-high": "volume",
|
||||
"weather-sun": "sun",
|
||||
"weather-moon": "moon",
|
||||
"weather-moon-stars": "moon-stars",
|
||||
"weather-cloud-off": "cloud-off",
|
||||
"weather-cloud": "cloud",
|
||||
"weather-cloud-haze": "cloud-fog",
|
||||
"weather-cloud-lightning": "cloud-bolt",
|
||||
|
||||
@@ -87,7 +87,7 @@ NBox {
|
||||
|
||||
NIcon {
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
icon: weatherReady ? LocationService.weatherSymbolFromCode(LocationService.data.weather.current_weather.weathercode) : ""
|
||||
icon: weatherReady ? LocationService.weatherSymbolFromCode(LocationService.data.weather.current_weather.weathercode, LocationService.data.weather.current_weather.is_day) : "weather-cloud-off"
|
||||
pointSize: Style.fontSizeXXXL * 1.75
|
||||
color: Color.mPrimary
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ DraggableDesktopWidget {
|
||||
|
||||
NIcon {
|
||||
anchors.centerIn: parent
|
||||
icon: weatherReady ? LocationService.weatherSymbolFromCode(currentWeatherCode) : "cloud"
|
||||
icon: weatherReady ? LocationService.weatherSymbolFromCode(currentWeatherCode, LocationService.data.weather.current_weather.is_day) : "weather-cloud-off"
|
||||
pointSize: Math.round(Style.fontSizeXXXL * 2 * widgetScale)
|
||||
color: weatherReady ? Color.mPrimary : Color.mOnSurfaceVariant
|
||||
}
|
||||
|
||||
@@ -323,7 +323,7 @@ Item {
|
||||
|
||||
NIcon {
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
icon: LocationService.weatherSymbolFromCode(LocationService.data.weather.current_weather.weathercode)
|
||||
icon: weatherReady ? LocationService.weatherSymbolFromCode(LocationService.data.weather.current_weather.weathercode, LocationService.data.weather.current_weather.is_day) : "weather-cloud-off"
|
||||
pointSize: Style.fontSizeXXXL
|
||||
color: Color.mPrimary
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ Singleton {
|
||||
// Fetch weather data from Open-Meteo API
|
||||
function fetchWeatherData(latitude, longitude, errorCallback) {
|
||||
Logger.d("Location", "Fetching weather from api.open-meteo.com");
|
||||
var url = "https://api.open-meteo.com/v1/forecast?latitude=" + latitude + "&longitude=" + longitude + "¤t_weather=true¤t=relativehumidity_2m,surface_pressure&daily=temperature_2m_max,temperature_2m_min,weathercode,sunset,sunrise&timezone=auto";
|
||||
var url = "https://api.open-meteo.com/v1/forecast?latitude=" + latitude + "&longitude=" + longitude + "¤t_weather=true¤t=relativehumidity_2m,surface_pressure,is_day&daily=temperature_2m_max,temperature_2m_min,weathercode,sunset,sunrise&timezone=auto";
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState === XMLHttpRequest.DONE) {
|
||||
@@ -237,11 +237,11 @@ Singleton {
|
||||
}
|
||||
|
||||
// --------------------------------
|
||||
function weatherSymbolFromCode(code) {
|
||||
function weatherSymbolFromCode(code, isDay) {
|
||||
if (code === 0)
|
||||
return "weather-sun";
|
||||
return isDay ? "weather-sun" : "weather-moon";
|
||||
if (code === 1 || code === 2)
|
||||
return "weather-cloud-sun";
|
||||
return isDay ? "weather-cloud-sun" : "weather-moon-stars";
|
||||
if (code === 3)
|
||||
return "weather-cloud";
|
||||
if (code >= 45 && code <= 48)
|
||||
|
||||
Reference in New Issue
Block a user