From df744f540c939da2f4c329e321582f4729ada839 Mon Sep 17 00:00:00 2001 From: Mavridis Philippe Date: Mon, 15 Nov 2021 12:15:01 +0200 Subject: [PATCH] KWeather: Better icon name string handling. Signed-off-by: Mavridis Philippe --- kweather/weather_icon.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/kweather/weather_icon.cpp b/kweather/weather_icon.cpp index 6e2f164..6ea3287 100644 --- a/kweather/weather_icon.cpp +++ b/kweather/weather_icon.cpp @@ -20,9 +20,11 @@ WeatherIcon::WeatherIcon( int condition, bool night ) case Fog: { name = "weather-fog"; - if( night && iconExists( TQString(name.latin1()).append("-night")) ) + if( night ) { - name.append("-night"); + TQString night_icon = name + "-night"; + if( iconExists(night_icon) ) + name = night_icon; } iconName = name; return; @@ -31,9 +33,11 @@ WeatherIcon::WeatherIcon( int condition, bool night ) case Mist: { name = "weather-mist"; - if( night && iconExists( TQString(name.latin1()).append("-night")) ) + if( night ) { - name.append("-night"); + TQString night_icon = name + "-night"; + if( iconExists(night_icon) ) + name = night_icon; } iconName = name; return; @@ -111,7 +115,8 @@ WeatherIcon::WeatherIcon( int condition, bool night, unsigned int strength ) case 2: { name = "weather-snow-moderate"; - if (! iconExists( TQString(name.latin1()).append("-day")) ) + TQString test_icon = name + "-day"; + if (! iconExists(test_icon) ) { name = "weather-snow-scattered"; } @@ -120,7 +125,8 @@ WeatherIcon::WeatherIcon( int condition, bool night, unsigned int strength ) case 3: { name = "weather-snow-ample"; - if ( iconExists( TQString(name.latin1()).append("-day") ) ) + TQString test_icon = name + "-day"; + if ( iconExists(test_icon) ) break; } case 4: { iconName = "weather-snow-scattered"; return; } @@ -139,7 +145,8 @@ WeatherIcon::WeatherIcon( int condition, bool night, unsigned int strength ) case 2: { name = "weather-storm-moderate"; - if (! iconExists( TQString(name.latin1()).append("-day")) ) + TQString test_icon = name + "-day"; + if (! iconExists(test_icon) ) { name = "weather-storm"; }