diff options
| author | louis <louis.braun@gmx.de> | 2015-03-29 13:29:59 +0200 |
|---|---|---|
| committer | louis <louis.braun@gmx.de> | 2015-03-29 13:29:59 +0200 |
| commit | e3ce79dd8c01222cb65ba1d2190fa463703b9b96 (patch) | |
| tree | c3928c9aa6ec58e0fab0995483480237b23fb256 | |
| parent | 05912add7a19b78413eb1030669963284ca24dec (diff) | |
| download | vdr-plugin-skindesigner-e3ce79dd8c01222cb65ba1d2190fa463703b9b96.tar.gz vdr-plugin-skindesigner-e3ce79dd8c01222cb65ba1d2190fa463703b9b96.tar.bz2 | |
added viewelement <lastrecordings> with information about 5 newest recordings in main menu
| -rw-r--r-- | HISTORY | 3 | ||||
| -rw-r--r-- | dtd/displaymenu.dtd | 11 | ||||
| -rw-r--r-- | libtemplate/templateview.c | 8 | ||||
| -rw-r--r-- | libtemplate/templateviewelement.h | 1 | ||||
| -rw-r--r-- | skinskeleton/xmlfiles/displaymenumain.xml | 15 | ||||
| -rw-r--r-- | views/displaymenuview.c | 30 | ||||
| -rw-r--r-- | views/displaymenuview.h | 1 | ||||
| -rw-r--r-- | views/displayviewelements.c | 19 | ||||
| -rw-r--r-- | views/displayviewelements.h | 8 | ||||
| -rw-r--r-- | views/viewhelpers.c | 76 | ||||
| -rw-r--r-- | views/viewhelpers.h | 3 |
11 files changed, 172 insertions, 3 deletions
@@ -239,3 +239,6 @@ Version 0.3.2 Version 0.3.3 +- added viewelement <lastrecordings> with information about 5 newest + recordings in main menu + diff --git a/dtd/displaymenu.dtd b/dtd/displaymenu.dtd index 4b6d248..ead958c 100644 --- a/dtd/displaymenu.dtd +++ b/dtd/displaymenu.dtd @@ -123,6 +123,15 @@ condition CDATA #IMPLIED
>
+<!ELEMENT lastrecordings (area|areascroll)*>
+<!ATTLIST lastrecordings
+ detached CDATA #IMPLIED
+ delay CDATA #IMPLIED
+ fadetime CDATA #IMPLIED
+ debug CDATA #IMPLIED
+ condition CDATA #IMPLIED
+>
+
<!ELEMENT customtokens (area|areascroll)*>
<!ATTLIST customtokens
detached CDATA #IMPLIED
@@ -165,7 +174,7 @@ <!ELEMENT menumain (background | header | datetime | time | colorbuttons | scrollbar | timers |
discusage | devices | systemload | systemmemory | temperatures | currentschedule |
- currentweather | customtokens | menuitems)*>
+ currentweather | lastrecordings | customtokens | menuitems)*>
<!ATTLIST menumain
x CDATA #REQUIRED
y CDATA #REQUIRED
diff --git a/libtemplate/templateview.c b/libtemplate/templateview.c index 1383ed2..df523a1 100644 --- a/libtemplate/templateview.c +++ b/libtemplate/templateview.c @@ -1213,6 +1213,7 @@ void cTemplateViewMenu::SetViewElements(void) { viewElementsAllowed.insert("systemmemory"); viewElementsAllowed.insert("temperatures"); viewElementsAllowed.insert("timers"); + viewElementsAllowed.insert("lastrecordings"); viewElementsAllowed.insert("devices"); viewElementsAllowed.insert("currentweather"); viewElementsAllowed.insert("currentschedule"); @@ -1303,13 +1304,16 @@ string cTemplateViewMenu::GetViewElementName(eViewElement ve) { case veTimers: name = "Timers"; break; + case veLastRecordings: + name = "Last Recordings"; + break; case veCurrentSchedule: name = "Current Schedule"; break; case veCurrentWeather: name = "Current Weather"; break; - case veCustomTokens: + case veCustomTokens: name = "Custom Tokens"; break; case veDevices: @@ -1424,6 +1428,8 @@ void cTemplateViewMenu::AddPixmap(string sViewElement, cTemplatePixmap *pix, vec ve = veTemperatures; } else if (!sViewElement.compare("timers")) { ve = veTimers; + } else if (!sViewElement.compare("lastrecordings")) { + ve = veLastRecordings; } else if (!sViewElement.compare("currentschedule")) { ve = veCurrentSchedule; } else if (!sViewElement.compare("customtokens")) { diff --git a/libtemplate/templateviewelement.h b/libtemplate/templateviewelement.h index 4e4ea00..6f1adcc 100644 --- a/libtemplate/templateviewelement.h +++ b/libtemplate/templateviewelement.h @@ -48,6 +48,7 @@ enum eViewElement { veSystemMemory,
veTemperatures,
veTimers,
+ veLastRecordings,
veCurrentSchedule,
veMenuItem,
veMenuCurrentItemDetail,
diff --git a/skinskeleton/xmlfiles/displaymenumain.xml b/skinskeleton/xmlfiles/displaymenumain.xml index e37bfcc..61816bb 100644 --- a/skinskeleton/xmlfiles/displaymenumain.xml +++ b/skinskeleton/xmlfiles/displaymenumain.xml @@ -19,6 +19,21 @@ <timers> </timers> + <!-- Available Variables lastrecordings: 5 newest recordings + {recordings[]} array with 5 newest recordings + {recordings[name]} name of recording + {recordings[seriesname]} series name if available + {recordings[date]} date of recording in dd.mm.yy + {recordings[time]} time of recording in hh:mm + {recordings[duration]} duration of recording in minutes + {recordings[hasposter]} true if poster available + {recordings[posterpath]} path of poster if available + {recordings[posterwidth]} width of poster + {recordings[posterheight]} height of poster + --> + <lastrecordings> + </lastrecordings> + <!-- Available Variables discusage: {freetime} available disc capacity in hh:mm {freepercent} available disc capacity in percent diff --git a/views/displaymenuview.c b/views/displaymenuview.c index 4e7b0d5..408c088 100644 --- a/views/displaymenuview.c +++ b/views/displaymenuview.c @@ -205,6 +205,7 @@ cDisplayMenuMainView::~cDisplayMenuMainView() { void cDisplayMenuMainView::DrawStaticViewElements(void) { DrawTimers(); + DrawLastRecordings(); DrawDiscUsage(); DrawTemperatures(); DrawCurrentSchedule(); @@ -250,6 +251,35 @@ void cDisplayMenuMainView::DrawTimers(void) { } } +void cDisplayMenuMainView::DrawLastRecordings(void) { + if (!ExecuteViewElement(veLastRecordings)) { + return; + } + + if (DetachViewElement(veLastRecordings)) { + cViewElement *viewElement = GetViewElement(veLastRecordings); + if (!viewElement) { + viewElement = new cViewElementLastRecordings(tmplView->GetViewElement(veLastRecordings)); + AddViewElement(veLastRecordings, viewElement); + viewElement->Start(); + } else { + if (!viewElement->Starting()) + viewElement->Render(); + } + } else { + map < string, string > stringTokens; + map < string, int > intTokens; + map < string, vector< map< string, string > > > recordingLoopTokens; + vector< map< string, string > > lastRecordings; + + SetLastRecordings(&intTokens, &stringTokens, &lastRecordings); + recordingLoopTokens.insert(pair< string, vector< map< string, string > > >("recordings", lastRecordings)); + + ClearViewElement(veLastRecordings); + DrawViewElement(veLastRecordings, &stringTokens, &intTokens, &recordingLoopTokens); + } +} + void cDisplayMenuMainView::DrawDiscUsage(void) { if (!ExecuteViewElement(veDiscUsage)) { return; diff --git a/views/displaymenuview.h b/views/displaymenuview.h index dbf8acf..ecea005 100644 --- a/views/displaymenuview.h +++ b/views/displaymenuview.h @@ -38,6 +38,7 @@ class cDisplayMenuMainView : public cDisplayMenuView { private: bool initial; void DrawTimers(void); + void DrawLastRecordings(void); void DrawDiscUsage(void); bool DrawLoad(void); bool DrawMemory(void); diff --git a/views/displayviewelements.c b/views/displayviewelements.c index 61760df..8f2b476 100644 --- a/views/displayviewelements.c +++ b/views/displayviewelements.c @@ -129,7 +129,6 @@ bool cViewElementTimers::Render(void) { vector< map< string, string > > timers; SetTimers(&intTokens, &stringTokens, &timers); - timerLoopTokens.insert(pair< string, vector< map< string, string > > >("timers", timers)); ClearViewElement(veTimers); @@ -139,6 +138,24 @@ bool cViewElementTimers::Render(void) { /********************************************************************************************************************/ +cViewElementLastRecordings::cViewElementLastRecordings(cTemplateViewElement *tmplViewElement) : cViewElement(tmplViewElement) { +} + +bool cViewElementLastRecordings::Render(void) { + ClearTokens(); + map < string, vector< map< string, string > > > recordingLoopTokens; + vector< map< string, string > > lastRecordings; + + SetLastRecordings(&intTokens, &stringTokens, &lastRecordings); + recordingLoopTokens.insert(pair< string, vector< map< string, string > > >("recordings", lastRecordings)); + + ClearViewElement(veLastRecordings); + DrawViewElement(veLastRecordings, &stringTokens, &intTokens, &recordingLoopTokens); + return true; +} + +/********************************************************************************************************************/ + cViewElementDiscUsage::cViewElementDiscUsage(cTemplateViewElement *tmplViewElement) : cViewElement(tmplViewElement) { } diff --git a/views/displayviewelements.h b/views/displayviewelements.h index 46492f4..5ccf2d9 100644 --- a/views/displayviewelements.h +++ b/views/displayviewelements.h @@ -78,6 +78,14 @@ public: bool Render(void); }; +class cViewElementLastRecordings : public cViewElement, public cViewHelpers { +private: +public: + cViewElementLastRecordings(cTemplateViewElement *tmplViewElement); + virtual ~cViewElementLastRecordings() {}; + bool Render(void); +}; + class cViewElementDiscUsage : public cViewElement, public cViewHelpers { private: public: diff --git a/views/viewhelpers.c b/views/viewhelpers.c index f5bb1ef..3e50434 100644 --- a/views/viewhelpers.c +++ b/views/viewhelpers.c @@ -612,6 +612,45 @@ void cViewHelpers::SetTimers(map<string,int> *intTokens, map<string,string> *str } } +void cViewHelpers::SetLastRecordings(map<string,int> *intTokens, map<string,string> *stringTokens, vector<map<string,string> > *lastRecordings) { + RecordingsSortMode = rsmTime; + Recordings.Sort(); + int found = 0; + for (cRecording *recording = Recordings.Last(); recording; recording = Recordings.Prev(recording)) { + map< string, string > recVals; + string recFullPath = recording->Name() ? recording->Name() : ""; + string recName = ""; + string recPath = ""; + RecName(recFullPath, recName, recPath); + stringstream recDuration; + int dur = recording->LengthInSeconds()/60; + recDuration << dur; + string posterPath = ""; + int posterWidth = 0; + int posterHeight = 0; + bool hasPoster = false; + RecPoster(recording, posterWidth, posterHeight, posterPath, hasPoster); + stringstream sPosterWidth; + sPosterWidth << posterWidth; + stringstream sPosterHeight; + sPosterHeight << posterHeight; + string sHasPoster = hasPoster ? "1" : "0"; + recVals.insert(pair< string, string >("recordings[name]", recName)); + recVals.insert(pair< string, string >("recordings[seriesname]", recPath)); + recVals.insert(pair< string, string >("recordings[date]", *ShortDateString(recording->Start()))); + recVals.insert(pair< string, string >("recordings[time]", *TimeString(recording->Start()))); + recVals.insert(pair< string, string >("recordings[duration]", recDuration.str())); + recVals.insert(pair< string, string >("recordings[hasposter]", sHasPoster)); + recVals.insert(pair< string, string >("recordings[posterpath]", posterPath)); + recVals.insert(pair< string, string >("recordings[posterwidth]", sPosterWidth.str())); + recVals.insert(pair< string, string >("recordings[posterheight]", sPosterHeight.str())); + lastRecordings->push_back(recVals); + found++; + if (found == 5) + break; + } +} + 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)); @@ -845,3 +884,40 @@ void cViewHelpers::SetCurrentSchedule(map < string, string > &stringTokens, map stringTokens.insert(pair<string,string>("bannerpath", bannerPath)); intTokens.insert(pair<string,int>("hasbanner", hasBanner)); } + +void cViewHelpers::RecName(string &path, string &name, string &folder) { + size_t delim = path.find_last_of('~'); + if (delim == string::npos) { + name = path; + if (name.find('%') == 0) { + name = name.substr(1); + } + return; + } + name = path.substr(delim+1); + if (name.find('%') == 0) { + name = name.substr(1); + } + folder = path.substr(0, delim); + size_t delim2 = folder.find_last_of('~'); + if (delim2 == string::npos) { + return; + } + folder = folder.substr(delim2+1); +} + +void cViewHelpers::RecPoster(const cRecording *rec, int &posterWidth, int &posterHeight, string &path, bool &hasPoster) { + static cPlugin *pScraper = GetScraperPlugin(); + if (!pScraper) + return; + ScraperGetPoster callPoster; + callPoster.event = NULL; + callPoster.recording = rec; + if (pScraper->Service("GetPoster", &callPoster)) { + posterWidth = callPoster.poster.width; + posterHeight = callPoster.poster.height; + path = callPoster.poster.path; + hasPoster = true; + } +} + diff --git a/views/viewhelpers.h b/views/viewhelpers.h index 4d54677..1223a78 100644 --- a/views/viewhelpers.h +++ b/views/viewhelpers.h @@ -15,6 +15,8 @@ private: int lastMinute; double lastSystemLoad; int lastMemUsage; + void RecName(string &path, string &name, string &folder); + void RecPoster(const cRecording *rec, int &posterWidth, int &posterHeight, string &path, bool &hasPoster); protected: void InitDevices(void); bool SetDevices(bool initial, map<string,int> *intTokens, vector<map<string,string> > *devices); @@ -26,6 +28,7 @@ protected: bool SetDate(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 SetLastRecordings(map<string,int> *intTokens, map<string,string> *stringTokens, vector<map<string,string> > *lastRecordings); 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); |
