1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

Implemented hotkeys for Main and Commands menu

This commit is contained in:
Klaus Schmidinger 2001-02-03 15:28:49 +01:00
parent caa96c00ea
commit 7f6a2a7a0c
5 changed files with 52 additions and 14 deletions

10
FORMATS
View File

@ -86,9 +86,13 @@ Video Disk Recorder File Formats
Examples: Examples:
Check for new mail: /usr/local/bin/checkmail 2>&1 1 Check for new mail: /usr/local/bin/checkmail 2>&1
CPU status : /usr/loval/bin/cpustatus 2>&1 2 CPU status : /usr/loval/bin/cpustatus 2>&1
Disk space : df -h | grep '/video' | awk '{ print 100 - $5 "% free"; }' 3 Disk space : df -h | grep '/video' | awk '{ print 100 - $5 "% free"; }'
If the first non-blank character of the 'title' is a digit in the range
1..9, the command can be selected directly by pressing the respective numerical
key on the remote control.
* marks.vdr * marks.vdr

View File

@ -367,3 +367,7 @@ Video Disk Recorder Revision History
- The "Left" and "Right" keys are now used to page up and down in lists (thanks - The "Left" and "Right" keys are now used to page up and down in lists (thanks
to Martin Hammerschmid). Since the "Timers" menu already uses these keys to to Martin Hammerschmid). Since the "Timers" menu already uses these keys to
(de)activate timers, this functionality is not available here. (de)activate timers, this functionality is not available here.
- The "Main" and "Commands" menu now support "hotkeys", which means that if the
first non-blank character of a menu item is a digit in the range 1..9, that
item can be selected by pressing the respective numeric key on the remote
control.

27
menu.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: menu.c 1.59 2001/02/03 14:28:42 kls Exp $ * $Id: menu.c 1.60 2001/02/03 15:28:49 kls Exp $
*/ */
#include "menu.h" #include "menu.h"
@ -1620,6 +1620,7 @@ cMenuCommands::cMenuCommands(void)
Add(new cOsdItem(command->Title())); Add(new cOsdItem(command->Title()));
i++; i++;
} }
SetHasHotkeys();
} }
eOSState cMenuCommands::Execute(void) eOSState cMenuCommands::Execute(void)
@ -1650,18 +1651,25 @@ eOSState cMenuCommands::ProcessKey(eKeys Key)
#define STOP_RECORDING tr("Stop recording ") #define STOP_RECORDING tr("Stop recording ")
static const char *hk(int n, const char *s)
{
static char buffer[32];
snprintf(buffer, sizeof(buffer), " %d %s", n, s);
return buffer;
}
cMenuMain::cMenuMain(bool Replaying) cMenuMain::cMenuMain(bool Replaying)
:cOsdMenu(tr("Main")) :cOsdMenu(tr("Main"))
{ {
Add(new cOsdItem(tr("Schedule"), osSchedule)); Add(new cOsdItem(hk(1, tr("Schedule")), osSchedule));
Add(new cOsdItem(tr("Channels"), osChannels)); Add(new cOsdItem(hk(2, tr("Channels")), osChannels));
Add(new cOsdItem(tr("Timers"), osTimers)); Add(new cOsdItem(hk(3, tr("Timers")), osTimers));
Add(new cOsdItem(tr("Recordings"), osRecordings)); Add(new cOsdItem(hk(4, tr("Recordings")), osRecordings));
Add(new cOsdItem(tr("Setup"), osSetup)); Add(new cOsdItem(hk(5, tr("Setup")), osSetup));
if (Commands.Count()) if (Commands.Count())
Add(new cOsdItem(tr("Commands"), osCommands)); Add(new cOsdItem(hk(6, tr("Commands")), osCommands));
if (Replaying) if (Replaying)
Add(new cOsdItem(tr("Stop replaying"), osStopReplay)); Add(new cOsdItem(tr(" Stop replaying"), osStopReplay));
const char *s = NULL; const char *s = NULL;
while ((s = cRecordControls::GetInstantId(s)) != NULL) { while ((s = cRecordControls::GetInstantId(s)) != NULL) {
char *buffer = NULL; char *buffer = NULL;
@ -1670,10 +1678,11 @@ cMenuMain::cMenuMain(bool Replaying)
delete buffer; delete buffer;
} }
if (cVideoCutter::Active()) if (cVideoCutter::Active())
Add(new cOsdItem(tr("Cancel editing"), osCancelEdit)); Add(new cOsdItem(tr(" Cancel editing"), osCancelEdit));
SetHelp(tr("Record"), NULL, NULL, cReplayControl::LastReplayed() ? tr("Resume") : NULL); SetHelp(tr("Record"), NULL, NULL, cReplayControl::LastReplayed() ? tr("Resume") : NULL);
Display(); Display();
lastActivity = time(NULL); lastActivity = time(NULL);
SetHasHotkeys();
} }
eOSState cMenuMain::ProcessKey(eKeys Key) eOSState cMenuMain::ProcessKey(eKeys Key)

