1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
/**
* based on setup.c,v 1.1.1.1 2006/02/26 14:11:02 lordjaxom
*
* version by Midas
*
*/
#include "setup.h"
#include <vdr/interface.h>
cMenuSetupBlock::cMenuSetupBlock():
cMenuSetupPage()
{
mEventsData = EventsBlock; // need to use copy constructor
mSetupData = SetupBlock;
Set();
}
void cMenuSetupBlock::Set(void) {
int current = Current();
cOsdItem *item;
Clear();
Add(new cMenuEditBoolItem(tr("Hide Mainmenu Entry"), &mSetupData.HideMenuEntry));
Add(new cMenuEditIntItem(tr("Message Timeout [s]"), &mSetupData.MessageTimeout, 0, 10));
item = new cOsdItem("");
item->SetSelectable(false);
Add(item);
item = new cOsdItem(tr("--- Keywords -------------------------------------------------------------------"));
item->SetSelectable(false);
Add(item);
#define NONKEYWORDITEMS 4
int index = 0;
cEventBlock *event = mEventsData.First();
while (event != NULL) {
Add(new cOsdItem(event->Pattern()));
event = mEventsData.Next(event);
++index;
}
SetCurrent(Get(current));
SetHelpKeys();
Display();
}
void cMenuSetupBlock::SetHelpKeys(void)
{
const char *red = NULL;
const char *yellow = NULL;
printf("sethelpkeys, current = %d\n", Current());
if (Current() >= NONKEYWORDITEMS) {
red = trVDR("Button$Edit");
yellow = trVDR("Button$Delete");
}
SetHelp(red, trVDR("Button$New"), yellow, NULL);
}
void cMenuSetupBlock::Store(void)
{
EventsBlock = mEventsData;
EventsBlock.Save();
SetupBlock = mSetupData;
SetupStore("HideMenuEntry", SetupBlock.HideMenuEntry);
SetupStore("MessageTimeout", SetupBlock.MessageTimeout);
}
eOSState cMenuSetupBlock::Edit(void)
{
if (HasSubMenu() || Current() < NONKEYWORDITEMS)
return osContinue;
cEventBlock *event = mEventsData.Get(Current() - NONKEYWORDITEMS);
if (event != NULL)
return AddSubMenu(new cMenuSetupEditBlock(event));
return osContinue;
}
eOSState cMenuSetupBlock::New(void)
{
if (HasSubMenu())
return osContinue;
mEventsData.Add(new cEventBlock());
Set();
return osContinue;
}
eOSState cMenuSetupBlock::Delete(void)
{
if (HasSubMenu() || Current() < NONKEYWORDITEMS)
return osContinue;
cEventBlock *event = mEventsData.Get(Current() - NONKEYWORDITEMS);
if (event != NULL) {
if (Interface->Confirm(tr("Delete keyword?")))
mEventsData.Del(event);
}
Set();
return osContinue;
}
eOSState cMenuSetupBlock::ProcessKey(eKeys Key) {
bool hadSubMenu = HasSubMenu();
eOSState state = cMenuSetupPage::ProcessKey(Key);
if (hadSubMenu && !HasSubMenu()) {
Set();
return state;
}
switch (state) {
case osUnknown: // normal key handling
switch (Key) {
case kRed: return Edit();
case kGreen: return New();
case kYellow: return Delete();
default:
break;
}
break;
default:
break;
}
if (!HasSubMenu())
Set();
return state;
}
static const char *ALLOWEDCHARS = "$ abcdefghijklmnopqrstuvwxyz0123456789-_.#~/[]{}()+*^$";
cMenuSetupEditBlock::cMenuSetupEditBlock(cEventBlock *Event):
cOsdMenu("", 33),
mEvent(Event),
mData(*Event)
{
char buf[80];
snprintf(buf, sizeof(buf), "%s - %s '%s'", trVDR("Setup"), trVDR("Plugin"), "block");
SetTitle(buf);
Add(new cMenuEditStrItem(tr("Pattern"), mData.mPattern, sizeof(mData.mPattern), tr(ALLOWEDCHARS)));
Add(new cMenuEditBoolItem(tr("Regular Expression"), &mData.mRegularExp));
Add(new cMenuEditBoolItem(tr("Ignore Case"), &mData.mIgnoreCase));
}
eOSState cMenuSetupEditBlock::ProcessKey(eKeys Key)
{
eOSState state = cOsdMenu::ProcessKey(Key);
if (state == osUnknown) {
switch (Key) {
case kOk:
if (!mData.Compile()) {
Skins.Message(mtError, tr("Malformed regular expression!"));
state = osContinue;
} else {
*mEvent = mData;
state = osBack;
}
break;
default:
break;
}
}
return state;
}
|