summaryrefslogtreecommitdiff
path: root/menu.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2013-11-03 13:43:01 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2013-11-03 13:43:01 +0100
commit0b5085f4f00618a96eaaba97c05dd1c5177b5e42 (patch)
treed3cadfea05def188295b06f3f4df190182df732d /menu.c
parent512cd24e5396bf2d027ff6dd698ad77f9b266ff5 (diff)
downloadvdr-0b5085f4f00618a96eaaba97c05dd1c5177b5e42.tar.gz
vdr-0b5085f4f00618a96eaaba97c05dd1c5177b5e42.tar.bz2
In the "Select folder" menu pressing Ok now selects the folder, even if this is a folder that contains sub folders
Diffstat (limited to 'menu.c')
-rw-r--r--menu.c35
1 files changed, 26 insertions, 9 deletions
diff --git a/menu.c b/menu.c
index 6fb87ef4..9d75775f 100644
--- a/menu.c
+++ b/menu.c
@@ -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;
}