KWeather: Better icon name string handling.

Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
pull/18/head
Mavridis Philippe 3 years ago
parent a21cf7acf6
commit df744f540c
No known key found for this signature in database
GPG Key ID: F8D2D7E2F989A494

@ -20,9 +20,11 @@ WeatherIcon::WeatherIcon( int condition, bool night )
case Fog: case Fog:
{ {
name = "weather-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; iconName = name;
return; return;
@ -31,9 +33,11 @@ WeatherIcon::WeatherIcon( int condition, bool night )
case Mist: case Mist:
{ {
name = "weather-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; iconName = name;
return; return;
@ -111,7 +115,8 @@ WeatherIcon::WeatherIcon( int condition, bool night, unsigned int strength )
case 2: case 2:
{ {
name = "weather-snow-moderate"; name = "weather-snow-moderate";
if (! iconExists( TQString(name.latin1()).append("-day")) ) TQString test_icon = name + "-day";
if (! iconExists(test_icon) )
{ {
name = "weather-snow-scattered"; name = "weather-snow-scattered";
} }
@ -120,7 +125,8 @@ WeatherIcon::WeatherIcon( int condition, bool night, unsigned int strength )
case 3: case 3:
{ {
name = "weather-snow-ample"; name = "weather-snow-ample";
if ( iconExists( TQString(name.latin1()).append("-day") ) ) TQString test_icon = name + "-day";
if ( iconExists(test_icon) )
break; break;
} }
case 4: { iconName = "weather-snow-scattered"; return; } case 4: { iconName = "weather-snow-scattered"; return; }
@ -139,7 +145,8 @@ WeatherIcon::WeatherIcon( int condition, bool night, unsigned int strength )
case 2: case 2:
{ {
name = "weather-storm-moderate"; name = "weather-storm-moderate";
if (! iconExists( TQString(name.latin1()).append("-day")) ) TQString test_icon = name + "-day";
if (! iconExists(test_icon) )
{ {
name = "weather-storm"; name = "weather-storm";
} }

Loading…
Cancel
Save