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"
17 #include "mainwindow.h"
20 #include <QDialogButtonBox>
21 #include <QPushButton>
24 //#include <QMaemo5InformationBox>
27 PIRPanelManager::PIRPanelManager(
42 altMainPanelFlag(false),
43 currentTabsName(Universal_Tabs),
46 QSettings settings("pietrzak.org", "Pierogi");
47 if (settings.contains("currentTabsName"))
49 currentTabsName = PIRTabBarName(settings.value("currentTabsName").toInt());
52 // Set up the panel names:
53 shortPanelNames[Main_Panel] = "Main";
54 longPanelNames[Main_Panel] =
55 "Main Panel - power, volume, and channel controls";
56 shortPanelNames[Utility_Panel] = "Utility";
57 longPanelNames[Utility_Panel] =
58 "Utility Panel - commonly used controls";
59 shortPanelNames[Keypad_Panel] = "Keypad";
60 longPanelNames[Keypad_Panel] =
61 "Keypad Panel - numeric value entry";
62 shortPanelNames[Menu_Panel] = "Menu";
63 longPanelNames[Menu_Panel] =
64 "Menu Panel - enter, exit, and navigate menus";
65 shortPanelNames[Media_Panel] = "Media";
66 longPanelNames[Media_Panel] =
67 "Media Panel - control over recorded data";
68 shortPanelNames[Media2_Panel] = "Media2";
69 longPanelNames[Media2_Panel] =
70 "Media2 Panel - additonal media controls";
71 shortPanelNames[Record_Panel] = "Record";
72 longPanelNames[Record_Panel] =
73 "Program/Record Panel - control over memory and storage";
74 shortPanelNames[TV_Panel] = "TV";
75 longPanelNames[TV_Panel] =
76 "TV Panel - teletext and picture-in-picture";
77 shortPanelNames[Input_Panel] = "Input";
78 longPanelNames[Input_Panel] =
79 "Input Panel - manage data sources";
80 shortPanelNames[Adjust_Panel] = "Adjust";
81 longPanelNames[Adjust_Panel] =
82 "Adjust Panel - modify audio and video";
83 shortPanelNames[AC_Panel] = "AC";
84 longPanelNames[AC_Panel] =
85 "A/C Panel - air conditioner controls";
86 shortPanelNames[Audio_Panel] = "Audio";
87 longPanelNames[Audio_Panel] =
88 "Audio Device Panel - various audio related buttons";
90 mainForm = new PIRMainForm(mainWindow);
91 panels[Main_Panel] = mainForm;
93 altMainForm = new PIRAltMainForm(mainWindow);
94 panels[Alt_Main_Panel] = altMainForm;
96 utilityForm = new PIRUtilityForm(mainWindow);
97 panels[Utility_Panel] = utilityForm;
99 keypadForm = new PIRKeypadForm(mainWindow);
100 panels[Keypad_Panel] = keypadForm;
102 menuForm = new PIRMenuForm(mainWindow);
103 panels[Menu_Panel] = menuForm;
105 mediaForm = new PIRMediaForm(mainWindow);
106 panels[Media_Panel] = mediaForm;
108 media2Form = new PIRMedia2Form(mainWindow);
109 panels[Media2_Panel] = media2Form;
111 recordForm = new PIRRecordForm(mainWindow);
112 panels[Record_Panel] = recordForm;
114 tvForm = new PIRTVForm(mainWindow);
115 panels[TV_Panel] = tvForm;
117 inputForm = new PIRInputForm(mainWindow);
118 panels[Input_Panel] = inputForm;
120 adjustForm = new PIRAdjustForm(mainWindow);
121 panels[Adjust_Panel] = adjustForm;
123 acForm = new PIRAirConditionerForm(mainWindow);
124 panels[AC_Panel] = acForm;
126 audioDeviceForm = new PIRAudioDeviceForm(mainWindow);
127 panels[Audio_Panel] = audioDeviceForm;
129 // Set up the panel collections:
130 PIRPanelNameList pset;
132 // The universal collection:
133 pset.push_back(Main_Panel);
134 pset.push_back(Utility_Panel);
135 pset.push_back(Keypad_Panel);
136 pset.push_back(Menu_Panel);
137 pset.push_back(Media_Panel);
138 pset.push_back(Input_Panel);
139 tabLists[Universal_Tabs] = pset;
141 // The TV collection:
143 pset.push_back(Main_Panel);
144 pset.push_back(Utility_Panel);
145 pset.push_back(Keypad_Panel);
146 pset.push_back(Menu_Panel);
147 pset.push_back(TV_Panel);
148 pset.push_back(Adjust_Panel);
149 tabLists[TV_Tabs] = pset;
151 // The video media collection:
153 pset.push_back(Main_Panel);
154 pset.push_back(Menu_Panel);
155 pset.push_back(Media_Panel);
156 pset.push_back(Media2_Panel);
157 pset.push_back(Input_Panel);
158 tabLists[VideoMedia_Tabs] = pset;
160 // Audio panel collection:
162 pset.push_back(Main_Panel);
163 pset.push_back(Keypad_Panel);
164 pset.push_back(Media_Panel);
165 pset.push_back(Audio_Panel);
166 tabLists[Audio_Tabs] = pset;
168 // The air conditioner collection:
170 pset.push_back(AC_Panel);
171 tabLists[AC_Tabs] = pset;
173 // The recording collection:
175 pset.push_back(Record_Panel);
176 pset.push_back(Keypad_Panel);
177 tabLists[Record_Tabs] = pset;
181 PIRPanelManager::~PIRPanelManager()
183 // Note! We are _not_ deleting the panel forms here, because the Qt GUI
184 // has ownership over some of them. Moreover, the Panel Manager is not
185 // currently designed to be destroyed until the program ends. Should the
186 // manager need to be destroyed earlier, this destructor will need to be
191 void PIRPanelManager::updateTabSet()
193 QSettings settings("pietrzak.org", "Pierogi");
194 settings.setValue("currentTabsName", currentTabsName);
196 mainWindow->disableUpdates();
197 mainWindow->clearTabs();
199 PIRPanelNameList::const_iterator i = tabLists[currentTabsName].begin();
201 while (i != tabLists[currentTabsName].end())
203 if ((*i == Main_Panel) && altMainPanelFlag)
205 mainWindow->addTab(altMainForm, shortPanelNames[Main_Panel]);
209 mainWindow->addTab(panels[*i], shortPanelNames[*i]);
215 mainWindow->enableUpdates();
219 void PIRPanelManager::enableButtons(
220 const PIRKeysetManager *keyset,
223 mainForm->enableButtons(keyset, id);
224 altMainForm->enableButtons(keyset, id);
225 commonEnableButtons(keyset, id);
229 void PIRPanelManager::enableButtons(
230 const PIRKeysetManager *keyset,
231 unsigned int currentID,
232 unsigned int defaultID)
234 mainForm->enableButtons(keyset, currentID, defaultID);
235 altMainForm->enableButtons(keyset, currentID, defaultID);
236 commonEnableButtons(keyset, currentID);
240 void PIRPanelManager::commonEnableButtons(
241 const PIRKeysetManager *keyset,
244 utilityForm->enableButtons(keyset, id);
245 keypadForm->enableButtons(keyset, id);
246 menuForm->enableButtons(keyset, id);
247 mediaForm->enableButtons(keyset, id);
248 media2Form->enableButtons(keyset, id);
249 recordForm->enableButtons(keyset, id);
250 tvForm->enableButtons(keyset, id);
251 inputForm->enableButtons(keyset, id);
252 adjustForm->enableButtons(keyset, id);
253 acForm->enableButtons(keyset, id);
254 audioDeviceForm->enableButtons(keyset, id);
258 void PIRPanelManager::useMainPanel()
260 if (!altMainPanelFlag)
262 // Already set correctly, nothing to do:
266 altMainPanelFlag = false;
272 void PIRPanelManager::useAltMainPanel()
274 if (altMainPanelFlag)
276 // Already set correctly, nothing to do:
280 altMainPanelFlag = true;
287 void PIRPanelManager::setupUniversalTabs()
289 if (currentTabsName == Universal_Tabs) return;
291 currentTabsName = Universal_Tabs;
296 void PIRPanelManager::setupTVTabs()
298 if (currentTabsName == TV_Tabs) return;
300 currentTabsName = TV_Tabs;
305 void PIRPanelManager::setupVideoTabs()
307 if (currentTabsName == VideoMedia_Tabs) return;
309 currentTabsName = VideoMedia_Tabs;
314 void PIRPanelManager::setupACTabs()
316 if (currentTabsName == AC_Tabs) return;
318 currentTabsName = AC_Tabs;
323 void PIRPanelManager::setupRecordTabs()
325 if (currentTabsName == Record_Tabs) return;
327 currentTabsName = Record_Tabs;
333 void PIRPanelManager::setupTabs(
336 if (currentTabsName == name) return;
338 currentTabsName = name;