From b6a6ea2f6bf697b94a489521b774f2b8dc67629a Mon Sep 17 00:00:00 2001 From: louis Date: Fri, 5 Jun 2015 14:48:45 +0200 Subject: [PATCH] refresh custom token display with each custom token change --- HISTORY | 3 +++ displaychannel.c | 3 +++ displayreplay.c | 2 ++ libtemplate/globals.c | 23 +++++++++++++++++++++++ libtemplate/globals.h | 7 +++++-- libtemplate/templateview.h | 1 + views/displaychannelview.c | 8 ++++++++ views/displaychannelview.h | 1 + views/displaymenuview.c | 16 ++++++++++------ views/displaymenuview.h | 2 +- views/displayreplayview.c | 7 +++++++ views/displayreplayview.h | 1 + 12 files changed, 65 insertions(+), 9 deletions(-) diff --git a/HISTORY b/HISTORY index 672b3d0..6bfb6f3 100644 --- a/HISTORY +++ b/HISTORY @@ -361,3 +361,6 @@ Version 0.5.1 Version 0.5.2 +- only close OSD when a skin is successfully updated from Git +- refresh custom token display with each custom token change + diff --git a/displaychannel.c b/displaychannel.c index 4d67fab..ff18da7 100644 --- a/displaychannel.c +++ b/displaychannel.c @@ -174,6 +174,9 @@ void cSDDisplayChannel::Flush(void) { channelView->DrawBackground(); channelView->DrawSignalBackground(); channelView->DrawCurrentWeather(); + } + + if (initial || channelView->CustomTokenChange()) { channelView->DrawCustomTokens(); } diff --git a/displayreplay.c b/displayreplay.c index 130f0e4..3d5e346 100644 --- a/displayreplay.c +++ b/displayreplay.c @@ -110,6 +110,8 @@ void cSDDisplayReplay::Flush(void) { replayView->DoFadeIn(); initial = false; } else { + if (replayView->CustomTokenChange()) + replayView->DrawCustomTokens(); replayView->Flush(); } } diff --git a/libtemplate/globals.c b/libtemplate/globals.c index e884b24..702bf8e 100644 --- a/libtemplate/globals.c +++ b/libtemplate/globals.c @@ -4,6 +4,9 @@ #include cGlobals::cGlobals(void) { + customTokenChange = 0; + lastCustomTokenQuery = 0; + fonts.insert(pair("vdrOsd", Setup.FontOsd)); fonts.insert(pair("vdrFix", Setup.FontFix)); fonts.insert(pair("vdrSml", Setup.FontSml)); @@ -198,11 +201,13 @@ string cGlobals::DoTranslate(string token) { void cGlobals::AddCustomInt(string &name, int value) { customIntTokens.erase(name); customIntTokens.insert(pair(name, value)); + customTokenChange = time(0); } void cGlobals::AddCustomString(string &name, string &value) { customStringTokens.erase(name); customStringTokens.insert(pair(name, value)); + customTokenChange = time(0); } bool cGlobals::GetCustomInt(string name, int &val) { @@ -214,6 +219,24 @@ bool cGlobals::GetCustomInt(string name, int &val) { return false; } +map cGlobals::GetCustomStringTokens(void) { + lastCustomTokenQuery = time(0); + return customStringTokens; +} + +map cGlobals::GetCustomIntTokens(void) { + lastCustomTokenQuery = time(0); + return customIntTokens; +} + +bool cGlobals::CustomTokenChange(void) { + if (!lastCustomTokenQuery) + return true; + if (lastCustomTokenQuery < customTokenChange) + return true; + return false; +} + void cGlobals::ListCustomTokens(void) { for (map::iterator it = customStringTokens.begin(); it != customStringTokens.end(); it++) { dsyslog("skindesigner: custom string token \"%s\" = \"%s\"", (it->first).c_str(), (it->second).c_str()); diff --git a/libtemplate/globals.h b/libtemplate/globals.h index 9629e63..d566fac 100644 --- a/libtemplate/globals.h +++ b/libtemplate/globals.h @@ -20,6 +20,8 @@ typedef uint32_t tColor; class cGlobals { private: + time_t customTokenChange; + time_t lastCustomTokenQuery; string language; string DoTranslate(string token); map colors; @@ -50,8 +52,9 @@ public: void AddCustomInt(string &name, int value); void AddCustomString(string &name, string &value); bool GetCustomInt(string name, int &val); - map GetCustomStringTokens(void) { return customStringTokens; }; - map GetCustomIntTokens(void) { return customIntTokens; }; + map GetCustomStringTokens(void); + map GetCustomIntTokens(void); + bool CustomTokenChange(void); void ListCustomTokens(void); void Debug(void); }; diff --git a/libtemplate/templateview.h b/libtemplate/templateview.h index 64add2a..d592b22 100644 --- a/libtemplate/templateview.h +++ b/libtemplate/templateview.h @@ -125,6 +125,7 @@ public: bool GetScalingWindow(cRect &scalingWindow); map GetCustomStringTokens(void) { return globals->GetCustomStringTokens(); }; map GetCustomIntTokens(void) { return globals->GetCustomIntTokens(); }; + bool CustomTokenChange(void) { return globals->CustomTokenChange(); }; //Checks for parsing template XML files bool ValidSubView(const char *subView); bool ValidViewElement(const char *viewElement); diff --git a/views/displaychannelview.c b/views/displaychannelview.c index 255dc3e..47537ec 100644 --- a/views/displaychannelview.c +++ b/views/displaychannelview.c @@ -556,10 +556,18 @@ void cDisplayChannelView::DrawCustomTokens(void) { } else { map < string, string > stringTokens = tmplView->GetCustomStringTokens(); map < string, int > intTokens = tmplView->GetCustomIntTokens(); + ClearViewElement(veCustomTokens); DrawViewElement(veCustomTokens, &stringTokens, &intTokens); } } +bool cDisplayChannelView::CustomTokenChange(void) { + if (!tmplView) + return false; + return tmplView->CustomTokenChange(); +} + + void cDisplayChannelView::DrawCurrentWeather(void) { if (!ExecuteViewElement(veCurrentWeather)) { return; diff --git a/views/displaychannelview.h b/views/displaychannelview.h index 068b27a..9468d7d 100644 --- a/views/displaychannelview.h +++ b/views/displaychannelview.h @@ -49,6 +49,7 @@ public: void ClearChannelGroups(void); void DisplayMessage(eMessageType Type, const char *Text); void DrawCustomTokens(void); + bool CustomTokenChange(void); void DrawCurrentWeather(void); void DoStart(void) { Start(); }; void Flush(void) { DoFlush(); }; diff --git a/views/displaymenuview.c b/views/displaymenuview.c index d76095c..aba112f 100644 --- a/views/displaymenuview.c +++ b/views/displaymenuview.c @@ -293,7 +293,6 @@ void cDisplayMenuMainView::DrawStaticViewElements(void) { DrawTemperatures(); DrawCurrentSchedule(); DrawCurrentWeather(); - DrawCustomTokens(); } bool cDisplayMenuMainView::DrawDynamicViewElements(void) { @@ -301,9 +300,9 @@ bool cDisplayMenuMainView::DrawDynamicViewElements(void) { bool memChanged = DrawMemory(); bool vdrChanged = DrawVdrStats(); bool devicesChanged = DrawDevices(); + bool customTokensChanged = DrawCustomTokens(); initial = false; - return loadChanged || memChanged || vdrChanged || devicesChanged; - + return loadChanged || memChanged || vdrChanged || devicesChanged || customTokensChanged; } void cDisplayMenuMainView::DrawTimers(void) { @@ -588,12 +587,15 @@ void cDisplayMenuMainView::DrawCurrentWeather(void) { } } -void cDisplayMenuMainView::DrawCustomTokens(void) { +bool cDisplayMenuMainView::DrawCustomTokens(void) { if (!ExecuteViewElement(veCustomTokens)) { - return; + return false; } if (!tmplView) - return; + return false; + + if (!initial && !tmplView->CustomTokenChange()) + return false; if (DetachViewElement(veCustomTokens)) { cViewElement *viewElement = GetViewElement(veCustomTokens); @@ -608,8 +610,10 @@ void cDisplayMenuMainView::DrawCustomTokens(void) { } else { map < string, string > stringTokens = tmplView->GetCustomStringTokens(); map < string, int > intTokens = tmplView->GetCustomIntTokens(); + ClearViewElement(veCustomTokens); DrawViewElement(veCustomTokens, &stringTokens, &intTokens); } + return true; } /************************************************************************ diff --git a/views/displaymenuview.h b/views/displaymenuview.h index 60a859e..7fbd9a3 100644 --- a/views/displaymenuview.h +++ b/views/displaymenuview.h @@ -62,7 +62,7 @@ private: bool DrawDevices(void); void DrawCurrentSchedule(void); void DrawCurrentWeather(void); - void DrawCustomTokens(void); + bool DrawCustomTokens(void); public: cDisplayMenuMainView(cTemplateView *tmplView, bool menuInit, string currentRecording); virtual ~cDisplayMenuMainView(); diff --git a/views/displayreplayview.c b/views/displayreplayview.c index 400807f..385ed2e 100644 --- a/views/displayreplayview.c +++ b/views/displayreplayview.c @@ -457,9 +457,16 @@ void cDisplayReplayView::DrawCustomTokens(void) { return; map < string, string > stringTokens = tmplView->GetCustomStringTokens(); map < string, int > intTokens = tmplView->GetCustomIntTokens(); + ClearViewElement(veCustomTokens); DrawViewElement(veCustomTokens, &stringTokens, &intTokens); } +bool cDisplayReplayView::CustomTokenChange(void) { + if (!tmplView) + return false; + return tmplView->CustomTokenChange(); +} + /**************************************************************************************** * Private Functions *****************************************************************************************/ diff --git a/views/displayreplayview.h b/views/displayreplayview.h index 87de67d..f776d3d 100644 --- a/views/displayreplayview.h +++ b/views/displayreplayview.h @@ -44,6 +44,7 @@ public: void ClearOnPause(void); void DelayOnPause(void); void DrawCustomTokens(void); + bool CustomTokenChange(void); void DoFadeIn(void) { Start(); }; void Flush(void) { DoFlush(); }; };