Missed one file
[pierogi] / forms / piraltmainform.cpp
1 #include "piraltmainform.h"
2 #include "ui_piraltmainform.h"
3
4 #include "mainwindow.h"
5 #include "pirkeysetmanager.h"
6
7 // Ugly global:
8 extern PIRMakeMgr makeManager;
9
10
11 PIRAltMainForm::PIRAltMainForm(
12   MainWindow *mw)
13   : QWidget(0),
14     ui(new Ui::PIRAltMainForm),
15     mainWindow(mw),
16     defaultID(0)
17 {
18   ui->setupUi(this);
19 }
20
21
22 PIRAltMainForm::~PIRAltMainForm()
23 {
24   delete ui;
25 }
26
27
28 void PIRAltMainForm::enableButtons(
29   const PIRKeysetManager *keyset,
30   unsigned int id)
31 {
32   // No default id:
33   defaultID = 0;
34
35   emit powerEnabled(keyset->hasKey(id, Power_Key));
36   emit volumeUpEnabled(keyset->hasKey(id, VolumeUp_Key));
37   emit volumeDownEnabled(keyset->hasKey(id, VolumeDown_Key));
38   emit channelUpEnabled(keyset->hasKey(id, ChannelUp_Key));
39   emit channelDownEnabled(keyset->hasKey(id, ChannelDown_Key));
40   emit muteEnabled(keyset->hasKey(id, Mute_Key));
41
42   emit keysetMakeChanged(makeManager.getMakeString(keyset->getMake(id)));
43   emit keysetNameChanged(keyset->getDisplayName(id));
44 }
45
46
47 void PIRAltMainForm::enableButtons(
48   const PIRKeysetManager *keyset,
49   unsigned int cID,
50   unsigned int dID)
51 {
52   defaultID = dID;
53   emit powerEnabled(keyset->hasKey(cID, Power_Key));
54   emit volumeUpEnabled(keyset->hasKey(dID, VolumeUp_Key));
55   emit volumeDownEnabled(keyset->hasKey(dID, VolumeDown_Key));
56   emit channelUpEnabled(keyset->hasKey(cID, ChannelUp_Key));
57   emit channelDownEnabled(keyset->hasKey(cID, ChannelDown_Key));
58   emit muteEnabled(keyset->hasKey(dID, Mute_Key));
59
60   emit keysetMakeChanged(makeManager.getMakeString(keyset->getMake(cID)));
61   emit keysetNameChanged(keyset->getDisplayName(cID));
62 }
63
64
65 void PIRAltMainForm::on_volumeUpButton_pressed()
66 {
67   if (defaultID)
68   {
69     mainWindow->startRepeating(VolumeUp_Key, defaultID);
70   }
71   else
72   {
73     mainWindow->startRepeating(VolumeUp_Key);
74   }
75 }
76
77 void PIRAltMainForm::on_volumeUpButton_released()
78 {
79   mainWindow->stopRepeating();
80 }
81
82 void PIRAltMainForm::on_volumeDownButton_pressed()
83 {
84   if (defaultID)
85   {
86     mainWindow->startRepeating(VolumeDown_Key, defaultID);
87   }
88   else
89   {
90     mainWindow->startRepeating(VolumeDown_Key);
91   }
92 }
93
94 void PIRAltMainForm::on_volumeDownButton_released()
95 {
96   mainWindow->stopRepeating();
97 }
98
99 void PIRAltMainForm::on_muteButton_pressed()
100 {
101   if (defaultID)
102   {
103     mainWindow->startRepeating(Mute_Key, defaultID);
104   }
105   else
106   {
107     mainWindow->startRepeating(Mute_Key);
108   }
109 }
110
111 void PIRAltMainForm::on_muteButton_released()
112 {
113   mainWindow->stopRepeating();
114 }
115
116 void PIRAltMainForm::on_powerButton_pressed()
117 {
118   mainWindow->startRepeating(Power_Key);
119 }
120
121 void PIRAltMainForm::on_powerButton_released()
122 {
123   mainWindow->stopRepeating();
124 }
125
126 void PIRAltMainForm::on_channelUpButton_pressed()
127 {
128   mainWindow->startRepeating(ChannelUp_Key);
129 }
130
131 void PIRAltMainForm::on_channelUpButton_released()
132 {
133   mainWindow->stopRepeating();
134 }
135
136 void PIRAltMainForm::on_channelDownButton_pressed()
137 {
138   mainWindow->startRepeating(ChannelDown_Key);
139 }
140
141 void PIRAltMainForm::on_channelDownButton_released()
142 {
143   mainWindow->stopRepeating();
144 }