summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-07-29 23:45:41 (UTC)
committer llornkcor <llornkcor>2002-07-29 23:45:41 (UTC)
commit0adb56cb2cd83e9933baa9776c77c4c637f93d04 (patch) (unidiff)
tree13cba758a845d0a7ec079924c8fd71fb1fa416dc
parent121002ebe4cdebd99fcba5ec833c1c7b05bb8892 (diff)
downloadopie-0adb56cb2cd83e9933baa9776c77c4c637f93d04.zip
opie-0adb56cb2cd83e9933baa9776c77c4c637f93d04.tar.gz
opie-0adb56cb2cd83e9933baa9776c77c4c637f93d04.tar.bz2
paintevent
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 1fae689..689366e 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -224,267 +224,267 @@ void AudioWidget::resizeEvent( QResizeEvent * ) {
224 for ( int i = 0; i < 11; i++ ) { 224 for ( int i = 0; i < 11; i++ ) {
225 if ( !masks[i]->isNull() ) { 225 if ( !masks[i]->isNull() ) {
226 delete buttonPixUp[i]; 226 delete buttonPixUp[i];
227 delete buttonPixDown[i]; 227 delete buttonPixDown[i];
228 buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] ); 228 buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] );
229 buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] ); 229 buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] );
230 } 230 }
231 } 231 }
232 232
233 delete pixUp; 233 delete pixUp;
234 delete pixDn; 234 delete pixDn;
235} 235}
236 236
237static bool audioSliderBeingMoved = FALSE; 237static bool audioSliderBeingMoved = FALSE;
238 238
239 239
240void AudioWidget::sliderPressed() { 240void AudioWidget::sliderPressed() {
241 audioSliderBeingMoved = TRUE; 241 audioSliderBeingMoved = TRUE;
242} 242}
243 243
244 244
245void AudioWidget::sliderReleased() { 245void AudioWidget::sliderReleased() {
246 audioSliderBeingMoved = FALSE; 246 audioSliderBeingMoved = FALSE;
247 if ( slider.width() == 0 ) 247 if ( slider.width() == 0 )
248 return; 248 return;
249 long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); 249 long val = long((double)slider.value() * mediaPlayerState->length() / slider.width());
250 mediaPlayerState->setPosition( val ); 250 mediaPlayerState->setPosition( val );
251} 251}
252 252
253void AudioWidget::setPosition( long i ) { 253void AudioWidget::setPosition( long i ) {
254 // qDebug("set position %d",i); 254 // qDebug("set position %d",i);
255 updateSlider( i, mediaPlayerState->length() ); 255 updateSlider( i, mediaPlayerState->length() );
256} 256}
257 257
258 258
259void AudioWidget::setLength( long max ) { 259void AudioWidget::setLength( long max ) {
260 updateSlider( mediaPlayerState->position(), max ); 260 updateSlider( mediaPlayerState->position(), max );
261} 261}
262 262
263 263
264void AudioWidget::setView( char view ) { 264void AudioWidget::setView( char view ) {
265 if (mediaPlayerState->streaming() ) { 265 if (mediaPlayerState->streaming() ) {
266 if( !slider.isHidden()) slider.hide(); 266 if( !slider.isHidden()) slider.hide();
267 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 267 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
268 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 268 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
269 } else { 269 } else {
270 // this stops the slider from being moved, thus 270 // this stops the slider from being moved, thus
271 // does not stop stream when it reaches the end 271 // does not stop stream when it reaches the end
272 slider.show(); 272 slider.show();
273 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 273 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
274 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 274 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
275 } 275 }
276 276
277 if ( view == 'a' ) { 277 if ( view == 'a' ) {
278 startTimer( 150 ); 278 startTimer( 150 );
279 showMaximized(); 279 showMaximized();
280 } else { 280 } else {
281 killTimers(); 281 killTimers();
282 hide(); 282 hide();
283 } 283 }
284} 284}
285 285
286 286
287static QString timeAsString( long length ) { 287static QString timeAsString( long length ) {
288 length /= 44100; 288 length /= 44100;
289 int minutes = length / 60; 289 int minutes = length / 60;
290 int seconds = length % 60; 290 int seconds = length % 60;
291 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); 291 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 );
292} 292}
293 293
294void AudioWidget::updateSlider( long i, long max ) { 294void AudioWidget::updateSlider( long i, long max ) {
295 time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); 295 time.setText( timeAsString( i ) + " / " + timeAsString( max ) );
296 if ( max == 0 ) { 296 if ( max == 0 ) {
297 return; 297 return;
298 } 298 }
299 // Will flicker too much if we don't do this 299 // Will flicker too much if we don't do this
300 // Scale to something reasonable 300 // Scale to something reasonable
301 int width = slider.width(); 301 int width = slider.width();
302 int val = int((double)i * width / max); 302 int val = int((double)i * width / max);
303 if ( !audioSliderBeingMoved ) { 303 if ( !audioSliderBeingMoved ) {
304 if ( slider.value() != val ) { 304 if ( slider.value() != val ) {
305 slider.setValue( val ); 305 slider.setValue( val );
306 } 306 }
307 307
308 if ( slider.maxValue() != width ) { 308 if ( slider.maxValue() != width ) {
309 slider.setMaxValue( width ); 309 slider.setMaxValue( width );
310 } 310 }
311 } 311 }
312} 312}
313 313
314 314
315void AudioWidget::setToggleButton( int i, bool down ) { 315void AudioWidget::setToggleButton( int i, bool down ) {
316 if ( down != audioButtons[i].isDown ) { 316 if ( down != audioButtons[i].isDown ) {
317 toggleButton( i ); 317 toggleButton( i );
318 } 318 }
319} 319}
320 320
321 321
322void AudioWidget::toggleButton( int i ) { 322void AudioWidget::toggleButton( int i ) {
323 audioButtons[i].isDown = !audioButtons[i].isDown; 323 audioButtons[i].isDown = !audioButtons[i].isDown;
324 QPainter p(this); 324 QPainter p(this);
325 paintButton ( &p, i ); 325 paintButton ( &p, i );
326} 326}
327 327
328 328
329void AudioWidget::paintButton( QPainter *p, int i ) { 329void AudioWidget::paintButton( QPainter *p, int i ) {
330 if ( audioButtons[i].isDown ) 330 if ( audioButtons[i].isDown )
331 p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); 331 p->drawPixmap( xoff, yoff, *buttonPixDown[i] );
332 else 332 else
333 p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); 333 p->drawPixmap( xoff, yoff, *buttonPixUp[i] );
334} 334}
335 335
336 336
337void AudioWidget::timerEvent( QTimerEvent * ) { 337void AudioWidget::timerEvent( QTimerEvent * ) {
338// static int frame = 0; 338// static int frame = 0;
339// if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) { 339// if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) {
340// frame = frame >= 7 ? 0 : frame + 1; 340// frame = frame >= 7 ? 0 : frame + 1;
341// } 341// }
342} 342}
343 343
344 344
345void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { 345void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
346 for ( int i = 0; i < numButtons; i++ ) { 346 for ( int i = 0; i < numButtons; i++ ) {
347 if ( event->state() == QMouseEvent::LeftButton ) { 347 if ( event->state() == QMouseEvent::LeftButton ) {
348 348
349 // The test to see if the mouse click is inside the button or not 349 // The test to see if the mouse click is inside the button or not
350 int x = event->pos().x() - xoff; 350 int x = event->pos().x() - xoff;
351 int y = event->pos().y() - yoff; 351 int y = event->pos().y() - yoff;
352 352
353 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() 353 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width()
354 && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 ); 354 && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 );
355 355
356 if ( isOnButton && i == AudioVolumeUp ) 356 if ( isOnButton && i == AudioVolumeUp )
357 qDebug("on up"); 357 qDebug("on up");
358 358
359 if ( isOnButton && !audioButtons[i].isHeld ) { 359 if ( isOnButton && !audioButtons[i].isHeld ) {
360 audioButtons[i].isHeld = TRUE; 360 audioButtons[i].isHeld = TRUE;
361 toggleButton(i); 361 toggleButton(i);
362 switch (i) { 362 switch (i) {
363 case AudioVolumeUp: 363 case AudioVolumeUp:
364 qDebug("more clicked"); 364 qDebug("more clicked");
365 emit moreClicked(); 365 emit moreClicked();
366 return; 366 return;
367 case AudioVolumeDown: emit lessClicked(); return; 367 case AudioVolumeDown: emit lessClicked(); return;
368 } 368 }
369 } else if ( !isOnButton && audioButtons[i].isHeld ) { 369 } else if ( !isOnButton && audioButtons[i].isHeld ) {
370 audioButtons[i].isHeld = FALSE; 370 audioButtons[i].isHeld = FALSE;
371 toggleButton(i); 371 toggleButton(i);
372 } 372 }
373 } else { 373 } else {
374 if ( audioButtons[i].isHeld ) { 374 if ( audioButtons[i].isHeld ) {
375 audioButtons[i].isHeld = FALSE; 375 audioButtons[i].isHeld = FALSE;
376 if ( !audioButtons[i].isToggle ) 376 if ( !audioButtons[i].isToggle )
377 setToggleButton( i, FALSE ); 377 setToggleButton( i, FALSE );
378 switch (i) { 378 switch (i) {
379 case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; 379 case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return;
380 case AudioStop: mediaPlayerState->setPlaying(FALSE); return; 380 case AudioStop: mediaPlayerState->setPlaying(FALSE); return;
381 case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return; 381 case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return;
382 case AudioNext: mediaPlayerState->setNext(); return; 382 case AudioNext: mediaPlayerState->setNext(); return;
383 case AudioPrevious: mediaPlayerState->setPrev(); return; 383 case AudioPrevious: mediaPlayerState->setPrev(); return;
384 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; 384 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return;
385 case AudioVolumeUp: emit moreReleased(); return; 385 case AudioVolumeUp: emit moreReleased(); return;
386 case AudioVolumeDown: emit lessReleased(); return; 386 case AudioVolumeDown: emit lessReleased(); return;
387 case AudioPlayList: mediaPlayerState->setList(); return; 387 case AudioPlayList: mediaPlayerState->setList(); return;
388 } 388 }
389 } 389 }
390 } 390 }
391 } 391 }
392} 392}
393 393
394 394
395void AudioWidget::mousePressEvent( QMouseEvent *event ) { 395void AudioWidget::mousePressEvent( QMouseEvent *event ) {
396 mouseMoveEvent( event ); 396 mouseMoveEvent( event );
397} 397}
398 398
399 399
400void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { 400void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) {
401 mouseMoveEvent( event ); 401 mouseMoveEvent( event );
402} 402}
403 403
404 404
405void AudioWidget::showEvent( QShowEvent* ) { 405void AudioWidget::showEvent( QShowEvent* ) {
406 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 406 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
407 mouseMoveEvent( &event ); 407 mouseMoveEvent( &event );
408} 408}
409 409
410 410
411void AudioWidget::closeEvent( QCloseEvent* ) { 411void AudioWidget::closeEvent( QCloseEvent* ) {
412 mediaPlayerState->setList(); 412 mediaPlayerState->setList();
413} 413}
414 414
415 415
416void AudioWidget::paintEvent( QPaintEvent * ) { 416void AudioWidget::paintEvent( QPaintEvent * pe) {
417 if ( !pe->erased() ) { 417 if ( !pe->erased() ) {
418 // Combine with background and double buffer 418 // Combine with background and double buffer
419 QPixmap pix( pe->rect().size() ); 419 QPixmap pix( pe->rect().size() );
420 QPainter p( &pix ); 420 QPainter p( &pix );
421 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 421 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
422 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); 422 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() );
423 for ( int i = 0; i < numButtons; i++ ) 423 for ( int i = 0; i < numButtons; i++ )
424 paintButton( &p, i ); 424 paintButton( &p, i );
425 QPainter p2( this ); 425 QPainter p2( this );
426 p2.drawPixmap( pe->rect().topLeft(), pix ); 426 p2.drawPixmap( pe->rect().topLeft(), pix );
427 } else { 427 } else {
428 QPainter p( this ); 428 QPainter p( this );
429 for ( int i = 0; i < numButtons; i++ ) 429 for ( int i = 0; i < numButtons; i++ )
430 paintButton( &p, i ); 430 paintButton( &p, i );
431 } 431 }
432} 432}
433 433
434void AudioWidget::keyReleaseEvent( QKeyEvent *e) 434void AudioWidget::keyReleaseEvent( QKeyEvent *e)
435{ 435{
436 switch ( e->key() ) { 436 switch ( e->key() ) {
437////////////////////////////// Zaurus keys 437////////////////////////////// Zaurus keys
438 case Key_Home: 438 case Key_Home:
439 break; 439 break;
440 case Key_F9: //activity 440 case Key_F9: //activity
441 hide(); 441 hide();
442// qDebug("Audio F9"); 442// qDebug("Audio F9");
443 break; 443 break;
444 case Key_F10: //contacts 444 case Key_F10: //contacts
445 break; 445 break;
446 case Key_F11: //menu 446 case Key_F11: //menu
447 break; 447 break;
448 case Key_F12: //home 448 case Key_F12: //home
449 break; 449 break;
450 case Key_F13: //mail 450 case Key_F13: //mail
451 break; 451 break;
452 case Key_Space: { 452 case Key_Space: {
453 if(mediaPlayerState->playing()) { 453 if(mediaPlayerState->playing()) {
454// toggleButton(1); 454// toggleButton(1);
455 mediaPlayerState->setPlaying(FALSE); 455 mediaPlayerState->setPlaying(FALSE);
456// toggleButton(1); 456// toggleButton(1);
457 } else { 457 } else {
458// toggleButton(0); 458// toggleButton(0);
459 mediaPlayerState->setPlaying(TRUE); 459 mediaPlayerState->setPlaying(TRUE);
460// toggleButton(0); 460// toggleButton(0);
461 } 461 }
462 } 462 }
463 break; 463 break;
464 case Key_Down: 464 case Key_Down:
465 toggleButton(6); 465 toggleButton(6);
466 emit lessClicked(); 466 emit lessClicked();
467 emit lessReleased(); 467 emit lessReleased();
468 toggleButton(6); 468 toggleButton(6);
469 break; 469 break;
470 case Key_Up: 470 case Key_Up:
471 toggleButton(5); 471 toggleButton(5);
472 emit moreClicked(); 472 emit moreClicked();
473 emit moreReleased(); 473 emit moreReleased();
474 toggleButton(5); 474 toggleButton(5);
475 break; 475 break;
476 case Key_Right: 476 case Key_Right:
477// toggleButton(3); 477// toggleButton(3);
478 mediaPlayerState->setNext(); 478 mediaPlayerState->setNext();
479// toggleButton(3); 479// toggleButton(3);
480 break; 480 break;
481 case Key_Left: 481 case Key_Left:
482// toggleButton(4); 482// toggleButton(4);
483 mediaPlayerState->setPrev(); 483 mediaPlayerState->setPrev();
484// toggleButton(4); 484// toggleButton(4);
485 break; 485 break;
486 case Key_Escape: 486 case Key_Escape:
487 break; 487 break;
488 488
489 }; 489 };
490} 490}