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
mode of the currently displayed menu. <sortmode> can be used in
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 "libcore/helpers.h"
@ -19,6 +20,7 @@ cSDDisplayMenu::cSDDisplayMenu(cTemplate *menuTemplate) {
doOutput = false;
return;
}
SetCurrentRecording();
}
cSDDisplayMenu::~cSDDisplayMenu() {
@ -312,3 +314,19 @@ void cSDDisplayMenu::Flush(void) {
}
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;
ePluginMenuType pluginMenuType;
mutable cFont *textAreaFont;
void SetCurrentRecording(void);
protected:
int Tab(int n);
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>
<!-- 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
{subtitle} Subtitle of the current Schedule
{start} Start of current Schedule in hh:mm
{stop} End 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 (empty for recordings)
{duration} Duration of current Schedule in min
{durationhours} Duration, full hours
{minutes} Duration, rest of minutes
{elapsed} Elapsed time of current Schedule in min
{remaining} Remaining 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 (0 for recordings)
{hasPoster} true if poster is available
{posterpath} Full Path of Poster to use in image path attribute
{posterwidth} width of poster in pixel

View File

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

View File

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

View File

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

View File

@ -51,6 +51,7 @@ public:
class cDisplayMenuMainView : public cDisplayMenuView {
private:
bool initial;
string currentRecording;
void DrawTimers(void);
void DrawLastRecordings(void);
void DrawDiscUsage(void);
@ -62,7 +63,7 @@ private:
void DrawCurrentWeather(void);
void DrawCustomTokens(void);
public:
cDisplayMenuMainView(cTemplateView *tmplView, bool menuInit);
cDisplayMenuMainView(cTemplateView *tmplView, bool menuInit, string currentRecording);
virtual ~cDisplayMenuMainView();
void DrawStaticViewElements(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) {
ClearTokens();
SetCurrentSchedule(stringTokens, intTokens);
SetCurrentSchedule(currentRecording, stringTokens, intTokens);
ClearViewElement(veCurrentSchedule);
DrawViewElement(veCurrentSchedule, &stringTokens, &intTokens);
return true;

View File

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

View File

@ -801,15 +801,62 @@ bool cViewHelpers::SetSystemTemperatures(map < string, string > &stringTokens, m
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();
const cChannel *channel = NULL;
if (!device->Replaying() || device->Transferring()) {
channel = Channels.GetByNumber(device->CurrentChannel());
}
if (!channel)
return;
if (channel) {
SetCurrentScheduleFromChannel(channel, stringTokens, intTokens);
} else {
if (recName.size() == 0)
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;
cSchedulesLock SchedulesLock;
if (const cSchedules *Schedules = cSchedules::Schedules(SchedulesLock))
@ -818,6 +865,7 @@ void cViewHelpers::SetCurrentSchedule(map < string, string > &stringTokens, map
if (!event)
return;
intTokens.insert(pair<string,int>("islivetv", 1));
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()));
@ -888,39 +936,86 @@ void cViewHelpers::SetCurrentSchedule(map < string, string > &stringTokens, map
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::SetCurrentScheduleFromRecording(const cRecording *recording, map < string, string > &stringTokens, map < string, int > &intTokens) {
intTokens.insert(pair<string,int>("islivetv", 0));
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();
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;
if (pScraper) {
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;
callPoster.event = NULL;
callPoster.recording = recording;
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

@ -17,6 +17,8 @@ private:
int lastMemUsage;
void RecName(string &path, string &name, string &folder);
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:
void InitDevices(void);
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 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);
void SetCurrentSchedule(string recName, map < string, string > &stringTokens, map < string, int > &intTokens);
public:
cViewHelpers(void);
virtual ~cViewHelpers(void);