1 #include "pirpanelmanager.h"
3 #include "pirpanelselectionform.h"
5 #include "forms/pirmainform.h"
6 #include "forms/piraltmainform.h"
7 #include "forms/pirutilityform.h"
8 #include "forms/pirkeypadform.h"
9 #include "forms/pirmenuform.h"
10 #include "forms/pirmediaform.h"
11 #include "forms/pirmedia2form.h"
12 #include "forms/pirrecordform.h"
13 #include "forms/pirtvform.h"
14 #include "forms/pirinputform.h"
15 #include "forms/piradjustform.h"
16 #include "forms/pirairconditionerform.h"
17 #include "forms/pirfavoritesform.h"
19 #include "mainwindow.h"
24 //#include <QMaemo5InformationBox>
27 PIRPanelManager::PIRPanelManager(MainWindow *mw)
41 altMainPanelFlag(false),
44 // Set up the panel names:
45 shortPanelNames[Main_Panel] = "Main";
46 longPanelNames[Main_Panel] =
47 "Main Panel - power, volume, and channel controls";
48 shortPanelNames[Utility_Panel] = "Utility";
49 longPanelNames[Utility_Panel] =
50 "Utility Panel - commonly used controls";
51 shortPanelNames[Keypad_Panel] = "Keypad";
52 longPanelNames[Keypad_Panel] =
53 "Keypad Panel - numeric value entry";
54 shortPanelNames[Menu_Panel] = "Menu";
55 longPanelNames[Menu_Panel] =
56 "Menu Panel - enter, exit, and navigate menus";
57 shortPanelNames[Media_Panel] = "Media";
58 longPanelNames[Media_Panel] =
59 "Media Panel - control over recorded data";
60 shortPanelNames[Media2_Panel] = "Media2";
61 longPanelNames[Media2_Panel] =
62 "Media2 Panel - additonal media controls";
63 shortPanelNames[Record_Panel] = "Record";
64 longPanelNames[Record_Panel] =
65 "Program/Record Panel - control over memory and storage";
66 shortPanelNames[TV_Panel] = "TV";
67 longPanelNames[TV_Panel] =
68 "TV Panel - teletext and picture-in-picture";
69 shortPanelNames[Input_Panel] = "Input";
70 longPanelNames[Input_Panel] =
71 "Input Panel - manage data sources";
72 shortPanelNames[Adjust_Panel] = "Adjust";
73 longPanelNames[Adjust_Panel] =
74 "Adjust Panel - modify audio and video";
75 shortPanelNames[AC_Panel] = "AC";
76 longPanelNames[AC_Panel] =
77 "A/C Panel - air conditioner controls";
78 shortPanelNames[Favorites_Panel] = "Favorites";
79 longPanelNames[Favorites_Panel] =
80 "Favorites Panel - memorized keysets";
82 activePanels[Main_Panel] = false;
83 activePanels[Utility_Panel]= false;
84 activePanels[Keypad_Panel]= false;
85 activePanels[Menu_Panel]= false;
86 activePanels[Media_Panel]= false;
87 activePanels[Media2_Panel]= false;
88 activePanels[Record_Panel]= false;
89 activePanels[TV_Panel]= false;
90 activePanels[Input_Panel]= false;
91 activePanels[Adjust_Panel]= false;
92 activePanels[AC_Panel]= false;
93 activePanels[Favorites_Panel]= false;
97 PIRPanelManager::~PIRPanelManager()
99 // Note! We are _not_ deleting the panel forms here, because the Qt GUI
100 // has ownership over some of them. Moreover, the Panel Manager is not
101 // currently designed to be destroyed until the program ends. Should the
102 // manager need to be destroyed earlier, this destructor will need to be
107 void PIRPanelManager::setupPanels(
108 PIRPanelSelectionForm *psf)
110 QSettings settings("pietrzak.org", "Pierogi");
112 settings.beginGroup("Panels");
114 // Do the panel settings exist? (We'll check for "Main_Panel".)
115 if (!settings.contains(shortPanelNames[Main_Panel]))
117 // A default set of panels:
118 psf->setCheckBox(Main_Panel, true);
119 psf->setCheckBox(Utility_Panel, true);
120 psf->setCheckBox(Keypad_Panel, true);
121 psf->setCheckBox(Menu_Panel, true);
122 psf->setCheckBox(Media_Panel, true);
123 psf->setCheckBox(Favorites_Panel, true);
129 settings.value(shortPanelNames[Main_Panel]).toBool());
131 if (settings.contains(shortPanelNames[Utility_Panel]))
135 settings.value(shortPanelNames[Utility_Panel]).toBool());
138 if (settings.contains(shortPanelNames[Keypad_Panel]))
142 settings.value(shortPanelNames[Keypad_Panel]).toBool());
145 if (settings.contains(shortPanelNames[Menu_Panel]))
149 settings.value(shortPanelNames[Menu_Panel]).toBool());
152 if (settings.contains(shortPanelNames[Media_Panel]))
156 settings.value(shortPanelNames[Media_Panel]).toBool());
159 if (settings.contains(shortPanelNames[Media2_Panel]))
163 settings.value(shortPanelNames[Media2_Panel]).toBool());
166 if (settings.contains(shortPanelNames[Record_Panel]))
170 settings.value(shortPanelNames[Record_Panel]).toBool());
173 if (settings.contains(shortPanelNames[TV_Panel]))
177 settings.value(shortPanelNames[TV_Panel]).toBool());
180 if (settings.contains(shortPanelNames[Input_Panel]))
184 settings.value(shortPanelNames[Input_Panel]).toBool());
187 if (settings.contains(shortPanelNames[Adjust_Panel]))
191 settings.value(shortPanelNames[Adjust_Panel]).toBool());
194 if (settings.contains(shortPanelNames[AC_Panel]))
198 settings.value(shortPanelNames[AC_Panel]).toBool());
201 if (settings.contains(shortPanelNames[Favorites_Panel]))
205 settings.value(shortPanelNames[Favorites_Panel]).toBool());
213 void PIRPanelManager::enableButtons(
214 const PIRKeysetManager *keyset,
217 if (altMainPanelFlag)
219 if (altMainForm) altMainForm->enableButtons(keyset, id);
223 if (mainForm) mainForm->enableButtons(keyset, id);
225 if (utilityForm) utilityForm->enableButtons(keyset, id);
226 if (keypadForm) keypadForm->enableButtons(keyset, id);
227 if (menuForm) menuForm->enableButtons(keyset, id);
228 if (mediaForm) mediaForm->enableButtons(keyset, id);
229 if (media2Form) media2Form->enableButtons(keyset, id);
230 if (recordForm) recordForm->enableButtons(keyset, id);
231 if (tvForm) tvForm->enableButtons(keyset, id);
232 if (inputForm) inputForm->enableButtons(keyset, id);
233 if (adjustForm) adjustForm->enableButtons(keyset, id);
234 if (acForm) acForm->enableButtons(keyset, id);
238 void PIRPanelManager::managePanel(
242 int currentPanel = 0;
243 int displayCount = 0;
245 // PIRPanelList::iterator i = panelList.begin();
246 while (currentPanel < Last_Panel_Marker)
248 if (currentPanel == name)
252 else if (activePanels[PIRPanelName(currentPanel)])
260 if (currentPanel == Last_Panel_Marker)
262 // should throw an error message here!!!
266 QSettings settings("pietrzak.org", "Pierogi");
268 settings.beginGroup("Panels");
270 if (state == Qt::Unchecked && activePanels[PIRPanelName(currentPanel)])
272 hidePanel(name, displayCount);
273 activePanels[PIRPanelName(currentPanel)] = false;
274 settings.setValue(shortPanelNames[PIRPanelName(currentPanel)], false);
276 else if (state == Qt::Checked && !activePanels[PIRPanelName(currentPanel)])
278 showPanel(name, displayCount);
279 activePanels[PIRPanelName(currentPanel)] = true;
280 settings.setValue(shortPanelNames[PIRPanelName(currentPanel)], true);
287 void PIRPanelManager::useMainPanel()
289 if (!altMainPanelFlag)
291 // Already set correctly, nothing to do:
295 altMainPanelFlag = false;
297 // Is the main panel currently active?
298 if (activePanels[Main_Panel])
300 mainWindow->removePanel(0, altMainForm);
303 mainForm = new PIRMainForm(mainWindow);
306 mainWindow->insertPanel(0, mainForm, longPanelNames[Main_Panel]);
307 mainWindow->selectPanel(0);
310 mainWindow->enableButtons();
314 void PIRPanelManager::useAltMainPanel()
316 if (altMainPanelFlag)
318 // Already set correctly, nothing to do:
322 altMainPanelFlag = true;
324 // Is the main panel currently active?
325 if (activePanels[Main_Panel])
327 mainWindow->removePanel(0, mainForm);
330 altMainForm = new PIRAltMainForm(mainWindow);
333 mainWindow->insertPanel(0, altMainForm, longPanelNames[Main_Panel]);
334 mainWindow->selectPanel(0);
337 mainWindow->enableButtons();
341 void PIRPanelManager::hidePanel(
348 if (altMainPanelFlag)
350 if (altMainForm) mainWindow->removePanel(index, altMainForm);
354 if (mainForm) mainWindow->removePanel(index, mainForm);
359 if (utilityForm) mainWindow->removePanel(index, utilityForm);
363 if (keypadForm) mainWindow->removePanel(index, keypadForm);
367 if (menuForm) mainWindow->removePanel(index, menuForm);
371 if (mediaForm) mainWindow->removePanel(index, mediaForm);
375 if (media2Form) mainWindow->removePanel(index, media2Form);
379 if (recordForm) mainWindow->removePanel(index, recordForm);
383 if (tvForm) mainWindow->removePanel(index, tvForm);
387 if (inputForm) mainWindow->removePanel(index, inputForm);
391 if (adjustForm) mainWindow->removePanel(index, adjustForm);
395 if (acForm) mainWindow->removePanel(index, acForm);
398 case Favorites_Panel:
399 if (favoritesForm) mainWindow->removePanel(index, favoritesForm);
409 void PIRPanelManager::showPanel(
416 if (altMainPanelFlag)
420 altMainForm = new PIRAltMainForm(mainWindow);
421 mainWindow->enableButtons();
424 mainWindow->insertPanel(
427 longPanelNames[Main_Panel]);
433 mainForm = new PIRMainForm(mainWindow);
434 mainWindow->enableButtons();
437 mainWindow->insertPanel(
440 longPanelNames[Main_Panel]);
448 utilityForm = new PIRUtilityForm(mainWindow);
449 mainWindow->enableButtons();
452 mainWindow->insertPanel(
455 longPanelNames[Utility_Panel]);
462 keypadForm = new PIRKeypadForm(mainWindow);
463 mainWindow->enableButtons();
466 mainWindow->insertPanel(
469 longPanelNames[Keypad_Panel]);
476 menuForm = new PIRMenuForm(mainWindow);
477 mainWindow->enableButtons();
480 mainWindow->insertPanel(
483 longPanelNames[Menu_Panel]);
490 mediaForm = new PIRMediaForm(mainWindow);
491 mainWindow->enableButtons();
494 mainWindow->insertPanel(
497 longPanelNames[Media_Panel]);
504 media2Form = new PIRMedia2Form(mainWindow);
505 mainWindow->enableButtons();
508 mainWindow->insertPanel(
511 longPanelNames[Media2_Panel]);
518 recordForm = new PIRRecordForm(mainWindow);
519 mainWindow->enableButtons();
522 mainWindow->insertPanel(
525 longPanelNames[Record_Panel]);
532 tvForm = new PIRTVForm(mainWindow);
533 mainWindow->enableButtons();
536 mainWindow->insertPanel(
539 longPanelNames[TV_Panel]);
546 inputForm = new PIRInputForm(mainWindow);
547 mainWindow->enableButtons();
550 mainWindow->insertPanel(
553 longPanelNames[Input_Panel]);
560 adjustForm = new PIRAdjustForm(mainWindow);
561 mainWindow->enableButtons();
564 mainWindow->insertPanel(
567 longPanelNames[Adjust_Panel]);
574 acForm = new PIRAirConditionerForm(mainWindow);
575 mainWindow->enableButtons();
578 mainWindow->insertPanel(
581 longPanelNames[AC_Panel]);
585 case Favorites_Panel:
588 favoritesForm = new PIRFavoritesForm(mainWindow);
589 mainWindow->enableButtons();
592 mainWindow->insertPanel(
595 longPanelNames[Favorites_Panel]);
605 void PIRPanelManager::selectPrevFavKeyset()
607 // If the favorites form doesn't exist, no need to continue:
608 if (!favoritesForm) return;
610 favoritesForm->selectPrevFavKeyset();
614 void PIRPanelManager::selectNextFavKeyset()
616 // If the favorites form doesn't exist, no need to continue:
617 if (!favoritesForm) return;
619 favoritesForm->selectNextFavKeyset();
623 void PIRPanelManager::addFavoritesItem(
624 PIRKeysetWidgetItem *item)
628 favoritesForm = new PIRFavoritesForm(mainWindow);
631 favoritesForm->addItem(item);
635 QListWidget *PIRPanelManager::getFavoritesListWidget()
639 favoritesForm = new PIRFavoritesForm(mainWindow);
642 return favoritesForm->getFavoritesListWidget();