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.
28 #include "woptionpane.h"
29 #include "wremoteconfig.h"
35 #ifdef VOMP_PLATTFORM_MVP
36 #include "mediaoptions.h"
39 //#include "command.h"
44 setTitleBarColour(DrawStyle::TITLEBARBACKGROUND);
45 setTitleText(tr("Options"));
50 if (Video::getInstance()->getFormat() == Video::PAL)
51 setPosition(100, 110);
55 tabbar.setPosition(6, 32);
56 tabbar.setSize(getWidth() - 12, getHeight() - 34);
62 // --- edit options start here
64 static const char* options1[] = {"Old", "New"};
66 static const char* options5[] = {"Chop sides", "Letterbox"};
67 static const char* options6[] = {"On", "Off", "Last state"};
68 static const char* options7[] = {"All", "FTA only"};
69 static const char* options15[] = {"Alphabetical", "Chronological"};
71 static const char* options13[] = {"1024", "2048", "4096", "8192", "16384", "32768", "65536"};
72 static const char* options14[] = {"No", "Yes"};
73 // Get list of languages from VDR and construct options table
74 LangCode = VDR::getInstance()->getLanguageList();
75 options2 = new const char*[LangCode.size()];
76 options2keys = new const char*[LangCode.size()];
77 I18n::lang_code_list::const_iterator iter;
79 for (iter = LangCode.begin(); iter != LangCode.end(); ++iter,++LangNumber)
81 options2[LangNumber] = iter->second.c_str();
82 options2keys[LangNumber] = iter->first.c_str();
86 panes = new Boxx*[numPanes];
88 wop = new WOptionPane();
89 tabbar.addTab(tr("General"), wop);
91 #ifdef MVP_REMOTE_TYPES
92 option = new Option(1, "Remote control type", "General", "Remote type", Option::TYPE_TEXT, 2, 0, 0, options1);
93 options.push_back(option);
94 wop->addOptionLine(option);
96 option = new Option(2, "Language", "General", "LangCode", Option::TYPE_KEYED_TEXT, LangCode.size(), 0, 0, options2, options2keys);
97 options.push_back(option);
98 wop->addOptionLine(option);
101 UINT suppconn = Video::getInstance()->getSupportedFormats();
104 if (suppconn & Video::COMPOSITERGB) {
106 options3.push_back("RGB+composite");
107 options3keys.push_back("RGB+composite");
109 if (Video::SVIDEO & suppconn) {
110 options3.push_back("S-Video");
111 options3keys.push_back("S-Video");
113 if (Video::HDMI & suppconn) {
114 defaultch = options3.size();
115 options3.push_back("HDMI");
116 options3keys.push_back("HDMI");
118 if (Video::HDMI3D & suppconn) {
119 options3.push_back("HDMI3D");
120 options3keys.push_back("HDMI3D");
122 option = new Option(3, "TV connection type", "TV", "Connection",
123 Option::TYPE_KEYED_TEXT, options3.size(), defaultch, 0,
124 &(options3[0]), &(options3keys[0]));
126 options.push_back(option);
127 wop->addOptionLine(option);
130 UINT suppformats = Video::getInstance()->supportedTVFormats();
133 options16.push_back("NTSC");
134 options16keys.push_back("NTSC");
135 if (suppformats & Video::PAL) {
137 options16.push_back("PAL");
138 options16keys.push_back("PAL");
140 if (Video::NTSC_J & suppformats) {
141 options16.push_back("NTSC-J");
142 options16keys.push_back("NTSC-J");
144 if (Video::PAL_M & suppformats) {
145 options16.push_back("PAL-M");
146 options16keys.push_back("PAL-M");
149 option = new Option(16, "TV standard (needs restart)", "General", "Override Video Format",
150 Option::TYPE_KEYED_TEXT, options16.size(), defaultch, 0,
151 &(options16[0]), &(options16keys[0]));
153 options.push_back(option);
154 wop->addOptionLine(option);
157 UINT supptvsize=Video::getInstance()->supportedTVsize();
160 options4.push_back("4:3");
161 options4keys.push_back("4:3");
162 if (Video::ASPECT16X9 & supptvsize) {
163 options4.push_back("16:9");
164 options4keys.push_back("16:9");
167 if (Video::ASPECT14X9 & supptvsize) {
168 options4.push_back("14:9");
169 options4keys.push_back("14:9");
171 option = new Option(4, "TV aspect ratio", "TV", "Aspect",
172 Option::TYPE_KEYED_TEXT, options4.size(), defaultch, 0,
173 &(options4[0]), &(options4keys[0]));
174 options.push_back(option);
175 wop->addOptionLine(option);
178 option = new Option(5, "16:9 on 4:3 display mode", "TV", "Widemode", Option::TYPE_TEXT, 2, 0, 0, options5);
179 options.push_back(option);
180 wop->addOptionLine(option);
181 option = new Option(6, "Power state after bootup", "General", "Power After Boot", Option::TYPE_TEXT, 3, 0, 0, options6);
182 options.push_back(option);
183 wop->addOptionLine(option);
184 option = new Option(7, "Display channels", "General", "Channels", Option::TYPE_TEXT, 2, 0, 0, options7);
185 options.push_back(option);
186 wop->addOptionLine(option);
187 option = new Option(15, "Recordings sort order", "General", "Recordings Sort Order", Option::TYPE_TEXT, 2, 0, 0, options15);
188 options.push_back(option);
189 wop->addOptionLine(option);
191 Remote::getInstance()->addOptionsToPanes(0,&options,wop);
192 Video::getInstance()->addOptionsToPanes(0,&options,wop);
193 Audio::getInstance()->addOptionsToPanes(0,&options,wop);
196 /* WRemoteConfig* wrc = new WRemoteConfig();
197 tabbar.addTab(tr("Remote Control"), wrc);*/
198 Remote::getInstance()->addOptionPagesToWTB(&tabbar);
201 Video::getInstance()->addOptionPagesToWTB(&tabbar);
202 Audio::getInstance()->addOptionPagesToWTB(&tabbar);
203 #ifdef VOMP_PLATTFORM_MVP
204 MediaOptions::getInstance()->addOptionPagesToWTB(&tabbar);
208 wop = new WOptionPane();
209 tabbar.addTab(tr("Timers"), wop);
212 option = new Option(9, "Default start margin (minutes)", "Timers", "Start margin", Option::TYPE_INT, 20, 5, 0, NULL);
213 options.push_back(option);
214 wop->addOptionLine(option);
215 option = new Option(10, "Default end margin (minutes)", "Timers", "End margin", Option::TYPE_INT, 20, 5, 0, NULL);
216 options.push_back(option);
217 wop->addOptionLine(option);
218 option = new Option(11, "Default priority", "Timers", "Priority", Option::TYPE_INT, 100, 99, 0, NULL);
219 options.push_back(option);
220 wop->addOptionLine(option);
221 option = new Option(12, "Default lifetime", "Timers", "Lifetime", Option::TYPE_INT, 100, 99, 0, NULL);
222 options.push_back(option);
223 wop->addOptionLine(option);
225 Remote::getInstance()->addOptionsToPanes(1,&options,wop);
226 Video::getInstance()->addOptionsToPanes(1,&options,wop);
227 Audio::getInstance()->addOptionsToPanes(1,&options,wop);
230 wop = new WOptionPane();
231 tabbar.addTab(tr("Advanced"), wop);
234 option = new Option(8, "VDR-Pri 0=OK !See forums!", "General", "Live priority", Option::TYPE_INT, 199, -1, -99, NULL);
235 options.push_back(option);
236 wop->addOptionLine(option);
237 option = new Option(13, "TCP receive window size", "Advanced", "TCP receive window", Option::TYPE_TEXT, 7, /*1*/DEFAULT_TCP_WINDOWSIZENR, 0, options13);
238 options.push_back(option);
239 wop->addOptionLine(option);
241 option = new Option(14, "Use WSS (PAL only)", "General", "WSS", Option::TYPE_TEXT, 2, 0, 0, options14);
242 options.push_back(option);
243 wop->addOptionLine(option);
246 Remote::getInstance()->addOptionsToPanes(2,&options,wop);
247 Video::getInstance()->addOptionsToPanes(2,&options,wop);
248 Audio::getInstance()->addOptionsToPanes(2,&options,wop);
253 // for (int i = 0; i < numPanes; i++) delete panes[i]; //Move to TabBar, Marten
256 for(vector<Option*>::iterator j = options.begin(); j != options.end(); j++) delete *j;
258 delete[] options2keys;
261 int VOpts::handleCommand(int command)
263 // either is active, handle back
264 if (command == Remote::BACK)
271 int retval = tabbar.handleCommand(command);
274 BoxStack::getInstance()->update(this);
277 else if (retval == 2)
279 // command was taken and actively ignored
291 VDR* vdr = VDR::getInstance();
293 Remote::getInstance()->saveOptionstoServer(); //Remote
294 Video::getInstance()->saveOptionstoServer(); //Video
295 Audio::getInstance()->saveOptionstoServer(); //Remote
296 #ifdef VOMP_PLATTFORM_MVP
297 MediaOptions::getInstance()->saveOptionstoServer(); //Media
300 // Damn, and the dynamic idea was going *so* well...
301 //Whats about a check with typeid operator?
303 wop = (WOptionPane*)panes[0];
305 wop = (WOptionPane*)panes[1];
307 wop = (WOptionPane*)panes[2];
311 for (UINT i = 0; i < options.size(); i++)
313 if (options[i]->configChoice == options[i]->userSetChoice) continue; // no change
315 Log::getInstance()->log("Options", Log::DEBUG, "Option %i has changed", i);
319 if (options[i]->optionType == Option::TYPE_TEXT)
321 vdr->configSave(options[i]->configSection, options[i]->configKey, options[i]->options[options[i]->userSetChoice]);
323 else if (options[i]->optionType == Option::TYPE_KEYED_TEXT)
325 vdr->configSave(options[i]->configSection, options[i]->configKey, options[i]->optionkeys[options[i]->userSetChoice]);
330 sprintf(buffer, "%i", options[i]->userSetChoice);
331 vdr->configSave(options[i]->configSection, options[i]->configKey, buffer);
335 if (options[i]->opthandler == NULL) //Ok, noone else is handling this, we are doing it
337 switch(options[i]->id)
341 #ifdef MVP_REMOTE_TYPES
342 if (options[i]->userSetChoice == 1)
344 Log::getInstance()->log("Options", Log::DEBUG, "Setting New Remote");
345 Remote::getInstance()->setRemoteType(Remote::NEWREMOTE);
349 Log::getInstance()->log("Options", Log::DEBUG, "Setting Old Remote");
350 Remote::getInstance()->setRemoteType(Remote::OLDREMOTE);
357 Message* m = new Message();
358 m->message = Message::CHANGE_LANGUAGE;
359 m->to = Command::getInstance();
360 Command::getInstance()->postMessageNoLock(m);
365 if (STRCASECMP(options[i]->optionkeys[options[i]->userSetChoice], "RGB+composite")==0)
367 Log::getInstance()->log("Options", Log::DEBUG, "Setting RGB/Composite");
368 Video::getInstance()->setConnection(Video::COMPOSITERGB);
370 else if (STRCASECMP(options[i]->optionkeys[options[i]->userSetChoice], "S-Video")==0)
372 Log::getInstance()->log("Options", Log::DEBUG, "Setting S-Video");
373 Video::getInstance()->setConnection(Video::SVIDEO);
375 else if (STRCASECMP(options[i]->optionkeys[options[i]->userSetChoice], "HDMI")==0)
377 Log::getInstance()->log("Options", Log::DEBUG, "Setting HDMI");
378 Video::getInstance()->setConnection(Video::HDMI);
380 else if (STRCASECMP(options[i]->optionkeys[options[i]->userSetChoice], "HDMI3D")==0)
382 Log::getInstance()->log("Options", Log::DEBUG, "Setting HDMI");
383 Video::getInstance()->setConnection(Video::HDMI3D);
389 if (STRCASECMP(options[i]->optionkeys[options[i]->userSetChoice], "16:9")==0)
391 Log::getInstance()->log("Options", Log::DEBUG, "Setting 16:9 TV");
392 Video::getInstance()->setTVsize(Video::ASPECT16X9);
394 else if (STRCASECMP(options[i]->optionkeys[options[i]->userSetChoice], "4:3")==0)
396 Log::getInstance()->log("Options", Log::DEBUG, "Setting 4:3 TV");
397 Video::getInstance()->setTVsize(Video::ASPECT4X3);
399 else if (STRCASECMP(options[i]->optionkeys[options[i]->userSetChoice], "14:9")==0)
401 Log::getInstance()->log("Options", Log::DEBUG, "Setting 14:9 TV");
402 Video::getInstance()->setTVsize(Video::ASPECT14X9);
408 if (options[i]->userSetChoice == 1)
410 Log::getInstance()->log("Options", Log::DEBUG, "Setting letterbox");
411 Video::getInstance()->setMode(Video::LETTERBOX);
415 Log::getInstance()->log("Options", Log::DEBUG, "Setting chop-sides");
416 Video::getInstance()->setMode(Video::NORMAL);
422 size_t newTCPsize = 2048;
423 if (options[i]->userSetChoice == 0) newTCPsize = 1024;
424 else if (options[i]->userSetChoice == 1) newTCPsize = 2048;
425 else if (options[i]->userSetChoice == 2) newTCPsize = 4096;
426 else if (options[i]->userSetChoice == 3) newTCPsize = 8192;
427 else if (options[i]->userSetChoice == 4) newTCPsize = 16384;
428 else if (options[i]->userSetChoice == 5) newTCPsize = 32768;
429 else if (options[i]->userSetChoice == 6) newTCPsize = 65536;
430 Log::getInstance()->log("Options", Log::DEBUG, "Setting TCP window size %i", newTCPsize);
431 VDR::getInstance()->setReceiveWindow(newTCPsize);
438 options[i]->opthandler->handleOptionChanges(options[i]);
443 void VOpts::processMessage(Message* m)
445 if (m->message == Message::MOUSE_MOVE)
447 int x=(m->parameter>>16)-getScreenX();
448 int y=(m->parameter&0xFFFF)-getScreenY();
449 if (tabbar.mouseMove(x,y))
451 BoxStack::getInstance()->update(this);
455 else if (m->message == Message::MOUSE_LBDOWN)
457 int x=(m->parameter>>16)-getScreenX();
458 int y=(m->parameter&0xFFFF)-getScreenY();
459 if (tabbar.mouseLBDOWN(x,y))
461 BoxStack::getInstance()->update(this);
463 else if (x<0 || y <0 || x>(int)getWidth() || y>(int)getHeight())
465 BoxStack::getInstance()->handleCommand(Remote::BACK); //simulate cancel press