also check default paths when images and icons are loaded

This commit is contained in:
louis 2014-01-25 15:52:53 +01:00
parent 0cbc226651
commit 2a3eecd99e
5 changed files with 93 additions and 26 deletions

View File

@ -111,3 +111,4 @@ Version 1.1.0
- left / right scroll page up / down in recmenu result lists
- Improved favorites menu with whats on now / next and up to four user
defined times
- also check default paths when images and icons are loaded

View File

@ -191,38 +191,47 @@ void cTvguideConfig::SetStyle(void) {
}
void cTvguideConfig::SetLogoPath(cString path) {
logoPath = path;
logoPath = checkSlashAtEnd(*path);
logoPathSet = true;
esyslog("tvguide: Logo Path set to %s", *logoPath);
}
void cTvguideConfig::SetImagesPath(cString path) {
epgImagePath = path;
epgImagePath = checkSlashAtEnd(*path);
imagesPathSet = true;
esyslog("tvguide: EPG Image Path set to %s", *epgImagePath);
}
void cTvguideConfig::SetIconsPath(cString path) {
iconPath = path;
iconPath = checkSlashAtEnd(*path);
iconsPathSet = true;
esyslog("tvguide: Icon Path set to %s", *iconPath);
}
void cTvguideConfig::SetDefaultPathes(void) {
logoPathDefault = cString::sprintf("%s/logos/", cPlugin::ResourceDirectory(PLUGIN_NAME_I18N));
iconPathDefault = cString::sprintf("%s/icons/", cPlugin::ResourceDirectory(PLUGIN_NAME_I18N));
epgImagePathDefault = cString::sprintf("%s/epgimages/", cPlugin::CacheDirectory(PLUGIN_NAME_I18N));
if (!logoPathSet) {
cString path = cString::sprintf("%s/channellogos/", cPlugin::ResourceDirectory(PLUGIN_NAME_I18N));
SetLogoPath(path);
logoPath = logoPathDefault;
}
if (!imagesPathSet) {
cString path = cString::sprintf("%s/epgimages/", cPlugin::CacheDirectory(PLUGIN_NAME_I18N));
SetImagesPath(path);
epgImagePath = epgImagePathDefault;
}
if (!iconsPathSet) {
cString path = cString::sprintf("%s/icons/", cPlugin::ResourceDirectory(PLUGIN_NAME_I18N));
SetIconsPath(path);
iconPath = iconPathDefault;
}
}
cString cTvguideConfig::checkSlashAtEnd(std::string path) {
try {
if (!(path.at(path.size()-1) == '/'))
return cString::sprintf("%s/", path.c_str());
} catch (...) {return path.c_str();}
return path.c_str();
}
bool cTvguideConfig::SetupParse(const char *Name, const char *Value) {
if (strcmp(Name, "timeFormat") == 0) timeFormat = atoi(Value);
else if (strcmp(Name, "debugImageLoading") == 0) debugImageLoading = atoi(Value);

View File

@ -40,6 +40,7 @@ enum eBlueKeyMode {
class cTvguideConfig {
private:
cString checkSlashAtEnd(std::string path);
public:
cTvguideConfig();
~cTvguideConfig();
@ -89,6 +90,9 @@ class cTvguideConfig {
int epgImageHeightLarge;
cString epgImagePath;
cString iconPath;
cString logoPathDefault;
cString iconPathDefault;
cString epgImagePathDefault;
int recMenuAskFolder;
int favWhatsOnNow;
int favWhatsOnNext;

View File

@ -548,6 +548,7 @@ void cImageCache::AddCornersGroupVertical(cImage *img) {
bool cImageCache::LoadIcon(std::string name) {
bool success = false;
if (tvguideConfig.iconsPathSet) {
cString iconPathTheme = cString::sprintf("%s%s/", *tvguideConfig.iconPath, *tvguideConfig.themeName);
success = LoadImage(name, *iconPathTheme, "png");
if (success) {
@ -558,6 +559,19 @@ bool cImageCache::LoadIcon(std::string name) {
return true;
}
}
}
if (!success) {
cString iconPathTheme = cString::sprintf("%s%s/", *tvguideConfig.iconPathDefault, *tvguideConfig.themeName);
success = LoadImage(name, *iconPathTheme, "png");
if (success) {
return true;
} else {
success = LoadImage(name, *tvguideConfig.iconPathDefault, "png");
if (success) {
return true;
}
}
}
return false;
}
@ -573,10 +587,19 @@ bool cImageCache::LoadLogo(const cChannel *channel) {
} else if (tvguideConfig.logoExtension == 1) {
extension = "jpg";
}
if (tvguideConfig.logoPathSet) {
success = LoadImage(channelID.c_str(), *tvguideConfig.logoPath, *extension);
if (success)
return true;
success = LoadImage(logoLower.c_str(), *tvguideConfig.logoPath, *extension);
if (success)
return true;
}
success = LoadImage(channelID.c_str(), *tvguideConfig.logoPathDefault, *extension);
if (success)
return true;
success = LoadImage(logoLower.c_str(), *tvguideConfig.logoPathDefault, *extension);
return success;
}

View File

@ -29,10 +29,16 @@ bool cImageLoader::LoadLogo(const cChannel *channel, int width, int height) {
extension = "jpg";
}
bool success = false;
if (tvguideConfig.logoPathSet) {
success = LoadImage(channelID.c_str(), *tvguideConfig.logoPath, *extension);
if (!success) {
success = LoadImage(logoLower.c_str(), *tvguideConfig.logoPath, *extension);
}
}
if (!success)
success = LoadImage(channelID.c_str(), *tvguideConfig.logoPathDefault, *extension);
if (!success)
success = LoadImage(logoLower.c_str(), *tvguideConfig.logoPathDefault, *extension);
if (success)
buffer.sample(Geometry(width, height));
return success;
@ -77,12 +83,22 @@ bool cImageLoader::LoadPoster(const char *poster, int width, int height) {
bool cImageLoader::LoadIcon(const char *cIcon, int size) {
if (size==0)
return false;
cString iconPathTheme = cString::sprintf("%s%s/recmenuicons/", *tvguideConfig.iconPath, *tvguideConfig.themeName);
bool success = false;
if (tvguideConfig.iconsPathSet) {
cString iconPathTheme = cString::sprintf("%s%s/recmenuicons/", *tvguideConfig.iconPath, *tvguideConfig.themeName);
success = LoadImage(cIcon, *iconPathTheme, "png");
if (!success) {
cString iconPathdefault = cString::sprintf("%s/recmenuicons/", *tvguideConfig.iconPath);
success = LoadImage(cIcon, *iconPathdefault, "png");
cString iconPath = cString::sprintf("%srecmenuicons/", *tvguideConfig.iconPath);
success = LoadImage(cIcon, *iconPath, "png");
}
}
if (!success) {
cString iconPathTheme = cString::sprintf("%s%s/recmenuicons/", *tvguideConfig.iconPathDefault, *tvguideConfig.themeName);
success = LoadImage(cIcon, *iconPathTheme, "png");
if (!success) {
cString iconPath = cString::sprintf("%srecmenuicons/", *tvguideConfig.iconPathDefault);
success = LoadImage(cIcon, *iconPath, "png");
}
}
if (!success)
return false;
@ -94,8 +110,22 @@ bool cImageLoader::LoadOsdElement(cString name, int width, int height) {
if ((width == 0)||(height==0))
return false;
bool success = false;
if (tvguideConfig.iconsPathSet) {
cString path = cString::sprintf("%s%s%s", *tvguideConfig.iconPath, *tvguideConfig.themeName, "/osdElements/");
success = LoadImage(*name, *path, "png");
if (!success) {
path = cString::sprintf("%s%s", *tvguideConfig.iconPath, "/osdElements/");
success = LoadImage(*name, *path, "png");
}
}
if (!success) {
cString path = cString::sprintf("%s%s%s", *tvguideConfig.iconPathDefault, *tvguideConfig.themeName, "/osdElements/");
success = LoadImage(*name, *path, "png");
}
if (!success) {
cString path = cString::sprintf("%s%s", *tvguideConfig.iconPathDefault, "/osdElements/");
success = LoadImage(*name, *path, "png");
}
if (!success)
return false;
Geometry size(width, height);