2 Copyright 2007 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29 #include "woptionpane.h"
30 #include "wremoteconfig.h"
36 #ifdef VOMP_PLATTFORM_MVP
37 #include "mediaoptions.h"
40 //#include "command.h"
45 setTitleBarColour(DrawStyle::TITLEBARBACKGROUND);
46 setTitleText(tr("Options"));
51 if (Video::getInstance()->getFormat() == Video::PAL)
52 setPosition(100, 110);
56 tabbar.setPosition(6, 32);
57 tabbar.setSize(getWidth() - 12, getHeight() - 34);
63 // --- edit options start here
65 static const char* options1[] = {"Old", "New"};
67 static const char* options5[] = {"Chop sides", "Letterbox"};
68 static const char* options6[] = {"On", "Off", "Last state"};
69 static const char* options7[] = {"All", "FTA only"};
70 static const char* options15[] = {"Alphabetical", "Chronological"};
72 static const char* options13[] = {"Auto","1024", "2048", "4096", "8192", "16384", "32768", "65536"};
73 static const char* options14[] = {"No", "Yes"};
74 static const char* options18[] = {"Off", "On"};
75 #ifdef ADVANCED_MENUES
76 static const char* options19[] = { "Advanced","Classic"};
78 // Get list of languages from VDR and construct options table
79 LangCode = VDR::getInstance()->getLanguageList();
80 options2 = new const char*[LangCode.size()];
81 options2keys = new const char*[LangCode.size()];
82 I18n::lang_code_list::const_iterator iter;
84 for (iter = LangCode.begin(); iter != LangCode.end(); ++iter,++LangNumber)
86 options2[LangNumber] = iter->second.c_str();
87 options2keys[LangNumber] = iter->first.c_str();
91 panes = new Boxx*[numPanes];
93 wop = new WOptionPane();
94 tabbar.addTab(tr("General"), wop);
96 #ifdef MVP_REMOTE_TYPES
97 option = new Option(1, "Remote control type", "General", "Remote type", Option::TYPE_TEXT, 2, 0, 0, options1);
98 options.push_back(option);
99 wop->addOptionLine(option);
101 option = new Option(2, "Language", "General", "LangCode", Option::TYPE_KEYED_TEXT, LangCode.size(), 0, 0, options2, options2keys);
102 options.push_back(option);
103 wop->addOptionLine(option);
105 UINT suppconn = Video::getInstance()->getSupportedFormats();
108 if (suppconn & Video::COMPOSITERGB) {
110 options3.push_back("RGB+composite");
111 options3keys.push_back("RGB+composite");
113 if (Video::SVIDEO & suppconn) {
114 options3.push_back("S-Video");
115 options3keys.push_back("S-Video");
117 if (Video::HDMI & suppconn) {
118 defaultch = options3.size();
119 options3.push_back("HDMI");
120 options3keys.push_back("HDMI");
122 if (Video::HDMI3D & suppconn) {
123 options3.push_back("HDMI3D");
124 options3keys.push_back("HDMI3D");
126 option = new Option(3, "TV connection type", "TV", "Connection",
127 Option::TYPE_KEYED_TEXT, options3.size(), defaultch, 0,
128 &(options3[0]), &(options3keys[0]));
130 options.push_back(option);
131 wop->addOptionLine(option);
134 UINT suppformats = Video::getInstance()->supportedTVFormats();
137 options16.push_back("NTSC");
138 options16keys.push_back("NTSC");
139 if (suppformats & Video::PAL) {
141 options16.push_back("PAL");
142 options16keys.push_back("PAL");
144 if (Video::NTSC_J & suppformats) {
145 options16.push_back("NTSC-J");
146 options16keys.push_back("NTSC-J");
148 if (Video::PAL_M & suppformats) {
149 options16.push_back("PAL-M");
150 options16keys.push_back("PAL-M");
153 option = new Option(16, "TV standard (needs restart)", "General", "Override Video Format",
154 Option::TYPE_KEYED_TEXT, options16.size(), defaultch, 0,
155 &(options16[0]), &(options16keys[0]));
157 options.push_back(option);
158 wop->addOptionLine(option);
161 UINT supptvsize=Video::getInstance()->supportedTVsize();
164 options4.push_back("4:3");
165 options4keys.push_back("4:3");
166 if (Video::ASPECT16X9 & supptvsize) {
167 options4.push_back("16:9");
168 options4keys.push_back("16:9");
171 if (Video::ASPECT14X9 & supptvsize) {
172 options4.push_back("14:9");
173 options4keys.push_back("14:9");
175 option = new Option(4, "TV aspect ratio", "TV", "Aspect",
176 Option::TYPE_KEYED_TEXT, options4.size(), defaultch, 0,
177 &(options4[0]), &(options4keys[0]));
178 options.push_back(option);
179 wop->addOptionLine(option);
182 option = new Option(5, "16:9 on 4:3 display mode", "TV", "Widemode", Option::TYPE_TEXT, 2, 0, 0, options5);
183 options.push_back(option);
184 wop->addOptionLine(option);
185 option = new Option(6, "Power state after bootup", "General", "Power After Boot", Option::TYPE_TEXT, 3, 0, 0, options6);
186 options.push_back(option);
187 wop->addOptionLine(option);
188 option = new Option(7, "Display channels", "General", "Channels", Option::TYPE_TEXT, 2, 0, 0, options7);
189 options.push_back(option);
190 wop->addOptionLine(option);
191 option = new Option(15, "Recordings sort order", "General", "Recordings Sort Order", Option::TYPE_TEXT, 2, 0, 0, options15);
192 options.push_back(option);
193 wop->addOptionLine(option);
194 option = new Option(18, "Automatic VDR shutdown", "General", "VDR shutdown", Option::TYPE_TEXT, 2, 0, 0, options18);
195 options.push_back(option);
196 wop->addOptionLine(option);
198 Remote::getInstance()->addOptionsToPanes(0,&options,wop);
199 Video::getInstance()->addOptionsToPanes(0,&options,wop);
200 Audio::getInstance()->addOptionsToPanes(0,&options,wop);
203 /* WRemoteConfig* wrc = new WRemoteConfig();
204 tabbar.addTab(tr("Remote Control"), wrc);*/
205 Remote::getInstance()->addOptionPagesToWTB(&tabbar);
208 Video::getInstance()->addOptionPagesToWTB(&tabbar);
209 Audio::getInstance()->addOptionPagesToWTB(&tabbar);
210 #ifdef VOMP_PLATTFORM_MVP
211 MediaOptions::getInstance()->addOptionPagesToWTB(&tabbar);
215 wop = new WOptionPane();
216 tabbar.addTab(tr("Timers"), wop);
219 option = new Option(9, "Default start margin (minutes)", "Timers", "Start margin", Option::TYPE_INT, 20, 5, 0, NULL);
220 options.push_back(option);
221 wop->addOptionLine(option);
222 option = new Option(10, "Default end margin (minutes)", "Timers", "End margin", Option::TYPE_INT, 20, 5, 0, NULL);
223 options.push_back(option);
224 wop->addOptionLine(option);
225 option = new Option(11, "Default priority", "Timers", "Priority", Option::TYPE_INT, 100, 99, 0, NULL);
226 options.push_back(option);
227 wop->addOptionLine(option);
228 option = new Option(12, "Default lifetime", "Timers", "Lifetime", Option::TYPE_INT, 100, 99, 0, NULL);
229 options.push_back(option);
230 wop->addOptionLine(option);
232 Remote::getInstance()->addOptionsToPanes(1,&options,wop);
233 Video::getInstance()->addOptionsToPanes(1,&options,wop);
234 Audio::getInstance()->addOptionsToPanes(1,&options,wop);
237 wop = new WOptionPane();
238 tabbar.addTab(tr("Advanced"), wop);
241 option = new Option(8, "VDR-Pri 0=OK !See forums!", "General", "Live priority", Option::TYPE_INT, 199, -1, -99, NULL);
242 options.push_back(option);
243 wop->addOptionLine(option);
244 option = new Option(13, "TCP receive window size", "Advanced", "TCP receive window", Option::TYPE_TEXT, 8, /*1*/DEFAULT_TCP_WINDOWSIZENR, 0, options13);
245 options.push_back(option);
246 wop->addOptionLine(option);
248 option = new Option(14, "Use WSS (PAL only)", "General", "WSS", Option::TYPE_TEXT, 2, 0, 0, options14);
249 options.push_back(option);
250 wop->addOptionLine(option);
252 const char * * fontnames;
253 const char * * fontnames_keys;
254 int numfonts=Osd::getInstance()->getFontNames(&fontnames,&fontnames_keys);
256 option = new Option(17, "Font Name", "Advanced", "Font Name", Option::TYPE_KEYED_TEXT, numfonts, 1, 0, fontnames,fontnames_keys);
257 options.push_back(option);
258 wop->addOptionLine(option);
261 #ifdef ADVANCED_MENUES
262 option = new Option(19, "Advanced Menu", "General", "Menu type",Option::TYPE_TEXT, 2, 0, 0, options19);
263 options.push_back(option);
264 wop->addOptionLine(option);
267 Remote::getInstance()->addOptionsToPanes(2,&options,wop);
268 Video::getInstance()->addOptionsToPanes(2,&options,wop);
269 Audio::getInstance()->addOptionsToPanes(2,&options,wop);
274 // for (int i = 0; i < numPanes; i++) delete panes[i]; //Move to TabBar, Marten
277 for(vector<Option*>::iterator j = options.begin(); j != options.end(); j++) delete *j;
279 delete[] options2keys;
282 int VOpts::handleCommand(int command)
284 // either is active, handle back
285 if (command == Remote::BACK)
292 int retval = tabbar.handleCommand(command);
295 BoxStack::getInstance()->update(this);
298 else if (retval == 2)
300 // command was taken and actively ignored
312 VDR* vdr = VDR::getInstance();
314 Remote::getInstance()->saveOptionstoServer(); //Remote
315 Video::getInstance()->saveOptionstoServer(); //Video
316 Audio::getInstance()->saveOptionstoServer(); //Remote
317 #ifdef VOMP_PLATTFORM_MVP
318 MediaOptions::getInstance()->saveOptionstoServer(); //Media
321 // Damn, and the dynamic idea was going *so* well...
322 //Whats about a check with typeid operator?
324 wop = (WOptionPane*)panes[0];
326 wop = (WOptionPane*)panes[1];
328 wop = (WOptionPane*)panes[2];
332 for (UINT i = 0; i < options.size(); i++)
334 if (options[i]->configChoice == options[i]->userSetChoice) continue; // no change
336 Log::getInstance()->log("Options", Log::DEBUG, "Option %i has changed", i);
340 if (options[i]->optionType == Option::TYPE_TEXT)
342 vdr->configSave(options[i]->configSection, options[i]->configKey, options[i]->options[options[i]->userSetChoice]);
344 else if (options[i]->optionType == Option::TYPE_KEYED_TEXT)
346 vdr->configSave(options[i]->configSection, options[i]->configKey, options[i]->optionkeys[options[i]->userSetChoice]);
351 sprintf(buffer, "%i", options[i]->userSetChoice);
352 vdr->configSave(options[i]->configSection, options[i]->configKey, buffer);
356 if (options[i]->opthandler == NULL) //Ok, noone else is handling this, we are doing it
358 switch(options[i]->id)
362 #ifdef MVP_REMOTE_TYPES
363 if (options[i]->userSetChoice == 1)
365 Log::getInstance()->log("Options", Log::DEBUG, "Setting New Remote");
366 Remote::getInstance()->setRemoteType(Remote::NEWREMOTE);
370 Log::getInstance()->log("Options", Log::DEBUG, "Setting Old Remote");
371 Remote::getInstance()->setRemoteType(Remote::OLDREMOTE);
378 Message* m = new Message();
379 m->message = Message::CHANGE_LANGUAGE;
380 m->to = Command::getInstance();
381 Command::getInstance()->postMessageNoLock(m);
386 if (STRCASECMP(options[i]->optionkeys[options[i]->userSetChoice], "RGB+composite")==0)
388 Log::getInstance()->log("Options", Log::DEBUG, "Setting RGB/Composite");
389 Video::getInstance()->setConnection(Video::COMPOSITERGB);
391 else if (STRCASECMP(options[i]->optionkeys[options[i]->userSetChoice], "S-Video")==0)
393 Log::getInstance()->log("Options", Log::DEBUG, "Setting S-Video");
394 Video::getInstance()->setConnection(Video::SVIDEO);
396 else if (STRCASECMP(options[i]->optionkeys[options[i]->userSetChoice], "HDMI")==0)
398 Log::getInstance()->log("Options", Log::DEBUG, "Setting HDMI");
399 Video::getInstance()->setConnection(Video::HDMI);
401 else if (STRCASECMP(options[i]->optionkeys[options[i]->userSetChoice], "HDMI3D")==0)
403 Log::getInstance()->log("Options", Log::DEBUG, "Setting HDMI");
404 Video::getInstance()->setConnection(Video::HDMI3D);
410 if (STRCASECMP(options[i]->optionkeys[options[i]->userSetChoice], "16:9")==0)
412 Log::getInstance()->log("Options", Log::DEBUG, "Setting 16:9 TV");
413 Video::getInstance()->setTVsize(Video::ASPECT16X9);
415 else if (STRCASECMP(options[i]->optionkeys[options[i]->userSetChoice], "4:3")==0)
417 Log::getInstance()->log("Options", Log::DEBUG, "Setting 4:3 TV");
418 Video::getInstance()->setTVsize(Video::ASPECT4X3);
420 else if (STRCASECMP(options[i]->optionkeys[options[i]->userSetChoice], "14:9")==0)
422 Log::getInstance()->log("Options", Log::DEBUG, "Setting 14:9 TV");
423 Video::getInstance()->setTVsize(Video::ASPECT14X9);
429 if (options[i]->userSetChoice == 1)
431 Log::getInstance()->log("Options", Log::DEBUG, "Setting letterbox");
432 Video::getInstance()->setMode(Video::LETTERBOX);
436 Log::getInstance()->log("Options", Log::DEBUG, "Setting chop-sides");
437 Video::getInstance()->setMode(Video::NORMAL);
443 size_t newTCPsize = 2048;
444 if (options[i]->userSetChoice == 0) newTCPsize = 0; //zero means auto
445 else if (options[i]->userSetChoice == 1) newTCPsize = 1024;
446 else if (options[i]->userSetChoice == 2) newTCPsize = 2048;
447 else if (options[i]->userSetChoice == 3) newTCPsize = 4096;
448 else if (options[i]->userSetChoice == 4) newTCPsize = 8192;
449 else if (options[i]->userSetChoice == 5) newTCPsize = 16384;
450 else if (options[i]->userSetChoice == 6) newTCPsize = 32768;
451 else if (options[i]->userSetChoice == 7) newTCPsize = 65536;
452 Log::getInstance()->log("Options", Log::DEBUG, "Setting TCP window size %i", newTCPsize);
453 VDR::getInstance()->setReceiveWindow(newTCPsize);
458 Osd::getInstance()->setFont(options[i]->optionkeys[options[i]->userSetChoice]);
463 if (options[i]->userSetChoice == 1)
465 Log::getInstance()->log("Options", Log::DEBUG, "Setting automatic vdr shutdown");
466 VDR::getInstance()->setVDRShutdown(true);
470 Log::getInstance()->log("Options", Log::DEBUG, "Setting local shutdown");
471 VDR::getInstance()->setVDRShutdown(false);
477 if (options[i]->userSetChoice == 1)
479 Log::getInstance()->log("Options", Log::DEBUG, "Setting classic menu");
480 Command::getInstance()->setAdvMenues(false);
484 Log::getInstance()->log("Options", Log::DEBUG, "Setting advanced menu");
485 Command::getInstance()->setAdvMenues(true);
493 options[i]->opthandler->handleOptionChanges(options[i]);
498 void VOpts::processMessage(Message* m)
500 if (m->message == Message::MOUSE_MOVE)
502 int x=(m->parameter>>16)-getScreenX();
503 int y=(m->parameter&0xFFFF)-getScreenY();
504 if (tabbar.mouseMove(x,y))
506 BoxStack::getInstance()->update(this);
510 else if (m->message == Message::MOUSE_LBDOWN)
512 int x=(m->parameter>>16)-getScreenX();
513 int y=(m->parameter&0xFFFF)-getScreenY();
514 if (tabbar.mouseLBDOWN(x,y))
516 BoxStack::getInstance()->update(this);
518 else if (x<0 || y <0 || x>(int)getWidth() || y>(int)getHeight())
520 BoxStack::getInstance()->handleCommand(Remote::BACK); //simulate cancel press