2 Copyright 2004-2005 Chris Tallon
4 This file is part of VOMP.
6 VOMP is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 VOMP is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with VOMP; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 VWelcome* VWelcome::instance = NULL;
35 if (Video::getInstance()->getFormat() == Video::PAL)
37 setScreenPos(140, 170);
41 setScreenPos(130, 140);
44 setBackgroundColour(Colour::VIEWBACKGROUND);
46 setTitleBarColour(Colour::TITLEBARBACKGROUND);
48 sl.setSurface(surface);
49 sl.setSurfaceOffset(20, 40);
50 sl.setDimensions(170, 140);
52 jpeg.setSurface(surface);
53 jpeg.setSurfaceOffset(240, 60);
60 Timers::getInstance()->cancelTimer(this, 1);
64 VWelcome* VWelcome::getInstance()
69 void VWelcome::setup()
72 setTitleText(tr("Welcome"));
73 sl.addOption(tr("1. Live TV"), 1);
74 sl.addOption(tr("2. Radio"), 0);
75 sl.addOption(tr("3. Recordings"), 0);
76 sl.addOption(tr("4. Options"), 0);
77 sl.addOption(tr("5. Stand by"), 0);
78 sl.addOption(tr("6. Reboot"), 0);
85 jpeg.init("/vdr.jpg");
90 void VWelcome::drawClock()
92 // Blank the area first
93 rectangle(area.w - 60, 0, 60, 30, titleBarColour);
98 struct tm* tms = localtime(&t);
99 strftime(timeString, 19, "%H:%M", tms);
100 drawTextRJ(timeString, 450, 5, Colour::LIGHTTEXT);
102 time_t dt = 60 - (t % 60); // seconds to the next minute
103 if (dt == 0) dt = 60; // advance a whole minute if necessary
104 dt += t; // get a time_t value for it rather than using duration
105 // (so it will occur at the actual second and not second and a half)
107 Timers::getInstance()->setTimer(this, 1, dt);
110 void VWelcome::timercall(int clientReference)
113 ViewMan::getInstance()->updateView(this, &clockRegion);
116 int VWelcome::handleCommand(int command)
122 VInfo* viewWait = new VInfo();
123 viewWait->create(100, 100);
124 viewWait->setScreenPos(485, 185);
125 viewWait->setTitleBarOn(0);
126 viewWait->setBackgroundColour(Colour::DANGER);
129 ViewMan::getInstance()->add(viewWait);
142 case Remote::DF_DOWN:
172 Message* m = new Message();
173 m->message = Message::STANDBY;
174 Command::getInstance()->postMessage(m);
179 Command::getInstance()->doReboot();
183 int option = sl.getCurrentOption();
189 else if (option == 1)
194 else if (option == 2)
199 else if (option == 3)
204 else if (option == 4)
206 Message* m = new Message();
207 m->message = Message::STANDBY;
208 Command::getInstance()->postMessage(m);
211 else if (option == 5)
213 Command::getInstance()->doReboot();
216 return 2; // never gets here
224 void VWelcome::doChannelsList()
226 ChannelList* chanList = VDR::getInstance()->getChannelsList(VDR::VIDEO);
230 VChannelList* vchan = new VChannelList(VDR::VIDEO);
231 vchan->setList(chanList);
233 ViewMan::getInstance()->add(vchan);
238 // Message* m = new Message();
240 // m->to = ViewMan::getInstance();
241 // m->message = Message::SWAP_ME_FOR;
242 // m->parameter = (ULONG)vchan;
243 // ViewMan::getInstance()->postMessage(m);
247 void VWelcome::doRadioList()
249 ChannelList* chanList = VDR::getInstance()->getChannelsList(VDR::RADIO);
253 VChannelList* vchan = new VChannelList(VDR::RADIO);
254 vchan->setList(chanList);
256 ViewMan::getInstance()->add(vchan);
262 void VWelcome::doRecordingsList()
264 ViewMan* viewman = ViewMan::getInstance();
266 VInfo* viewWait = new VInfo();
267 viewWait->create(460, 190);
268 if (Video::getInstance()->getFormat() == Video::PAL)
270 viewWait->setScreenPos(140, 170);
274 viewWait->setScreenPos(130, 140);
276 viewWait->setOneLiner(tr("Downloading recordings list"));
279 viewman->add(viewWait);
282 VDR* vdr = VDR::getInstance();
283 Directory* recDir = vdr->getRecordingsList();
287 VRecordingList* vrec = new VRecordingList(NULL);
288 vrec->setDir(recDir);
290 ViewMan::getInstance()->add(vrec);
296 Log::getInstance()->log("VWelcome", Log::DEBUG, "possible delay start");
297 viewman->removeView(viewWait);
298 Log::getInstance()->log("VWelcome", Log::DEBUG, "possible delay end");
301 void VWelcome::doOptions()
303 VOptions* voptions = new VOptions();
304 ViewMan::getInstance()->add(voptions);
309 void VWelcome::processMessage(Message* m)
311 if (m->message == Message::REDRAW_LANG)
313 Log::getInstance()->log("VWelcome", Log::DEBUG, "Got redraw lang message");
316 show(); // careful, this only works properly because the only place
317 // this is called from is voptions and that disappears before
318 // this message is delivered