changed skin handling and added themes support for skins

This commit is contained in:
louis
2014-10-03 15:54:23 +02:00
parent 7766972eec
commit 91a0681ab8
593 changed files with 495 additions and 144 deletions

View File

@@ -97,6 +97,11 @@ bool FileExists(const string &path, const string &name, const string &ext) {
return (stat (fileName.str().c_str(), &buffer) == 0);
}
bool FolderExists(const string &path) {
struct stat buffer;
return stat(path.c_str(), &buffer) == 0 && S_ISDIR(buffer.st_mode);
}
bool FirstFileInFolder(string &path, string &extension, string &fileName) {
DIR *folder = NULL;
struct dirent *file;

View File

@@ -13,6 +13,7 @@ std::string CutText(string &text, int width, string fontName, int fontSize);
std::string StrToLowerCase(string str);
bool isNumber(const string& s);
bool FileExists(const string &path, const string &name, const string &ext);
bool FolderExists(const string &path);
bool FirstFileInFolder(string &path, string &extension, string &fileName);
class splitstring : public std::string {

View File

@@ -26,6 +26,21 @@ cImageCache::~cImageCache() {
}
}
void cImageCache::SetPathes(void) {
string logoPathSkin = *cString::sprintf("%s%s/themes/%s/logos/", *config.skinPath, Setup.OSDSkin, Setup.OSDTheme);
if (FolderExists(logoPathSkin)) {
logoPath = logoPathSkin;
} else {
logoPath = *config.logoPath;
}
iconPath = *cString::sprintf("%s%s/themes/%s/", *config.skinPath, Setup.OSDSkin, Setup.OSDTheme);
skinPartsPath = *cString::sprintf("%s%s/themes/%s/skinparts/", *config.skinPath, Setup.OSDSkin, Setup.OSDTheme);
dsyslog("skindesigner: using channel logo path %s", logoPath.c_str());
dsyslog("skindesigner: using icon path %s", iconPath.c_str());
dsyslog("skindesigner: using skinparts path %s", skinPartsPath.c_str());
}
void cImageCache::CacheLogo(int width, int height) {
if (config.numLogosPerSizeInitial == 0)
return;
@@ -125,14 +140,13 @@ bool cImageCache::LogoExists(string channelID) {
const cChannel *channel = Channels.GetByChannelID(chanID);
if (!channel)
return false;
string logoPath = *cString::sprintf("%s%s/logos/", *config.skinPath, Setup.OSDTheme);
string logoLower = StrToLowerCase(channel->Name());
string logoExt = *config.logoExtension;
bool logoExists = FileExists(logoPath, logoLower, logoExt);
bool logoExists = FileExists(logoPath.c_str(), logoLower, logoExt);
if (logoExists) {
return true;
}
logoExists = FileExists(logoPath, channelID, logoExt);
logoExists = FileExists(logoPath.c_str(), channelID, logoExt);
if (logoExists) {
return true;
}
@@ -265,8 +279,8 @@ bool cImageCache::LoadIcon(eImageType type, string name) {
subdir = "menuicons";
else if (type == itIcon)
subdir = "icons";
cString iconPath = cString::sprintf("%s%s/graphics/%s/", *config.skinPath, Setup.OSDTheme, *subdir);
success = LoadImage(name, *iconPath, "png");
cString subIconPath = cString::sprintf("%s%s/", iconPath.c_str(), *subdir);
success = LoadImage(name, *subIconPath, "png");
if (success) {
return true;
}
@@ -276,21 +290,20 @@ bool cImageCache::LoadIcon(eImageType type, string name) {
bool cImageCache::LoadLogo(const cChannel *channel) {
if (!channel)
return false;
cString logoPath = cString::sprintf("%s%s/logos/", *config.skinPath, Setup.OSDTheme);
string channelID = StrToLowerCase(*(channel->GetChannelID().ToString()));
string logoLower = StrToLowerCase(channel->Name());
bool success = false;
success = LoadImage(channelID.c_str(), *logoPath, *config.logoExtension);
success = LoadImage(channelID.c_str(), logoPath.c_str(), *config.logoExtension);
if (success)
return true;
success = LoadImage(logoLower.c_str(), *logoPath, *config.logoExtension);
success = LoadImage(logoLower.c_str(), logoPath.c_str(), *config.logoExtension);
if (success)
return true;
return false;
}
bool cImageCache::LoadSeparatorLogo(string name) {
cString separatorPath = cString::sprintf("%s%s/logos/separatorlogos/", *config.skinPath, Setup.OSDTheme);
cString separatorPath = cString::sprintf("%sseparatorlogos/", logoPath.c_str());
string nameLower = StrToLowerCase(name.c_str());
bool success = false;
success = LoadImage(nameLower.c_str(), *separatorPath, *config.logoExtension);
@@ -301,8 +314,7 @@ bool cImageCache::LoadSeparatorLogo(string name) {
bool cImageCache::LoadSkinpart(string name) {
bool success = false;
cString iconPath = cString::sprintf("%s%s/graphics/skinparts/", *config.skinPath, Setup.OSDTheme);
success = LoadImage(name, *iconPath, "png");
success = LoadImage(name, skinPartsPath.c_str(), "png");
if (success) {
return true;
}

View File

@@ -18,6 +18,7 @@ public:
~cImageCache();
void Lock(void) { mutex.Lock(); }
void Unlock(void) { mutex.Unlock(); }
void SetPathes(void);
//channel logos
void CacheLogo(int width, int height);
cImage *GetLogo(string channelID, int width, int height);
@@ -41,6 +42,9 @@ private:
static cMutex mutex;
static string items[16];
cImage *tempStaticLogo;
string logoPath;
string iconPath;
string skinPartsPath;
map<string, cImage*> iconCache;
map<string, cImage*> channelLogoCache;
map<string, cImage*> skinPartsCache;

View File

@@ -27,7 +27,13 @@ bool cImageLoader::LoadImage(const char *path, int width, int height) {
}
void cImageLoader::DeterminateChannelLogoSize(int &width, int &height) {
cString logoPath = cString::sprintf("%s%s/logos/", *config.skinPath, Setup.OSDTheme);
cString logoPath;
cString logoPathSkin = cString::sprintf("%s%s/themes/%s/logos/", *config.skinPath, Setup.OSDSkin, Setup.OSDTheme);
if (FolderExists(*logoPathSkin)) {
logoPath = logoPathSkin;
} else {
logoPath = config.logoPath;
}
cString logoExt = config.logoExtension;
DIR *folder = NULL;
struct dirent *file;