author | simon <simon> | 2002-12-08 22:20:24 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-08 22:20:24 (UTC) |
commit | 00252c667bf6c6af3f2a1d2519bf23e448e8f174 (patch) (unidiff) | |
tree | 4ecb004aa67d993561178b33cad2a6f0a9e85049 /noncore/multimedia/opieplayer2 | |
parent | 695398075ec5e4d01f29c40c00538ee8c60404d2 (diff) | |
download | opie-00252c667bf6c6af3f2a1d2519bf23e448e8f174.zip opie-00252c667bf6c6af3f2a1d2519bf23e448e8f174.tar.gz opie-00252c667bf6c6af3f2a1d2519bf23e448e8f174.tar.bz2 |
- share the buttons data in a buttons member variable in the base class
Diffstat (limited to 'noncore/multimedia/opieplayer2') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 50 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.h | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.h | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 42 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.h | 2 |
5 files changed, 48 insertions, 50 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index 7fb3781..a9d5a88 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp | |||
@@ -59,59 +59,59 @@ const int yo = 22; // movable y offset | |||
59 | const char * const skin_mask_file_names[10] = { | 59 | const char * const skin_mask_file_names[10] = { |
60 | "play", "stop", "next", "prev", "up", | 60 | "play", "stop", "next", "prev", "up", |
61 | "down", "loop", "playlist", "forward", "back" | 61 | "down", "loop", "playlist", "forward", "back" |
62 | }; | 62 | }; |
63 | 63 | ||
64 | void changeTextColor( QWidget * w) { | 64 | void changeTextColor( QWidget * w) { |
65 | QPalette p = w->palette(); | 65 | QPalette p = w->palette(); |
66 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); | 66 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); |
67 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); | 67 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); |
68 | w->setPalette( p ); | 68 | w->setPalette( p ); |
69 | } | 69 | } |
70 | 70 | ||
71 | } | 71 | } |
72 | 72 | ||
73 | AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : | 73 | AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : |
74 | 74 | ||
75 | MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { | 75 | MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { |
76 | 76 | ||
77 | Button defaultButton; | 77 | Button defaultButton; |
78 | defaultButton.isToggle = defaultButton.isHeld = defaultButton.isDown = false; | 78 | defaultButton.isToggle = defaultButton.isHeld = defaultButton.isDown = false; |
79 | Button toggleButton; | 79 | Button toggleButton; |
80 | toggleButton.isToggle = true; | 80 | toggleButton.isToggle = true; |
81 | toggleButton.isHeld = toggleButton.isDown = false; | 81 | toggleButton.isHeld = toggleButton.isDown = false; |
82 | 82 | ||
83 | audioButtons.reserve( 10 ); | 83 | buttons.reserve( 10 ); |
84 | audioButtons.push_back( toggleButton ); // play | 84 | buttons.push_back( toggleButton ); // play |
85 | audioButtons.push_back( defaultButton ); // stop | 85 | buttons.push_back( defaultButton ); // stop |
86 | audioButtons.push_back( defaultButton ); // next | 86 | buttons.push_back( defaultButton ); // next |
87 | audioButtons.push_back( defaultButton ); // previous | 87 | buttons.push_back( defaultButton ); // previous |
88 | audioButtons.push_back( defaultButton ); // volume up | 88 | buttons.push_back( defaultButton ); // volume up |
89 | audioButtons.push_back( defaultButton ); // volume down | 89 | buttons.push_back( defaultButton ); // volume down |
90 | audioButtons.push_back( toggleButton ); // repeat/loop | 90 | buttons.push_back( toggleButton ); // repeat/loop |
91 | audioButtons.push_back( defaultButton ); // playlist | 91 | buttons.push_back( defaultButton ); // playlist |
92 | audioButtons.push_back( defaultButton ); // forward | 92 | buttons.push_back( defaultButton ); // forward |
93 | audioButtons.push_back( defaultButton ); // back | 93 | buttons.push_back( defaultButton ); // back |
94 | 94 | ||
95 | setCaption( tr("OpiePlayer") ); | 95 | setCaption( tr("OpiePlayer") ); |
96 | 96 | ||
97 | Config cfg("OpiePlayer"); | 97 | Config cfg("OpiePlayer"); |
98 | cfg.setGroup("Options"); | 98 | cfg.setGroup("Options"); |
99 | skin = cfg.readEntry("Skin","default"); | 99 | skin = cfg.readEntry("Skin","default"); |
100 | //skin = "scaleTest"; | 100 | //skin = "scaleTest"; |
101 | // color of background, frame, degree of transparency | 101 | // color of background, frame, degree of transparency |
102 | 102 | ||
103 | QString skinPath = "opieplayer2/skins/" + skin; | 103 | QString skinPath = "opieplayer2/skins/" + skin; |
104 | pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 104 | pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
105 | imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); | 105 | imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); |
106 | imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); | 106 | imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); |
107 | 107 | ||
108 | imgButtonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); | 108 | imgButtonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); |
109 | imgButtonMask.fill( 0 ); | 109 | imgButtonMask.fill( 0 ); |
110 | 110 | ||
111 | for ( int i = 0; i < 10; i++ ) { | 111 | for ( int i = 0; i < 10; i++ ) { |
112 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png" ); | 112 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png" ); |
113 | masks[i] = new QBitmap( filename ); | 113 | masks[i] = new QBitmap( filename ); |
114 | 114 | ||
115 | if ( !masks[i]->isNull() ) { | 115 | if ( !masks[i]->isNull() ) { |
116 | QImage imgMask = masks[i]->convertToImage(); | 116 | QImage imgMask = masks[i]->convertToImage(); |
117 | uchar **dest = imgButtonMask.jumpTable(); | 117 | uchar **dest = imgButtonMask.jumpTable(); |
@@ -306,174 +306,174 @@ void AudioWidget::updateSlider( long i, long max ) { | |||
306 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); | 306 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); |
307 | // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; | 307 | // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; |
308 | 308 | ||
309 | if ( max == 0 ) { | 309 | if ( max == 0 ) { |
310 | return; | 310 | return; |
311 | } | 311 | } |
312 | // Will flicker too much if we don't do this | 312 | // Will flicker too much if we don't do this |
313 | // Scale to something reasonable | 313 | // Scale to something reasonable |
314 | int width = slider.width(); | 314 | int width = slider.width(); |
315 | int val = int((double)i * width / max); | 315 | int val = int((double)i * width / max); |
316 | if ( !audioSliderBeingMoved ) { | 316 | if ( !audioSliderBeingMoved ) { |
317 | if ( slider.value() != val ) { | 317 | if ( slider.value() != val ) { |
318 | slider.setValue( val ); | 318 | slider.setValue( val ); |
319 | } | 319 | } |
320 | 320 | ||
321 | if ( slider.maxValue() != width ) { | 321 | if ( slider.maxValue() != width ) { |
322 | slider.setMaxValue( width ); | 322 | slider.setMaxValue( width ); |
323 | } | 323 | } |
324 | } | 324 | } |
325 | } | 325 | } |
326 | 326 | ||
327 | 327 | ||
328 | void AudioWidget::setToggleButton( int i, bool down ) { | 328 | void AudioWidget::setToggleButton( int i, bool down ) { |
329 | qDebug("setToggleButton %d", i); | 329 | qDebug("setToggleButton %d", i); |
330 | if ( down != audioButtons[i].isDown ) { | 330 | if ( down != buttons[i].isDown ) { |
331 | toggleButton( i ); | 331 | toggleButton( i ); |
332 | } | 332 | } |
333 | } | 333 | } |
334 | 334 | ||
335 | 335 | ||
336 | void AudioWidget::toggleButton( int i ) { | 336 | void AudioWidget::toggleButton( int i ) { |
337 | audioButtons[i].isDown = !audioButtons[i].isDown; | 337 | buttons[i].isDown = !buttons[i].isDown; |
338 | QPainter p(this); | 338 | QPainter p(this); |
339 | paintButton ( &p, i ); | 339 | paintButton ( &p, i ); |
340 | } | 340 | } |
341 | 341 | ||
342 | 342 | ||
343 | void AudioWidget::paintButton( QPainter *p, int i ) { | 343 | void AudioWidget::paintButton( QPainter *p, int i ) { |
344 | if ( audioButtons[i].isDown ) { | 344 | if ( buttons[i].isDown ) { |
345 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); | 345 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); |
346 | } else { | 346 | } else { |
347 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); | 347 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); |
348 | } | 348 | } |
349 | } | 349 | } |
350 | 350 | ||
351 | 351 | ||
352 | void AudioWidget::skipFor() { | 352 | void AudioWidget::skipFor() { |
353 | skipDirection = +1; | 353 | skipDirection = +1; |
354 | startTimer( 50 ); | 354 | startTimer( 50 ); |
355 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); | 355 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); |
356 | } | 356 | } |
357 | 357 | ||
358 | void AudioWidget::skipBack() { | 358 | void AudioWidget::skipBack() { |
359 | skipDirection = -1; | 359 | skipDirection = -1; |
360 | startTimer( 50 ); | 360 | startTimer( 50 ); |
361 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); | 361 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); |
362 | } | 362 | } |
363 | 363 | ||
364 | 364 | ||
365 | 365 | ||
366 | void AudioWidget::stopSkip() { | 366 | void AudioWidget::stopSkip() { |
367 | killTimers(); | 367 | killTimers(); |
368 | } | 368 | } |
369 | 369 | ||
370 | 370 | ||
371 | void AudioWidget::timerEvent( QTimerEvent * ) { | 371 | void AudioWidget::timerEvent( QTimerEvent * ) { |
372 | if ( skipDirection == +1 ) { | 372 | if ( skipDirection == +1 ) { |
373 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); | 373 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); |
374 | } else if ( skipDirection == -1 ) { | 374 | } else if ( skipDirection == -1 ) { |
375 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); | 375 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); |
376 | } | 376 | } |
377 | } | 377 | } |
378 | 378 | ||
379 | 379 | ||
380 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { | 380 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { |
381 | for ( unsigned int i = 0; i < audioButtons.size(); i++ ) { | 381 | for ( unsigned int i = 0; i < buttons.size(); i++ ) { |
382 | if ( event->state() == QMouseEvent::LeftButton ) { | 382 | if ( event->state() == QMouseEvent::LeftButton ) { |
383 | // The test to see if the mouse click is inside the button or not | 383 | // The test to see if the mouse click is inside the button or not |
384 | int x = event->pos().x() - xoff; | 384 | int x = event->pos().x() - xoff; |
385 | int y = event->pos().y() - yoff; | 385 | int y = event->pos().y() - yoff; |
386 | 386 | ||
387 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask.width() | 387 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask.width() |
388 | && y < imgButtonMask.height() | 388 | && y < imgButtonMask.height() |
389 | && imgButtonMask.pixelIndex( x, y ) == i + 1 ); | 389 | && imgButtonMask.pixelIndex( x, y ) == i + 1 ); |
390 | 390 | ||
391 | if ( isOnButton && !audioButtons[i].isHeld ) { | 391 | if ( isOnButton && !buttons[i].isHeld ) { |
392 | audioButtons[i].isHeld = TRUE; | 392 | buttons[i].isHeld = TRUE; |
393 | toggleButton(i); | 393 | toggleButton(i); |
394 | switch (i) { | 394 | switch (i) { |
395 | case VolumeUp: | 395 | case VolumeUp: |
396 | emit moreClicked(); | 396 | emit moreClicked(); |
397 | return; | 397 | return; |
398 | case VolumeDown: | 398 | case VolumeDown: |
399 | emit lessClicked(); | 399 | emit lessClicked(); |
400 | return; | 400 | return; |
401 | case Forward: | 401 | case Forward: |
402 | emit forwardClicked(); | 402 | emit forwardClicked(); |
403 | return; | 403 | return; |
404 | case Back: | 404 | case Back: |
405 | emit backClicked(); | 405 | emit backClicked(); |
406 | return; | 406 | return; |
407 | } | 407 | } |
408 | } else if ( !isOnButton && audioButtons[i].isHeld ) { | 408 | } else if ( !isOnButton && buttons[i].isHeld ) { |
409 | audioButtons[i].isHeld = FALSE; | 409 | buttons[i].isHeld = FALSE; |
410 | toggleButton(i); | 410 | toggleButton(i); |
411 | } | 411 | } |
412 | } else { | 412 | } else { |
413 | if ( audioButtons[i].isHeld ) { | 413 | if ( buttons[i].isHeld ) { |
414 | audioButtons[i].isHeld = FALSE; | 414 | buttons[i].isHeld = FALSE; |
415 | if ( !audioButtons[i].isToggle ) { | 415 | if ( !buttons[i].isToggle ) { |
416 | setToggleButton( i, FALSE ); | 416 | setToggleButton( i, FALSE ); |
417 | } | 417 | } |
418 | qDebug("mouseEvent %d", i); | 418 | qDebug("mouseEvent %d", i); |
419 | handleCommand( static_cast<Command>( i ), audioButtons[ i ].isDown ); | 419 | handleCommand( static_cast<Command>( i ), buttons[ i ].isDown ); |
420 | } | 420 | } |
421 | } | 421 | } |
422 | } | 422 | } |
423 | } | 423 | } |
424 | 424 | ||
425 | 425 | ||
426 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { | 426 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { |
427 | mouseMoveEvent( event ); | 427 | mouseMoveEvent( event ); |
428 | } | 428 | } |
429 | 429 | ||
430 | 430 | ||
431 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { | 431 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { |
432 | mouseMoveEvent( event ); | 432 | mouseMoveEvent( event ); |
433 | } | 433 | } |
434 | 434 | ||
435 | 435 | ||
436 | void AudioWidget::showEvent( QShowEvent* ) { | 436 | void AudioWidget::showEvent( QShowEvent* ) { |
437 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); | 437 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); |
438 | mouseMoveEvent( &event ); | 438 | mouseMoveEvent( &event ); |
439 | } | 439 | } |
440 | 440 | ||
441 | 441 | ||
442 | void AudioWidget::paintEvent( QPaintEvent * pe ) { | 442 | void AudioWidget::paintEvent( QPaintEvent * pe ) { |
443 | if ( !pe->erased() ) { | 443 | if ( !pe->erased() ) { |
444 | // Combine with background and double buffer | 444 | // Combine with background and double buffer |
445 | QPixmap pix( pe->rect().size() ); | 445 | QPixmap pix( pe->rect().size() ); |
446 | QPainter p( &pix ); | 446 | QPainter p( &pix ); |
447 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | 447 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); |
448 | p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() ); | 448 | p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() ); |
449 | for ( unsigned int i = 0; i < audioButtons.size(); i++ ) | 449 | for ( unsigned int i = 0; i < buttons.size(); i++ ) |
450 | paintButton( &p, i ); | 450 | paintButton( &p, i ); |
451 | QPainter p2( this ); | 451 | QPainter p2( this ); |
452 | p2.drawPixmap( pe->rect().topLeft(), pix ); | 452 | p2.drawPixmap( pe->rect().topLeft(), pix ); |
453 | } else { | 453 | } else { |
454 | QPainter p( this ); | 454 | QPainter p( this ); |
455 | for ( unsigned int i = 0; i < audioButtons.size(); i++ ) | 455 | for ( unsigned int i = 0; i < buttons.size(); i++ ) |
456 | paintButton( &p, i ); | 456 | paintButton( &p, i ); |
457 | } | 457 | } |
458 | } | 458 | } |
459 | 459 | ||
460 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { | 460 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { |
461 | switch ( e->key() ) { | 461 | switch ( e->key() ) { |
462 | ////////////////////////////// Zaurus keys | 462 | ////////////////////////////// Zaurus keys |
463 | case Key_Home: | 463 | case Key_Home: |
464 | break; | 464 | break; |
465 | case Key_F9: //activity | 465 | case Key_F9: //activity |
466 | hide(); | 466 | hide(); |
467 | // qDebug("Audio F9"); | 467 | // qDebug("Audio F9"); |
468 | break; | 468 | break; |
469 | case Key_F10: //contacts | 469 | case Key_F10: //contacts |
470 | break; | 470 | break; |
471 | case Key_F11: //menu | 471 | case Key_F11: //menu |
472 | mediaPlayerState.toggleBlank(); | 472 | mediaPlayerState.toggleBlank(); |
473 | break; | 473 | break; |
474 | case Key_F12: //home | 474 | case Key_F12: //home |
475 | break; | 475 | break; |
476 | case Key_F13: //mail | 476 | case Key_F13: //mail |
477 | mediaPlayerState.toggleBlank(); | 477 | mediaPlayerState.toggleBlank(); |
478 | break; | 478 | break; |
479 | case Key_Space: { | 479 | case Key_Space: { |
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h index e09c5f8..52a358c 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.h +++ b/noncore/multimedia/opieplayer2/audiowidget.h | |||
@@ -89,31 +89,29 @@ protected: | |||
89 | private slots: | 89 | private slots: |
90 | void skipFor(); | 90 | void skipFor(); |
91 | void skipBack(); | 91 | void skipBack(); |
92 | void stopSkip(); | 92 | void stopSkip(); |
93 | private: | 93 | private: |
94 | void toggleButton( int ); | 94 | void toggleButton( int ); |
95 | void setToggleButton( int, bool ); | 95 | void setToggleButton( int, bool ); |
96 | void paintButton( QPainter *p, int i ); | 96 | void paintButton( QPainter *p, int i ); |
97 | int skipDirection; | 97 | int skipDirection; |
98 | QString skin; | 98 | QString skin; |
99 | QPixmap pixBg; | 99 | QPixmap pixBg; |
100 | QImage imgUp; | 100 | QImage imgUp; |
101 | QImage imgDn; | 101 | QImage imgDn; |
102 | QImage imgButtonMask; | 102 | QImage imgButtonMask; |
103 | QBitmap *masks[10]; | 103 | QBitmap *masks[10]; |
104 | QPixmap *buttonPixUp[10]; | 104 | QPixmap *buttonPixUp[10]; |
105 | QPixmap *buttonPixDown[10]; | 105 | QPixmap *buttonPixDown[10]; |
106 | 106 | ||
107 | QPixmap *pixmaps[4]; | 107 | QPixmap *pixmaps[4]; |
108 | OTicker songInfo; | 108 | OTicker songInfo; |
109 | QSlider slider; | 109 | QSlider slider; |
110 | QLineEdit time; | 110 | QLineEdit time; |
111 | int xoff, yoff; | 111 | int xoff, yoff; |
112 | bool isStreaming : 1; | 112 | bool isStreaming : 1; |
113 | |||
114 | ButtonVector audioButtons; | ||
115 | }; | 113 | }; |
116 | 114 | ||
117 | 115 | ||
118 | #endif // AUDIO_WIDGET_H | 116 | #endif // AUDIO_WIDGET_H |
119 | 117 | ||
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h index c81768c..b88d7e2 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.h +++ b/noncore/multimedia/opieplayer2/mediawidget.h | |||
@@ -46,29 +46,31 @@ public: | |||
46 | }; | 46 | }; |
47 | typedef std::vector<Button> ButtonVector; | 47 | typedef std::vector<Button> ButtonVector; |
48 | 48 | ||
49 | MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 ); | 49 | MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 ); |
50 | virtual ~MediaWidget(); | 50 | virtual ~MediaWidget(); |
51 | 51 | ||
52 | public slots: | 52 | public slots: |
53 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0; | 53 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0; |
54 | virtual void setLength( long length ) = 0; | 54 | virtual void setLength( long length ) = 0; |
55 | virtual void setPlaying( bool playing ) = 0; | 55 | virtual void setPlaying( bool playing ) = 0; |
56 | 56 | ||
57 | signals: | 57 | signals: |
58 | void moreReleased(); | 58 | void moreReleased(); |
59 | void lessReleased(); | 59 | void lessReleased(); |
60 | void forwardReleased(); | 60 | void forwardReleased(); |
61 | void backReleased(); | 61 | void backReleased(); |
62 | 62 | ||
63 | protected: | 63 | protected: |
64 | virtual void closeEvent( QCloseEvent * ); | 64 | virtual void closeEvent( QCloseEvent * ); |
65 | 65 | ||
66 | void handleCommand( Command command, bool buttonDown ); | 66 | void handleCommand( Command command, bool buttonDown ); |
67 | 67 | ||
68 | MediaPlayerState &mediaPlayerState; | 68 | MediaPlayerState &mediaPlayerState; |
69 | PlayListWidget &playList; | 69 | PlayListWidget &playList; |
70 | |||
71 | ButtonVector buttons; | ||
70 | }; | 72 | }; |
71 | 73 | ||
72 | #endif // MEDIAWIDGET_H | 74 | #endif // MEDIAWIDGET_H |
73 | /* vim: et sw=4 ts=4 | 75 | /* vim: et sw=4 ts=4 |
74 | */ | 76 | */ |
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index 6e2e03e..7838229 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp | |||
@@ -55,56 +55,56 @@ | |||
55 | 55 | ||
56 | namespace | 56 | namespace |
57 | { | 57 | { |
58 | 58 | ||
59 | const int xo = 2; // movable x offset | 59 | const int xo = 2; // movable x offset |
60 | const int yo = 0; // movable y offset | 60 | const int yo = 0; // movable y offset |
61 | 61 | ||
62 | const char * const skinV_mask_file_names[7] = { | 62 | const char * const skinV_mask_file_names[7] = { |
63 | "stop","play","back","fwd","up","down","full" | 63 | "stop","play","back","fwd","up","down","full" |
64 | }; | 64 | }; |
65 | 65 | ||
66 | } | 66 | } |
67 | 67 | ||
68 | VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) | 68 | VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) |
69 | : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ) | 69 | : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ) |
70 | { | 70 | { |
71 | setCaption( tr("OpiePlayer - Video") ); | 71 | setCaption( tr("OpiePlayer - Video") ); |
72 | 72 | ||
73 | Button defaultButton; | 73 | Button defaultButton; |
74 | defaultButton.isToggle = defaultButton.isHeld = defaultButton.isDown = false; | 74 | defaultButton.isToggle = defaultButton.isHeld = defaultButton.isDown = false; |
75 | Button toggleButton; | 75 | Button toggleButton; |
76 | toggleButton.isToggle = true; | 76 | toggleButton.isToggle = true; |
77 | toggleButton.isHeld = toggleButton.isDown = false; | 77 | toggleButton.isHeld = toggleButton.isDown = false; |
78 | 78 | ||
79 | videoButtons.reserve( 7 ); | 79 | buttons.reserve( 7 ); |
80 | videoButtons.push_back( defaultButton ); // stop | 80 | buttons.push_back( defaultButton ); // stop |
81 | videoButtons.push_back( toggleButton ); // play | 81 | buttons.push_back( toggleButton ); // play |
82 | videoButtons.push_back( defaultButton ); // previous | 82 | buttons.push_back( defaultButton ); // previous |
83 | videoButtons.push_back( defaultButton ); // next | 83 | buttons.push_back( defaultButton ); // next |
84 | videoButtons.push_back( defaultButton ); // volUp | 84 | buttons.push_back( defaultButton ); // volUp |
85 | videoButtons.push_back( defaultButton ); // volDown | 85 | buttons.push_back( defaultButton ); // volDown |
86 | videoButtons.push_back( toggleButton ); //fullscreen | 86 | buttons.push_back( toggleButton ); //fullscreen |
87 | 87 | ||
88 | videoFrame = new XineVideoWidget ( this, "Video frame" ); | 88 | videoFrame = new XineVideoWidget ( this, "Video frame" ); |
89 | 89 | ||
90 | connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); | 90 | connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); |
91 | connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); | 91 | connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); |
92 | 92 | ||
93 | Config cfg("OpiePlayer"); | 93 | Config cfg("OpiePlayer"); |
94 | cfg.setGroup("Options"); | 94 | cfg.setGroup("Options"); |
95 | skin = cfg.readEntry("Skin","default"); | 95 | skin = cfg.readEntry("Skin","default"); |
96 | 96 | ||
97 | QString skinPath = "opieplayer2/skins/" + skin; | 97 | QString skinPath = "opieplayer2/skins/" + skin; |
98 | pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 98 | pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
99 | imgUp = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); | 99 | imgUp = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); |
100 | imgDn = QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); | 100 | imgDn = QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); |
101 | 101 | ||
102 | imgButtonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); | 102 | imgButtonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); |
103 | imgButtonMask.fill( 0 ); | 103 | imgButtonMask.fill( 0 ); |
104 | 104 | ||
105 | for ( int i = 0; i < 7; i++ ) { | 105 | for ( int i = 0; i < 7; i++ ) { |
106 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); | 106 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); |
107 | masks[i] = new QBitmap( filename ); | 107 | masks[i] = new QBitmap( filename ); |
108 | 108 | ||
109 | if ( !masks[i]->isNull() ) { | 109 | if ( !masks[i]->isNull() ) { |
110 | QImage imgMask = masks[i]->convertToImage(); | 110 | QImage imgMask = masks[i]->convertToImage(); |
@@ -237,100 +237,100 @@ void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) | |||
237 | // Effectively blank the view next time we show it so it looks nicer | 237 | // Effectively blank the view next time we show it so it looks nicer |
238 | scaledWidth = 0; | 238 | scaledWidth = 0; |
239 | scaledHeight = 0; | 239 | scaledHeight = 0; |
240 | hide(); | 240 | hide(); |
241 | } | 241 | } |
242 | 242 | ||
243 | void VideoWidget::updateSlider( long i, long max ) { | 243 | void VideoWidget::updateSlider( long i, long max ) { |
244 | // Will flicker too much if we don't do this | 244 | // Will flicker too much if we don't do this |
245 | if ( max == 0 ) { | 245 | if ( max == 0 ) { |
246 | return; | 246 | return; |
247 | } | 247 | } |
248 | int width = slider->width(); | 248 | int width = slider->width(); |
249 | int val = int((double)i * width / max); | 249 | int val = int((double)i * width / max); |
250 | if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { | 250 | if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { |
251 | if ( slider->value() != val ) { | 251 | if ( slider->value() != val ) { |
252 | slider->setValue( val ); | 252 | slider->setValue( val ); |
253 | } | 253 | } |
254 | if ( slider->maxValue() != width ) { | 254 | if ( slider->maxValue() != width ) { |
255 | slider->setMaxValue( width ); | 255 | slider->setMaxValue( width ); |
256 | } | 256 | } |
257 | } | 257 | } |
258 | } | 258 | } |
259 | 259 | ||
260 | void VideoWidget::setToggleButton( int i, bool down ) { | 260 | void VideoWidget::setToggleButton( int i, bool down ) { |
261 | if ( down != videoButtons[i].isDown ) { | 261 | if ( down != buttons[i].isDown ) { |
262 | toggleButton( i ); | 262 | toggleButton( i ); |
263 | } | 263 | } |
264 | } | 264 | } |
265 | 265 | ||
266 | void VideoWidget::toggleButton( int i ) { | 266 | void VideoWidget::toggleButton( int i ) { |
267 | videoButtons[i].isDown = !videoButtons[i].isDown; | 267 | buttons[i].isDown = !buttons[i].isDown; |
268 | QPainter p(this); | 268 | QPainter p(this); |
269 | paintButton ( &p, i ); | 269 | paintButton ( &p, i ); |
270 | } | 270 | } |
271 | 271 | ||
272 | void VideoWidget::paintButton( QPainter *p, int i ) { | 272 | void VideoWidget::paintButton( QPainter *p, int i ) { |
273 | 273 | ||
274 | if ( videoButtons[i].isDown ) { | 274 | if ( buttons[i].isDown ) { |
275 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); | 275 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); |
276 | } else { | 276 | } else { |
277 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); | 277 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); |
278 | } | 278 | } |
279 | } | 279 | } |
280 | 280 | ||
281 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | 281 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { |
282 | for ( unsigned int i = 0; i < videoButtons.size(); i++ ) { | 282 | for ( unsigned int i = 0; i < buttons.size(); i++ ) { |
283 | if ( event->state() == QMouseEvent::LeftButton ) { | 283 | if ( event->state() == QMouseEvent::LeftButton ) { |
284 | // The test to see if the mouse click is inside the button or not | 284 | // The test to see if the mouse click is inside the button or not |
285 | int x = event->pos().x() - xoff; | 285 | int x = event->pos().x() - xoff; |
286 | int y = event->pos().y() - yoff; | 286 | int y = event->pos().y() - yoff; |
287 | 287 | ||
288 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask.width() | 288 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask.width() |
289 | && y < imgButtonMask.height() | 289 | && y < imgButtonMask.height() |
290 | && imgButtonMask.pixelIndex( x, y ) == i + 1 ); | 290 | && imgButtonMask.pixelIndex( x, y ) == i + 1 ); |
291 | 291 | ||
292 | if ( isOnButton && !videoButtons[i].isHeld ) { | 292 | if ( isOnButton && !buttons[i].isHeld ) { |
293 | videoButtons[i].isHeld = TRUE; | 293 | buttons[i].isHeld = TRUE; |
294 | toggleButton(i); | 294 | toggleButton(i); |
295 | 295 | ||
296 | switch (i) { | 296 | switch (i) { |
297 | case VideoVolUp: | 297 | case VideoVolUp: |
298 | emit moreClicked(); | 298 | emit moreClicked(); |
299 | return; | 299 | return; |
300 | case VideoVolDown: | 300 | case VideoVolDown: |
301 | emit lessClicked(); | 301 | emit lessClicked(); |
302 | return; | 302 | return; |
303 | } | 303 | } |
304 | } else if ( !isOnButton && videoButtons[i].isHeld ) { | 304 | } else if ( !isOnButton && buttons[i].isHeld ) { |
305 | videoButtons[i].isHeld = FALSE; | 305 | buttons[i].isHeld = FALSE; |
306 | toggleButton(i); | 306 | toggleButton(i); |
307 | } | 307 | } |
308 | } else { | 308 | } else { |
309 | 309 | ||
310 | if ( videoButtons[i].isHeld ) { | 310 | if ( buttons[i].isHeld ) { |
311 | videoButtons[i].isHeld = FALSE; | 311 | buttons[i].isHeld = FALSE; |
312 | if ( !videoButtons[i].isToggle ) { | 312 | if ( !buttons[i].isToggle ) { |
313 | setToggleButton( i, FALSE ); | 313 | setToggleButton( i, FALSE ); |
314 | } | 314 | } |
315 | 315 | ||
316 | switch(i) { | 316 | switch(i) { |
317 | 317 | ||
318 | case VideoPlay: { | 318 | case VideoPlay: { |
319 | if( mediaPlayerState.isPaused() ) { | 319 | if( mediaPlayerState.isPaused() ) { |
320 | setToggleButton( i, FALSE ); | 320 | setToggleButton( i, FALSE ); |
321 | mediaPlayerState.setPaused( FALSE ); | 321 | mediaPlayerState.setPaused( FALSE ); |
322 | return; | 322 | return; |
323 | } else if( !mediaPlayerState.isPaused() ) { | 323 | } else if( !mediaPlayerState.isPaused() ) { |
324 | setToggleButton( i, TRUE ); | 324 | setToggleButton( i, TRUE ); |
325 | mediaPlayerState.setPaused( TRUE ); | 325 | mediaPlayerState.setPaused( TRUE ); |
326 | return; | 326 | return; |
327 | } else { | 327 | } else { |
328 | return; | 328 | return; |
329 | } | 329 | } |
330 | } | 330 | } |
331 | 331 | ||
332 | case VideoStop: mediaPlayerState.setPlaying( FALSE ); return; | 332 | case VideoStop: mediaPlayerState.setPlaying( FALSE ); return; |
333 | case VideoNext: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; | 333 | case VideoNext: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; |
334 | case VideoPrevious: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; | 334 | case VideoPrevious: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; |
335 | case VideoVolUp: emit moreReleased(); return; | 335 | case VideoVolUp: emit moreReleased(); return; |
336 | case VideoVolDown: emit lessReleased(); return; | 336 | case VideoVolDown: emit lessReleased(); return; |
@@ -405,56 +405,56 @@ void VideoWidget::makeVisible() { | |||
405 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 405 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
406 | connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 406 | connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
407 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 407 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
408 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 408 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
409 | } | 409 | } |
410 | } | 410 | } |
411 | } | 411 | } |
412 | 412 | ||
413 | 413 | ||
414 | 414 | ||
415 | 415 | ||
416 | void VideoWidget::paintEvent( QPaintEvent * pe) { | 416 | void VideoWidget::paintEvent( QPaintEvent * pe) { |
417 | QPainter p( this ); | 417 | QPainter p( this ); |
418 | 418 | ||
419 | if ( mediaPlayerState.isFullscreen() ) { | 419 | if ( mediaPlayerState.isFullscreen() ) { |
420 | // Clear the background | 420 | // Clear the background |
421 | p.setBrush( QBrush( Qt::black ) ); | 421 | p.setBrush( QBrush( Qt::black ) ); |
422 | } else { | 422 | } else { |
423 | if ( !pe->erased() ) { | 423 | if ( !pe->erased() ) { |
424 | // Combine with background and double buffer | 424 | // Combine with background and double buffer |
425 | QPixmap pix( pe->rect().size() ); | 425 | QPixmap pix( pe->rect().size() ); |
426 | QPainter p( &pix ); | 426 | QPainter p( &pix ); |
427 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | 427 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); |
428 | p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() ); | 428 | p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() ); |
429 | for ( unsigned int i = 0; i < videoButtons.size(); i++ ) { | 429 | for ( unsigned int i = 0; i < buttons.size(); i++ ) { |
430 | paintButton( &p, i ); | 430 | paintButton( &p, i ); |
431 | } | 431 | } |
432 | QPainter p2( this ); | 432 | QPainter p2( this ); |
433 | p2.drawPixmap( pe->rect().topLeft(), pix ); | 433 | p2.drawPixmap( pe->rect().topLeft(), pix ); |
434 | } else { | 434 | } else { |
435 | QPainter p( this ); | 435 | QPainter p( this ); |
436 | for ( unsigned int i = 0; i < videoButtons.size(); i++ ) | 436 | for ( unsigned int i = 0; i < buttons.size(); i++ ) |
437 | paintButton( &p, i ); | 437 | paintButton( &p, i ); |
438 | } | 438 | } |
439 | //slider->repaint( TRUE ); | 439 | //slider->repaint( TRUE ); |
440 | } | 440 | } |
441 | } | 441 | } |
442 | 442 | ||
443 | 443 | ||
444 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { | 444 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { |
445 | switch ( e->key() ) { | 445 | switch ( e->key() ) { |
446 | ////////////////////////////// Zaurus keys | 446 | ////////////////////////////// Zaurus keys |
447 | case Key_Home: | 447 | case Key_Home: |
448 | break; | 448 | break; |
449 | case Key_F9: //activity | 449 | case Key_F9: //activity |
450 | break; | 450 | break; |
451 | case Key_F10: //contacts | 451 | case Key_F10: //contacts |
452 | // hide(); | 452 | // hide(); |
453 | break; | 453 | break; |
454 | case Key_F11: //menu | 454 | case Key_F11: //menu |
455 | break; | 455 | break; |
456 | case Key_F12: //home | 456 | case Key_F12: //home |
457 | break; | 457 | break; |
458 | case Key_F13: //mail | 458 | case Key_F13: //mail |
459 | break; | 459 | break; |
460 | case Key_Space: { | 460 | case Key_Space: { |
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h index 34558f8..f996803 100644 --- a/noncore/multimedia/opieplayer2/videowidget.h +++ b/noncore/multimedia/opieplayer2/videowidget.h | |||
@@ -99,32 +99,30 @@ private: | |||
99 | // Ticker songInfo; | 99 | // Ticker songInfo; |
100 | QPixmap pixBg; | 100 | QPixmap pixBg; |
101 | QImage imgUp; | 101 | QImage imgUp; |
102 | QImage imgDn; | 102 | QImage imgDn; |
103 | QImage imgButtonMask; | 103 | QImage imgButtonMask; |
104 | QBitmap *masks[7]; | 104 | QBitmap *masks[7]; |
105 | QPixmap *buttonPixUp[7]; | 105 | QPixmap *buttonPixUp[7]; |
106 | QPixmap *buttonPixDown[7]; | 106 | QPixmap *buttonPixDown[7]; |
107 | QString skin; | 107 | QString skin; |
108 | // QPixmap *pixmaps[4]; | 108 | // QPixmap *pixmaps[4]; |
109 | int xoff, yoff; | 109 | int xoff, yoff; |
110 | 110 | ||
111 | 111 | ||
112 | void paintButton( QPainter *p, int i ); | 112 | void paintButton( QPainter *p, int i ); |
113 | void toggleButton( int ); | 113 | void toggleButton( int ); |
114 | void setToggleButton( int, bool ); | 114 | void setToggleButton( int, bool ); |
115 | 115 | ||
116 | QString backgroundPix; | 116 | QString backgroundPix; |
117 | QSlider *slider; | 117 | QSlider *slider; |
118 | QPixmap *pixmaps[3]; | 118 | QPixmap *pixmaps[3]; |
119 | QImage *currentFrame; | 119 | QImage *currentFrame; |
120 | int scaledWidth; | 120 | int scaledWidth; |
121 | int scaledHeight; | 121 | int scaledHeight; |
122 | XineVideoWidget* videoFrame; | 122 | XineVideoWidget* videoFrame; |
123 | |||
124 | ButtonVector videoButtons; | ||
125 | }; | 123 | }; |
126 | 124 | ||
127 | #endif // VIDEO_WIDGET_H | 125 | #endif // VIDEO_WIDGET_H |
128 | 126 | ||
129 | 127 | ||
130 | 128 | ||