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 // Get list of languages from VDR and construct options table
76 LangCode = VDR::getInstance()->getLanguageList();
77 options2 = new const char*[LangCode.size()];
78 options2keys = new const char*[LangCode.size()];
79 I18n::lang_code_list::const_iterator iter;
81 for (iter = LangCode.begin(); iter != LangCode.end(); ++iter,++LangNumber)
83 options2[LangNumber] = iter->second.c_str();
84 options2keys[LangNumber] = iter->first.c_str();
88 panes = new Boxx*[numPanes];
90 wop = new WOptionPane();
91 tabbar.addTab(tr("General"), wop);
93 #ifdef MVP_REMOTE_TYPES
94 option = new Option(1, "Remote control type", "General", "Remote type", Option::TYPE_TEXT, 2, 0, 0, options1);
95 options.push_back(option);
96 wop->addOptionLine(option);
98 option = new Option(2, "Language", "General", "LangCode", Option::TYPE_KEYED_TEXT, LangCode.size(), 0, 0, options2, options2keys);
99 options.push_back(option);
100 wop->addOptionLine(option);
103 UINT suppconn = Video::getInstance()->getSupportedFormats();
106 if (suppconn & Video::COMPOSITERGB) {
108 options3.push_back("RGB+composite");
109 options3keys.push_back("RGB+composite");
111 if (Video::SVIDEO & suppconn) {
112 options3.push_back("S-Video");
113 options3keys.push_back("S-Video");
115 if (Video::HDMI & suppconn) {
116 defaultch = options3.size();
117 options3.push_back("HDMI");
118 options3keys.push_back("HDMI");
120 if (Video::HDMI3D & suppconn) {
121 options3.push_back("HDMI3D");
122 options3keys.push_back("HDMI3D");
124 option = new Option(3, "TV connection type", "TV", "Connection",
125 Option::TYPE_KEYED_TEXT, options3.size(), defaultch, 0,
126 &(options3[0]), &(options3keys[0]));
128 options.push_back(option);
129 wop->addOptionLine(option);
132 UINT suppformats = Video::getInstance()->supportedTVFormats();
135 options16.push_back("NTSC");
136 options16keys.push_back("NTSC");
137 if (suppformats & Video::PAL) {
139 options16.push_back("PAL");
140 options16keys.push_back("PAL");
142 if (Video::NTSC_J & suppformats) {
143 options16.push_back("NTSC-J");
144 options16keys.push_back("NTSC-J");
146 if (Video::PAL_M & suppformats) {
147 options16.push_back("PAL-M");
148 options16keys.push_back("PAL-M");
151 option = new Option(16, "TV standard (needs restart)", "General", "Override Video Format",
152 Option::TYPE_KEYED_TEXT, options16.size(), defaultch, 0,
153 &(options16[0]), &(options16keys[0]));
155 options.push_back(option);
156 wop->addOptionLine(option);
159 UINT supptvsize=Video::getInstance()->supportedTVsize();
162 options4.push_back("4:3");
163 options4keys.push_back("4:3");
164 if (Video::ASPECT16X9 & supptvsize) {
165 options4.push_back("16:9");
166 options4keys.push_back("16:9");
169 if (Video::ASPECT14X9 & supptvsize) {
170 options4.push_back("14:9");
171 options4keys.push_back("14:9");
173 option = new Option(4, "TV aspect ratio", "TV", "Aspect",
174 Option::TYPE_KEYED_TEXT, options4.size(), defaultch, 0,
175 &(options4[0]), &(options4keys[0]));
176 options.push_back(option);
177 wop->addOptionLine(option);
180 option = new Option(5, "16:9 on 4:3 display mode", "TV", "Widemode", Option::TYPE_TEXT, 2, 0, 0, options5);
181 options.push_back(option);
182 wop->addOptionLine(option);
183 option = new Option(6, "Power state after bootup", "General", "Power After Boot", Option::TYPE_TEXT, 3, 0, 0, options6);
184 options.push_back(option);
185 wop->addOptionLine(option);
186 option = new Option(7, "Display channels", "General", "Channels", Option::TYPE_TEXT, 2, 0, 0, options7);
187 options.push_back(option);
188 wop->addOptionLine(option);
189 option = new Option(15, "Recordings sort order", "General", "Recordings Sort Order", Option::TYPE_TEXT, 2, 0, 0, options15);
190 options.push_back(option);
191 wop->addOptionLine(option);
192 option = new Option(18, "Automatic VDR shutdown", "General", "VDR shutdown", Option::TYPE_TEXT, 2, 0, 0, options18);
193 options.push_back(option);
194 wop->addOptionLine(option);
196 Remote::getInstance()->addOptionsToPanes(0,&options,wop);
197 Video::getInstance()->addOptionsToPanes(0,&options,wop);
198 Audio::getInstance()->addOptionsToPanes(0,&options,wop);
201 /* WRemoteConfig* wrc = new WRemoteConfig();
202 tabbar.addTab(tr("Remote Control"), wrc);*/
203 Remote::getInstance()->addOptionPagesToWTB(&tabbar);
206 Video::getInstance()->addOptionPagesToWTB(&tabbar);
207 Audio::getInstance()->addOptionPagesToWTB(&tabbar);
208 #ifdef VOMP_PLATTFORM_MVP
209 MediaOptions::getInstance()->addOptionPagesToWTB(&tabbar);
213 wop = new WOptionPane();
214 tabbar.addTab(tr("Timers"), wop);
217 option = new Option(9, "Default start margin (minutes)", "Timers", "Start margin", Option::TYPE_INT, 20, 5, 0, NULL);
218 options.push_back(option);
219 wop->addOptionLine(option);
220 option = new Option(10, "Default end margin (minutes)", "Timers", "End margin", Option::TYPE_INT, 20, 5, 0, NULL);
221 options.push_back(option);
222 wop->addOptionLine(option);
223 option = new Option(11, "Default priority", "Timers", "Priority", Option::TYPE_INT, 100, 99, 0, NULL);
224 options.push_back(option);
225 wop->addOptionLine(option);
226 option = new Option(12, "Default lifetime", "Timers", "Lifetime", Option::TYPE_INT, 100, 99, 0, NULL);
227 options.push_back(option);
228 wop->addOptionLine(option);
230 Remote::getInstance()->addOptionsToPanes(1,&options,wop);
231 Video::getInstance()->addOptionsToPanes(1,&options,wop);
232 Audio::getInstance()->addOptionsToPanes(1,&options,wop);
235 wop = new WOptionPane();
236 tabbar.addTab(tr("Advanced"), wop);
239 option = new Option(8, "VDR-Pri 0=OK !See forums!", "General", "Live priority", Option::TYPE_INT, 199, -1, -99, NULL);
240 options.push_back(option);
241 wop->addOptionLine(option);
242 option = new Option(13, "TCP receive window size", "Advanced", "TCP receive window", Option::TYPE_TEXT, 8, /*1*/DEFAULT_TCP_WINDOWSIZENR, 0, options13);
243 options.push_back(option);
244 wop->addOptionLine(option);
246 option = new Option(14, "Use WSS (PAL only)", "General", "WSS", Option::TYPE_TEXT, 2, 0, 0, options14);
247 options.push_back(option);
248 wop->addOptionLine(option);
250 const char * * fontnames;
251 const char * * fontnames_keys;
252 int numfonts=Osd::getInstance()->getFontNames(&fontnames,&fontnames_keys);
254 option = new Option(17, "Font Name", "Advanced", "Font Name", Option::TYPE_KEYED_TEXT, numfonts, 1, 0, fontnames,fontnames_keys);
255 options.push_back(option);
256 wop->addOptionLine(option);
259 Remote::getInstance()->addOptionsToPanes(2,&options,wop);
260 Video::getInstance()->addOptionsToPanes(2,&options,wop);
261 Audio::getInstance()->addOptionsToPanes(2,&options,wop);
266 // for (int i = 0; i < numPanes; i++) delete panes[i]; //Move to TabBar, Marten
269 for(vector<Option*>::iterator j = options.begin(); j != options.end(); j++) delete *j;
271 delete[] options2keys;
274 int VOpts::handleCommand(int command)
276 // either is active, handle back
277 if (command == Remote::BACK)
284 int retval = tabbar.handleCommand(command);
287 BoxStack::getInstance()->update(this);
290 else if (retval == 2)
292 // command was taken and actively ignored
304 VDR* vdr = VDR::getInstance();
306 Remote::getInstance()->saveOptionstoServer(); //Remote
307 Video::getInstance()->saveOptionstoServer(); //Video
308 Audio::getInstance()->saveOptionstoServer(); //Remote
309 #ifdef VOMP_PLATTFORM_MVP
310 MediaOptions::getInstance()->saveOptionstoServer(); //Media
313 // Damn, and the dynamic idea was going *so* well...
314 //Whats about a check with typeid operator?
316 wop = (WOptionPane*)panes[0];
318 wop = (WOptionPane*)panes[1];
320 wop = (WOptionPane*)panes[2];
324 for (UINT i = 0; i < options.size(); i++)
326 if (options[i]->configChoice == options[i]->userSetChoice) continue; // no change
328 Log::getInstance()->log("Options", Log::DEBUG, "Option %i has changed", i);
332 if (options[i]->optionType == Option::TYPE_TEXT)
334 vdr->configSave(options[i]->configSection, options[i]->configKey, options[i]->options[options[i]->userSetChoice]);
336 else if (options[i]->optionType == Option::TYPE_KEYED_TEXT)
338 vdr->configSave(options[i]->configSection, options[i]->configKey, options[i]->optionkeys[options[i]->userSetChoice]);
343 sprintf(buffer, "%i", options[i]->userSetChoice);
344 vdr->configSave(options[i]->configSection, options[i]->configKey, buffer);
348 if (options[i]->opthandler == NULL) //Ok, noone else is handling this, we are doing it
350 switch(options[i]->id)
354 #ifdef MVP_REMOTE_TYPES
355 if (options[i]->userSetChoice == 1)
357 Log::getInstance()->log("Options", Log::DEBUG, "Setting New Remote");
358 Remote::getInstance()->setRemoteType(Remote::NEWREMOTE);
362 Log::getInstance()->log("Options", Log::DEBUG, "Setting Old Remote");
363 Remote::getInstance()->setRemoteType(Remote::OLDREMOTE);
370 Message* m = new Message();
371 m->message = Message::CHANGE_LANGUAGE;
372 m->to = Command::getInstance();
373 Command::getInstance()->postMessageNoLock(m);
378 if (STRCASECMP(options[i]->optionkeys[options[i]->userSetChoice], "RGB+composite")==0)
380 Log::getInstance()->log("Options", Log::DEBUG, "Setting RGB/Composite");
381 Video::getInstance()->setConnection(Video::COMPOSITERGB);
383 else if (STRCASECMP(options[i]->optionkeys[options[i]->userSetChoice], "S-Video")==0)
385 Log::getInstance()->log("Options", Log::DEBUG, "Setting S-Video");
386 Video::getInstance()->setConnection(Video::SVIDEO);
388 else if (STRCASECMP(options[i]->optionkeys[options[i]->userSetChoice], "HDMI")==0)
390 Log::getInstance()->log("Options", Log::DEBUG, "Setting HDMI");
391 Video::getInstance()->setConnection(Video::HDMI);
393 else if (STRCASECMP(options[i]->optionkeys[options[i]->userSetChoice], "HDMI3D")==0)
395 Log::getInstance()->log("Options", Log::DEBUG, "Setting HDMI");
396 Video::getInstance()->setConnection(Video::HDMI3D);
402 if (STRCASECMP(options[i]->optionkeys[options[i]->userSetChoice], "16:9")==0)
404 Log::getInstance()->log("Options", Log::DEBUG, "Setting 16:9 TV");
405 Video::getInstance()->setTVsize(Video::ASPECT16X9);
407 else if (STRCASECMP(options[i]->optionkeys[options[i]->userSetChoice], "4:3")==0)
409 Log::getInstance()->log("Options", Log::DEBUG, "Setting 4:3 TV");
410 Video::getInstance()->setTVsize(Video::ASPECT4X3);
412 else if (STRCASECMP(options[i]->optionkeys[options[i]->userSetChoice], "14:9")==0)
414 Log::getInstance()->log("Options", Log::DEBUG, "Setting 14:9 TV");
415 Video::getInstance()->setTVsize(Video::ASPECT14X9);
421 if (options[i]->userSetChoice == 1)
423 Log::getInstance()->log("Options", Log::DEBUG, "Setting letterbox");
424 Video::getInstance()->setMode(Video::LETTERBOX);
428 Log::getInstance()->log("Options", Log::DEBUG, "Setting chop-sides");
429 Video::getInstance()->setMode(Video::NORMAL);
435 size_t newTCPsize = 2048;
436 if (options[i]->userSetChoice == 0) newTCPsize = 0; //zero means auto
437 else if (options[i]->userSetChoice == 1) newTCPsize = 1024;
438 else if (options[i]->userSetChoice == 2) newTCPsize = 2048;
439 else if (options[i]->userSetChoice == 3) newTCPsize = 4096;
440 else if (options[i]->userSetChoice == 4) newTCPsize = 8192;
441 else if (options[i]->userSetChoice == 5) newTCPsize = 16384;
442 else if (options[i]->userSetChoice == 6) newTCPsize = 32768;
443 else if (options[i]->userSetChoice == 7) newTCPsize = 65536;
444 Log::getInstance()->log("Options", Log::DEBUG, "Setting TCP window size %i", newTCPsize);
445 VDR::getInstance()->setReceiveWindow(newTCPsize);
450 Osd::getInstance()->setFont(options[i]->optionkeys[options[i]->userSetChoice]);
455 if (options[i]->userSetChoice == 1)
457 Log::getInstance()->log("Options", Log::DEBUG, "Setting automatic vdr shutdown");
458 VDR::getInstance()->setVDRShutdown(true);
462 Log::getInstance()->log("Options", Log::DEBUG, "Setting local shutdown");
463 VDR::getInstance()->setVDRShutdown(false);
471 options[i]->opthandler->handleOptionChanges(options[i]);
476 void VOpts::processMessage(Message* m)
478 if (m->message == Message::MOUSE_MOVE)
480 int x=(m->parameter>>16)-getScreenX();
481 int y=(m->parameter&0xFFFF)-getScreenY();
482 if (tabbar.mouseMove(x,y))
484 BoxStack::getInstance()->update(this);
488 else if (m->message == Message::MOUSE_LBDOWN)
490 int x=(m->parameter>>16)-getScreenX();
491 int y=(m->parameter&0xFFFF)-getScreenY();
492 if (tabbar.mouseLBDOWN(x,y))
494 BoxStack::getInstance()->update(this);
496 else if (x<0 || y <0 || x>(int)getWidth() || y>(int)getHeight())
498 BoxStack::getInstance()->handleCommand(Remote::BACK); //simulate cancel press