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"
35 #include "staticartwork.h"
37 #ifdef VOMP_PLATTFORM_MVP
38 #include "mediaoptions.h"
41 //#include "command.h"
46 setTitleBarColour(DrawStyle::TITLEBARBACKGROUND);
47 setTitleText(tr("Options"));
48 TVMediaInfo *info= new TVMediaInfo();
49 info->setStaticArtwork(sa_properties);
50 setTitleBarIcon(info);
55 if (Video::getInstance()->getFormat() == Video::PAL)
56 setPosition(100, 110);
60 tabbar.setPosition(6, 32);
61 tabbar.setSize(getWidth() - 12, getHeight() - 34);
67 // --- edit options start here
68 #ifdef MVP_REMOTE_TYPES
69 static const char* options1[] = {"Old", "New"};
71 static const char* options5[] = {"Chop sides", "Letterbox"};
72 static const char* options6[] = {"On", "Off", "Last state"};
73 static const char* options7[] = {"All", "FTA only"};
74 static const char* options15[] = {"Alphabetical", "Chronological"};
76 static const char* options13[] = {"Auto","1024", "2048", "4096", "8192", "16384", "32768", "65536"};
78 static const char* options14[] = {"No", "Yes"};
80 static const char* options18[] = {"Off", "On"};
81 #ifdef ADVANCED_MENUES
82 static const char* options19[] = { "Advanced","Classic"};
84 // Get list of languages from VDR and construct options table
85 LangCode = VDR::getInstance()->getLanguageList();
86 options2 = new const char*[LangCode.size()];
87 options2keys = new const char*[LangCode.size()];
88 I18n::lang_code_list::const_iterator iter;
90 for (iter = LangCode.begin(); iter != LangCode.end(); ++iter,++LangNumber)
92 options2[LangNumber] = iter->second.c_str();
93 options2keys[LangNumber] = iter->first.c_str();
97 panes = new Boxx*[numPanes];
99 wop = new WOptionPane();
100 tabbar.addTab(tr("General"), wop);
102 #ifdef MVP_REMOTE_TYPES
103 option = new Option(1, "Remote control type", "General", "Remote type", Option::TYPE_TEXT, 2, 0, 0, options1);
104 options.push_back(option);
105 wop->addOptionLine(option);
107 option = new Option(2, "Language", "General", "LangCode", Option::TYPE_KEYED_TEXT, LangCode.size(), 0, 0, options2, options2keys);
108 options.push_back(option);
109 wop->addOptionLine(option);
111 UINT suppconn = Video::getInstance()->getSupportedFormats();
114 if (suppconn & Video::COMPOSITERGB) {
116 options3.push_back("RGB+composite");
117 options3keys.push_back("RGB+composite");
119 if (Video::SVIDEO & suppconn) {
120 options3.push_back("S-Video");
121 options3keys.push_back("S-Video");
123 if (Video::HDMI & suppconn) {
124 defaultch = options3.size();
125 options3.push_back("HDMI");
126 options3keys.push_back("HDMI");
128 if (Video::HDMI3D & suppconn) {
129 options3.push_back("HDMI3D");
130 options3keys.push_back("HDMI3D");
132 option = new Option(3, "TV connection type", "TV", "Connection",
133 Option::TYPE_KEYED_TEXT, options3.size(), defaultch, 0,
134 &(options3[0]), &(options3keys[0]));
136 options.push_back(option);
137 wop->addOptionLine(option);
140 UINT suppformats = Video::getInstance()->supportedTVFormats();
143 options16.push_back("NTSC");
144 options16keys.push_back("NTSC");
145 if (suppformats & Video::PAL) {
147 options16.push_back("PAL");
148 options16keys.push_back("PAL");
150 if (Video::NTSC_J & suppformats) {
151 options16.push_back("NTSC-J");
152 options16keys.push_back("NTSC-J");
154 if (Video::PAL_M & suppformats) {
155 options16.push_back("PAL-M");
156 options16keys.push_back("PAL-M");
159 option = new Option(16, "TV standard (needs restart)", "General", "Override Video Format",
160 Option::TYPE_KEYED_TEXT, options16.size(), defaultch, 0,
161 &(options16[0]), &(options16keys[0]));
163 options.push_back(option);
164 wop->addOptionLine(option);
167 UINT supptvsize=Video::getInstance()->supportedTVsize();
170 options4.push_back("4:3");
171 options4keys.push_back("4:3");
172 if (Video::ASPECT16X9 & supptvsize) {
173 options4.push_back("16:9");
174 options4keys.push_back("16:9");
177 if (Video::ASPECT14X9 & supptvsize) {
178 options4.push_back("14:9");
179 options4keys.push_back("14:9");
181 option = new Option(4, "TV aspect ratio", "TV", "Aspect",
182 Option::TYPE_KEYED_TEXT, options4.size(), defaultch, 0,
183 &(options4[0]), &(options4keys[0]));
184 options.push_back(option);
185 wop->addOptionLine(option);
188 option = new Option(5, "16:9 on 4:3 display mode", "TV", "Widemode", Option::TYPE_TEXT, 2, 0, 0, options5);
189 options.push_back(option);
190 wop->addOptionLine(option);
191 option = new Option(6, "Power state after bootup", "General", "Power After Boot", Option::TYPE_TEXT, 3, 0, 0, options6);
192 options.push_back(option);
193 wop->addOptionLine(option);
194 option = new Option(7, "Display channels", "General", "Channels", Option::TYPE_TEXT, 2, 0, 0, options7);
195 options.push_back(option);
196 wop->addOptionLine(option);
197 option = new Option(15, "Recordings sort order", "General", "Recordings Sort Order", Option::TYPE_TEXT, 2, 0, 0, options15);
198 options.push_back(option);
199 wop->addOptionLine(option);
200 option = new Option(18, "Automatic VDR shutdown", "General", "VDR shutdown", Option::TYPE_TEXT, 2, 0, 0, options18);
201 options.push_back(option);
202 wop->addOptionLine(option);
204 Remote::getInstance()->addOptionsToPanes(0,&options,wop);
205 Video::getInstance()->addOptionsToPanes(0,&options,wop);
206 Audio::getInstance()->addOptionsToPanes(0,&options,wop);
209 /* WRemoteConfig* wrc = new WRemoteConfig();
210 tabbar.addTab(tr("Remote Control"), wrc);*/
211 Remote::getInstance()->addOptionPagesToWTB(&tabbar);
214 Video::getInstance()->addOptionPagesToWTB(&tabbar);
215 Audio::getInstance()->addOptionPagesToWTB(&tabbar);
216 #ifdef VOMP_PLATTFORM_MVP
217 MediaOptions::getInstance()->addOptionPagesToWTB(&tabbar);
221 wop = new WOptionPane();
222 tabbar.addTab(tr("Timers"), wop);
225 option = new Option(9, "Default start margin (minutes)", "Timers", "Start margin", Option::TYPE_INT, 20, 5, 0, NULL);
226 options.push_back(option);
227 wop->addOptionLine(option);
228 option = new Option(10, "Default end margin (minutes)", "Timers", "End margin", Option::TYPE_INT, 20, 5, 0, NULL);
229 options.push_back(option);
230 wop->addOptionLine(option);
231 option = new Option(11, "Default priority", "Timers", "Priority", Option::TYPE_INT, 100, 99, 0, NULL);
232 options.push_back(option);
233 wop->addOptionLine(option);
234 option = new Option(12, "Default lifetime", "Timers", "Lifetime", Option::TYPE_INT, 100, 99, 0, NULL);
235 options.push_back(option);
236 wop->addOptionLine(option);
238 Remote::getInstance()->addOptionsToPanes(1,&options,wop);
239 Video::getInstance()->addOptionsToPanes(1,&options,wop);
240 Audio::getInstance()->addOptionsToPanes(1,&options,wop);
243 wop = new WOptionPane();
244 tabbar.addTab(tr("Advanced"), wop);
247 option = new Option(8, "VDR-Pri 0=OK !See forums!", "General", "Live priority", Option::TYPE_INT, 199, -1, -99, NULL);
248 options.push_back(option);
249 wop->addOptionLine(option);
250 option = new Option(13, "TCP receive window size", "Advanced", "TCP receive window", Option::TYPE_TEXT, 8, /*1*/DEFAULT_TCP_WINDOWSIZENR, 0, options13);
251 options.push_back(option);
252 wop->addOptionLine(option);
254 option = new Option(14, "Use WSS (PAL only)", "General", "WSS", Option::TYPE_TEXT, 2, 0, 0, options14);
255 options.push_back(option);
256 wop->addOptionLine(option);
258 const char * * fontnames;
259 const char * * fontnames_keys;
260 int numfonts=Osd::getInstance()->getFontNames(&fontnames,&fontnames_keys);
262 option = new Option(17, "Font Name", "Advanced", "Font Name", Option::TYPE_KEYED_TEXT, numfonts, 1, 0, fontnames,fontnames_keys);
263 options.push_back(option);
264 wop->addOptionLine(option);
267 int numskins=SkinFactory::getNumberofSkins();
269 option = new Option(20, "Skin Name (needs restart)", "Advanced", "Skin Name", Option::TYPE_KEYED_TEXT, numskins, 0, 0,
270 SkinFactory::getSkinNames(),SkinFactory::getSkinNames());
271 options.push_back(option);
272 wop->addOptionLine(option);
275 #ifdef ADVANCED_MENUES
276 option = new Option(19, "Advanced Menu", "Advanced", "Menu type",Option::TYPE_TEXT, 2, 0, 0, options19);
277 options.push_back(option);
278 wop->addOptionLine(option);
281 Remote::getInstance()->addOptionsToPanes(2,&options,wop);
282 Video::getInstance()->addOptionsToPanes(2,&options,wop);
283 Audio::getInstance()->addOptionsToPanes(2,&options,wop);
288 // for (int i = 0; i < numPanes; i++) delete panes[i]; //Move to TabBar, Marten
291 for(vector<Option*>::iterator j = options.begin(); j != options.end(); j++) delete *j;
293 delete[] options2keys;
296 int VOpts::handleCommand(int command)
298 // either is active, handle back
299 if (command == Remote::BACK)
306 int retval = tabbar.handleCommand(command);
309 BoxStack::getInstance()->update(this);
312 else if (retval == 2)
314 // command was taken and actively ignored
326 VDR* vdr = VDR::getInstance();
328 Remote::getInstance()->saveOptionstoServer(); //Remote
329 Video::getInstance()->saveOptionstoServer(); //Video
330 Audio::getInstance()->saveOptionstoServer(); //Remote
331 #ifdef VOMP_PLATTFORM_MVP
332 MediaOptions::getInstance()->saveOptionstoServer(); //Media
335 // Damn, and the dynamic idea was going *so* well...
336 //Whats about a check with typeid operator?
338 wop = (WOptionPane*)panes[0];
340 wop = (WOptionPane*)panes[1];
342 wop = (WOptionPane*)panes[2];
346 for (UINT i = 0; i < options.size(); i++)
348 if (options[i]->configChoice == options[i]->userSetChoice) continue; // no change
350 Log::getInstance()->log("Options", Log::DEBUG, "Option %i has changed", i);
354 if (options[i]->optionType == Option::TYPE_TEXT)
356 vdr->configSave(options[i]->configSection, options[i]->configKey, options[i]->options[options[i]->userSetChoice]);
358 else if (options[i]->optionType == Option::TYPE_KEYED_TEXT)
360 vdr->configSave(options[i]->configSection, options[i]->configKey, options[i]->optionkeys[options[i]->userSetChoice]);
365 sprintf(buffer, "%i", options[i]->userSetChoice);
366 vdr->configSave(options[i]->configSection, options[i]->configKey, buffer);
370 if (options[i]->opthandler == NULL) //Ok, noone else is handling this, we are doing it
372 switch(options[i]->id)
376 #ifdef MVP_REMOTE_TYPES
377 if (options[i]->userSetChoice == 1)
379 Log::getInstance()->log("Options", Log::DEBUG, "Setting New Remote");
380 Remote::getInstance()->setRemoteType(Remote::NEWREMOTE);
384 Log::getInstance()->log("Options", Log::DEBUG, "Setting Old Remote");
385 Remote::getInstance()->setRemoteType(Remote::OLDREMOTE);
392 Message* m = new Message();
393 m->message = Message::CHANGE_LANGUAGE;
394 m->to = Command::getInstance();
395 Command::getInstance()->postMessageNoLock(m);
400 if (STRCASECMP(options[i]->optionkeys[options[i]->userSetChoice], "RGB+composite")==0)
402 Log::getInstance()->log("Options", Log::DEBUG, "Setting RGB/Composite");
403 Video::getInstance()->setConnection(Video::COMPOSITERGB);
405 else if (STRCASECMP(options[i]->optionkeys[options[i]->userSetChoice], "S-Video")==0)
407 Log::getInstance()->log("Options", Log::DEBUG, "Setting S-Video");
408 Video::getInstance()->setConnection(Video::SVIDEO);
410 else if (STRCASECMP(options[i]->optionkeys[options[i]->userSetChoice], "HDMI")==0)
412 Log::getInstance()->log("Options", Log::DEBUG, "Setting HDMI");
413 Video::getInstance()->setConnection(Video::HDMI);
415 else if (STRCASECMP(options[i]->optionkeys[options[i]->userSetChoice], "HDMI3D")==0)
417 Log::getInstance()->log("Options", Log::DEBUG, "Setting HDMI");
418 Video::getInstance()->setConnection(Video::HDMI3D);
424 if (STRCASECMP(options[i]->optionkeys[options[i]->userSetChoice], "16:9")==0)
426 Log::getInstance()->log("Options", Log::DEBUG, "Setting 16:9 TV");
427 Video::getInstance()->setTVsize(Video::ASPECT16X9);
429 else if (STRCASECMP(options[i]->optionkeys[options[i]->userSetChoice], "4:3")==0)
431 Log::getInstance()->log("Options", Log::DEBUG, "Setting 4:3 TV");
432 Video::getInstance()->setTVsize(Video::ASPECT4X3);
434 else if (STRCASECMP(options[i]->optionkeys[options[i]->userSetChoice], "14:9")==0)
436 Log::getInstance()->log("Options", Log::DEBUG, "Setting 14:9 TV");
437 Video::getInstance()->setTVsize(Video::ASPECT14X9);
443 if (options[i]->userSetChoice == 1)
445 Log::getInstance()->log("Options", Log::DEBUG, "Setting letterbox");
446 Video::getInstance()->setMode(Video::LETTERBOX);
450 Log::getInstance()->log("Options", Log::DEBUG, "Setting chop-sides");
451 Video::getInstance()->setMode(Video::NORMAL);
457 size_t newTCPsize = 2048;
458 if (options[i]->userSetChoice == 0) newTCPsize = 0; //zero means auto
459 else if (options[i]->userSetChoice == 1) newTCPsize = 1024;
460 else if (options[i]->userSetChoice == 2) newTCPsize = 2048;
461 else if (options[i]->userSetChoice == 3) newTCPsize = 4096;
462 else if (options[i]->userSetChoice == 4) newTCPsize = 8192;
463 else if (options[i]->userSetChoice == 5) newTCPsize = 16384;
464 else if (options[i]->userSetChoice == 6) newTCPsize = 32768;
465 else if (options[i]->userSetChoice == 7) newTCPsize = 65536;
466 Log::getInstance()->log("Options", Log::DEBUG, "Setting TCP window size %i", newTCPsize);
467 VDR::getInstance()->setReceiveWindow(newTCPsize);
472 Osd::getInstance()->setFont(options[i]->optionkeys[options[i]->userSetChoice]);
477 if (options[i]->userSetChoice == 1)
479 Log::getInstance()->log("Options", Log::DEBUG, "Setting automatic vdr shutdown");
480 VDR::getInstance()->setVDRShutdown(true);
484 Log::getInstance()->log("Options", Log::DEBUG, "Setting local shutdown");
485 VDR::getInstance()->setVDRShutdown(false);
491 if (options[i]->userSetChoice == 1)
493 Log::getInstance()->log("Options", Log::DEBUG, "Setting classic menu");
494 Command::getInstance()->setAdvMenues(false);
498 Log::getInstance()->log("Options", Log::DEBUG, "Setting advanced menu");
499 Command::getInstance()->setAdvMenues(true);
505 SkinFactory::InitSkin(options[i]->userSetChoice);
506 Log::getInstance()->log("Options", Log::DEBUG, "Init Skin %d",options[i]->userSetChoice);
513 options[i]->opthandler->handleOptionChanges(options[i]);
518 void VOpts::processMessage(Message* m)
520 if (m->message == Message::MOUSE_MOVE)
522 int x=(m->parameter.num>>16)-getScreenX();
523 int y=(m->parameter.num&0xFFFF)-getScreenY();
524 if (tabbar.mouseMove(x,y))
526 BoxStack::getInstance()->update(this);
530 else if (m->message == Message::MOUSE_LBDOWN)
532 int x=(m->parameter.num>>16)-getScreenX();
533 int y=(m->parameter.num&0xFFFF)-getScreenY();
534 if (tabbar.mouseLBDOWN(x,y))
536 BoxStack::getInstance()->update(this);
538 else if (x<0 || y <0 || x>(int)getWidth() || y>(int)getHeight())
540 BoxStack::getInstance()->handleCommand(Remote::BACK); //simulate cancel press