From 3a53ab95b6abd1458c6bd8ebf53c3a868a6f2fcb Mon Sep 17 00:00:00 2001 From: louis Date: Sun, 5 Apr 2015 16:56:15 +0200 Subject: [PATCH] added category indicator token to default menus --- HISTORY | 2 + displaymenu.c | 5 ++- libcore/imagecache.c | 5 ++- libcore/imagecache.h | 2 +- libtemplate/templateview.c | 6 +++ .../blackhole/xmlfiles/displaymenudefault.xml | 1 + .../metrixhd/xmlfiles/displaymenudefault.xml | 40 ++++++++++++++++--- skinskeleton/xmlfiles/displaymenudefault.xml | 11 ++++- views/displaymenuitemview.c | 39 +++++++++++++++++- views/displaymenuitemview.h | 6 +++ views/displaymenulistview.c | 31 ++++++++++---- views/displaymenulistview.h | 7 +++- views/displaymenurootview.c | 3 +- views/displaymenurootview.h | 2 + 14 files changed, 139 insertions(+), 21 deletions(-) diff --git a/HISTORY b/HISTORY index 6701c7f..b3fffd7 100644 --- a/HISTORY +++ b/HISTORY @@ -276,3 +276,5 @@ Version 0.4.0 its own datetime display - adapted Makefiles to work also in a LCLBLD environment - reverted Makefile changes in parts +- added category indicator token to default menus + diff --git a/displaymenu.c b/displaymenu.c index 241503b..51b6d30 100644 --- a/displaymenu.c +++ b/displaymenu.c @@ -202,7 +202,10 @@ void cSDDisplayMenu::SetItem(const char *Text, int Index, bool Current, bool Sel rootView->LockFlush(); eMenuCategory cat = MenuCategory(); if (cat == mcMain && rootView->SubViewAvailable()) { - list->AddMainMenuItem(Index, Text, Current, Selectable); + string plugName = list->AddMainMenuItem(Index, Text, Current, Selectable); + if (Current) { + rootView->SetSelectedPluginMainMenu(plugName); + } } else if (cat == mcSetup && rootView->SubViewAvailable()) { list->AddSetupMenuItem(Index, Text, Current, Selectable); } else { diff --git a/libcore/imagecache.c b/libcore/imagecache.c index 3d80f9b..af05777 100644 --- a/libcore/imagecache.c +++ b/libcore/imagecache.c @@ -188,7 +188,7 @@ cImage *cImageCache::GetIcon(eImageType type, string name, int width, int height return NULL; } -string cImageCache::GetIconName(string label, eMenuCategory cat) { +string cImageCache::GetIconName(string label, eMenuCategory cat, string plugName) { //if cat is set, use standard menu entries switch (cat) { case mcSchedule: @@ -267,6 +267,9 @@ string cImageCache::GetIconName(string label, eMenuCategory cat) { } } catch (...) {} //check for Plugins + if (plugName.size() > 0) { + return *cString::sprintf("pluginicons/%s", plugName.c_str()); + } for (int i = 0; ; i++) { cPlugin *p = cPluginManager::GetPlugin(i); if (p) { diff --git a/libcore/imagecache.h b/libcore/imagecache.h index 207dbb0..e8a0365 100644 --- a/libcore/imagecache.h +++ b/libcore/imagecache.h @@ -25,7 +25,7 @@ public: //icons void CacheIcon(eImageType type, string path, int width, int height); cImage *GetIcon(eImageType type, string name, int width, int height); - string GetIconName(string label, eMenuCategory cat = mcUndefined); + string GetIconName(string label, eMenuCategory cat = mcUndefined, string plugName = ""); bool MenuIconExists(string name); //skinparts void CacheSkinpart(string path, int width, int height); diff --git a/libtemplate/templateview.c b/libtemplate/templateview.c index 352b6c7..5af8229 100644 --- a/libtemplate/templateview.c +++ b/libtemplate/templateview.c @@ -637,6 +637,11 @@ void cTemplateView::SetFunctionDefinitions(void) { attributes.insert("mode"); funcsAllowed.insert(pair< string, set >(name, attributes)); + name = "listelement"; + attributes.clear(); + attributes.insert("debug"); + funcsAllowed.insert(pair< string, set >(name, attributes)); + name = "area"; attributes.clear(); attributes.insert("debug"); @@ -1147,6 +1152,7 @@ cTemplateViewMenu::cTemplateViewMenu(void) { //definition of allowed parameters for currentitems viewlist attributes.clear(); + attributes.insert("debug"); attributes.insert("delay"); attributes.insert("fadetime"); funcsAllowed.insert(pair< string, set >("currentelement", attributes)); diff --git a/skins/blackhole/xmlfiles/displaymenudefault.xml b/skins/blackhole/xmlfiles/displaymenudefault.xml index 766f02c..6259feb 100644 --- a/skins/blackhole/xmlfiles/displaymenudefault.xml +++ b/skins/blackhole/xmlfiles/displaymenudefault.xml @@ -59,6 +59,7 @@ + diff --git a/skins/metrixhd/xmlfiles/displaymenudefault.xml b/skins/metrixhd/xmlfiles/displaymenudefault.xml index 20ac1ba..e419ecc 100644 --- a/skins/metrixhd/xmlfiles/displaymenudefault.xml +++ b/skins/metrixhd/xmlfiles/displaymenudefault.xml @@ -113,7 +113,7 @@ - + - + - + + + + + + + + + + + + + + + + + + + + + + - + diff --git a/skinskeleton/xmlfiles/displaymenudefault.xml b/skinskeleton/xmlfiles/displaymenudefault.xml index 8f38b18..64036ff 100644 --- a/skinskeleton/xmlfiles/displaymenudefault.xml +++ b/skinskeleton/xmlfiles/displaymenudefault.xml @@ -28,7 +28,16 @@ {column5width} proposed width of column5 {column6width} proposed width of column6 {current} true if column is currently selected - {separator} true if column is a list separator + {separator} true if column is a list separator + + A dynamic token is set to indicate the current menu category or the plugin which is currently running. + With that it is possible to display different default menus with an individual style. + If a setup menu is diplayed, the token + {setup} is set to true + For the commands menu + {commands} is set to true + If a plugin is running, a token called as the name of the plugin is set to true + {pluginname} is set to true --> diff --git a/views/displaymenuitemview.c b/views/displaymenuitemview.c index c0d3b42..1ce4066 100644 --- a/views/displaymenuitemview.c +++ b/views/displaymenuitemview.c @@ -106,6 +106,7 @@ cDisplayMenuItemDefaultView::cDisplayMenuItemDefaultView(cTemplateViewList *tmpl this->tabs = tabs; this->tabWidths = tabWidths; maxTabs = cSkinDisplayMenu::MaxTabs; + menuCategory = ""; } cDisplayMenuItemDefaultView::~cDisplayMenuItemDefaultView() { @@ -138,6 +139,9 @@ void cDisplayMenuItemDefaultView::SetTokens(void) { intTokens.insert(pair("current", current)); intTokens.insert(pair("separator", !selectable)); intTokens.insert(pair("nummenuitem", num+1)); + if (menuCategory.size() > 0) { + intTokens.insert(pair(menuCategory, 1)); + } } void cDisplayMenuItemDefaultView::Prepare(void) { @@ -173,6 +177,10 @@ cDisplayMenuItemMainView::cDisplayMenuItemMainView(cTemplateViewList *tmplList, number = ""; label = ""; icon = ""; + isPlugin = false; + plugName = ""; + SplitMenuText(); + CheckPlugins(); } cDisplayMenuItemMainView::~cDisplayMenuItemMainView() { @@ -193,8 +201,11 @@ void cDisplayMenuItemMainView::SetTokens(void) { void cDisplayMenuItemMainView::Prepare(void) { ArrangeContainer(); - SplitMenuText(); - icon = imgCache->GetIconName(label); + if (isPlugin) { + icon = imgCache->GetIconName(label, mcUnknown, plugName); + } else { + icon = imgCache->GetIconName(label); + } } @@ -214,6 +225,12 @@ void cDisplayMenuItemMainView::Render(void) { dirty = false; } +string cDisplayMenuItemMainView::GetPluginName(void) { + if (!isPlugin) + return ""; + return plugName; +} + void cDisplayMenuItemMainView::Debug(void) { esyslog("skindesigner: Main Menu Item ---------------"); cDisplayMenuItemView::Debug(); @@ -266,6 +283,24 @@ void cDisplayMenuItemMainView::SplitMenuText(void) { } } +void cDisplayMenuItemMainView::CheckPlugins(void) { + for (int i = 0; ; i++) { + cPlugin *p = cPluginManager::GetPlugin(i); + if (p) { + const char *mainMenuEntry = p->MainMenuEntry(); + if (mainMenuEntry) { + string plugMainEntry = mainMenuEntry; + if (label.substr(0, plugMainEntry.size()) == plugMainEntry) { + isPlugin = true; + plugName = p->Name() ? p->Name() : ""; + return; + } + } + } else + break; + } +} + /************************************************************* * cDisplayMenuItemSchedulesView *************************************************************/ diff --git a/views/displaymenuitemview.h b/views/displaymenuitemview.h index e9cfd5f..1108571 100644 --- a/views/displaymenuitemview.h +++ b/views/displaymenuitemview.h @@ -42,11 +42,13 @@ private: int *tabWidths; string *tabTexts; int maxTabs; + string menuCategory; public: cDisplayMenuItemDefaultView(cTemplateViewList *tmplList, string *tabTexts, int *tabs, int *tabWidths, bool current, bool selectable); virtual ~cDisplayMenuItemDefaultView(); void SetTabTexts(string *tabTexts); void SetTokens(void); + void SetMenuCategory(string cat) { menuCategory = cat; }; void Prepare(void); void Render(void); void Debug(void); @@ -54,17 +56,21 @@ public: class cDisplayMenuItemMainView: public cDisplayMenuItemView { private: + bool isPlugin; + string plugName; string text; string number; string label; string icon; void SplitMenuText(void); + void CheckPlugins(void); public: cDisplayMenuItemMainView(cTemplateViewList *tmplList, string itemText, bool current, bool selectable); virtual ~cDisplayMenuItemMainView(); void SetTokens(void); void Prepare(void); void Render(void); + string GetPluginName(void); void Debug(void); }; diff --git a/views/displaymenulistview.c b/views/displaymenulistview.c index 3a51b82..87845d7 100644 --- a/views/displaymenulistview.c +++ b/views/displaymenulistview.c @@ -2,7 +2,7 @@ #include "displaymenulistview.h" -cDisplayMenuListView::cDisplayMenuListView(cTemplateViewList *tmplList, int count) { +cDisplayMenuListView::cDisplayMenuListView(cTemplateViewList *tmplList, int count, eMenuCategory cat, string currentPlug) { oneColumn = true; this->tmplList = tmplList; if (count < 0) { @@ -15,6 +15,8 @@ cDisplayMenuListView::cDisplayMenuListView(cTemplateViewList *tmplList, int coun intTokens.insert(pair("numelements", count)); tmplList->CalculateListParameters(&intTokens); } + this->cat = cat; + this->currentPlug = currentPlug; menuItems = new cDisplayMenuItemView*[itemCount]; for (int i=0; iSetMenuCategory(GetDefaultMenuCategory()); menuItems[index] = item; } -void cDisplayMenuListView::AddMainMenuItem(int index, const char *itemText, bool current, bool selectable) { +string cDisplayMenuListView::AddMainMenuItem(int index, const char *itemText, bool current, bool selectable) { if (index >= itemCount) - return; + return ""; if (menuItems[index]) { - menuItems[index]->SetCurrent(current); - return; + cDisplayMenuItemMainView *menuItem = dynamic_cast(menuItems[index]); + if (!menuItem) + return ""; + menuItem->SetCurrent(current); + return menuItem->GetPluginName(); } - cDisplayMenuItemView *item = new cDisplayMenuItemMainView(tmplList, itemText, current, selectable); + cDisplayMenuItemMainView *item = new cDisplayMenuItemMainView(tmplList, itemText, current, selectable); menuItems[index] = item; + return item->GetPluginName(); } void cDisplayMenuListView::AddSetupMenuItem(int index, const char *itemText, bool current, bool selectable) { @@ -241,3 +248,13 @@ void cDisplayMenuListView::Debug(void) { } } } + +string cDisplayMenuListView::GetDefaultMenuCategory(void) { + if (cat == mcSchedule || cat == mcScheduleNow || cat == mcScheduleNext) + return "schedule"; + else if (cat >= mcPluginSetup && cat <= mcSetupPlugins) + return "setup"; + else if (cat == mcCommand) + return "commands"; + return currentPlug; +} diff --git a/views/displaymenulistview.h b/views/displaymenulistview.h index a407020..60758cf 100644 --- a/views/displaymenulistview.h +++ b/views/displaymenulistview.h @@ -8,20 +8,23 @@ class cDisplayMenuListView { private: cTemplateViewList *tmplList; + eMenuCategory cat; + string currentPlug; int itemCount; cDisplayMenuItemView **menuItems; int *tabs; int *tabWidths; bool oneColumn; + string GetDefaultMenuCategory(void); public: - cDisplayMenuListView(cTemplateViewList *tmplList, int count = -1); + cDisplayMenuListView(cTemplateViewList *tmplList, int count, eMenuCategory cat = mcUnknown, string currentPlug = ""); virtual ~cDisplayMenuListView(); void Clear(void); void SetTabs(int tab1, int tab2, int tab3, int tab4, int tab5); int GetMaxItems(void) { return itemCount; }; int GetListWidth(void); void AddDefaultMenuItem(int index, string *tabTexts, bool current, bool selectable); - void AddMainMenuItem(int index, const char *itemText, bool current, bool selectable); + string AddMainMenuItem(int index, const char *itemText, bool current, bool selectable); void AddSetupMenuItem(int index, const char *itemText, bool current, bool selectable); void AddSchedulesMenuItem(int index, const cEvent *event, const cChannel *channel, eTimerMatch timerMatch, eMenuCategory cat, bool isEpgSearchFav, bool current, bool selectable); void AddChannelsMenuItem(int index, const cChannel *channel, bool withProvider, bool current, bool selectable); diff --git a/views/displaymenurootview.c b/views/displaymenurootview.c index 5d429cd..c101d38 100644 --- a/views/displaymenurootview.c +++ b/views/displaymenurootview.c @@ -7,6 +7,7 @@ cDisplayMenuRootView::cDisplayMenuRootView(cTemplateView *rootView) : cView(rootView) { cat = mcUndefined; + selectedPluginMainMenu = ""; sortMode = msmUnknown; sortModeLast = msmUnknown; menuTitle = ""; @@ -208,7 +209,7 @@ void cDisplayMenuRootView::SetMenu(eMenuCategory menuCat, bool menuInit) { cTemplateViewList *tmplMenuItems = subView->GetViewList(vlMenuItem); if (!tmplMenuItems) return; - listView = new cDisplayMenuListView(tmplMenuItems); + listView = new cDisplayMenuListView(tmplMenuItems, -1, menuCat, selectedPluginMainMenu); } else { //Create detailed view detailView = new cDisplayMenuDetailView(subView); diff --git a/views/displaymenurootview.h b/views/displaymenurootview.h index 4a250bc..79b4b56 100644 --- a/views/displaymenurootview.h +++ b/views/displaymenurootview.h @@ -15,6 +15,7 @@ enum ePluginMenuType { class cDisplayMenuRootView : public cView, public cViewHelpers { private: eMenuCategory cat; + string selectedPluginMainMenu; eMenuSortMode sortMode; eMenuSortMode sortModeLast; eSubView viewType; @@ -51,6 +52,7 @@ public: virtual ~cDisplayMenuRootView(); bool createOsd(void); void SetMenu(eMenuCategory menuCat, bool menuInit); + void SetSelectedPluginMainMenu(string name) { selectedPluginMainMenu = name; }; void SetSortMode(eMenuSortMode sortMode); void SetCurrentRecording(string rec) { currentRecording = rec; }; void CorrectDefaultMenu(void);