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/pirpowersearchform.h"
20 #include "mainwindow.h"
23 #include <QDialogButtonBox>
24 #include <QPushButton>
27 //#include <QMaemo5InformationBox>
30 PIRPanelManager::PIRPanelManager(
48 altMainPanelFlag(false),
49 currentTabsName(Universal_Tabs),
52 QSettings settings("pietrzak.org", "Pierogi");
53 if (settings.contains("currentTabsName"))
55 currentTabsName = PIRTabBarName(settings.value("currentTabsName").toInt());
58 // Set up the panel names:
59 shortPanelNames[Main_Panel] = "Main";
60 longPanelNames[Main_Panel] =
61 "Main Panel - power, volume, and channel controls";
62 shortPanelNames[Utility_Panel] = "Utility";
63 longPanelNames[Utility_Panel] =
64 "Utility Panel - commonly used controls";
65 shortPanelNames[Keypad_Panel] = "Keypad";
66 longPanelNames[Keypad_Panel] =
67 "Keypad Panel - numeric value entry";
68 shortPanelNames[Menu_Panel] = "Menu";
69 longPanelNames[Menu_Panel] =
70 "Menu Panel - enter, exit, and navigate menus";
71 shortPanelNames[Media_Panel] = "Media";
72 longPanelNames[Media_Panel] =
73 "Media Panel - control over recorded data";
74 shortPanelNames[Media2_Panel] = "Media2";
75 longPanelNames[Media2_Panel] =
76 "Media2 Panel - additonal media controls";
77 shortPanelNames[Record_Panel] = "Record";
78 longPanelNames[Record_Panel] =
79 "Program/Record Panel - control over memory and storage";
80 shortPanelNames[TV_Panel] = "TV";
81 longPanelNames[TV_Panel] =
82 "TV Panel - teletext and picture-in-picture";
83 shortPanelNames[Input_Panel] = "Input";
84 longPanelNames[Input_Panel] =
85 "Input Panel - manage data sources";
86 shortPanelNames[Adjust_Panel] = "Adjust";
87 longPanelNames[Adjust_Panel] =
88 "Adjust Panel - modify audio and video";
89 shortPanelNames[AC_Panel] = "AC";
90 longPanelNames[AC_Panel] =
91 "A/C Panel - air conditioner controls";
92 shortPanelNames[Audio_Panel] = "Audio";
93 longPanelNames[Audio_Panel] =
94 "Audio Device Panel - various audio related buttons";
95 shortPanelNames[Camera_Panel] = "Camera";
96 longPanelNames[Camera_Panel] =
97 "Camera Panel - simple shutter controls";
98 shortPanelNames[Roomba_Panel] = "Roomba";
99 longPanelNames[Roomba_Panel] =
100 "Roomba Panel - robotic vacuum cleaner controls";
101 shortPanelNames[PowerSearch_Panel] = "Keyset Search";
102 longPanelNames[PowerSearch_Panel] =
103 "Keyset Search Panel - execute power button in each keyset";
105 mainForm = new PIRMainForm(mainWindow);
106 panels[Main_Panel] = mainForm;
108 altMainForm = new PIRAltMainForm(mainWindow);
109 panels[Alt_Main_Panel] = altMainForm;
111 utilityForm = new PIRUtilityForm(mainWindow);
112 panels[Utility_Panel] = utilityForm;
114 keypadForm = new PIRKeypadForm(mainWindow);
115 panels[Keypad_Panel] = keypadForm;
117 menuForm = new PIRMenuForm(mainWindow);
118 panels[Menu_Panel] = menuForm;
120 mediaForm = new PIRMediaForm(mainWindow);
121 panels[Media_Panel] = mediaForm;
123 media2Form = new PIRMedia2Form(mainWindow);
124 panels[Media2_Panel] = media2Form;
126 recordForm = new PIRRecordForm(mainWindow);
127 panels[Record_Panel] = recordForm;
129 tvForm = new PIRTVForm(mainWindow);
130 panels[TV_Panel] = tvForm;
132 inputForm = new PIRInputForm(mainWindow);
133 panels[Input_Panel] = inputForm;
135 adjustForm = new PIRAdjustForm(mainWindow);
136 panels[Adjust_Panel] = adjustForm;
138 acForm = new PIRAirConditionerForm(mainWindow);
139 panels[AC_Panel] = acForm;
141 audioDeviceForm = new PIRAudioDeviceForm(mainWindow);
142 panels[Audio_Panel] = audioDeviceForm;
144 cameraForm = new PIRCameraForm(mainWindow);
145 panels[Camera_Panel] = cameraForm;
147 roombaForm = new PIRRoombaForm(mainWindow);
148 panels[Roomba_Panel] = roombaForm;
150 powerSearchForm = new PIRPowerSearchForm(mainWindow);
151 panels[PowerSearch_Panel] = powerSearchForm;
153 // Set up the panel collections:
154 PIRPanelNameList pset;
156 // The universal collection:
157 pset.push_back(Main_Panel);
158 pset.push_back(Utility_Panel);
159 pset.push_back(Keypad_Panel);
160 pset.push_back(Menu_Panel);
161 pset.push_back(Media_Panel);
162 // pset.push_back(Input_Panel);
163 tabLists[Universal_Tabs] = pset;
165 // The TV collection:
167 pset.push_back(Main_Panel);
168 pset.push_back(Utility_Panel);
169 pset.push_back(Keypad_Panel);
170 pset.push_back(Menu_Panel);
171 pset.push_back(TV_Panel);
172 pset.push_back(Adjust_Panel);
173 tabLists[TV_Tabs] = pset;
175 // The video media collection:
177 pset.push_back(Main_Panel);
178 pset.push_back(Menu_Panel);
179 pset.push_back(Media_Panel);
180 pset.push_back(Media2_Panel);
181 pset.push_back(Input_Panel);
182 tabLists[VideoMedia_Tabs] = pset;
184 // Audio panel collection:
186 pset.push_back(Main_Panel);
187 pset.push_back(Keypad_Panel);
188 pset.push_back(Media_Panel);
189 pset.push_back(Audio_Panel);
190 tabLists[Audio_Tabs] = pset;
192 // The air conditioner collection:
194 pset.push_back(AC_Panel);
195 tabLists[AC_Tabs] = pset;
197 // The recording collection:
199 pset.push_back(Record_Panel);
200 pset.push_back(Keypad_Panel);
201 tabLists[Record_Tabs] = pset;
203 // The camera control collection:
205 pset.push_back(Camera_Panel);
206 tabLists[Camera_Tabs] = pset;
208 // The Roomba collection:
210 pset.push_back(Roomba_Panel);
211 tabLists[Roomba_Tabs] = pset;
213 // The Power Search collection:
215 pset.push_back(PowerSearch_Panel);
216 tabLists[PowerSearch_Tabs] = pset;
220 PIRPanelManager::~PIRPanelManager()
222 // Note! We are _not_ deleting the panel forms here, because the Qt GUI
223 // has ownership over some of them. Moreover, the Panel Manager is not
224 // currently designed to be destroyed until the program ends. Should the
225 // manager need to be destroyed earlier, this destructor will need to be
230 void PIRPanelManager::updateTabSet()
232 QSettings settings("pietrzak.org", "Pierogi");
233 settings.setValue("currentTabsName", currentTabsName);
235 mainWindow->disableUpdates();
236 mainWindow->clearTabs();
238 PIRPanelNameList::const_iterator i = tabLists[currentTabsName].begin();
240 while (i != tabLists[currentTabsName].end())
242 if ((*i == Main_Panel) && altMainPanelFlag)
244 mainWindow->addTab(altMainForm, shortPanelNames[Main_Panel]);
248 mainWindow->addTab(panels[*i], shortPanelNames[*i]);
254 mainWindow->enableUpdates();
258 void PIRPanelManager::enableButtons(
259 const PIRKeysetManager *keyset,
262 mainForm->enableButtons(keyset, id);
263 altMainForm->enableButtons(keyset, id);
264 commonEnableButtons(keyset, id);
268 void PIRPanelManager::enableButtons(
269 const PIRKeysetManager *keyset,
270 unsigned int currentID,
271 unsigned int defaultID)
273 mainForm->enableButtons(keyset, currentID, defaultID);
274 altMainForm->enableButtons(keyset, currentID, defaultID);
275 commonEnableButtons(keyset, currentID);
279 void PIRPanelManager::commonEnableButtons(
280 const PIRKeysetManager *keyset,
283 utilityForm->enableButtons(keyset, id);
284 keypadForm->enableButtons(keyset, id);
285 menuForm->enableButtons(keyset, id);
286 mediaForm->enableButtons(keyset, id);
287 media2Form->enableButtons(keyset, id);
288 recordForm->enableButtons(keyset, id);
289 tvForm->enableButtons(keyset, id);
290 inputForm->enableButtons(keyset, id);
291 adjustForm->enableButtons(keyset, id);
292 acForm->enableButtons(keyset, id);
293 audioDeviceForm->enableButtons(keyset, id);
294 cameraForm->enableButtons(keyset, id);
295 roombaForm->enableButtons(keyset, id);
297 // Also, set the label in the power search form:
298 powerSearchForm->setKeysetName(mainWindow->getCurrentFullName());
302 void PIRPanelManager::useMainPanel()
304 if (!altMainPanelFlag)
306 // Already set correctly, nothing to do:
310 altMainPanelFlag = false;
316 void PIRPanelManager::useAltMainPanel()
318 if (altMainPanelFlag)
320 // Already set correctly, nothing to do:
324 altMainPanelFlag = true;
331 void PIRPanelManager::setupUniversalTabs()
333 if (currentTabsName == Universal_Tabs) return;
335 currentTabsName = Universal_Tabs;
340 void PIRPanelManager::setupTVTabs()
342 if (currentTabsName == TV_Tabs) return;
344 currentTabsName = TV_Tabs;
349 void PIRPanelManager::setupVideoTabs()
351 if (currentTabsName == VideoMedia_Tabs) return;
353 currentTabsName = VideoMedia_Tabs;
358 void PIRPanelManager::setupACTabs()
360 if (currentTabsName == AC_Tabs) return;
362 currentTabsName = AC_Tabs;
367 void PIRPanelManager::setupRecordTabs()
369 if (currentTabsName == Record_Tabs) return;
371 currentTabsName = Record_Tabs;
377 void PIRPanelManager::setupTabs(
380 if (currentTabsName == name) return;
382 currentTabsName = name;