use recording info for <currentschedule> viewelement in main menu if recording is replayed

This commit is contained in:
louis 2015-04-01 10:14:26 +02:00
parent 203754e204
commit b98fee9668
20 changed files with 175 additions and 50 deletions

View File

@ -251,5 +251,5 @@ Version 0.3.3
- added viewelement <sortmode> in displaymenu to display the sort - added viewelement <sortmode> in displaymenu to display the sort
mode of the currently displayed menu. <sortmode> can be used in mode of the currently displayed menu. <sortmode> can be used in
any list menu, implementation in displaymenu.xml is default any list menu, implementation in displaymenu.xml is default
- use recording info for <currentschedule> viewelement in main menu
if recording is replayed. New token {islivetv} indicates this.

View File

@ -1,3 +1,4 @@
#include <vdr/player.h>
#include "displaymenu.h" #include "displaymenu.h"
#include "libcore/helpers.h" #include "libcore/helpers.h"
@ -19,6 +20,7 @@ cSDDisplayMenu::cSDDisplayMenu(cTemplate *menuTemplate) {
doOutput = false; doOutput = false;
return; return;
} }
SetCurrentRecording();
} }
cSDDisplayMenu::~cSDDisplayMenu() { cSDDisplayMenu::~cSDDisplayMenu() {
@ -312,3 +314,19 @@ void cSDDisplayMenu::Flush(void) {
} }
state = vsIdle; state = vsIdle;
} }
void cSDDisplayMenu::SetCurrentRecording(void) {
cControl *control = cControl::Control();
if (!control) {
return;
}
const cRecording *recording = control->GetRecording();
if (!recording) {
return;
}
string recFileName = "";
if (recording->FileName()) {
recFileName = recording->FileName();
}
rootView->SetCurrentRecording(recFileName);
}

View File

@ -21,6 +21,7 @@ private:
int pluginMenu; int pluginMenu;
ePluginMenuType pluginMenuType; ePluginMenuType pluginMenuType;
mutable cFont *textAreaFont; mutable cFont *textAreaFont;
void SetCurrentRecording(void);
protected: protected:
int Tab(int n); int Tab(int n);
public: public:

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -88,15 +88,17 @@
</temperatures> </temperatures>
<!-- Available Variables currentschedule: <!-- Available Variables currentschedule:
if a recording is displayed, info of this recording is used
{islivetv} true if info is from livetv, false if recording is displayed
{title} Title of the current Schedule {title} Title of the current Schedule
{subtitle} Subtitle of the current Schedule {subtitle} Subtitle of the current Schedule
{start} Start of current Schedule in hh:mm {start} Start of current Schedule in hh:mm (empty for recordings)
{stop} End of current Schedule in hh:mm {stop} End of current Schedule in hh:mm (empty for recordings)
{duration} Duration of current Schedule in min {duration} Duration of current Schedule in min
{durationhours} Duration, full hours {durationhours} Duration, full hours
{minutes} Duration, rest of minutes {minutes} Duration, rest of minutes
{elapsed} Elapsed time of current Schedule in min {elapsed} Elapsed time of current Schedule in min (0 for recordings)
{remaining} Remaining time of current Schedule in min {remaining} Remaining time of current Schedule in min (0 for recordings)
{hasPoster} true if poster is available {hasPoster} true if poster is available
{posterpath} Full Path of Poster to use in image path attribute {posterpath} Full Path of Poster to use in image path attribute
{posterwidth} width of poster in pixel {posterwidth} width of poster in pixel

View File

