]> git.vomp.tv Git - vompclient.git/blob - vwelcome.cc
New GUI code
[vompclient.git] / vwelcome.cc
1 /*
2     Copyright 2004-2005 Chris Tallon
3
4     This file is part of VOMP.
5
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.
10
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.
15
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
19 */
20
21 #include "vwelcome.h"
22
23 VWelcome::VWelcome()
24 {
25   create(460, 200);
26   if (Video::getInstance()->getFormat() == Video::PAL)
27   {
28     setScreenPos(140, 170);
29   }
30   else
31   {
32     setScreenPos(130, 140);
33   }
34
35   sl.setSurface(surface);
36   jpeg.setSurface(surface);
37
38   setBackgroundColour(Colour::VIEWBACKGROUND);
39   setTitleBarOn(1);
40   setTitleBarColour(Colour::TITLEBARBACKGROUND);
41   setTitleText(tr("Welcome"));
42
43   sl.setSurfaceOffset(20, 40);
44   sl.setDimensions(170, 140);
45
46   sl.addOption(tr("1. Live TV"), 1);
47   sl.addOption(tr("2. Radio"), 0);
48   sl.addOption(tr("3. Recordings"), 0);
49   sl.addOption(tr("4. Options"), 0);
50   sl.addOption(tr("5. Stand by"), 0);
51   sl.addOption(tr("6. Reboot"), 0);
52
53   jpeg.setSurfaceOffset(240, 60);
54 }
55
56 VWelcome::~VWelcome()
57 {
58 }
59
60 void VWelcome::draw()
61 {
62
63   View::draw();
64   sl.draw();
65
66   char timeString[20];
67   time_t t;
68   time(&t);
69   struct tm* tms = localtime(&t);
70   strftime(timeString, 19, "%H:%M", tms);
71
72   drawTextRJ(timeString, 450, 5, Colour::LIGHTTEXT);
73
74   jpeg.init("/vdr.jpg");
75   jpeg.draw();
76 }
77
78 int VWelcome::handleCommand(int command)
79 {
80   switch(command)
81   {
82     case Remote::DF_UP:
83     case Remote::UP:
84     {
85       sl.up();
86       sl.draw();
87       show();
88       return 2;
89     }
90     case Remote::DF_DOWN:
91     case Remote::DOWN:
92     {
93       sl.down();
94       sl.draw();
95       show();
96       return 2;
97     }
98     case Remote::ONE:
99     {
100       doChannelsList();
101       return 2;
102     }
103     case Remote::TWO:
104     {
105       doRadioList();
106       return 2;
107     }
108     case Remote::THREE:
109     {
110       doRecordingsList();
111       return 2;
112     }
113     case Remote::FOUR:
114     {
115       doOptions();
116       return 2;
117     }
118     case Remote::FIVE:
119     {
120       Message* m = new Message();
121       m->message = Message::STANDBY;
122       Command::getInstance()->postMessage(m);
123       return 4;
124     }
125     case Remote::SIX:
126     {
127       Command::getInstance()->doReboot();
128     }
129     case Remote::OK:
130     {
131       int option = sl.getCurrentOption();
132       if (option == 0)
133       {
134         doChannelsList();
135         return 2;
136       }
137       else if (option == 1)
138       {
139         doRadioList();
140         return 2;
141       }
142       else if (option == 2)
143       {
144         doRecordingsList();
145         return 2;
146       }
147       else if (option == 3)
148       {
149         doOptions();
150         return 2;
151       }
152       else if (option == 4)
153       {
154         Message* m = new Message();
155         m->message = Message::STANDBY;
156         Command::getInstance()->postMessage(m);
157         return 4;
158       }
159       else if (option == 5)
160       {
161         Command::getInstance()->doReboot();
162         return 2;
163       }
164       return 2; // never gets here
165     }
166   }
167
168   return 1;
169 }
170
171
172 void VWelcome::doChannelsList()
173 {
174   ChannelList* chanList = VDR::getInstance()->getChannelsList(VDR::VIDEO);
175
176   if (chanList)
177   {
178     VChannelList* vchan = new VChannelList(VDR::VIDEO);
179     vchan->setList(chanList);
180
181     ViewMan::getInstance()->addNoLock(vchan);
182     vchan->draw();
183     vchan->show();
184
185
186 //        Message* m = new Message();
187 //        m->from = this;
188 //        m->to = ViewMan::getInstance();
189 //        m->message = Message::SWAP_ME_FOR;
190 //        m->parameter = (ULONG)vchan;
191 //        ViewMan::getInstance()->postMessage(m);
192   }
193 }
194
195 void VWelcome::doRadioList()
196 {
197   ChannelList* chanList = VDR::getInstance()->getChannelsList(VDR::RADIO);
198
199   if (chanList)
200   {
201     VChannelList* vchan = new VChannelList(VDR::RADIO);
202     vchan->setList(chanList);
203
204     ViewMan::getInstance()->addNoLock(vchan);
205     vchan->draw();
206     vchan->show();
207   }
208 }
209
210 void VWelcome::doRecordingsList()
211 {
212   ViewMan* viewman = ViewMan::getInstance();
213
214   VInfo* viewWait = new VInfo();
215   viewWait->create(460, 190);
216   if (Video::getInstance()->getFormat() == Video::PAL)
217   {
218     viewWait->setScreenPos(140, 170);
219   }
220   else
221   {
222     viewWait->setScreenPos(130, 140);
223   }
224   viewWait->setMainText(tr("\n                  Downloading recordings list"));
225   viewWait->draw();
226   viewWait->show();
227   viewman->addNoLock(viewWait);
228
229
230   VDR* vdr = VDR::getInstance();
231   Directory* recDir = vdr->getRecordingsList();
232
233   if (recDir)
234   {
235     VRecordingList* vrec = new VRecordingList(NULL);
236     vrec->setDir(recDir);
237
238     ViewMan::getInstance()->addNoLock(vrec);
239
240     vrec->draw();
241     vrec->show();
242   }
243
244   Log::getInstance()->log("VWelcome", Log::DEBUG, "possible delay start");
245   viewman->removeView(viewWait, 1);
246   Log::getInstance()->log("VWelcome", Log::DEBUG, "possible delay end");
247 }
248
249 void VWelcome::doOptions()
250 {
251   VOptions* voptions = new VOptions();
252   ViewMan::getInstance()->addNoLock(voptions);
253   voptions->draw();
254   voptions->show();
255 }