Zren / plasma-applet-simpleweather

https://store.kde.org/p/1287571/
4 stars 5 forks source link

Does not show base temperature when using wetter.com #4

Closed vitalykorotkov closed 5 years ago

vitalykorotkov commented 5 years ago

openSUSE Leap 15, KDE Plasma 5.12.6

vetalicity@linux-57r7:~> plasmawindowed com.github.zren.simpleweather
org.kde.plasmaquick: Applet preload policy set to 1
org.kde.plasma: requesting config for "Simple Weather" without a containment!
file:///home/vetalicity/.local/share/plasma/plasmoids/com.github.zren.simpleweather/contents/ui/WeatherData.qml:93: ReferenceError: Util is not defined
qml: 0
file:///home/vetalicity/.local/share/plasma/plasmoids/com.github.zren.simpleweather/contents/ui/WeatherData.qml:93: ReferenceError: Util is not defined
file:///home/vetalicity/.local/share/plasma/plasmoids/com.github.zren.simpleweather/contents/ui/WeatherData.qml:93: ReferenceError: Util is not defined

screenshot_20190202_130531

Zren commented 5 years ago

The wetter.com source does not supply the "current temperature". Instead it's trying to show an icon.

https://github.com/Zren/plasma-applet-simpleweather/blob/master/package/contents/ui/WeatherData.qml#L102

property string currentConditionIconName: {
    var conditionIconName = data["Condition Icon"] || todaysForecastIcon || null
    return conditionIconName ? Util.existingWeatherIconName(conditionIconName) : "weather-none-available"
}

It seems the Util module does not exist in plasma 5.12, which means it can't use the Util.existingWeatherIconName function.

Unfortunately, the Plasma 5.12 code doesn't allow me to use that function at all, since it uses a private C++ applet function, unlike the Plasma 5.14 code which was written to allow QML widget to use the Util function.

@IkiruOG the following code in WeatherData.qml should work.

property string currentConditionIconName: {
    var conditionIconName = data["Condition Icon"] || todaysForecastIcon || null
    return conditionIconName ? conditionIconName : "weather-none-available"
}

It only needs that Util function to display the "weather-none-available" icon if the user's icon theme is missing the current weather icon.

vitalykorotkov commented 5 years ago

Sadly. Then I'll wait for a plasma update or update it myself. This code works. The icon is now displayed. Thank you!

Zren commented 5 years ago

This code works. The icon is now displayed.

Awesome! v3 will have code to check if it's Plasma 5.12, and if so, not use the function. That function isn't really necessary as long as your icon theme has all the weather icons.