adapted plugin setup to support skin setups

This commit is contained in:
louis 2015-01-20 09:29:16 +01:00
parent f72a1856cb
commit 3bcda748cd
15 changed files with 451 additions and 149 deletions

View File

@ -71,7 +71,6 @@ OBJS = $(PLUGIN).o \
libcore/helpers.o \ libcore/helpers.o \
libcore/imageloader.o \ libcore/imageloader.o \
libcore/recfolderinfo.o \ libcore/recfolderinfo.o \
libcore/skinsetupparameter.o \
libcore/skinsetup.o \ libcore/skinsetup.o \
libcore/extrecinfo.o \ libcore/extrecinfo.o \
libcore/timers.o \ libcore/timers.o \

View File

@ -3,6 +3,7 @@
#include "libcore/imageloader.h" #include "libcore/imageloader.h"
cDesignerConfig::cDesignerConfig() { cDesignerConfig::cDesignerConfig() {
tmplGlobals = NULL;
epgImagePathSet = false; epgImagePathSet = false;
skinPathSet = false; skinPathSet = false;
logoPathSet = false; logoPathSet = false;
@ -27,9 +28,7 @@ cDesignerConfig::cDesignerConfig() {
} }
cDesignerConfig::~cDesignerConfig() { cDesignerConfig::~cDesignerConfig() {
for (map < string, cSkinSetup* >::iterator it = skinSetups.begin(); it != skinSetups.end(); it++) { ClearSkinSetups();
delete it->second;
}
} }
void cDesignerConfig::SetPathes(void) { void cDesignerConfig::SetPathes(void) {
@ -78,6 +77,12 @@ void cDesignerConfig::ReadSkins(void) {
dsyslog("skindesigner %ld skins found in %s", skins.size(), *skinPath); dsyslog("skindesigner %ld skins found in %s", skins.size(), *skinPath);
} }
void cDesignerConfig::ClearSkinSetups(void) {
for (map < string, cSkinSetup* >::iterator it = skinSetups.begin(); it != skinSetups.end(); it++) {
delete it->second;
}
}
void cDesignerConfig::ReadSkinSetup(string skin) { void cDesignerConfig::ReadSkinSetup(string skin) {
cSkinSetup *skinSetup = new cSkinSetup(skin); cSkinSetup *skinSetup = new cSkinSetup(skin);
if (skinSetup->ReadFromXML()) { if (skinSetup->ReadFromXML()) {
@ -103,6 +108,59 @@ cSkinSetup* cDesignerConfig::GetSkinSetup(string &skin) {
return NULL; return NULL;
} }
cSkinSetup* cDesignerConfig::GetSkinSetup(void) {
if (setupIt == skinSetups.end()) {
return NULL;
}
cSkinSetup* skinSetup = setupIt->second;
setupIt++;
return skinSetup;
}
void cDesignerConfig::TranslateSetup(void) {
for (map< string, cSkinSetup* >::iterator it = skinSetups.begin(); it != skinSetups.end(); it++) {
(it->second)->TranslateSetup();
}
}
void cDesignerConfig::CheckUnknownSetupParameters(void) {
for (vector < pair <string, int> >::iterator it = unknownSetupParameters.begin(); it != unknownSetupParameters.end(); it++) {
string name = (*it).first;
int value = (*it).second;
InitSkinIterator();
string activeSkin = "";
bool skinFound = false;
while (GetSkin(activeSkin)) {
size_t hit = name.find(activeSkin);
if (hit != 0)
continue;
skinFound = true;
break;
}
if (skinFound) {
cSkinSetup* skinSetup = GetSkinSetup(activeSkin);
if (skinSetup != NULL) {
string paramName = name.substr(activeSkin.size()+1);
cSkinSetupParameter *skinSetupParam = skinSetup->GetParameter(paramName);
if (skinSetupParam) {
skinSetupParam->value = value;
continue;
}
}
}
esyslog("skindesigner: ERROR Unknown Setup Parameter %s", name.c_str());
}
}
void cDesignerConfig::UpdateGlobals(void) {
string activeSkin = Setup.OSDSkin;
cSkinSetup *skinSetupActiveSkin = GetSkinSetup(activeSkin);
if (skinSetupActiveSkin && tmplGlobals) {
dsyslog("skindesigner: globals for skin %s adapted to skin setup", activeSkin.c_str());
skinSetupActiveSkin->AddToGlobals(tmplGlobals);
}
}
void cDesignerConfig::CheckDecimalPoint(void) { void cDesignerConfig::CheckDecimalPoint(void) {
struct lconv *pLocInfo; struct lconv *pLocInfo;
@ -216,6 +274,7 @@ cString cDesignerConfig::CheckSlashAtEnd(std::string path) {
} }
bool cDesignerConfig::SetupParse(const char *Name, const char *Value) { bool cDesignerConfig::SetupParse(const char *Name, const char *Value) {
bool pluginSetupParam = true;
if (!strcasecmp(Name, "DebugImageLoading")) debugImageLoading = atoi(Value); if (!strcasecmp(Name, "DebugImageLoading")) debugImageLoading = atoi(Value);
else if (!strcasecmp(Name, "LimitChannelLogoCache")) limitLogoCache = atoi(Value); else if (!strcasecmp(Name, "LimitChannelLogoCache")) limitLogoCache = atoi(Value);
else if (!strcasecmp(Name, "NumberLogosInitially")) numLogosPerSizeInitial = atoi(Value); else if (!strcasecmp(Name, "NumberLogosInitially")) numLogosPerSizeInitial = atoi(Value);
@ -224,6 +283,11 @@ bool cDesignerConfig::SetupParse(const char *Name, const char *Value) {
else if (!strcasecmp(Name, "RerunDistance")) rerunDistance = atoi(Value); else if (!strcasecmp(Name, "RerunDistance")) rerunDistance = atoi(Value);
else if (!strcasecmp(Name, "RerunMaxChannel")) rerunMaxChannel = atoi(Value); else if (!strcasecmp(Name, "RerunMaxChannel")) rerunMaxChannel = atoi(Value);
else if (!strcasecmp(Name, "BlockFlush")) blockFlush = atoi(Value); else if (!strcasecmp(Name, "BlockFlush")) blockFlush = atoi(Value);
else return false; else pluginSetupParam = false;
if (!pluginSetupParam) {
unknownSetupParameters.push_back(pair <string, int>(Name, atoi(Value)));
}
return true; return true;
} }

View File

@ -27,9 +27,12 @@ private:
string fontOsd; string fontOsd;
string fontSml; string fontSml;
string osdLanguage; string osdLanguage;
cGlobals *tmplGlobals;
map < string, map < int, string > > plugins; map < string, map < int, string > > plugins;
map < string, map < int, string > >::iterator plugIt; map < string, map < int, string > >::iterator plugIt;
map < string, cSkinSetup* > skinSetups; map < string, cSkinSetup* > skinSetups;
map < string, cSkinSetup* >::iterator setupIt;
vector < pair <string, int> > unknownSetupParameters;
public: public:
cDesignerConfig(); cDesignerConfig();
~cDesignerConfig(); ~cDesignerConfig();
@ -42,7 +45,14 @@ public:
void ReadSkinSetup(string skin); void ReadSkinSetup(string skin);
void InitSkinIterator(void) { skinIterator = skins.begin(); }; void InitSkinIterator(void) { skinIterator = skins.begin(); };
bool GetSkin(string &skin); bool GetSkin(string &skin);
void ClearSkinSetups(void);
cSkinSetup* GetSkinSetup(string &skin); cSkinSetup* GetSkinSetup(string &skin);
cSkinSetup* GetSkinSetup(void);
void InitSetupIterator(void) { setupIt = skinSetups.begin(); };
void TranslateSetup(void);
void CheckUnknownSetupParameters(void);
void SetGlobals(cGlobals *globals) { tmplGlobals = globals; };
void UpdateGlobals(void);
void CheckDecimalPoint(void); void CheckDecimalPoint(void);
void SetSkin(void); void SetSkin(void);
bool SkinChanged(void); bool SkinChanged(void);
@ -58,14 +68,15 @@ public:
cString skinPath; cString skinPath;
cString logoPath; cString logoPath;
cString epgImagePath; cString epgImagePath;
vector<string> skins;
vector<string>::iterator skinIterator;
bool replaceDecPoint;
char decPoint;
//Setup Parameter
int numLogosPerSizeInitial; int numLogosPerSizeInitial;
int limitLogoCache; int limitLogoCache;
int numLogosMax; int numLogosMax;
int debugImageLoading; int debugImageLoading;
bool replaceDecPoint;
char decPoint;
vector<string> skins;
vector<string>::iterator skinIterator;
int rerunAmount; int rerunAmount;
int rerunDistance; int rerunDistance;
int rerunMaxChannel; int rerunMaxChannel;

View File

@ -262,6 +262,7 @@ bool cSkinDesigner::LoadTemplates(void) {
esyslog("skindesigner: error parsing globals, aborting"); esyslog("skindesigner: error parsing globals, aborting");
return false; return false;
} }
config.SetGlobals(globals);
cSkinSetup *skinSetup = config.GetSkinSetup(skin); cSkinSetup *skinSetup = config.GetSkinSetup(skin);
if (skinSetup) { if (skinSetup) {

View File

@ -19,6 +19,7 @@ cSDDisplayMenu::cSDDisplayMenu(cTemplate *menuTemplate) {
doOutput = false; doOutput = false;
return; return;
} }
esyslog("skindesigner: menu opened");
} }
cSDDisplayMenu::~cSDDisplayMenu() { cSDDisplayMenu::~cSDDisplayMenu() {
@ -26,6 +27,7 @@ cSDDisplayMenu::~cSDDisplayMenu() {
delete rootView; delete rootView;
if (textAreaFont) if (textAreaFont)
delete textAreaFont; delete textAreaFont;
esyslog("skindesigner: menu closed");
} }
void cSDDisplayMenu::Scroll(bool Up, bool Page) { void cSDDisplayMenu::Scroll(bool Up, bool Page) {
@ -69,6 +71,7 @@ void cSDDisplayMenu::SetPluginMenu(string name, int menu, int type, bool init) {
void cSDDisplayMenu::SetTitle(const char *Title) { void cSDDisplayMenu::SetTitle(const char *Title) {
if (!doOutput) if (!doOutput)
return; return;
esyslog("skindesigner: --------------- Set Title %s", Title);
rootView->SetTitle(Title); rootView->SetTitle(Title);
} }
@ -184,6 +187,7 @@ bool cSDDisplayMenu::SetItemPlugin(map<string,string> *stringTokens, map<string,
} }
void cSDDisplayMenu::SetItem(const char *Text, int Index, bool Current, bool Selectable) { void cSDDisplayMenu::SetItem(const char *Text, int Index, bool Current, bool Selectable) {
esyslog("skindesigner: %d: %s %s", Index, Current ? "<---Active--->" : "", Text);
if (!doOutput) if (!doOutput)
return; return;
cDisplayMenuListView *list = rootView->GetListView(); cDisplayMenuListView *list = rootView->GetListView();

View File

@ -1,10 +1,40 @@
#include "skinsetup.h" #include "skinsetup.h"
#include "../libtemplate/xmlparser.h" #include "../libtemplate/xmlparser.h"
// --- cSkinSetupParameter -----------------------------------------------------------
cSkinSetupParameter::cSkinSetupParameter(void) {
type = sptUnknown;
name = "";
displayText = "";
min = 0;
max = 1000;
value = 0;
}
void cSkinSetupParameter::Debug(void) {
string sType = "unknown";
if (type == sptBool)
sType = "bool";
else if (type == sptInt)
sType = "int";
dsyslog("skindesigner: name \"%s\", type %s, displayText \"%s\", Value %d", name.c_str(), sType.c_str(), displayText.c_str(), value);
if (type == sptInt)
dsyslog("skindesigner: min %d, max %d", min, max);
}
// --- cSkinSetup -----------------------------------------------------------
cSkinSetup::cSkinSetup(string skin) { cSkinSetup::cSkinSetup(string skin) {
this->skin = skin; this->skin = skin;
} }
cSkinSetup::~cSkinSetup() {
for (map < string, cSkinSetupParameter* >::iterator p = parameters.begin(); p != parameters.end(); p++) {
delete p->second;
}
}
bool cSkinSetup::ReadFromXML(void) { bool cSkinSetup::ReadFromXML(void) {
string xmlFile = "setup.xml"; string xmlFile = "setup.xml";
cXmlParser parser; cXmlParser parser;
@ -30,22 +60,39 @@ void cSkinSetup::SetParameter(xmlChar *type, xmlChar *name, xmlChar* displayText
esyslog("skindesigner: invalid setup parameter for skin %s", skin.c_str()); esyslog("skindesigner: invalid setup parameter for skin %s", skin.c_str());
return; return;
} }
cSkinSetupParameter param;
param.type = paramType; cSkinSetupParameter *param = new cSkinSetupParameter();
param.name = (const char*)name; param->type = paramType;
param.displayText = (const char*)displayText; param->name = (const char*)name;
param->displayText = (const char*)displayText;
if (min && paramType == sptInt) { if (min && paramType == sptInt) {
param.min = atoi((const char*)min); param->min = atoi((const char*)min);
} }
if (max && paramType == sptInt) { if (max && paramType == sptInt) {
param.max = atoi((const char*)max); param->max = atoi((const char*)max);
} }
param.value = atoi((const char*)value); param->value = atoi((const char*)value);
parameters.insert(pair<string, cSkinSetupParameter>(param.name, param)); parameters.insert(pair< string, cSkinSetupParameter* >(param->name, param));
} }
cSkinSetupParameter *cSkinSetup::GetParameter(void) {
if (paramIt == parameters.end())
return NULL;
cSkinSetupParameter *param = paramIt->second;
paramIt++;
return param;
}
cSkinSetupParameter *cSkinSetup::GetParameter(string name) {
map < string, cSkinSetupParameter* >::iterator hit = parameters.find(name);
if (hit != parameters.end())
return hit->second;
return NULL;
}
void cSkinSetup::SetTranslation(string translationToken, map < string, string > transl) { void cSkinSetup::SetTranslation(string translationToken, map < string, string > transl) {
translations.insert(pair<string, map < string, string > >(translationToken, transl)); translations.insert(pair<string, map < string, string > >(translationToken, transl));
} }
@ -53,19 +100,73 @@ void cSkinSetup::SetTranslation(string translationToken, map < string, string >
void cSkinSetup::AddToGlobals(cGlobals *globals) { void cSkinSetup::AddToGlobals(cGlobals *globals) {
if (!globals) if (!globals)
return; return;
for (map<string, cSkinSetupParameter>::iterator p = parameters.begin(); p != parameters.end(); p++) { for (map < string, cSkinSetupParameter* >::iterator p = parameters.begin(); p != parameters.end(); p++) {
string paramName = p->first; cSkinSetupParameter *param = p->second;
cSkinSetupParameter param = p->second; globals->intVars.erase(param->name);
globals->intVars.erase(paramName); globals->intVars.insert(pair<string,int>(param->name, param->value));
globals->intVars.insert(pair<string,int>(paramName, param.value));
} }
} }
void cSkinSetup::TranslateSetup(void) {
InitParameterIterator();
cSkinSetupParameter *param = NULL;
while (param = GetParameter()) {
string transl = "";
if (Translate(param->displayText, transl)) {
param->displayText = transl;
}
}
}
bool cSkinSetup::Translate(string text, string &translation) {
string transStart = "{tr(";
string transEnd = ")}";
size_t foundStart = text.find(transStart);
size_t foundEnd = text.find(transEnd);
bool translated = false;
while (foundStart != string::npos && foundEnd != string::npos) {
string token = text.substr(foundStart + 1, foundEnd - foundStart);
string transToken = DoTranslate(token);
if (transToken.size() > 0)
translated = true;
else
return false;
text.replace(foundStart, foundEnd - foundStart + 2, transToken);
foundStart = text.find(transStart);
foundEnd = text.find(transEnd);
}
if (translated)
translation = text;
return translated;
}
string cSkinSetup::DoTranslate(string token) {
string translation = "";
map <string, map< string, string > >::iterator hit = translations.find(token);
if (hit == translations.end()) {
esyslog("skindesigner: invalid translation token %s", token.c_str());
return translation;
}
map< string, string > translats = hit->second;
map< string, string >::iterator trans = translats.find(Setup.OSDLanguage);
if (trans != translats.end()) {
translation = trans->second;
} else {
map< string, string >::iterator transDefault = translats.find("en_EN");
if (transDefault != translats.end()) {
translation = transDefault->second;
}
}
return translation;
}
void cSkinSetup::Debug(void) { void cSkinSetup::Debug(void) {
dsyslog("skindesigner: Skin \"%s\" Setup Parameters", skin.c_str()); dsyslog("skindesigner: Skin \"%s\" Setup Parameters", skin.c_str());
for (map<string, cSkinSetupParameter>::iterator p = parameters.begin(); p != parameters.end(); p++) { for (map < string, cSkinSetupParameter* >::iterator p = parameters.begin(); p != parameters.end(); p++) {
(p->second).Debug(); (p->second)->Debug();
} }
dsyslog("skindesigner: Skin \"%s\" Setup Parameter Translations", skin.c_str()); dsyslog("skindesigner: Skin \"%s\" Setup Parameter Translations", skin.c_str());
for (map<string, map<string,string> >::iterator trans = translations.begin(); trans != translations.end(); trans++) { for (map<string, map<string,string> >::iterator trans = translations.begin(); trans != translations.end(); trans++) {
dsyslog("skindesigner: translation token %s", (trans->first).c_str()); dsyslog("skindesigner: translation token %s", (trans->first).c_str());
@ -74,4 +175,5 @@ void cSkinSetup::Debug(void) {
dsyslog("skindesigner: translation language %s value \"%s\"", (trans2->first).c_str(), (trans2->second).c_str()); dsyslog("skindesigner: translation language %s value \"%s\"", (trans2->first).c_str(), (trans2->second).c_str());
} }
} }
} }

View File

@ -9,24 +9,53 @@
#include <vdr/plugin.h> #include <vdr/plugin.h>
#include <libxml/xmlstring.h> #include <libxml/xmlstring.h>
#include "../libtemplate/globals.h" #include "../libtemplate/globals.h"
#include "skinsetupparameter.h"
using namespace std; using namespace std;
enum eSetupParameterType {
sptInt,
sptBool,
sptUnknown
};
// --- cSkinSetupParameter -----------------------------------------------------------
class cSkinSetupParameter {
private:
public:
cSkinSetupParameter(void);
virtual ~cSkinSetupParameter(void) {};
eSetupParameterType type;
string name;
string displayText;
int min;
int max;
int value;
void Debug(void);
};
// --- cSkinSetup ----------------------------------------------------------- // --- cSkinSetup -----------------------------------------------------------
class cSkinSetup { class cSkinSetup {
private: private:
string skin; string skin;
map <string, cSkinSetupParameter> parameters; map < string, cSkinSetupParameter* > parameters;
map < string, cSkinSetupParameter* >::iterator paramIt;
map < string, map< string, string > > translations; map < string, map< string, string > > translations;
string DoTranslate(string token);
bool Translate(string text, string &translation);
public: public:
cSkinSetup(string skin); cSkinSetup(string skin);
virtual ~cSkinSetup(void) {}; virtual ~cSkinSetup(void);
bool ReadFromXML(void); bool ReadFromXML(void);
void SetParameter(xmlChar *type, xmlChar *name, xmlChar* displayText, xmlChar *min, xmlChar *max, xmlChar *value); void SetParameter(xmlChar *type, xmlChar *name, xmlChar* displayText, xmlChar *min, xmlChar *max, xmlChar *value);
void SetTranslation(string translationToken, map < string, string > transl); void SetTranslation(string translationToken, map < string, string > transl);
void AddToGlobals(cGlobals *globals); void AddToGlobals(cGlobals *globals);
void TranslateSetup(void);
void InitParameterIterator(void) { paramIt = parameters.begin(); };
cSkinSetupParameter *GetParameter(void);
cSkinSetupParameter *GetParameter(string name);
string GetSkin(void) { return skin; };
void Debug(void); void Debug(void);
}; };

View File

@ -1,21 +0,0 @@
#include "skinsetupparameter.h"
cSkinSetupParameter::cSkinSetupParameter(void) {
type = sptUnknown;
name = "";
displayText = "";
min = 0;
max = 1000;
value = 0;
}
void cSkinSetupParameter::Debug(void) {
string sType = "unknown";
if (type == sptBool)
sType = "bool";
else if (type == sptInt)
sType = "int";
dsyslog("skindesigner: name \"%s\", type %s, displayText \"%s\", Value %d", name.c_str(), sType.c_str(), displayText.c_str(), value);
if (type == sptInt)
dsyslog("skindesigner: min %d, max %d", min, max);
}

View File

@ -1,31 +0,0 @@
#ifndef __SKINSETUPPARAMETER_H
#define __SKINSETUPPARAMETER_H
#include <string>
#include <vdr/plugin.h>
using namespace std;
enum eSetupParameterType {
sptInt,
sptBool,
sptUnknown
};
// --- cSkinSetupParameter -----------------------------------------------------------
class cSkinSetupParameter {
private:
public:
cSkinSetupParameter(void);
virtual ~cSkinSetupParameter(void) {};
eSetupParameterType type;
string name;
string displayText;
int min;
int max;
int value;
void Debug(void);
};
#endif //__SKINSETUPPARAMETER_H

View File

@ -6,7 +6,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: vdr-skindesigner 0.0.1\n" "Project-Id-Version: vdr-skindesigner 0.0.1\n"
"Report-Msgid-Bugs-To: <see README>\n" "Report-Msgid-Bugs-To: <see README>\n"
"POT-Creation-Date: 2014-10-18 07:30+0200\n" "POT-Creation-Date: 2015-01-19 17:09+0100\n"
"PO-Revision-Date: 2014-09-27 11:02+0200\n" "PO-Revision-Date: 2014-09-27 11:02+0200\n"
"Last-Translator: Louis Braun <louis.braun@gmx.de>\n" "Last-Translator: Louis Braun <louis.braun@gmx.de>\n"
"Language-Team: \n" "Language-Team: \n"
@ -21,12 +21,12 @@ msgstr "eines nach dem anderen"
msgid "at one go" msgid "at one go"
msgstr "alle auf einmal" msgstr "alle auf einmal"
msgid "Skin"
msgstr ""
msgid "Menu Item display method" msgid "Menu Item display method"
msgstr "Art der Ausgabe der Menüelemente" msgstr "Art der Ausgabe der Menüelemente"
msgid "Reruns"
msgstr "Wiederholungen"
msgid "Maximum number of reruns to display" msgid "Maximum number of reruns to display"
msgstr "Anzahl anzuzeigender Wiederholungen" msgstr "Anzahl anzuzeigender Wiederholungen"
@ -36,9 +36,6 @@ msgstr "Zeitl. Abstand der Wiederholung (in h)"
msgid "Limit Channel Numbers (0 = no limit)" msgid "Limit Channel Numbers (0 = no limit)"
msgstr "Kanalnummern begrenzen (0 = unbegrenzt)" msgstr "Kanalnummern begrenzen (0 = unbegrenzt)"
msgid "Image Loading"
msgstr "Bilder"
msgid "Debug Image Loading" msgid "Debug Image Loading"
msgstr "Debugausgabe für das Laden der Bilder" msgstr "Debugausgabe für das Laden der Bilder"
@ -51,8 +48,8 @@ msgstr "Anzahl der initial zu cachenden Logos"
msgid "Number to cache in maximum" msgid "Number to cache in maximum"
msgstr "Maximale Anzahl zu cachender Logos" msgstr "Maximale Anzahl zu cachender Logos"
msgid "Cache Statistics" msgid "has no setup"
msgstr "Cache Statistik" msgstr ""
msgid "cached" msgid "cached"
msgstr "cached" msgstr "cached"
@ -71,3 +68,12 @@ msgstr "Logos"
msgid "skinparts" msgid "skinparts"
msgstr "Skinparts" msgstr "Skinparts"
#~ msgid "Reruns"
#~ msgstr "Wiederholungen"
#~ msgid "Image Loading"
#~ msgstr "Bilder"
#~ msgid "Cache Statistics"
#~ msgstr "Cache Statistik"

193
setup.c
View File

@ -1,7 +1,14 @@
#include "setup.h" #include "setup.h"
cSkinDesignerSetup::cSkinDesignerSetup() { cSkinDesignerSetup::cSkinDesignerSetup() {
data = config; numLogosPerSizeInitial = config.numLogosPerSizeInitial;
limitLogoCache = config.limitLogoCache;
numLogosMax = config.numLogosMax;
debugImageLoading = config.debugImageLoading;
rerunAmount = config.rerunAmount;
rerunDistance = config.rerunDistance;
rerunMaxChannel = config.rerunMaxChannel;
blockFlush = config.blockFlush;
menuDisplayStyle[0] = tr("after one another"); menuDisplayStyle[0] = tr("after one another");
menuDisplayStyle[1] = tr("at one go"); menuDisplayStyle[1] = tr("at one go");
Setup(); Setup();
@ -15,36 +22,117 @@ void cSkinDesignerSetup::Setup(void) {
int current = Current(); int current = Current();
Clear(); Clear();
Add(new cMenuEditStraItem(tr("Menu Item display method"), &data.blockFlush, 2, menuDisplayStyle)); SkinSetup();
PluginSetup();
ImageCacheStatistics();
cString message = cString::sprintf("---------------- %s ----------------", tr("Reruns"));
Add(new cOsdItem(*message));
cList<cOsdItem>::Last()->SetSelectable(false);
Add(new cMenuEditIntItem(tr("Maximum number of reruns to display"), &data.rerunAmount, 1, 100));
Add(new cMenuEditIntItem(tr("Minimum timely distance of rerun (in hours)"), &data.rerunDistance, 0, 1000));
Add(new cMenuEditIntItem(tr("Limit Channel Numbers (0 = no limit)"), &data.rerunMaxChannel, 0, 1000));
message = cString::sprintf("---------------- %s ----------------", tr("Image Loading"));
Add(new cOsdItem(*message));
cList<cOsdItem>::Last()->SetSelectable(false);
Add(new cMenuEditBoolItem(tr("Debug Image Loading"), &data.debugImageLoading));
Add(new cMenuEditBoolItem(tr("Limit Channel Logo Cache"), &data.limitLogoCache));
Add(new cMenuEditIntItem(tr("Number to cache initially (per size)"), &data.numLogosPerSizeInitial, 0, 1000));
Add(new cMenuEditIntItem(tr("Number to cache in maximum"), &data.numLogosMax, 0, 1000));
if (!imgCache) {
SetCurrent(Get(current)); SetCurrent(Get(current));
Display(); Display();
}
eOSState cSkinDesignerSetup::ProcessKey(eKeys Key) {
bool hadSubMenu = HasSubMenu();
eOSState state = cMenuSetupPage::ProcessKey(Key);
if (hadSubMenu && Key == kOk) {
esyslog("skindesigner: store submenu");
}
if (!hadSubMenu && (state == osUnknown || Key == kOk)) {
if ((Key == kOk && !hadSubMenu)) {
switch (Key) {
case kOk: {
string itemText = Get(Current())->Text();
size_t hit = itemText.find(tr("Skin"));
if (hit == 0) {
string skin = itemText.substr(strlen(tr("Skin"))+1);
state = AddSubMenu(new cSkindesignerSkinSetup(skin));
}
break;
} default:
break;
}
}
}
return state;
}
void cSkinDesignerSetup::Store(void) {
config.numLogosPerSizeInitial = numLogosPerSizeInitial;
config.limitLogoCache = limitLogoCache;
config.numLogosMax = numLogosMax;
config.debugImageLoading = debugImageLoading;
config.rerunAmount = rerunAmount;
config.rerunDistance = rerunDistance;
config.rerunMaxChannel = rerunMaxChannel;
config.blockFlush = blockFlush;
config.InitSetupIterator();
cSkinSetup *skinSetup = NULL;
while (skinSetup = config.GetSkinSetup()) {
string skin = skinSetup->GetSkin();
skinSetup->InitParameterIterator();
cSkinSetupParameter *param = NULL;
while (param = skinSetup->GetParameter()) {
SetupStore(*cString::sprintf("%s.%s", skin.c_str(), param->name.c_str()), param->value);
}
}
config.UpdateGlobals();
SetupStore("DebugImageLoading", debugImageLoading);
SetupStore("LimitChannelLogoCache", limitLogoCache);
SetupStore("NumberLogosInitially", numLogosPerSizeInitial);
SetupStore("NumberLogosMax", numLogosMax);
SetupStore("RerunAmount", rerunAmount);
SetupStore("RerunDistance", rerunDistance);
SetupStore("RerunMaxChannel", rerunMaxChannel);
SetupStore("BlockFlush", blockFlush);
}
cOsdItem *cSkinDesignerSetup::InfoItem(const char *label) {
cOsdItem *item;
item = new cOsdItem(cString::sprintf("---------------- %s ----------------", tr(label)));
item->SetSelectable(false);
return item;
}
void cSkinDesignerSetup::PluginSetup(void) {
Add(InfoItem("Plugin Setup"));
Add(new cMenuEditStraItem(tr("Menu Item display method"), &blockFlush, 2, menuDisplayStyle));
Add(InfoItem("Reruns"));
Add(new cMenuEditIntItem(tr("Maximum number of reruns to display"), &rerunAmount, 1, 100));
Add(new cMenuEditIntItem(tr("Minimum timely distance of rerun (in hours)"), &rerunDistance, 0, 1000));
Add(new cMenuEditIntItem(tr("Limit Channel Numbers (0 = no limit)"), &rerunMaxChannel, 0, 1000));
Add(InfoItem("Image Loading"));
Add(new cMenuEditBoolItem(tr("Debug Image Loading"), &debugImageLoading));
Add(new cMenuEditBoolItem(tr("Limit Channel Logo Cache"), &limitLogoCache));
Add(new cMenuEditIntItem(tr("Number to cache initially (per size)"), &numLogosPerSizeInitial, 0, 1000));
Add(new cMenuEditIntItem(tr("Number to cache in maximum"), &numLogosMax, 0, 1000));
}
void cSkinDesignerSetup::SkinSetup(void) {
Add(InfoItem("Skin Setup"));
config.InitSkinIterator();
string skin = "";
while (config.GetSkin(skin)) {
cSkinSetup *skinSetup = config.GetSkinSetup(skin);
if (!skinSetup) {
Add(new cOsdItem(cString::sprintf("%s %s %s", tr("Skin"), skin.c_str(), tr("has no setup"))));
cList<cOsdItem>::Last()->SetSelectable(false);
} else {
Add(new cOsdItem(cString::sprintf("%s %s", tr("Skin"), skin.c_str())));
}
}
}
void cSkinDesignerSetup::ImageCacheStatistics(void) {
if (!imgCache) {
return; return;
} }
message = cString::sprintf("---------------- %s ----------------", tr("Cache Statistics")); Add(InfoItem("Cache Statistics"));
Add(new cOsdItem(*message));
cList<cOsdItem>::Last()->SetSelectable(false);
int sizeIconCache = 0; int sizeIconCache = 0;
int numIcons = 0; int numIcons = 0;
imgCache->GetIconCacheSize(numIcons, sizeIconCache); imgCache->GetIconCacheSize(numIcons, sizeIconCache);
@ -65,35 +153,44 @@ void cSkinDesignerSetup::Setup(void) {
cString skinpartCacheInfo = cString::sprintf("%s %d %s - %s %d %s", tr("cached"), numSkinparts, tr("skinparts"), tr("size"), sizeSkinpartCache, tr("byte")); cString skinpartCacheInfo = cString::sprintf("%s %d %s - %s %d %s", tr("cached"), numSkinparts, tr("skinparts"), tr("size"), sizeSkinpartCache, tr("byte"));
Add(new cOsdItem(*skinpartCacheInfo)); Add(new cOsdItem(*skinpartCacheInfo));
cList<cOsdItem>::Last()->SetSelectable(false); cList<cOsdItem>::Last()->SetSelectable(false);
SetCurrent(Get(current));
Display();
} }
eOSState cSkinDesignerSetup::ProcessKey(eKeys Key) { // --- cSkindesignerSkinSetup -----------------------------------------------------------
eOSState state = cMenuSetupPage::ProcessKey(Key);
switch (state) { cSkindesignerSkinSetup::cSkindesignerSkinSetup(string skin) : cOsdMenu(*cString::sprintf("%s: %s \"%s\"", trVDR("Setup"), tr("Skin"), skin.c_str()), 30) {
case osContinue: { this->skin = skin;
if (NORMALKEY(Key) == kUp || NORMALKEY(Key) == kDown) { Set();
cOsdItem* item = Get(Current()); }
if (item)
item->ProcessKey(kNone); cSkindesignerSkinSetup::~cSkindesignerSkinSetup() {
}
eOSState cSkindesignerSkinSetup::ProcessKey(eKeys Key) {
eOSState state = cOsdMenu::ProcessKey(Key);
if (state == osUnknown) {
switch (Key) {
case kOk:
return osBack;
default:
break;
} }
break; }
default: break;
} }
return state; return state;
} }
void cSkinDesignerSetup::Store(void) { void cSkindesignerSkinSetup::Set(void) {
config = data; cSkinSetup *skinSetup = config.GetSkinSetup(skin);
if (!skinSetup)
return;
skinSetup->InitParameterIterator();
cSkinSetupParameter *param = NULL;
while (param = skinSetup->GetParameter()) {
if (param->type == sptInt) {
Add(new cMenuEditIntItem(param->displayText.c_str(), &param->value, param->min, param->max));
} else if (param->type == sptBool) {
Add(new cMenuEditBoolItem(param->displayText.c_str(), &param->value));
}
}
SetupStore("DebugImageLoading", config.debugImageLoading);
SetupStore("LimitChannelLogoCache", config.limitLogoCache);
SetupStore("NumberLogosInitially", config.numLogosPerSizeInitial);
SetupStore("NumberLogosMax", config.numLogosMax);
SetupStore("RerunAmount", config.rerunAmount);
SetupStore("RerunDistance", config.rerunDistance);
SetupStore("RerunMaxChannel", config.rerunMaxChannel);
SetupStore("BlockFlush", config.blockFlush);
} }

40
setup.h
View File

@ -3,15 +3,43 @@
#include "config.h" #include "config.h"
// --- cSkinDesignerSetup -----------------------------------------------------------
class cSkinDesignerSetup : public cMenuSetupPage { class cSkinDesignerSetup : public cMenuSetupPage {
private:
int numLogosPerSizeInitial;
int limitLogoCache;
int numLogosMax;
int debugImageLoading;
int rerunAmount;
int rerunDistance;
int rerunMaxChannel;
int blockFlush;
const char *menuDisplayStyle[2];
void Setup(void);
virtual void Store(void);
virtual eOSState ProcessKey(eKeys Key);
cOsdItem *InfoItem(const char *label);
void PluginSetup(void);
void SkinSetup(void);
void ImageCacheStatistics(void);
public: public:
cSkinDesignerSetup(void); cSkinDesignerSetup(void);
virtual ~cSkinDesignerSetup(); virtual ~cSkinDesignerSetup();
private:
cDesignerConfig data;
const char *menuDisplayStyle[2];
void Setup(void);
virtual eOSState ProcessKey(eKeys Key);
virtual void Store(void);
}; };
// --- cSkindesignerSkinSetup -----------------------------------------------------------
class cSkindesignerSkinSetup : public cOsdMenu {
private:
string skin;
protected:
virtual eOSState ProcessKey(eKeys Key);
void Set(void);
public:
cSkindesignerSkinSetup(string skin);
virtual ~cSkindesignerSkinSetup();
};
#endif //__SKINDESIGNER_SETUP_H #endif //__SKINDESIGNER_SETUP_H

View File

@ -98,6 +98,7 @@ bool cPluginSkinDesigner::Start(void) {
cXmlParser::InitLibXML(); cXmlParser::InitLibXML();
cImageImporterSVG::InitLibRSVG(); cImageImporterSVG::InitLibRSVG();
bool trueColorAvailable = true; bool trueColorAvailable = true;
if (!cOsdProvider::SupportsTrueColor()) { if (!cOsdProvider::SupportsTrueColor()) {
esyslog("skindesigner: No TrueColor OSD found! Using default Skin LCARS!"); esyslog("skindesigner: No TrueColor OSD found! Using default Skin LCARS!");
trueColorAvailable = false; trueColorAvailable = false;
@ -115,6 +116,9 @@ bool cPluginSkinDesigner::Start(void) {
newSkin->ActivateBackupSkin(); newSkin->ActivateBackupSkin();
} }
} }
config.TranslateSetup();
config.CheckUnknownSetupParameters();
if (skins.size() == 0) { if (skins.size() == 0) {
esyslog("skindesigner: no skins found! Using default Skin LCARS!"); esyslog("skindesigner: no skins found! Using default Skin LCARS!");
} }
@ -218,6 +222,14 @@ cString cPluginSkinDesigner::SVDRPCommand(const char *Command, const char *Optio
} }
if (strcasecmp(Command, "RELD") == 0) { if (strcasecmp(Command, "RELD") == 0) {
config.ClearSkinSetups();
config.InitSkinIterator();
string skin = "";
while (config.GetSkin(skin)) {
config.ReadSkinSetup(skin);
}
config.TranslateSetup();
config.CheckUnknownSetupParameters();
activeSkin->Reload(); activeSkin->Reload();
ReplyCode = 250; ReplyCode = 250;
return "SKINDESIGNER reload of templates and caches forced."; return "SKINDESIGNER reload of templates and caches forced.";

View File

@ -12,9 +12,9 @@
"displayname" is used to display the option in the setup menu. "displayname" is used to display the option in the setup menu.
--> -->
<parameters> <parameters>
<parameter type="bool" name="showsignal" displaytext="tr(showsignaltext)">0</parameter> <parameter type="bool" name="showsignal" displaytext="{tr(showsignaltext)}">0</parameter>
<parameter type="bool" name="showposter" displaytext="tr(showpostertext)">1</parameter> <parameter type="bool" name="showposter" displaytext="{tr(showpostertext)}">1</parameter>
<parameter type="int" name="fadetime" min="0" max="1000" displaytext="tr(fadetext)">300</parameter> <parameter type="int" name="fadetime" min="0" max="1000" displaytext="{tr(fadetext)}">300</parameter>
</parameters> </parameters>
<!-- <!--

View File

@ -307,8 +307,9 @@ void cDisplayChannelView::ClearScreenResolution(void) {
} }
void cDisplayChannelView::DrawScraperContent(const cEvent *event) { void cDisplayChannelView::DrawScraperContent(const cEvent *event) {
if (!event) if (!event) {
return; return;
}
if (!ViewElementImplemented(veScraperContent)) { if (!ViewElementImplemented(veScraperContent)) {
return; return;