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/pirroombaform.h"
18 #include "mainwindow.h"
21 #include <QDialogButtonBox>
22 #include <QPushButton>
25 //#include <QMaemo5InformationBox>
28 PIRPanelManager::PIRPanelManager(
44 altMainPanelFlag(false),
45 currentTabsName(Universal_Tabs),
48 QSettings settings("pietrzak.org", "Pierogi");
49 if (settings.contains("currentTabsName"))
51 currentTabsName = PIRTabBarName(settings.value("currentTabsName").toInt());
54 // Set up the panel names:
55 shortPanelNames[Main_Panel] = "Main";
56 longPanelNames[Main_Panel] =
57 "Main Panel - power, volume, and channel controls";
58 shortPanelNames[Utility_Panel] = "Utility";
59 longPanelNames[Utility_Panel] =
60 "Utility Panel - commonly used controls";
61 shortPanelNames[Keypad_Panel] = "Keypad";
62 longPanelNames[Keypad_Panel] =
63 "Keypad Panel - numeric value entry";
64 shortPanelNames[Menu_Panel] = "Menu";
65 longPanelNames[Menu_Panel] =
66 "Menu Panel - enter, exit, and navigate menus";
67 shortPanelNames[Media_Panel] = "Media";
68 longPanelNames[Media_Panel] =
69 "Media Panel - control over recorded data";
70 shortPanelNames[Media2_Panel] = "Media2";
71 longPanelNames[Media2_Panel] =
72 "Media2 Panel - additonal media controls";
73 shortPanelNames[Record_Panel] = "Record";
74 longPanelNames[Record_Panel] =
75 "Program/Record Panel - control over memory and storage";
76 shortPanelNames[TV_Panel] = "TV";
77 longPanelNames[TV_Panel] =
78 "TV Panel - teletext and picture-in-picture";
79 shortPanelNames[Input_Panel] = "Input";
80 longPanelNames[Input_Panel] =
81 "Input Panel - manage data sources";
82 shortPanelNames[Adjust_Panel] = "Adjust";
83 longPanelNames[Adjust_Panel] =
84 "Adjust Panel - modify audio and video";
85 shortPanelNames[AC_Panel] = "AC";
86 longPanelNames[AC_Panel] =
87 "A/C Panel - air conditioner controls";
88 shortPanelNames[Audio_Panel] = "Audio";
89 longPanelNames[Audio_Panel] =
90 "Audio Device Panel - various audio related buttons";
91 shortPanelNames[Roomba_Panel] = "Roomba";
92 longPanelNames[Roomba_Panel] =
93 "Roomba Panel - robotic vacuum cleaner controls";
95 mainForm = new PIRMainForm(mainWindow);
96 panels[Main_Panel] = mainForm;
98 altMainForm = new PIRAltMainForm(mainWindow);
99 panels[Alt_Main_Panel] = altMainForm;
101 utilityForm = new PIRUtilityForm(mainWindow);
102 panels[Utility_Panel] = utilityForm;
104 keypadForm = new PIRKeypadForm(mainWindow);
105 panels[Keypad_Panel] = keypadForm;
107 menuForm = new PIRMenuForm(mainWindow);
108 panels[Menu_Panel] = menuForm;
110 mediaForm = new PIRMediaForm(mainWindow);
111 panels[Media_Panel] = mediaForm;
113 media2Form = new PIRMedia2Form(mainWindow);
114 panels[Media2_Panel] = media2Form;
116 recordForm = new PIRRecordForm(mainWindow);
117 panels[Record_Panel] = recordForm;
119 tvForm = new PIRTVForm(mainWindow);
120 panels[TV_Panel] = tvForm;
122 inputForm = new PIRInputForm(mainWindow);
123 panels[Input_Panel] = inputForm;
125 adjustForm = new PIRAdjustForm(mainWindow);
126 panels[Adjust_Panel] = adjustForm;
128 acForm = new PIRAirConditionerForm(mainWindow);
129 panels[AC_Panel] = acForm;
131 audioDeviceForm = new PIRAudioDeviceForm(mainWindow);
132 panels[Audio_Panel] = audioDeviceForm;
134 roombaForm = new PIRRoombaForm(mainWindow);
135 panels[Roomba_Panel] = roombaForm;
137 // Set up the panel collections:
138 PIRPanelNameList pset;
140 // The universal collection:
141 pset.push_back(Main_Panel);
142 pset.push_back(Utility_Panel);
143 pset.push_back(Keypad_Panel);
144 pset.push_back(Menu_Panel);
145 pset.push_back(Media_Panel);
146 // pset.push_back(Input_Panel);
147 tabLists[Universal_Tabs] = pset;
149 // The TV collection:
151 pset.push_back(Main_Panel);
152 pset.push_back(Utility_Panel);
153 pset.push_back(Keypad_Panel);
154 pset.push_back(Menu_Panel);
155 pset.push_back(TV_Panel);
156 pset.push_back(Adjust_Panel);
157 tabLists[TV_Tabs] = pset;
159 // The video media collection:
161 pset.push_back(Main_Panel);
162 pset.push_back(Menu_Panel);
163 pset.push_back(Media_Panel);
164 pset.push_back(Media2_Panel);
165 pset.push_back(Input_Panel);
166 tabLists[VideoMedia_Tabs] = pset;
168 // Audio panel collection:
170 pset.push_back(Main_Panel);
171 pset.push_back(Keypad_Panel);
172 pset.push_back(Media_Panel);
173 pset.push_back(Audio_Panel);
174 tabLists[Audio_Tabs] = pset;
176 // The air conditioner collection:
178 pset.push_back(AC_Panel);
179 tabLists[AC_Tabs] = pset;
181 // The recording collection:
183 pset.push_back(Record_Panel);
184 pset.push_back(Keypad_Panel);
185 tabLists[Record_Tabs] = pset;
187 // The Roomba collection:
189 pset.push_back(Roomba_Panel);
190 tabLists[Roomba_Tabs] = pset;
194 PIRPanelManager::~PIRPanelManager()
196 // Note! We are _not_ deleting the panel forms here, because the Qt GUI
197 // has ownership over some of them. Moreover, the Panel Manager is not
198 // currently designed to be destroyed until the program ends. Should the
199 // manager need to be destroyed earlier, this destructor will need to be
204 void PIRPanelManager::updateTabSet()
206 QSettings settings("pietrzak.org", "Pierogi");
207 settings.setValue("currentTabsName", currentTabsName);
209 mainWindow->disableUpdates();
210 mainWindow->clearTabs();
212 PIRPanelNameList::const_iterator i = tabLists[currentTabsName].begin();
214 while (i != tabLists[currentTabsName].end())
216 if ((*i == Main_Panel) && altMainPanelFlag)
218 mainWindow->addTab(altMainForm, shortPanelNames[Main_Panel]);
222 mainWindow->addTab(panels[*i], shortPanelNames[*i]);
228 mainWindow->enableUpdates();
232 void PIRPanelManager::enableButtons(
233 const PIRKeysetManager *keyset,
236 mainForm->enableButtons(keyset, id);
237 altMainForm->enableButtons(keyset, id);
238 commonEnableButtons(keyset, id);
242 void PIRPanelManager::enableButtons(
243 const PIRKeysetManager *keyset,
244 unsigned int currentID,
245 unsigned int defaultID)
247 mainForm->enableButtons(keyset, currentID, defaultID);
248 altMainForm->enableButtons(keyset, currentID, defaultID);
249 commonEnableButtons(keyset, currentID);
253 void PIRPanelManager::commonEnableButtons(
254 const PIRKeysetManager *keyset,
257 utilityForm->enableButtons(keyset, id);
258 keypadForm->enableButtons(keyset, id);
259 menuForm->enableButtons(keyset, id);
260 mediaForm->enableButtons(keyset, id);
261 media2Form->enableButtons(keyset, id);
262 recordForm->enableButtons(keyset, id);
263 tvForm->enableButtons(keyset, id);
264 inputForm->enableButtons(keyset, id);
265 adjustForm->enableButtons(keyset, id);
266 acForm->enableButtons(keyset, id);
267 audioDeviceForm->enableButtons(keyset, id);
268 roombaForm->enableButtons(keyset, id);
272 void PIRPanelManager::useMainPanel()
274 if (!altMainPanelFlag)
276 // Already set correctly, nothing to do:
280 altMainPanelFlag = false;
286 void PIRPanelManager::useAltMainPanel()
288 if (altMainPanelFlag)
290 // Already set correctly, nothing to do:
294 altMainPanelFlag = true;
301 void PIRPanelManager::setupUniversalTabs()
303 if (currentTabsName == Universal_Tabs) return;
305 currentTabsName = Universal_Tabs;
310 void PIRPanelManager::setupTVTabs()
312 if (currentTabsName == TV_Tabs) return;
314 currentTabsName = TV_Tabs;
319 void PIRPanelManager::setupVideoTabs()
321 if (currentTabsName == VideoMedia_Tabs) return;
323 currentTabsName = VideoMedia_Tabs;
328 void PIRPanelManager::setupACTabs()
330 if (currentTabsName == AC_Tabs) return;
332 currentTabsName = AC_Tabs;
337 void PIRPanelManager::setupRecordTabs()
339 if (currentTabsName == Record_Tabs) return;
341 currentTabsName = Record_Tabs;
347 void PIRPanelManager::setupTabs(
350 if (currentTabsName == name) return;
352 currentTabsName = name;