2 #include <enigma_main.h>
3 #include <enigma_mainmenu.h>
4 #include <enigma_setup.h>
5 #include <enigma_plugins.h>
6 #include <enigma_info.h>
7 #include <enigma_vcr.h>
8 #include <enigma_lcd.h>
11 #include <lib/gui/eskin.h>
12 #include <lib/driver/eavswitch.h>
13 #include <lib/gui/elabel.h>
14 #include <lib/dvb/epgcache.h>
15 #include <lib/dvb/decoder.h>
16 #include <lib/base/i18n.h>
17 #include <lib/gui/guiactions.h>
18 #include <lib/system/init_num.h>
19 #include <lib/system/info.h>
21 struct enigmaMainmenuActions
24 eAction close
, prev
, next
;
25 enigmaMainmenuActions():
26 map("mainmenu", _("enigma mainmenu")),
27 close(map
, "close", _("close the mainmenu"), eAction::prioDialog
),
28 prev(map
, "prev", _("select previous entry"), eAction::prioDialog
),
29 next(map
, "next", _("select next entry"), eAction::prioDialog
)
34 eAutoInitP0
<enigmaMainmenuActions
> i_mainmenuActions(eAutoInitNumbers::actions
, "enigma mainmenu actions");
37 void eMainMenu::setActive(int i
)
39 int count
= MENU_ENTRIES
;
40 if (!eSystemInfo::getInstance()->hasScartSwitch())
42 for (int a
=0; a
<7; a
++)
44 int c
=(i
+a
+count
-3)%count
;
46 label
[a
]->setPixmap(pixmaps
[c
][0]); // unselected
48 label
[a
]->setPixmap(pixmaps
[c
][1]); // selected
54 description
->setText(eString("(1) ") + eString(_("TV mode")));
57 description
->setText(eString("(2) ") + eString(_("Radio mode")));
61 description
->setText(eString("(3) ") + eString(_("File mode")));
64 description
->setText(eString("(4) ") + eString(_("Information")));
67 description
->setText(eString("(5) ") + eString(_("Shutdown")));
70 description
->setText(eString("(6) ") + eString(_("Setup")));
73 description
->setText(eString("(7) ") + eString(_("Games")));
76 description
->setText(eString("(8) ") + eString(_("Timer")));
79 description
->setText(eString("(9) ") + eString(_("VCR")));
83 description
->setText(eString("(3) ") + eString(_("Information")));
86 description
->setText(eString("(4) ") + eString(_("Setup")));
89 description
->setText(eString("(5) ") + eString(_("Timer")));
92 description
->setText(eString("(6) ") + eString(_("VCR")));
98 LCDTitle
->setText(_("Mainmenu"));
100 LCDElement
->setText( description
->getText() );
104 eMainMenu::eMainMenu()
108 eSystemInfo::getInstance()->hasScartSwitch()?11:10,
110 eSystemInfo::getInstance()->hasScartSwitch()?8:7,
116 eConfig::getInstance()->getKey("/ezap/osd/simpleMainMenu", simpleMainmenu
);
118 if ( !simpleMainmenu
)
120 addActionMap(&i_mainmenuActions
->map
);
121 addActionMap(&i_cursorActions
->map
);
122 addActionMap(&i_shortcutActions
->map
);
123 eLabel
*background
=new eLabel(this);
124 background
->setName("background");
126 label
[0]=new eLabel(this);
127 label
[0]->setName("l3");
128 label
[1]=new eLabel(this);
129 label
[1]->setName("l2");
130 label
[2]=new eLabel(this);
131 label
[2]->setName("l1");
132 label
[3]=new eLabel(this);
133 label
[3]->setName("m");
134 label
[4]=new eLabel(this);
135 label
[4]->setName("r1");
136 label
[5]=new eLabel(this);
137 label
[5]->setName("r2");
138 label
[6]=new eLabel(this);
139 label
[6]->setName("r3");
141 description
=new eLabel(this);
142 description
->setName("description");
144 if (eSkin::getActive()->build(this, "eZapMainMenu"))
145 eFatal("unable to load main menu");
147 char *pixmap_name
[]={
165 int count
= MENU_ENTRIES
;
166 if (!eSystemInfo::getInstance()->hasScartSwitch())
168 for (int i
=0; i
<count
; i
++)
170 pixmaps
[i
][0]=eSkin::getActive()->queryImage(eString("mainmenu.") + eString(pixmap_name
[i
]) );
171 pixmaps
[i
][1]=eSkin::getActive()->queryImage(eString("mainmenu.") + eString(pixmap_name
[i
]) + ".sel" );
173 eFatal("error, mainmenu bug, mainmenu.%s not defined", pixmap_name
[i
]);
175 eFatal("error, mainmenu bug, mainmenu.%s.sel not defined", pixmap_name
[i
]);
176 pixmaps
[i
][0]->uncompressdata();
177 pixmaps
[i
][1]->uncompressdata();
180 setActive(active
=eZapMain::getInstance()->getMode());
184 CONNECT(wndShowTimer
.timeout
, eMainMenu::showWindow
);
185 wnd
.cmove(ePoint(180, 115));
187 int count
= MENU_ENTRIES
;
188 for (int i
=0; i
<count
; i
++)
193 CONNECT((new eListBoxEntryMenu(wnd
.getList(), _("TV mode"), eString().sprintf("(%d) %s", ++entry
, _("TV mode")) ))->selected
, eMainMenu::sel_tv
);
194 CONNECT((new eListBoxEntryMenu(wnd
.getList(), _("Radio mode"), eString().sprintf("(%d) %s", ++entry
, _("Radio mode")) ))->selected
, eMainMenu::sel_radio
);
196 CONNECT((new eListBoxEntryMenu(wnd
.getList(), _("File mode"), eString().sprintf("(%d) %s", ++entry
, _("File mode")) ))->selected
, eMainMenu::sel_file
);
197 if ( eSystemInfo::getInstance()->hasScartSwitch() )
198 CONNECT((new eListBoxEntryMenu(wnd
.getList(), _("VCR"), eString().sprintf("(%d) %s", ++entry
, _("VCR")) ))->selected
, eMainMenu::sel_vcr
);
199 new eListBoxEntryMenuSeparator(wnd
.getList(), eSkin::getActive()->queryImage("listbox.separator"), 0, true );
200 CONNECT((new eListBoxEntryMenu(wnd
.getList(), _("Timer"), eString().sprintf("(%d) %s", ++entry
, _("Timer")) ))->selected
, eMainMenu::sel_timer
);
201 CONNECT((new eListBoxEntryMenu(wnd
.getList(), _("Setup"), eString().sprintf("(%d) %s", ++entry
, _("Setup")) ))->selected
, eMainMenu::sel_setup
);
202 CONNECT((new eListBoxEntryMenu(wnd
.getList(), _("Games"), eString().sprintf("(%d) %s", ++entry
, _("Games")) ))->selected
, eMainMenu::sel_plugins
);
203 CONNECT((new eListBoxEntryMenu(wnd
.getList(), _("Information"), eString().sprintf("(%d) %s", ++entry
, _("Information")) ))->selected
, eMainMenu::sel_info
);
204 new eListBoxEntryMenuSeparator(wnd
.getList(), eSkin::getActive()->queryImage("listbox.separator"), 0, true );
205 CONNECT((new eListBoxEntryMenu(wnd
.getList(), _("Shutdown"), eString().sprintf("(%d) %s", ++entry
, _("Shutdown")) ))->selected
, eMainMenu::sel_quit
);
207 if ( eSystemInfo::getInstance()->hasScartSwitch() )
208 CONNECT((new eListBoxEntryMenu(wnd
.getList(), _("VCR"), eString().sprintf("(%d) %s", ++entry
, _("VCR")) ))->selected
, eMainMenu::sel_vcr
);
209 new eListBoxEntryMenuSeparator(wnd
.getList(), eSkin::getActive()->queryImage("listbox.separator"), 0, true );
210 CONNECT((new eListBoxEntryMenu(wnd
.getList(), _("Timer"), eString().sprintf("(%d) %s", ++entry
, _("Timer")) ))->selected
, eMainMenu::sel_timer
);
211 CONNECT((new eListBoxEntryMenu(wnd
.getList(), _("Setup"), eString().sprintf("(%d) %s", ++entry
, _("Setup")) ))->selected
, eMainMenu::sel_setup
);
212 new eListBoxEntryMenuSeparator(wnd
.getList(), eSkin::getActive()->queryImage("listbox.separator"), 0, true );
213 CONNECT((new eListBoxEntryMenu(wnd
.getList(), _("Information"), eString().sprintf("(%d) %s", ++entry
, _("Information")) ))->selected
, eMainMenu::sel_info
);
218 eMainMenu::~eMainMenu()
221 eConfig::getInstance()->getKey("/ezap/osd/simpleMainMenu", simpleMainmenu
);
223 if ( !simpleMainmenu
)
225 int count
= MENU_ENTRIES
;
226 if (!eSystemInfo::getInstance()->hasScartSwitch())
228 for (int i
=0; i
<count
; i
++)
231 pixmaps
[i
][0]->compressdata();
233 pixmaps
[i
][1]->compressdata();
238 void eMainMenu::setLCD( eWidget
*LCDTitle
, eWidget
*LCDElement
)
240 eWidget::setLCD(LCDTitle
, LCDElement
);
241 wnd
.setLCD(LCDTitle
,LCDElement
);
245 void eMainMenu::sel_tv()
247 eZapMain::getInstance()->setMode(eZapMain::modeTV
, 1);
254 void eMainMenu::sel_radio()
256 eZapMain::getInstance()->setMode(eZapMain::modeRadio
, 1);
264 void eMainMenu::sel_file()
266 eZapMain::getInstance()->setMode(eZapMain::modeFile
, 1);
274 void eMainMenu::sel_vcr()
277 eZapMain::getInstance()->toggleScart(1);
281 void eMainMenu::sel_info()
285 info
.setLCD(LCDTitle
, LCDElement
);
294 extern bool checkPin( int, const char* );
296 void eMainMenu::sel_setup()
299 eConfig::getInstance()->getKey("/elitedvb/pins/setuplock", setuppin
);
301 if ( checkPin( setuppin
, _("setup") ) )
309 setup
.setLCD(LCDTitle
, LCDElement
);
315 while(i
==-1); // to redisplay Setup after language change
316 if ( !simpleMainmenu
)
317 setActive(active
); // --"--
322 void eMainMenu::sel_plugins()
325 eZapPlugins
plugins(eZapPlugins::GamePlugin
, LCDTitle
, LCDElement
);
327 eZapPlugins
plugins(eZapPlugins::GamePlugin
);
334 void eMainMenu::sel_timer()
337 eTimerListView setup
;
339 setup
.setLCD(LCDTitle
, LCDElement
);
347 void eMainMenu::sel_quit()
355 int eMainMenu::eventHandler(const eWidgetEvent
&event
)
358 if ( !simpleMainmenu
)
362 case eWidgetEvent::willShow
:
365 LCDTitle
->setText(_("Mainmenu"));
367 LCDElement
->setText( description
->getText() );
370 case eWidgetEvent::evtAction
:
372 int count
= MENU_ENTRIES
;
373 if (!eSystemInfo::getInstance()->hasScartSwitch())
375 if (event
.action
== &i_mainmenuActions
->close
)
377 else if (event
.action
== &i_mainmenuActions
->prev
)
383 else if (event
.action
== &i_mainmenuActions
->next
)
389 else if (event
.action
== &i_cursorActions
->ok
)
391 else if (event
.action
== &i_cursorActions
->cancel
)
393 else if (event
.action
== &i_shortcutActions
->number0
)
395 else if (event
.action
== &i_shortcutActions
->number1
)
397 else if (event
.action
== &i_shortcutActions
->number2
)
399 else if (event
.action
== &i_shortcutActions
->number3
)
401 else if (event
.action
== &i_shortcutActions
->number4
)
403 else if (event
.action
== &i_shortcutActions
->number5
)
405 else if (event
.action
== &i_shortcutActions
->number6
)
407 else if (event
.action
== &i_shortcutActions
->number7
)
409 else if (event
.action
== &i_shortcutActions
->number8
)
411 else if (event
.action
== &i_shortcutActions
->number9
)
419 setActive(active
=num
);
433 case eWidgetEvent::willShow
:
436 case eWidgetEvent::willHide
:
439 case eWidgetEvent::execBegin
:
440 wndShowTimer
.start(0,true);
446 return eWidget::eventHandler(event
);
449 void eMainMenu::selected(int i
)
498 void eMainMenu::showWindow()
503 void eMainMenu::eraseBackground(gPainter
*, const eRect
&where
)