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, see <https://www.gnu.org/licenses/>.
28 #include "woptionpane.h"
29 #include "wremoteconfig.h"
33 #include "messagequeue.h"
36 #include "staticartwork.h"
38 #ifdef VOMP_PLATTFORM_MVP
39 #include "mediaoptions.h"
47 setTitleBarColour(DrawStyle::TITLEBARBACKGROUND);
48 setTitleText(tr("Options"));
49 TVMediaInfo *info= new TVMediaInfo();
50 info->setStaticArtwork(sa_properties);
51 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 static const char* options5[] = {"Chop sides", "Letterbox"};
69 static const char* options6[] = {"On", "Off", "Last state"};
70 static const char* options7[] = {"All", "FTA only"};
71 static const char* options15[] = {"Alphabetical", "Chronological"};
73 static const char* options13[] = {"Auto","1024", "2048", "4096", "8192", "16384", "32768", "65536"};
75 static const char* options18[] = {"Off", "On"};
76 #ifdef ADVANCED_MENUES
77 static const char* options19[] = { "Advanced","Classic"};
79 // Get list of languages from VDR and construct options table
80 LangCode = VDR::getInstance()->getLanguageList();
81 options2 = new const char*[LangCode.size()];
82 options2keys = new const char*[LangCode.size()];
83 I18n::lang_code_list::const_iterator iter;
85 for (iter = LangCode.begin(); iter != LangCode.end(); ++iter,++LangNumber)
87 options2[LangNumber] = iter->second.c_str();
88 options2keys[LangNumber] = iter->first.c_str();
92 panes = new Boxx*[numPanes];
94 wop = new WOptionPane();
95 tabbar.addTab(tr("General"), wop);
97 option = new Option(2, "Language", "General", "LangCode", Option::TYPE_KEYED_TEXT, LangCode.size(), 0, 0, options2, options2keys);
98 options.push_back(option);
99 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);
190 option = new Option(18, "Automatic VDR shutdown", "General", "VDR shutdown", Option::TYPE_TEXT, 2, 0, 0, options18);
191 options.push_back(option);
192 wop->addOptionLine(option);
194 InputMan::getInstance()->addOptionsToPanes(0,&options,wop);
195 Video::getInstance()->addOptionsToPanes(0,&options,wop);
196 Audio::getInstance()->addOptionsToPanes(0,&options,wop);
199 /* WRemoteConfig* wrc = new WRemoteConfig();
200 tabbar.addTab(tr("Remote Control"), wrc);*/
201 InputMan::getInstance()->addOptionPagesToWTB(&tabbar);
204 Video::getInstance()->addOptionPagesToWTB(&tabbar);
205 Audio::getInstance()->addOptionPagesToWTB(&tabbar);
206 #ifdef VOMP_PLATTFORM_MVP
207 MediaOptions::getInstance()->addOptionPagesToWTB(&tabbar);
211 wop = new WOptionPane();
212 tabbar.addTab(tr("Timers"), wop);
215 option = new Option(9, "Default start margin (minutes)", "Timers", "Start margin", Option::TYPE_INT, 20, 5, 0, NULL);
216 options.push_back(option);
217 wop->addOptionLine(option);
218 option = new Option(10, "Default end margin (minutes)", "Timers", "End margin", Option::TYPE_INT, 20, 5, 0, NULL);
219 options.push_back(option);
220 wop->addOptionLine(option);
221 option = new Option(11, "Default priority", "Timers", "Priority", Option::TYPE_INT, 100, 99, 0, NULL);
222 options.push_back(option);
223 wop->addOptionLine(option);
224 option = new Option(12, "Default lifetime", "Timers", "Lifetime", Option::TYPE_INT, 100, 99, 0, NULL);
225 options.push_back(option);
226 wop->addOptionLine(option);
228 InputMan::getInstance()->addOptionsToPanes(1,&options,wop);
229 Video::getInstance()->addOptionsToPanes(1,&options,wop);
230 Audio::getInstance()->addOptionsToPanes(1,&options,wop);
233 wop = new WOptionPane();
234 tabbar.addTab(tr("Advanced"), wop);
237 option = new Option(8, "VDR-Pri 0=OK !See forums!", "General", "Live priority", Option::TYPE_INT, 199, -1, -99, NULL);
238 options.push_back(option);
239 wop->addOptionLine(option);
240 option = new Option(13, "TCP receive window size", "Advanced", "TCP receive window", Option::TYPE_TEXT, 8, /*1*/DEFAULT_TCP_WINDOWSIZENR, 0, options13);
241 options.push_back(option);
242 wop->addOptionLine(option);
243 const char * * fontnames;
244 const char * * fontnames_keys;
245 int numfonts=Osd::getInstance()->getFontNames(&fontnames,&fontnames_keys);
247 option = new Option(17, "Font Name", "Advanced", "Font Name", Option::TYPE_KEYED_TEXT, numfonts, 1, 0, fontnames,fontnames_keys);
248 options.push_back(option);
249 wop->addOptionLine(option);
252 int numskins=SkinFactory::getNumberofSkins();
254 option = new Option(20, "Skin Name (needs restart)", "Advanced", "Skin Name", Option::TYPE_KEYED_TEXT, numskins, 0, 0,
255 SkinFactory::getSkinNames(),SkinFactory::getSkinNames());
256 options.push_back(option);
257 wop->addOptionLine(option);
260 #ifdef ADVANCED_MENUES
261 option = new Option(19, "Advanced Menu", "Advanced", "Menu type",Option::TYPE_TEXT, 2, 0, 0, options19);
262 options.push_back(option);
263 wop->addOptionLine(option);
266 InputMan::getInstance()->addOptionsToPanes(2,&options,wop);
267 Video::getInstance()->addOptionsToPanes(2,&options,wop);
268 Audio::getInstance()->addOptionsToPanes(2,&options,wop);
273 // for (int i = 0; i < numPanes; i++) delete panes[i]; //Move to TabBar, Marten
276 for(std::vector<Option*>::iterator j = options.begin(); j != options.end(); j++) delete *j;
278 delete[] options2keys;
281 int VOpts::handleCommand(int command)
283 // either is active, handle back
284 if (command == Input::BACK)
291 int retval = tabbar.handleCommand(command);
294 BoxStack::getInstance()->update(this);
297 else if (retval == 2)
299 // command was taken and actively ignored
311 VDR* vdr = VDR::getInstance();
313 InputMan::getInstance()->saveOptionstoServer(); //Remote
314 Video::getInstance()->saveOptionstoServer(); //Video
315 Audio::getInstance()->saveOptionstoServer(); //Remote
316 #ifdef VOMP_PLATTFORM_MVP
317 MediaOptions::getInstance()->saveOptionstoServer(); //Media
320 // Damn, and the dynamic idea was going *so* well...
321 //Whats about a check with typeid operator?
323 wop = static_cast<WOptionPane*>(panes[0]);
325 wop = static_cast<WOptionPane*>(panes[1]);
327 wop = static_cast<WOptionPane*>(panes[2]);
331 for (UINT i = 0; i < options.size(); i++)
333 if (options[i]->configChoice == options[i]->userSetChoice) continue; // no change
335 Log::getInstance()->log("Options", Log::DEBUG, "Option %i has changed", i);
339 if (options[i]->optionType == Option::TYPE_TEXT)
341 vdr->configSave(options[i]->configSection, options[i]->configKey, options[i]->options[options[i]->userSetChoice]);
343 else if (options[i]->optionType == Option::TYPE_KEYED_TEXT)
345 vdr->configSave(options[i]->configSection, options[i]->configKey, options[i]->optionkeys[options[i]->userSetChoice]);
350 sprintf(buffer, "%i", options[i]->userSetChoice);
351 vdr->configSave(options[i]->configSection, options[i]->configKey, buffer);
355 if (options[i]->opthandler == NULL) //Ok, noone else is handling this, we are doing it
357 switch(options[i]->id)
365 Message* m = new Message();
366 m->message = Message::CHANGE_LANGUAGE;
367 m->p_to = Message::CONTROL;
368 MessageQueue::getInstance()->postMessage(m);
373 if (STRCASECMP(options[i]->optionkeys[options[i]->userSetChoice], "RGB+composite")==0)
375 Log::getInstance()->log("Options", Log::DEBUG, "Setting RGB/Composite");
376 Video::getInstance()->setConnection(Video::COMPOSITERGB);
378 else if (STRCASECMP(options[i]->optionkeys[options[i]->userSetChoice], "S-Video")==0)
380 Log::getInstance()->log("Options", Log::DEBUG, "Setting S-Video");
381 Video::getInstance()->setConnection(Video::SVIDEO);
383 else if (STRCASECMP(options[i]->optionkeys[options[i]->userSetChoice], "HDMI")==0)
385 Log::getInstance()->log("Options", Log::DEBUG, "Setting HDMI");
386 Video::getInstance()->setConnection(Video::HDMI);
388 else if (STRCASECMP(options[i]->optionkeys[options[i]->userSetChoice], "HDMI3D")==0)
390 Log::getInstance()->log("Options", Log::DEBUG, "Setting HDMI");
391 Video::getInstance()->setConnection(Video::HDMI3D);
397 if (STRCASECMP(options[i]->optionkeys[options[i]->userSetChoice], "16:9")==0)
399 Log::getInstance()->log("Options", Log::DEBUG, "Setting 16:9 TV");
400 Video::getInstance()->setTVsize(Video::ASPECT16X9);
402 else if (STRCASECMP(options[i]->optionkeys[options[i]->userSetChoice], "4:3")==0)
404 Log::getInstance()->log("Options", Log::DEBUG, "Setting 4:3 TV");
405 Video::getInstance()->setTVsize(Video::ASPECT4X3);
407 else if (STRCASECMP(options[i]->optionkeys[options[i]->userSetChoice], "14:9")==0)
409 Log::getInstance()->log("Options", Log::DEBUG, "Setting 14:9 TV");
410 Video::getInstance()->setTVsize(Video::ASPECT14X9);
416 if (options[i]->userSetChoice == 1)
418 Log::getInstance()->log("Options", Log::DEBUG, "Setting letterbox");
419 Video::getInstance()->setMode(Video::LETTERBOX);
423 Log::getInstance()->log("Options", Log::DEBUG, "Setting chop-sides");
424 Video::getInstance()->setMode(Video::NORMAL);
430 size_t newTCPsize = 2048;
431 if (options[i]->userSetChoice == 0) newTCPsize = 0; //zero means auto
432 else if (options[i]->userSetChoice == 1) newTCPsize = 1024;
433 else if (options[i]->userSetChoice == 2) newTCPsize = 2048;
434 else if (options[i]->userSetChoice == 3) newTCPsize = 4096;
435 else if (options[i]->userSetChoice == 4) newTCPsize = 8192;
436 else if (options[i]->userSetChoice == 5) newTCPsize = 16384;
437 else if (options[i]->userSetChoice == 6) newTCPsize = 32768;
438 else if (options[i]->userSetChoice == 7) newTCPsize = 65536;
439 Log::getInstance()->log("Options", Log::DEBUG, "Setting TCP window size %i", newTCPsize);
440 VDR::getInstance()->setReceiveWindow(newTCPsize);
445 Osd::getInstance()->setFont(options[i]->optionkeys[options[i]->userSetChoice]);
450 if (options[i]->userSetChoice == 1)
452 Log::getInstance()->log("Options", Log::DEBUG, "Setting automatic vdr shutdown");
453 VDR::getInstance()->setVDRShutdown(true);
457 Log::getInstance()->log("Options", Log::DEBUG, "Setting local shutdown");
458 VDR::getInstance()->setVDRShutdown(false);
464 if (options[i]->userSetChoice == 1)
466 Log::getInstance()->log("Options", Log::DEBUG, "Setting classic menu");
467 Control::getInstance()->setAdvMenus(false);
471 Log::getInstance()->log("Options", Log::DEBUG, "Setting advanced menu");
472 Control::getInstance()->setAdvMenus(true);
478 SkinFactory::InitSkin(options[i]->userSetChoice);
479 Log::getInstance()->log("Options", Log::DEBUG, "Init Skin %d",options[i]->userSetChoice);
486 options[i]->opthandler->handleOptionChanges(options[i]);
491 void VOpts::processMessage(Message* m)
493 if (m->message == Message::MOUSE_MOVE)
495 int x = m->parameter - getScreenX();
496 int y = m->tag - getScreenY();
497 if (tabbar.mouseMove(x, y)) BoxStack::getInstance()->update(this);
499 else if (m->message == Message::MOUSE_LBDOWN)
501 int x = m->parameter - getScreenX();
502 int y = m->tag - getScreenY();
503 if (tabbar.mouseLBDOWN(x, y))
505 BoxStack::getInstance()->update(this);
507 else if (coordsOutsideBox(m))
509 BoxStack::getInstance()->handleCommand(Input::BACK); //simulate cancel press