20
osd.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: osd.c 1.14 2001/02/03 14:26:18 kls Exp $ * $Id: osd.c 1.15 2001/02/03 15:14:45 kls Exp $
*/ */
#include "osd.h" #include "osd.h"
@ -77,6 +77,7 @@ eOSState cOsdItem::ProcessKey(eKeys Key)
cOsdMenu::cOsdMenu(const char *Title, int c0, int c1, int c2, int c3, int c4) cOsdMenu::cOsdMenu(const char *Title, int c0, int c1, int c2, int c3, int c4)
{ {
hasHotkeys = false;
visible = false; visible = false;
title = strdup(Title); title = strdup(Title);
cols[0] = c0; cols[0] = c0;
@ -290,6 +291,20 @@ void cOsdMenu::Mark(void)
} }
} }
eOSState cOsdMenu::HotKey(eKeys Key)
{
for (cOsdItem *item = First(); item; item = Next(item)) {
const char *s = item->Text();
if (s && (s = skipspace(s)) != NULL) {
if (*s == Key - k1 + '1') {
current = item->Index();
return ProcessKey(kOk);
}
}
}
return osContinue;
}
eOSState cOsdMenu::AddSubMenu(cOsdMenu *SubMenu) eOSState cOsdMenu::AddSubMenu(cOsdMenu *SubMenu)
{ {
delete subMenu; delete subMenu;
@ -319,6 +334,9 @@ eOSState cOsdMenu::ProcessKey(eKeys Key)
return state; return state;
} }
switch (Key) { switch (Key) {
case k1...k9: if (hasHotkeys)
return HotKey(Key);
break;
case kUp|k_Repeat: case kUp|k_Repeat:
case kUp: CursorUp(); break; case kUp: CursorUp(); break;
case kDown|k_Repeat: case kDown|k_Repeat:

5
osd.h
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: osd.h 1.19 2001/02/03 14:14:23 kls Exp $ * $Id: osd.h 1.20 2001/02/03 15:13:59 kls Exp $
*/ */
#ifndef __OSD_H #ifndef __OSD_H
@ -77,6 +77,7 @@ private:
cOsdMenu *subMenu; cOsdMenu *subMenu;
const char *helpRed, *helpGreen, *helpYellow, *helpBlue; const char *helpRed, *helpGreen, *helpYellow, *helpBlue;
const char *status; const char *status;
bool hasHotkeys;
protected: protected:
bool visible; bool visible;
virtual void Clear(void); virtual void Clear(void);
@ -88,6 +89,7 @@ protected:
void PageUp(void); void PageUp(void);
void PageDown(void); void PageDown(void);
void Mark(void); void Mark(void);
eOSState HotKey(eKeys Key);
eOSState AddSubMenu(cOsdMenu *SubMenu); eOSState AddSubMenu(cOsdMenu *SubMenu);
bool HasSubMenu(void) { return subMenu; } bool HasSubMenu(void) { return subMenu; }
void SetStatus(const char *s); void SetStatus(const char *s);
@ -97,6 +99,7 @@ protected:
public: public:
cOsdMenu(const char *Title, int c0 = 0, int c1 = 0, int c2 = 0, int c3 = 0, int c4 = 0); cOsdMenu(const char *Title, int c0 = 0, int c1 = 0, int c2 = 0, int c3 = 0, int c4 = 0);
virtual ~cOsdMenu(); virtual ~cOsdMenu();
void SetHasHotkeys(void) { hasHotkeys = true; }
int Current(void) { return current; } int Current(void) { return current; }
void Add(cOsdItem *Item, bool Current = false); void Add(cOsdItem *Item, bool Current = false);
void Display(void); void Display(void);