added customtokens view element in displaymenumain, added automatic determination of custom int tokens

This commit is contained in:
louis 2014-12-19 15:39:21 +01:00
parent a443d53e85
commit b0fd460403
10 changed files with 61 additions and 13 deletions

View File

@ -114,4 +114,6 @@ Version 0.1.0
- fixed possible Nullpointer access in displaymenurootview
- added currentschedule viewelement in displaymenumain
- fixed bug that wrong channel was shown in header of whatson
if entering from whatsonnow
if entering from whatsonnow
- added customtokens view element in displaymenumain
- added automatic determination of custom int tokens

View File

@ -146,12 +146,19 @@ bool cSkinDesigner::SetCustomToken(string option) {
if (!globals)
return true;
map<string, string>::iterator hit = globals->customTokens.find(key);
if (hit != globals->customTokens.end()) {
globals->customTokens.erase(key);
if (isNumber(val)) {
map<string, int>::iterator hit = globals->customIntTokens.find(key);
if (hit != globals->customIntTokens.end()) {
globals->customIntTokens.erase(key);
}
globals->customIntTokens.insert(pair<string,int>(key, atoi(val.c_str())));
} else {
map<string, string>::iterator hit = globals->customStringTokens.find(key);
if (hit != globals->customStringTokens.end()) {
globals->customStringTokens.erase(key);
}
globals->customStringTokens.insert(pair<string,string>(key, val));
}
globals->customTokens.insert(pair<string,string>(key, val));
return true;
}
@ -159,8 +166,11 @@ void cSkinDesigner::ListCustomTokens(void) {
if (!globals)
return;
for (map<string, string>::iterator it = globals->customTokens.begin(); it != globals->customTokens.end(); it++) {
dsyslog("skindesigner: custom token \"%s\" = \"%s\"", (it->first).c_str(), (it->second).c_str());
for (map<string, string>::iterator it = globals->customStringTokens.begin(); it != globals->customStringTokens.end(); it++) {
dsyslog("skindesigner: custom string token \"%s\" = \"%s\"", (it->first).c_str(), (it->second).c_str());
}
for (map<string, int>::iterator it = globals->customIntTokens.begin(); it != globals->customIntTokens.end(); it++) {
dsyslog("skindesigner: custom int token \"%s\" = \"%d\"", (it->first).c_str(), it->second);
}
}

View File

@ -65,6 +65,11 @@
debug CDATA #IMPLIED
>
<!ELEMENT customtokens (area|areascroll)*>
<!ATTLIST customtokens
debug CDATA #IMPLIED
>
<!ELEMENT scrollbar (area|areascroll)*>
<!ATTLIST scrollbar
debug CDATA #IMPLIED
@ -94,7 +99,7 @@
>
<!ELEMENT menumain (background | header | datetime | colorbuttons | scrollbar | timers |
discusage | devices | systemload | currentschedule | menuitems)*>
discusage | devices | systemload | currentschedule | customtokens | menuitems)*>
<!ATTLIST menumain
x CDATA #REQUIRED
y CDATA #REQUIRED

View File

@ -31,7 +31,8 @@ public:
map <string, string> stringVars;
map <string, string> fonts;
map <string, map< string, string > > translations;
map <string, string> customTokens;
map <string, string> customStringTokens;
map <string, int> customIntTokens;
bool ReadFromXML(void);
bool Translate(string text, string &translation);
void Debug(void);

View File

@ -105,7 +105,8 @@ public:
int GetNumPixmapsViewElement(eViewElement ve);
int GetNumListViewMenuItems(void);
bool GetScalingWindow(cRect &scalingWindow);
map<string,string> GetCustomTokens(void) { return globals->customTokens; };
map<string,string> GetCustomStringTokens(void) { return globals->customStringTokens; };
map<string,int> GetCustomIntTokens(void) { return globals->customIntTokens; };
//Checks for parsing template XML files
bool ValidSubView(const char *subView);
bool ValidViewElement(const char *viewElement);

View File

@ -233,6 +233,14 @@
</area>
</systemload>
<!-- Available Variables customtokens:
all custom tokens set by the svdrp command SCTK are available in this viewelement
For instance, use an appropriate script which runs periodically as cronjob and
sets these custom tokens with svdrpsend or dbus2vdr
-->
<customtokens>
</customtokens>
<menuitems x="0" y="7%" orientation="vertical" width="70%" height="56%" align="center" numlistelements="8">
<!-- Available Variables main menu listelement:
{nummenuitem} number of item in list, starts with 1

View File

@ -79,6 +79,14 @@
<currentschedule>
</currentschedule>
<!-- Available Variables customtokens:
all custom tokens set by the svdrp command SCTK are available in this viewelement
For instance, use an appropriate script which runs periodically as cronjob and
sets these custom tokens with svdrpsend or dbus2vdr
-->
<customtokens>
</customtokens>
<menuitems x="0" y="0" orientation="vertical" width="100%" height="100%" align="center" numlistelements="8">
<!-- Available Variables main menu listelement:
{nummenuitem} number of item in list, starts with 1

View File

@ -539,8 +539,8 @@ void cDisplayChannelView::DrawCustomTokens(void) {
}
if (!tmplView)
return;
map < string, string > stringTokens = tmplView->GetCustomTokens();
map < string, int > intTokens;
map < string, string > stringTokens = tmplView->GetCustomStringTokens();
map < string, int > intTokens = tmplView->GetCustomIntTokens();
DrawViewElement(veCustomTokens, &stringTokens, &intTokens);
}

View File

@ -230,6 +230,7 @@ void cDisplayMenuMainView::DrawStaticViewElements(void) {
DrawTimers();
DrawDiscUsage();
DrawCurrentSchedule();
DrawCustomTokens();
}
bool cDisplayMenuMainView::DrawDynamicViewElements(void) {
@ -501,6 +502,17 @@ void cDisplayMenuMainView::DrawCurrentSchedule(void) {
DrawViewElement(veCurrentSchedule, &stringTokens, &intTokens);
}
void cDisplayMenuMainView::DrawCustomTokens(void) {
if (!ViewElementImplemented(veCustomTokens)) {
return;
}
if (!tmplView)
return;
map < string, string > stringTokens = tmplView->GetCustomStringTokens();
map < string, int > intTokens = tmplView->GetCustomIntTokens();
DrawViewElement(veCustomTokens, &stringTokens, &intTokens);
}
/************************************************************************
* cDisplayMenuSchedulesView
************************************************************************/

View File

@ -39,6 +39,7 @@ private:
bool DrawLoad(void);
bool DrawDevices(void);
void DrawCurrentSchedule(void);
void DrawCustomTokens(void);
public:
cDisplayMenuMainView(cTemplateView *tmplView, bool menuInit);
virtual ~cDisplayMenuMainView();