@ -10,6 +10,7 @@ cDisplayMenuRootView::cDisplayMenuRootView(cTemplateView *rootView) : cView(root
sortMode = msmUnknown; sortMode = msmUnknown;
sortModeLast = msmUnknown; sortModeLast = msmUnknown;
menuTitle = ""; menuTitle = "";
currentRecording = "";
viewType = svUndefined; viewType = svUndefined;
subView = NULL; subView = NULL;
subViewAvailable = false; subViewAvailable = false;
@ -186,7 +187,7 @@ void cDisplayMenuRootView::SetMenu(eMenuCategory menuCat, bool menuInit) {
//Create new View //Create new View
switch (newViewType) { switch (newViewType) {
case svMenuMain: case svMenuMain:
view = new cDisplayMenuMainView(subView, menuInit); view = new cDisplayMenuMainView(subView, menuInit, currentRecording);
break; break;
case svMenuSchedules: case svMenuSchedules:
if (subViewAvailable) if (subViewAvailable)

View File

@ -27,6 +27,7 @@ private:
cDisplayMenuView *view; cDisplayMenuView *view;
cDisplayMenuListView *listView; cDisplayMenuListView *listView;
cDisplayMenuDetailView *detailView; cDisplayMenuDetailView *detailView;
string currentRecording;
string menuTitle; string menuTitle;
string buttonTexts[4]; string buttonTexts[4];
bool defaultBackgroundDrawn; bool defaultBackgroundDrawn;
@ -50,6 +51,7 @@ public:
bool createOsd(void); bool createOsd(void);
void SetMenu(eMenuCategory menuCat, bool menuInit); void SetMenu(eMenuCategory menuCat, bool menuInit);
void SetSortMode(eMenuSortMode sortMode); void SetSortMode(eMenuSortMode sortMode);
void SetCurrentRecording(string rec) { currentRecording = rec; };
void CorrectDefaultMenu(void); void CorrectDefaultMenu(void);
void SetPluginMenu(string name, int menu, int type); void SetPluginMenu(string name, int menu, int type);
void SetTitle(const char *title); void SetTitle(const char *title);

View File

@ -227,7 +227,8 @@ void cDisplayMenuView::Action(void) {
* cDisplayMenuMainView * cDisplayMenuMainView
************************************************************************/ ************************************************************************/
cDisplayMenuMainView::cDisplayMenuMainView(cTemplateView *tmplView, bool menuInit) : cDisplayMenuView(tmplView, menuInit) { cDisplayMenuMainView::cDisplayMenuMainView(cTemplateView *tmplView, bool menuInit, string currentRecording) : cDisplayMenuView(tmplView, menuInit) {
this->currentRecording = currentRecording;
initial = true; initial = true;
InitDevices(); InitDevices();
} }
@ -458,7 +459,7 @@ void cDisplayMenuMainView::DrawCurrentSchedule(void) {
if (DetachViewElement(veCurrentSchedule)) { if (DetachViewElement(veCurrentSchedule)) {
cViewElement *viewElement = GetViewElement(veCurrentSchedule); cViewElement *viewElement = GetViewElement(veCurrentSchedule);
if (!viewElement) { if (!viewElement) {
viewElement = new cViewElementCurrentSchedule(tmplView->GetViewElement(veCurrentSchedule)); viewElement = new cViewElementCurrentSchedule(tmplView->GetViewElement(veCurrentSchedule), currentRecording);
AddViewElement(veCurrentSchedule, viewElement); AddViewElement(veCurrentSchedule, viewElement);
viewElement->Start(); viewElement->Start();
} else { } else {
@ -468,7 +469,7 @@ void cDisplayMenuMainView::DrawCurrentSchedule(void) {
} else { } else {
map < string, string > stringTokens; map < string, string > stringTokens;
map < string, int > intTokens; map < string, int > intTokens;
SetCurrentSchedule(stringTokens, intTokens); SetCurrentSchedule(currentRecording, stringTokens, intTokens);
ClearViewElement(veCurrentSchedule); ClearViewElement(veCurrentSchedule);
DrawViewElement(veCurrentSchedule, &stringTokens, &intTokens); DrawViewElement(veCurrentSchedule, &stringTokens, &intTokens);
} }

View File

@ -51,6 +51,7 @@ public:
class cDisplayMenuMainView : public cDisplayMenuView { class cDisplayMenuMainView : public cDisplayMenuView {
private: private:
bool initial; bool initial;
string currentRecording;
void DrawTimers(void); void DrawTimers(void);
void DrawLastRecordings(void); void DrawLastRecordings(void);
void DrawDiscUsage(void); void DrawDiscUsage(void);
@ -62,7 +63,7 @@ private:
void DrawCurrentWeather(void); void DrawCurrentWeather(void);
void DrawCustomTokens(void); void DrawCustomTokens(void);
public: public:
cDisplayMenuMainView(cTemplateView *tmplView, bool menuInit); cDisplayMenuMainView(cTemplateView *tmplView, bool menuInit, string currentRecording);
virtual ~cDisplayMenuMainView(); virtual ~cDisplayMenuMainView();
void DrawStaticViewElements(void); void DrawStaticViewElements(void);
bool DrawDynamicViewElements(void); bool DrawDynamicViewElements(void);

View File

@ -212,12 +212,13 @@ bool cViewElementTemperature::Render(void) {
/********************************************************************************************************************/ /********************************************************************************************************************/
cViewElementCurrentSchedule::cViewElementCurrentSchedule(cTemplateViewElement *tmplViewElement) : cViewElement(tmplViewElement) { cViewElementCurrentSchedule::cViewElementCurrentSchedule(cTemplateViewElement *tmplViewElement, string currentRecording) : cViewElement(tmplViewElement) {
this->currentRecording = currentRecording;
} }
bool cViewElementCurrentSchedule::Render(void) { bool cViewElementCurrentSchedule::Render(void) {
ClearTokens(); ClearTokens();
SetCurrentSchedule(stringTokens, intTokens); SetCurrentSchedule(currentRecording, stringTokens, intTokens);
ClearViewElement(veCurrentSchedule); ClearViewElement(veCurrentSchedule);
DrawViewElement(veCurrentSchedule, &stringTokens, &intTokens); DrawViewElement(veCurrentSchedule, &stringTokens, &intTokens);
return true; return true;

View File

@ -120,8 +120,9 @@ public:
class cViewElementCurrentSchedule : public cViewElement, public cViewHelpers { class cViewElementCurrentSchedule : public cViewElement, public cViewHelpers {
private: private:
string currentRecording;
public: public:
cViewElementCurrentSchedule(cTemplateViewElement *tmplViewElement); cViewElementCurrentSchedule(cTemplateViewElement *tmplViewElement, string currentRecording);
virtual ~cViewElementCurrentSchedule() {}; virtual ~cViewElementCurrentSchedule() {};
bool Render(void); bool Render(void);
}; };

View File

@ -801,15 +801,62 @@ bool cViewHelpers::SetSystemTemperatures(map < string, string > &stringTokens, m
return true; return true;
} }
void cViewHelpers::SetCurrentSchedule(map < string, string > &stringTokens, map < string, int > &intTokens) { void cViewHelpers::SetCurrentSchedule(string recName, map < string, string > &stringTokens, map < string, int > &intTokens) {
cDevice *device = cDevice::PrimaryDevice(); cDevice *device = cDevice::PrimaryDevice();
const cChannel *channel = NULL; const cChannel *channel = NULL;
if (!device->Replaying() || device->Transferring()) { if (!device->Replaying() || device->Transferring()) {
channel = Channels.GetByNumber(device->CurrentChannel()); channel = Channels.GetByNumber(device->CurrentChannel());
} }
if (!channel) if (channel) {
SetCurrentScheduleFromChannel(channel, stringTokens, intTokens);
} else {
if (recName.size() == 0)
return; return;
const cRecording *recording = new cRecording(recName.c_str());
if (recording) {
SetCurrentScheduleFromRecording(recording, stringTokens, intTokens);
delete recording;
}
}
}
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;
}
}
void cViewHelpers::SetCurrentScheduleFromChannel(const cChannel *channel, map < string, string > &stringTokens, map < string, int > &intTokens) {
const cEvent *event = NULL; const cEvent *event = NULL;
cSchedulesLock SchedulesLock; cSchedulesLock SchedulesLock;
if (const cSchedules *Schedules = cSchedules::Schedules(SchedulesLock)) if (const cSchedules *Schedules = cSchedules::Schedules(SchedulesLock))
@ -818,6 +865,7 @@ void cViewHelpers::SetCurrentSchedule(map < string, string > &stringTokens, map
if (!event) if (!event)
return; return;
intTokens.insert(pair<string,int>("islivetv", 1));
stringTokens.insert(pair<string,string>("title", (event->Title())?event->Title():"")); 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>("subtitle", (event->ShortText())?event->ShortText():""));
stringTokens.insert(pair<string,string>("start", *event->GetTimeString())); stringTokens.insert(pair<string,string>("start", *event->GetTimeString()));
@ -888,39 +936,86 @@ void cViewHelpers::SetCurrentSchedule(map < string, string > &stringTokens, map
intTokens.insert(pair<string,int>("hasbanner", hasBanner)); intTokens.insert(pair<string,int>("hasbanner", hasBanner));
} }
void cViewHelpers::RecName(string &path, string &name, string &folder) { void cViewHelpers::SetCurrentScheduleFromRecording(const cRecording *recording, map < string, string > &stringTokens, map < string, int > &intTokens) {
size_t delim = path.find_last_of('~'); intTokens.insert(pair<string,int>("islivetv", 0));
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) { string recFullName = recording->Name() ? recording->Name() : "";
string recName = "";
string recFolder = "";
RecName(recFullName, recName, recFolder);
stringTokens.insert(pair<string,string>("title", recName));
const cRecordingInfo *info = recording->Info();
if (info) {
stringTokens.insert(pair<string,string>("subtitle", info->ShortText() ? info->ShortText() : ""));
} else {
stringTokens.insert(pair<string,string>("subtitle", recFolder));
}
stringTokens.insert(pair<string,string>("start", ""));
stringTokens.insert(pair<string,string>("stop", ""));
intTokens.insert(pair<string,int>("duration", recording->LengthInSeconds() / 60));
intTokens.insert(pair<string,int>("durationhours", recording->LengthInSeconds() / 3600));
stringTokens.insert(pair<string,string>("durationminutes", *cString::sprintf("%.2d", (recording->LengthInSeconds() / 60)%60)));
intTokens.insert(pair<string,int>("elapsed", 0));
intTokens.insert(pair<string,int>("remaining", 0));
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(); static cPlugin *pScraper = GetScraperPlugin();
if (!pScraper) if (pScraper) {
return; ScraperGetPosterBannerV2 call;
call.event = NULL;
call.recording = recording;
if (pScraper->Service("GetPosterBannerV2", &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; ScraperGetPoster callPoster;
callPoster.event = NULL; callPoster.event = NULL;
callPoster.recording = rec; callPoster.recording = recording;
if (pScraper->Service("GetPoster", &callPoster)) { if (pScraper->Service("GetPoster", &callPoster)) {
posterWidth = callPoster.poster.width; posterWidth = callPoster.poster.width;
posterHeight = callPoster.poster.height; posterHeight = callPoster.poster.height;
path = callPoster.poster.path; posterPath = callPoster.poster.path;
hasPoster = true; 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

@ -17,6 +17,8 @@ private:
int lastMemUsage; int lastMemUsage;
void RecName(string &path, string &name, string &folder); void RecName(string &path, string &name, string &folder);
void RecPoster(const cRecording *rec, int &posterWidth, int &posterHeight, string &path, bool &hasPoster); void RecPoster(const cRecording *rec, int &posterWidth, int &posterHeight, string &path, bool &hasPoster);
void SetCurrentScheduleFromChannel(const cChannel *channel, map < string, string > &stringTokens, map < string, int > &intTokens);
void SetCurrentScheduleFromRecording(const cRecording *recording, map < string, string > &stringTokens, map < string, int > &intTokens);
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);
@ -34,7 +36,7 @@ protected:
bool SetSystemLoad(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 SetSystemMemory(map < string, string > &stringTokens, map < string, int > &intTokens);
bool SetSystemTemperatures(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); void SetCurrentSchedule(string recName, map < string, string > &stringTokens, map < string, int > &intTokens);
public: public:
cViewHelpers(void); cViewHelpers(void);
virtual ~cViewHelpers(void); virtual ~cViewHelpers(void);