mirror of
https://projects.vdr-developer.org/git/vdr-plugin-skindesigner.git
synced 2023-10-19 17:58:31 +02:00
added viewelement <lastrecordings> with information about 5 newest recordings in main menu
This commit is contained in:
parent
05912add7a
commit
e3ce79dd8c
3
HISTORY
3
HISTORY
@ -239,3 +239,6 @@ Version 0.3.2
|
||||
|
||||
Version 0.3.3
|
||||
|
||||
- added viewelement <lastrecordings> with information about 5 newest
|
||||
recordings in main menu
|
||||
|
||||
|
@ -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
|
||||
|
@ -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")) {
|
||||
|
@ -48,6 +48,7 @@ enum eViewElement {
|
||||
veSystemMemory,
|
||||
veTemperatures,
|
||||
veTimers,
|
||||
veLastRecordings,
|
||||
veCurrentSchedule,
|
||||
veMenuItem,
|
||||
veMenuCurrentItemDetail,
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
}
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user