-rw-r--r-- | core/multimedia/opieplayer/audiowidget.cpp | 3 |
1 files changed, 0 insertions, 3 deletions
diff --git a/core/multimedia/opieplayer/audiowidget.cpp b/core/multimedia/opieplayer/audiowidget.cpp index aa48961..ac8c935 100644 --- a/core/multimedia/opieplayer/audiowidget.cpp +++ b/core/multimedia/opieplayer/audiowidget.cpp | |||
@@ -183,188 +183,185 @@ void AudioWidget::updateSlider( long i, long max ) { | |||
183 | // Will flicker too much if we don't do this | 183 | // Will flicker too much if we don't do this |
184 | // Scale to something reasonable | 184 | // Scale to something reasonable |
185 | int width = slider->width(); | 185 | int width = slider->width(); |
186 | int val = int((double)i * width / max); | 186 | int val = int((double)i * width / max); |
187 | if ( !audioSliderBeingMoved ) { | 187 | if ( !audioSliderBeingMoved ) { |
188 | if ( slider->value() != val ) | 188 | if ( slider->value() != val ) |
189 | slider->setValue( val ); | 189 | slider->setValue( val ); |
190 | if ( slider->maxValue() != width ) | 190 | if ( slider->maxValue() != width ) |
191 | slider->setMaxValue( width ); | 191 | slider->setMaxValue( width ); |
192 | } | 192 | } |
193 | } | 193 | } |
194 | 194 | ||
195 | 195 | ||
196 | void AudioWidget::setToggleButton( int i, bool down ) { | 196 | void AudioWidget::setToggleButton( int i, bool down ) { |
197 | if ( down != audioButtons[i].isDown ) | 197 | if ( down != audioButtons[i].isDown ) |
198 | toggleButton( i ); | 198 | toggleButton( i ); |
199 | } | 199 | } |
200 | 200 | ||
201 | 201 | ||
202 | void AudioWidget::toggleButton( int i ) { | 202 | void AudioWidget::toggleButton( int i ) { |
203 | audioButtons[i].isDown = !audioButtons[i].isDown; | 203 | audioButtons[i].isDown = !audioButtons[i].isDown; |
204 | QPainter p(this); | 204 | QPainter p(this); |
205 | paintButton ( &p, i ); | 205 | paintButton ( &p, i ); |
206 | } | 206 | } |
207 | 207 | ||
208 | 208 | ||
209 | void AudioWidget::paintButton( QPainter *p, int i ) { | 209 | void AudioWidget::paintButton( QPainter *p, int i ) { |
210 | int x = audioButtons[i].xPos; | 210 | int x = audioButtons[i].xPos; |
211 | int y = audioButtons[i].yPos; | 211 | int y = audioButtons[i].yPos; |
212 | int offset = 22 + 14 * audioButtons[i].isBig + audioButtons[i].isDown; | 212 | int offset = 22 + 14 * audioButtons[i].isBig + audioButtons[i].isDown; |
213 | int buttonSize = 64 + audioButtons[i].isBig * (90 - 64); | 213 | int buttonSize = 64 + audioButtons[i].isBig * (90 - 64); |
214 | p->drawPixmap( x, y, *pixmaps[audioButtons[i].isBig], buttonSize * (audioButtons[i].isDown + 2 * audioButtons[i].color), 0, buttonSize, buttonSize ); | 214 | p->drawPixmap( x, y, *pixmaps[audioButtons[i].isBig], buttonSize * (audioButtons[i].isDown + 2 * audioButtons[i].color), 0, buttonSize, buttonSize ); |
215 | p->drawPixmap( x + offset, y + offset, *pixmaps[2], 18 * i, 0, 18, 18 ); | 215 | p->drawPixmap( x + offset, y + offset, *pixmaps[2], 18 * i, 0, 18, 18 ); |
216 | } | 216 | } |
217 | 217 | ||
218 | 218 | ||
219 | void AudioWidget::timerEvent( QTimerEvent * ) { | 219 | void AudioWidget::timerEvent( QTimerEvent * ) { |
220 | static int frame = 0; | 220 | static int frame = 0; |
221 | if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) { | 221 | if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) { |
222 | frame = frame >= 7 ? 0 : frame + 1; | 222 | frame = frame >= 7 ? 0 : frame + 1; |
223 | int x = audioButtons[AudioPlay].xPos; | 223 | int x = audioButtons[AudioPlay].xPos; |
224 | int y = audioButtons[AudioPlay].yPos; | 224 | int y = audioButtons[AudioPlay].yPos; |
225 | QPainter p( this ); | 225 | QPainter p( this ); |
226 | // Optimize to only draw the little bit of the changing images which is different | 226 | // Optimize to only draw the little bit of the changing images which is different |
227 | p.drawPixmap( x + 14, y + 8, *pixmaps[3], 32 * frame, 0, 32, 32 ); | 227 | p.drawPixmap( x + 14, y + 8, *pixmaps[3], 32 * frame, 0, 32, 32 ); |
228 | p.drawPixmap( x + 37, y + 37, *pixmaps[2], 18 * AudioPlay, 0, 6, 3 ); | 228 | p.drawPixmap( x + 37, y + 37, *pixmaps[2], 18 * AudioPlay, 0, 6, 3 ); |
229 | } | 229 | } |
230 | } | 230 | } |
231 | 231 | ||
232 | 232 | ||
233 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { | 233 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { |
234 | for ( int i = 0; i < numButtons; i++ ) { | 234 | for ( int i = 0; i < numButtons; i++ ) { |
235 | int size = audioButtons[i].isBig; | 235 | int size = audioButtons[i].isBig; |
236 | int x = audioButtons[i].xPos; | 236 | int x = audioButtons[i].xPos; |
237 | int y = audioButtons[i].yPos; | 237 | int y = audioButtons[i].yPos; |
238 | if ( event->state() == QMouseEvent::LeftButton ) { | 238 | if ( event->state() == QMouseEvent::LeftButton ) { |
239 | // The test to see if the mouse click is inside the circular button or not | 239 | // The test to see if the mouse click is inside the circular button or not |
240 | // (compared with the radius squared to avoid a square-root of our distance) | 240 | // (compared with the radius squared to avoid a square-root of our distance) |
241 | int radius = 32 + 13 * size; | 241 | int radius = 32 + 13 * size; |
242 | QPoint center = QPoint( x + radius, y + radius ); | 242 | QPoint center = QPoint( x + radius, y + radius ); |
243 | QPoint dXY = center - event->pos(); | 243 | QPoint dXY = center - event->pos(); |
244 | int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); | 244 | int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); |
245 | bool isOnButton = dist <= (radius * radius); | 245 | bool isOnButton = dist <= (radius * radius); |
246 | // QRect r( x, y, 64 + 22*size, 64 + 22*size ); | 246 | // QRect r( x, y, 64 + 22*size, 64 + 22*size ); |
247 | // bool isOnButton = r.contains( event->pos() ); // Rectangular Button code | 247 | // bool isOnButton = r.contains( event->pos() ); // Rectangular Button code |
248 | if ( isOnButton && !audioButtons[i].isHeld ) { | 248 | if ( isOnButton && !audioButtons[i].isHeld ) { |
249 | audioButtons[i].isHeld = TRUE; | 249 | audioButtons[i].isHeld = TRUE; |
250 | toggleButton(i); | 250 | toggleButton(i); |
251 | qDebug("button toggled1 %d",i); | 251 | qDebug("button toggled1 %d",i); |
252 | switch (i) { | 252 | switch (i) { |
253 | case AudioVolumeUp: emit moreClicked(); return; | 253 | case AudioVolumeUp: emit moreClicked(); return; |
254 | case AudioVolumeDown: emit lessClicked(); return; | 254 | case AudioVolumeDown: emit lessClicked(); return; |
255 | } | 255 | } |
256 | } else if ( !isOnButton && audioButtons[i].isHeld ) { | 256 | } else if ( !isOnButton && audioButtons[i].isHeld ) { |
257 | audioButtons[i].isHeld = FALSE; | 257 | audioButtons[i].isHeld = FALSE; |
258 | toggleButton(i); | 258 | toggleButton(i); |
259 | qDebug("button toggled2 %d",i); | 259 | qDebug("button toggled2 %d",i); |
260 | } | 260 | } |
261 | } else { | 261 | } else { |
262 | if ( audioButtons[i].isHeld ) { | 262 | if ( audioButtons[i].isHeld ) { |
263 | audioButtons[i].isHeld = FALSE; | 263 | audioButtons[i].isHeld = FALSE; |
264 | if ( !audioButtons[i].isToggle ) | 264 | if ( !audioButtons[i].isToggle ) |
265 | setToggleButton( i, FALSE ); | 265 | setToggleButton( i, FALSE ); |
266 | qDebug("button toggled3 %d",i); | 266 | qDebug("button toggled3 %d",i); |
267 | switch (i) { | 267 | switch (i) { |
268 | case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; | 268 | case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; |
269 | case AudioStop: mediaPlayerState->setPlaying(FALSE); return; | 269 | case AudioStop: mediaPlayerState->setPlaying(FALSE); return; |
270 | case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return; | 270 | case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return; |
271 | case AudioNext: mediaPlayerState->setNext(); return; | 271 | case AudioNext: mediaPlayerState->setNext(); return; |
272 | case AudioPrevious: mediaPlayerState->setPrev(); return; | 272 | case AudioPrevious: mediaPlayerState->setPrev(); return; |
273 | case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; | 273 | case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; |
274 | case AudioVolumeUp: emit moreReleased(); return; | 274 | case AudioVolumeUp: emit moreReleased(); return; |
275 | case AudioVolumeDown: emit lessReleased(); return; | 275 | case AudioVolumeDown: emit lessReleased(); return; |
276 | case AudioPlayList: mediaPlayerState->setList(); return; | 276 | case AudioPlayList: mediaPlayerState->setList(); return; |
277 | } | 277 | } |
278 | } | 278 | } |
279 | } | 279 | } |
280 | } | 280 | } |
281 | } | 281 | } |
282 | 282 | ||
283 | 283 | ||
284 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { | 284 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { |
285 | mouseMoveEvent( event ); | 285 | mouseMoveEvent( event ); |
286 | } | 286 | } |
287 | 287 | ||
288 | 288 | ||
289 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { | 289 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { |
290 | mouseMoveEvent( event ); | 290 | mouseMoveEvent( event ); |
291 | } | 291 | } |
292 | 292 | ||
293 | 293 | ||
294 | void AudioWidget::showEvent( QShowEvent* ) { | 294 | void AudioWidget::showEvent( QShowEvent* ) { |
295 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); | 295 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); |
296 | mouseMoveEvent( &event ); | 296 | mouseMoveEvent( &event ); |
297 | } | 297 | } |
298 | 298 | ||
299 | 299 | ||
300 | void AudioWidget::closeEvent( QCloseEvent* ) { | 300 | void AudioWidget::closeEvent( QCloseEvent* ) { |
301 | mediaPlayerState->setList(); | 301 | mediaPlayerState->setList(); |
302 | } | 302 | } |
303 | 303 | ||
304 | 304 | ||
305 | void AudioWidget::paintEvent( QPaintEvent * ) { | 305 | void AudioWidget::paintEvent( QPaintEvent * ) { |
306 | QPainter p( this ); | 306 | QPainter p( this ); |
307 | for ( int i = 0; i < numButtons; i++ ) | 307 | for ( int i = 0; i < numButtons; i++ ) |
308 | paintButton( &p, i ); | 308 | paintButton( &p, i ); |
309 | } | 309 | } |
310 | 310 | ||
311 | void AudioWidget::showMe() { | ||
312 | show(); | ||
313 | } | ||
314 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) | 311 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) |
315 | { | 312 | { |
316 | switch ( e->key() ) { | 313 | switch ( e->key() ) { |
317 | ////////////////////////////// Zaurus keys | 314 | ////////////////////////////// Zaurus keys |
318 | case Key_Home: | 315 | case Key_Home: |
319 | break; | 316 | break; |
320 | case Key_F9: //activity | 317 | case Key_F9: //activity |
321 | hide(); | 318 | hide(); |
322 | // qDebug("Audio F9"); | 319 | // qDebug("Audio F9"); |
323 | break; | 320 | break; |
324 | case Key_F10: //contacts | 321 | case Key_F10: //contacts |
325 | break; | 322 | break; |
326 | case Key_F11: //menu | 323 | case Key_F11: //menu |
327 | break; | 324 | break; |
328 | case Key_F12: //home | 325 | case Key_F12: //home |
329 | break; | 326 | break; |
330 | case Key_F13: //mail | 327 | case Key_F13: //mail |
331 | break; | 328 | break; |
332 | case Key_Space: { | 329 | case Key_Space: { |
333 | if(mediaPlayerState->playing()) { | 330 | if(mediaPlayerState->playing()) { |
334 | // toggleButton(1); | 331 | // toggleButton(1); |
335 | mediaPlayerState->setPlaying(FALSE); | 332 | mediaPlayerState->setPlaying(FALSE); |
336 | // toggleButton(1); | 333 | // toggleButton(1); |
337 | } else { | 334 | } else { |
338 | // toggleButton(0); | 335 | // toggleButton(0); |
339 | mediaPlayerState->setPlaying(TRUE); | 336 | mediaPlayerState->setPlaying(TRUE); |
340 | // toggleButton(0); | 337 | // toggleButton(0); |
341 | } | 338 | } |
342 | } | 339 | } |
343 | break; | 340 | break; |
344 | case Key_Down: | 341 | case Key_Down: |
345 | toggleButton(6); | 342 | toggleButton(6); |
346 | emit lessClicked(); | 343 | emit lessClicked(); |
347 | emit lessReleased(); | 344 | emit lessReleased(); |
348 | toggleButton(6); | 345 | toggleButton(6); |
349 | break; | 346 | break; |
350 | case Key_Up: | 347 | case Key_Up: |
351 | toggleButton(5); | 348 | toggleButton(5); |
352 | emit moreClicked(); | 349 | emit moreClicked(); |
353 | emit moreReleased(); | 350 | emit moreReleased(); |
354 | toggleButton(5); | 351 | toggleButton(5); |
355 | break; | 352 | break; |
356 | case Key_Right: | 353 | case Key_Right: |
357 | // toggleButton(3); | 354 | // toggleButton(3); |
358 | mediaPlayerState->setNext(); | 355 | mediaPlayerState->setNext(); |
359 | // toggleButton(3); | 356 | // toggleButton(3); |
360 | break; | 357 | break; |
361 | case Key_Left: | 358 | case Key_Left: |
362 | // toggleButton(4); | 359 | // toggleButton(4); |
363 | mediaPlayerState->setPrev(); | 360 | mediaPlayerState->setPrev(); |
364 | // toggleButton(4); | 361 | // toggleButton(4); |
365 | break; | 362 | break; |
366 | case Key_Escape: | 363 | case Key_Escape: |
367 | break; | 364 | break; |
368 | 365 | ||
369 | }; | 366 | }; |
370 | } | 367 | } |