refresh custom token display with each custom token change

This commit is contained in:
louis 2015-06-05 14:48:45 +02:00
parent 57244494b6
commit b6a6ea2f6b
12 changed files with 65 additions and 9 deletions

View File

@ -361,3 +361,6 @@ Version 0.5.1
Version 0.5.2 Version 0.5.2
- only close OSD when a skin is successfully updated from Git
- refresh custom token display with each custom token change

View File

@ -174,6 +174,9 @@ void cSDDisplayChannel::Flush(void) {
channelView->DrawBackground(); channelView->DrawBackground();
channelView->DrawSignalBackground(); channelView->DrawSignalBackground();
channelView->DrawCurrentWeather(); channelView->DrawCurrentWeather();
}
if (initial || channelView->CustomTokenChange()) {
channelView->DrawCustomTokens(); channelView->DrawCustomTokens();
} }

View File

@ -110,6 +110,8 @@ void cSDDisplayReplay::Flush(void) {
replayView->DoFadeIn(); replayView->DoFadeIn();
initial = false; initial = false;
} else { } else {
if (replayView->CustomTokenChange())
replayView->DrawCustomTokens();
replayView->Flush(); replayView->Flush();
} }
} }

View File

@ -4,6 +4,9 @@
#include <locale.h> #include <locale.h>
cGlobals::cGlobals(void) { cGlobals::cGlobals(void) {
customTokenChange = 0;
lastCustomTokenQuery = 0;
fonts.insert(pair<string, string>("vdrOsd", Setup.FontOsd)); fonts.insert(pair<string, string>("vdrOsd", Setup.FontOsd));
fonts.insert(pair<string, string>("vdrFix", Setup.FontFix)); fonts.insert(pair<string, string>("vdrFix", Setup.FontFix));
fonts.insert(pair<string, string>("vdrSml", Setup.FontSml)); fonts.insert(pair<string, string>("vdrSml", Setup.FontSml));
@ -198,11 +201,13 @@ string cGlobals::DoTranslate(string token) {
void cGlobals::AddCustomInt(string &name, int value) { void cGlobals::AddCustomInt(string &name, int value) {
customIntTokens.erase(name); customIntTokens.erase(name);
customIntTokens.insert(pair<string,int>(name, value)); customIntTokens.insert(pair<string,int>(name, value));
customTokenChange = time(0);
} }
void cGlobals::AddCustomString(string &name, string &value) { void cGlobals::AddCustomString(string &name, string &value) {
customStringTokens.erase(name); customStringTokens.erase(name);
customStringTokens.insert(pair<string,string>(name, value)); customStringTokens.insert(pair<string,string>(name, value));
customTokenChange = time(0);
} }
bool cGlobals::GetCustomInt(string name, int &val) { bool cGlobals::GetCustomInt(string name, int &val) {
@ -214,6 +219,24 @@ bool cGlobals::GetCustomInt(string name, int &val) {
return false; return false;
} }
map <string, string> cGlobals::GetCustomStringTokens(void) {
lastCustomTokenQuery = time(0);
return customStringTokens;
}
map <string, int> 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) { void cGlobals::ListCustomTokens(void) {
for (map<string, string>::iterator it = customStringTokens.begin(); it != customStringTokens.end(); it++) { for (map<string, string>::iterator it = customStringTokens.begin(); it != customStringTokens.end(); it++) {
dsyslog("skindesigner: custom string token \"%s\" = \"%s\"", (it->first).c_str(), (it->second).c_str()); dsyslog("skindesigner: custom string token \"%s\" = \"%s\"", (it->first).c_str(), (it->second).c_str());

View File

@ -20,6 +20,8 @@ typedef uint32_t tColor;
class cGlobals { class cGlobals {
private: private:
time_t customTokenChange;
time_t lastCustomTokenQuery;
string language; string language;
string DoTranslate(string token); string DoTranslate(string token);
map <string, tColor> colors; map <string, tColor> colors;
@ -50,8 +52,9 @@ public:
void AddCustomInt(string &name, int value); void AddCustomInt(string &name, int value);
void AddCustomString(string &name, string &value); void AddCustomString(string &name, string &value);
bool GetCustomInt(string name, int &val); bool GetCustomInt(string name, int &val);
map <string, string> GetCustomStringTokens(void) { return customStringTokens; }; map <string, string> GetCustomStringTokens(void);
map <string, int> GetCustomIntTokens(void) { return customIntTokens; }; map <string, int> GetCustomIntTokens(void);
bool CustomTokenChange(void);
void ListCustomTokens(void); void ListCustomTokens(void);
void Debug(void); void Debug(void);
}; };

View File

@ -125,6 +125,7 @@ public:
bool GetScalingWindow(cRect &scalingWindow); bool GetScalingWindow(cRect &scalingWindow);
map<string,string> GetCustomStringTokens(void) { return globals->GetCustomStringTokens(); }; map<string,string> GetCustomStringTokens(void) { return globals->GetCustomStringTokens(); };
map<string,int> GetCustomIntTokens(void) { return globals->GetCustomIntTokens(); }; map<string,int> GetCustomIntTokens(void) { return globals->GetCustomIntTokens(); };
bool CustomTokenChange(void) { return globals->CustomTokenChange(); };
//Checks for parsing template XML files //Checks for parsing template XML files
bool ValidSubView(const char *subView); bool ValidSubView(const char *subView);
bool ValidViewElement(const char *viewElement); bool ValidViewElement(const char *viewElement);

View File

@ -556,10 +556,18 @@ void cDisplayChannelView::DrawCustomTokens(void) {
} else { } else {
map < string, string > stringTokens = tmplView->GetCustomStringTokens(); map < string, string > stringTokens = tmplView->GetCustomStringTokens();
map < string, int > intTokens = tmplView->GetCustomIntTokens(); map < string, int > intTokens = tmplView->GetCustomIntTokens();
ClearViewElement(veCustomTokens);
DrawViewElement(veCustomTokens, &stringTokens, &intTokens); DrawViewElement(veCustomTokens, &stringTokens, &intTokens);
} }
} }
bool cDisplayChannelView::CustomTokenChange(void) {
if (!tmplView)
return false;
return tmplView->CustomTokenChange();
}
void cDisplayChannelView::DrawCurrentWeather(void) { void cDisplayChannelView::DrawCurrentWeather(void) {
if (!ExecuteViewElement(veCurrentWeather)) { if (!ExecuteViewElement(veCurrentWeather)) {
return; return;

View File

@ -49,6 +49,7 @@ public:
void ClearChannelGroups(void); void ClearChannelGroups(void);
void DisplayMessage(eMessageType Type, const char *Text); void DisplayMessage(eMessageType Type, const char *Text);
void DrawCustomTokens(void); void DrawCustomTokens(void);
bool CustomTokenChange(void);
void DrawCurrentWeather(void); void DrawCurrentWeather(void);
void DoStart(void) { Start(); }; void DoStart(void) { Start(); };
void Flush(void) { DoFlush(); }; void Flush(void) { DoFlush(); };

View File

@ -293,7 +293,6 @@ void cDisplayMenuMainView::DrawStaticViewElements(void) {
DrawTemperatures(); DrawTemperatures();
DrawCurrentSchedule(); DrawCurrentSchedule();
DrawCurrentWeather(); DrawCurrentWeather();
DrawCustomTokens();
} }
bool cDisplayMenuMainView::DrawDynamicViewElements(void) { bool cDisplayMenuMainView::DrawDynamicViewElements(void) {
@ -301,9 +300,9 @@ bool cDisplayMenuMainView::DrawDynamicViewElements(void) {
bool memChanged = DrawMemory(); bool memChanged = DrawMemory();
bool vdrChanged = DrawVdrStats(); bool vdrChanged = DrawVdrStats();
bool devicesChanged = DrawDevices(); bool devicesChanged = DrawDevices();
bool customTokensChanged = DrawCustomTokens();
initial = false; initial = false;
return loadChanged || memChanged || vdrChanged || devicesChanged; return loadChanged || memChanged || vdrChanged || devicesChanged || customTokensChanged;
} }
void cDisplayMenuMainView::DrawTimers(void) { void cDisplayMenuMainView::DrawTimers(void) {
@ -588,12 +587,15 @@ void cDisplayMenuMainView::DrawCurrentWeather(void) {
} }
} }
void cDisplayMenuMainView::DrawCustomTokens(void) { bool cDisplayMenuMainView::DrawCustomTokens(void) {
if (!ExecuteViewElement(veCustomTokens)) { if (!ExecuteViewElement(veCustomTokens)) {
return; return false;
} }
if (!tmplView) if (!tmplView)
return; return false;
if (!initial && !tmplView->CustomTokenChange())
return false;
if (DetachViewElement(veCustomTokens)) { if (DetachViewElement(veCustomTokens)) {
cViewElement *viewElement = GetViewElement(veCustomTokens); cViewElement *viewElement = GetViewElement(veCustomTokens);
@ -608,8 +610,10 @@ void cDisplayMenuMainView::DrawCustomTokens(void) {
} else { } else {
map < string, string > stringTokens = tmplView->GetCustomStringTokens(); map < string, string > stringTokens = tmplView->GetCustomStringTokens();
map < string, int > intTokens = tmplView->GetCustomIntTokens(); map < string, int > intTokens = tmplView->GetCustomIntTokens();
ClearViewElement(veCustomTokens);
DrawViewElement(veCustomTokens, &stringTokens, &intTokens); DrawViewElement(veCustomTokens, &stringTokens, &intTokens);
} }
return true;
} }
/************************************************************************ /************************************************************************

View File

@ -62,7 +62,7 @@ private:
bool DrawDevices(void); bool DrawDevices(void);
void DrawCurrentSchedule(void); void DrawCurrentSchedule(void);
void DrawCurrentWeather(void); void DrawCurrentWeather(void);
void DrawCustomTokens(void); bool DrawCustomTokens(void);
public: public:
cDisplayMenuMainView(cTemplateView *tmplView, bool menuInit, string currentRecording); cDisplayMenuMainView(cTemplateView *tmplView, bool menuInit, string currentRecording);
virtual ~cDisplayMenuMainView(); virtual ~cDisplayMenuMainView();

View File

@ -457,9 +457,16 @@ void cDisplayReplayView::DrawCustomTokens(void) {
return; return;
map < string, string > stringTokens = tmplView->GetCustomStringTokens(); map < string, string > stringTokens = tmplView->GetCustomStringTokens();
map < string, int > intTokens = tmplView->GetCustomIntTokens(); map < string, int > intTokens = tmplView->GetCustomIntTokens();
ClearViewElement(veCustomTokens);
DrawViewElement(veCustomTokens, &stringTokens, &intTokens); DrawViewElement(veCustomTokens, &stringTokens, &intTokens);
} }
bool cDisplayReplayView::CustomTokenChange(void) {
if (!tmplView)
return false;
return tmplView->CustomTokenChange();
}
/**************************************************************************************** /****************************************************************************************
* Private Functions * Private Functions
*****************************************************************************************/ *****************************************************************************************/

View File

@ -44,6 +44,7 @@ public:
void ClearOnPause(void); void ClearOnPause(void);
void DelayOnPause(void); void DelayOnPause(void);
void DrawCustomTokens(void); void DrawCustomTokens(void);
bool CustomTokenChange(void);
void DoFadeIn(void) { Start(); }; void DoFadeIn(void) { Start(); };
void Flush(void) { DoFlush(); }; void Flush(void) { DoFlush(); };
}; };