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/pirfavoritesform.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[Favorites_Panel] = "Favorites";
87 longPanelNames[Favorites_Panel] =
88 "Favorites Panel - memorized keysets";
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 favoritesForm = new PIRFavoritesForm(mainWindow);
127 panels[Favorites_Panel] = favoritesForm;
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(Favorites_Panel);
139 tabLists[Universal_Tabs] = pset;
141 // The TV collection:
143 pset.push_back(Main_Panel);
144 pset.push_back(Keypad_Panel);
145 pset.push_back(Menu_Panel);
146 pset.push_back(TV_Panel);
147 pset.push_back(Adjust_Panel);
148 pset.push_back(Favorites_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 pset.push_back(Favorites_Panel);
159 tabLists[VideoMedia_Tabs] = pset;
161 // The air conditioner collection:
163 pset.push_back(AC_Panel);
164 pset.push_back(Favorites_Panel);
165 tabLists[AC_Tabs] = pset;
167 // The recording collection:
169 pset.push_back(Record_Panel);
170 pset.push_back(Keypad_Panel);
171 pset.push_back(Favorites_Panel);
172 tabLists[Record_Tabs] = pset;
176 PIRPanelManager::~PIRPanelManager()
178 // Note! We are _not_ deleting the panel forms here, because the Qt GUI
179 // has ownership over some of them. Moreover, the Panel Manager is not
180 // currently designed to be destroyed until the program ends. Should the
181 // manager need to be destroyed earlier, this destructor will need to be
186 void PIRPanelManager::updateTabSet()
188 QSettings settings("pietrzak.org", "Pierogi");
189 settings.setValue("currentTabsName", currentTabsName);
191 mainWindow->disableUpdates();
192 mainWindow->clearTabs();
194 PIRPanelNameList::const_iterator i = tabLists[currentTabsName].begin();
196 while (i != tabLists[currentTabsName].end())
198 if ((*i == Main_Panel) && altMainPanelFlag)
200 mainWindow->addTab(altMainForm, shortPanelNames[Main_Panel]);
204 mainWindow->addTab(panels[*i], shortPanelNames[*i]);
210 mainWindow->enableUpdates();
214 void PIRPanelManager::enableButtons(
215 const PIRKeysetManager *keyset,
218 mainForm->enableButtons(keyset, id);
219 altMainForm->enableButtons(keyset, id);
220 commonEnableButtons(keyset, id);
224 void PIRPanelManager::enableButtons(
225 const PIRKeysetManager *keyset,
226 unsigned int currentID,
227 unsigned int defaultID)
229 mainForm->enableButtons(keyset, currentID, defaultID);
230 altMainForm->enableButtons(keyset, currentID, defaultID);
231 commonEnableButtons(keyset, currentID);
235 void PIRPanelManager::commonEnableButtons(
236 const PIRKeysetManager *keyset,
239 utilityForm->enableButtons(keyset, id);
240 keypadForm->enableButtons(keyset, id);
241 menuForm->enableButtons(keyset, id);
242 mediaForm->enableButtons(keyset, id);
243 media2Form->enableButtons(keyset, id);
244 recordForm->enableButtons(keyset, id);
245 tvForm->enableButtons(keyset, id);
246 inputForm->enableButtons(keyset, id);
247 adjustForm->enableButtons(keyset, id);
248 acForm->enableButtons(keyset, id);
252 void PIRPanelManager::useMainPanel()
254 if (!altMainPanelFlag)
256 // Already set correctly, nothing to do:
260 altMainPanelFlag = false;
266 void PIRPanelManager::useAltMainPanel()
268 if (altMainPanelFlag)
270 // Already set correctly, nothing to do:
274 altMainPanelFlag = true;
280 void PIRPanelManager::selectPrevFavKeyset()
282 favoritesForm->selectPrevFavKeyset();
286 void PIRPanelManager::selectNextFavKeyset()
288 favoritesForm->selectNextFavKeyset();
292 void PIRPanelManager::addFavoritesItem(
293 PIRKeysetWidgetItem *item)
295 favoritesForm->addItem(item);
299 QListWidget *PIRPanelManager::getFavoritesListWidget()
301 return favoritesForm->getFavoritesListWidget();
305 void PIRPanelManager::setupUniversalTabs()
307 if (currentTabsName == Universal_Tabs) return;
309 currentTabsName = Universal_Tabs;
314 void PIRPanelManager::setupTVTabs()
316 if (currentTabsName == TV_Tabs) return;
318 currentTabsName = TV_Tabs;
323 void PIRPanelManager::setupVideoTabs()
325 if (currentTabsName == VideoMedia_Tabs) return;
327 currentTabsName = VideoMedia_Tabs;
332 void PIRPanelManager::setupACTabs()
334 if (currentTabsName == AC_Tabs) return;
336 currentTabsName = AC_Tabs;
341 void PIRPanelManager::setupRecordTabs()
343 if (currentTabsName == Record_Tabs) return;
345 currentTabsName = Record_Tabs;
350 void PIRPanelManager::setupTabs(
353 if (currentTabsName == name) return;
355 currentTabsName = name;