diff options
Diffstat (limited to 'menu.c')
-rw-r--r-- | menu.c | 35 |
1 files changed, 26 insertions, 9 deletions
@@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: menu.c 3.11 2013/10/21 08:05:59 kls Exp $ + * $Id: menu.c 3.12 2013/11/03 13:27:17 kls Exp $ */ #include "menu.h" @@ -719,9 +719,11 @@ cMenuFolder::cMenuFolder(const char *Title, cNestedItemList *NestedItemList, con list = nestedItemList = NestedItemList; firstFolder = NULL; editing = false; + helpKeys = -1; Set(); - SetHelpKeys(); DescendPath(Path); + Display(); + SetHelpKeys(); } cMenuFolder::cMenuFolder(const char *Title, cList<cNestedItem> *List, cNestedItemList *NestedItemList, const char *Dir, const char *Path) @@ -733,14 +735,28 @@ cMenuFolder::cMenuFolder(const char *Title, cList<cNestedItem> *List, cNestedIte dir = Dir; firstFolder = NULL; editing = false; + helpKeys = -1; Set(); - SetHelpKeys(); DescendPath(Path); + Display(); + SetHelpKeys(); } void cMenuFolder::SetHelpKeys(void) { - SetHelp(firstFolder ? tr("Button$Select") : NULL, tr("Button$New"), firstFolder ? tr("Button$Delete") : NULL, firstFolder ? tr("Button$Edit") : NULL); + if (HasSubMenu()) + return; + int NewHelpKeys = 0; + if (firstFolder) { + if (cMenuFolderItem *Folder = (cMenuFolderItem *)Get(Current())) { + if (Folder->Folder()->SubItems()) + NewHelpKeys = 1; + } + } + if (NewHelpKeys != helpKeys) { + helpKeys = NewHelpKeys; + SetHelp(NewHelpKeys > 0 ? tr("Button$Open") : NULL, tr("Button$New"), firstFolder ? tr("Button$Delete") : NULL, firstFolder ? tr("Button$Edit") : NULL); + } } void cMenuFolder::Set(const char *CurrentFolder) @@ -769,7 +785,7 @@ void cMenuFolder::DescendPath(const char *Path) for (cMenuFolderItem *Folder = (cMenuFolderItem *)firstFolder; Folder; Folder = (cMenuFolderItem *)Next(Folder)) { if (strncmp(Folder->Folder()->Text(), Path, p - Path) == 0) { SetCurrent(Folder); - if (Folder->Folder()->SubItems()) + if (Folder->Folder()->SubItems() && strchr(p + 1, FOLDERDELIMCHAR)) AddSubMenu(new cMenuFolder(Title(), Folder->Folder()->SubItems(), nestedItemList, !isempty(dir) ? *cString::sprintf("%s%c%s", *dir, FOLDERDELIMCHAR, Folder->Folder()->Text()) : Folder->Folder()->Text(), p + 1)); break; } @@ -778,12 +794,12 @@ void cMenuFolder::DescendPath(const char *Path) } } -eOSState cMenuFolder::Select(void) +eOSState cMenuFolder::Select(bool Open) { if (firstFolder) { cMenuFolderItem *Folder = (cMenuFolderItem *)Get(Current()); if (Folder) { - if (Folder->Folder()->SubItems()) + if (Open && Folder->Folder()->SubItems()) return AddSubMenu(new cMenuFolder(Title(), Folder->Folder()->SubItems(), nestedItemList, !isempty(dir) ? *cString::sprintf("%s%c%s", *dir, FOLDERDELIMCHAR, Folder->Folder()->Text()) : Folder->Folder()->Text())); else return osEnd; @@ -858,8 +874,8 @@ eOSState cMenuFolder::ProcessKey(eKeys Key) if (state == osUnknown) { switch (Key) { - case kOk: - case kRed: return Select(); + case kOk: return Select(false); + case kRed: return Select(true); case kGreen: return New(); case kYellow: return Delete(); case kBlue: return Edit(); @@ -868,6 +884,7 @@ eOSState cMenuFolder::ProcessKey(eKeys Key) } else if (state == osEnd && HasSubMenu() && editing) state = SetFolder(); + SetHelpKeys(); return state; } |