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/pirmacroform.h"
19 #include "forms/pirpowersearchform.h"
21 #include "mainwindow.h"
24 #include <QDialogButtonBox>
25 #include <QPushButton>
28 //#include <QMaemo5InformationBox>
31 PIRPanelManager::PIRPanelManager(
50 altMainPanelFlag(false),
51 currentTabsName(Universal_Tabs),
54 QSettings settings("pietrzak.org", "Pierogi");
55 if (settings.contains("currentTabsName"))
57 int tabVal = settings.value("currentTabsName").toInt();
59 if (tabVal >= Last_Tabs_Marker)
61 currentTabsName = Universal_Tabs;
65 currentTabsName = PIRTabBarName(tabVal);
69 // Set up the panel names:
70 shortPanelNames[Main_Panel] = "Main";
71 longPanelNames[Main_Panel] =
72 "Main Panel - power, volume, and channel controls";
73 shortPanelNames[Utility_Panel] = "Utility";
74 longPanelNames[Utility_Panel] =
75 "Utility Panel - commonly used controls";
76 shortPanelNames[Keypad_Panel] = "Keypad";
77 longPanelNames[Keypad_Panel] =
78 "Keypad Panel - numeric value entry";
79 shortPanelNames[Menu_Panel] = "Menu";
80 longPanelNames[Menu_Panel] =
81 "Menu Panel - enter, exit, and navigate menus";
82 shortPanelNames[Media_Panel] = "Media";
83 longPanelNames[Media_Panel] =
84 "Media Panel - control over recorded data";
85 shortPanelNames[Media2_Panel] = "Media2";
86 longPanelNames[Media2_Panel] =
87 "Media2 Panel - additonal media controls";
88 shortPanelNames[Record_Panel] = "Record";
89 longPanelNames[Record_Panel] =
90 "Program/Record Panel - control over memory and storage";
91 shortPanelNames[TV_Panel] = "TV";
92 longPanelNames[TV_Panel] =
93 "TV Panel - teletext and picture-in-picture";
94 shortPanelNames[Input_Panel] = "Input";
95 longPanelNames[Input_Panel] =
96 "Input Panel - manage data sources";
97 shortPanelNames[Adjust_Panel] = "Adjust";
98 longPanelNames[Adjust_Panel] =
99 "Adjust Panel - modify audio and video";
100 shortPanelNames[AC_Panel] = "AC";
101 longPanelNames[AC_Panel] =
102 "A/C Panel - air conditioner controls";
103 shortPanelNames[Audio_Panel] = "Audio";
104 longPanelNames[Audio_Panel] =
105 "Audio Device Panel - various audio related buttons";
106 shortPanelNames[Camera_Panel] = "Camera";
107 longPanelNames[Camera_Panel] =
108 "Camera Panel - simple shutter controls";
109 shortPanelNames[Roomba_Panel] = "Roomba";
110 longPanelNames[Roomba_Panel] =
111 "Roomba Panel - robotic vacuum cleaner controls";
112 shortPanelNames[Macro_Panel] = "Edit Macros";
113 longPanelNames[Macro_Panel] =
114 "Edit Macros Panel - create, delete, edit, and manage macros";
115 shortPanelNames[PowerSearch_Panel] = "Keyset Search";
116 longPanelNames[PowerSearch_Panel] =
117 "Keyset Search Panel - execute power button in each keyset";
119 mainForm = new PIRMainForm(mainWindow);
120 panels[Main_Panel] = mainForm;
122 altMainForm = new PIRAltMainForm(mainWindow);
123 panels[Alt_Main_Panel] = altMainForm;
125 utilityForm = new PIRUtilityForm(mainWindow);
126 panels[Utility_Panel] = utilityForm;
128 keypadForm = new PIRKeypadForm(mainWindow);
129 panels[Keypad_Panel] = keypadForm;
131 menuForm = new PIRMenuForm(mainWindow);
132 panels[Menu_Panel] = menuForm;
134 mediaForm = new PIRMediaForm(mainWindow);
135 panels[Media_Panel] = mediaForm;
137 media2Form = new PIRMedia2Form(mainWindow);
138 panels[Media2_Panel] = media2Form;
140 recordForm = new PIRRecordForm(mainWindow);
141 panels[Record_Panel] = recordForm;
143 tvForm = new PIRTVForm(mainWindow);
144 panels[TV_Panel] = tvForm;
146 inputForm = new PIRInputForm(mainWindow);
147 panels[Input_Panel] = inputForm;
149 adjustForm = new PIRAdjustForm(mainWindow);
150 panels[Adjust_Panel] = adjustForm;
152 acForm = new PIRAirConditionerForm(mainWindow);
153 panels[AC_Panel] = acForm;
155 audioDeviceForm = new PIRAudioDeviceForm(mainWindow);
156 panels[Audio_Panel] = audioDeviceForm;
158 cameraForm = new PIRCameraForm(mainWindow);
159 panels[Camera_Panel] = cameraForm;
161 roombaForm = new PIRRoombaForm(mainWindow);
162 panels[Roomba_Panel] = roombaForm;
164 macroForm = new PIRMacroForm(mainWindow);
165 panels[Macro_Panel] = macroForm;
167 powerSearchForm = new PIRPowerSearchForm(mainWindow);
168 panels[PowerSearch_Panel] = powerSearchForm;
170 // Set up the panel collections:
171 PIRPanelNameList pset;
173 // The universal collection:
174 pset.push_back(Main_Panel);
175 pset.push_back(Utility_Panel);
176 pset.push_back(Keypad_Panel);
177 pset.push_back(Menu_Panel);
178 pset.push_back(Media_Panel);
179 // pset.push_back(Input_Panel);
180 tabLists[Universal_Tabs] = pset;
182 // The TV collection:
184 pset.push_back(Main_Panel);
185 pset.push_back(Utility_Panel);
186 pset.push_back(Keypad_Panel);
187 pset.push_back(Menu_Panel);
188 pset.push_back(TV_Panel);
189 pset.push_back(Adjust_Panel);
190 tabLists[TV_Tabs] = pset;
192 // The video media collection:
194 pset.push_back(Main_Panel);
195 pset.push_back(Menu_Panel);
196 pset.push_back(Media_Panel);
197 pset.push_back(Media2_Panel);
198 pset.push_back(Input_Panel);
199 tabLists[VideoMedia_Tabs] = pset;
201 // Audio panel collection:
203 pset.push_back(Main_Panel);
204 pset.push_back(Keypad_Panel);
205 pset.push_back(Media_Panel);
206 pset.push_back(Audio_Panel);
207 tabLists[Audio_Tabs] = pset;
209 // The air conditioner collection:
211 pset.push_back(AC_Panel);
212 tabLists[AC_Tabs] = pset;
214 // The recording collection:
216 pset.push_back(Record_Panel);
217 pset.push_back(Keypad_Panel);
218 tabLists[Record_Tabs] = pset;
220 // The camera control collection:
222 pset.push_back(Camera_Panel);
223 tabLists[Camera_Tabs] = pset;
225 // The Roomba collection:
227 pset.push_back(Roomba_Panel);
228 tabLists[Roomba_Tabs] = pset;
230 // The Macro Management collection:
232 pset.push_back(Macro_Panel);
233 tabLists[Macro_Tabs] = pset;
235 // The Power Search collection:
237 pset.push_back(PowerSearch_Panel);
238 tabLists[PowerSearch_Tabs] = pset;
242 PIRPanelManager::~PIRPanelManager()
244 // Note! We are _not_ deleting the panel forms here, because the Qt GUI
245 // has ownership over some of them. Moreover, the Panel Manager is not
246 // currently designed to be destroyed until the program ends. Should the
247 // manager need to be destroyed earlier, this destructor will need to be
252 void PIRPanelManager::updateTabSet()
254 QSettings settings("pietrzak.org", "Pierogi");
255 settings.setValue("currentTabsName", currentTabsName);
257 mainWindow->disableUpdates();
258 mainWindow->clearTabs();
260 PIRPanelNameList::const_iterator i = tabLists[currentTabsName].begin();
262 while (i != tabLists[currentTabsName].end())
264 if ((*i == Main_Panel) && altMainPanelFlag)
266 mainWindow->addTab(altMainForm, shortPanelNames[Main_Panel]);
270 mainWindow->addTab(panels[*i], shortPanelNames[*i]);
276 mainWindow->enableUpdates();
280 void PIRPanelManager::enableButtons(
281 const PIRKeysetManager *keyset,
284 mainForm->enableButtons(keyset, id);
285 altMainForm->enableButtons(keyset, id);
286 commonEnableButtons(keyset, id);
290 void PIRPanelManager::enableButtons(
291 const PIRKeysetManager *keyset,
292 unsigned int currentID,
293 unsigned int defaultID)
295 mainForm->enableButtons(keyset, currentID, defaultID);
296 altMainForm->enableButtons(keyset, currentID, defaultID);
297 commonEnableButtons(keyset, currentID);
301 void PIRPanelManager::commonEnableButtons(
302 const PIRKeysetManager *keyset,
305 utilityForm->enableButtons(keyset, id);
306 keypadForm->enableButtons(keyset, id);
307 menuForm->enableButtons(keyset, id);
308 mediaForm->enableButtons(keyset, id);
309 media2Form->enableButtons(keyset, id);
310 recordForm->enableButtons(keyset, id);
311 tvForm->enableButtons(keyset, id);
312 inputForm->enableButtons(keyset, id);
313 adjustForm->enableButtons(keyset, id);
314 acForm->enableButtons(keyset, id);
315 audioDeviceForm->enableButtons(keyset, id);
316 cameraForm->enableButtons(keyset, id);
317 roombaForm->enableButtons(keyset, id);
319 // Also, set the label in the power search form:
320 powerSearchForm->setKeysetName(mainWindow->getCurrentFullName());
324 void PIRPanelManager::useMainPanel()
326 if (!altMainPanelFlag)
328 // Already set correctly, nothing to do:
332 altMainPanelFlag = false;
338 void PIRPanelManager::useAltMainPanel()
340 if (altMainPanelFlag)
342 // Already set correctly, nothing to do:
346 altMainPanelFlag = true;
353 void PIRPanelManager::setupUniversalTabs()
355 if (currentTabsName == Universal_Tabs) return;
357 currentTabsName = Universal_Tabs;
362 void PIRPanelManager::setupTVTabs()
364 if (currentTabsName == TV_Tabs) return;
366 currentTabsName = TV_Tabs;
371 void PIRPanelManager::setupVideoTabs()
373 if (currentTabsName == VideoMedia_Tabs) return;
375 currentTabsName = VideoMedia_Tabs;
380 void PIRPanelManager::setupACTabs()
382 if (currentTabsName == AC_Tabs) return;
384 currentTabsName = AC_Tabs;
389 void PIRPanelManager::setupRecordTabs()
391 if (currentTabsName == Record_Tabs) return;
393 currentTabsName = Record_Tabs;
399 void PIRPanelManager::setupTabs(
402 if (currentTabsName == name) return;
404 currentTabsName = name;