summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian <zerov83@gmail.com>2016-03-30 22:30:50 +0200
committerChristian <zerov83@gmail.com>2016-03-30 22:30:50 +0200
commiteef71c613bdd5b6c5b2e944a49ba43c314b73b0f (patch)
treec7d93bb8acb2fe92374575180305ce6fe1190ccb
parentee8662006d8bd06e79f12ee5143ecebd05eb2a75 (diff)
downloadvdr-plugin-plex-eef71c613bdd5b6c5b2e944a49ba43c314b73b0f.tar.gz
vdr-plugin-plex-eef71c613bdd5b6c5b2e944a49ba43c314b73b0f.tar.bz2
New viewelement "time" for detailview
-rw-r--r--detailView.cpp41
-rw-r--r--detailView.h3
-rw-r--r--plex.cpp4
-rw-r--r--plexSdOsd.cpp7
-rw-r--r--templates/plug-plex-detail.xml18
-rw-r--r--tokendefinitions.h3
6 files changed, 72 insertions, 4 deletions
diff --git a/detailView.cpp b/detailView.cpp
index 397247e..83152b0 100644
--- a/detailView.cpp
+++ b/detailView.cpp
@@ -8,6 +8,7 @@ cDetailView::cDetailView(std::shared_ptr<skindesignerapi::cOsdView> detailView,
m_pfooter = std::shared_ptr<skindesignerapi::cViewElement>(detailView->GetViewElement((int)eViewElementsDetail::footer));
m_pInfo = std::shared_ptr<skindesignerapi::cViewElement>(detailView->GetViewElement((int)eViewElementsDetail::info));
m_pScrollbar = std::shared_ptr<skindesignerapi::cViewElement>(detailView->GetViewElement((int)eViewElementsDetail::scrollbar));
+ m_pWatch = std::shared_ptr<skindesignerapi::cViewElement>(detailView->GetViewElement((int)eViewElementsDetail::watch));
m_pVideo = video;
m_drawall = true;
@@ -53,6 +54,7 @@ void cDetailView::Draw()
DrawFooter();
DrawInfo();
DrawScrollbar();
+ DrawTime();
}
void cDetailView::Clear()
@@ -62,6 +64,7 @@ void cDetailView::Clear()
m_pScrollbar->Clear();
m_pfooter->Clear();
m_pGrid->Clear();
+ m_pWatch->Clear();
}
void cDetailView::DrawBackground()
@@ -158,6 +161,44 @@ void cDetailView::DrawScrollbar()
m_pScrollbar->Display();
}
+bool cDetailView::DrawTime()
+{
+ time_t t = time(0); // get time now
+ struct tm * now = localtime(&t);
+ int sec = now->tm_sec;
+ if (sec == m_lastsecond)
+ return false;
+
+ int min = now->tm_min;
+ int hour = now->tm_hour;
+ int hourMinutes = hour%12 * 5 + min / 12;
+
+ char monthname[20];
+ char monthshort[10];
+ strftime(monthshort, sizeof(monthshort), "%b", now);
+ strftime(monthname, sizeof(monthname), "%B", now);
+
+ m_pWatch->Clear();
+ m_pWatch->ClearTokens();
+ m_pWatch->AddIntToken((int)eTokenTimeInt::sec, sec);
+ m_pWatch->AddIntToken((int)eTokenTimeInt::min, min);
+ m_pWatch->AddIntToken((int)eTokenTimeInt::hour, hour);
+ m_pWatch->AddIntToken((int)eTokenTimeInt::hmins, hourMinutes);
+ m_pWatch->AddIntToken((int)eTokenTimeInt::year, now->tm_year + 1900);
+ m_pWatch->AddIntToken((int)eTokenTimeInt::day, now->tm_mday);
+ m_pWatch->AddStringToken((int)eTokenTimeStr::time, *TimeString(t));
+ m_pWatch->AddStringToken((int)eTokenTimeStr::monthname, monthname);
+ m_pWatch->AddStringToken((int)eTokenTimeStr::monthnameshort, monthshort);
+ m_pWatch->AddStringToken((int)eTokenTimeStr::month, *cString::sprintf("%02d", now->tm_mon + 1));
+ m_pWatch->AddStringToken((int)eTokenTimeStr::dayleadingzero, *cString::sprintf("%02d", now->tm_mday));
+ m_pWatch->AddStringToken((int)eTokenTimeStr::dayname, *WeekDayNameFull(now->tm_wday));
+ m_pWatch->AddStringToken((int)eTokenTimeStr::daynameshort, *WeekDayName(now->tm_wday));
+ m_pWatch->Display();
+
+ m_lastsecond = sec;
+ return true;
+}
+
eOSState cDetailView::NavigateSelect()
{
if(m_setIterator) return eOSState::osContinue;
diff --git a/detailView.h b/detailView.h
index 38cbdba..9398fc2 100644
--- a/detailView.h
+++ b/detailView.h
@@ -19,15 +19,18 @@ public:
virtual eOSState NavigateBack();
plexclient::Video* GetVideo() { return m_pVideo; };
virtual void Clear();
+ bool DrawTime();
private:
std::shared_ptr<skindesignerapi::cViewElement> m_pBackground;
std::shared_ptr<skindesignerapi::cViewElement> m_pfooter;
std::shared_ptr<skindesignerapi::cViewElement> m_pInfo;
std::shared_ptr<skindesignerapi::cViewElement> m_pScrollbar;
+ std::shared_ptr<skindesignerapi::cViewElement> m_pWatch;
plexclient::Video *m_pVideo;
bool m_drawall;
+ int m_lastsecond;
void DrawBackground();
void DrawFooter();
diff --git a/plex.cpp b/plex.cpp
index 7aff066..9eb47ee 100644
--- a/plex.cpp
+++ b/plex.cpp
@@ -135,6 +135,10 @@ bool cMyPlugin::Start(void)
skindesignerapi::cTokenContainer *tkDetailExtraGrid = new skindesignerapi::cTokenContainer();
cPlexSdOsd::DefineGridTokens(tkDetailExtraGrid);
m_pPlugStruct->RegisterViewGrid((int)eViews::detailView, (int)eViewDetailViewGrids::extras, "extragrid", tkDetailExtraGrid);
+
+ skindesignerapi::cTokenContainer *tkDetailWatch = new skindesignerapi::cTokenContainer();
+ cPlexSdOsd::DefineWatchTokens(tkDetailWatch);
+ m_pPlugStruct->RegisterViewElement((int)eViews::detailView, (int)eViewElementsDetail::watch, "time", tkDetailWatch);
if (!skindesignerapi::SkindesignerAPI::RegisterPlugin(m_pPlugStruct)) {
diff --git a/plexSdOsd.cpp b/plexSdOsd.cpp
index 67ab462..5e93b1b 100644
--- a/plexSdOsd.cpp
+++ b/plexSdOsd.cpp
@@ -86,7 +86,6 @@ eOSState cPlexSdOsd::ProcessKey(eKeys Key)
return eOSState::osContinue;
}
}
- if (m_pBrowserGrid->DrawTime()) m_pBrowserGrid->Flush();
state = ProcessKeyBrowserView(Key);
}
@@ -98,7 +97,7 @@ eOSState cPlexSdOsd::ProcessKeyDetailView(eKeys Key)
{
eOSState state = eOSState::osContinue;
plexclient::Video* vid = NULL;
-
+
switch (Key & ~k_Repeat) {
case kUp:
if(m_pDetailGrid->NavigateUp()) Flush();
@@ -154,6 +153,8 @@ eOSState cPlexSdOsd::ProcessKeyDetailView(eKeys Key)
state = eOSState::osEnd;
}
+ if (state != osEnd && m_pDetailGrid->DrawTime()) m_pDetailGrid->Flush();
+
return state;
}
@@ -221,6 +222,8 @@ eOSState cPlexSdOsd::ProcessKeyBrowserView(eKeys Key)
state = eOSState::osEnd;
}
+ if (state != osEnd && m_pBrowserGrid->DrawTime()) m_pBrowserGrid->Flush();
+
return state;
}
diff --git a/templates/plug-plex-detail.xml b/templates/plug-plex-detail.xml
index f48a81d..d63c2e8 100644
--- a/templates/plug-plex-detail.xml
+++ b/templates/plug-plex-detail.xml
@@ -2,7 +2,23 @@
<!DOCTYPE displayplugin SYSTEM "../../../dtd/displayplugin.dtd">
<displayplugin x="0" y="0" width="100%" height="100%" fadetime="0" scaletvx="0" scaletvy="0" scaletvwidth="100%" scaletvheight="100%">
-
+ <!-- Available Variables time:
+ {time} timestring in hh:mm
+ {sec} current seconds
+ {min} current minutes
+ {hour} current hours
+ {hmins} current "hourminutes" to display an hour hand
+ {day} day in digits
+ {dayleadingzero} day in digits with leading 0
+ {dayname} Full name of the day
+ {daynameshort} Short 3 char name of the day
+ {month} month in digits with leading 0
+ {monthname} Full name of the month
+ {monthnameshort} 3 letter abbrivation of month name
+ {year} year in yyyy
+ -->
+ <viewelement name="time">
+ </viewelement>
<!-- Available Variables message:
{displaymessage} bool: message displayed?
{message} string: message to display
diff --git a/tokendefinitions.h b/tokendefinitions.h
index cf6036c..e4e9d0a 100644
--- a/tokendefinitions.h
+++ b/tokendefinitions.h
@@ -11,7 +11,8 @@ enum class eViewElementsDetail {
footer,
info,
message,
- scrollbar
+ scrollbar,
+ watch
};
enum class eViewElementsRoot {