author | simon <simon> | 2002-12-09 15:19:47 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-09 15:19:47 (UTC) |
commit | 47d689545e68f2439cc88630ac78016712f92cc9 (patch) (unidiff) | |
tree | 5d2d01f7a68c2bed804c0b6518f9a8858de27a2e | |
parent | 3f37a852175ace7ee69b626f48eaea19d736b6ed (diff) | |
download | opie-47d689545e68f2439cc88630ac78016712f92cc9.zip opie-47d689545e68f2439cc88630ac78016712f92cc9.tar.gz opie-47d689545e68f2439cc88630ac78016712f92cc9.tar.bz2 |
- merged the duplicated (and identical) paintEvent methods into the
base class
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 19 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.h | 1 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.cpp | 28 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.h | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 31 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.h | 1 |
6 files changed, 30 insertions, 52 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index 553c56b..277d162 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp | |||
@@ -384,51 +384,32 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { | |||
384 | 384 | ||
385 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { | 385 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { |
386 | mouseMoveEvent( event ); | 386 | mouseMoveEvent( event ); |
387 | } | 387 | } |
388 | 388 | ||
389 | 389 | ||
390 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { | 390 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { |
391 | mouseMoveEvent( event ); | 391 | mouseMoveEvent( event ); |
392 | } | 392 | } |
393 | 393 | ||
394 | 394 | ||
395 | void AudioWidget::showEvent( QShowEvent* ) { | 395 | void AudioWidget::showEvent( QShowEvent* ) { |
396 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); | 396 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); |
397 | mouseMoveEvent( &event ); | 397 | mouseMoveEvent( &event ); |
398 | } | 398 | } |
399 | 399 | ||
400 | |||
401 | void AudioWidget::paintEvent( QPaintEvent * pe ) { | ||
402 | if ( !pe->erased() ) { | ||
403 | // Combine with background and double buffer | ||
404 | QPixmap pix( pe->rect().size() ); | ||
405 | QPainter p( &pix ); | ||
406 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | ||
407 | p.drawTiledPixmap( pe->rect(), backgroundPixmap, pe->rect().topLeft() ); | ||
408 | for ( unsigned int i = 0; i < buttons.count(); i++ ) | ||
409 | paintButton( p, buttons[ i ] ); | ||
410 | QPainter p2( this ); | ||
411 | p2.drawPixmap( pe->rect().topLeft(), pix ); | ||
412 | } else { | ||
413 | QPainter p( this ); | ||
414 | for ( unsigned int i = 0; i < buttons.count(); i++ ) | ||
415 | paintButton( p, buttons[ i ] ); | ||
416 | } | ||
417 | } | ||
418 | |||
419 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { | 400 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { |
420 | switch ( e->key() ) { | 401 | switch ( e->key() ) { |
421 | ////////////////////////////// Zaurus keys | 402 | ////////////////////////////// Zaurus keys |
422 | case Key_Home: | 403 | case Key_Home: |
423 | break; | 404 | break; |
424 | case Key_F9: //activity | 405 | case Key_F9: //activity |
425 | hide(); | 406 | hide(); |
426 | // qDebug("Audio F9"); | 407 | // qDebug("Audio F9"); |
427 | break; | 408 | break; |
428 | case Key_F10: //contacts | 409 | case Key_F10: //contacts |
429 | break; | 410 | break; |
430 | case Key_F11: //menu | 411 | case Key_F11: //menu |
431 | mediaPlayerState.toggleBlank(); | 412 | mediaPlayerState.toggleBlank(); |
432 | break; | 413 | break; |
433 | case Key_F12: //home | 414 | case Key_F12: //home |
434 | break; | 415 | break; |
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h index 69837cd..8c433ac 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.h +++ b/noncore/multimedia/opieplayer2/audiowidget.h | |||
@@ -65,33 +65,32 @@ public slots: | |||
65 | 65 | ||
66 | public: | 66 | public: |
67 | virtual void setLength( long ); | 67 | virtual void setLength( long ); |
68 | virtual void setPlaying( bool b) { setToggleButton( Play, b ); } | 68 | virtual void setPlaying( bool b) { setToggleButton( Play, b ); } |
69 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); | 69 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); |
70 | 70 | ||
71 | signals: | 71 | signals: |
72 | void moreClicked(); | 72 | void moreClicked(); |
73 | void lessClicked(); | 73 | void lessClicked(); |
74 | void forwardClicked(); | 74 | void forwardClicked(); |
75 | void backClicked(); | 75 | void backClicked(); |
76 | void sliderMoved(long); | 76 | void sliderMoved(long); |
77 | 77 | ||
78 | protected: | 78 | protected: |
79 | void doBlank(); | 79 | void doBlank(); |
80 | void doUnblank(); | 80 | void doUnblank(); |
81 | void paintEvent( QPaintEvent *pe ); | ||
82 | void showEvent( QShowEvent *se ); | 81 | void showEvent( QShowEvent *se ); |
83 | void resizeEvent( QResizeEvent *re ); | 82 | void resizeEvent( QResizeEvent *re ); |
84 | void mouseMoveEvent( QMouseEvent *event ); | 83 | void mouseMoveEvent( QMouseEvent *event ); |
85 | void mousePressEvent( QMouseEvent *event ); | 84 | void mousePressEvent( QMouseEvent *event ); |
86 | void mouseReleaseEvent( QMouseEvent *event ); | 85 | void mouseReleaseEvent( QMouseEvent *event ); |
87 | void timerEvent( QTimerEvent *event ); | 86 | void timerEvent( QTimerEvent *event ); |
88 | void keyReleaseEvent( QKeyEvent *e); | 87 | void keyReleaseEvent( QKeyEvent *e); |
89 | private slots: | 88 | private slots: |
90 | void skipFor(); | 89 | void skipFor(); |
91 | void skipBack(); | 90 | void skipBack(); |
92 | void stopSkip(); | 91 | void stopSkip(); |
93 | private: | 92 | private: |
94 | void setToggleButton( int, bool ); | 93 | void setToggleButton( int, bool ); |
95 | int skipDirection; | 94 | int skipDirection; |
96 | QString skin; | 95 | QString skin; |
97 | QImage imgUp; | 96 | QImage imgUp; |
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp index f977b61..3a44185 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.cpp +++ b/noncore/multimedia/opieplayer2/mediawidget.cpp | |||
@@ -31,32 +31,60 @@ MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPla | |||
31 | this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) ); | 31 | this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) ); |
32 | connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ), | 32 | connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ), |
33 | this, SLOT( setLength( long ) ) ); | 33 | this, SLOT( setLength( long ) ) ); |
34 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), | 34 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), |
35 | this, SLOT( setPlaying( bool ) ) ); | 35 | this, SLOT( setPlaying( bool ) ) ); |
36 | } | 36 | } |
37 | 37 | ||
38 | MediaWidget::~MediaWidget() | 38 | MediaWidget::~MediaWidget() |
39 | { | 39 | { |
40 | } | 40 | } |
41 | 41 | ||
42 | void MediaWidget::closeEvent( QCloseEvent * ) | 42 | void MediaWidget::closeEvent( QCloseEvent * ) |
43 | { | 43 | { |
44 | mediaPlayerState.setList(); | 44 | mediaPlayerState.setList(); |
45 | } | 45 | } |
46 | 46 | ||
47 | void MediaWidget::paintEvent( QPaintEvent *pe ) | ||
48 | { | ||
49 | QPainter p( this ); | ||
50 | |||
51 | if ( mediaPlayerState.isFullscreen() ) { | ||
52 | // Clear the background | ||
53 | p.setBrush( QBrush( Qt::black ) ); | ||
54 | return; | ||
55 | } | ||
56 | |||
57 | if ( !pe->erased() ) { | ||
58 | // Combine with background and double buffer | ||
59 | QPixmap pix( pe->rect().size() ); | ||
60 | QPainter p( &pix ); | ||
61 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | ||
62 | p.drawTiledPixmap( pe->rect(), backgroundPixmap, pe->rect().topLeft() ); | ||
63 | for ( unsigned int i = 0; i < buttons.count(); i++ ) { | ||
64 | paintButton( p, buttons[ i ] ); | ||
65 | } | ||
66 | QPainter p2( this ); | ||
67 | p2.drawPixmap( pe->rect().topLeft(), pix ); | ||
68 | } else { | ||
69 | QPainter p( this ); | ||
70 | for ( unsigned int i = 0; i < buttons.count(); i++ ) | ||
71 | paintButton( p, buttons[ i ] ); | ||
72 | } | ||
73 | } | ||
74 | |||
47 | void MediaWidget::handleCommand( Command command, bool buttonDown ) | 75 | void MediaWidget::handleCommand( Command command, bool buttonDown ) |
48 | { | 76 | { |
49 | switch ( command ) { | 77 | switch ( command ) { |
50 | case Play: mediaPlayerState.togglePaused(); | 78 | case Play: mediaPlayerState.togglePaused(); |
51 | case Stop: mediaPlayerState.setPlaying(FALSE); return; | 79 | case Stop: mediaPlayerState.setPlaying(FALSE); return; |
52 | case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; | 80 | case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; |
53 | case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; | 81 | case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; |
54 | case Loop: mediaPlayerState.setLooping( buttonDown ); return; | 82 | case Loop: mediaPlayerState.setLooping( buttonDown ); return; |
55 | case VolumeUp: emit moreReleased(); return; | 83 | case VolumeUp: emit moreReleased(); return; |
56 | case VolumeDown: emit lessReleased(); return; | 84 | case VolumeDown: emit lessReleased(); return; |
57 | case PlayList: mediaPlayerState.setList(); return; | 85 | case PlayList: mediaPlayerState.setList(); return; |
58 | case Forward: emit forwardReleased(); return; | 86 | case Forward: emit forwardReleased(); return; |
59 | case Back: emit backReleased(); return; | 87 | case Back: emit backReleased(); return; |
60 | } | 88 | } |
61 | } | 89 | } |
62 | 90 | ||
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h index 211e56c..8cdaad1 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.h +++ b/noncore/multimedia/opieplayer2/mediawidget.h | |||
@@ -68,32 +68,34 @@ public: | |||
68 | virtual ~MediaWidget(); | 68 | virtual ~MediaWidget(); |
69 | 69 | ||
70 | public slots: | 70 | public slots: |
71 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0; | 71 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0; |
72 | virtual void setLength( long length ) = 0; | 72 | virtual void setLength( long length ) = 0; |
73 | virtual void setPlaying( bool playing ) = 0; | 73 | virtual void setPlaying( bool playing ) = 0; |
74 | 74 | ||
75 | signals: | 75 | signals: |
76 | void moreReleased(); | 76 | void moreReleased(); |
77 | void lessReleased(); | 77 | void lessReleased(); |
78 | void forwardReleased(); | 78 | void forwardReleased(); |
79 | void backReleased(); | 79 | void backReleased(); |
80 | 80 | ||
81 | protected: | 81 | protected: |
82 | virtual void closeEvent( QCloseEvent * ); | 82 | virtual void closeEvent( QCloseEvent * ); |
83 | 83 | ||
84 | virtual void paintEvent( QPaintEvent *pe ); | ||
85 | |||
84 | void handleCommand( Command command, bool buttonDown ); | 86 | void handleCommand( Command command, bool buttonDown ); |
85 | 87 | ||
86 | bool isOverButton( const QPoint &position, int buttonId ) const; | 88 | bool isOverButton( const QPoint &position, int buttonId ) const; |
87 | 89 | ||
88 | void paintButton( int buttonId ); | 90 | void paintButton( int buttonId ); |
89 | void paintButton( QPainter &p, const Button &button ); | 91 | void paintButton( QPainter &p, const Button &button ); |
90 | 92 | ||
91 | void toggleButton( int buttonId ); | 93 | void toggleButton( int buttonId ); |
92 | 94 | ||
93 | MediaPlayerState &mediaPlayerState; | 95 | MediaPlayerState &mediaPlayerState; |
94 | PlayListWidget &playList; | 96 | PlayListWidget &playList; |
95 | 97 | ||
96 | ButtonMap buttons; | 98 | ButtonMap buttons; |
97 | 99 | ||
98 | QImage buttonMask; | 100 | QImage buttonMask; |
99 | 101 | ||
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index a8bf252..8f6a8a9 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp | |||
@@ -362,63 +362,32 @@ void VideoWidget::makeVisible() { | |||
362 | slider->hide(); | 362 | slider->hide(); |
363 | } | 363 | } |
364 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 364 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
365 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 365 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
366 | disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 366 | disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
367 | disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 367 | disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
368 | } else { | 368 | } else { |
369 | slider->show(); | 369 | slider->show(); |
370 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 370 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
371 | connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 371 | connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
372 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 372 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
373 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 373 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
374 | } | 374 | } |
375 | } | 375 | } |
376 | } | 376 | } |
377 | 377 | ||
378 | |||
379 | |||
380 | |||
381 | void VideoWidget::paintEvent( QPaintEvent * pe) { | ||
382 | QPainter p( this ); | ||
383 | |||
384 | if ( mediaPlayerState.isFullscreen() ) { | ||
385 | // Clear the background | ||
386 | p.setBrush( QBrush( Qt::black ) ); | ||
387 | } else { | ||
388 | if ( !pe->erased() ) { | ||
389 | // Combine with background and double buffer | ||
390 | QPixmap pix( pe->rect().size() ); | ||
391 | QPainter p( &pix ); | ||
392 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | ||
393 | p.drawTiledPixmap( pe->rect(), backgroundPixmap, pe->rect().topLeft() ); | ||
394 | for ( unsigned int i = 0; i < buttons.count(); i++ ) { | ||
395 | paintButton( p, buttons[ i ] ); | ||
396 | } | ||
397 | QPainter p2( this ); | ||
398 | p2.drawPixmap( pe->rect().topLeft(), pix ); | ||
399 | } else { | ||
400 | QPainter p( this ); | ||
401 | for ( unsigned int i = 0; i < buttons.count(); i++ ) | ||
402 | paintButton( p, buttons[ i ] ); | ||
403 | } | ||
404 | //slider->repaint( TRUE ); | ||
405 | } | ||
406 | } | ||
407 | |||
408 | |||
409 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { | 378 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { |
410 | switch ( e->key() ) { | 379 | switch ( e->key() ) { |
411 | ////////////////////////////// Zaurus keys | 380 | ////////////////////////////// Zaurus keys |
412 | case Key_Home: | 381 | case Key_Home: |
413 | break; | 382 | break; |
414 | case Key_F9: //activity | 383 | case Key_F9: //activity |
415 | break; | 384 | break; |
416 | case Key_F10: //contacts | 385 | case Key_F10: //contacts |
417 | // hide(); | 386 | // hide(); |
418 | break; | 387 | break; |
419 | case Key_F11: //menu | 388 | case Key_F11: //menu |
420 | break; | 389 | break; |
421 | case Key_F12: //home | 390 | case Key_F12: //home |
422 | break; | 391 | break; |
423 | case Key_F13: //mail | 392 | case Key_F13: //mail |
424 | break; | 393 | break; |
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h index 9d5239b..45279d7 100644 --- a/noncore/multimedia/opieplayer2/videowidget.h +++ b/noncore/multimedia/opieplayer2/videowidget.h | |||
@@ -75,33 +75,32 @@ public slots: | |||
75 | public: | 75 | public: |
76 | virtual void setPlaying( bool b); | 76 | virtual void setPlaying( bool b); |
77 | virtual void setLength( long ); | 77 | virtual void setLength( long ); |
78 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); | 78 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); |
79 | 79 | ||
80 | signals: | 80 | signals: |
81 | void moreClicked(); | 81 | void moreClicked(); |
82 | void lessClicked(); | 82 | void lessClicked(); |
83 | void moreReleased(); | 83 | void moreReleased(); |
84 | void lessReleased(); | 84 | void lessReleased(); |
85 | void sliderMoved( long ); | 85 | void sliderMoved( long ); |
86 | void videoResized ( const QSize &s ); | 86 | void videoResized ( const QSize &s ); |
87 | 87 | ||
88 | protected: | 88 | protected: |
89 | 89 | ||
90 | void resizeEvent( QResizeEvent * ); | 90 | void resizeEvent( QResizeEvent * ); |
91 | void paintEvent( QPaintEvent *pe ); | ||
92 | void showEvent( QShowEvent *se ); | 91 | void showEvent( QShowEvent *se ); |
93 | void mouseMoveEvent( QMouseEvent *event ); | 92 | void mouseMoveEvent( QMouseEvent *event ); |
94 | void mousePressEvent( QMouseEvent *event ); | 93 | void mousePressEvent( QMouseEvent *event ); |
95 | void mouseReleaseEvent( QMouseEvent *event ); | 94 | void mouseReleaseEvent( QMouseEvent *event ); |
96 | void keyReleaseEvent( QKeyEvent *e); | 95 | void keyReleaseEvent( QKeyEvent *e); |
97 | 96 | ||
98 | private: | 97 | private: |
99 | // Ticker songInfo; | 98 | // Ticker songInfo; |
100 | QImage imgUp; | 99 | QImage imgUp; |
101 | QImage imgDn; | 100 | QImage imgDn; |
102 | QString skin; | 101 | QString skin; |
103 | 102 | ||
104 | 103 | ||
105 | void setToggleButton( int, bool ); | 104 | void setToggleButton( int, bool ); |
106 | 105 | ||
107 | QString backgroundPix; | 106 | QString backgroundPix; |