Log In
New Account
  
Home My Page Project Cloud Code Snippets Project Openings Pierogi
Summary Forums Tracker Lists Tasks Docs News SCM Files
1 #include "mainwindow.h"
2 #include "ui_mainwindow.h"
3 #include "pirkeysetwidgetitem.h"
5 //#include "pirexception.h"
7 #include <QtCore/QCoreApplication>
8 #include <QMutex>
9 #include <QtGui/QMessageBox>
10 #include <QSettings>
11 //#include <QDesktopServices>
12 //#include <QUrl>
14 //#include <iostream>
16 //#define DEBUGGING
18 // Some ugly globals used for thread communications:
20 // A global to show that a command is being processed:
21 bool commandInFlight = false;
22 QMutex commandIFMutex;
24 // The stopRepeatingFlag boolean is the method used to tell running commands
25 // in the worker thread to stop:
26 bool stopRepeatingFlag = false;
27 QMutex stopRepeatingMutex;
29 extern PIRMakeMgr makeManager;
32 MainWindow::MainWindow(QWidget *parent)
33   : QMainWindow(parent),
34     ui(new Ui::MainWindow),
35     selectKeysetForm(0),
36     secondaryForm(0),
37     documentationForm(0),
38     aboutForm(0),
39     currentKeyset(0)
40 {
41   ui->setupUi(this);
43   // Make this a Maemo 5 stacked widget:
44   setAttribute(Qt::WA_Maemo5StackedWindow);
46   // Collect the keysets:
47   myKeysets = new PIRKeysetManager(this);
49   // Set up the keyset selection window:
50   selectKeysetForm = new PIRSelectKeysetForm(this);
52   // Set up the secondary buttons window:
53   secondaryForm = new PIRSecondaryForm(this);
55   myKeysets->populateGuiWidget(selectKeysetForm);
57   // Remember any favorites the user has already set:
58   populateFavorites();
60   QSettings settings("pietrzak.org", "Pierogi");
61   if (settings.contains("currentKeysetName"))
62   {
63     myKeysets->findKeysetID(
64       settings.value("currentKeysetMake").toString(),
65       settings.value("currentKeysetName").toString(),
66       currentKeyset);
67 //    currentKeyset = settings.value("currentKeyset").toInt();
68   }
70   enableButtons();
71   secondaryForm->enableButtons(myKeysets, currentKeyset);
73   connect(
74     ui->favoriteKeysetsWidget,
75 //    SIGNAL(itemActivated(QListWidgetItem *)),
76     SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
77     this,
78     SLOT(keysetSelectionChanged(QListWidgetItem *)),
79     Qt::QueuedConnection);
81   // Make sure the two selection lists don't show different selections:
82   QListWidget *klw = selectKeysetForm->getKeysetListWidget();
83   connect(
84     ui->favoriteKeysetsWidget,
85     SIGNAL(itemActivated(QListWidgetItem *)),
86     klw,
87     SLOT(clearSelection()),
88     Qt::QueuedConnection);
90   connect(
91     klw,
92     SIGNAL(itemActivated(QListWidgetItem *)),
93     ui->favoriteKeysetsWidget,
94     SLOT(clearSelection()),
95     Qt::QueuedConnection);
97 #ifndef DEBUGGING
98   // The PIRModprobe object should take care of setting up and shutting down
99   // the lirc_rx51 kernel module, if necessary:
100  
101   if (modprobeObj.loadRX51Module() != 0)
102   {
103     // Couldn't load module, quit:
104     QMessageBox errBox;
105     errBox.setText("Couldn't load lirc_rx51 kernel module!");
106     errBox.setIcon(QMessageBox::Warning);
107     errBox.exec();
108 //    throw; // Need a clean way to exit here!!!
109   }
110 #endif
114 MainWindow::~MainWindow()
116   delete myKeysets;
117   if (selectKeysetForm) delete selectKeysetForm;
118   if (documentationForm) delete documentationForm;
119   if (aboutForm) delete aboutForm;
120   delete ui;
124 void MainWindow::setOrientation(ScreenOrientation orientation)
126 #if defined(Q_OS_SYMBIAN)
127     // If the version of Qt on the device is < 4.7.2, that attribute won't work
128     if (orientation != ScreenOrientationAuto) {
129         const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.'));
130         if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) {
131             qWarning("Screen orientation locking only supported with Qt 4.7.2 and above");
132             return;
133         }
134     }
135 #endif // Q_OS_SYMBIAN
137     Qt::WidgetAttribute attribute;
138     switch (orientation) {
139 #if QT_VERSION < 0x040702
140     // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes
141     case ScreenOrientationLockPortrait:
142         attribute = static_cast<Qt::WidgetAttribute>(128);
143         break;
144     case ScreenOrientationLockLandscape:
145         attribute = static_cast<Qt::WidgetAttribute>(129);
146         break;
147     default:
148     case ScreenOrientationAuto:
149         attribute = static_cast<Qt::WidgetAttribute>(130);
150         break;
151 #else // QT_VERSION < 0x040702
152     case ScreenOrientationLockPortrait:
153         attribute = Qt::WA_LockPortraitOrientation;
154         break;
155     case ScreenOrientationLockLandscape:
156         attribute = Qt::WA_LockLandscapeOrientation;
157         break;
158     default:
159     case ScreenOrientationAuto:
160         attribute = Qt::WA_AutoOrientation;
161         break;
162 #endif // QT_VERSION < 0x040702
163     };
164     setAttribute(attribute, true);
167 void MainWindow::showExpanded()
169 #if defined(Q_OS_SYMBIAN) || defined(Q_WS_SIMULATOR)
170     showFullScreen();
171 #elif defined(Q_WS_MAEMO_5)
172     showMaximized();
173 #else
174     show();
175 #endif
179 void MainWindow::enableButtons()
181   // This is going to be a little painful...
182   // Main keys
183   emit powerEnabled(myKeysets->hasKey(currentKeyset, Power_Key));
184   emit volumeUpEnabled(myKeysets->hasKey(currentKeyset, VolumeUp_Key));
185   emit volumeDownEnabled(myKeysets->hasKey(currentKeyset, VolumeDown_Key));
186   emit channelUpEnabled(myKeysets->hasKey(currentKeyset, ChannelUp_Key));
187   emit channelDownEnabled(myKeysets->hasKey(currentKeyset, ChannelDown_Key));
189   // Main tab labels:
190   emit keysetMakeChanged(
191     makeManager.getMakeString(myKeysets->getMake(currentKeyset)));
192   emit keysetNameChanged(myKeysets->getDisplayName(currentKeyset));
194   // Utility keys:
195   emit redEnabled(myKeysets->hasKey(currentKeyset, Red_Key));
196   emit greenEnabled(myKeysets->hasKey(currentKeyset, Green_Key));
197   emit yellowEnabled(myKeysets->hasKey(currentKeyset, Yellow_Key));
198   emit blueEnabled(myKeysets->hasKey(currentKeyset, Blue_Key));
199   emit aspectRatioEnabled(myKeysets->hasKey(currentKeyset, AspectRatio_Key));
200   emit surroundEnabled(myKeysets->hasKey(currentKeyset, Surround_Key));
201   emit audioEnabled(myKeysets->hasKey(currentKeyset, Audio_Key));
202   emit infoEnabled(myKeysets->hasKey(currentKeyset, Info_Key));
203   emit captionsEnabled(myKeysets->hasKey(currentKeyset, Captions_Key));
204   emit sleepEnabled(myKeysets->hasKey(currentKeyset, Sleep_Key));
205   emit inputEnabled(myKeysets->hasKey(currentKeyset, Input_Key));
206   emit muteEnabled(myKeysets->hasKey(currentKeyset, Mute_Key));
208   // Keypad keys
209   emit zeroEnabled(myKeysets->hasKey(currentKeyset, Zero_Key));
210   emit oneEnabled(myKeysets->hasKey(currentKeyset, One_Key));
211   emit twoEnabled(myKeysets->hasKey(currentKeyset, Two_Key));
212   emit threeEnabled(myKeysets->hasKey(currentKeyset, Three_Key));
213   emit fourEnabled(myKeysets->hasKey(currentKeyset, Four_Key));
214   emit fiveEnabled(myKeysets->hasKey(currentKeyset, Five_Key));
215   emit sixEnabled(myKeysets->hasKey(currentKeyset, Six_Key));
216   emit sevenEnabled(myKeysets->hasKey(currentKeyset, Seven_Key));
217   emit eightEnabled(myKeysets->hasKey(currentKeyset, Eight_Key));
218   emit nineEnabled(myKeysets->hasKey(currentKeyset, Nine_Key));
219   emit enterEnabled(myKeysets->hasKey(currentKeyset, Enter_Key));
220   emit clearEnabled(myKeysets->hasKey(currentKeyset, Clear_Key));
221   emit dashEnabled(myKeysets->hasKey(currentKeyset, Dash_Key));
222   emit plusOneHundredEnabled(myKeysets->hasKey(currentKeyset, PlusOneHundred_Key));
223   emit doubleDigitEnabled(myKeysets->hasKey(currentKeyset, DoubleDigit_Key));
224   emit prevChannelEnabled(myKeysets->hasKey(currentKeyset, PrevChannel_Key));
226   // Menu keys:
227   emit upEnabled(myKeysets->hasKey(currentKeyset, Up_Key));
228   emit downEnabled(myKeysets->hasKey(currentKeyset, Down_Key));
229   emit leftEnabled(myKeysets->hasKey(currentKeyset, Left_Key));
230   emit rightEnabled(myKeysets->hasKey(currentKeyset, Right_Key));
231   emit selectEnabled(myKeysets->hasKey(currentKeyset, Select_Key));
232   emit menuEnabled(myKeysets->hasKey(currentKeyset, Menu_Key));
233   emit exitEnabled(myKeysets->hasKey(currentKeyset, Exit_Key));
234   emit guideEnabled(myKeysets->hasKey(currentKeyset, Guide_Key));
235   emit discMenuEnabled(myKeysets->hasKey(currentKeyset, DiscMenu_Key));
237   // Media keys:
238   emit nextEnabled(myKeysets->hasKey(currentKeyset, Next_Key));
239   emit previousEnabled(myKeysets->hasKey(currentKeyset, Previous_Key));
240   emit advanceEnabled(myKeysets->hasKey(currentKeyset, Advance_Key));
241   emit replayEnabled(myKeysets->hasKey(currentKeyset, Replay_Key));
242   emit stepForwardEnabled(myKeysets->hasKey(currentKeyset, StepForward_Key));
243   emit stepBackEnabled(myKeysets->hasKey(currentKeyset, StepBack_Key));
244   emit fastForwardEnabled(myKeysets->hasKey(currentKeyset, FastForward_Key));
245   emit reverseEnabled(myKeysets->hasKey(currentKeyset, Rewind_Key));
246   emit playEnabled(myKeysets->hasKey(currentKeyset, Play_Key));
247   emit pauseEnabled(myKeysets->hasKey(currentKeyset, Pause_Key));
248   emit stopEnabled(myKeysets->hasKey(currentKeyset, Stop_Key));
249   emit ejectEnabled(myKeysets->hasKey(currentKeyset, Eject_Key));
251 /*
252   // Media2 keys:
253   emit discTitleEnabled(myKeysets->hasKey(currentKeyset, DiscTitle_Key));
254   emit discSelectEnabled(myKeysets->hasKey(currentKeyset, NextDisc_Key));
255   emit vhsSpeedEnabled(myKeysets->hasKey(currentKeyset, VHSSpeed_Key));
256   emit trackingMinusEnabled(myKeysets->hasKey(currentKeyset, TrackingMinus_Key));
257   emit trackingPlusEnabled(myKeysets->hasKey(currentKeyset, TrackingPlus_Key));
258   emit autoTrackingEnabled(myKeysets->hasKey(currentKeyset, AutoTracking_Key));
259   emit pageUpEnabled(myKeysets->hasKey(currentKeyset, PageUp_Key));
260   emit pageDownEnabled(myKeysets->hasKey(currentKeyset, PageDown_Key));
261   emit slowEnabled(myKeysets->hasKey(currentKeyset, Slow_Key));
262   emit slowMinusEnabled(myKeysets->hasKey(currentKeyset, SlowMinus_Key));
263   emit slowPlusEnabled(myKeysets->hasKey(currentKeyset, SlowPlus_Key));
264   emit programEnabled(myKeysets->hasKey(currentKeyset, Program_Key));
265   emit tunerBandEnabled(myKeysets->hasKey(currentKeyset, TunerBand_Key));
266   emit repeatEnabled(myKeysets->hasKey(currentKeyset, Repeat_Key));
267   emit repeatABEnabled(myKeysets->hasKey(currentKeyset, RepeatAB_Key));
268   emit randomEnabled(myKeysets->hasKey(currentKeyset, Random_Key));
270   // TV Keys:
271   emit pictureModeEnabled(myKeysets->hasKey(currentKeyset, PictureMode_Key));
272   emit soundModeEnabled(myKeysets->hasKey(currentKeyset, SoundMode_Key));
273   emit liveTVEnabled(myKeysets->hasKey(currentKeyset, LiveTV_Key));
274   emit favoritesEnabled(myKeysets->hasKey(currentKeyset, Favorites_Key));
275   emit teletextEnabled(myKeysets->hasKey(currentKeyset, Teletext_Key));
276   emit teletextHoldEnabled(myKeysets->hasKey(currentKeyset, TeletextHold_Key));
277   emit teletextRevealEnabled(myKeysets->hasKey(currentKeyset, TeletextReveal_Key));
278   emit teletextSizeEnabled(myKeysets->hasKey(currentKeyset, TeletextSize_Key));
279   emit pipEnabled(myKeysets->hasKey(currentKeyset, PIP_Key));
280   emit pipSwapEnabled(myKeysets->hasKey(currentKeyset, PIPSwap_Key));
281   emit pipMoveEnabled(myKeysets->hasKey(currentKeyset, PIPMove_Key));
282   emit pipSourceEnabled(myKeysets->hasKey(currentKeyset, PIPSource_Key));
283   emit pipChannelUpEnabled(myKeysets->hasKey(currentKeyset, PIPChannelUp_Key));
284   emit pipChannelDownEnabled(myKeysets->hasKey(currentKeyset, PIPChannelDown_Key));
285   emit pipPauseEnabled(myKeysets->hasKey(currentKeyset, PIPPause_Key));
286   emit pipSizeEnabled(myKeysets->hasKey(currentKeyset, PIPSize_Key));
287 */
291 void MainWindow::receivedExternalWarning(
292   const char *warning)
294   QMessageBox errBox;
295   errBox.setText(warning);
296   errBox.setIcon(QMessageBox::Warning);
297   errBox.exec();
301 // Main tab buttons:
303 void MainWindow::on_powerButton_pressed()
305   startRepeating(Power_Key);
308 void MainWindow::on_powerButton_released()
310   stopRepeating();
313 void MainWindow::on_mainChannelUpButton_pressed()
315   startRepeating(ChannelUp_Key);
318 void MainWindow::on_mainChannelUpButton_released()
320   stopRepeating();
323 void MainWindow::on_mainChannelDownButton_pressed()
325   startRepeating(ChannelDown_Key);
328 void MainWindow::on_mainChannelDownButton_released()
330   stopRepeating();
333 void MainWindow::on_mainVolumeUp_pressed()
335   startRepeating(VolumeUp_Key);
338 void MainWindow::on_mainVolumeUp_released()
340   stopRepeating();
343 void MainWindow::on_mainVolumeDownButton_pressed()
345   startRepeating(VolumeDown_Key);
348 void MainWindow::on_mainVolumeDownButton_released()
350   stopRepeating();
354 // Utility tab buttons:
356 void MainWindow::on_redButton_pressed()
358   startRepeating(Red_Key);
361 void MainWindow::on_redButton_released()
363   stopRepeating();
366 void MainWindow::on_greenButton_pressed()
368   startRepeating(Green_Key);
371 void MainWindow::on_greenButton_released()
373   stopRepeating();
376 void MainWindow::on_yellowButton_pressed()
378   startRepeating(Yellow_Key);
381 void MainWindow::on_yellowButton_released()
383   stopRepeating();
386 void MainWindow::on_blueButton_pressed()
388   startRepeating(Blue_Key);
391 void MainWindow::on_blueButton_released()
393   stopRepeating();
396 void MainWindow::on_aspectRatioButton_pressed()
398   startRepeating(AspectRatio_Key);
401 void MainWindow::on_aspectRatioButton_released()
403   stopRepeating();
406 void MainWindow::on_surroundButton_pressed()
408   startRepeating(Surround_Key);
411 void MainWindow::on_surroundButton_released()
413   stopRepeating();
416 void MainWindow::on_audioButton_pressed()
418   startRepeating(Audio_Key);
421 void MainWindow::on_audioButton_released()
423   stopRepeating();
426 void MainWindow::on_infoButton_pressed()
428   startRepeating(Info_Key);
431 void MainWindow::on_infoButton_released()
433   stopRepeating();
436 void MainWindow::on_captionButton_pressed()
438   startRepeating(Captions_Key);
441 void MainWindow::on_captionButton_released()
443   stopRepeating();
446 void MainWindow::on_inputButton_pressed()
448   startRepeating(Input_Key);
451 void MainWindow::on_inputButton_released()
453   stopRepeating();
456 void MainWindow::on_sleepButton_pressed()
458   startRepeating(Sleep_Key);
461 void MainWindow::on_sleepButton_released()
463   stopRepeating();
466 void MainWindow::on_muteButton_pressed()
468   startRepeating(Mute_Key);
471 void MainWindow::on_muteButton_released()
473   stopRepeating();
477 // Keypad tab buttons:
479 void MainWindow::on_oneButton_pressed()
481   startRepeating(One_Key);
484 void MainWindow::on_oneButton_released()
486   stopRepeating();
489 void MainWindow::on_twoButton_pressed()
491   startRepeating(Two_Key);
494 void MainWindow::on_twoButton_released()
496   stopRepeating();
499 void MainWindow::on_threeButton_pressed()
501   startRepeating(Three_Key);
504 void MainWindow::on_threeButton_released()
506   stopRepeating();
509 void MainWindow::on_fourButton_pressed()
511   startRepeating(Four_Key);
514 void MainWindow::on_fourButton_released()
516   stopRepeating();
519 void MainWindow::on_fiveButton_pressed()
521   startRepeating(Five_Key);
524 void MainWindow::on_fiveButton_released()
526   stopRepeating();
529 void MainWindow::on_sixButton_pressed()
531   startRepeating(Six_Key);
534 void MainWindow::on_sixButton_released()
536   stopRepeating();
539 void MainWindow::on_sevenButton_pressed()
541   startRepeating(Seven_Key);
544 void MainWindow::on_sevenButton_released()
546   stopRepeating();
549 void MainWindow::on_eightButton_pressed()
551   startRepeating(Eight_Key);
554 void MainWindow::on_eightButton_released()
556   stopRepeating();
559 void MainWindow::on_nineButton_pressed()
561   startRepeating(Nine_Key);
564 void MainWindow::on_nineButton_released()
566   stopRepeating();
569 void MainWindow::on_zeroButton_pressed()
571   startRepeating(Zero_Key);
574 void MainWindow::on_zeroButton_released()
576   stopRepeating();
579 void MainWindow::on_enterButton_pressed()
581   startRepeating(Enter_Key);
584 void MainWindow::on_enterButton_released()
586   stopRepeating();
589 void MainWindow::on_clearButton_pressed()
591   startRepeating(Clear_Key);
594 void MainWindow::on_clearButton_released()
596   stopRepeating();
599 void MainWindow::on_prevChannelButton_pressed()
601   startRepeating(PrevChannel_Key);
604 void MainWindow::on_prevChannelButton_released()
606   stopRepeating();
609 void MainWindow::on_plusOneHundredButton_pressed()
611   startRepeating(PlusOneHundred_Key);
614 void MainWindow::on_plusOneHundredButton_released()
616   stopRepeating();
619 void MainWindow::on_dashButton_pressed()
621   startRepeating(Dash_Key);
624 void MainWindow::on_dashButton_released()
626   stopRepeating();
629 void MainWindow::on_doubleDigitButton_pressed()
631   startRepeating(DoubleDigit_Key);
634 void MainWindow::on_doubleDigitButton_released()
636   stopRepeating();
640 // Menu tab buttons:
642 void MainWindow::on_upButton_pressed()
644   startRepeating(Up_Key);
647 void MainWindow::on_upButton_released()
649   stopRepeating();
652 void MainWindow::on_leftButton_pressed()
654   startRepeating(Left_Key);
657 void MainWindow::on_leftButton_released()
659   stopRepeating();
662 void MainWindow::on_rightButton_pressed()
664   startRepeating(Right_Key);
667 void MainWindow::on_rightButton_released()
669   stopRepeating();
672 void MainWindow::on_downButton_pressed()
674   startRepeating(Down_Key);
677 void MainWindow::on_downButton_released()
679   stopRepeating();
682 void MainWindow::on_selectButton_pressed()
684   startRepeating(Select_Key);
687 void MainWindow::on_selectButton_released()
689   stopRepeating();
692 void MainWindow::on_menuButton_pressed()
694   startRepeating(Menu_Key);
697 void MainWindow::on_menuButton_released()
699   stopRepeating();
702 void MainWindow::on_exitButton_pressed()
704   startRepeating(Exit_Key);
707 void MainWindow::on_exitButton_released()
709   stopRepeating();
712 void MainWindow::on_guideButton_pressed()
714   startRepeating(Guide_Key);
717 void MainWindow::on_guideButton_released()
719   stopRepeating();
722 void MainWindow::on_discMenuButton_pressed()
724   startRepeating(DiscMenu_Key);
727 void MainWindow::on_discMenuButton_released()
729   stopRepeating();
733 // Media tab buttons:
735 void MainWindow::on_mediaPreviousButton_pressed()
737   startRepeating(Previous_Key);
740 void MainWindow::on_mediaPreviousButton_released()
742   stopRepeating();
745 void MainWindow::on_mediaNextButton_pressed()
747   startRepeating(Next_Key);
750 void MainWindow::on_mediaNextButton_released()
752   stopRepeating();
755 void MainWindow::on_replayButton_pressed()
757   startRepeating(Replay_Key);
760 void MainWindow::on_replayButton_released()
762   stopRepeating();
765 void MainWindow::on_advanceButton_pressed()
767   startRepeating(Advance_Key);
770 void MainWindow::on_advanceButton_released()
772   stopRepeating();
775 void MainWindow::on_stepBackButton_pressed()
777   startRepeating(StepBack_Key);
780 void MainWindow::on_stepBackButton_released()
782   stopRepeating();
785 void MainWindow::on_stepForwardButton_pressed()
787   startRepeating(StepForward_Key);
790 void MainWindow::on_stepForwardButton_released()
792   stopRepeating();
795 void MainWindow::on_reverseButton_pressed()
797   startRepeating(Rewind_Key);
800 void MainWindow::on_reverseButton_released()
802   stopRepeating();
805 void MainWindow::on_fastForwardButton_pressed()
807   startRepeating(FastForward_Key);
810 void MainWindow::on_fastForwardButton_released()
812   stopRepeating();
815 void MainWindow::on_playButton_pressed()
817   startRepeating(Play_Key);
820 void MainWindow::on_playButton_released()
822   stopRepeating();
825 void MainWindow::on_pauseButton_pressed()
827   startRepeating(Pause_Key);
830 void MainWindow::on_pauseButton_released()
832   stopRepeating();
835 void MainWindow::on_stopButton_pressed()
837   startRepeating(Stop_Key);
840 void MainWindow::on_stopButton_released()
842   stopRepeating();
845 void MainWindow::on_ejectButton_pressed()
847   startRepeating(Eject_Key);
850 void MainWindow::on_ejectButton_released()
852   stopRepeating();
856 /*
857 // Media2 tab slots:
859 void MainWindow::on_discTitleButton_pressed()
861   startRepeating(DiscTitle_Key);
864 void MainWindow::on_discTitleButton_released()
866   stopRepeating();
869 void MainWindow::on_discSelectButton_pressed()
871   startRepeating(NextDisc_Key);
874 void MainWindow::on_discSelectButton_released()
876   stopRepeating();
879 void MainWindow::on_vhsSpeedButton_pressed()
881   startRepeating(VHSSpeed_Key);
884 void MainWindow::on_vhsSpeedButton_released()
886   stopRepeating();
889 void MainWindow::on_trackingPlusButton_pressed()
891   startRepeating(TrackingPlus_Key);
894 void MainWindow::on_trackingPlusButton_released()
896   stopRepeating();
899 void MainWindow::on_trackingMinusButton_pressed()
901   startRepeating(TrackingMinus_Key);
904 void MainWindow::on_trackingMinusButton_released()
906   stopRepeating();
909 void MainWindow::on_autoTrackingButton_pressed()
911   startRepeating(AutoTracking_Key);
914 void MainWindow::on_autoTrackingButton_released()
916   stopRepeating();
919 void MainWindow::on_pageUpButton_pressed()
921   startRepeating(PageUp_Key);
924 void MainWindow::on_pageUpButton_released()
926   stopRepeating();
929 void MainWindow::on_pageDownButton_pressed()
931   startRepeating(PageDown_Key);
934 void MainWindow::on_pageDownButton_released()
936   stopRepeating();
939 void MainWindow::on_slowButton_pressed()
941   startRepeating(Slow_Key);
944 void MainWindow::on_slowButton_released()
946   stopRepeating();
949 void MainWindow::on_slowMinusButton_pressed()
951   startRepeating(SlowMinus_Key);
954 void MainWindow::on_slowMinusButton_released()
956   stopRepeating();
959 void MainWindow::on_slowPlusButton_pressed()
961   startRepeating(SlowPlus_Key);
964 void MainWindow::on_slowPlusButton_released()
966   stopRepeating();
969 void MainWindow::on_programButton_pressed()
971   startRepeating(Program_Key);
974 void MainWindow::on_programButton_released()
976   stopRepeating();
979 void MainWindow::on_tunerBandButton_pressed()
981   startRepeating(TunerBand_Key);
984 void MainWindow::on_tunerBandButton_released()
986   stopRepeating();
989 void MainWindow::on_repeatButton_pressed()
991   startRepeating(Repeat_Key);
994 void MainWindow::on_repeatButton_released()
996   stopRepeating();
999 void MainWindow::on_repeatABButton_pressed()
1001   startRepeating(RepeatAB_Key);
1004 void MainWindow::on_repeatABButton_released()
1006   stopRepeating();
1009 void MainWindow::on_randomButton_pressed()
1011   startRepeating(Random_Key);
1014 void MainWindow::on_randomButton_released()
1016   stopRepeating();
1020 // TV Slots:
1022 void MainWindow::on_pictureModeButton_pressed()
1024   startRepeating(PictureMode_Key);
1027 void MainWindow::on_pictureModeButton_released()
1029   stopRepeating();
1032 void MainWindow::on_soundModeButton_pressed()
1034   startRepeating(SoundMode_Key);
1037 void MainWindow::on_soundModeButton_released()
1039   stopRepeating();
1042 void MainWindow::on_liveTVButton_pressed()
1044   startRepeating(LiveTV_Key);
1047 void MainWindow::on_liveTVButton_released()
1049   stopRepeating();
1052 void MainWindow::on_favoritesButton_pressed()
1054   startRepeating(Favorites_Key);
1057 void MainWindow::on_favoritesButton_released()
1059   stopRepeating();
1062 void MainWindow::on_teletextButton_pressed()
1064   startRepeating(Teletext_Key);
1067 void MainWindow::on_teletextButton_released()
1069   stopRepeating();
1072 void MainWindow::on_teletextHoldButton_pressed()
1074   startRepeating(TeletextHold_Key);
1077 void MainWindow::on_teletextHoldButton_released()
1079   stopRepeating();
1082 void MainWindow::on_teletextRevealButton_pressed()
1084   startRepeating(TeletextReveal_Key);
1087 void MainWindow::on_teletextRevealButton_released()
1089   stopRepeating();
1092 void MainWindow::on_teletextSizeButton_pressed()
1094   startRepeating(TeletextSize_Key);
1097 void MainWindow::on_teletextSizeButton_released()
1099   stopRepeating();
1102 void MainWindow::on_pipOnOffButton_pressed()
1104   startRepeating(PIP_Key);
1107 void MainWindow::on_pipOnOffButton_released()
1109   stopRepeating();
1112 void MainWindow::on_pipSwapButton_pressed()
1114   startRepeating(PIPSwap_Key);
1117 void MainWindow::on_pipSwapButton_released()
1119   stopRepeating();
1122 void MainWindow::on_pipPositionButton_pressed()
1124   startRepeating(PIPMove_Key);
1127 void MainWindow::on_pipPositionButton_released()
1129   stopRepeating();
1132 void MainWindow::on_pipSourceButton_pressed()
1134   startRepeating(PIPSource_Key);
1137 void MainWindow::on_pipSourceButton_released()
1139   stopRepeating();
1142 void MainWindow::on_pipChannelUpButton_pressed()
1144   startRepeating(PIPChannelUp_Key);
1147 void MainWindow::on_pipChannelUpButton_released()
1149   stopRepeating();
1152 void MainWindow::on_pipChannelDownButton_pressed()
1154   startRepeating(PIPChannelDown_Key);
1157 void MainWindow::on_pipChannelDownButton_released()
1159   stopRepeating();
1162 void MainWindow::on_pipPauseButton_pressed()
1164   startRepeating(PIPPause_Key);
1167 void MainWindow::on_pipPauseButton_released()
1169   stopRepeating();
1172 void MainWindow::on_pipSizeButton_pressed()
1174   startRepeating(PIPSize_Key);
1177 void MainWindow::on_pipSizeButton_released()
1179   stopRepeating();
1181 */
1185 // Menu actions:
1187 void MainWindow::on_actionSelectKeyset_triggered()
1189   selectKeysetForm->show();
1192 void MainWindow::on_actionSecondary_Buttons_triggered()
1194   if (!secondaryForm)
1195   {
1196     secondaryForm = new PIRSecondaryForm(this);
1197   }
1199   secondaryForm->show();
1202 void MainWindow::on_actionAbout_triggered()
1204   if (!aboutForm)
1205   {
1206     aboutForm = new PIRAboutForm(this);
1207   }
1209   aboutForm->show();
1212 void MainWindow::on_actionDocumentation_triggered()
1214   if (!documentationForm)
1215   {
1216     documentationForm = new PIRDocumentationForm(this);
1217   }
1219   documentationForm->show();
1223 // Other actions:
1225 void MainWindow::keysetSelectionChanged(
1226   QListWidgetItem *item)
1228   if (!item) return;  // Should probably say something here!
1230   PIRKeysetWidgetItem *kwi = dynamic_cast<PIRKeysetWidgetItem *>(item);
1232   if (!kwi) return; // Also need to say something here
1233   
1234   currentKeyset = kwi->getID();
1236   QSettings settings("pietrzak.org", "Pierogi");
1237 //  settings.setValue("currentKeyset", currentKeyset);
1239   settings.setValue(
1240     "currentKeysetMake",
1241     makeManager.getMakeString(kwi->getMake()));
1243   settings.setValue(
1244     "currentKeysetName",
1245     myKeysets->getDisplayName(currentKeyset));
1247   enableButtons();
1248   secondaryForm->enableButtons(myKeysets, currentKeyset);
1252 void MainWindow::finalCleanup()
1254   // Perform any necessary cleanup work here.
1256   // Make certain that the thread stops repeating:
1257   stopRepeating();
1261 void MainWindow::on_addKeysetButton_clicked()
1263   // Is the current keyset already a favorite?
1264   int count = ui->favoriteKeysetsWidget->count();
1265   int index = 0;
1266   PIRKeysetWidgetItem *kwi = NULL;
1267   while (index < count)
1268   {
1269     kwi = dynamic_cast<PIRKeysetWidgetItem *>(
1270       ui->favoriteKeysetsWidget->item(index));
1272     if (kwi && (kwi->getID() == currentKeyset))
1273     {
1274       // Current keyset already in list!  No need to continue.
1275       return;
1276     }
1277     ++index;
1278   }
1280   // Ok, add the current keyset to the favorites:
1281   PIRMakeName make = myKeysets->getMake(currentKeyset);
1283   QString name = makeManager.getMakeString(make);
1284   name.append(" ");
1285   name.append(myKeysets->getDisplayName(currentKeyset));
1287   ui->favoriteKeysetsWidget->addItem(
1288     new PIRKeysetWidgetItem(name, currentKeyset, make));
1290   // And, add the keyset id to the persistent list:
1291   QSettings settings("pietrzak.org", "Pierogi");
1293   int favSettingsSize = settings.beginReadArray("favorites");
1294   settings.endArray();
1296   settings.beginWriteArray("favorites");
1297   settings.setArrayIndex(favSettingsSize);
1298 //  settings.setValue("keysetID", currentKeyset);
1300   settings.setValue(
1301     "keysetMake",
1302     makeManager.getMakeString(myKeysets->getMake(currentKeyset)));
1304   settings.setValue("keysetName", myKeysets->getDisplayName(currentKeyset));
1306   settings.endArray();
1310 void MainWindow::on_removeKeysetButton_clicked()
1312   // Deleting an item removes it from the list, so just grab the currently
1313   // selected item and delete it:
1314   QListWidgetItem *item = ui->favoriteKeysetsWidget->currentItem();
1316   if (item) delete item;
1318   // Remove this item from the persistent list.  Well, actually, it seems a
1319   // little more convenient to just blow away the existing list of favorites
1320   // and rewrite it, as modifying an existing QSettings array in the middle
1321   // seems a bit hard...
1322   QSettings settings("pietrzak.org", "Pierogi");
1324   settings.remove("favorites");
1326   int count = ui->favoriteKeysetsWidget->count();
1328   // If the count is empty, we can stop right here:
1329   if (count == 0) return;
1331   int index = 0;
1332   unsigned int id;
1333   PIRKeysetWidgetItem *kwi = NULL;
1334   settings.beginWriteArray("favorites");
1335   while (index < count)
1336   {
1337     kwi = dynamic_cast<PIRKeysetWidgetItem *>(
1338       ui->favoriteKeysetsWidget->item(index));
1340     settings.setArrayIndex(index);
1341 //    settings.setValue("keysetID", kwi->getID());
1342     id = kwi->getID();
1344     settings.setValue(
1345       "keysetMake",
1346       makeManager.getMakeString(myKeysets->getMake(id)));
1348     settings.setValue("keysetName", myKeysets->getDisplayName(id));
1350     ++index;
1351   }
1352   settings.endArray();
1355 void MainWindow::populateFavorites()
1357   QSettings settings("pietrzak.org", "Pierogi");
1359   int size = settings.beginReadArray("favorites");
1360   int index = 0;
1361   QString make;
1362   QString name;
1363 //  unsigned int id;
1364   PIRKeysetWidgetItem *kwi;
1366   while (index < size)
1367   {
1368     settings.setArrayIndex(index);
1369 //    id = settings.value("keysetID").toInt();
1370     make = settings.value("keysetMake").toString();
1371     name = settings.value("keysetName").toString();
1373     kwi = myKeysets->makeKeysetItem(make, name);
1375     // Did the item creation work?
1376 //    if (myKeysets->keysetExists(id))
1377     if (kwi)
1378     {
1379       // Keyset does exist, so continue:
1380 //      make = myKeysets->getMake(id);
1381 //      name = makeManager.getMakeString(make);
1382 //      name.append(" ");
1383 //      name.append(myKeysets->getDisplayName(id));
1384 //    kwi = new PIRKeysetWidgetItem(name, id, make);
1385 //    myKeysets->populateDeviceTypes(kwi, id);
1386 //      ui->favoriteKeysetsWidget->addItem(new PIRKeysetWidgetItem(name, id, make));
1387       ui->favoriteKeysetsWidget->addItem(kwi);
1388     }
1390     ++index;
1391   }
1393   settings.endArray();
1397 void MainWindow::startRepeating(
1398   PIRKeyName name)
1400   QMutexLocker locker(&commandIFMutex);
1401   if (!commandInFlight)
1402   {
1403     commandInFlight = true;
1404     emit buttonPressed(currentKeyset, name);
1405   }
1409 void MainWindow::stopRepeating()
1411   QMutexLocker locker(&stopRepeatingMutex);
1412   stopRepeatingFlag = true;

Terms of Use    Privacy Policy    Contribution Guidelines    Feedback

Powered By GForge Collaborative Development Environment