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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #include "woptionpane.h"
30 #include "wremoteconfig.h"
37 //#include "command.h"
42 setTitleBarColour(Colour::TITLEBARBACKGROUND);
43 setTitleText(tr("Options"));
47 if (Video::getInstance()->getFormat() == Video::PAL)
48 setPosition(100, 110);
52 tabbar.setPosition(6, 32);
53 tabbar.setSize(getWidth() - 12, getHeight() - 34);
59 // --- edit options start here
61 static const char* options1[] = {"Old", "New"};
62 static const char* options3[] = {"RGB+composite", "S-Video"};
63 static const char* options4[] = {"4:3", "16:9"};
64 static const char* options5[] = {"Chop sides", "Letterbox"};
65 static const char* options6[] = {"On", "Off", "Last state"};
66 static const char* options7[] = {"All", "FTA only"};
67 static const char* options15[] = {"Alphabetical", "Chronological"};
69 static const char* options13[] = {"1024", "2048", "4096", "8192", "16384", "32768", "65536"};
70 static const char* options14[] = {"No", "Yes"};
73 panes = new Boxx*[numPanes];
75 wop = new WOptionPane();
76 tabbar.addTab(tr("General"), wop);
79 option = new Option(1, "Remote control type", "General", "Remote type", Option::TYPE_TEXT, 2, 0, 0, options1);
80 options.push_back(option);
81 wop->addOptionLine(option);
82 option = new Option(2, "Language", "General", "Language", Option::TYPE_TEXT, I18n::NumLanguages, 0, 0, I18n::Languages);
83 options.push_back(option);
84 wop->addOptionLine(option);
85 option = new Option(3, "TV connection type", "TV", "Connection", Option::TYPE_TEXT, 2, 0, 0, options3);
86 options.push_back(option);
87 wop->addOptionLine(option);
88 option = new Option(4, "TV aspect ratio", "TV", "Aspect", Option::TYPE_TEXT, 2, 0, 0, options4);
89 options.push_back(option);
90 wop->addOptionLine(option);
91 option = new Option(5, "16:9 on 4:3 display mode", "TV", "Widemode", Option::TYPE_TEXT, 2, 0, 0, options5);
92 options.push_back(option);
93 wop->addOptionLine(option);
94 option = new Option(6, "Power state after bootup", "General", "Power After Boot", Option::TYPE_TEXT, 3, 0, 0, options6);
95 options.push_back(option);
96 wop->addOptionLine(option);
97 option = new Option(7, "Display channels", "General", "Channels", Option::TYPE_TEXT, 2, 0, 0, options7);
98 options.push_back(option);
99 wop->addOptionLine(option);
100 option = new Option(15, "Recordings sort order", "General", "Recordings Sort Order", Option::TYPE_TEXT, 2, 0, 0, options15);
101 options.push_back(option);
102 wop->addOptionLine(option);
105 /* WRemoteConfig* wrc = new WRemoteConfig();
106 tabbar.addTab(tr("Remote Control"), wrc);*/
107 Remote::getInstance()->addOptionPagesToWTB(&tabbar);
110 Video::getInstance()->addOptionPagesToWTB(&tabbar);
111 Audio::getInstance()->addOptionPagesToWTB(&tabbar);
114 wop = new WOptionPane();
115 tabbar.addTab(tr("Timers"), wop);
118 option = new Option(9, "Default start margin (minutes)", "Timers", "Start margin", Option::TYPE_INT, 20, 5, 0, NULL);
119 options.push_back(option);
120 wop->addOptionLine(option);
121 option = new Option(10, "Default end margin (minutes)", "Timers", "End margin", Option::TYPE_INT, 20, 5, 0, NULL);
122 options.push_back(option);
123 wop->addOptionLine(option);
124 option = new Option(11, "Default priority", "Timers", "Priority", Option::TYPE_INT, 100, 99, 0, NULL);
125 options.push_back(option);
126 wop->addOptionLine(option);
127 option = new Option(12, "Default lifetime", "Timers", "Lifetime", Option::TYPE_INT, 100, 99, 0, NULL);
128 options.push_back(option);
129 wop->addOptionLine(option);
132 wop = new WOptionPane();
133 tabbar.addTab(tr("Advanced"), wop);
136 option = new Option(8, "VDR-Pri 0=OK !See forums!", "General", "Live priority", Option::TYPE_INT, 100, 0, 0, NULL);
137 options.push_back(option);
138 wop->addOptionLine(option);
139 option = new Option(13, "TCP receive window size", "Advanced", "TCP receive window", Option::TYPE_TEXT, 7, 1, 0, options13);
140 options.push_back(option);
141 wop->addOptionLine(option);
142 option = new Option(14, "Use WSS (PAL only)", "General", "WSS", Option::TYPE_TEXT, 2, 0, 0, options14);
143 options.push_back(option);
144 wop->addOptionLine(option);
149 // for (int i = 0; i < numPanes; i++) delete panes[i]; //Move to TabBar, Marten
152 for(vector<Option*>::iterator j = options.begin(); j != options.end(); j++) delete *j;
155 int VOpts::handleCommand(int command)
157 // either is active, handle back
158 if (command == Remote::BACK)
165 int retval = tabbar.handleCommand(command);
168 BoxStack::getInstance()->update(this);
171 else if (retval == 2)
173 // command was taken and actively ignored
185 VDR* vdr = VDR::getInstance();
187 Remote::getInstance()->saveOptionstoServer(); //Remote
188 Video::getInstance()->saveOptionstoServer(); //Video
189 Audio::getInstance()->saveOptionstoServer(); //Remote
191 // Damn, and the dynamic idea was going *so* well...
192 //Whats about a check with typeid operator?
194 wop = (WOptionPane*)panes[0];
196 wop = (WOptionPane*)panes[1];
198 wop = (WOptionPane*)panes[2];
202 for (UINT i = 0; i < options.size(); i++)
204 if (options[i]->configChoice == options[i]->userSetChoice) continue; // no change
206 Log::getInstance()->log("Options", Log::DEBUG, "Option %i has changed", i);
210 if (options[i]->optionType == Option::TYPE_TEXT)
212 vdr->configSave(options[i]->configSection, options[i]->configKey, options[i]->options[options[i]->userSetChoice]);
217 sprintf(buffer, "%i", options[i]->userSetChoice);
218 vdr->configSave(options[i]->configSection, options[i]->configKey, buffer);
223 switch(options[i]->id)
227 if (options[i]->userSetChoice == 1)
229 Log::getInstance()->log("Options", Log::DEBUG, "Setting New Remote");
230 Remote::getInstance()->setRemoteType(Remote::NEWREMOTE);
234 Log::getInstance()->log("Options", Log::DEBUG, "Setting Old Remote");
235 Remote::getInstance()->setRemoteType(Remote::OLDREMOTE);
241 Message* m = new Message();
242 m->message = Message::CHANGE_LANGUAGE;
243 m->to = Command::getInstance();
244 Command::getInstance()->postMessageNoLock(m);
249 if (options[i]->userSetChoice == 1)
251 Log::getInstance()->log("Options", Log::DEBUG, "Setting S-Video");
252 Video::getInstance()->setConnection(Video::SVIDEO);
256 Log::getInstance()->log("Options", Log::DEBUG, "Setting RGB/Composite");
257 Video::getInstance()->setConnection(Video::COMPOSITERGB);
263 if (options[i]->userSetChoice == 1)
265 Log::getInstance()->log("Options", Log::DEBUG, "Setting 16:9 TV");
266 Video::getInstance()->setTVsize(Video::ASPECT16X9);
270 Log::getInstance()->log("Options", Log::DEBUG, "Setting 4:3 TV");
271 Video::getInstance()->setTVsize(Video::ASPECT4X3);
277 if (options[i]->userSetChoice == 1)
279 Log::getInstance()->log("Options", Log::DEBUG, "Setting letterbox");
280 Video::getInstance()->setMode(Video::LETTERBOX);
284 Log::getInstance()->log("Options", Log::DEBUG, "Setting chop-sides");
285 Video::getInstance()->setMode(Video::NORMAL);
291 size_t newTCPsize = 2048;
293 if (options[i]->userSetChoice == 0) newTCPsize = 1024;
294 else if (options[i]->userSetChoice == 1) newTCPsize = 2048;
295 else if (options[i]->userSetChoice == 2) newTCPsize = 4096;
296 else if (options[i]->userSetChoice == 3) newTCPsize = 8192;
297 else if (options[i]->userSetChoice == 4) newTCPsize = 16384;
298 else if (options[i]->userSetChoice == 5) newTCPsize = 32768;
299 else if (options[i]->userSetChoice == 6) newTCPsize = 65536;
301 Log::getInstance()->log("Options", Log::DEBUG, "Setting TCP window size %i", newTCPsize);
302 VDR::getInstance()->setReceiveWindow(newTCPsize);
309 void VOpts::processMessage(Message* m)
311 if (m->message == Message::MOUSE_MOVE)
313 int x=(m->parameter>>16)-getScreenX();
314 int y=(m->parameter&0xFFFF)-getScreenY();
315 if (tabbar.mouseMove(x,y)) {
316 BoxStack::getInstance()->update(this);
320 else if (m->message == Message::MOUSE_LBDOWN)
322 int x=(m->parameter>>16)-getScreenX();
323 int y=(m->parameter&0xFFFF)-getScreenY();
324 if (tabbar.mouseLBDOWN(x,y)) {
325 BoxStack::getInstance()->update(this);
326 } else if (x<0 || y <0 || x>(int)getWidth() || y>(int)getHeight())
328 BoxStack::getInstance()->handleCommand(Remote::BACK); //simulate cancel press