author | sandman <sandman> | 2002-06-30 00:24:42 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-06-30 00:24:42 (UTC) |
commit | 2e3c599f9b2498ecd9c2332d38a0ae293954b570 (patch) (unidiff) | |
tree | 1a5f95206bba7ca896b09558cf1b46ac6e03f205 | |
parent | 0235faab30f436ae3fbfed21e9f07486181bb0dd (diff) | |
download | opie-2e3c599f9b2498ecd9c2332d38a0ae293954b570.zip opie-2e3c599f9b2498ecd9c2332d38a0ae293954b570.tar.gz opie-2e3c599f9b2498ecd9c2332d38a0ae293954b570.tar.bz2 |
Some fixes (keeping vol/mute in sync with other apps)
-rw-r--r-- | core/applets/volumeapplet/volume.cpp | 49 | ||||
-rw-r--r-- | core/applets/volumeapplet/volume.h | 2 |
2 files changed, 22 insertions, 29 deletions
diff --git a/core/applets/volumeapplet/volume.cpp b/core/applets/volumeapplet/volume.cpp index b047877..eedc749 100644 --- a/core/applets/volumeapplet/volume.cpp +++ b/core/applets/volumeapplet/volume.cpp | |||
@@ -90,206 +90,197 @@ static const char * mic_xpm[] = { | |||
90 | "* c #6A696A", | 90 | "* c #6A696A", |
91 | "= c #E6E2E6", | 91 | "= c #E6E2E6", |
92 | "- c #F6F2F6", | 92 | "- c #F6F2F6", |
93 | "; c #CDC6CD", | 93 | "; c #CDC6CD", |
94 | "> c #737573", | 94 | "> c #737573", |
95 | ", c #4A484A", | 95 | ", c #4A484A", |
96 | "' c #DEDEDE", | 96 | "' c #DEDEDE", |
97 | ") c #F6EEF6", | 97 | ") c #F6EEF6", |
98 | "! c #414041", | 98 | "! c #414041", |
99 | "~ c #202020", | 99 | "~ c #202020", |
100 | "{ c #ACAEAC", | 100 | "{ c #ACAEAC", |
101 | "] c #838583", | 101 | "] c #838583", |
102 | "^ c #6A656A", | 102 | "^ c #6A656A", |
103 | " ", | 103 | " ", |
104 | " .... ", | 104 | " .... ", |
105 | " .+@+#. ", | 105 | " .+@+#. ", |
106 | " ..$%&%*. ", | 106 | " ..$%&%*. ", |
107 | " .=-.;=>=,. ", | 107 | " .=-.;=>=,. ", |
108 | " .'+).&+!+. ", | 108 | " .'+).&+!+. ", |
109 | " .+;+;.~+~. ", | 109 | " .+;+;.~+~. ", |
110 | " ..%{%,.... ", | 110 | " ..%{%,.... ", |
111 | " ..&=>=~.. ", | 111 | " ..&=>=~.. ", |
112 | " .+..]^,.. ", | 112 | " .+..]^,.. ", |
113 | " .+....... ", | 113 | " .+....... ", |
114 | " .%... ", | 114 | " .%... ", |
115 | " .=... ", | 115 | " .=... ", |
116 | " .+... ", | 116 | " .+... ", |
117 | " .+... ", | 117 | " .+... ", |
118 | " .... ", | 118 | " .... ", |
119 | " .... ", | 119 | " .... ", |
120 | " .. ", | 120 | " .. ", |
121 | " . ", | 121 | " . ", |
122 | ". "}; | 122 | ". "}; |
123 | 123 | ||
124 | /* XPM */ | 124 | /* XPM */ |
125 | static const char * alarm_xpm[] = { | 125 | static const char * alarm_xpm[] = { |
126 | "20 20 33 1", | 126 | "20 20 33 1", |
127 | " c None", | 127 | " c None", |
128 | ". c #080602", | 128 | ". c #080602", |
129 | "+ c #AAA602", | 129 | "+ c #AAA602", |
130 | "@ c #252002", | 130 | "@ c #252002", |
131 | "# c #434202", | 131 | "# c #434202", |
132 | "$ c #795602", | 132 | "$ c #795602", |
133 | "% c #C3C20D", | 133 | "% c #C3C20D", |
134 | "& c #DADAC2", | 134 | "& c #DADAC2", |
135 | "* c #826002", | 135 | "* c #826002", |
136 | "= c #740502", | 136 | "= c #740502", |
137 | "- c #D6D602", | 137 | "- c #D6D602", |
138 | "; c #322E02", | 138 | "; c #322E02", |
139 | "> c #826A02", | 139 | "> c #826A02", |
140 | ", c #F1F195", | 140 | ", c #F1F195", |
141 | "' c #959215", | 141 | "' c #959215", |
142 | ") c #423602", | 142 | ") c #423602", |
143 | "! c #4B0302", | 143 | "! c #4B0302", |
144 | "~ c #844315", | 144 | "~ c #844315", |
145 | "{ c #AAAA2A", | 145 | "{ c #AAAA2A", |
146 | "] c #E2DE42", | 146 | "] c #E2DE42", |
147 | "^ c #BA7E04", | 147 | "^ c #BA7E04", |
148 | "/ c #7F7502", | 148 | "/ c #7F7502", |
149 | "( c #828276", | 149 | "( c #828276", |
150 | "_ c #FEFE4E", | 150 | "_ c #FEFE4E", |
151 | ": c #7D1902", | 151 | ": c #7D1902", |
152 | "< c #989656", | 152 | "< c #989656", |
153 | "[ c #260B02", | 153 | "[ c #260B02", |
154 | "} c #F7F7D8", | 154 | "} c #F7F7D8", |
155 | "| c #DCDA5A", | 155 | "| c #DCDA5A", |
156 | "1 c #823102", | 156 | "1 c #823102", |
157 | "2 c #B1AC6B", | 157 | "2 c #B1AC6B", |
158 | "3 c #F7F710", | 158 | "3 c #F7F710", |
159 | "4 c #838204", | 159 | "4 c #838204", |
160 | " ", | 160 | " ", |
161 | " ", | 161 | " ", |
162 | " 4'4/ ", | 162 | " 4'4/ ", |
163 | " /-^= ", | 163 | " /-^= ", |
164 | " 42{4>4 ", | 164 | " 42{4>4 ", |
165 | " '2|+*$44 ", | 165 | " '2|+*$44 ", |
166 | " +2&3+$1*44 ", | 166 | " +2&3+$1*44 ", |
167 | " (%_}_+/$:>/4 ", | 167 | " (%_}_+/$:>/4 ", |
168 | " 4%_}3+#;>:*4 ", | 168 | " 4%_}3+#;>:*4 ", |
169 | " 4%_}&+#[1$/4 ", | 169 | " 4%_}&+#[1$/4 ", |
170 | " 4%_,2')[~~>4 ", | 170 | " 4%_,2')[~~>4 ", |
171 | " 4%33'4#@~1>4 ", | 171 | " 4%33'4#@~1>4 ", |
172 | " 4%3344#[:>/4 ", | 172 | " 4%3344#[:>/4 ", |
173 | " 42&_3'4#@>:*44 ", | 173 | " 42&_3'4#@>:*44 ", |
174 | " 42|}}3'4#[;$)$44 ", | 174 | " 42|}}3'4#[;$)$44 ", |
175 | "444{]]2^~~:!!#.@##/ ", | 175 | "444{]]2^~~:!!#.@##/ ", |
176 | "4444-%*:==!!=...../ ", | 176 | "4444-%*:==!!=...../ ", |
177 | " /:[.. ", | 177 | " /:[.. ", |
178 | " /@. ", | 178 | " /@. ", |
179 | " "}; | 179 | " "}; |
180 | 180 | ||
181 | VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *parent, const char *name ) | 181 | VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *parent, const char *name ) |
182 | : QFrame ( parent, name, WStyle_StaysOnTop | WType_Popup ) | 182 | : QFrame ( parent, name, WStyle_StaysOnTop | WType_Popup ) |
183 | { | 183 | { |
184 | m_icon = icon; | 184 | m_icon = icon; |
185 | 185 | ||
186 | bool has_wav_alarm = false; | 186 | bool has_wav_alarm = true; |
187 | 187 | ||
188 | switch ( ODevice::inst ( )-> model ( )) { // we need to add other devices eventually | 188 | switch ( ODevice::inst ( )-> model ( )) { // we need to add other devices eventually |
189 | case OMODEL_iPAQ_H31xx: | ||
190 | case OMODEL_iPAQ_H36xx: | ||
191 | case OMODEL_iPAQ_H37xx: | ||
192 | case OMODEL_iPAQ_H38xx: | ||
193 | has_wav_alarm = true; | ||
194 | break; | ||
195 | case OMODEL_Zaurus_SL5000: | 189 | case OMODEL_Zaurus_SL5000: |
196 | has_wav_alarm = false; //poor guys probably feeling left out... | 190 | has_wav_alarm = false; //poor guys probably feeling left out... |
197 | break; | ||
198 | default: | ||
199 | has_wav_alarm = true; //lets just presume | ||
200 | break; | 191 | break; |
201 | } | 192 | } |
202 | 193 | ||
203 | 194 | ||
204 | setFrameStyle ( QFrame::PopupPanel | QFrame::Raised ); | 195 | setFrameStyle ( QFrame::PopupPanel | QFrame::Raised ); |
205 | 196 | ||
206 | QGridLayout *grid = new QGridLayout ( this, 1, 1, 6, 4 ); | 197 | QGridLayout *grid = new QGridLayout ( this, 1, 1, 6, 4 ); |
207 | grid-> setSpacing ( 4 ); | 198 | grid-> setSpacing ( 4 ); |
208 | grid-> setMargin ( 6 ); | 199 | grid-> setMargin ( 6 ); |
209 | 200 | ||
210 | QVBoxLayout *vbox; | 201 | QVBoxLayout *vbox; |
211 | QLabel *l; | 202 | QLabel *l; |
212 | 203 | ||
213 | vbox = new QVBoxLayout ( ); | 204 | vbox = new QVBoxLayout ( ); |
214 | vbox-> setSpacing ( 4 ); | 205 | vbox-> setSpacing ( 4 ); |
215 | grid-> addLayout ( vbox, 1, 0 ); | 206 | grid-> addLayout ( vbox, 1, 0 ); |
216 | 207 | ||
217 | upButton = new QPushButton ( this ); | 208 | upButton = new QPushButton ( this ); |
218 | upButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); | 209 | upButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); |
219 | upButton-> setPixmap ( Resource::loadPixmap ( "up" )); | 210 | upButton-> setPixmap ( Resource::loadPixmap ( "up" )); |
220 | upButton-> setFocusPolicy ( QWidget::NoFocus ); | 211 | upButton-> setFocusPolicy ( QWidget::NoFocus ); |
221 | 212 | ||
222 | vbox-> addWidget ( upButton ); | 213 | vbox-> addWidget ( upButton ); |
223 | 214 | ||
224 | downButton = new QPushButton ( this ); | 215 | downButton = new QPushButton ( this ); |
225 | downButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); | 216 | downButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); |
226 | downButton-> setPixmap ( Resource::loadPixmap ( "down" )); | 217 | downButton-> setPixmap ( Resource::loadPixmap ( "down" )); |
227 | downButton-> setFocusPolicy ( QWidget::NoFocus ); | 218 | downButton-> setFocusPolicy ( QWidget::NoFocus ); |
228 | 219 | ||
229 | vbox-> addWidget ( downButton ); | 220 | vbox-> addWidget ( downButton ); |
230 | 221 | ||
231 | volSlider = new QSlider ( this ); | 222 | volSlider = new QSlider ( this ); |
232 | volSlider-> setRange ( 0, 100 ); | 223 | volSlider-> setRange ( 0, 100 ); |
233 | volSlider-> setTickmarks ( QSlider::Both ); | 224 | volSlider-> setTickmarks ( QSlider::Both ); |
234 | volSlider-> setTickInterval ( 20 ); | 225 | volSlider-> setTickInterval ( 20 ); |
235 | volSlider-> setFocusPolicy ( QWidget::NoFocus ); | 226 | volSlider-> setFocusPolicy ( QWidget::NoFocus ); |
236 | 227 | ||
237 | l = new QLabel ( this ); | 228 | l = new QLabel ( this ); |
238 | l-> setPixmap ( QPixmap ( vol_xpm )); | 229 | l-> setPixmap ( QPixmap ( vol_xpm )); |
239 | 230 | ||
240 | grid-> addWidget ( l, 0, 1, AlignCenter ); | 231 | grid-> addWidget ( l, 0, 1, AlignCenter ); |
241 | grid-> addWidget ( volSlider, 1, 1, AlignCenter ); | 232 | grid-> addWidget ( volSlider, 1, 1, AlignCenter ); |
242 | 233 | ||
243 | volLed = new OLedBox ( green, this ); | 234 | volLed = new OLedBox ( green, this ); |
244 | volLed-> setFocusPolicy ( QWidget::NoFocus ); | 235 | volLed-> setFocusPolicy ( QWidget::NoFocus ); |
245 | volLed-> setFixedSize ( 16, 16 ); | 236 | volLed-> setFixedSize ( 16, 16 ); |
246 | 237 | ||
247 | grid-> addWidget ( volLed, 2, 1, AlignCenter ); | 238 | grid-> addWidget ( volLed, 2, 1, AlignCenter ); |
248 | 239 | ||
249 | micSlider = new QSlider ( this ); | 240 | micSlider = new QSlider ( this ); |
250 | micSlider-> setRange ( 0, 100 ); | 241 | micSlider-> setRange ( 0, 100 ); |
251 | micSlider-> setTickmarks ( QSlider::Both ); | 242 | micSlider-> setTickmarks ( QSlider::Both ); |
252 | micSlider-> setTickInterval ( 20 ); | 243 | micSlider-> setTickInterval ( 20 ); |
253 | micSlider-> setFocusPolicy ( QWidget::NoFocus ); | 244 | micSlider-> setFocusPolicy ( QWidget::NoFocus ); |
254 | 245 | ||
255 | l = new QLabel ( this ); | 246 | l = new QLabel ( this ); |
256 | l-> setPixmap ( QPixmap ( mic_xpm )); | 247 | l-> setPixmap ( QPixmap ( mic_xpm )); |
257 | 248 | ||
258 | grid-> addWidget ( l, 0, 2, AlignCenter ); | 249 | grid-> addWidget ( l, 0, 2, AlignCenter ); |
259 | grid-> addWidget ( micSlider, 1, 2, AlignCenter ); | 250 | grid-> addWidget ( micSlider, 1, 2, AlignCenter ); |
260 | 251 | ||
261 | micLed = new OLedBox ( red, this ); | 252 | micLed = new OLedBox ( red, this ); |
262 | micLed-> setFocusPolicy ( QWidget::NoFocus ); | 253 | micLed-> setFocusPolicy ( QWidget::NoFocus ); |
263 | micLed-> setFixedSize ( 16, 16 ); | 254 | micLed-> setFixedSize ( 16, 16 ); |
264 | 255 | ||
265 | grid-> addWidget ( micLed, 2, 2, AlignCenter ); | 256 | grid-> addWidget ( micLed, 2, 2, AlignCenter ); |
266 | 257 | ||
267 | alarmSlider = new QSlider ( this ); | 258 | alarmSlider = new QSlider ( this ); |
268 | alarmSlider-> setRange ( 0, 100 ); | 259 | alarmSlider-> setRange ( 0, 100 ); |
269 | alarmSlider-> setTickmarks ( QSlider::Both ); | 260 | alarmSlider-> setTickmarks ( QSlider::Both ); |
270 | alarmSlider-> setTickInterval ( 20 ); | 261 | alarmSlider-> setTickInterval ( 20 ); |
271 | alarmSlider-> setFocusPolicy ( QWidget::NoFocus ); | 262 | alarmSlider-> setFocusPolicy ( QWidget::NoFocus ); |
272 | 263 | ||
273 | QLabel *alarmLabel = new QLabel ( this ); | 264 | QLabel *alarmLabel = new QLabel ( this ); |
274 | alarmLabel-> setPixmap ( QPixmap ( alarm_xpm )); | 265 | alarmLabel-> setPixmap ( QPixmap ( alarm_xpm )); |
275 | 266 | ||
276 | grid-> addWidget ( alarmLabel, 0, 3, AlignCenter ); | 267 | grid-> addWidget ( alarmLabel, 0, 3, AlignCenter ); |
277 | grid-> addWidget ( alarmSlider, 1, 3, AlignCenter ); | 268 | grid-> addWidget ( alarmSlider, 1, 3, AlignCenter ); |
278 | 269 | ||
279 | alarmLed = new OLedBox ( yellow, this ); | 270 | alarmLed = new OLedBox ( yellow, this ); |
280 | alarmLed-> setFocusPolicy ( QWidget::NoFocus ); | 271 | alarmLed-> setFocusPolicy ( QWidget::NoFocus ); |
281 | alarmLed-> setFixedSize ( 16, 16 ); | 272 | alarmLed-> setFixedSize ( 16, 16 ); |
282 | 273 | ||
283 | grid-> addWidget ( alarmLed, 2, 3, AlignCenter ); | 274 | grid-> addWidget ( alarmLed, 2, 3, AlignCenter ); |
284 | 275 | ||
285 | if ( !has_wav_alarm ) { | 276 | if ( !has_wav_alarm ) { |
286 | alarmSlider-> hide ( ); | 277 | alarmSlider-> hide ( ); |
287 | alarmLabel-> hide ( ); | 278 | alarmLabel-> hide ( ); |
288 | alarmLed-> hide ( ); | 279 | alarmLed-> hide ( ); |
289 | } | 280 | } |
290 | 281 | ||
291 | grid-> addWidget ( new QLabel ( tr( "Enable Sounds for:" ), this ), 0, 4, AlignVCenter | AlignLeft ); | 282 | grid-> addWidget ( new QLabel ( tr( "Enable Sounds for:" ), this ), 0, 4, AlignVCenter | AlignLeft ); |
292 | 283 | ||
293 | vbox = new QVBoxLayout ( ); | 284 | vbox = new QVBoxLayout ( ); |
294 | vbox-> setSpacing ( 4 ); | 285 | vbox-> setSpacing ( 4 ); |
295 | grid-> addMultiCellLayout ( vbox, 1, 2, 4, 4 ); | 286 | grid-> addMultiCellLayout ( vbox, 1, 2, 4, 4 ); |
@@ -315,325 +306,325 @@ VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *pa | |||
315 | 306 | ||
316 | vbox-> addStretch ( 100 ); | 307 | vbox-> addStretch ( 100 ); |
317 | 308 | ||
318 | setFixedSize ( sizeHint ( )); | 309 | setFixedSize ( sizeHint ( )); |
319 | setFocusPolicy ( QWidget::NoFocus ); | 310 | setFocusPolicy ( QWidget::NoFocus ); |
320 | 311 | ||
321 | rateTimer = new QTimer( this ); | 312 | rateTimer = new QTimer( this ); |
322 | connect ( rateTimer, SIGNAL( timeout ( )), this, SLOT( rateTimerDone ( ))); | 313 | connect ( rateTimer, SIGNAL( timeout ( )), this, SLOT( rateTimerDone ( ))); |
323 | 314 | ||
324 | connect ( upButton, SIGNAL( pressed ( )), this, SLOT( buttonChanged ( ))); | 315 | connect ( upButton, SIGNAL( pressed ( )), this, SLOT( buttonChanged ( ))); |
325 | connect ( upButton, SIGNAL( released ( )), this, SLOT( buttonChanged ( ))); | 316 | connect ( upButton, SIGNAL( released ( )), this, SLOT( buttonChanged ( ))); |
326 | connect ( downButton, SIGNAL( pressed ( )), this, SLOT( buttonChanged ( ))); | 317 | connect ( downButton, SIGNAL( pressed ( )), this, SLOT( buttonChanged ( ))); |
327 | connect ( downButton, SIGNAL( released ( )), this, SLOT( buttonChanged ( ))); | 318 | connect ( downButton, SIGNAL( released ( )), this, SLOT( buttonChanged ( ))); |
328 | 319 | ||
329 | connect ( micSlider, SIGNAL( valueChanged ( int )), this, SLOT( micMoved( int ))); | 320 | connect ( micSlider, SIGNAL( valueChanged ( int )), this, SLOT( micMoved( int ))); |
330 | connect ( volSlider, SIGNAL( valueChanged ( int )), this, SLOT( volMoved( int ))); | 321 | connect ( volSlider, SIGNAL( valueChanged ( int )), this, SLOT( volMoved( int ))); |
331 | connect ( alarmSlider, SIGNAL( valueChanged ( int )), this, SLOT( alarmMoved( int ))); | 322 | connect ( alarmSlider, SIGNAL( valueChanged ( int )), this, SLOT( alarmMoved( int ))); |
332 | 323 | ||
333 | connect ( volLed, SIGNAL( toggled ( bool )), this, SLOT( volMuteToggled ( bool ))); | 324 | connect ( volLed, SIGNAL( toggled ( bool )), this, SLOT( volMuteToggled ( bool ))); |
334 | connect ( micLed, SIGNAL( toggled ( bool )), this, SLOT( micMuteToggled ( bool ))); | 325 | connect ( micLed, SIGNAL( toggled ( bool )), this, SLOT( micMuteToggled ( bool ))); |
335 | connect ( alarmLed, SIGNAL( toggled ( bool )), this, SLOT( alarmSoundToggled ( bool ))); | 326 | connect ( alarmLed, SIGNAL( toggled ( bool )), this, SLOT( alarmSoundToggled ( bool ))); |
336 | 327 | ||
337 | connect ( alarmBox, SIGNAL( toggled ( bool )), this, SLOT( alarmSoundToggled ( bool ))); | 328 | connect ( alarmBox, SIGNAL( toggled ( bool )), this, SLOT( alarmSoundToggled ( bool ))); |
338 | connect ( keyBox, SIGNAL( toggled ( bool )), this, SLOT( keyClickToggled ( bool ))); | 329 | connect ( keyBox, SIGNAL( toggled ( bool )), this, SLOT( keyClickToggled ( bool ))); |
339 | connect ( tapBox, SIGNAL( toggled ( bool )), this, SLOT( screenTapToggled ( bool ))); | 330 | connect ( tapBox, SIGNAL( toggled ( bool )), this, SLOT( screenTapToggled ( bool ))); |
340 | 331 | ||
341 | // initialize variables | 332 | // initialize variables |
342 | 333 | ||
343 | readConfig ( true ); | 334 | readConfig ( true ); |
344 | 335 | ||
345 | // initialize the config file, in case some entries are missing | 336 | // initialize the config file, in case some entries are missing |
346 | 337 | ||
347 | writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_None ); | 338 | writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_None ); |
348 | writeConfigEntry ( "Mute", m_vol_muted, UPD_None ); | 339 | writeConfigEntry ( "Mute", m_vol_muted, UPD_None ); |
349 | writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); | 340 | writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); |
350 | writeConfigEntry ( "TouchSound", m_snd_touch, UPD_None ); | 341 | writeConfigEntry ( "TouchSound", m_snd_touch, UPD_None ); |
351 | writeConfigEntry ( "KeySound", m_snd_key, UPD_None ); | 342 | writeConfigEntry ( "KeySound", m_snd_key, UPD_None ); |
352 | writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); | 343 | writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); |
353 | 344 | ||
354 | writeConfigEntry ( "Mic", m_mic_percent, UPD_None ); | 345 | writeConfigEntry ( "Mic", m_mic_percent, UPD_None ); |
355 | writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); | 346 | writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); |
356 | } | 347 | } |
357 | 348 | ||
358 | bool VolumeControl::volMuted ( ) const | 349 | bool VolumeControl::volMuted ( ) const |
359 | { | 350 | { |
360 | return m_vol_muted; | 351 | return m_vol_muted; |
361 | } | 352 | } |
362 | 353 | ||
363 | int VolumeControl::volPercent ( ) const | 354 | int VolumeControl::volPercent ( ) const |
364 | { | 355 | { |
365 | return m_vol_percent; | 356 | return m_vol_percent; |
366 | } | 357 | } |
367 | 358 | ||
368 | void VolumeControl::keyPressEvent ( QKeyEvent *e ) | 359 | void VolumeControl::keyPressEvent ( QKeyEvent *e ) |
369 | { | 360 | { |
370 | switch ( e-> key ( )) { | 361 | switch ( e-> key ( )) { |
371 | case Key_Up: | 362 | case Key_Up: |
372 | volSlider-> subtractStep ( ); | 363 | volSlider-> subtractStep ( ); |
373 | break; | 364 | break; |
374 | case Key_Down: | 365 | case Key_Down: |
375 | volSlider-> addStep ( ); | 366 | volSlider-> addStep ( ); |
376 | break; | 367 | break; |
377 | case Key_Space: | 368 | case Key_Space: |
378 | volLed-> toggle ( ); | 369 | volLed-> toggle ( ); |
379 | break; | 370 | break; |
380 | case Key_Escape: | 371 | case Key_Escape: |
381 | hide ( ); | 372 | hide ( ); |
382 | break; | 373 | break; |
383 | } | 374 | } |
384 | } | 375 | } |
385 | 376 | ||
386 | void VolumeControl::buttonChanged ( ) | 377 | void VolumeControl::buttonChanged ( ) |
387 | { | 378 | { |
388 | if ( upButton-> isDown ( ) || downButton->isDown ( )) { | 379 | if ( upButton-> isDown ( ) || downButton->isDown ( )) { |
389 | rateTimerDone ( ); // Call it one time manually, otherwise it wont get | 380 | rateTimerDone ( ); // Call it one time manually, otherwise it wont get |
390 | // called at all when a button is pressed for a time | 381 | // called at all when a button is pressed for a time |
391 | // shorter than RATE_TIMER_INTERVAL. | 382 | // shorter than RATE_TIMER_INTERVAL. |
392 | rateTimer-> start ( RATE_TIMER_INTERVAL, false ); | 383 | rateTimer-> start ( RATE_TIMER_INTERVAL, false ); |
393 | } | 384 | } |
394 | else | 385 | else |
395 | rateTimer-> stop ( ); | 386 | rateTimer-> stop ( ); |
396 | } | 387 | } |
397 | 388 | ||
398 | void VolumeControl::rateTimerDone ( ) | 389 | void VolumeControl::rateTimerDone ( ) |
399 | { | 390 | { |
400 | if ( upButton-> isDown ( )) | 391 | if ( upButton-> isDown ( )) |
401 | volSlider-> setValue ( volSlider-> value ( ) - 2 ); | 392 | volSlider-> setValue ( volSlider-> value ( ) - 2 ); |
402 | else // if ( downButton-> isDown ( )) | 393 | else // if ( downButton-> isDown ( )) |
403 | volSlider-> setValue ( volSlider-> value ( ) + 2 ); | 394 | volSlider-> setValue ( volSlider-> value ( ) + 2 ); |
404 | } | 395 | } |
405 | 396 | ||
406 | void VolumeControl::show ( bool /*showMic*/ ) | 397 | void VolumeControl::show ( bool /*showMic*/ ) |
407 | { | 398 | { |
408 | readConfig ( ); | 399 | readConfig ( ); |
409 | 400 | ||
410 | QPoint curPos = m_icon-> mapToGlobal ( QPoint ( 0, 0 )); | 401 | QPoint curPos = m_icon-> mapToGlobal ( QPoint ( 0, 0 )); |
411 | printf ( "SHOW AT : %d/%d\n", curPos.x(), curPos.y()); | ||
412 | printf ( "SIZEHINT: %d/%d\n", sizeHint().width(),sizeHint().height()); | ||
413 | 402 | ||
414 | int w = sizeHint ( ). width ( ); | 403 | int w = sizeHint ( ). width ( ); |
415 | int x = curPos.x ( ) - ( w / 2 ); | 404 | int x = curPos.x ( ) - ( w / 2 ); |
416 | 405 | ||
417 | if (( x + w ) > QPEApplication::desktop ( )-> width ( )) | 406 | if (( x + w ) > QPEApplication::desktop ( )-> width ( )) |
418 | x = QPEApplication::desktop ( )-> width ( ) - w; | 407 | x = QPEApplication::desktop ( )-> width ( ) - w; |
419 | 408 | ||
420 | |||
421 | move ( x, curPos. y ( ) - sizeHint ( ). height ( )); | 409 | move ( x, curPos. y ( ) - sizeHint ( ). height ( )); |
422 | QFrame::show ( ); | 410 | QFrame::show ( ); |
423 | 411 | ||
424 | } | 412 | } |
425 | 413 | ||
426 | void VolumeControl::readConfig ( bool force ) | 414 | void VolumeControl::readConfig ( bool force ) |
427 | { | 415 | { |
428 | Config cfg ( "qpe" ); | 416 | Config cfg ( "qpe" ); |
429 | cfg. setGroup ( "Volume" ); | 417 | cfg. setGroup ( "Volume" ); |
430 | 418 | ||
431 | int old_vp = m_vol_percent; | 419 | int old_vp = m_vol_percent; |
432 | int old_mp = m_mic_percent; | 420 | int old_mp = m_mic_percent; |
433 | bool old_vm = m_vol_muted; | 421 | bool old_vm = m_vol_muted; |
434 | bool old_mm = m_mic_muted; | 422 | bool old_mm = m_mic_muted; |
435 | bool old_sk = m_snd_key; | 423 | bool old_sk = m_snd_key; |
436 | bool old_st = m_snd_touch; | 424 | bool old_st = m_snd_touch; |
437 | bool old_sa = m_snd_alarm; | 425 | bool old_sa = m_snd_alarm; |
438 | int old_ap = m_alarm_percent; | 426 | int old_ap = m_alarm_percent; |
439 | 427 | ||
440 | m_vol_percent = cfg. readNumEntry ( "VolumePercent", 50 ); | 428 | m_vol_percent = cfg. readNumEntry ( "VolumePercent", 50 ); |
441 | m_mic_percent = cfg. readNumEntry ( "Mic", 50 ); | 429 | m_mic_percent = cfg. readNumEntry ( "Mic", 50 ); |
442 | m_vol_muted = cfg. readBoolEntry ( "Mute", 0 ); | 430 | m_vol_muted = cfg. readBoolEntry ( "Mute", 0 ); |
443 | m_mic_muted = cfg. readBoolEntry ( "MicMute", 0 ); | 431 | m_mic_muted = cfg. readBoolEntry ( "MicMute", 0 ); |
444 | m_snd_key = cfg. readBoolEntry ( "KeySound", 0 ); | 432 | m_snd_key = cfg. readBoolEntry ( "KeySound", 0 ); |
445 | m_snd_touch = cfg. readBoolEntry ( "TouchSound", 0 ); | 433 | m_snd_touch = cfg. readBoolEntry ( "TouchSound", 0 ); |
446 | m_snd_alarm = cfg. readBoolEntry ( "AlarmSound", 1 ); | 434 | m_snd_alarm = cfg. readBoolEntry ( "AlarmSound", 1 ); |
447 | m_alarm_percent = cfg. readNumEntry ( "AlarmPercent", 65 ); | 435 | m_alarm_percent = cfg. readNumEntry ( "AlarmPercent", 65 ); |
448 | 436 | ||
449 | if ( force || ( m_vol_percent != old_vp )) | 437 | if ( force || ( m_vol_percent != old_vp )) |
450 | volSlider-> setValue ( 100 - m_vol_percent ); | 438 | volSlider-> setValue ( 100 - m_vol_percent ); |
451 | if ( force || ( m_mic_percent != old_mp )) | 439 | if ( force || ( m_mic_percent != old_mp )) |
452 | micSlider-> setValue ( 100 - m_mic_percent ); | 440 | micSlider-> setValue ( 100 - m_mic_percent ); |
453 | if ( force || ( m_alarm_percent != old_ap )) | 441 | if ( force || ( m_alarm_percent != old_ap )) |
454 | alarmSlider-> setValue ( 100 - m_alarm_percent ); | 442 | alarmSlider-> setValue ( 100 - m_alarm_percent ); |
455 | 443 | ||
456 | if ( force || ( m_vol_muted != old_vm )) | 444 | if ( force || ( m_vol_muted != old_vm )) |
457 | volLed-> setOn ( !m_vol_muted ); | 445 | volLed-> setOn ( !m_vol_muted ); |
458 | if ( force || ( m_mic_muted != old_mm )) | 446 | if ( force || ( m_mic_muted != old_mm )) |
459 | micLed-> setOn ( !m_mic_muted ); | 447 | micLed-> setOn ( !m_mic_muted ); |
460 | if ( force || ( m_snd_alarm != old_sa )) | 448 | if ( force || ( m_snd_alarm != old_sa )) |
461 | alarmLed-> setOn ( m_snd_alarm ); | 449 | alarmLed-> setOn ( m_snd_alarm ); |
462 | 450 | ||
463 | if ( force || ( m_snd_key != old_sk )) | 451 | if ( force || ( m_snd_key != old_sk )) |
464 | keyBox-> setChecked ( m_snd_key ); | 452 | keyBox-> setChecked ( m_snd_key ); |
465 | if ( force || ( m_snd_touch != old_st )) | 453 | if ( force || ( m_snd_touch != old_st )) |
466 | tapBox-> setChecked ( m_snd_touch ); | 454 | tapBox-> setChecked ( m_snd_touch ); |
467 | if ( force || ( m_snd_alarm != old_sa )) | 455 | if ( force || ( m_snd_alarm != old_sa )) |
468 | alarmBox-> setChecked ( m_snd_alarm ); | 456 | alarmBox-> setChecked ( m_snd_alarm ); |
469 | } | 457 | } |
470 | 458 | ||
471 | 459 | ||
472 | void VolumeControl::volumeChanged ( bool nowMuted ) | 460 | void VolumeControl::volumeChanged ( bool nowMuted ) |
473 | { | 461 | { |
474 | int previousVolume = m_vol_percent; | 462 | int prevVol = m_vol_percent; |
463 | bool prevMute = m_vol_muted; | ||
475 | 464 | ||
476 | if ( !nowMuted ) | 465 | readConfig ( ); |
477 | readConfig ( ); | ||
478 | 466 | ||
479 | // Handle case where muting it toggled | 467 | // Handle case where muting it toggled |
480 | if ( m_vol_muted != nowMuted ) { | 468 | if ( m_vol_muted != prevMute ) |
481 | m_vol_muted = nowMuted; | 469 | m_icon-> redraw ( true ); |
482 | m_icon-> repaint ( true ); | 470 | else if ( prevVol != m_vol_percent ) // Avoid over repainting |
483 | } | 471 | m_icon-> redraw ( false ); |
484 | else if ( previousVolume != m_vol_percent ) { | ||
485 | // Avoid over repainting | ||
486 | m_icon-> repaint( 2, height ( ) - 3, width ( ) - 4, 2, false ); | ||
487 | } | ||
488 | |||
489 | } | 472 | } |
490 | 473 | ||
491 | void VolumeControl::micChanged ( bool nowMuted ) | 474 | void VolumeControl::micChanged ( bool nowMuted ) |
492 | { | 475 | { |
493 | if ( !nowMuted ) | 476 | if ( !nowMuted ) |
494 | readConfig ( ); | 477 | readConfig ( ); |
495 | m_mic_muted = nowMuted; | 478 | m_mic_muted = nowMuted; |
496 | } | 479 | } |
497 | 480 | ||
498 | void VolumeControl::screenTapToggled ( bool b ) | 481 | void VolumeControl::screenTapToggled ( bool b ) |
499 | { | 482 | { |
500 | m_snd_touch = b; | 483 | m_snd_touch = b; |
501 | writeConfigEntry ( "TouchSound", m_snd_touch, UPD_Vol ); | 484 | writeConfigEntry ( "TouchSound", m_snd_touch, UPD_Vol ); |
502 | } | 485 | } |
503 | 486 | ||
504 | void VolumeControl::keyClickToggled ( bool b ) | 487 | void VolumeControl::keyClickToggled ( bool b ) |
505 | { | 488 | { |
506 | m_snd_key = b; | 489 | m_snd_key = b; |
507 | writeConfigEntry ( "KeySound", m_snd_key, UPD_Vol ); | 490 | writeConfigEntry ( "KeySound", m_snd_key, UPD_Vol ); |
508 | } | 491 | } |
509 | 492 | ||
510 | void VolumeControl::alarmSoundToggled ( bool b ) | 493 | void VolumeControl::alarmSoundToggled ( bool b ) |
511 | { | 494 | { |
512 | m_snd_alarm = b; | 495 | m_snd_alarm = b; |
513 | writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); | 496 | writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); |
514 | } | 497 | } |
515 | 498 | ||
516 | void VolumeControl::volMuteToggled ( bool b ) | 499 | void VolumeControl::volMuteToggled ( bool b ) |
517 | { | 500 | { |
518 | m_vol_muted = !b; | 501 | m_vol_muted = !b; |
519 | 502 | ||
520 | m_icon-> repaint ( !m_vol_muted ); // clear if removing mute | 503 | m_icon-> redraw ( true ); |
521 | 504 | ||
522 | writeConfigEntry ( "Mute", m_vol_muted, UPD_Vol ); | 505 | writeConfigEntry ( "Mute", m_vol_muted, UPD_Vol ); |
523 | } | 506 | } |
524 | 507 | ||
525 | void VolumeControl::micMuteToggled ( bool b ) | 508 | void VolumeControl::micMuteToggled ( bool b ) |
526 | { | 509 | { |
527 | m_mic_muted = !b; | 510 | m_mic_muted = !b; |
528 | writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); | 511 | writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); |
529 | } | 512 | } |
530 | 513 | ||
531 | 514 | ||
532 | void VolumeControl::volMoved ( int percent ) | 515 | void VolumeControl::volMoved ( int percent ) |
533 | { | 516 | { |
534 | m_vol_percent = 100 - percent; | 517 | m_vol_percent = 100 - percent; |
535 | 518 | ||
536 | // clamp volume percent to be between 0 and 100 | 519 | // clamp volume percent to be between 0 and 100 |
537 | m_vol_percent = ( m_vol_percent < 0 ) ? 0 : (( m_vol_percent > 100 ) ? 100 : m_vol_percent ); | 520 | m_vol_percent = ( m_vol_percent < 0 ) ? 0 : (( m_vol_percent > 100 ) ? 100 : m_vol_percent ); |
538 | // repaint just the little volume rectangle | 521 | // repaint just the little volume rectangle |
539 | repaint ( 2, height ( ) - 3, width ( ) - 4, 2, false ); | 522 | m_icon-> redraw ( false ); |
540 | 523 | ||
541 | writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_Vol ); | 524 | writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_Vol ); |
542 | } | 525 | } |
543 | 526 | ||
544 | void VolumeControl::micMoved ( int percent ) | 527 | void VolumeControl::micMoved ( int percent ) |
545 | { | 528 | { |
546 | m_mic_percent = 100 - percent; | 529 | m_mic_percent = 100 - percent; |
547 | 530 | ||
548 | // clamp volume percent to be between 0 and 100 | 531 | // clamp volume percent to be between 0 and 100 |
549 | m_mic_percent = ( m_mic_percent < 0 ) ? 0 : (( m_mic_percent > 100 ) ? 100 : m_mic_percent ); | 532 | m_mic_percent = ( m_mic_percent < 0 ) ? 0 : (( m_mic_percent > 100 ) ? 100 : m_mic_percent ); |
550 | 533 | ||
551 | writeConfigEntry ( "Mic", m_mic_percent, UPD_Mic ); | 534 | writeConfigEntry ( "Mic", m_mic_percent, UPD_Mic ); |
552 | } | 535 | } |
553 | 536 | ||
554 | void VolumeControl::alarmMoved ( int percent ) | 537 | void VolumeControl::alarmMoved ( int percent ) |
555 | { | 538 | { |
556 | m_alarm_percent = 100 - percent; | 539 | m_alarm_percent = 100 - percent; |
557 | 540 | ||
558 | // clamp volume percent to be between 0 and 100 | 541 | // clamp volume percent to be between 0 and 100 |
559 | m_alarm_percent = ( m_alarm_percent < 0 ) ? 0 : (( m_alarm_percent > 100 ) ? 100 : m_alarm_percent ); | 542 | m_alarm_percent = ( m_alarm_percent < 0 ) ? 0 : (( m_alarm_percent > 100 ) ? 100 : m_alarm_percent ); |
560 | 543 | ||
561 | writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); | 544 | writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); |
562 | } | 545 | } |
563 | 546 | ||
564 | 547 | ||
565 | void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd ) | 548 | void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd ) |
566 | { | 549 | { |
567 | Config cfg ( "qpe" ); | 550 | Config cfg ( "qpe" ); |
568 | cfg. setGroup ( "Volume" ); | 551 | cfg. setGroup ( "Volume" ); |
569 | cfg. writeEntry ( entry, val ); | 552 | cfg. writeEntry ( entry, val ); |
570 | // cfg. write ( ); | 553 | // cfg. write ( ); |
571 | 554 | ||
572 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) | 555 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) |
573 | switch ( upd ) { | 556 | switch ( upd ) { |
574 | case UPD_Vol: { | 557 | case UPD_Vol: { |
575 | QCopEnvelope ( "QPE/System", "volumeChange(bool)" ) << m_vol_muted; | 558 | QCopEnvelope ( "QPE/System", "volumeChange(bool)" ) << m_vol_muted; |
576 | break; | 559 | break; |
577 | } | 560 | } |
578 | case UPD_Mic: { | 561 | case UPD_Mic: { |
579 | QCopEnvelope ( "QPE/System", "micChange(bool)" ) << m_mic_muted; | 562 | QCopEnvelope ( "QPE/System", "micChange(bool)" ) << m_mic_muted; |
580 | break; | 563 | break; |
581 | } | 564 | } |
582 | case UPD_None: | 565 | case UPD_None: |
583 | break; | 566 | break; |
584 | } | 567 | } |
585 | #endif | 568 | #endif |
586 | } | 569 | } |
587 | 570 | ||
588 | //=========================================================================== | 571 | //=========================================================================== |
589 | 572 | ||
590 | VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) | 573 | VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) |
591 | : QWidget( parent, name ) | 574 | : QWidget( parent, name ) |
592 | { | 575 | { |
593 | setFixedHeight ( 18 ); | 576 | setFixedHeight ( 18 ); |
594 | setFixedWidth ( 14 ); | 577 | setFixedWidth ( 14 ); |
595 | 578 | ||
596 | m_pixmap = new QPixmap ( Resource::loadPixmap ( "volume" )); | 579 | m_pixmap = new QPixmap ( Resource::loadPixmap ( "volume" )); |
597 | m_dialog = new VolumeControl ( this ); | 580 | m_dialog = new VolumeControl ( this ); |
598 | 581 | ||
599 | connect ( qApp, SIGNAL( volumeChanged ( bool )), m_dialog, SLOT( volumeChanged( bool ))); | 582 | connect ( qApp, SIGNAL( volumeChanged ( bool )), m_dialog, SLOT( volumeChanged( bool ))); |
600 | connect ( qApp, SIGNAL( micChanged ( bool )), m_dialog, SLOT ( micChanged( bool ))); | 583 | connect ( qApp, SIGNAL( micChanged ( bool )), m_dialog, SLOT ( micChanged( bool ))); |
601 | } | 584 | } |
602 | 585 | ||
603 | VolumeApplet::~VolumeApplet() | 586 | VolumeApplet::~VolumeApplet() |
604 | { | 587 | { |
605 | delete m_pixmap; | 588 | delete m_pixmap; |
606 | } | 589 | } |
607 | 590 | ||
608 | 591 | ||
609 | void VolumeApplet::mousePressEvent ( QMouseEvent * ) | 592 | void VolumeApplet::mousePressEvent ( QMouseEvent * ) |
610 | { | 593 | { |
611 | if ( m_dialog-> isVisible ( )) | 594 | if ( m_dialog-> isVisible ( )) |
612 | m_dialog-> hide ( ); | 595 | m_dialog-> hide ( ); |
613 | else | 596 | else |
614 | m_dialog-> show ( true ); | 597 | m_dialog-> show ( true ); |
615 | } | 598 | } |
616 | 599 | ||
600 | void VolumeApplet::redraw ( bool all ) | ||
601 | { | ||
602 | if ( all ) | ||
603 | repaint ( true ); | ||
604 | else | ||
605 | repaint ( 2, height ( ) - 3, width ( ) - 4, 2, false ); | ||
606 | } | ||
607 | |||
617 | 608 | ||
618 | void VolumeApplet::paintEvent ( QPaintEvent * ) | 609 | void VolumeApplet::paintEvent ( QPaintEvent * ) |
619 | { | 610 | { |
620 | QPainter p ( this ); | 611 | QPainter p ( this ); |
621 | 612 | ||
622 | p. drawPixmap ( 0, 1, *m_pixmap ); | 613 | p. drawPixmap ( 0, 1, *m_pixmap ); |
623 | p. setPen ( darkGray ); | 614 | p. setPen ( darkGray ); |
624 | p. drawRect ( 1, height() - 4, width() - 2, 4 ); | 615 | p. drawRect ( 1, height() - 4, width() - 2, 4 ); |
625 | 616 | ||
626 | int pixelsWide = m_dialog-> volPercent ( ) * ( width() - 4 ) / 100; | 617 | int pixelsWide = m_dialog-> volPercent ( ) * ( width() - 4 ) / 100; |
627 | p. fillRect ( 2, height() - 3, pixelsWide, 2, red ); | 618 | p. fillRect ( 2, height() - 3, pixelsWide, 2, red ); |
628 | p. fillRect ( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray ); | 619 | p. fillRect ( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray ); |
629 | 620 | ||
630 | if ( m_dialog-> volMuted ( )) { | 621 | if ( m_dialog-> volMuted ( )) { |
631 | p. setPen ( red ); | 622 | p. setPen ( red ); |
632 | p. drawLine ( 1, 2, width() - 2, height() - 5 ); | 623 | p. drawLine ( 1, 2, width() - 2, height() - 5 ); |
633 | p. drawLine ( 1, 3, width() - 2, height() - 4 ); | 624 | p. drawLine ( 1, 3, width() - 2, height() - 4 ); |
634 | p. drawLine ( width() - 2, 2, 1, height() - 5 ); | 625 | p. drawLine ( width() - 2, 2, 1, height() - 5 ); |
635 | p. drawLine ( width() - 2, 3, 1, height() - 4 ); | 626 | p. drawLine ( width() - 2, 3, 1, height() - 4 ); |
636 | } | 627 | } |
637 | } | 628 | } |
638 | 629 | ||
639 | 630 | ||
diff --git a/core/applets/volumeapplet/volume.h b/core/applets/volumeapplet/volume.h index ff5c64a..4d988ac 100644 --- a/core/applets/volumeapplet/volume.h +++ b/core/applets/volumeapplet/volume.h | |||
@@ -17,108 +17,110 @@ | |||
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #ifndef __VOLUME_APPLET_H__ | 21 | #ifndef __VOLUME_APPLET_H__ |
22 | #define __VOLUME_APPLET_H__ | 22 | #define __VOLUME_APPLET_H__ |
23 | 23 | ||
24 | 24 | ||
25 | #include <qframe.h> | 25 | #include <qframe.h> |
26 | 26 | ||
27 | class QPixmap; | 27 | class QPixmap; |
28 | class QTimer; | 28 | class QTimer; |
29 | class QSlider; | 29 | class QSlider; |
30 | class QCheckBox; | 30 | class QCheckBox; |
31 | class QButton; | 31 | class QButton; |
32 | class OLedBox; | 32 | class OLedBox; |
33 | 33 | ||
34 | class VolumeApplet; | 34 | class VolumeApplet; |
35 | 35 | ||
36 | class VolumeControl : public QFrame { | 36 | class VolumeControl : public QFrame { |
37 | Q_OBJECT | 37 | Q_OBJECT |
38 | 38 | ||
39 | public: | 39 | public: |
40 | VolumeControl ( VolumeApplet *icon, bool showMic = false, QWidget *parent=0, const char *name=0 ); | 40 | VolumeControl ( VolumeApplet *icon, bool showMic = false, QWidget *parent=0, const char *name=0 ); |
41 | 41 | ||
42 | bool volMuted ( ) const; | 42 | bool volMuted ( ) const; |
43 | int volPercent ( ) const; | 43 | int volPercent ( ) const; |
44 | 44 | ||
45 | virtual void show ( bool showmic ); | 45 | virtual void show ( bool showmic ); |
46 | 46 | ||
47 | protected: | 47 | protected: |
48 | virtual void keyPressEvent ( QKeyEvent * e ); | 48 | virtual void keyPressEvent ( QKeyEvent * e ); |
49 | 49 | ||
50 | protected slots: | 50 | protected slots: |
51 | void volumeChanged ( bool muted ); | 51 | void volumeChanged ( bool muted ); |
52 | void micChanged ( bool muted ); | 52 | void micChanged ( bool muted ); |
53 | 53 | ||
54 | private slots: | 54 | private slots: |
55 | void volMoved ( int percent ); | 55 | void volMoved ( int percent ); |
56 | void micMoved ( int percent ); | 56 | void micMoved ( int percent ); |
57 | void alarmMoved ( int percent ); | 57 | void alarmMoved ( int percent ); |
58 | 58 | ||
59 | void volMuteToggled ( bool ); | 59 | void volMuteToggled ( bool ); |
60 | void micMuteToggled ( bool ); | 60 | void micMuteToggled ( bool ); |
61 | void alarmSoundToggled ( bool ); | 61 | void alarmSoundToggled ( bool ); |
62 | void keyClickToggled ( bool ); | 62 | void keyClickToggled ( bool ); |
63 | void screenTapToggled ( bool ); | 63 | void screenTapToggled ( bool ); |
64 | 64 | ||
65 | void buttonChanged ( ); | 65 | void buttonChanged ( ); |
66 | void rateTimerDone ( ); | 66 | void rateTimerDone ( ); |
67 | 67 | ||
68 | private: | 68 | private: |
69 | void readConfig ( bool force = false ); | 69 | void readConfig ( bool force = false ); |
70 | 70 | ||
71 | enum eUpdate { | 71 | enum eUpdate { |
72 | UPD_None, | 72 | UPD_None, |
73 | UPD_Vol, | 73 | UPD_Vol, |
74 | UPD_Mic | 74 | UPD_Mic |
75 | }; | 75 | }; |
76 | void writeConfigEntry ( const char *entry, int val, eUpdate upd ); | 76 | void writeConfigEntry ( const char *entry, int val, eUpdate upd ); |
77 | 77 | ||
78 | 78 | ||
79 | private: | 79 | private: |
80 | QSlider *volSlider; | 80 | QSlider *volSlider; |
81 | QSlider *micSlider; | 81 | QSlider *micSlider; |
82 | QSlider *alarmSlider; | 82 | QSlider *alarmSlider; |
83 | OLedBox *volLed; | 83 | OLedBox *volLed; |
84 | OLedBox *micLed; | 84 | OLedBox *micLed; |
85 | OLedBox *alarmLed; | 85 | OLedBox *alarmLed; |
86 | 86 | ||
87 | QCheckBox *alarmBox; | 87 | QCheckBox *alarmBox; |
88 | QCheckBox *tapBox; | 88 | QCheckBox *tapBox; |
89 | QCheckBox *keyBox; | 89 | QCheckBox *keyBox; |
90 | QPushButton *upButton; | 90 | QPushButton *upButton; |
91 | QPushButton *downButton; | 91 | QPushButton *downButton; |
92 | QTimer *rateTimer; | 92 | QTimer *rateTimer; |
93 | 93 | ||
94 | int m_vol_percent; | 94 | int m_vol_percent; |
95 | int m_mic_percent; | 95 | int m_mic_percent; |
96 | int m_alarm_percent; | 96 | int m_alarm_percent; |
97 | bool m_vol_muted; | 97 | bool m_vol_muted; |
98 | bool m_mic_muted; | 98 | bool m_mic_muted; |
99 | bool m_snd_alarm; | 99 | bool m_snd_alarm; |
100 | bool m_snd_touch; | 100 | bool m_snd_touch; |
101 | bool m_snd_key; | 101 | bool m_snd_key; |
102 | 102 | ||
103 | VolumeApplet *m_icon; | 103 | VolumeApplet *m_icon; |
104 | }; | 104 | }; |
105 | 105 | ||
106 | class VolumeApplet : public QWidget { | 106 | class VolumeApplet : public QWidget { |
107 | Q_OBJECT | 107 | Q_OBJECT |
108 | 108 | ||
109 | public: | 109 | public: |
110 | VolumeApplet ( QWidget *parent = 0, const char *name=0 ); | 110 | VolumeApplet ( QWidget *parent = 0, const char *name=0 ); |
111 | ~VolumeApplet ( ); | 111 | ~VolumeApplet ( ); |
112 | 112 | ||
113 | void redraw ( bool all = true ); | ||
114 | |||
113 | protected: | 115 | protected: |
114 | virtual void mousePressEvent ( QMouseEvent * ); | 116 | virtual void mousePressEvent ( QMouseEvent * ); |
115 | virtual void paintEvent ( QPaintEvent* ); | 117 | virtual void paintEvent ( QPaintEvent* ); |
116 | 118 | ||
117 | private: | 119 | private: |
118 | QPixmap * m_pixmap; | 120 | QPixmap * m_pixmap; |
119 | VolumeControl *m_dialog; | 121 | VolumeControl *m_dialog; |
120 | }; | 122 | }; |
121 | 123 | ||
122 | 124 | ||
123 | #endif // __VOLUME_APPLET_H__ | 125 | #endif // __VOLUME_APPLET_H__ |
124 | 126 | ||