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);
226 commonEnableButtons(keyset, id);
230 void PIRPanelManager::enableButtons(
231 const PIRKeysetManager *keyset,
232 unsigned int currentID,
233 unsigned int defaultID)
235 if (altMainPanelFlag)
237 if (altMainForm) altMainForm->enableButtons(keyset, currentID, defaultID);
241 if (mainForm) mainForm->enableButtons(keyset, currentID, defaultID);
244 commonEnableButtons(keyset, currentID);
248 void PIRPanelManager::commonEnableButtons(
249 const PIRKeysetManager *keyset,
252 if (utilityForm) utilityForm->enableButtons(keyset, id);
253 if (keypadForm) keypadForm->enableButtons(keyset, id);
254 if (menuForm) menuForm->enableButtons(keyset, id);
255 if (mediaForm) mediaForm->enableButtons(keyset, id);
256 if (media2Form) media2Form->enableButtons(keyset, id);
257 if (recordForm) recordForm->enableButtons(keyset, id);
258 if (tvForm) tvForm->enableButtons(keyset, id);
259 if (inputForm) inputForm->enableButtons(keyset, id);
260 if (adjustForm) adjustForm->enableButtons(keyset, id);
261 if (acForm) acForm->enableButtons(keyset, id);
265 void PIRPanelManager::managePanel(
269 int currentPanel = 0;
270 int displayCount = 0;
272 // PIRPanelList::iterator i = panelList.begin();
273 while (currentPanel < Last_Panel_Marker)
275 if (currentPanel == name)
279 else if (activePanels[PIRPanelName(currentPanel)])
287 if (currentPanel == Last_Panel_Marker)
289 // should throw an error message here!!!
293 QSettings settings("pietrzak.org", "Pierogi");
295 settings.beginGroup("Panels");
297 if (state == Qt::Unchecked && activePanels[PIRPanelName(currentPanel)])
299 hidePanel(name, displayCount);
300 activePanels[PIRPanelName(currentPanel)] = false;
301 settings.setValue(shortPanelNames[PIRPanelName(currentPanel)], false);
303 else if (state == Qt::Checked && !activePanels[PIRPanelName(currentPanel)])
305 showPanel(name, displayCount);
306 activePanels[PIRPanelName(currentPanel)] = true;
307 settings.setValue(shortPanelNames[PIRPanelName(currentPanel)], true);
314 void PIRPanelManager::useMainPanel()
316 if (!altMainPanelFlag)
318 // Already set correctly, nothing to do:
322 altMainPanelFlag = false;
324 // Is the main panel currently active?
325 if (activePanels[Main_Panel])
327 mainWindow->removePanel(0, altMainForm);
330 mainForm = new PIRMainForm(mainWindow);
333 mainWindow->insertPanel(0, mainForm, longPanelNames[Main_Panel]);
334 mainWindow->selectPanel(0);
337 mainWindow->enableButtons();
341 void PIRPanelManager::useAltMainPanel()
343 if (altMainPanelFlag)
345 // Already set correctly, nothing to do:
349 altMainPanelFlag = true;
351 // Is the main panel currently active?
352 if (activePanels[Main_Panel])
354 mainWindow->removePanel(0, mainForm);
357 altMainForm = new PIRAltMainForm(mainWindow);
360 mainWindow->insertPanel(0, altMainForm, longPanelNames[Main_Panel]);
361 mainWindow->selectPanel(0);
364 mainWindow->enableButtons();
368 void PIRPanelManager::hidePanel(
375 if (altMainPanelFlag)
377 if (altMainForm) mainWindow->removePanel(index, altMainForm);
381 if (mainForm) mainWindow->removePanel(index, mainForm);
386 if (utilityForm) mainWindow->removePanel(index, utilityForm);
390 if (keypadForm) mainWindow->removePanel(index, keypadForm);
394 if (menuForm) mainWindow->removePanel(index, menuForm);
398 if (mediaForm) mainWindow->removePanel(index, mediaForm);
402 if (media2Form) mainWindow->removePanel(index, media2Form);
406 if (recordForm) mainWindow->removePanel(index, recordForm);
410 if (tvForm) mainWindow->removePanel(index, tvForm);
414 if (inputForm) mainWindow->removePanel(index, inputForm);
418 if (adjustForm) mainWindow->removePanel(index, adjustForm);
422 if (acForm) mainWindow->removePanel(index, acForm);
425 case Favorites_Panel:
426 if (favoritesForm) mainWindow->removePanel(index, favoritesForm);
436 void PIRPanelManager::showPanel(
443 if (altMainPanelFlag)
447 altMainForm = new PIRAltMainForm(mainWindow);
448 mainWindow->enableButtons();
451 mainWindow->insertPanel(
454 longPanelNames[Main_Panel]);
460 mainForm = new PIRMainForm(mainWindow);
461 mainWindow->enableButtons();
464 mainWindow->insertPanel(
467 longPanelNames[Main_Panel]);
475 utilityForm = new PIRUtilityForm(mainWindow);
476 mainWindow->enableButtons();
479 mainWindow->insertPanel(
482 longPanelNames[Utility_Panel]);
489 keypadForm = new PIRKeypadForm(mainWindow);
490 mainWindow->enableButtons();
493 mainWindow->insertPanel(
496 longPanelNames[Keypad_Panel]);
503 menuForm = new PIRMenuForm(mainWindow);
504 mainWindow->enableButtons();
507 mainWindow->insertPanel(
510 longPanelNames[Menu_Panel]);
517 mediaForm = new PIRMediaForm(mainWindow);
518 mainWindow->enableButtons();
521 mainWindow->insertPanel(
524 longPanelNames[Media_Panel]);
531 media2Form = new PIRMedia2Form(mainWindow);
532 mainWindow->enableButtons();
535 mainWindow->insertPanel(
538 longPanelNames[Media2_Panel]);
545 recordForm = new PIRRecordForm(mainWindow);
546 mainWindow->enableButtons();
549 mainWindow->insertPanel(
552 longPanelNames[Record_Panel]);
559 tvForm = new PIRTVForm(mainWindow);
560 mainWindow->enableButtons();
563 mainWindow->insertPanel(
566 longPanelNames[TV_Panel]);
573 inputForm = new PIRInputForm(mainWindow);
574 mainWindow->enableButtons();
577 mainWindow->insertPanel(
580 longPanelNames[Input_Panel]);
587 adjustForm = new PIRAdjustForm(mainWindow);
588 mainWindow->enableButtons();
591 mainWindow->insertPanel(
594 longPanelNames[Adjust_Panel]);
601 acForm = new PIRAirConditionerForm(mainWindow);
602 mainWindow->enableButtons();
605 mainWindow->insertPanel(
608 longPanelNames[AC_Panel]);
612 case Favorites_Panel:
615 favoritesForm = new PIRFavoritesForm(mainWindow);
616 mainWindow->enableButtons();
619 mainWindow->insertPanel(
622 longPanelNames[Favorites_Panel]);
632 void PIRPanelManager::selectPrevFavKeyset()
634 // If the favorites form doesn't exist, no need to continue:
635 if (!favoritesForm) return;
637 favoritesForm->selectPrevFavKeyset();
641 void PIRPanelManager::selectNextFavKeyset()
643 // If the favorites form doesn't exist, no need to continue:
644 if (!favoritesForm) return;
646 favoritesForm->selectNextFavKeyset();
650 void PIRPanelManager::addFavoritesItem(
651 PIRKeysetWidgetItem *item)
655 favoritesForm = new PIRFavoritesForm(mainWindow);
658 favoritesForm->addItem(item);
662 QListWidget *PIRPanelManager::getFavoritesListWidget()
666 favoritesForm = new PIRFavoritesForm(mainWindow);
669 return favoritesForm->getFavoritesListWidget();