added possibility to detach viewelements

This commit is contained in:
louis 2015-03-28 11:57:51 +01:00
parent fcf90375fa
commit 762e2c1507
30 changed files with 1188 additions and 681 deletions

View File

@ -229,4 +229,8 @@ Version 0.3.1
Version 0.3.2 Version 0.3.2
- fixed crash if number of dvb devices changes - fixed crash if number of dvb devices changes
- added possibility to detach dedicated viewelements in displaychannel
and displaymenumain that they start in an own thread
- introduced background="true" attribute in viewelements. These areas
will only be drawn once.

View File

@ -91,8 +91,8 @@ OBJS = $(PLUGIN).o \
views/view.o \ views/view.o \
views/viewgrid.o \ views/viewgrid.o \
views/viewhelpers.o \ views/viewhelpers.o \
views/displayviewelements.o \
views/displaychannelview.o \ views/displaychannelview.o \
views/displaychannelviewelements.o \
views/displaymenurootview.o \ views/displaymenurootview.o \
views/displaymenuview.o \ views/displaymenuview.o \
views/displaymenulistview.o \ views/displaymenulistview.o \

View File

@ -22,13 +22,11 @@ cSDDisplayChannel::cSDDisplayChannel(cTemplate *channelTemplate, bool WithInfo)
doOutput = false; doOutput = false;
return; return;
} }
esyslog("skindesigner: displaychannel opened");
} }
cSDDisplayChannel::~cSDDisplayChannel() { cSDDisplayChannel::~cSDDisplayChannel() {
if (channelView) if (channelView)
delete channelView; delete channelView;
esyslog("skindesigner: displaychannel closed");
} }
void cSDDisplayChannel::SetChannel(const cChannel *Channel, int Number) { void cSDDisplayChannel::SetChannel(const cChannel *Channel, int Number) {

View File

@ -95,24 +95,36 @@
<!ELEMENT currentweather (area|areascroll)*> <!ELEMENT currentweather (area|areascroll)*>
<!ATTLIST currentweather <!ATTLIST currentweather
detached CDATA #IMPLIED
delay CDATA #IMPLIED
fadetime CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
> >
<!ELEMENT scrapercontent (area|areascroll)*> <!ELEMENT scrapercontent (area|areascroll)*>
<!ATTLIST scrapercontent <!ATTLIST scrapercontent
detached CDATA #IMPLIED
delay CDATA #IMPLIED
fadetime CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
> >
<!ELEMENT datetime (area|areascroll)*> <!ELEMENT datetime (area|areascroll)*>
<!ATTLIST datetime <!ATTLIST datetime
detached CDATA #IMPLIED
delay CDATA #IMPLIED
fadetime CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
> >
<!ELEMENT time (area|areascroll)*> <!ELEMENT time (area|areascroll)*>
<!ATTLIST time <!ATTLIST time
detached CDATA #IMPLIED
delay CDATA #IMPLIED
fadetime CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
> >
@ -125,6 +137,9 @@
<!ELEMENT customtokens (area|areascroll)*> <!ELEMENT customtokens (area|areascroll)*>
<!ATTLIST customtokens <!ATTLIST customtokens
detached CDATA #IMPLIED
delay CDATA #IMPLIED
fadetime CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
> >

View File

@ -53,54 +53,81 @@
<!ELEMENT timers (area|areascroll)*> <!ELEMENT timers (area|areascroll)*>
<!ATTLIST timers <!ATTLIST timers
detached CDATA #IMPLIED
delay CDATA #IMPLIED
fadetime CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
> >
<!ELEMENT discusage (area|areascroll)*> <!ELEMENT discusage (area|areascroll)*>
<!ATTLIST discusage <!ATTLIST discusage
detached CDATA #IMPLIED
delay CDATA #IMPLIED
fadetime CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
> >
<!ELEMENT devices (area|areascroll)*> <!ELEMENT devices (area|areascroll)*>
<!ATTLIST devices <!ATTLIST devices
detached CDATA #IMPLIED
delay CDATA #IMPLIED
fadetime CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
> >
<!ELEMENT systemload (area|areascroll)*> <!ELEMENT systemload (area|areascroll)*>
<!ATTLIST systemload <!ATTLIST systemload
detached CDATA #IMPLIED
delay CDATA #IMPLIED
fadetime CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
> >
<!ELEMENT systemmemory (area|areascroll)*> <!ELEMENT systemmemory (area|areascroll)*>
<!ATTLIST systemmemory <!ATTLIST systemmemory
detached CDATA #IMPLIED
delay CDATA #IMPLIED
fadetime CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
> >
<!ELEMENT temperatures (area|areascroll)*> <!ELEMENT temperatures (area|areascroll)*>
<!ATTLIST temperatures <!ATTLIST temperatures
detached CDATA #IMPLIED
delay CDATA #IMPLIED
fadetime CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
> >
<!ELEMENT currentschedule (area|areascroll)*> <!ELEMENT currentschedule (area|areascroll)*>
<!ATTLIST currentschedule <!ATTLIST currentschedule
detached CDATA #IMPLIED
delay CDATA #IMPLIED
fadetime CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
> >
<!ELEMENT currentweather (area|areascroll)*> <!ELEMENT currentweather (area|areascroll)*>
<!ATTLIST currentweather <!ATTLIST currentweather
detached CDATA #IMPLIED
delay CDATA #IMPLIED
fadetime CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
> >
<!ELEMENT customtokens (area|areascroll)*> <!ELEMENT customtokens (area|areascroll)*>
<!ATTLIST customtokens <!ATTLIST customtokens
detached CDATA #IMPLIED
delay CDATA #IMPLIED
fadetime CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
> >

View File

@ -7,6 +7,7 @@
layer CDATA #REQUIRED layer CDATA #REQUIRED
transparency CDATA #IMPLIED transparency CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
background (true|false) #IMPLIED
debug (true|false) #IMPLIED debug (true|false) #IMPLIED
> >

View File

@ -83,6 +83,8 @@ void cTemplateFunction::SetParameters(vector<pair<string, string> > params) {
p.first = ptLayer; p.first = ptLayer;
} else if (!name.compare("transparency")) { } else if (!name.compare("transparency")) {
p.first = ptTransparency; p.first = ptTransparency;
} else if (!name.compare("background")) {
p.first = ptBackground;
} else if (!name.compare("quadrant")) { } else if (!name.compare("quadrant")) {
p.first = ptQuadrant; p.first = ptQuadrant;
} else if (!name.compare("type")) { } else if (!name.compare("type")) {
@ -271,6 +273,9 @@ bool cTemplateFunction::CalculateParameters(void) {
case ptDetached: case ptDetached:
paramValid = SetDetached(value); paramValid = SetDetached(value);
break; break;
case ptBackground:
paramValid = SetBackground(value);
break;
default: default:
paramValid = true; paramValid = true;
break; break;
@ -413,6 +418,8 @@ int cTemplateFunction::GetNumericParameter(eParamType type) {
return 0; return 0;
else if (type == ptDetached) else if (type == ptDetached)
return 0; return 0;
else if (type == ptBackground)
return 0;
return -1; return -1;
} }
return hit->second; return hit->second;
@ -1077,6 +1084,14 @@ bool cTemplateFunction::SetDetached(string value) {
return true; return true;
} }
bool cTemplateFunction::SetBackground(string value) {
int back = 0;
if (!value.compare("true"))
back = 1;
numericParameters.insert(pair<eParamType, int>(ptBackground, back));
return true;
}
void cTemplateFunction::ParseStringParameters(void) { void cTemplateFunction::ParseStringParameters(void) {
//first replace stringtokens in Text (drawText) //first replace stringtokens in Text (drawText)
stringstream text; stringstream text;

View File

@ -56,6 +56,7 @@ enum eParamType {
ptText, ptText,
ptLayer, ptLayer,
ptTransparency, ptTransparency,
ptBackground,
ptQuadrant, ptQuadrant,
ptType, ptType,
ptAlign, ptAlign,
@ -154,6 +155,7 @@ protected:
bool SetOverflow(string value); bool SetOverflow(string value);
bool SetHideRoot(string value); bool SetHideRoot(string value);
bool SetDetached(string value); bool SetDetached(string value);
bool SetBackground(string value);
void ParseStringParameters(void); void ParseStringParameters(void);
void ParseNumericalParameters(void); void ParseNumericalParameters(void);
void CalculateAlign(int elementWidth, int elementHeight); void CalculateAlign(int elementWidth, int elementHeight);

View File

@ -12,6 +12,7 @@ cTemplatePixmap::cTemplatePixmap(void) {
containerHeight = 0; containerHeight = 0;
globals = NULL; globals = NULL;
scrolling = false; scrolling = false;
background = false;
} }
cTemplatePixmap::~cTemplatePixmap() { cTemplatePixmap::~cTemplatePixmap() {
@ -171,6 +172,8 @@ bool cTemplatePixmap::CalculateParameters(void) {
} }
} }
background = parameters->GetNumericParameter(ptBackground);
return paramsValid; return paramsValid;
} }

View File

@ -21,6 +21,7 @@ using namespace std;
class cTemplatePixmap { class cTemplatePixmap {
protected: protected:
bool scrolling; bool scrolling;
bool background;
cTemplateFunction *parameters; cTemplateFunction *parameters;
vector<cTemplateFunction*> functions; vector<cTemplateFunction*> functions;
vector<cTemplateFunction*>::iterator funcIt; vector<cTemplateFunction*>::iterator funcIt;
@ -76,6 +77,7 @@ public:
bool DoExecute(void) { return parameters->DoExecute(); }; bool DoExecute(void) { return parameters->DoExecute(); };
bool DoDebug(void) { return parameters->DoDebug(); }; bool DoDebug(void) { return parameters->DoDebug(); };
bool Ready(void); bool Ready(void);
bool BackgroundArea(void) { return background; };
//Traverse Functions //Traverse Functions
void InitIterator(void); void InitIterator(void);
cTemplateFunction *GetNextFunction(void); cTemplateFunction *GetNextFunction(void);

View File

@ -638,6 +638,7 @@ void cTemplateView::SetFunctionDefinitions(void) {
attributes.insert("height"); attributes.insert("height");
attributes.insert("layer"); attributes.insert("layer");
attributes.insert("transparency"); attributes.insert("transparency");
attributes.insert("background");
funcsAllowed.insert(pair< string, set<string> >(name, attributes)); funcsAllowed.insert(pair< string, set<string> >(name, attributes));
name = "areascroll"; name = "areascroll";

View File

@ -52,7 +52,7 @@
</area> </area>
</scrollbar> </scrollbar>
<currentweather> <currentweather detached="true" delay="100" fadetime="0">
<area x="40%" y="0" width="15%" height="8%" layer="3"> <area x="40%" y="0" width="15%" height="8%" layer="3">
<drawimage name="weathericon" imagetype="icon" path="{icon}" align="right" valign="center" width="{areaheight}*0.8" height="{areaheight}*0.8"/> <drawimage name="weathericon" imagetype="icon" path="{icon}" align="right" valign="center" width="{areaheight}*0.8" height="{areaheight}*0.8"/>
<drawtext name="temperature" x="{areawidth} - {width(weathericon)} - {width(temperature)} - 10" valign="center" font="{light}" fontsize="80%" color="{clrWhite}" text="{temperature}°C" /> <drawtext name="temperature" x="{areawidth} - {width(weathericon)} - {width(temperature)} - 10" valign="center" font="{light}" fontsize="80%" color="{clrWhite}" text="{temperature}°C" />
@ -75,7 +75,7 @@
{timers[channelid]} ChannelID of channel {timers[channelid]} ChannelID of channel
{timers[channellogoexists]} true if channel logo exists {timers[channellogoexists]} true if channel logo exists
--> -->
<timers> <timers detached="true" delay="100" fadetime="0">
<area condition="not{numtimers}" x="55%" y="71%" width="44%" height="19%" layer="2"> <area condition="not{numtimers}" x="55%" y="71%" width="44%" height="19%" layer="2">
<drawtext align="center" valign="center" font="{semibold}" fontsize="40%" color="{clrWhite}" text="{tr(noactivetimers)}" /> <drawtext align="center" valign="center" font="{semibold}" fontsize="40%" color="{clrWhite}" text="{tr(noactivetimers)}" />
</area> </area>
@ -97,7 +97,7 @@
{discalert} true if disc usage is > 95% {discalert} true if disc usage is > 95%
{vdrusagestring} localized VDR internal usage string {vdrusagestring} localized VDR internal usage string
--> -->
<discusage> <discusage detached="true" delay="100" fadetime="0">
<area x="55%" y="51%" width="44%" height="19%" layer="5"> <area x="55%" y="51%" width="44%" height="19%" layer="5">
<drawimage imagetype="skinpart" path="tachohands/perc_{usedpercent}" x="{areawidth}*0.025" y="5%" width="20%" height="{areawidth}*0.20"/> <drawimage imagetype="skinpart" path="tachohands/perc_{usedpercent}" x="{areawidth}*0.025" y="5%" width="20%" height="{areawidth}*0.20"/>
</area> </area>
@ -131,7 +131,7 @@
{load} current system load {load} current system load
{loadhand} system load for tacho hand (between 0 and 2.5 in 0.025 steps multiplied by 1000, >2.5 is always 2525) {loadhand} system load for tacho hand (between 0 and 2.5 in 0.025 steps multiplied by 1000, >2.5 is always 2525)
--> -->
<systemload> <systemload detached="true" delay="100" fadetime="0">
<area x="55%" y="51%" width="44%" height="19%" layer="5"> <area x="55%" y="51%" width="44%" height="19%" layer="5">
<drawimage imagetype="skinpart" path="tachohands/load_{loadhand}" x="{areawidth}*0.28" y="5%" width="20%" height="{areawidth}*0.20"/> <drawimage imagetype="skinpart" path="tachohands/load_{loadhand}" x="{areawidth}*0.28" y="5%" width="20%" height="{areawidth}*0.20"/>
</area> </area>
@ -144,7 +144,7 @@
{cputemp} current cpu temperature in °C {cputemp} current cpu temperature in °C
{gputemp} current gpu temperature in °C {gputemp} current gpu temperature in °C
--> -->
<temperatures> <temperatures detached="true" delay="100" fadetime="0">
<area x="55%" y="51%" width="44%" height="19%" layer="5"> <area x="55%" y="51%" width="44%" height="19%" layer="5">
<drawimage condition="gt({cputemp}, 80)" imagetype="skinpart" path="tachohands/temp_81" x="{areawidth}*0.53" y="5%" width="20%" height="{areawidth}*0.2"/> <drawimage condition="gt({cputemp}, 80)" imagetype="skinpart" path="tachohands/temp_81" x="{areawidth}*0.53" y="5%" width="20%" height="{areawidth}*0.2"/>
<drawimage condition="lt({cputemp}, 81)" imagetype="skinpart" path="tachohands/temp_{cputemp}" x="{areawidth}*0.53" y="5%" width="20%" height="{areawidth}*0.2"/> <drawimage condition="lt({cputemp}, 81)" imagetype="skinpart" path="tachohands/temp_{cputemp}" x="{areawidth}*0.53" y="5%" width="20%" height="{areawidth}*0.2"/>

View File

@ -7,16 +7,6 @@
<area x="0" y="80%" width="100%" height="20%" layer="1"> <area x="0" y="80%" width="100%" height="20%" layer="1">
<fill color="{clrTransBlack}" /> <fill color="{clrTransBlack}" />
</area> </area>
<!-- background datetime -->
<area x="70%" y="0" width="30%" height="13%" layer="1">
<fill color="{clrTransBlack}" />
<drawrectangle x="0" y="0" width="45%" height="100%" color="{clrTransBlueLight}" />
</area>
<!-- background weather -->
<area x="70%" y="15%" width="30%" height="13%" layer="1">
<fill color="{clrTransBlack}" />
<drawrectangle x="0" y="0" width="45%" height="100%" color="{clrTransBlueLight}" />
</area>
<!-- background channellogo --> <!-- background channellogo -->
<area x="0" y="80%" width="20%" height="20%" layer="2"> <area x="0" y="80%" width="20%" height="20%" layer="2">
<fill color="{clrTransBlueLight}" /> <fill color="{clrTransBlueLight}" />
@ -196,11 +186,11 @@
{devices[channelid]} ID of the currently tuned channel {devices[channelid]} ID of the currently tuned channel
{devices[source]} source of the currently tuned channel {devices[source]} source of the currently tuned channel
--> -->
<devices detached="true" delay="500" fadetime="500"> <devices condition="{showdevices}" detached="true" delay="100" fadetime="{fadetime}">
<area condition="{showdevices}" x="70%" y="30%" width="30%" height="{areaheight}/12 * {numdevices}" layer="1"> <area x="70%" y="30%" width="30%" height="{areaheight}/12 * {numdevices}" layer="1" background="true">
<fill color="{clrTransBlack}"/> <fill color="{clrTransBlack}"/>
</area> </area>
<area condition="{showdevices}" x="70%" y="30%" width="30%" height="{areaheight}/12 * {numdevices}" layer="2"> <area x="70%" y="30%" width="30%" height="{areaheight}/12 * {numdevices}" layer="2">
<loop name="devices" x="0" y="0" orientation="vertical" columnwidth="{areawidth}" rowheight="{areaheight} / {numdevices}" overflow="cut"> <loop name="devices" x="0" y="0" orientation="vertical" columnwidth="{areawidth}" rowheight="{areaheight} / {numdevices}" overflow="cut">
<drawtext name="label" x="5" y="0" font="{light}" fontsize="{rowheight}*0.35" color="{clrWhite}" text="{devices[num]}: {devices[type]}" /> <drawtext name="label" x="5" y="0" font="{light}" fontsize="{rowheight}*0.35" color="{clrWhite}" text="{devices[num]}: {devices[type]}" />
<drawtext condition="{devices[hascam]}" x="{width(label)} + 15" y="0" font="{light}" fontsize="{rowheight}*0.35" color="{clrWhite}" text="(CAM {devices[cam]})" /> <drawtext condition="{devices[hascam]}" x="{width(label)} + 15" y="0" font="{light}" fontsize="{rowheight}*0.35" color="{clrWhite}" text="(CAM {devices[cam]})" />
@ -235,6 +225,10 @@
{ozone} ozone value in DU {ozone} ozone value in DU
--> -->
<currentweather> <currentweather>
<area background="true" x="70%" y="15%" width="30%" height="13%" layer="1">
<fill color="{clrTransBlack}" />
<drawrectangle x="0" y="0" width="45%" height="100%" color="{clrTransBlueLight}" />
</area>
<area x="70%" y="15%" width="13%" height="13%" layer="2"> <area x="70%" y="15%" width="13%" height="13%" layer="2">
<drawimage imagetype="icon" path="{icon}" align="center" valign="center" width="{areaheight}*0.8" height="{areaheight}*0.8"/> <drawimage imagetype="icon" path="{icon}" align="center" valign="center" width="{areaheight}*0.8" height="{areaheight}*0.8"/>
</area> </area>
@ -284,6 +278,10 @@
{year} year in yyyy {year} year in yyyy
--> -->
<datetime> <datetime>
<area background="true" x="70%" y="0" width="30%" height="13%" layer="1">
<fill color="{clrTransBlack}" />
<drawrectangle x="0" y="0" width="45%" height="100%" color="{clrTransBlueLight}" />
</area>
<area x="70%" y="0" width="13%" height="13%" layer="2"> <area x="70%" y="0" width="13%" height="13%" layer="2">
<drawtext align="right" y="0" font="{light}" fontsize="50%" color="{clrWhite}" text="{dayname}" /> <drawtext align="right" y="0" font="{light}" fontsize="50%" color="{clrWhite}" text="{dayname}" />
<drawtext align="right" y="48%" font="{light}" fontsize="50%" color="{clrWhite}" text="{day}. {monthnameshort}" /> <drawtext align="right" y="48%" font="{light}" fontsize="50%" color="{clrWhite}" text="{day}. {monthnameshort}" />

View File

@ -120,7 +120,7 @@
{timers[channelid]} ChannelID of channel {timers[channelid]} ChannelID of channel
{timers[channellogoexists]} true if channel logo exists {timers[channellogoexists]} true if channel logo exists
--> -->
<timers> <timers detached="true" delay="100" fadetime="0">
<area x="0" y="75%" width="{areawidth}/8 - 5" height="25%" layer="1"> <area x="0" y="75%" width="{areawidth}/8 - 5" height="25%" layer="1">
<fill color="{clrTransBlack}" /> <fill color="{clrTransBlack}" />
</area> </area>
@ -174,8 +174,8 @@
{discalert} true if disc usage is > 95% {discalert} true if disc usage is > 95%
{vdrusagestring} localized VDR internal usage string {vdrusagestring} localized VDR internal usage string
--> -->
<discusage> <discusage detached="true" delay="100" fadetime="0">
<area x="75%" y="26%" width="25%" height="10%" layer="1"> <area background="true" x="75%" y="26%" width="25%" height="10%" layer="1">
<fill condition="not{discalert}" color="{clrTransBlack}"/> <fill condition="not{discalert}" color="{clrTransBlack}"/>
<fill condition="{discalert}" color="{clrRed}"/> <fill condition="{discalert}" color="{clrRed}"/>
</area> </area>
@ -206,7 +206,7 @@
{pressure} pressure in HPo {pressure} pressure in HPo
{ozone} ozone value in DU {ozone} ozone value in DU
--> -->
<currentweather> <currentweather detached="true" delay="100" fadetime="0">
<area x="75%" y="13%" width="25%" height="10%" layer="2"> <area x="75%" y="13%" width="25%" height="10%" layer="2">
<drawrectangle x="0" y="0" width="53%" height="100%" color="{clrTransBlueLight}" /> <drawrectangle x="0" y="0" width="53%" height="100%" color="{clrTransBlueLight}" />
<drawrectangle x="53%" y="0" width="47%" height="100%" color="{clrTransBlack}" /> <drawrectangle x="53%" y="0" width="47%" height="100%" color="{clrTransBlack}" />
@ -240,8 +240,8 @@
{devices[channelid]} ID of the currently tuned channel {devices[channelid]} ID of the currently tuned channel
{devices[source]} source of the currently tuned channel {devices[source]} source of the currently tuned channel
--> -->
<devices> <devices detached="true" delay="100" fadetime="0">
<area x="75%" y="48%" width="25%" height="{areaheight}/12 * {numdevices}" layer="1"> <area background="true" x="75%" y="48%" width="25%" height="{areaheight}/12 * {numdevices}" layer="1">
<fill color="{clrTransBlack}"/> <fill color="{clrTransBlack}"/>
</area> </area>
<area x="75%" y="48%" width="25%" height="{areaheight}/12 * {numdevices}" layer="2"> <area x="75%" y="48%" width="25%" height="{areaheight}/12 * {numdevices}" layer="2">
@ -261,8 +261,8 @@
<!-- Available Variables systemload: <!-- Available Variables systemload:
{load} current system load {load} current system load
--> -->
<systemload> <systemload detached="true" delay="100" fadetime="0">
<area x="75%" y="40%" width="25%" height="5%" layer="1"> <area background="true" x="75%" y="40%" width="25%" height="5%" layer="1">
<fill color="{clrTransBlack}"/> <fill color="{clrTransBlack}"/>
</area> </area>
<area x="75%" y="40%" width="25%" height="5%" layer="2"> <area x="75%" y="40%" width="25%" height="5%" layer="2">

View File

@ -28,7 +28,7 @@
{timers[channelid]} ChannelID of channel {timers[channelid]} ChannelID of channel
{timers[channellogoexists]} true if channel logo exists {timers[channellogoexists]} true if channel logo exists
--> -->
<timers> <timers detached="true" delay="100" fadetime="0">
<area x="85%" y="28%" width="14%" height="60%" layer="1"> <area x="85%" y="28%" width="14%" height="60%" layer="1">
<drawrectangle condition="gt({numtimers}, 0)" x="0" y="0" width="{areawidth}" height="{areaheight} / 4 * 99 / 100" color="{clrTransBlack}" /> <drawrectangle condition="gt({numtimers}, 0)" x="0" y="0" width="{areawidth}" height="{areaheight} / 4 * 99 / 100" color="{clrTransBlack}" />
<drawrectangle condition="gt({numtimers}, 1)" x="0" y="{areaheight} / 4" width="{areawidth}" height="{areaheight} / 4 * 99 / 100" color="{clrTransBlack}" /> <drawrectangle condition="gt({numtimers}, 1)" x="0" y="{areaheight} / 4" width="{areawidth}" height="{areaheight} / 4 * 99 / 100" color="{clrTransBlack}" />
@ -61,8 +61,8 @@
{discalert} true if disc usage is > 95% {discalert} true if disc usage is > 95%
{vdrusagestring} localized VDR internal usage string {vdrusagestring} localized VDR internal usage string
--> -->
<discusage> <discusage detached="true" delay="100" fadetime="0">
<area x="89%" y="11%" width="10%" height="16%" layer="1"> <area background="true" x="89%" y="11%" width="10%" height="16%" layer="1">
<fill condition="lt({freepercent}, 6)" color="{clrTransRed}" /> <fill condition="lt({freepercent}, 6)" color="{clrTransRed}" />
<fill condition="gt({freepercent}, 5)" color="{clrBackground}" /> <fill condition="gt({freepercent}, 5)" color="{clrBackground}" />
<drawimage imagetype="skinpart" path="discpercent" x="0" y="82%" width="{areawidth}" height="18%"/> <drawimage imagetype="skinpart" path="discpercent" x="0" y="82%" width="{areawidth}" height="18%"/>
@ -75,8 +75,8 @@
</area> </area>
</discusage> </discusage>
<currentweather> <currentweather detached="true" delay="100" fadetime="0">
<area x="63%" y="11%" width="25%" height="16%" layer="1"> <area background="true" x="63%" y="11%" width="25%" height="16%" layer="1">
<fill color="{clrBackground}"/> <fill color="{clrBackground}"/>
</area> </area>
<area x="63%" y="11%" width="25%" height="16%" layer="2"> <area x="63%" y="11%" width="25%" height="16%" layer="2">

View File

@ -2,16 +2,13 @@
#include <vdr/menu.h> #include <vdr/menu.h>
#include "../services/scraper2vdr.h" #include "../services/scraper2vdr.h"
#include "displaychannelview.h" #include "displaychannelview.h"
#include "displaychannelviewelements.h" #include "displayviewelements.h"
#include "../libcore/timers.h" #include "../libcore/timers.h"
#include "../libcore/helpers.h" #include "../libcore/helpers.h"
cDisplayChannelView::cDisplayChannelView(cTemplateView *tmplView) : cView(tmplView) { cDisplayChannelView::cDisplayChannelView(cTemplateView *tmplView) : cView(tmplView) {
lastScreenWidth = 0; lastScreenWidth = 0;
lastScreenHeight = 0; lastScreenHeight = 0;
lastSignalDisplay = 0;
lastSignalStrength = 0;
lastSignalQuality = 0;
lastNumAudioTracks = 0; lastNumAudioTracks = 0;
lastAudioChannel = -1; lastAudioChannel = -1;
lastTracDesc = ""; lastTracDesc = "";
@ -65,15 +62,27 @@ void cDisplayChannelView::DrawDate(void) {
return; return;
} }
map < string, string > stringTokens; if (DetachViewElement(veDateTime)) {
map < string, int > intTokens; cViewElement *viewElement = GetViewElement(veDateTime);
if (!viewElement) {
if (!SetDate(stringTokens, intTokens)) { viewElement = new cViewElementDate(tmplView->GetViewElement(veDateTime));
return; AddViewElement(veDateTime, viewElement);
} viewElement->Start();
} else {
if (!viewElement->Starting())
viewElement->Render();
}
} else {
map < string, string > stringTokens;
map < string, int > intTokens;
if (!SetDate(stringTokens, intTokens)) {
return;
}
ClearViewElement(veDateTime); ClearViewElement(veDateTime);
DrawViewElement(veDateTime, &stringTokens, &intTokens); DrawViewElement(veDateTime, &stringTokens, &intTokens);
}
} }
void cDisplayChannelView::DrawTime(void) { void cDisplayChannelView::DrawTime(void) {
@ -81,14 +90,26 @@ void cDisplayChannelView::DrawTime(void) {
return; return;
} }
map < string, string > stringTokens; if (DetachViewElement(veTime)) {
map < string, int > intTokens; cViewElement *viewElement = GetViewElement(veTime);
if (!viewElement) {
viewElement = new cViewElementTime(tmplView->GetViewElement(veTime));
AddViewElement(veTime, viewElement);
viewElement->Start();
} else {
if (!viewElement->Starting())
viewElement->Render();
}
} else {
map < string, string > stringTokens;
map < string, int > intTokens;
if (!SetTime(stringTokens, intTokens)) { if (!SetTime(stringTokens, intTokens)) {
return; return;
} }
ClearViewElement(veTime); ClearViewElement(veTime);
DrawViewElement(veTime, &stringTokens, &intTokens); DrawViewElement(veTime, &stringTokens, &intTokens);
}
} }
void cDisplayChannelView::DrawProgressBar(cString &start, cString &stop, int Current, int Total) { void cDisplayChannelView::DrawProgressBar(cString &start, cString &stop, int Current, int Total) {
@ -316,72 +337,22 @@ void cDisplayChannelView::DrawScraperContent(const cEvent *event) {
return; return;
} }
static cPlugin *pScraper = GetScraperPlugin(); if (DetachViewElement(veScraperContent)) {
if (!pScraper) { cViewElement *viewElement = GetViewElement(veScraperContent);
return; if (!viewElement) {
} viewElement = new cViewElementScraperContent(event, ctPosterBanner, tmplView->GetViewElement(veScraperContent));
AddViewElement(veScraperContent, viewElement);
ScraperGetPosterBanner call; viewElement->Start();
call.event = event; } else {
if (pScraper->Service("GetPosterBanner", &call)) { if (!viewElement->Starting())
int mediaWidth = 0; viewElement->Render();
int mediaHeight = 0; }
string mediaPath = ""; } else {
bool isBanner = false;
int posterWidth = 0;
int posterHeight = 0;
string posterPath = "";
bool hasPoster = false;
int bannerWidth = 0;
int bannerHeight = 0;
string bannerPath = "";
bool hasBanner = false;
if ((call.type == tSeries) && call.banner.path.size() > 0) {
mediaWidth = call.banner.width;
mediaHeight = call.banner.height;
mediaPath = call.banner.path;
isBanner = true;
bannerWidth = mediaWidth;
bannerHeight = mediaHeight;
bannerPath = mediaPath;
hasBanner = true;
ScraperGetPoster callPoster;
callPoster.event = event;
callPoster.recording = NULL;
if (pScraper->Service("GetPoster", &callPoster)) {
posterWidth = callPoster.poster.width;
posterHeight = callPoster.poster.height;
posterPath = callPoster.poster.path;
hasPoster = true;
}
} else if (call.type == tMovie && call.poster.path.size() > 0 && call.poster.height > 0) {
mediaWidth = call.poster.width;
mediaHeight = call.poster.height;
mediaPath = call.poster.path;
posterWidth = call.poster.width;
posterHeight = call.poster.height;
posterPath = call.poster.path;
hasPoster = true;
} else
return;
map < string, int > intTokens;
map < string, string > stringTokens; map < string, string > stringTokens;
intTokens.insert(pair<string,int>("mediawidth", mediaWidth)); map < string, int > intTokens;
intTokens.insert(pair<string,int>("mediaheight", mediaHeight));
intTokens.insert(pair<string,int>("isbanner", isBanner)); SetPosterBanner(event, stringTokens, intTokens);
stringTokens.insert(pair<string,string>("mediapath", mediaPath)); ClearScraperContent();
intTokens.insert(pair<string,int>("posterwidth", posterWidth));
intTokens.insert(pair<string,int>("posterheight", posterHeight));
stringTokens.insert(pair<string,string>("posterpath", posterPath));
intTokens.insert(pair<string,int>("hasposter", hasPoster));
intTokens.insert(pair<string,int>("bannerwidth", bannerWidth));
intTokens.insert(pair<string,int>("bannerheight", bannerHeight));
stringTokens.insert(pair<string,string>("bannerpath", bannerPath));
intTokens.insert(pair<string,int>("hasbanner", hasBanner));
ClearViewElement(veScraperContent);
DrawViewElement(veScraperContent, &stringTokens, &intTokens); DrawViewElement(veScraperContent, &stringTokens, &intTokens);
} }
} }
@ -395,25 +366,26 @@ void cDisplayChannelView::DrawSignal(void) {
return; return;
} }
time_t Now = time(NULL); if (DetachViewElement(veSignalQuality)) {
if (Now != lastSignalDisplay) { cViewElement *viewElement = GetViewElement(veSignalQuality);
int SignalStrength = cDevice::ActualDevice()->SignalStrength(); if (!viewElement) {
int SignalQuality = cDevice::ActualDevice()->SignalQuality(); viewElement = new cViewElementSignal(tmplView->GetViewElement(veSignalQuality));
if (SignalStrength < 0) SignalStrength = 0; AddViewElement(veSignalQuality, viewElement);
if (SignalQuality < 0) SignalQuality = 0; viewElement->Start();
if ((SignalStrength == 0)&&(SignalQuality==0)) } else {
return; if (!viewElement->Starting())
if ((lastSignalStrength != SignalStrength) || (lastSignalQuality != SignalQuality)) { viewElement->Render();
map < string, int > intTokens;
map < string, string > stringTokens;
intTokens.insert(pair<string,int>("signalstrength", SignalStrength));
intTokens.insert(pair<string,int>("signalquality", SignalQuality));
ClearViewElement(veSignalQuality);
DrawViewElement(veSignalQuality, &stringTokens, &intTokens);
} }
lastSignalStrength = SignalStrength; } else {
lastSignalQuality = SignalQuality; map < string, string > stringTokens;
lastSignalDisplay = Now; map < string, int > intTokens;
bool changed = SetSignal(intTokens);
if (!changed)
return;
ClearSignal();
DrawViewElement(veSignalQuality, &stringTokens, &intTokens);
} }
} }
@ -445,7 +417,8 @@ void cDisplayChannelView::DrawDevices(bool initial) {
AddViewElement(veDevices, viewElement); AddViewElement(veDevices, viewElement);
viewElement->Start(); viewElement->Start();
} else { } else {
viewElement->Render(); if (!viewElement->Starting())
viewElement->Render();
} }
} else { } else {
map < string, string > stringTokens; map < string, string > stringTokens;
@ -459,10 +432,9 @@ void cDisplayChannelView::DrawDevices(bool initial) {
deviceLoopTokens.insert(pair< string, vector< map< string, string > > >("devices", devices)); deviceLoopTokens.insert(pair< string, vector< map< string, string > > >("devices", devices));
ClearViewElement(veDevices); ClearDevices();
DrawViewElement(veDevices, &stringTokens, &intTokens, &deviceLoopTokens); DrawViewElement(veDevices, &stringTokens, &intTokens, &deviceLoopTokens);
} }
} }
void cDisplayChannelView::ClearDevices(void) { void cDisplayChannelView::ClearDevices(void) {
@ -477,8 +449,8 @@ void cDisplayChannelView::DrawChannelGroups(const cChannel *Channel, cString Cha
bool separatorExists = imgCache->SeparatorLogoExists(*ChannelName); bool separatorExists = imgCache->SeparatorLogoExists(*ChannelName);
string separatorPath = separatorExists ? *ChannelName : ""; string separatorPath = separatorExists ? *ChannelName : "";
std::string prevChannelSep = GetChannelSep(Channel, true); string prevChannelSep = GetChannelSep(Channel, true);
std::string nextChannelSep = GetChannelSep(Channel, false); string nextChannelSep = GetChannelSep(Channel, false);
bool prevAvailable = (prevChannelSep.size() > 0)?true:false; bool prevAvailable = (prevChannelSep.size() > 0)?true:false;
bool nextAvailable = (nextChannelSep.size() > 0)?true:false; bool nextAvailable = (nextChannelSep.size() > 0)?true:false;
@ -502,7 +474,7 @@ void cDisplayChannelView::ClearChannelGroups(void) {
} }
string cDisplayChannelView::GetChannelSep(const cChannel *channel, bool prev) { string cDisplayChannelView::GetChannelSep(const cChannel *channel, bool prev) {
std::string sepName = ""; string sepName = "";
const cChannel *sep = prev ? Channels.Prev(channel) : const cChannel *sep = prev ? Channels.Prev(channel) :
Channels.Next(channel); Channels.Next(channel);
for (; sep; (prev)?(sep = Channels.Prev(sep)):(sep = Channels.Next(sep))) { for (; sep; (prev)?(sep = Channels.Prev(sep)):(sep = Channels.Next(sep))) {
@ -540,24 +512,49 @@ void cDisplayChannelView::DrawCustomTokens(void) {
} }
if (!tmplView) if (!tmplView)
return; return;
map < string, string > stringTokens = tmplView->GetCustomStringTokens();
map < string, int > intTokens = tmplView->GetCustomIntTokens(); if (DetachViewElement(veCustomTokens)) {
DrawViewElement(veCustomTokens, &stringTokens, &intTokens); cViewElement *viewElement = GetViewElement(veCustomTokens);
if (!viewElement) {
viewElement = new cViewElementCustomTokens(tmplView->GetViewElement(veCustomTokens), tmplView);
AddViewElement(veCustomTokens, viewElement);
viewElement->Start();
} else {
if (!viewElement->Starting())
viewElement->Render();
}
} else {
map < string, string > stringTokens = tmplView->GetCustomStringTokens();
map < string, int > intTokens = tmplView->GetCustomIntTokens();
DrawViewElement(veCustomTokens, &stringTokens, &intTokens);
}
} }
void cDisplayChannelView::DrawCurrentWeather(void) { void cDisplayChannelView::DrawCurrentWeather(void) {
if (!ExecuteViewElement(veCurrentWeather)) { if (!ExecuteViewElement(veCurrentWeather)) {
return; return;
} }
map < string, string > stringTokens;
map < string, int > intTokens; if (DetachViewElement(veCurrentWeather)) {
if (!SetCurrentWeatherTokens(stringTokens, intTokens)){ cViewElement *viewElement = GetViewElement(veCurrentWeather);
if (!viewElement) {
viewElement = new cViewElementWeather(tmplView->GetViewElement(veCurrentWeather));
AddViewElement(veCurrentWeather, viewElement);
viewElement->Start();
} else {
if (!viewElement->Starting())
viewElement->Render();
}
} else {
map < string, string > stringTokens;
map < string, int > intTokens;
if (!SetCurrentWeatherTokens(stringTokens, intTokens)){
ClearViewElement(veCurrentWeather);
return;
}
ClearViewElement(veCurrentWeather); ClearViewElement(veCurrentWeather);
return; DrawViewElement(veCurrentWeather, &stringTokens, &intTokens);
} }
ClearViewElement(veCurrentWeather);
DrawViewElement(veCurrentWeather, &stringTokens, &intTokens);
} }

View File

@ -9,9 +9,6 @@ class cDisplayChannelView : public cView, public cViewHelpers {
private: private:
int lastScreenWidth; int lastScreenWidth;
int lastScreenHeight; int lastScreenHeight;
int lastSignalDisplay;
int lastSignalStrength;
int lastSignalQuality;
int lastNumAudioTracks; int lastNumAudioTracks;
int lastAudioChannel; int lastAudioChannel;
string lastTracDesc; string lastTracDesc;

View File

@ -1,23 +0,0 @@
#include "displaychannelviewelements.h"
cViewElementDevices::cViewElementDevices(cTemplateViewElement *tmplViewElement) : cViewElement(tmplViewElement) {
init = true;
}
void cViewElementDevices::Render(void) {
map < string, vector< map< string, string > > > deviceLoopTokens;
vector< map< string, string > > devices;
if (init)
InitDevices();
bool changed = SetDevices(init, &intTokens, &devices);
init = false;
if (!changed)
return;
deviceLoopTokens.insert(pair< string, vector< map< string, string > > >("devices", devices));
Clear();
Draw(&deviceLoopTokens);
}

View File

@ -1,17 +0,0 @@
#ifndef __DISPLAYCHANNELVIEWELEMENTS_H
#define __DISPLAYCHANNELVIEWELEMENTS_H
#include "../libtemplate/template.h"
#include "view.h"
#include "viewhelpers.h"
class cViewElementDevices : public cViewElement, public cViewHelpers {
private:
bool init;
public:
cViewElementDevices(cTemplateViewElement *tmplViewElement);
virtual ~cViewElementDevices() {};
void Render(void);
};
#endif //__DISPLAYCHANNELVIEWELEMENTS_H

View File

@ -62,12 +62,13 @@ cDisplayMenuItemCurrentMainView::cDisplayMenuItemCurrentMainView(cTemplateViewEl
this->icon = icon; this->icon = icon;
} }
void cDisplayMenuItemCurrentMainView::Render(void) { bool cDisplayMenuItemCurrentMainView::Render(void) {
stringTokens.insert(pair<string,string>("number", number)); stringTokens.insert(pair<string,string>("number", number));
stringTokens.insert(pair<string,string>("label", label)); stringTokens.insert(pair<string,string>("label", label));
stringTokens.insert(pair<string,string>("icon", icon)); stringTokens.insert(pair<string,string>("icon", icon));
SetTokensPosMenuItem(); SetTokensPosMenuItem();
DrawViewElement(veMenuCurrentItemDetail, &stringTokens, &intTokens); DrawViewElement(veMenuCurrentItemDetail, &stringTokens, &intTokens);
return true;
} }
/************************************************************* /*************************************************************
@ -83,7 +84,7 @@ cDisplayMenuItemCurrentSchedulesView::cDisplayMenuItemCurrentSchedulesView(cTemp
this->isEpgSearchFav = isEpgSearchFav; this->isEpgSearchFav = isEpgSearchFav;
} }
void cDisplayMenuItemCurrentSchedulesView::Render(void) { bool cDisplayMenuItemCurrentSchedulesView::Render(void) {
intTokens.insert(pair<string,int>("whatson", (cat == mcSchedule)&&(!isEpgSearchFav) ? true: false)); intTokens.insert(pair<string,int>("whatson", (cat == mcSchedule)&&(!isEpgSearchFav) ? true: false));
intTokens.insert(pair<string,int>("whatsonnow", (cat == mcScheduleNow) ? true: false)); intTokens.insert(pair<string,int>("whatsonnow", (cat == mcScheduleNow) ? true: false));
intTokens.insert(pair<string,int>("whatsonnext", (cat == mcScheduleNext) ? true: false)); intTokens.insert(pair<string,int>("whatsonnext", (cat == mcScheduleNext) ? true: false));
@ -145,6 +146,7 @@ void cDisplayMenuItemCurrentSchedulesView::Render(void) {
loopTokens.insert(pair<string, vector< map< string, string > > >("schedule", schedulesTokens)); loopTokens.insert(pair<string, vector< map< string, string > > >("schedule", schedulesTokens));
SetTokensPosMenuItem(); SetTokensPosMenuItem();
DrawViewElement(veMenuCurrentItemDetail, &stringTokens, &intTokens, &loopTokens); DrawViewElement(veMenuCurrentItemDetail, &stringTokens, &intTokens, &loopTokens);
return true;
} }
void cDisplayMenuItemCurrentSchedulesView::ReadSchedules(vector< map<string,string> > *schedulesTokens) { void cDisplayMenuItemCurrentSchedulesView::ReadSchedules(vector< map<string,string> > *schedulesTokens) {
@ -179,9 +181,9 @@ cDisplayMenuItemCurrentChannelView::cDisplayMenuItemCurrentChannelView(cTemplate
this->channel = channel; this->channel = channel;
} }
void cDisplayMenuItemCurrentChannelView::Render(void) { bool cDisplayMenuItemCurrentChannelView::Render(void) {
if (!channel) if (!channel)
return; return false;
//general channel information //general channel information
intTokens.insert(pair<string,int>("number", channel->Number())); intTokens.insert(pair<string,int>("number", channel->Number()));
intTokens.insert(pair<string,int>("transponder", channel->Transponder())); intTokens.insert(pair<string,int>("transponder", channel->Transponder()));
@ -276,6 +278,7 @@ void cDisplayMenuItemCurrentChannelView::Render(void) {
loopTokens.insert(pair<string, vector< map< string, string > > >("schedule", schedulesTokens)); loopTokens.insert(pair<string, vector< map< string, string > > >("schedule", schedulesTokens));
SetTokensPosMenuItem(); SetTokensPosMenuItem();
DrawViewElement(veMenuCurrentItemDetail, &stringTokens, &intTokens, &loopTokens); DrawViewElement(veMenuCurrentItemDetail, &stringTokens, &intTokens, &loopTokens);
return true;
} }
void cDisplayMenuItemCurrentChannelView::ReadSchedules(vector< map<string,string> > *schedulesTokens) { void cDisplayMenuItemCurrentChannelView::ReadSchedules(vector< map<string,string> > *schedulesTokens) {
@ -314,9 +317,9 @@ cDisplayMenuItemCurrentTimerView::cDisplayMenuItemCurrentTimerView(cTemplateView
this->timer = timer; this->timer = timer;
} }
void cDisplayMenuItemCurrentTimerView::Render(void) { bool cDisplayMenuItemCurrentTimerView::Render(void) {
if (!timer) if (!timer)
return; return false;
intTokens.insert(pair<string,int>("flagactive", timer->HasFlags(tfActive))); intTokens.insert(pair<string,int>("flagactive", timer->HasFlags(tfActive)));
intTokens.insert(pair<string,int>("flaginstant", timer->HasFlags(tfInstant))); intTokens.insert(pair<string,int>("flaginstant", timer->HasFlags(tfInstant)));
intTokens.insert(pair<string,int>("flagvps", timer->HasFlags(tfVps))); intTokens.insert(pair<string,int>("flagvps", timer->HasFlags(tfVps)));
@ -398,6 +401,7 @@ void cDisplayMenuItemCurrentTimerView::Render(void) {
} }
SetTokensPosMenuItem(); SetTokensPosMenuItem();
DrawViewElement(veMenuCurrentItemDetail, &stringTokens, &intTokens); DrawViewElement(veMenuCurrentItemDetail, &stringTokens, &intTokens);
return true;
} }
/************************************************************* /*************************************************************
@ -412,9 +416,9 @@ cDisplayMenuItemCurrentRecordingView::cDisplayMenuItemCurrentRecordingView(cTemp
this->newRecs = newRecs; this->newRecs = newRecs;
} }
void cDisplayMenuItemCurrentRecordingView::Render(void) { bool cDisplayMenuItemCurrentRecordingView::Render(void) {
if (!recording) if (!recording)
return; return false;
map < string, vector< map< string, string > > > loopTokens; map < string, vector< map< string, string > > > loopTokens;
bool isFolder = (total > 0) ? true : false; bool isFolder = (total > 0) ? true : false;
@ -468,7 +472,7 @@ void cDisplayMenuItemCurrentRecordingView::Render(void) {
const cRecordingInfo *info = usedRecording->Info(); const cRecordingInfo *info = usedRecording->Info();
if (!info) return; if (!info) return true;
bool extRecinfoAvailable = false; bool extRecinfoAvailable = false;
if (info->Aux()) { if (info->Aux()) {
@ -509,7 +513,7 @@ void cDisplayMenuItemCurrentRecordingView::Render(void) {
stringTokens.insert(pair<string,string>("description", info->Description() ? info->Description() : "")); stringTokens.insert(pair<string,string>("description", info->Description() ? info->Description() : ""));
const cEvent *event = info->GetEvent(); const cEvent *event = info->GetEvent();
if (!event) return; if (!event) return true;
string recDate = *(event->GetDateString()); string recDate = *(event->GetDateString());
string recTime = *(event->GetTimeString()); string recTime = *(event->GetTimeString());
@ -538,6 +542,7 @@ void cDisplayMenuItemCurrentRecordingView::Render(void) {
stringTokens.insert(pair<string,string>("durationeventminutes", *cString::sprintf("%.2d", duration%60))); stringTokens.insert(pair<string,string>("durationeventminutes", *cString::sprintf("%.2d", duration%60)));
SetTokensPosMenuItem(); SetTokensPosMenuItem();
DrawViewElement(veMenuCurrentItemDetail, &stringTokens, &intTokens, &loopTokens); DrawViewElement(veMenuCurrentItemDetail, &stringTokens, &intTokens, &loopTokens);
return true;
} }
/************************************************************* /*************************************************************
@ -553,7 +558,8 @@ cDisplayMenuItemCurrentPluginView::cDisplayMenuItemCurrentPluginView(cTemplateVi
loopTokens = pluginLoopTokens; loopTokens = pluginLoopTokens;
} }
void cDisplayMenuItemCurrentPluginView::Render(void) { bool cDisplayMenuItemCurrentPluginView::Render(void) {
SetTokensPosMenuItem(); SetTokensPosMenuItem();
DrawViewElement(veMenuCurrentItemDetail, &stringTokens, &intTokens, &loopTokens); DrawViewElement(veMenuCurrentItemDetail, &stringTokens, &intTokens, &loopTokens);
return true;
} }

View File

@ -24,7 +24,7 @@ private:
public: public:
cDisplayMenuItemCurrentMainView(cTemplateViewElement *tmplCurrent, string number, string label, string icon); cDisplayMenuItemCurrentMainView(cTemplateViewElement *tmplCurrent, string number, string label, string icon);
virtual ~cDisplayMenuItemCurrentMainView() {}; virtual ~cDisplayMenuItemCurrentMainView() {};
void Render(void); bool Render(void);
}; };
class cDisplayMenuItemCurrentSchedulesView: public cDisplayMenuItemCurrentView { class cDisplayMenuItemCurrentSchedulesView: public cDisplayMenuItemCurrentView {
@ -38,7 +38,7 @@ private:
public: public:
cDisplayMenuItemCurrentSchedulesView(cTemplateViewElement *tmplCurrent, const cEvent *event, const cChannel *channel, eTimerMatch timerMatch, eMenuCategory cat, bool isEpgSearchFav); cDisplayMenuItemCurrentSchedulesView(cTemplateViewElement *tmplCurrent, const cEvent *event, const cChannel *channel, eTimerMatch timerMatch, eMenuCategory cat, bool isEpgSearchFav);
virtual ~cDisplayMenuItemCurrentSchedulesView() {}; virtual ~cDisplayMenuItemCurrentSchedulesView() {};
void Render(void); bool Render(void);
}; };
class cDisplayMenuItemCurrentChannelView: public cDisplayMenuItemCurrentView { class cDisplayMenuItemCurrentChannelView: public cDisplayMenuItemCurrentView {
@ -48,7 +48,7 @@ private:
public: public:
cDisplayMenuItemCurrentChannelView(cTemplateViewElement *tmplCurrent, const cChannel *channel); cDisplayMenuItemCurrentChannelView(cTemplateViewElement *tmplCurrent, const cChannel *channel);
virtual ~cDisplayMenuItemCurrentChannelView() {}; virtual ~cDisplayMenuItemCurrentChannelView() {};
void Render(void); bool Render(void);
}; };
class cDisplayMenuItemCurrentTimerView: public cDisplayMenuItemCurrentView { class cDisplayMenuItemCurrentTimerView: public cDisplayMenuItemCurrentView {
@ -57,7 +57,7 @@ private:
public: public:
cDisplayMenuItemCurrentTimerView(cTemplateViewElement *tmplCurrent, const cTimer *timer); cDisplayMenuItemCurrentTimerView(cTemplateViewElement *tmplCurrent, const cTimer *timer);
virtual ~cDisplayMenuItemCurrentTimerView() {}; virtual ~cDisplayMenuItemCurrentTimerView() {};
void Render(void); bool Render(void);
}; };
class cDisplayMenuItemCurrentRecordingView: public cDisplayMenuItemCurrentView { class cDisplayMenuItemCurrentRecordingView: public cDisplayMenuItemCurrentView {
@ -69,7 +69,7 @@ private:
public: public:
cDisplayMenuItemCurrentRecordingView(cTemplateViewElement *tmplCurrent, const cRecording *recording, int level, int total, int newRecs); cDisplayMenuItemCurrentRecordingView(cTemplateViewElement *tmplCurrent, const cRecording *recording, int level, int total, int newRecs);
virtual ~cDisplayMenuItemCurrentRecordingView() {}; virtual ~cDisplayMenuItemCurrentRecordingView() {};
void Render(void); bool Render(void);
}; };
class cDisplayMenuItemCurrentPluginView: public cDisplayMenuItemCurrentView { class cDisplayMenuItemCurrentPluginView: public cDisplayMenuItemCurrentView {
@ -78,7 +78,7 @@ private:
public: public:
cDisplayMenuItemCurrentPluginView(cTemplateViewElement *tmplCurrent, map <string,string> &plugStringTokens, map <string,int> &plugIntTokens, map<string,vector<map<string,string> > > &pluginLoopTokens); cDisplayMenuItemCurrentPluginView(cTemplateViewElement *tmplCurrent, map <string,string> &plugStringTokens, map <string,int> &plugIntTokens, map<string,vector<map<string,string> > > &pluginLoopTokens);
virtual ~cDisplayMenuItemCurrentPluginView() {}; virtual ~cDisplayMenuItemCurrentPluginView() {};
void Render(void); bool Render(void);
}; };
#endif //__DISPLAYMENUITEMCURRENTVIEW_H #endif //__DISPLAYMENUITEMCURRENTVIEW_H

View File

@ -1,12 +1,13 @@
#define __STL_CONFIG_H #define __STL_CONFIG_H
#include <vdr/menu.h> #include <vdr/menu.h>
#include <vdr/videodir.h>
#include "displaymenurootview.h" #include "displaymenurootview.h"
#include "displayviewelements.h"
#include "../config.h" #include "../config.h"
#include "../libcore/helpers.h" #include "../libcore/helpers.h"
cDisplayMenuRootView::cDisplayMenuRootView(cTemplateView *rootView) : cView(rootView) { cDisplayMenuRootView::cDisplayMenuRootView(cTemplateView *rootView) : cView(rootView) {
cat = mcUndefined; cat = mcUndefined;
menuTitle = "";
viewType = svUndefined; viewType = svUndefined;
subView = NULL; subView = NULL;
subViewAvailable = false; subViewAvailable = false;
@ -479,37 +480,9 @@ void cDisplayMenuRootView::DrawHeader(void) {
if (!ExecuteViewElement(veHeader)) { if (!ExecuteViewElement(veHeader)) {
return; return;
} }
map < string, string > stringTokens; map < string, string > stringTokens;
map < string, int > intTokens; map < string, int > intTokens;
SetMenuHeader(cat, menuTitle, stringTokens, intTokens);
stringTokens.insert(pair<string,string>("title", menuTitle));
stringTokens.insert(pair<string,string>("vdrversion", VDRVERSION));
//check for standard menu entries
bool hasIcon = false;
string icon = imgCache->GetIconName(menuTitle, cat);
if (imgCache->MenuIconExists(icon))
hasIcon = true;
stringTokens.insert(pair<string,string>("icon", icon));
intTokens.insert(pair<string,int>("hasicon", hasIcon));
//Disc Usage
string vdrUsageString = *cVideoDiskUsage::String();
int discUsage = cVideoDiskUsage::UsedPercent();
bool discAlert = (discUsage > 95) ? true : false;
string freeTime = *cString::sprintf("%02d:%02d", cVideoDiskUsage::FreeMinutes() / 60, cVideoDiskUsage::FreeMinutes() % 60);
int freeGB = cVideoDiskUsage::FreeMB() / 1024;
intTokens.insert(pair<string, int>("usedpercent", discUsage));
intTokens.insert(pair<string, int>("freepercent", 100-discUsage));
intTokens.insert(pair<string, int>("discalert", discAlert));
intTokens.insert(pair<string, int>("freegb", freeGB));
stringTokens.insert(pair<string,string>("freetime", freeTime));
stringTokens.insert(pair<string,string>("vdrusagestring", vdrUsageString));
ClearViewElement(veHeader); ClearViewElement(veHeader);
DrawViewElement(veHeader, &stringTokens, &intTokens); DrawViewElement(veHeader, &stringTokens, &intTokens);
} }

View File

@ -1,13 +1,10 @@
#define __STL_CONFIG_H #define __STL_CONFIG_H
#include <fstream>
#include <iostream>
#include <sys/sysinfo.h>
#include <vdr/menu.h> #include <vdr/menu.h>
#include <vdr/videodir.h> #include <vdr/videodir.h>
#include "displaymenuview.h" #include "displaymenuview.h"
#include "displayviewelements.h"
#include "../config.h" #include "../config.h"
#include "../libcore/helpers.h" #include "../libcore/helpers.h"
#include "../libcore/timers.h"
#include "../services/scraper2vdr.h" #include "../services/scraper2vdr.h"
cDisplayMenuView::cDisplayMenuView(cTemplateView *tmplView, bool menuInit) : cView(tmplView) { cDisplayMenuView::cDisplayMenuView(cTemplateView *tmplView, bool menuInit) : cView(tmplView) {
@ -39,35 +36,9 @@ bool cDisplayMenuView::DrawHeader(void) {
if (!ExecuteViewElement(veHeader)) { if (!ExecuteViewElement(veHeader)) {
return false; return false;
} }
map < string, string > stringTokens; map < string, string > stringTokens;
map < string, int > intTokens; map < string, int > intTokens;
SetMenuHeader(cat, menuTitle, stringTokens, intTokens);
stringTokens.insert(pair<string,string>("title", menuTitle));
stringTokens.insert(pair<string,string>("vdrversion", VDRVERSION));
//check for standard menu entries
bool hasIcon = false;
string icon = imgCache->GetIconName(menuTitle, cat);
if (imgCache->MenuIconExists(icon))
hasIcon = true;
stringTokens.insert(pair<string,string>("icon", icon));
intTokens.insert(pair<string,int>("hasicon", hasIcon));
//Disc Usage
string vdrUsageString = *cVideoDiskUsage::String();
int discUsage = cVideoDiskUsage::UsedPercent();
bool discAlert = (discUsage > 95) ? true : false;
string freeTime = *cString::sprintf("%02d:%02d", cVideoDiskUsage::FreeMinutes() / 60, cVideoDiskUsage::FreeMinutes() % 60);
int freeGB = cVideoDiskUsage::FreeMB() / 1024;
intTokens.insert(pair<string, int>("usedpercent", discUsage));
intTokens.insert(pair<string, int>("freepercent", 100-discUsage));
intTokens.insert(pair<string, int>("discalert", discAlert));
intTokens.insert(pair<string, int>("freegb", freeGB));
stringTokens.insert(pair<string,string>("freetime", freeTime));
stringTokens.insert(pair<string,string>("vdrusagestring", vdrUsageString));
ClearViewElement(veHeader); ClearViewElement(veHeader);
DrawViewElement(veHeader, &stringTokens, &intTokens); DrawViewElement(veHeader, &stringTokens, &intTokens);
return true; return true;
@ -224,8 +195,6 @@ void cDisplayMenuView::Action(void) {
cDisplayMenuMainView::cDisplayMenuMainView(cTemplateView *tmplView, bool menuInit) : cDisplayMenuView(tmplView, menuInit) { cDisplayMenuMainView::cDisplayMenuMainView(cTemplateView *tmplView, bool menuInit) : cDisplayMenuView(tmplView, menuInit) {
initial = true; initial = true;
lastSystemLoad = 0.0;
lastMemUsage = -1;
InitDevices(); InitDevices();
} }
@ -256,382 +225,215 @@ void cDisplayMenuMainView::DrawTimers(void) {
if (!ExecuteViewElement(veTimers)) { if (!ExecuteViewElement(veTimers)) {
return; return;
} }
if (DetachViewElement(veTimers)) {
map < string, string > stringTokens; cViewElement *viewElement = GetViewElement(veTimers);
map < string, int > intTokens; if (!viewElement) {
viewElement = new cViewElementTimers(tmplView->GetViewElement(veTimers));
map < string, vector< map< string, string > > > timerLoopTokens; AddViewElement(veTimers, viewElement);
vector< map< string, string > > timers; viewElement->Start();
cGlobalSortedTimers SortedTimers;// local and remote timers
int numTimers = SortedTimers.Size();
intTokens.insert(pair<string, int>("numtimers", numTimers));
int numTimerConflicts = SortedTimers.NumTimerConfilicts();
intTokens.insert(pair<string, int>("numtimerconflicts", numTimerConflicts));
for (int i=0; i<15; i++) {
stringstream name;
name << "timer" << i+1 << "exists";
if (i < numTimers) {
intTokens.insert(pair<string, int>(name.str(), true));
} else { } else {
intTokens.insert(pair<string, int>(name.str(), false)); if (!viewElement->Starting())
viewElement->Render();
} }
} } else {
map < string, string > stringTokens;
map < string, int > intTokens;
map < string, vector< map< string, string > > > timerLoopTokens;
vector< map< string, string > > timers;
for (int i = 0; i < numTimers; i++) { SetTimers(&intTokens, &stringTokens, &timers);
if (i >=15)
break;
map< string, string > timerVals;
const cTimer *Timer = SortedTimers[i];
const cEvent *event = Timer->Event();
if (event) {
timerVals.insert(pair< string, string >("timers[title]", event->Title()));
} else {
const char *File = Setup.FoldersInTimerMenu ? NULL : strrchr(Timer->File(), FOLDERDELIMCHAR);
if (File && strcmp(File + 1, TIMERMACRO_TITLE) && strcmp(File + 1, TIMERMACRO_EPISODE))
File++;
else
File = Timer->File();
timerVals.insert(pair< string, string >("timers[title]", File));
}
const cChannel *channel = Timer->Channel();
if (channel) {
timerVals.insert(pair< string, string >("timers[channelname]", channel->Name()));
stringstream chanNum;
chanNum << channel->Number();
timerVals.insert(pair< string, string >("timers[channelnumber]", chanNum.str()));
string channelID = *(channel->GetChannelID().ToString());
timerVals.insert(pair< string, string >("timers[channelid]", channelID));
bool logoExists = imgCache->LogoExists(channelID);
timerVals.insert(pair< string, string >("timers[channellogoexists]", logoExists ? "1" : "0"));
} else {
timerVals.insert(pair< string, string >("timers[channelname]", ""));
timerVals.insert(pair< string, string >("timers[channelnumber]", "0"));
timerVals.insert(pair< string, string >("timers[channelid]", ""));
timerVals.insert(pair< string, string >("timers[channellogoexists]", "0"));
}
timerVals.insert(pair< string, string >("timers[recording]", Timer->Recording() ? "1" : "0"));
cString timerDate(""); timerLoopTokens.insert(pair< string, vector< map< string, string > > >("timers", timers));
if (Timer->Recording()) {
timerDate = cString::sprintf("-%s", *TimeString(Timer->StopTime()));
} else {
time_t Now = time(NULL);
cString Today = WeekDayName(Now);
cString Time = TimeString(Timer->StartTime());
cString Day = WeekDayName(Timer->StartTime());
if (Timer->StartTime() > Now + 6 * SECSINDAY) {
time_t ttm = Timer->StartTime();
struct tm * timerTime = localtime(&ttm);
timerDate = cString::sprintf("%02d.%02d %s", timerTime->tm_mday, timerTime->tm_mon + 1, *Time);
} else if (strcmp(Day, Today) != 0)
timerDate = cString::sprintf("%s %s", *Day, *Time);
else
timerDate = Time;
if (Timer->Flags() & tfVps)
timerDate = cString::sprintf("VPS %s", *timerDate);
}
timerVals.insert(pair< string, string >("timers[datetime]", *timerDate));
timers.push_back(timerVals); ClearViewElement(veTimers);
} DrawViewElement(veTimers, &stringTokens, &intTokens, &timerLoopTokens);
}
timerLoopTokens.insert(pair< string, vector< map< string, string > > >("timers", timers));
ClearViewElement(veTimers);
DrawViewElement(veTimers, &stringTokens, &intTokens, &timerLoopTokens);
} }
void cDisplayMenuMainView::DrawDiscUsage(void) { void cDisplayMenuMainView::DrawDiscUsage(void) {
if (!ExecuteViewElement(veDiscUsage)) { if (!ExecuteViewElement(veDiscUsage)) {
return; return;
} }
if (DetachViewElement(veDiscUsage)) {
map < string, string > stringTokens; cViewElement *viewElement = GetViewElement(veDiscUsage);
map < string, int > intTokens; if (!viewElement) {
viewElement = new cViewElementDiscUsage(tmplView->GetViewElement(veDiscUsage));
string vdrUsageString = *cVideoDiskUsage::String(); AddViewElement(veDiscUsage, viewElement);
int discUsage = cVideoDiskUsage::UsedPercent(); viewElement->Start();
bool discAlert = (discUsage > 95) ? true : false; } else {
string freeTime = *cString::sprintf("%02d:%02d", cVideoDiskUsage::FreeMinutes() / 60, cVideoDiskUsage::FreeMinutes() % 60); if (!viewElement->Starting())
int freeGB = cVideoDiskUsage::FreeMB() / 1024; viewElement->Render();
}
intTokens.insert(pair<string, int>("usedpercent", discUsage)); } else {
intTokens.insert(pair<string, int>("freepercent", 100-discUsage)); map < string, string > stringTokens;
intTokens.insert(pair<string, int>("discalert", discAlert)); map < string, int > intTokens;
intTokens.insert(pair<string, int>("freegb", freeGB)); SetDiscUsage(stringTokens, intTokens);
stringTokens.insert(pair<string,string>("freetime", freeTime)); ClearViewElement(veDiscUsage);
stringTokens.insert(pair<string,string>("vdrusagestring", vdrUsageString)); DrawViewElement(veDiscUsage, &stringTokens, &intTokens);
}
ClearViewElement(veDiscUsage);
DrawViewElement(veDiscUsage, &stringTokens, &intTokens);
} }
bool cDisplayMenuMainView::DrawLoad(void) { bool cDisplayMenuMainView::DrawLoad(void) {
if (!ExecuteViewElement(veSystemLoad)) { if (!ExecuteViewElement(veSystemLoad)) {
return false; return false;
} }
bool changed = false;
map < string, string > stringTokens; if (DetachViewElement(veSystemLoad)) {
map < string, int > intTokens; cViewElement *viewElement = GetViewElement(veSystemLoad);
if (!viewElement) {
double systemLoad; viewElement = new cViewElementSystemLoad(tmplView->GetViewElement(veSystemLoad));
if (getloadavg(&systemLoad, 1) > 0) { AddViewElement(veSystemLoad, viewElement);
if (lastSystemLoad == systemLoad) { viewElement->Start();
return false; changed = true;
} else {
if (!viewElement->Starting())
changed = viewElement->Render();
} }
string load = *cString::sprintf("%.2f", systemLoad); } else {
int loadHand = systemLoad * 1000; map < string, string > stringTokens;
int loadHandValue = 0; map < string, int > intTokens;
if (loadHand > 2500) changed = SetSystemLoad(stringTokens, intTokens);
loadHandValue = 2525; if (changed) {
else { ClearViewElement(veSystemLoad);
DrawViewElement(veSystemLoad, &stringTokens, &intTokens);
int loadHandDec = loadHand - (loadHand / 100) * 100;
if (loadHandDec <= 12)
loadHandDec = 0;
else if (loadHandDec <= 37)
loadHandDec = 25;
else if (loadHandDec <= 62)
loadHandDec = 50;
else if (loadHandDec <= 87)
loadHandDec = 75;
else
loadHandDec = 0;
loadHandValue = loadHand / 100 * 100 + loadHandDec;
} }
stringTokens.insert(pair<string,string>("load", load));
intTokens.insert(pair<string,int>("loadhand", loadHandValue));
lastSystemLoad = systemLoad;
} }
return changed;
ClearViewElement(veSystemLoad);
DrawViewElement(veSystemLoad, &stringTokens, &intTokens);
return true;
} }
bool cDisplayMenuMainView::DrawMemory(void) { bool cDisplayMenuMainView::DrawMemory(void) {
if (!ExecuteViewElement(veSystemMemory)) { if (!ExecuteViewElement(veSystemMemory)) {
return false; return false;
} }
struct sysinfo memInfo; bool changed = false;
sysinfo (&memInfo); if (DetachViewElement(veSystemMemory)) {
cViewElement *viewElement = GetViewElement(veSystemMemory);
long long totalMem = memInfo.totalram; if (!viewElement) {
totalMem += memInfo.totalswap; viewElement = new cViewElementSystemMemory(tmplView->GetViewElement(veSystemMemory));
totalMem *= memInfo.mem_unit; AddViewElement(veSystemMemory, viewElement);
int totalMemMB = totalMem / 1024 / 1024; viewElement->Start();
changed = true;
long long usedMem = memInfo.totalram - memInfo.freeram; } else {
usedMem += memInfo.totalswap - memInfo.freeswap; if (!viewElement->Starting())
usedMem *= memInfo.mem_unit; changed = viewElement->Render();
int usedMemMB = usedMem / 1024 / 1024; }
} else {
if (lastMemUsage == usedMemMB) { map < string, string > stringTokens;
return false; map < string, int > intTokens;
changed = SetSystemMemory(stringTokens, intTokens);
if (changed) {
ClearViewElement(veSystemMemory);
DrawViewElement(veSystemMemory, &stringTokens, &intTokens);
}
} }
lastMemUsage = usedMemMB; return changed;
map < string, string > stringTokens;
map < string, int > intTokens;
intTokens.insert(pair<string,int>("totalmem", totalMemMB));
intTokens.insert(pair<string,int>("usedmem", usedMemMB));
if (totalMemMB > 0)
intTokens.insert(pair<string,int>("usedmempercent", usedMemMB * 100 / totalMemMB));
ClearViewElement(veSystemMemory);
DrawViewElement(veSystemMemory, &stringTokens, &intTokens);
return true;
} }
void cDisplayMenuMainView::DrawTemperatures(void) { void cDisplayMenuMainView::DrawTemperatures(void) {
if (!ExecuteViewElement(veTemperatures)) { if (!ExecuteViewElement(veTemperatures)) {
return; return;
} }
cString execCommand = cString::sprintf("cd \"%s/\"; \"%s/temperatures\"", SCRIPTFOLDER, SCRIPTFOLDER); if (DetachViewElement(veTemperatures)) {
system(*execCommand); cViewElement *viewElement = GetViewElement(veTemperatures);
if (!viewElement) {
string tempCPU, tempGPU; viewElement = new cViewElementTemperature(tmplView->GetViewElement(veTemperatures));
int cpu, gpu; AddViewElement(veTemperatures, viewElement);
viewElement->Start();
cString itemFilename = cString::sprintf("%s/cpu", SCRIPTOUTPUTPATH ); } else {
ifstream file(*itemFilename, ifstream::in); if (!viewElement->Starting())
if( file.is_open() ) { viewElement->Render();
std::getline(file, tempCPU); }
if (tempCPU.size() > 2) {
cpu = atoi(tempCPU.substr(0,2).c_str());
} else
cpu = 0;
file.close();
} else { } else {
tempCPU = "0°C"; map < string, string > stringTokens;
cpu = 0; map < string, int > intTokens;
bool changed = SetSystemTemperatures(stringTokens, intTokens);
if (changed) {
ClearViewElement(veTemperatures);
DrawViewElement(veTemperatures, &stringTokens, &intTokens);
}
} }
itemFilename = cString::sprintf("%s/gpu", SCRIPTOUTPUTPATH );
ifstream file2(*itemFilename, ifstream::in);
if( file2.is_open() ) {
std::getline(file2, tempGPU);
if (tempGPU.size() > 2) {
gpu = atoi(tempGPU.substr(0,2).c_str());
} else
gpu = 0;
file2.close();
} else {
tempGPU = "0°C";
gpu = 0;
}
map < string, string > stringTokens;
map < string, int > intTokens;
intTokens.insert(pair<string,int>("cputemp", cpu));
intTokens.insert(pair<string,int>("gputemp", gpu));
ClearViewElement(veTemperatures);
DrawViewElement(veTemperatures, &stringTokens, &intTokens);
} }
bool cDisplayMenuMainView::DrawDevices(void) { bool cDisplayMenuMainView::DrawDevices(void) {
if (!ExecuteViewElement(veDevices)) { if (!ExecuteViewElement(veDevices)) {
return false; return false;
} }
bool changed = false;
if (DetachViewElement(veDevices)) {
cViewElement *viewElement = GetViewElement(veDevices);
if (!viewElement) {
viewElement = new cViewElementDevices(tmplView->GetViewElement(veDevices));
AddViewElement(veDevices, viewElement);
viewElement->Start();
changed = true;
} else {
if (!viewElement->Starting())
changed = viewElement->Render();
}
} else {
map < string, string > stringTokens;
map < string, int > intTokens;
map < string, vector< map< string, string > > > deviceLoopTokens;
vector< map< string, string > > devices;
map < string, string > stringTokens; changed = SetDevices(initial, &intTokens, &devices);
map < string, int > intTokens; if (!changed)
map < string, vector< map< string, string > > > deviceLoopTokens; return false;
vector< map< string, string > > devices;
bool changed = SetDevices(initial, &intTokens, &devices); deviceLoopTokens.insert(pair< string, vector< map< string, string > > >("devices", devices));
if (!changed) ClearViewElement(veDevices);
return false; DrawViewElement(veDevices, &stringTokens, &intTokens, &deviceLoopTokens);
}
deviceLoopTokens.insert(pair< string, vector< map< string, string > > >("devices", devices)); return changed;
ClearViewElement(veDevices);
DrawViewElement(veDevices, &stringTokens, &intTokens, &deviceLoopTokens);
return true;
} }
void cDisplayMenuMainView::DrawCurrentSchedule(void) { void cDisplayMenuMainView::DrawCurrentSchedule(void) {
if (!ExecuteViewElement(veCurrentSchedule)) { if (!ExecuteViewElement(veCurrentSchedule)) {
return; return;
} }
if (DetachViewElement(veCurrentSchedule)) {
cDevice *device = cDevice::PrimaryDevice(); cViewElement *viewElement = GetViewElement(veCurrentSchedule);
const cChannel *channel = NULL; if (!viewElement) {
if (!device->Replaying() || device->Transferring()) { viewElement = new cViewElementCurrentSchedule(tmplView->GetViewElement(veCurrentSchedule));
channel = Channels.GetByNumber(device->CurrentChannel()); AddViewElement(veCurrentSchedule, viewElement);
} viewElement->Start();
if (!channel) } else {
return; if (!viewElement->Starting())
viewElement->Render();
const cEvent *event = NULL;
cSchedulesLock SchedulesLock;
if (const cSchedules *Schedules = cSchedules::Schedules(SchedulesLock))
if (const cSchedule *Schedule = Schedules->GetSchedule(channel))
event = Schedule->GetPresentEvent();
if (!event)
return;
map < string, string > stringTokens;
map < string, int > intTokens;
stringTokens.insert(pair<string,string>("title", (event->Title())?event->Title():""));
stringTokens.insert(pair<string,string>("subtitle", (event->ShortText())?event->ShortText():""));
stringTokens.insert(pair<string,string>("start", *event->GetTimeString()));
stringTokens.insert(pair<string,string>("stop", *event->GetEndTimeString()));
intTokens.insert(pair<string,int>("duration", event->Duration() / 60));
intTokens.insert(pair<string,int>("durationhours", event->Duration() / 3600));
stringTokens.insert(pair<string,string>("durationminutes", *cString::sprintf("%.2d", (event->Duration() / 60)%60)));
intTokens.insert(pair<string,int>("elapsed", (int)round((time(NULL) - event->StartTime())/60)));
intTokens.insert(pair<string,int>("remaining", (int)round((event->EndTime() - time(NULL))/60)));
int mediaWidth = 0;
int mediaHeight = 0;
string mediaPath = "";
bool isBanner = false;
int posterWidth = 0;
int posterHeight = 0;
string posterPath = "";
bool hasPoster = false;
int bannerWidth = 0;
int bannerHeight = 0;
string bannerPath = "";
bool hasBanner = false;
static cPlugin *pScraper = GetScraperPlugin();
if (pScraper) {
ScraperGetPosterBanner call;
call.event = event;
if (pScraper->Service("GetPosterBanner", &call)) {
if ((call.type == tSeries) && call.banner.path.size() > 0) {
mediaWidth = call.banner.width;
mediaHeight = call.banner.height;
mediaPath = call.banner.path;
isBanner = true;
bannerWidth = mediaWidth;
bannerHeight = mediaHeight;
bannerPath = mediaPath;
hasBanner = true;
ScraperGetPoster callPoster;
callPoster.event = event;
callPoster.recording = NULL;
if (pScraper->Service("GetPoster", &callPoster)) {
posterWidth = callPoster.poster.width;
posterHeight = callPoster.poster.height;
posterPath = callPoster.poster.path;
hasPoster = true;
}
} else if (call.type == tMovie && call.poster.path.size() > 0 && call.poster.height > 0) {
mediaWidth = call.poster.width;
mediaHeight = call.poster.height;
mediaPath = call.poster.path;
posterWidth = call.poster.width;
posterHeight = call.poster.height;
posterPath = call.poster.path;
hasPoster = true;
}
} }
} else {
map < string, string > stringTokens;
map < string, int > intTokens;
SetCurrentSchedule(stringTokens, intTokens);
ClearViewElement(veCurrentSchedule);
DrawViewElement(veCurrentSchedule, &stringTokens, &intTokens);
} }
intTokens.insert(pair<string,int>("mediawidth", mediaWidth));
intTokens.insert(pair<string,int>("mediaheight", mediaHeight));
intTokens.insert(pair<string,int>("isbanner", isBanner));
stringTokens.insert(pair<string,string>("mediapath", mediaPath));
intTokens.insert(pair<string,int>("posterwidth", posterWidth));
intTokens.insert(pair<string,int>("posterheight", posterHeight));
stringTokens.insert(pair<string,string>("posterpath", posterPath));
intTokens.insert(pair<string,int>("hasposter", hasPoster));
intTokens.insert(pair<string,int>("bannerwidth", bannerWidth));
intTokens.insert(pair<string,int>("bannerheight", bannerHeight));
stringTokens.insert(pair<string,string>("bannerpath", bannerPath));
intTokens.insert(pair<string,int>("hasbanner", hasBanner));
ClearViewElement(veCurrentSchedule);
DrawViewElement(veCurrentSchedule, &stringTokens, &intTokens);
} }
void cDisplayMenuMainView::DrawCurrentWeather(void) { void cDisplayMenuMainView::DrawCurrentWeather(void) {
if (!ExecuteViewElement(veCurrentWeather)) { if (!ExecuteViewElement(veCurrentWeather)) {
return; return;
} }
map < string, string > stringTokens; if (DetachViewElement(veCurrentWeather)) {
map < string, int > intTokens; cViewElement *viewElement = GetViewElement(veCurrentWeather);
if (!SetCurrentWeatherTokens(stringTokens, intTokens)){ if (!viewElement) {
viewElement = new cViewElementWeather(tmplView->GetViewElement(veCurrentWeather));
AddViewElement(veCurrentWeather, viewElement);
viewElement->Start();
} else {
if (!viewElement->Starting())
viewElement->Render();
}
} else {
map < string, string > stringTokens;
map < string, int > intTokens;
if (!SetCurrentWeatherTokens(stringTokens, intTokens)){
ClearViewElement(veCurrentWeather);
return;
}
ClearViewElement(veCurrentWeather); ClearViewElement(veCurrentWeather);
return; DrawViewElement(veCurrentWeather, &stringTokens, &intTokens);
} }
ClearViewElement(veCurrentWeather);
DrawViewElement(veCurrentWeather, &stringTokens, &intTokens);
} }
void cDisplayMenuMainView::DrawCustomTokens(void) { void cDisplayMenuMainView::DrawCustomTokens(void) {
@ -640,9 +442,22 @@ void cDisplayMenuMainView::DrawCustomTokens(void) {
} }
if (!tmplView) if (!tmplView)
return; return;
map < string, string > stringTokens = tmplView->GetCustomStringTokens();
map < string, int > intTokens = tmplView->GetCustomIntTokens(); if (DetachViewElement(veCustomTokens)) {
DrawViewElement(veCustomTokens, &stringTokens, &intTokens); cViewElement *viewElement = GetViewElement(veCustomTokens);
if (!viewElement) {
viewElement = new cViewElementCustomTokens(tmplView->GetViewElement(veCustomTokens), tmplView);
AddViewElement(veCustomTokens, viewElement);
viewElement->Start();
} else {
if (!viewElement->Starting())
viewElement->Render();
}
} else {
map < string, string > stringTokens = tmplView->GetCustomStringTokens();
map < string, int > intTokens = tmplView->GetCustomIntTokens();
DrawViewElement(veCustomTokens, &stringTokens, &intTokens);
}
} }
/************************************************************************ /************************************************************************

View File

@ -37,8 +37,6 @@ public:
class cDisplayMenuMainView : public cDisplayMenuView { class cDisplayMenuMainView : public cDisplayMenuView {
private: private:
bool initial; bool initial;
double lastSystemLoad;
int lastMemUsage;
void DrawTimers(void); void DrawTimers(void);
void DrawDiscUsage(void); void DrawDiscUsage(void);
bool DrawLoad(void); bool DrawLoad(void);

207
views/displayviewelements.c Normal file
View File

@ -0,0 +1,207 @@
#include "displayviewelements.h"
cViewElementDevices::cViewElementDevices(cTemplateViewElement *tmplViewElement) : cViewElement(tmplViewElement) {
init = true;
}
bool cViewElementDevices::Render(void) {
ClearTokens();
map < string, vector< map< string, string > > > deviceLoopTokens;
vector< map< string, string > > devices;
if (init)
InitDevices();
bool changed = SetDevices(init, &intTokens, &devices);
init = false;
if (!changed)
return false;
deviceLoopTokens.insert(pair< string, vector< map< string, string > > >("devices", devices));
ClearViewElement(veDevices);
DrawViewElement(veDevices, &stringTokens, &intTokens, &deviceLoopTokens);
return true;
}
/********************************************************************************************************************/
cViewElementSignal::cViewElementSignal(cTemplateViewElement *tmplViewElement) : cViewElement(tmplViewElement) {
}
bool cViewElementSignal::Render(void) {
ClearTokens();
bool changed = SetSignal(intTokens);
if (!changed)
return false;
ClearViewElement(veSignalQuality);
DrawViewElement(veSignalQuality, &stringTokens, &intTokens);
return true;
}
/********************************************************************************************************************/
cViewElementWeather::cViewElementWeather(cTemplateViewElement *tmplViewElement) : cViewElement(tmplViewElement) {
}
bool cViewElementWeather::Render(void) {
ClearTokens();
if (!SetCurrentWeatherTokens(stringTokens, intTokens)){
ClearViewElement(veCurrentWeather);
return false;
}
ClearViewElement(veCurrentWeather);
DrawViewElement(veCurrentWeather, &stringTokens, &intTokens);
return true;
}
/********************************************************************************************************************/
cViewElementDate::cViewElementDate(cTemplateViewElement *tmplViewElement) : cViewElement(tmplViewElement) {
}
bool cViewElementDate::Render(void) {
ClearTokens();
if (!SetDate(stringTokens, intTokens)) {
return false;
}
ClearViewElement(veDateTime);
DrawViewElement(veDateTime, &stringTokens, &intTokens);
return true;
}
/********************************************************************************************************************/
cViewElementTime::cViewElementTime(cTemplateViewElement *tmplViewElement) : cViewElement(tmplViewElement) {
}
bool cViewElementTime::Render(void) {
ClearTokens();
if (!SetTime(stringTokens, intTokens)) {
return false;
}
ClearViewElement(veTime);
DrawViewElement(veTime, &stringTokens, &intTokens);
return true;
}
/********************************************************************************************************************/
cViewElementScraperContent::cViewElementScraperContent(const cEvent *event, ScraperContentType type, cTemplateViewElement *tmplViewElement) : cViewElement(tmplViewElement) {
this->event = event;
this->type = type;
}
bool cViewElementScraperContent::Render(void) {
ClearTokens();
SetPosterBanner(event, stringTokens, intTokens);
ClearViewElement(veScraperContent);
DrawViewElement(veScraperContent, &stringTokens, &intTokens);
return true;
}
/********************************************************************************************************************/
cViewElementCustomTokens::cViewElementCustomTokens(cTemplateViewElement *tmplViewElement, cTemplateView *tmplView) : cViewElement(tmplViewElement) {
this->tmplView = tmplView;
}
bool cViewElementCustomTokens::Render(void) {
ClearTokens();
if (!tmplView)
return false;
stringTokens = tmplView->GetCustomStringTokens();
intTokens = tmplView->GetCustomIntTokens();
ClearViewElement(veCustomTokens);
DrawViewElement(veCustomTokens, &stringTokens, &intTokens);
return true;
}
/********************************************************************************************************************/
cViewElementTimers::cViewElementTimers(cTemplateViewElement *tmplViewElement) : cViewElement(tmplViewElement) {
}
bool cViewElementTimers::Render(void) {
ClearTokens();
map < string, vector< map< string, string > > > timerLoopTokens;
vector< map< string, string > > timers;
SetTimers(&intTokens, &stringTokens, &timers);
timerLoopTokens.insert(pair< string, vector< map< string, string > > >("timers", timers));
ClearViewElement(veTimers);
DrawViewElement(veTimers, &stringTokens, &intTokens, &timerLoopTokens);
return true;
}
/********************************************************************************************************************/
cViewElementDiscUsage::cViewElementDiscUsage(cTemplateViewElement *tmplViewElement) : cViewElement(tmplViewElement) {
}
bool cViewElementDiscUsage::Render(void) {
ClearTokens();
SetDiscUsage(stringTokens, intTokens);
ClearViewElement(veDiscUsage);
DrawViewElement(veDiscUsage, &stringTokens, &intTokens);
return true;
}
/********************************************************************************************************************/
cViewElementSystemLoad::cViewElementSystemLoad(cTemplateViewElement *tmplViewElement) : cViewElement(tmplViewElement) {
}
bool cViewElementSystemLoad::Render(void) {
ClearTokens();
if (!SetSystemLoad(stringTokens, intTokens))
return false;
ClearViewElement(veSystemLoad);
DrawViewElement(veSystemLoad, &stringTokens, &intTokens);
return true;
}
/********************************************************************************************************************/
cViewElementSystemMemory::cViewElementSystemMemory(cTemplateViewElement *tmplViewElement) : cViewElement(tmplViewElement) {
}
bool cViewElementSystemMemory::Render(void) {
ClearTokens();
if (!SetSystemMemory(stringTokens, intTokens))
return false;
ClearViewElement(veSystemMemory);
DrawViewElement(veSystemMemory, &stringTokens, &intTokens);
return true;
}
/********************************************************************************************************************/
cViewElementTemperature::cViewElementTemperature(cTemplateViewElement *tmplViewElement) : cViewElement(tmplViewElement) {
}
bool cViewElementTemperature::Render(void) {
ClearTokens();
if (!SetSystemTemperatures(stringTokens, intTokens))
return false;
ClearViewElement(veTemperatures);
DrawViewElement(veTemperatures, &stringTokens, &intTokens);
return true;
}
/********************************************************************************************************************/
cViewElementCurrentSchedule::cViewElementCurrentSchedule(cTemplateViewElement *tmplViewElement) : cViewElement(tmplViewElement) {
}
bool cViewElementCurrentSchedule::Render(void) {
ClearTokens();
SetCurrentSchedule(stringTokens, intTokens);
ClearViewElement(veCurrentSchedule);
DrawViewElement(veCurrentSchedule, &stringTokens, &intTokens);
return true;
}

121
views/displayviewelements.h Normal file
View File

@ -0,0 +1,121 @@
#ifndef __DISPLAYCHANNELVIEWELEMENTS_H
#define __DISPLAYCHANNELVIEWELEMENTS_H
#include "../libtemplate/template.h"
#include "view.h"
#include "viewhelpers.h"
class cViewElementDevices : public cViewElement, public cViewHelpers {
private:
bool init;
public:
cViewElementDevices(cTemplateViewElement *tmplViewElement);
virtual ~cViewElementDevices() {};
bool Render(void);
};
class cViewElementSignal : public cViewElement, public cViewHelpers {
private:
public:
cViewElementSignal(cTemplateViewElement *tmplViewElement);
virtual ~cViewElementSignal() {};
bool Render(void);
};
class cViewElementWeather : public cViewElement, public cViewHelpers {
private:
public:
cViewElementWeather(cTemplateViewElement *tmplViewElement);
virtual ~cViewElementWeather() {};
bool Render(void);
};
class cViewElementDate : public cViewElement, public cViewHelpers {
private:
public:
cViewElementDate(cTemplateViewElement *tmplViewElement);
virtual ~cViewElementDate() {};
bool Render(void);
};
class cViewElementTime : public cViewElement, public cViewHelpers {
private:
public:
cViewElementTime(cTemplateViewElement *tmplViewElement);
virtual ~cViewElementTime() {};
bool Render(void);
};
enum ScraperContentType {
ctPosterBanner,
ctFull
};
class cViewElementScraperContent : public cViewElement, public cViewHelpers {
private:
ScraperContentType type;
const cEvent *event;
public:
cViewElementScraperContent(const cEvent *event, ScraperContentType type, cTemplateViewElement *tmplViewElement);
virtual ~cViewElementScraperContent() {};
bool Render(void);
};
class cViewElementCustomTokens : public cViewElement, public cViewHelpers {
private:
cTemplateView *tmplView;
public:
cViewElementCustomTokens(cTemplateViewElement *tmplViewElement, cTemplateView *tmplView);
virtual ~cViewElementCustomTokens() {};
bool Render(void);
};
class cViewElementTimers : public cViewElement, public cViewHelpers {
private:
public:
cViewElementTimers(cTemplateViewElement *tmplViewElement);
virtual ~cViewElementTimers() {};
bool Render(void);
};
class cViewElementDiscUsage : public cViewElement, public cViewHelpers {
private:
public:
cViewElementDiscUsage(cTemplateViewElement *tmplViewElement);
virtual ~cViewElementDiscUsage() {};
bool Render(void);
};
class cViewElementSystemLoad : public cViewElement, public cViewHelpers {
private:
public:
cViewElementSystemLoad(cTemplateViewElement *tmplViewElement);
virtual ~cViewElementSystemLoad() {};
bool Render(void);
};
class cViewElementSystemMemory : public cViewElement, public cViewHelpers {
private:
public:
cViewElementSystemMemory(cTemplateViewElement *tmplViewElement);
virtual ~cViewElementSystemMemory() {};
bool Render(void);
};
class cViewElementTemperature : public cViewElement, public cViewHelpers {
private:
public:
cViewElementTemperature(cTemplateViewElement *tmplViewElement);
virtual ~cViewElementTemperature() {};
bool Render(void);
};
class cViewElementCurrentSchedule : public cViewElement, public cViewHelpers {
private:
public:
cViewElementCurrentSchedule(cTemplateViewElement *tmplViewElement);
virtual ~cViewElementCurrentSchedule() {};
bool Render(void);
};
#endif //__DISPLAYCHANNELVIEWELEMENTS_H

View File

@ -37,7 +37,8 @@ cView::~cView() {
cDevice::PrimaryDevice()->ScaleVideo(cRect::Null); cDevice::PrimaryDevice()->ScaleVideo(cRect::Null);
} }
for (map<eViewElement,cViewElement*>::iterator dVeIt = detachedViewElements.begin(); dVeIt != detachedViewElements.end(); dVeIt++) { for (map<eViewElement,cViewElement*>::iterator dVeIt = detachedViewElements.begin(); dVeIt != detachedViewElements.end(); dVeIt++) {
delete dVeIt->second; cViewElement *ve = dVeIt->second;
delete ve;
} }
} }
@ -94,6 +95,11 @@ void cView::DrawViewElement(eViewElement ve, map <string,string> *stringTokens,
viewElement->InitIterator(); viewElement->InitIterator();
cTemplatePixmap *pix = NULL; cTemplatePixmap *pix = NULL;
while(pix = viewElement->GetNextPixmap()) { while(pix = viewElement->GetNextPixmap()) {
//check if already drawn background area, this can be skipped
if (PixmapExists(pixCurrent) && pix->BackgroundArea()) {
pixCurrent++;
continue;
}
//reset Template //reset Template
pix->ClearDynamicParameters(); pix->ClearDynamicParameters();
//create Pixmap if already fully parsed //create Pixmap if already fully parsed
@ -151,9 +157,12 @@ void cView::DrawViewElement(eViewElement ve, map <string,string> *stringTokens,
} }
void cView::ClearViewElement(eViewElement ve) { void cView::ClearViewElement(eViewElement ve) {
if (!tmplView) cTemplateViewElement *viewElement = NULL;
return; if (tmplViewElement) {
cTemplateViewElement *viewElement = tmplView->GetViewElement(ve); viewElement = tmplViewElement;
} else if (tmplView) {
viewElement = tmplView->GetViewElement(ve);
}
if (!viewElement) if (!viewElement)
return; return;
int pixCurrent = viewElement->GetPixOffset(); int pixCurrent = viewElement->GetPixOffset();
@ -162,7 +171,9 @@ void cView::ClearViewElement(eViewElement ve) {
cTemplatePixmap *pix = NULL; cTemplatePixmap *pix = NULL;
viewElement->InitIterator(); viewElement->InitIterator();
while(pix = viewElement->GetNextPixmap()) { while(pix = viewElement->GetNextPixmap()) {
Fill(pixCurrent, clrTransparent); if (!pix->BackgroundArea()) {
Fill(pixCurrent, clrTransparent);
}
pixCurrent++; pixCurrent++;
} }
} }
@ -834,6 +845,7 @@ void cView::DoDrawImage(int num, cTemplateFunction *func, int x0, int y0) {
************************************************************************/ ************************************************************************/
cViewElement::cViewElement(cTemplateViewElement *tmplViewElement) : cView(tmplViewElement) { cViewElement::cViewElement(cTemplateViewElement *tmplViewElement) : cView(tmplViewElement) {
tmplViewElement->SetPixOffset(0);
delay = tmplViewElement->GetNumericParameter(ptDelay); delay = tmplViewElement->GetNumericParameter(ptDelay);
SetFadeTime(tmplViewElement->GetNumericParameter(ptFadeTime)); SetFadeTime(tmplViewElement->GetNumericParameter(ptFadeTime));
} }
@ -858,82 +870,11 @@ void cViewElement::Action(void) {
} }
} }
void cViewElement::Draw(map < string, vector< map< string, string > > > *loopTokens) { void cViewElement::ClearTokens(void) {
if (!tmplViewElement) stringTokens.clear();
return; intTokens.clear();
if (tmplViewElement->DebugTokens()) {
DebugTokens("viewelement", &stringTokens, &intTokens, loopTokens);
}
//iterate through pixmaps of viewelement
int pixCurrent = 0;
tmplViewElement->InitIterator();
cTemplatePixmap *pix = NULL;
while(pix = tmplViewElement->GetNextPixmap()) {
//reset Template
pix->ClearDynamicParameters();
//create Pixmap if already fully parsed
if (!PixmapExists(pixCurrent) && pix->Ready() && pix->DoExecute() && !pix->Scrolling()) {
CreateViewPixmap(pixCurrent, pix);
}
//check if pixmap needs dynamic parameters
if ((!pix->Ready() || !pix->DoExecute()) && !pix->Scrolling()) {
//parse dynamic parameters and initiate functions
pix->ParseDynamicParameters(&intTokens, true);
if (pix->Ready() && pix->DoExecute()) {
CreateViewPixmap(pixCurrent, pix);
}
} else {
//parse dynamic parameters but not initiate functions
pix->ParseDynamicParameters(&intTokens, false);
}
//if pixmap still not valid, skip
if (!pix->Ready() && !pix->Scrolling()) {
pixCurrent++;
continue;
}
//if condition for pixmap set, check if cond is true
if (!pix->DoExecute()) {
pixCurrent++;
continue;
}
//parse dynamic tokens of pixmap functions
pix->ClearDynamicFunctionParameters();
pix->ParseDynamicFunctionParameters(&stringTokens, &intTokens);
if (!PixmapExists(pixCurrent) && pix->Scrolling()) {
cSize drawportSize;
scrolling = pix->CalculateDrawPortSize(drawportSize, loopTokens);
if (scrolling) {
/*
CreateScrollingPixmap(pixCurrent, pix, drawportSize);
pix->SetScrollingTextWidth();
veScroll = ve;
scrollingPix = pixCurrent;
scrollOrientation = pix->GetNumericParameter(ptOrientation);
scrollMode = pix->GetNumericParameter(ptScrollMode);
scrollDelay = pix->GetNumericParameter(ptDelay);
scrollSpeed = pix->GetNumericParameter(ptScrollSpeed);
*/
} else {
CreateViewPixmap(pixCurrent, pix);
}
}
if (pix->DoDebug()) {
pix->Debug();
}
DrawPixmap(pixCurrent, pix, loopTokens);
pixCurrent++;
}
} }
void cViewElement::Clear(void) {
int pixMax = NumPixmaps();
for (int pixCurrent = 0; pixCurrent < pixMax; pixCurrent++) {
Fill(pixCurrent, clrTransparent);
}
}
/*********************************************************************** /***********************************************************************
* cViewListItem * cViewListItem

View File

@ -72,12 +72,12 @@ protected:
map < string, string > stringTokens; map < string, string > stringTokens;
map < string, int > intTokens; map < string, int > intTokens;
void Action(void); void Action(void);
void Draw(map < string, vector< map< string, string > > > *loopTokens = NULL); void ClearTokens(void);
public: public:
cViewElement(cTemplateViewElement *tmplViewElement); cViewElement(cTemplateViewElement *tmplViewElement);
virtual ~cViewElement(); virtual ~cViewElement();
virtual void Render(void) {}; virtual bool Render(void) { return false; };
void Clear(void); bool Starting(void) { return Running(); };
}; };
class cViewListItem : public cView { class cViewListItem : public cView {

View File

@ -1,15 +1,25 @@
#include <fstream>
#include <iostream>
#include <vdr/menu.h> #include <vdr/menu.h>
#include <vdr/videodir.h>
#include <sys/sysinfo.h>
#include "../services/scraper2vdr.h" #include "../services/scraper2vdr.h"
#include "../services/weatherforecast.h" #include "../services/weatherforecast.h"
#include "../config.h" #include "../config.h"
#include "../libcore/timers.h"
#include "../libcore/helpers.h" #include "../libcore/helpers.h"
#include "viewhelpers.h" #include "viewhelpers.h"
cViewHelpers::cViewHelpers(void) { cViewHelpers::cViewHelpers(void) {
numDevices = 0; numDevices = 0;
devicesInit = false; devicesInit = false;
lSignalDisplay = 0;
lSignalStrength = 0;
lSignalQuality = 0;
lastSecond = -1; lastSecond = -1;
lastMinute = -1; lastMinute = -1;
lastSystemLoad = 0.0;
lastMemUsage = -1;
} }
cViewHelpers::~cViewHelpers() { cViewHelpers::~cViewHelpers() {
@ -141,6 +151,28 @@ bool cViewHelpers::SetDevices(bool initial, map<string,int> *intTokens, vector<m
return true; return true;
} }
bool cViewHelpers::SetSignal(map < string, int > &intTokens) {
bool done = false;
time_t Now = time(NULL);
if (Now != lSignalDisplay) {
int SignalStrength = cDevice::ActualDevice()->SignalStrength();
int SignalQuality = cDevice::ActualDevice()->SignalQuality();
if (SignalStrength < 0) SignalStrength = 0;
if (SignalQuality < 0) SignalQuality = 0;
if ((SignalStrength == 0)&&(SignalQuality==0))
return done;
if ((lSignalStrength != SignalStrength) || (lSignalQuality != SignalQuality)) {
intTokens.insert(pair<string,int>("signalstrength", SignalStrength));
intTokens.insert(pair<string,int>("signalquality", SignalQuality));
lSignalStrength = SignalStrength;
lSignalQuality = SignalQuality;
done = true;
}
lSignalDisplay = Now;
}
return done;
}
bool cViewHelpers::CheckNewMails(void) { bool cViewHelpers::CheckNewMails(void) {
static cPlugin *pMailbox = cPluginManager::GetPlugin("mailbox"); static cPlugin *pMailbox = cPluginManager::GetPlugin("mailbox");
if (!pMailbox) { if (!pMailbox) {
@ -359,13 +391,80 @@ void cViewHelpers::SetScraperTokens(const cEvent *event, const cRecording *recor
} }
void cViewHelpers::SetPosterBanner(const cEvent *event, map < string, string > &stringTokens, map < string, int > &intTokens) {
static cPlugin *pScraper = GetScraperPlugin();
if (!pScraper) {
return;
}
ScraperGetPosterBanner call;
call.event = event;
if (pScraper->Service("GetPosterBanner", &call)) {
int mediaWidth = 0;
int mediaHeight = 0;
string mediaPath = "";
bool isBanner = false;
int posterWidth = 0;
int posterHeight = 0;
string posterPath = "";
bool hasPoster = false;
int bannerWidth = 0;
int bannerHeight = 0;
string bannerPath = "";
bool hasBanner = false;
if ((call.type == tSeries) && call.banner.path.size() > 0) {
mediaWidth = call.banner.width;
mediaHeight = call.banner.height;
mediaPath = call.banner.path;
isBanner = true;
bannerWidth = mediaWidth;
bannerHeight = mediaHeight;
bannerPath = mediaPath;
hasBanner = true;
ScraperGetPoster callPoster;
callPoster.event = event;
callPoster.recording = NULL;
if (pScraper->Service("GetPoster", &callPoster)) {
posterWidth = callPoster.poster.width;
posterHeight = callPoster.poster.height;
posterPath = callPoster.poster.path;
hasPoster = true;
}
} else if (call.type == tMovie && call.poster.path.size() > 0 && call.poster.height > 0) {
mediaWidth = call.poster.width;
mediaHeight = call.poster.height;
mediaPath = call.poster.path;
posterWidth = call.poster.width;
posterHeight = call.poster.height;
posterPath = call.poster.path;
hasPoster = true;
} else
return;
intTokens.insert(pair<string,int>("mediawidth", mediaWidth));
intTokens.insert(pair<string,int>("mediaheight", mediaHeight));
intTokens.insert(pair<string,int>("isbanner", isBanner));
stringTokens.insert(pair<string,string>("mediapath", mediaPath));
intTokens.insert(pair<string,int>("posterwidth", posterWidth));
intTokens.insert(pair<string,int>("posterheight", posterHeight));
stringTokens.insert(pair<string,string>("posterpath", posterPath));
intTokens.insert(pair<string,int>("hasposter", hasPoster));
intTokens.insert(pair<string,int>("bannerwidth", bannerWidth));
intTokens.insert(pair<string,int>("bannerheight", bannerHeight));
stringTokens.insert(pair<string,string>("bannerpath", bannerPath));
intTokens.insert(pair<string,int>("hasbanner", hasBanner));
}
}
bool cViewHelpers::SetTime(map < string, string > &stringTokens, map < string, int > &intTokens) { bool cViewHelpers::SetTime(map < string, string > &stringTokens, map < string, int > &intTokens) {
time_t t = time(0); // get time now time_t t = time(0); // get time now
struct tm * now = localtime(&t); struct tm * now = localtime(&t);
int sec = now->tm_sec; int sec = now->tm_sec;
if (sec == lastSecond) if (sec == lastSecond) {
return false; return false;
}
int min = now->tm_min; int min = now->tm_min;
int hour = now->tm_hour; int hour = now->tm_hour;
int hourMinutes = hour%12 * 5 + min / 12; int hourMinutes = hour%12 * 5 + min / 12;
@ -433,3 +532,316 @@ bool cViewHelpers::SetCurrentWeatherTokens(map < string, string > &stringTokens,
stringTokens.insert(pair<string,string>("ozone", currentWeather.ozone)); stringTokens.insert(pair<string,string>("ozone", currentWeather.ozone));
return true; return true;
} }
void cViewHelpers::SetTimers(map<string,int> *intTokens, map<string,string> *stringTokens, vector<map<string,string> > *timers) {
cGlobalSortedTimers SortedTimers;// local and remote timers
int numTimers = SortedTimers.Size();
intTokens->insert(pair<string, int>("numtimers", numTimers));
int numTimerConflicts = SortedTimers.NumTimerConfilicts();
intTokens->insert(pair<string, int>("numtimerconflicts", numTimerConflicts));
for (int i=0; i<15; i++) {
stringstream name;
name << "timer" << i+1 << "exists";
if (i < numTimers) {
intTokens->insert(pair<string, int>(name.str(), true));
} else {
intTokens->insert(pair<string, int>(name.str(), false));
}
}
for (int i = 0; i < numTimers; i++) {
if (i >=15)
break;
map< string, string > timerVals;
const cTimer *Timer = SortedTimers[i];
const cEvent *event = Timer->Event();
if (event) {
timerVals.insert(pair< string, string >("timers[title]", event->Title()));
} else {
const char *File = Setup.FoldersInTimerMenu ? NULL : strrchr(Timer->File(), FOLDERDELIMCHAR);
if (File && strcmp(File + 1, TIMERMACRO_TITLE) && strcmp(File + 1, TIMERMACRO_EPISODE))
File++;
else
File = Timer->File();
timerVals.insert(pair< string, string >("timers[title]", File));
}
const cChannel *channel = Timer->Channel();
if (channel) {
timerVals.insert(pair< string, string >("timers[channelname]", channel->Name()));
stringstream chanNum;
chanNum << channel->Number();
timerVals.insert(pair< string, string >("timers[channelnumber]", chanNum.str()));
string channelID = *(channel->GetChannelID().ToString());
timerVals.insert(pair< string, string >("timers[channelid]", channelID));
bool logoExists = imgCache->LogoExists(channelID);
timerVals.insert(pair< string, string >("timers[channellogoexists]", logoExists ? "1" : "0"));
} else {
timerVals.insert(pair< string, string >("timers[channelname]", ""));
timerVals.insert(pair< string, string >("timers[channelnumber]", "0"));
timerVals.insert(pair< string, string >("timers[channelid]", ""));
timerVals.insert(pair< string, string >("timers[channellogoexists]", "0"));
}
timerVals.insert(pair< string, string >("timers[recording]", Timer->Recording() ? "1" : "0"));
cString timerDate("");
if (Timer->Recording()) {
timerDate = cString::sprintf("-%s", *TimeString(Timer->StopTime()));
} else {
time_t Now = time(NULL);
cString Today = WeekDayName(Now);
cString Time = TimeString(Timer->StartTime());
cString Day = WeekDayName(Timer->StartTime());
if (Timer->StartTime() > Now + 6 * SECSINDAY) {
time_t ttm = Timer->StartTime();
struct tm * timerTime = localtime(&ttm);
timerDate = cString::sprintf("%02d.%02d %s", timerTime->tm_mday, timerTime->tm_mon + 1, *Time);
} else if (strcmp(Day, Today) != 0)
timerDate = cString::sprintf("%s %s", *Day, *Time);
else
timerDate = Time;
if (Timer->Flags() & tfVps)
timerDate = cString::sprintf("VPS %s", *timerDate);
}
timerVals.insert(pair< string, string >("timers[datetime]", *timerDate));
timers->push_back(timerVals);
}
}
void cViewHelpers::SetMenuHeader(eMenuCategory cat, string menuTitle, map < string, string > &stringTokens, map < string, int > &intTokens) {
stringTokens.insert(pair<string,string>("title", menuTitle));
stringTokens.insert(pair<string,string>("vdrversion", VDRVERSION));
//check for standard menu entries
bool hasIcon = false;
string icon = imgCache->GetIconName(menuTitle, cat);
if (imgCache->MenuIconExists(icon))
hasIcon = true;
stringTokens.insert(pair<string,string>("icon", icon));
intTokens.insert(pair<string,int>("hasicon", hasIcon));
//Disc Usage
string vdrUsageString = *cVideoDiskUsage::String();
int discUsage = cVideoDiskUsage::UsedPercent();
bool discAlert = (discUsage > 95) ? true : false;
string freeTime = *cString::sprintf("%02d:%02d", cVideoDiskUsage::FreeMinutes() / 60, cVideoDiskUsage::FreeMinutes() % 60);
int freeGB = cVideoDiskUsage::FreeMB() / 1024;
intTokens.insert(pair<string, int>("usedpercent", discUsage));
intTokens.insert(pair<string, int>("freepercent", 100-discUsage));
intTokens.insert(pair<string, int>("discalert", discAlert));
intTokens.insert(pair<string, int>("freegb", freeGB));
stringTokens.insert(pair<string,string>("freetime", freeTime));
stringTokens.insert(pair<string,string>("vdrusagestring", vdrUsageString));
}
void cViewHelpers::SetDiscUsage(map < string, string > &stringTokens, map < string, int > &intTokens) {
string vdrUsageString = *cVideoDiskUsage::String();
int discUsage = cVideoDiskUsage::UsedPercent();
bool discAlert = (discUsage > 95) ? true : false;
string freeTime = *cString::sprintf("%02d:%02d", cVideoDiskUsage::FreeMinutes() / 60, cVideoDiskUsage::FreeMinutes() % 60);
int freeGB = cVideoDiskUsage::FreeMB() / 1024;
intTokens.insert(pair<string, int>("usedpercent", discUsage));
intTokens.insert(pair<string, int>("freepercent", 100-discUsage));
intTokens.insert(pair<string, int>("discalert", discAlert));
intTokens.insert(pair<string, int>("freegb", freeGB));
stringTokens.insert(pair<string,string>("freetime", freeTime));
stringTokens.insert(pair<string,string>("vdrusagestring", vdrUsageString));
}
bool cViewHelpers::SetSystemLoad(map < string, string > &stringTokens, map < string, int > &intTokens) {
double systemLoad;
if (getloadavg(&systemLoad, 1) > 0) {
if (lastSystemLoad == systemLoad) {
return false;
}
string load = *cString::sprintf("%.2f", systemLoad);
int loadHand = systemLoad * 1000;
int loadHandValue = 0;
if (loadHand > 2500)
loadHandValue = 2525;
else {
int loadHandDec = loadHand - (loadHand / 100) * 100;
if (loadHandDec <= 12)
loadHandDec = 0;
else if (loadHandDec <= 37)
loadHandDec = 25;
else if (loadHandDec <= 62)
loadHandDec = 50;
else if (loadHandDec <= 87)
loadHandDec = 75;
else
loadHandDec = 0;
loadHandValue = loadHand / 100 * 100 + loadHandDec;
}
stringTokens.insert(pair<string,string>("load", load));
intTokens.insert(pair<string,int>("loadhand", loadHandValue));
lastSystemLoad = systemLoad;
} else {
return false;
}
return true;
}
bool cViewHelpers::SetSystemMemory(map < string, string > &stringTokens, map < string, int > &intTokens) {
struct sysinfo memInfo;
sysinfo (&memInfo);
long long totalMem = memInfo.totalram;
totalMem += memInfo.totalswap;
totalMem *= memInfo.mem_unit;
int totalMemMB = totalMem / 1024 / 1024;
long long usedMem = memInfo.totalram - memInfo.freeram;
usedMem += memInfo.totalswap - memInfo.freeswap;
usedMem *= memInfo.mem_unit;
int usedMemMB = usedMem / 1024 / 1024;
if (lastMemUsage == usedMemMB) {
return false;
}
lastMemUsage = usedMemMB;
intTokens.insert(pair<string,int>("totalmem", totalMemMB));
intTokens.insert(pair<string,int>("usedmem", usedMemMB));
if (totalMemMB > 0)
intTokens.insert(pair<string,int>("usedmempercent", usedMemMB * 100 / totalMemMB));
return true;
}
bool cViewHelpers::SetSystemTemperatures(map < string, string > &stringTokens, map < string, int > &intTokens) {
cString execCommand = cString::sprintf("cd \"%s/\"; \"%s/temperatures\"", SCRIPTFOLDER, SCRIPTFOLDER);
system(*execCommand);
string tempCPU, tempGPU;
int cpu, gpu;
cString itemFilename = cString::sprintf("%s/cpu", SCRIPTOUTPUTPATH );
ifstream file(*itemFilename, ifstream::in);
if( file.is_open() ) {
std::getline(file, tempCPU);
if (tempCPU.size() > 2) {
cpu = atoi(tempCPU.substr(0,2).c_str());
} else
cpu = 0;
file.close();
} else {
tempCPU = "0°C";
cpu = 0;
}
itemFilename = cString::sprintf("%s/gpu", SCRIPTOUTPUTPATH );
ifstream file2(*itemFilename, ifstream::in);
if( file2.is_open() ) {
std::getline(file2, tempGPU);
if (tempGPU.size() > 2) {
gpu = atoi(tempGPU.substr(0,2).c_str());
} else
gpu = 0;
file2.close();
} else {
tempGPU = "0°C";
gpu = 0;
}
intTokens.insert(pair<string,int>("cputemp", cpu));
intTokens.insert(pair<string,int>("gputemp", gpu));
return true;
}
void cViewHelpers::SetCurrentSchedule(map < string, string > &stringTokens, map < string, int > &intTokens) {
cDevice *device = cDevice::PrimaryDevice();
const cChannel *channel = NULL;
if (!device->Replaying() || device->Transferring()) {
channel = Channels.GetByNumber(device->CurrentChannel());
}
if (!channel)
return;
const cEvent *event = NULL;
cSchedulesLock SchedulesLock;
if (const cSchedules *Schedules = cSchedules::Schedules(SchedulesLock))
if (const cSchedule *Schedule = Schedules->GetSchedule(channel))
event = Schedule->GetPresentEvent();
if (!event)
return;
stringTokens.insert(pair<string,string>("title", (event->Title())?event->Title():""));
stringTokens.insert(pair<string,string>("subtitle", (event->ShortText())?event->ShortText():""));
stringTokens.insert(pair<string,string>("start", *event->GetTimeString()));
stringTokens.insert(pair<string,string>("stop", *event->GetEndTimeString()));
intTokens.insert(pair<string,int>("duration", event->Duration() / 60));
intTokens.insert(pair<string,int>("durationhours", event->Duration() / 3600));
stringTokens.insert(pair<string,string>("durationminutes", *cString::sprintf("%.2d", (event->Duration() / 60)%60)));
intTokens.insert(pair<string,int>("elapsed", (int)round((time(NULL) - event->StartTime())/60)));
intTokens.insert(pair<string,int>("remaining", (int)round((event->EndTime() - time(NULL))/60)));
int mediaWidth = 0;
int mediaHeight = 0;
string mediaPath = "";
bool isBanner = false;
int posterWidth = 0;
int posterHeight = 0;
string posterPath = "";
bool hasPoster = false;
int bannerWidth = 0;
int bannerHeight = 0;
string bannerPath = "";
bool hasBanner = false;
static cPlugin *pScraper = GetScraperPlugin();
if (pScraper) {
ScraperGetPosterBanner call;
call.event = event;
if (pScraper->Service("GetPosterBanner", &call)) {
if ((call.type == tSeries) && call.banner.path.size() > 0) {
mediaWidth = call.banner.width;
mediaHeight = call.banner.height;
mediaPath = call.banner.path;
isBanner = true;
bannerWidth = mediaWidth;
bannerHeight = mediaHeight;
bannerPath = mediaPath;
hasBanner = true;
ScraperGetPoster callPoster;
callPoster.event = event;
callPoster.recording = NULL;
if (pScraper->Service("GetPoster", &callPoster)) {
posterWidth = callPoster.poster.width;
posterHeight = callPoster.poster.height;
posterPath = callPoster.poster.path;
hasPoster = true;
}
} else if (call.type == tMovie && call.poster.path.size() > 0 && call.poster.height > 0) {
mediaWidth = call.poster.width;
mediaHeight = call.poster.height;
mediaPath = call.poster.path;
posterWidth = call.poster.width;
posterHeight = call.poster.height;
posterPath = call.poster.path;
hasPoster = true;
}
}
}
intTokens.insert(pair<string,int>("mediawidth", mediaWidth));
intTokens.insert(pair<string,int>("mediaheight", mediaHeight));
intTokens.insert(pair<string,int>("isbanner", isBanner));
stringTokens.insert(pair<string,string>("mediapath", mediaPath));
intTokens.insert(pair<string,int>("posterwidth", posterWidth));
intTokens.insert(pair<string,int>("posterheight", posterHeight));
stringTokens.insert(pair<string,string>("posterpath", posterPath));
intTokens.insert(pair<string,int>("hasposter", hasPoster));
intTokens.insert(pair<string,int>("bannerwidth", bannerWidth));
intTokens.insert(pair<string,int>("bannerheight", bannerHeight));
stringTokens.insert(pair<string,string>("bannerpath", bannerPath));
intTokens.insert(pair<string,int>("hasbanner", hasBanner));
}

View File

@ -8,16 +8,30 @@ private:
int* lastSignalStrength; int* lastSignalStrength;
int* lastSignalQuality; int* lastSignalQuality;
bool* recDevices; bool* recDevices;
int lSignalDisplay;
int lSignalStrength;
int lSignalQuality;
int lastSecond; int lastSecond;
int lastMinute; int lastMinute;
double lastSystemLoad;
int lastMemUsage;
protected: protected:
void InitDevices(void); void InitDevices(void);
bool SetDevices(bool initial, map<string,int> *intTokens, vector<map<string,string> > *devices); bool SetDevices(bool initial, map<string,int> *intTokens, vector<map<string,string> > *devices);
bool SetSignal(map < string, int > &intTokens);
bool CheckNewMails(void); bool CheckNewMails(void);
void SetScraperTokens(const cEvent *event, const cRecording *recording, map < string, string > &stringTokens, map < string, int > &intTokens, map < string, vector< map< string, string > > > &loopTokens); void SetScraperTokens(const cEvent *event, const cRecording *recording, map < string, string > &stringTokens, map < string, int > &intTokens, map < string, vector< map< string, string > > > &loopTokens);
void SetPosterBanner(const cEvent *event, map < string, string > &stringTokens, map < string, int > &intTokens);
bool SetTime(map < string, string > &stringTokens, map < string, int > &intTokens); bool SetTime(map < string, string > &stringTokens, map < string, int > &intTokens);
bool SetDate(map < string, string > &stringTokens, map < string, int > &intTokens); bool SetDate(map < string, string > &stringTokens, map < string, int > &intTokens);
bool SetCurrentWeatherTokens(map < string, string > &stringTokens, map < string, int > &intTokens); bool SetCurrentWeatherTokens(map < string, string > &stringTokens, map < string, int > &intTokens);
void SetTimers(map<string,int> *intTokens, map<string,string> *stringTokens, vector<map<string,string> > *timers);
void SetMenuHeader(eMenuCategory cat, string menuTitle, map < string, string > &stringTokens, map < string, int > &intTokens);
void SetDiscUsage(map < string, string > &stringTokens, map < string, int > &intTokens);
bool SetSystemLoad(map < string, string > &stringTokens, map < string, int > &intTokens);
bool SetSystemMemory(map < string, string > &stringTokens, map < string, int > &intTokens);
bool SetSystemTemperatures(map < string, string > &stringTokens, map < string, int > &intTokens);
void SetCurrentSchedule(map < string, string > &stringTokens, map < string, int > &intTokens);
public: public:
cViewHelpers(void); cViewHelpers(void);
virtual ~cViewHelpers(void); virtual ~cViewHelpers(void);