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"
22 #include "mainwindow.h"
25 #include <QDialogButtonBox>
26 #include <QPushButton>
29 //#include <QMaemo5InformationBox>
32 PIRPanelManager::PIRPanelManager(
52 altMainPanelFlag(false),
53 currentTabsName(Universal_Tabs),
56 QSettings settings("pietrzak.org", "Pierogi");
57 if (settings.contains("currentTabsName"))
59 int tabVal = settings.value("currentTabsName").toInt();
61 if (tabVal >= Last_Tabs_Marker)
63 currentTabsName = Universal_Tabs;
67 currentTabsName = PIRTabBarName(tabVal);
71 // Set up the panel names:
72 shortPanelNames[Main_Panel] = "Main";
73 longPanelNames[Main_Panel] =
74 "Main Panel - power, volume, and channel controls";
75 shortPanelNames[Utility_Panel] = "Utility";
76 longPanelNames[Utility_Panel] =
77 "Utility Panel - commonly used controls";
78 shortPanelNames[Keypad_Panel] = "Keypad";
79 longPanelNames[Keypad_Panel] =
80 "Keypad Panel - numeric value entry";
81 shortPanelNames[Menu_Panel] = "Menu";
82 longPanelNames[Menu_Panel] =
83 "Menu Panel - enter, exit, and navigate menus";
84 shortPanelNames[Media_Panel] = "Media";
85 longPanelNames[Media_Panel] =
86 "Media Panel - control over recorded data";
87 shortPanelNames[Media2_Panel] = "Media2";
88 longPanelNames[Media2_Panel] =
89 "Media2 Panel - additonal media controls";
90 shortPanelNames[Record_Panel] = "Record";
91 longPanelNames[Record_Panel] =
92 "Program/Record Panel - control over memory and storage";
93 shortPanelNames[TV_Panel] = "TV";
94 longPanelNames[TV_Panel] =
95 "TV Panel - teletext and picture-in-picture";
96 shortPanelNames[Input_Panel] = "Input";
97 longPanelNames[Input_Panel] =
98 "Input Panel - manage data sources";
99 shortPanelNames[Adjust_Panel] = "Adjust";
100 longPanelNames[Adjust_Panel] =
101 "Adjust Panel - modify audio and video";
102 shortPanelNames[AC_Panel] = "AC";
103 longPanelNames[AC_Panel] =
104 "A/C Panel - air conditioner controls";
105 shortPanelNames[Audio_Panel] = "Audio";
106 longPanelNames[Audio_Panel] =
107 "Audio Device Panel - various audio related buttons";
108 shortPanelNames[Camera_Panel] = "Camera";
109 longPanelNames[Camera_Panel] =
110 "Camera Panel - simple shutter controls";
111 shortPanelNames[Roomba_Panel] = "Roomba";
112 longPanelNames[Roomba_Panel] =
113 "Roomba Panel - robotic vacuum cleaner controls";
114 shortPanelNames[User_Panel] = "User";
115 longPanelNames[User_Panel] =
116 "User Panel - macro control buttons";
117 shortPanelNames[Macro_Panel] = "Edit Macro Contents";
118 longPanelNames[Macro_Panel] =
119 "Edit Macros Panel - create, delete, edit, and manage macros";
120 shortPanelNames[PowerSearch_Panel] = "Keyset Search";
121 longPanelNames[PowerSearch_Panel] =
122 "Keyset Search Panel - execute power button in each keyset";
124 mainForm = new PIRMainForm(mainWindow);
125 panels[Main_Panel] = mainForm;
127 altMainForm = new PIRAltMainForm(mainWindow);
128 panels[Alt_Main_Panel] = altMainForm;
130 utilityForm = new PIRUtilityForm(mainWindow);
131 panels[Utility_Panel] = utilityForm;
133 keypadForm = new PIRKeypadForm(mainWindow);
134 panels[Keypad_Panel] = keypadForm;
136 menuForm = new PIRMenuForm(mainWindow);
137 panels[Menu_Panel] = menuForm;
139 mediaForm = new PIRMediaForm(mainWindow);
140 panels[Media_Panel] = mediaForm;
142 media2Form = new PIRMedia2Form(mainWindow);
143 panels[Media2_Panel] = media2Form;
145 recordForm = new PIRRecordForm(mainWindow);
146 panels[Record_Panel] = recordForm;
148 tvForm = new PIRTVForm(mainWindow);
149 panels[TV_Panel] = tvForm;
151 inputForm = new PIRInputForm(mainWindow);
152 panels[Input_Panel] = inputForm;
154 adjustForm = new PIRAdjustForm(mainWindow);
155 panels[Adjust_Panel] = adjustForm;
157 acForm = new PIRAirConditionerForm(mainWindow);
158 panels[AC_Panel] = acForm;
160 audioDeviceForm = new PIRAudioDeviceForm(mainWindow);
161 panels[Audio_Panel] = audioDeviceForm;
163 cameraForm = new PIRCameraForm(mainWindow);
164 panels[Camera_Panel] = cameraForm;
166 roombaForm = new PIRRoombaForm(mainWindow);
167 panels[Roomba_Panel] = roombaForm;
169 userForm = new PIRUserForm(mainWindow);
170 panels[User_Panel] = userForm;
172 macroForm = new PIRMacroForm(mainWindow);
173 panels[Macro_Panel] = macroForm;
175 powerSearchForm = new PIRPowerSearchForm(mainWindow);
176 panels[PowerSearch_Panel] = powerSearchForm;
178 // Set up the panel collections:
179 PIRPanelNameList pset;
181 // The universal collection:
182 pset.push_back(Main_Panel);
183 pset.push_back(Utility_Panel);
184 pset.push_back(Keypad_Panel);
185 pset.push_back(Menu_Panel);
186 pset.push_back(Media_Panel);
187 pset.push_back(User_Panel);
188 // pset.push_back(Input_Panel);
189 tabLists[Universal_Tabs] = pset;
191 // The TV collection:
193 pset.push_back(Main_Panel);
194 pset.push_back(Utility_Panel);
195 pset.push_back(Keypad_Panel);
196 pset.push_back(Menu_Panel);
197 pset.push_back(TV_Panel);
198 pset.push_back(Adjust_Panel);
199 tabLists[TV_Tabs] = pset;
201 // The video media collection:
203 pset.push_back(Main_Panel);
204 pset.push_back(Menu_Panel);
205 pset.push_back(Media_Panel);
206 pset.push_back(Media2_Panel);
207 pset.push_back(Input_Panel);
208 tabLists[VideoMedia_Tabs] = pset;
210 // Audio panel collection:
212 pset.push_back(Main_Panel);
213 pset.push_back(Keypad_Panel);
214 pset.push_back(Media_Panel);
215 pset.push_back(Audio_Panel);
216 tabLists[Audio_Tabs] = pset;
218 // The air conditioner collection:
220 pset.push_back(AC_Panel);
221 tabLists[AC_Tabs] = pset;
223 // The recording collection:
225 pset.push_back(Record_Panel);
226 pset.push_back(Keypad_Panel);
227 tabLists[Record_Tabs] = pset;
229 // The camera control collection:
231 pset.push_back(Camera_Panel);
232 tabLists[Camera_Tabs] = pset;
234 // The Roomba collection:
236 pset.push_back(Roomba_Panel);
237 tabLists[Roomba_Tabs] = pset;
239 // The Macro Management collection:
241 pset.push_back(Macro_Panel);
242 tabLists[Macro_Tabs] = pset;
244 // The Power Search collection:
246 pset.push_back(PowerSearch_Panel);
247 tabLists[PowerSearch_Tabs] = pset;
251 PIRPanelManager::~PIRPanelManager()
253 // Note! We are _not_ deleting the panel forms here, because the Qt GUI
254 // has ownership over some of them. Moreover, the Panel Manager is not
255 // currently designed to be destroyed until the program ends. Should the
256 // manager need to be destroyed earlier, this destructor will need to be
261 void PIRPanelManager::updateTabSet()
263 QSettings settings("pietrzak.org", "Pierogi");
264 settings.setValue("currentTabsName", currentTabsName);
266 mainWindow->disableUpdates();
267 mainWindow->clearTabs();
269 PIRPanelNameList::const_iterator i = tabLists[currentTabsName].begin();
271 while (i != tabLists[currentTabsName].end())
273 if ((*i == Main_Panel) && altMainPanelFlag)
275 mainWindow->addTab(altMainForm, shortPanelNames[Main_Panel]);
279 mainWindow->addTab(panels[*i], shortPanelNames[*i]);
285 mainWindow->enableUpdates();
289 void PIRPanelManager::enableButtons(
290 const PIRKeysetManager *keyset,
293 mainForm->enableButtons(keyset, id);
294 altMainForm->enableButtons(keyset, id);
295 commonEnableButtons(keyset, id);
299 void PIRPanelManager::enableButtons(
300 const PIRKeysetManager *keyset,
301 unsigned int currentID,
302 unsigned int defaultID)
304 mainForm->enableButtons(keyset, currentID, defaultID);
305 altMainForm->enableButtons(keyset, currentID, defaultID);
306 commonEnableButtons(keyset, currentID);
310 void PIRPanelManager::commonEnableButtons(
311 const PIRKeysetManager *keyset,
314 utilityForm->enableButtons(keyset, id);
315 keypadForm->enableButtons(keyset, id);
316 menuForm->enableButtons(keyset, id);
317 mediaForm->enableButtons(keyset, id);
318 media2Form->enableButtons(keyset, id);
319 recordForm->enableButtons(keyset, id);
320 tvForm->enableButtons(keyset, id);
321 inputForm->enableButtons(keyset, id);
322 adjustForm->enableButtons(keyset, id);
323 acForm->enableButtons(keyset, id);
324 audioDeviceForm->enableButtons(keyset, id);
325 cameraForm->enableButtons(keyset, id);
326 roombaForm->enableButtons(keyset, id);
328 // Also, set the label in the power search form:
329 powerSearchForm->setKeysetName(mainWindow->getCurrentFullName());
333 void PIRPanelManager::updateUserButtons()
335 userForm->setupButtons();
339 void PIRPanelManager::useMainPanel()
341 if (!altMainPanelFlag)
343 // Already set correctly, nothing to do:
347 altMainPanelFlag = false;
353 void PIRPanelManager::useAltMainPanel()
355 if (altMainPanelFlag)
357 // Already set correctly, nothing to do:
361 altMainPanelFlag = true;
368 void PIRPanelManager::setupUniversalTabs()
370 if (currentTabsName == Universal_Tabs) return;
372 currentTabsName = Universal_Tabs;
377 void PIRPanelManager::setupTVTabs()
379 if (currentTabsName == TV_Tabs) return;
381 currentTabsName = TV_Tabs;
386 void PIRPanelManager::setupVideoTabs()
388 if (currentTabsName == VideoMedia_Tabs) return;
390 currentTabsName = VideoMedia_Tabs;
395 void PIRPanelManager::setupACTabs()
397 if (currentTabsName == AC_Tabs) return;
399 currentTabsName = AC_Tabs;
404 void PIRPanelManager::setupRecordTabs()
406 if (currentTabsName == Record_Tabs) return;
408 currentTabsName = Record_Tabs;
414 void PIRPanelManager::setupTabs(
417 if (currentTabsName == name) return;
419 currentTabsName = name;
424 QComboBox *PIRPanelManager::getKeysetComboBox()
426 return macroForm->getKeysetComboBox();