1 #include "pirpanelmanager.h"
3 #include "forms/pirmainform.h"
4 #include "forms/piraltmainform.h"
5 #include "forms/pirutilityform.h"
6 #include "forms/pirkeypadform.h"
7 #include "forms/pirmenuform.h"
8 #include "forms/pirmediaform.h"
9 #include "forms/pirmedia2form.h"
10 #include "forms/pirrecordform.h"
11 #include "forms/pirtvform.h"
12 #include "forms/pirinputform.h"
13 #include "forms/piradjustform.h"
14 #include "forms/pirairconditionerform.h"
15 #include "forms/piraudiodeviceform.h"
16 #include "forms/pircameraform.h"
17 #include "forms/pirroombaform.h"
18 #include "forms/piruserform.h"
19 #include "forms/pirmacroform.h"
20 #include "forms/pirpowersearchform.h"
21 #include "forms/piradvancedform.h"
23 #include "mainwindow.h"
26 #include <QDialogButtonBox>
27 #include <QPushButton>
30 //#include <QMaemo5InformationBox>
33 PIRPanelManager::PIRPanelManager(
54 altMainPanelFlag(false),
55 currentTabsName(Universal_Tabs),
58 QSettings settings("pietrzak.org", "Pierogi");
59 if (settings.contains("currentTabsName"))
61 int tabVal = settings.value("currentTabsName").toInt();
63 if (tabVal >= Last_Tabs_Marker)
65 currentTabsName = Universal_Tabs;
69 currentTabsName = PIRTabBarName(tabVal);
73 // Set up the panel names:
74 shortPanelNames[Main_Panel] = "Main";
75 longPanelNames[Main_Panel] =
76 "Main Panel - power, volume, and channel controls";
77 shortPanelNames[Utility_Panel] = "Utility";
78 longPanelNames[Utility_Panel] =
79 "Utility Panel - commonly used controls";
80 shortPanelNames[Keypad_Panel] = "Keypad";
81 longPanelNames[Keypad_Panel] =
82 "Keypad Panel - numeric value entry";
83 shortPanelNames[Menu_Panel] = "Menu";
84 longPanelNames[Menu_Panel] =
85 "Menu Panel - enter, exit, and navigate menus";
86 shortPanelNames[Media_Panel] = "Media";
87 longPanelNames[Media_Panel] =
88 "Media Panel - control over recorded data";
89 shortPanelNames[Media2_Panel] = "Media2";
90 longPanelNames[Media2_Panel] =
91 "Media2 Panel - additonal media controls";
92 shortPanelNames[Record_Panel] = "Record";
93 longPanelNames[Record_Panel] =
94 "Program/Record Panel - control over memory and storage";
95 shortPanelNames[TV_Panel] = "TV";
96 longPanelNames[TV_Panel] =
97 "TV Panel - teletext and picture-in-picture";
98 shortPanelNames[Input_Panel] = "Input";
99 longPanelNames[Input_Panel] =
100 "Input Panel - manage data sources";
101 shortPanelNames[Adjust_Panel] = "Adjust";
102 longPanelNames[Adjust_Panel] =
103 "Adjust Panel - modify audio and video";
104 shortPanelNames[AC_Panel] = "AC";
105 longPanelNames[AC_Panel] =
106 "A/C Panel - air conditioner controls";
107 shortPanelNames[Audio_Panel] = "Audio";
108 longPanelNames[Audio_Panel] =
109 "Audio Device Panel - various audio related buttons";
110 shortPanelNames[Camera_Panel] = "Camera";
111 longPanelNames[Camera_Panel] =
112 "Camera Panel - simple shutter controls";
113 shortPanelNames[Roomba_Panel] = "Roomba";
114 longPanelNames[Roomba_Panel] =
115 "Roomba Panel - robotic vacuum cleaner controls";
116 shortPanelNames[User_Panel] = "User";
117 longPanelNames[User_Panel] =
118 "User Panel - macro control buttons";
119 shortPanelNames[Macro_Panel] = "Edit Macro Contents";
120 longPanelNames[Macro_Panel] =
121 "Edit Macros Panel - create, delete, edit, and manage macros";
122 shortPanelNames[PowerSearch_Panel] = "Keyset Search";
123 longPanelNames[PowerSearch_Panel] =
124 "Keyset Search Panel - execute power button in each keyset";
125 shortPanelNames[Advanced_Panel] = "Advanced Settings";
126 longPanelNames[Advanced_Panel] =
127 "Advanced Settings - allows adjustment of protocol settings";
129 mainForm = new PIRMainForm(mainWindow);
130 panels[Main_Panel] = mainForm;
132 altMainForm = new PIRAltMainForm(mainWindow);
133 panels[Alt_Main_Panel] = altMainForm;
135 utilityForm = new PIRUtilityForm(mainWindow);
136 panels[Utility_Panel] = utilityForm;
138 keypadForm = new PIRKeypadForm(mainWindow);
139 panels[Keypad_Panel] = keypadForm;
141 menuForm = new PIRMenuForm(mainWindow);
142 panels[Menu_Panel] = menuForm;
144 mediaForm = new PIRMediaForm(mainWindow);
145 panels[Media_Panel] = mediaForm;
147 media2Form = new PIRMedia2Form(mainWindow);
148 panels[Media2_Panel] = media2Form;
150 recordForm = new PIRRecordForm(mainWindow);
151 panels[Record_Panel] = recordForm;
153 tvForm = new PIRTVForm(mainWindow);
154 panels[TV_Panel] = tvForm;
156 inputForm = new PIRInputForm(mainWindow);
157 panels[Input_Panel] = inputForm;
159 adjustForm = new PIRAdjustForm(mainWindow);
160 panels[Adjust_Panel] = adjustForm;
162 acForm = new PIRAirConditionerForm(mainWindow);
163 panels[AC_Panel] = acForm;
165 audioDeviceForm = new PIRAudioDeviceForm(mainWindow);
166 panels[Audio_Panel] = audioDeviceForm;
168 cameraForm = new PIRCameraForm(mainWindow);
169 panels[Camera_Panel] = cameraForm;
171 roombaForm = new PIRRoombaForm(mainWindow);
172 panels[Roomba_Panel] = roombaForm;
174 userForm = new PIRUserForm(mainWindow);
175 panels[User_Panel] = userForm;
177 macroForm = new PIRMacroForm(mainWindow);
178 panels[Macro_Panel] = macroForm;
180 powerSearchForm = new PIRPowerSearchForm(mainWindow);
181 panels[PowerSearch_Panel] = powerSearchForm;
183 advancedForm = new PIRAdvancedForm();
184 panels[Advanced_Panel] = advancedForm;
186 // Set up the panel collections:
187 PIRPanelNameList pset;
189 // The universal collection:
190 pset.push_back(Main_Panel);
191 pset.push_back(Utility_Panel);
192 pset.push_back(Keypad_Panel);
193 pset.push_back(Menu_Panel);
194 pset.push_back(Media_Panel);
195 pset.push_back(User_Panel);
196 // pset.push_back(Input_Panel);
197 tabLists[Universal_Tabs] = pset;
199 // The TV collection:
201 pset.push_back(Main_Panel);
202 pset.push_back(Utility_Panel);
203 pset.push_back(Keypad_Panel);
204 pset.push_back(Menu_Panel);
205 pset.push_back(TV_Panel);
206 pset.push_back(Input_Panel);
207 tabLists[TV_Tabs] = pset;
209 // The video media collection:
211 pset.push_back(Main_Panel);
212 pset.push_back(Menu_Panel);
213 pset.push_back(Media_Panel);
214 pset.push_back(Media2_Panel);
215 pset.push_back(Input_Panel);
216 pset.push_back(Adjust_Panel);
217 tabLists[VideoMedia_Tabs] = pset;
219 // Audio panel collection:
221 pset.push_back(Main_Panel);
222 pset.push_back(Keypad_Panel);
223 pset.push_back(Media_Panel);
224 pset.push_back(Audio_Panel);
225 tabLists[Audio_Tabs] = pset;
227 // The air conditioner collection:
229 pset.push_back(AC_Panel);
230 tabLists[AC_Tabs] = pset;
232 // The recording collection:
234 pset.push_back(Record_Panel);
235 pset.push_back(Keypad_Panel);
236 tabLists[Record_Tabs] = pset;
238 // The camera control collection:
240 pset.push_back(Camera_Panel);
241 tabLists[Camera_Tabs] = pset;
243 // The Roomba collection:
245 pset.push_back(Roomba_Panel);
246 tabLists[Roomba_Tabs] = pset;
248 // The Macro Management collection:
250 pset.push_back(Macro_Panel);
251 tabLists[Macro_Tabs] = pset;
253 // The Power Search collection:
255 pset.push_back(PowerSearch_Panel);
256 tabLists[PowerSearch_Tabs] = pset;
258 // The Advanced Settings collection:
260 pset.push_back(Advanced_Panel);
261 tabLists[Advanced_Tabs] = pset;
265 PIRPanelManager::~PIRPanelManager()
267 // Note! We are _not_ deleting the panel forms here, because the Qt GUI
268 // has ownership over some of them. Moreover, the Panel Manager is not
269 // currently designed to be destroyed until the program ends. Should the
270 // manager need to be destroyed earlier, this destructor will need to be
275 void PIRPanelManager::updateTabSet()
277 QSettings settings("pietrzak.org", "Pierogi");
278 settings.setValue("currentTabsName", currentTabsName);
280 mainWindow->disableUpdates();
281 mainWindow->clearTabs();
283 PIRPanelNameList::const_iterator i = tabLists[currentTabsName].begin();
285 while (i != tabLists[currentTabsName].end())
287 if ((*i == Main_Panel) && altMainPanelFlag)
289 mainWindow->addTab(altMainForm, shortPanelNames[Main_Panel]);
293 mainWindow->addTab(panels[*i], shortPanelNames[*i]);
299 mainWindow->enableUpdates();
303 void PIRPanelManager::enableButtons(
304 PIRKeysetManager *keyset,
307 mainForm->enableButtons(keyset, id);
308 altMainForm->enableButtons(keyset, id);
309 commonEnableButtons(keyset, id);
313 void PIRPanelManager::enableButtons(
314 PIRKeysetManager *keyset,
315 unsigned int currentID,
316 unsigned int defaultID)
318 mainForm->enableButtons(keyset, currentID, defaultID);
319 altMainForm->enableButtons(keyset, currentID, defaultID);
320 commonEnableButtons(keyset, currentID);
324 void PIRPanelManager::commonEnableButtons(
325 PIRKeysetManager *keyset,
328 utilityForm->enableButtons(keyset, id);
329 keypadForm->enableButtons(keyset, id);
330 menuForm->enableButtons(keyset, id);
331 mediaForm->enableButtons(keyset, id);
332 media2Form->enableButtons(keyset, id);
333 recordForm->enableButtons(keyset, id);
334 tvForm->enableButtons(keyset, id);
335 inputForm->enableButtons(keyset, id);
336 adjustForm->enableButtons(keyset, id);
337 acForm->enableButtons(keyset, id);
338 audioDeviceForm->enableButtons(keyset, id);
339 cameraForm->enableButtons(keyset, id);
340 roombaForm->enableButtons(keyset, id);
342 // Also, set the label in the power search form:
343 powerSearchForm->setKeysetName(mainWindow->getCurrentFullName());
345 // Set up the advanced parameters:
346 advancedForm->setupForm(keyset, id);
350 void PIRPanelManager::updateUserButtons()
352 userForm->setupButtons();
356 void PIRPanelManager::useMainPanel()
358 if (!altMainPanelFlag)
360 // Already set correctly, nothing to do:
364 altMainPanelFlag = false;
370 void PIRPanelManager::useAltMainPanel()
372 if (altMainPanelFlag)
374 // Already set correctly, nothing to do:
378 altMainPanelFlag = true;
385 void PIRPanelManager::setupUniversalTabs()
387 if (currentTabsName == Universal_Tabs) return;
389 currentTabsName = Universal_Tabs;
394 void PIRPanelManager::setupTVTabs()
396 if (currentTabsName == TV_Tabs) return;
398 currentTabsName = TV_Tabs;
403 void PIRPanelManager::setupVideoTabs()
405 if (currentTabsName == VideoMedia_Tabs) return;
407 currentTabsName = VideoMedia_Tabs;
412 void PIRPanelManager::setupACTabs()
414 if (currentTabsName == AC_Tabs) return;
416 currentTabsName = AC_Tabs;
421 void PIRPanelManager::setupRecordTabs()
423 if (currentTabsName == Record_Tabs) return;
425 currentTabsName = Record_Tabs;
431 void PIRPanelManager::setupTabs(
434 if (currentTabsName == name) return;
436 currentTabsName = name;
441 void PIRPanelManager::gotoPreviousTabs()
443 PIRTabsCollection::const_iterator i = tabLists.find(currentTabsName);
445 if (i == tabLists.end())
447 // Couldn't find currentTabsName! Throw an error here?
451 if (i == tabLists.begin())
453 // Already at first collection, nothing to do:
458 currentTabsName = i->first;
463 void PIRPanelManager::gotoNextTabs()
465 PIRTabsCollection::const_iterator i = tabLists.find(currentTabsName);
467 if (i == tabLists.end())
469 // Couldn't find currentTabsName! Throw an error?
475 if (i == tabLists.end())
477 // We're already at the last collection, nothing to do:
481 currentTabsName = i->first;
486 QComboBox *PIRPanelManager::getKeysetComboBox()
488 return macroForm->getKeysetComboBox();