2 Copyright 2007 Chris Tallon
\r
4 This file is part of VOMP.
\r
6 VOMP is free software; you can redistribute it and/or modify
\r
7 it under the terms of the GNU General Public License as published by
\r
8 the Free Software Foundation; either version 2 of the License, or
\r
9 (at your option) any later version.
\r
11 VOMP is distributed in the hope that it will be useful,
\r
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
14 GNU General Public License for more details.
\r
16 You should have received a copy of the GNU General Public License
\r
17 along with VOMP; if not, write to the Free Software
\r
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
\r
27 #include "boxstack.h"
\r
28 #include "woptionpane.h"
\r
29 #include "wremoteconfig.h"
\r
33 #include "command.h"
\r
35 #ifdef VOMP_PLATTFORM_MVP
\r
36 #include "mediaoptions.h"
\r
39 //#include "command.h"
\r
44 setTitleBarColour(Colour::TITLEBARBACKGROUND);
\r
45 setTitleText(tr("Options"));
\r
50 if (Video::getInstance()->getFormat() == Video::PAL)
\r
51 setPosition(100, 110);
\r
53 setPosition(90, 90);
\r
55 tabbar.setPosition(6, 32);
\r
56 tabbar.setSize(getWidth() - 12, getHeight() - 34);
\r
62 // --- edit options start here
\r
64 static const char* options1[] = {"Old", "New"};
\r
65 static const char* options3[] = {"RGB+composite", "S-Video"};
\r
66 static const char* options4[] = {"4:3", "16:9"};
\r
67 static const char* options5[] = {"Chop sides", "Letterbox"};
\r
68 static const char* options6[] = {"On", "Off", "Last state"};
\r
69 static const char* options7[] = {"All", "FTA only"};
\r
70 static const char* options15[] = {"Alphabetical", "Chronological"};
\r
72 static const char* options13[] = {"1024", "2048", "4096", "8192", "16384", "32768", "65536"};
\r
73 static const char* options14[] = {"No", "Yes"};
\r
74 // Get list of languages from VDR and construct options table
\r
75 LangCode = VDR::getInstance()->getLanguageList();
\r
76 options2 = new const char*[LangCode.size()];
\r
77 options2keys = new const char*[LangCode.size()];
\r
78 I18n::lang_code_list::const_iterator iter;
\r
79 UINT LangNumber = 0;
\r
80 for (iter = LangCode.begin(); iter != LangCode.end(); ++iter,++LangNumber)
\r
82 options2[LangNumber] = iter->second.c_str();
\r
83 options2keys[LangNumber] = iter->first.c_str();
\r
87 panes = new Boxx*[numPanes];
\r
89 wop = new WOptionPane();
\r
90 tabbar.addTab(tr("General"), wop);
\r
92 option = new Option(1, "Remote control type", "General", "Remote type", Option::TYPE_TEXT, 2, 0, 0, options1);
\r
93 options.push_back(option);
\r
94 wop->addOptionLine(option);
\r
95 option = new Option(2, "Language", "General", "LangCode", Option::TYPE_KEYED_TEXT, LangCode.size(), 0, 0, options2, options2keys);
\r
96 options.push_back(option);
\r
97 wop->addOptionLine(option);
\r
98 option = new Option(3, "TV connection type", "TV", "Connection", Option::TYPE_TEXT, 2, 0, 0, options3);
\r
99 options.push_back(option);
\r
100 wop->addOptionLine(option);
\r
101 option = new Option(4, "TV aspect ratio", "TV", "Aspect", Option::TYPE_TEXT, 2, 0, 0, options4);
\r
102 options.push_back(option);
\r
103 wop->addOptionLine(option);
\r
104 option = new Option(5, "16:9 on 4:3 display mode", "TV", "Widemode", Option::TYPE_TEXT, 2, 0, 0, options5);
\r
105 options.push_back(option);
\r
106 wop->addOptionLine(option);
\r
107 option = new Option(6, "Power state after bootup", "General", "Power After Boot", Option::TYPE_TEXT, 3, 0, 0, options6);
\r
108 options.push_back(option);
\r
109 wop->addOptionLine(option);
\r
110 option = new Option(7, "Display channels", "General", "Channels", Option::TYPE_TEXT, 2, 0, 0, options7);
\r
111 options.push_back(option);
\r
112 wop->addOptionLine(option);
\r
113 option = new Option(15, "Recordings sort order", "General", "Recordings Sort Order", Option::TYPE_TEXT, 2, 0, 0, options15);
\r
114 options.push_back(option);
\r
115 wop->addOptionLine(option);
\r
117 Remote::getInstance()->addOptionsToPanes(0,&options,wop);
\r
118 Video::getInstance()->addOptionsToPanes(0,&options,wop);
\r
119 Audio::getInstance()->addOptionsToPanes(0,&options,wop);
\r
122 /* WRemoteConfig* wrc = new WRemoteConfig();
\r
123 tabbar.addTab(tr("Remote Control"), wrc);*/
\r
124 Remote::getInstance()->addOptionPagesToWTB(&tabbar);
\r
127 Video::getInstance()->addOptionPagesToWTB(&tabbar);
\r
128 Audio::getInstance()->addOptionPagesToWTB(&tabbar);
\r
129 #ifdef VOMP_PLATTFORM_MVP
\r
130 MediaOptions::getInstance()->addOptionPagesToWTB(&tabbar);
\r
134 wop = new WOptionPane();
\r
135 tabbar.addTab(tr("Timers"), wop);
\r
138 option = new Option(9, "Default start margin (minutes)", "Timers", "Start margin", Option::TYPE_INT, 20, 5, 0, NULL);
\r
139 options.push_back(option);
\r
140 wop->addOptionLine(option);
\r
141 option = new Option(10, "Default end margin (minutes)", "Timers", "End margin", Option::TYPE_INT, 20, 5, 0, NULL);
\r
142 options.push_back(option);
\r
143 wop->addOptionLine(option);
\r
144 option = new Option(11, "Default priority", "Timers", "Priority", Option::TYPE_INT, 100, 99, 0, NULL);
\r
145 options.push_back(option);
\r
146 wop->addOptionLine(option);
\r
147 option = new Option(12, "Default lifetime", "Timers", "Lifetime", Option::TYPE_INT, 100, 99, 0, NULL);
\r
148 options.push_back(option);
\r
149 wop->addOptionLine(option);
\r
151 Remote::getInstance()->addOptionsToPanes(1,&options,wop);
\r
152 Video::getInstance()->addOptionsToPanes(1,&options,wop);
\r
153 Audio::getInstance()->addOptionsToPanes(1,&options,wop);
\r
156 wop = new WOptionPane();
\r
157 tabbar.addTab(tr("Advanced"), wop);
\r
160 option = new Option(8, "VDR-Pri 0=OK !See forums!", "General", "Live priority", Option::TYPE_INT, 100, 0, 0, NULL);
\r
161 options.push_back(option);
\r
162 wop->addOptionLine(option);
\r
163 option = new Option(13, "TCP receive window size", "Advanced", "TCP receive window", Option::TYPE_TEXT, 7, 1, 0, options13);
\r
164 options.push_back(option);
\r
165 wop->addOptionLine(option);
\r
166 option = new Option(14, "Use WSS (PAL only)", "General", "WSS", Option::TYPE_TEXT, 2, 0, 0, options14);
\r
167 options.push_back(option);
\r
168 wop->addOptionLine(option);
\r
170 Remote::getInstance()->addOptionsToPanes(2,&options,wop);
\r
171 Video::getInstance()->addOptionsToPanes(2,&options,wop);
\r
172 Audio::getInstance()->addOptionsToPanes(2,&options,wop);
\r
177 // for (int i = 0; i < numPanes; i++) delete panes[i]; //Move to TabBar, Marten
\r
180 for(vector<Option*>::iterator j = options.begin(); j != options.end(); j++) delete *j;
\r
182 delete[] options2keys;
\r
185 int VOpts::handleCommand(int command)
\r
187 // either is active, handle back
\r
188 if (command == Remote::BACK)
\r
195 int retval = tabbar.handleCommand(command);
\r
198 BoxStack::getInstance()->update(this);
\r
201 else if (retval == 2)
\r
203 // command was taken and actively ignored
\r
213 void VOpts::doSave()
\r
215 VDR* vdr = VDR::getInstance();
\r
217 Remote::getInstance()->saveOptionstoServer(); //Remote
\r
218 Video::getInstance()->saveOptionstoServer(); //Video
\r
219 Audio::getInstance()->saveOptionstoServer(); //Remote
\r
220 #ifdef VOMP_PLATTFORM_MVP
\r
221 MediaOptions::getInstance()->saveOptionstoServer(); //Media
\r
224 // Damn, and the dynamic idea was going *so* well...
\r
225 //Whats about a check with typeid operator?
\r
227 wop = (WOptionPane*)panes[0];
\r
229 wop = (WOptionPane*)panes[1];
\r
231 wop = (WOptionPane*)panes[2];
\r
235 for (UINT i = 0; i < options.size(); i++)
\r
237 if (options[i]->configChoice == options[i]->userSetChoice) continue; // no change
\r
239 Log::getInstance()->log("Options", Log::DEBUG, "Option %i has changed", i);
\r
243 if (options[i]->optionType == Option::TYPE_TEXT)
\r
245 vdr->configSave(options[i]->configSection, options[i]->configKey, options[i]->options[options[i]->userSetChoice]);
\r
247 else if (options[i]->optionType == Option::TYPE_KEYED_TEXT)
\r
249 vdr->configSave(options[i]->configSection, options[i]->configKey, options[i]->optionkeys[options[i]->userSetChoice]);
\r
254 sprintf(buffer, "%i", options[i]->userSetChoice);
\r
255 vdr->configSave(options[i]->configSection, options[i]->configKey, buffer);
\r
259 if (options[i]->opthandler == NULL) //Ok, noone else is handling this, we are doing it
\r
261 switch(options[i]->id)
\r
265 if (options[i]->userSetChoice == 1)
\r
267 Log::getInstance()->log("Options", Log::DEBUG, "Setting New Remote");
\r
268 Remote::getInstance()->setRemoteType(Remote::NEWREMOTE);
\r
272 Log::getInstance()->log("Options", Log::DEBUG, "Setting Old Remote");
\r
273 Remote::getInstance()->setRemoteType(Remote::OLDREMOTE);
\r
279 Message* m = new Message();
\r
280 m->message = Message::CHANGE_LANGUAGE;
\r
281 m->to = Command::getInstance();
\r
282 Command::getInstance()->postMessageNoLock(m);
\r
287 if (options[i]->userSetChoice == 1)
\r
289 Log::getInstance()->log("Options", Log::DEBUG, "Setting S-Video");
\r
290 Video::getInstance()->setConnection(Video::SVIDEO);
\r
294 Log::getInstance()->log("Options", Log::DEBUG, "Setting RGB/Composite");
\r
295 Video::getInstance()->setConnection(Video::COMPOSITERGB);
\r
301 if (options[i]->userSetChoice == 1)
\r
303 Log::getInstance()->log("Options", Log::DEBUG, "Setting 16:9 TV");
\r
304 Video::getInstance()->setTVsize(Video::ASPECT16X9);
\r
308 Log::getInstance()->log("Options", Log::DEBUG, "Setting 4:3 TV");
\r
309 Video::getInstance()->setTVsize(Video::ASPECT4X3);
\r
315 if (options[i]->userSetChoice == 1)
\r
317 Log::getInstance()->log("Options", Log::DEBUG, "Setting letterbox");
\r
318 Video::getInstance()->setMode(Video::LETTERBOX);
\r
322 Log::getInstance()->log("Options", Log::DEBUG, "Setting chop-sides");
\r
323 Video::getInstance()->setMode(Video::NORMAL);
\r
329 size_t newTCPsize = 2048;
\r
330 if (options[i]->userSetChoice == 0) newTCPsize = 1024;
\r
331 else if (options[i]->userSetChoice == 1) newTCPsize = 2048;
\r
332 else if (options[i]->userSetChoice == 2) newTCPsize = 4096;
\r
333 else if (options[i]->userSetChoice == 3) newTCPsize = 8192;
\r
334 else if (options[i]->userSetChoice == 4) newTCPsize = 16384;
\r
335 else if (options[i]->userSetChoice == 5) newTCPsize = 32768;
\r
336 else if (options[i]->userSetChoice == 6) newTCPsize = 65536;
\r
337 Log::getInstance()->log("Options", Log::DEBUG, "Setting TCP window size %i", newTCPsize);
\r
338 VDR::getInstance()->setReceiveWindow(newTCPsize);
\r
345 options[i]->opthandler->handleOptionChanges(options[i]);
\r
350 void VOpts::processMessage(Message* m)
\r
352 if (m->message == Message::MOUSE_MOVE)
\r
354 int x=(m->parameter>>16)-getScreenX();
\r
355 int y=(m->parameter&0xFFFF)-getScreenY();
\r
356 if (tabbar.mouseMove(x,y))
\r
358 BoxStack::getInstance()->update(this);
\r
362 else if (m->message == Message::MOUSE_LBDOWN)
\r
364 int x=(m->parameter>>16)-getScreenX();
\r
365 int y=(m->parameter&0xFFFF)-getScreenY();
\r
366 if (tabbar.mouseLBDOWN(x,y))
\r
368 BoxStack::getInstance()->update(this);
\r
370 else if (x<0 || y <0 || x>(int)getWidth() || y>(int)getHeight())
\r
372 BoxStack::getInstance()->handleCommand(Remote::BACK); //simulate cancel press
\r