-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 45 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.h | 5 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.cpp | 44 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.h | 6 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 40 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.h | 1 |
6 files changed, 50 insertions, 91 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index 37c565b..dda039c 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp | |||
@@ -304,109 +304,64 @@ void AudioWidget::updateSlider( long i, long max ) { | |||
304 | slider.setMaxValue( width ); | 304 | slider.setMaxValue( width ); |
305 | } | 305 | } |
306 | } | 306 | } |
307 | } | 307 | } |
308 | 308 | ||
309 | void AudioWidget::skipFor() { | 309 | void AudioWidget::skipFor() { |
310 | skipDirection = +1; | 310 | skipDirection = +1; |
311 | startTimer( 50 ); | 311 | startTimer( 50 ); |
312 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); | 312 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); |
313 | } | 313 | } |
314 | 314 | ||
315 | void AudioWidget::skipBack() { | 315 | void AudioWidget::skipBack() { |
316 | skipDirection = -1; | 316 | skipDirection = -1; |
317 | startTimer( 50 ); | 317 | startTimer( 50 ); |
318 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); | 318 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); |
319 | } | 319 | } |
320 | 320 | ||
321 | 321 | ||
322 | 322 | ||
323 | void AudioWidget::stopSkip() { | 323 | void AudioWidget::stopSkip() { |
324 | killTimers(); | 324 | killTimers(); |
325 | } | 325 | } |
326 | 326 | ||
327 | 327 | ||
328 | void AudioWidget::timerEvent( QTimerEvent * ) { | 328 | void AudioWidget::timerEvent( QTimerEvent * ) { |
329 | if ( skipDirection == +1 ) { | 329 | if ( skipDirection == +1 ) { |
330 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); | 330 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); |
331 | } else if ( skipDirection == -1 ) { | 331 | } else if ( skipDirection == -1 ) { |
332 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); | 332 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); |
333 | } | 333 | } |
334 | } | 334 | } |
335 | 335 | ||
336 | |||
337 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { | ||
338 | for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) { | ||
339 | Button &button = *it; | ||
340 | Command command = button.command; | ||
341 | |||
342 | if ( event->state() == QMouseEvent::LeftButton ) { | ||
343 | // The test to see if the mouse click is inside the button or not | ||
344 | bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, command ); | ||
345 | |||
346 | if ( isOnButton && !button.isHeld ) { | ||
347 | button.isHeld = TRUE; | ||
348 | toggleButton( button ); | ||
349 | switch ( command ) { | ||
350 | case VolumeUp: | ||
351 | emit moreClicked(); | ||
352 | return; | ||
353 | case VolumeDown: | ||
354 | emit lessClicked(); | ||
355 | return; | ||
356 | case Forward: | ||
357 | emit forwardClicked(); | ||
358 | return; | ||
359 | case Back: | ||
360 | emit backClicked(); | ||
361 | return; | ||
362 | default: break; | ||
363 | } | ||
364 | } else if ( !isOnButton && button.isHeld ) { | ||
365 | button.isHeld = FALSE; | ||
366 | toggleButton( button ); | ||
367 | } | ||
368 | } else { | ||
369 | if ( button.isHeld ) { | ||
370 | button.isHeld = FALSE; | ||
371 | if ( button.type != ToggleButton ) { | ||
372 | setToggleButton( button, FALSE ); | ||
373 | } | ||
374 | handleCommand( command, button.isDown ); | ||
375 | } | ||
376 | } | ||
377 | } | ||
378 | } | ||
379 | |||
380 | |||
381 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { | 336 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { |
382 | mouseMoveEvent( event ); | 337 | mouseMoveEvent( event ); |
383 | } | 338 | } |
384 | 339 | ||
385 | 340 | ||
386 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { | 341 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { |
387 | mouseMoveEvent( event ); | 342 | mouseMoveEvent( event ); |
388 | } | 343 | } |
389 | 344 | ||
390 | 345 | ||
391 | void AudioWidget::showEvent( QShowEvent* ) { | 346 | void AudioWidget::showEvent( QShowEvent* ) { |
392 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); | 347 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); |
393 | mouseMoveEvent( &event ); | 348 | mouseMoveEvent( &event ); |
394 | } | 349 | } |
395 | 350 | ||
396 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { | 351 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { |
397 | switch ( e->key() ) { | 352 | switch ( e->key() ) { |
398 | ////////////////////////////// Zaurus keys | 353 | ////////////////////////////// Zaurus keys |
399 | case Key_Home: | 354 | case Key_Home: |
400 | break; | 355 | break; |
401 | case Key_F9: //activity | 356 | case Key_F9: //activity |
402 | hide(); | 357 | hide(); |
403 | // qDebug("Audio F9"); | 358 | // qDebug("Audio F9"); |
404 | break; | 359 | break; |
405 | case Key_F10: //contacts | 360 | case Key_F10: //contacts |
406 | break; | 361 | break; |
407 | case Key_F11: //menu | 362 | case Key_F11: //menu |
408 | mediaPlayerState.toggleBlank(); | 363 | mediaPlayerState.toggleBlank(); |
409 | break; | 364 | break; |
410 | case Key_F12: //home | 365 | case Key_F12: //home |
411 | break; | 366 | break; |
412 | case Key_F13: //mail | 367 | case Key_F13: //mail |
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h index 9b276b5..690d1b3 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.h +++ b/noncore/multimedia/opieplayer2/audiowidget.h | |||
@@ -40,68 +40,63 @@ | |||
40 | #include <qstring.h> | 40 | #include <qstring.h> |
41 | #include <qslider.h> | 41 | #include <qslider.h> |
42 | #include <qframe.h> | 42 | #include <qframe.h> |
43 | #include <qlineedit.h> | 43 | #include <qlineedit.h> |
44 | #include <qimage.h> | 44 | #include <qimage.h> |
45 | 45 | ||
46 | #include <opie/oticker.h> | 46 | #include <opie/oticker.h> |
47 | 47 | ||
48 | #include "mediawidget.h" | 48 | #include "mediawidget.h" |
49 | 49 | ||
50 | class QPixmap; | 50 | class QPixmap; |
51 | 51 | ||
52 | class AudioWidget : public MediaWidget { | 52 | class AudioWidget : public MediaWidget { |
53 | Q_OBJECT | 53 | Q_OBJECT |
54 | public: | 54 | public: |
55 | AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); | 55 | AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); |
56 | ~AudioWidget(); | 56 | ~AudioWidget(); |
57 | void setTickerText( const QString &text ) { songInfo.setText( text ); } | 57 | void setTickerText( const QString &text ) { songInfo.setText( text ); } |
58 | public slots: | 58 | public slots: |
59 | void updateSlider( long, long ); | 59 | void updateSlider( long, long ); |
60 | void sliderPressed( ); | 60 | void sliderPressed( ); |
61 | void sliderReleased( ); | 61 | void sliderReleased( ); |
62 | void setLooping( bool b) { setToggleButton( Loop, b ); } | 62 | void setLooping( bool b) { setToggleButton( Loop, b ); } |
63 | void setPosition( long ); | 63 | void setPosition( long ); |
64 | void setSeekable( bool ); | 64 | void setSeekable( bool ); |
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(); | ||
73 | void lessClicked(); | ||
74 | void forwardClicked(); | ||
75 | void backClicked(); | ||
76 | void sliderMoved(long); | 72 | void sliderMoved(long); |
77 | 73 | ||
78 | protected: | 74 | protected: |
79 | void doBlank(); | 75 | void doBlank(); |
80 | void doUnblank(); | 76 | void doUnblank(); |
81 | void showEvent( QShowEvent *se ); | 77 | void showEvent( QShowEvent *se ); |
82 | void resizeEvent( QResizeEvent *re ); | 78 | void resizeEvent( QResizeEvent *re ); |
83 | void mouseMoveEvent( QMouseEvent *event ); | ||
84 | void mousePressEvent( QMouseEvent *event ); | 79 | void mousePressEvent( QMouseEvent *event ); |
85 | void mouseReleaseEvent( QMouseEvent *event ); | 80 | void mouseReleaseEvent( QMouseEvent *event ); |
86 | void timerEvent( QTimerEvent *event ); | 81 | void timerEvent( QTimerEvent *event ); |
87 | void keyReleaseEvent( QKeyEvent *e); | 82 | void keyReleaseEvent( QKeyEvent *e); |
88 | private slots: | 83 | private slots: |
89 | void skipFor(); | 84 | void skipFor(); |
90 | void skipBack(); | 85 | void skipBack(); |
91 | void stopSkip(); | 86 | void stopSkip(); |
92 | private: | 87 | private: |
93 | int skipDirection; | 88 | int skipDirection; |
94 | QString skin; | 89 | QString skin; |
95 | QImage imgUp; | 90 | QImage imgUp; |
96 | QImage imgDn; | 91 | QImage imgDn; |
97 | 92 | ||
98 | OTicker songInfo; | 93 | OTicker songInfo; |
99 | QSlider slider; | 94 | QSlider slider; |
100 | QLineEdit time; | 95 | QLineEdit time; |
101 | bool isStreaming : 1; | 96 | bool isStreaming : 1; |
102 | bool audioSliderBeingMoved : 1; | 97 | bool audioSliderBeingMoved : 1; |
103 | }; | 98 | }; |
104 | 99 | ||
105 | 100 | ||
106 | #endif // AUDIO_WIDGET_H | 101 | #endif // AUDIO_WIDGET_H |
107 | 102 | ||
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp index 7eb75e6..3533d74 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.cpp +++ b/noncore/multimedia/opieplayer2/mediawidget.cpp | |||
@@ -40,64 +40,108 @@ MediaWidget::~MediaWidget() | |||
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 ) | 47 | void MediaWidget::paintEvent( QPaintEvent *pe ) |
48 | { | 48 | { |
49 | QPainter p( this ); | 49 | QPainter p( this ); |
50 | 50 | ||
51 | if ( mediaPlayerState.isFullscreen() ) { | 51 | if ( mediaPlayerState.isFullscreen() ) { |
52 | // Clear the background | 52 | // Clear the background |
53 | p.setBrush( QBrush( Qt::black ) ); | 53 | p.setBrush( QBrush( Qt::black ) ); |
54 | return; | 54 | return; |
55 | } | 55 | } |
56 | 56 | ||
57 | if ( !pe->erased() ) { | 57 | if ( !pe->erased() ) { |
58 | // Combine with background and double buffer | 58 | // Combine with background and double buffer |
59 | QPixmap pix( pe->rect().size() ); | 59 | QPixmap pix( pe->rect().size() ); |
60 | QPainter p( &pix ); | 60 | QPainter p( &pix ); |
61 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | 61 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); |
62 | p.drawTiledPixmap( pe->rect(), backgroundPixmap, pe->rect().topLeft() ); | 62 | p.drawTiledPixmap( pe->rect(), backgroundPixmap, pe->rect().topLeft() ); |
63 | paintAllButtons( p ); | 63 | paintAllButtons( p ); |
64 | QPainter p2( this ); | 64 | QPainter p2( this ); |
65 | p2.drawPixmap( pe->rect().topLeft(), pix ); | 65 | p2.drawPixmap( pe->rect().topLeft(), pix ); |
66 | } else { | 66 | } else { |
67 | QPainter p( this ); | 67 | QPainter p( this ); |
68 | paintAllButtons( p ); | 68 | paintAllButtons( p ); |
69 | } | 69 | } |
70 | } | 70 | } |
71 | 71 | ||
72 | void MediaWidget::mouseMoveEvent( QMouseEvent *event ) | ||
73 | { | ||
74 | for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) { | ||
75 | Button &button = *it; | ||
76 | Command command = button.command; | ||
77 | |||
78 | if ( event->state() == QMouseEvent::LeftButton ) { | ||
79 | // The test to see if the mouse click is inside the button or not | ||
80 | bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, command ); | ||
81 | |||
82 | if ( isOnButton && !button.isHeld ) { | ||
83 | button.isHeld = TRUE; | ||
84 | toggleButton( button ); | ||
85 | switch ( command ) { | ||
86 | case VolumeUp: | ||
87 | emit moreClicked(); | ||
88 | return; | ||
89 | case VolumeDown: | ||
90 | emit lessClicked(); | ||
91 | return; | ||
92 | case Forward: | ||
93 | emit forwardClicked(); | ||
94 | return; | ||
95 | case Back: | ||
96 | emit backClicked(); | ||
97 | return; | ||
98 | default: break; | ||
99 | } | ||
100 | } else if ( !isOnButton && button.isHeld ) { | ||
101 | button.isHeld = FALSE; | ||
102 | toggleButton( button ); | ||
103 | } | ||
104 | } else { | ||
105 | if ( button.isHeld ) { | ||
106 | button.isHeld = FALSE; | ||
107 | if ( button.type != ToggleButton ) { | ||
108 | setToggleButton( button, FALSE ); | ||
109 | } | ||
110 | handleCommand( command, button.isDown ); | ||
111 | } | ||
112 | } | ||
113 | } | ||
114 | } | ||
115 | |||
72 | void MediaWidget::makeVisible() | 116 | void MediaWidget::makeVisible() |
73 | { | 117 | { |
74 | } | 118 | } |
75 | 119 | ||
76 | void MediaWidget::handleCommand( Command command, bool buttonDown ) | 120 | void MediaWidget::handleCommand( Command command, bool buttonDown ) |
77 | { | 121 | { |
78 | switch ( command ) { | 122 | switch ( command ) { |
79 | case Play: mediaPlayerState.togglePaused(); | 123 | case Play: mediaPlayerState.togglePaused(); |
80 | case Stop: mediaPlayerState.setPlaying(FALSE); return; | 124 | case Stop: mediaPlayerState.setPlaying(FALSE); return; |
81 | case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; | 125 | case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; |
82 | case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; | 126 | case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; |
83 | case Loop: mediaPlayerState.setLooping( buttonDown ); return; | 127 | case Loop: mediaPlayerState.setLooping( buttonDown ); return; |
84 | case VolumeUp: emit moreReleased(); return; | 128 | case VolumeUp: emit moreReleased(); return; |
85 | case VolumeDown: emit lessReleased(); return; | 129 | case VolumeDown: emit lessReleased(); return; |
86 | case PlayList: mediaPlayerState.setList(); return; | 130 | case PlayList: mediaPlayerState.setList(); return; |
87 | case Forward: emit forwardReleased(); return; | 131 | case Forward: emit forwardReleased(); return; |
88 | case Back: emit backReleased(); return; | 132 | case Back: emit backReleased(); return; |
89 | case FullScreen: mediaPlayerState.setFullscreen( true ); makeVisible(); return; | 133 | case FullScreen: mediaPlayerState.setFullscreen( true ); makeVisible(); return; |
90 | default: assert( false ); | 134 | default: assert( false ); |
91 | } | 135 | } |
92 | } | 136 | } |
93 | 137 | ||
94 | bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const | 138 | bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const |
95 | { | 139 | { |
96 | return ( position.x() > 0 && position.y() > 0 && | 140 | return ( position.x() > 0 && position.y() > 0 && |
97 | position.x() < buttonMask.width() && | 141 | position.x() < buttonMask.width() && |
98 | position.y() < buttonMask.height() && | 142 | position.y() < buttonMask.height() && |
99 | buttonMask.pixelIndex( position.x(), position.y() ) == buttonId + 1 ); | 143 | buttonMask.pixelIndex( position.x(), position.y() ) == buttonId + 1 ); |
100 | } | 144 | } |
101 | 145 | ||
102 | void MediaWidget::paintAllButtons( QPainter &p ) | 146 | void MediaWidget::paintAllButtons( QPainter &p ) |
103 | { | 147 | { |
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h index 3f4c45d..c19fdbb 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.h +++ b/noncore/multimedia/opieplayer2/mediawidget.h | |||
@@ -48,67 +48,73 @@ public: | |||
48 | bool isHeld : 1; | 48 | bool isHeld : 1; |
49 | bool isDown : 1; | 49 | bool isDown : 1; |
50 | 50 | ||
51 | QBitmap mask; | 51 | QBitmap mask; |
52 | QPixmap pixUp; | 52 | QPixmap pixUp; |
53 | QPixmap pixDown; | 53 | QPixmap pixDown; |
54 | }; | 54 | }; |
55 | typedef std::vector<Button> ButtonVector; | 55 | typedef std::vector<Button> ButtonVector; |
56 | 56 | ||
57 | struct SkinButtonInfo | 57 | struct SkinButtonInfo |
58 | { | 58 | { |
59 | Command command; | 59 | Command command; |
60 | const char *fileName; | 60 | const char *fileName; |
61 | ButtonType type; | 61 | ButtonType type; |
62 | }; | 62 | }; |
63 | 63 | ||
64 | typedef std::vector<QBitmap> MaskVector; | 64 | typedef std::vector<QBitmap> MaskVector; |
65 | typedef std::vector<QPixmap> PixmapVector; | 65 | typedef std::vector<QPixmap> PixmapVector; |
66 | 66 | ||
67 | MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 ); | 67 | MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 ); |
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 | void forwardClicked(); | ||
81 | void backClicked(); | ||
82 | void moreClicked(); | ||
83 | void lessClicked(); | ||
80 | 84 | ||
81 | protected: | 85 | protected: |
82 | virtual void closeEvent( QCloseEvent * ); | 86 | virtual void closeEvent( QCloseEvent * ); |
83 | 87 | ||
84 | virtual void paintEvent( QPaintEvent *pe ); | 88 | virtual void paintEvent( QPaintEvent *pe ); |
85 | 89 | ||
90 | virtual void mouseMoveEvent( QMouseEvent *event ); | ||
91 | |||
86 | virtual void makeVisible(); | 92 | virtual void makeVisible(); |
87 | 93 | ||
88 | void handleCommand( Command command, bool buttonDown ); | 94 | void handleCommand( Command command, bool buttonDown ); |
89 | 95 | ||
90 | bool isOverButton( const QPoint &position, int buttonId ) const; | 96 | bool isOverButton( const QPoint &position, int buttonId ) const; |
91 | 97 | ||
92 | void paintAllButtons( QPainter &p ); | 98 | void paintAllButtons( QPainter &p ); |
93 | void paintButton( const Button &button ); | 99 | void paintButton( const Button &button ); |
94 | void paintButton( QPainter &p, const Button &button ); | 100 | void paintButton( QPainter &p, const Button &button ); |
95 | 101 | ||
96 | void setToggleButton( Button &button, bool down ); | 102 | void setToggleButton( Button &button, bool down ); |
97 | void setToggleButton( Command command, bool down ); | 103 | void setToggleButton( Command command, bool down ); |
98 | void toggleButton( Button &button ); | 104 | void toggleButton( Button &button ); |
99 | 105 | ||
100 | MediaPlayerState &mediaPlayerState; | 106 | MediaPlayerState &mediaPlayerState; |
101 | PlayListWidget &playList; | 107 | PlayListWidget &playList; |
102 | 108 | ||
103 | ButtonVector buttons; | 109 | ButtonVector buttons; |
104 | 110 | ||
105 | QImage buttonMask; | 111 | QImage buttonMask; |
106 | 112 | ||
107 | QPoint upperLeftOfButtonMask; | 113 | QPoint upperLeftOfButtonMask; |
108 | 114 | ||
109 | QPixmap backgroundPixmap; | 115 | QPixmap backgroundPixmap; |
110 | }; | 116 | }; |
111 | 117 | ||
112 | #endif // MEDIAWIDGET_H | 118 | #endif // MEDIAWIDGET_H |
113 | /* vim: et sw=4 ts=4 | 119 | /* vim: et sw=4 ts=4 |
114 | */ | 120 | */ |
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index cc586cc..41844e1 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp | |||
@@ -214,104 +214,64 @@ void VideoWidget::setLength( long max ) { | |||
214 | } | 214 | } |
215 | 215 | ||
216 | void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) | 216 | void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) |
217 | { | 217 | { |
218 | if ( displayType == MediaPlayerState::Video ) { | 218 | if ( displayType == MediaPlayerState::Video ) { |
219 | makeVisible(); | 219 | makeVisible(); |
220 | return; | 220 | return; |
221 | } | 221 | } |
222 | 222 | ||
223 | // Effectively blank the view next time we show it so it looks nicer | 223 | // Effectively blank the view next time we show it so it looks nicer |
224 | scaledWidth = 0; | 224 | scaledWidth = 0; |
225 | scaledHeight = 0; | 225 | scaledHeight = 0; |
226 | hide(); | 226 | hide(); |
227 | } | 227 | } |
228 | 228 | ||
229 | void VideoWidget::updateSlider( long i, long max ) { | 229 | void VideoWidget::updateSlider( long i, long max ) { |
230 | // Will flicker too much if we don't do this | 230 | // Will flicker too much if we don't do this |
231 | if ( max == 0 ) { | 231 | if ( max == 0 ) { |
232 | return; | 232 | return; |
233 | } | 233 | } |
234 | int width = slider->width(); | 234 | int width = slider->width(); |
235 | int val = int((double)i * width / max); | 235 | int val = int((double)i * width / max); |
236 | if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { | 236 | if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { |
237 | if ( slider->value() != val ) { | 237 | if ( slider->value() != val ) { |
238 | slider->setValue( val ); | 238 | slider->setValue( val ); |
239 | } | 239 | } |
240 | if ( slider->maxValue() != width ) { | 240 | if ( slider->maxValue() != width ) { |
241 | slider->setMaxValue( width ); | 241 | slider->setMaxValue( width ); |
242 | } | 242 | } |
243 | } | 243 | } |
244 | } | 244 | } |
245 | 245 | ||
246 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | ||
247 | for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) { | ||
248 | Button &button = *it; | ||
249 | Command command = button.command; | ||
250 | |||
251 | if ( event->state() == QMouseEvent::LeftButton ) { | ||
252 | // The test to see if the mouse click is inside the button or not | ||
253 | bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, command ); | ||
254 | |||
255 | if ( isOnButton && !button.isHeld ) { | ||
256 | button.isHeld = TRUE; | ||
257 | toggleButton( button ); | ||
258 | |||
259 | switch ( command ) { | ||
260 | case VolumeUp: | ||
261 | emit moreClicked(); | ||
262 | return; | ||
263 | case VolumeDown: | ||
264 | emit lessClicked(); | ||
265 | return; | ||
266 | default: break; | ||
267 | } | ||
268 | } else if ( !isOnButton && button.isHeld ) { | ||
269 | button.isHeld = FALSE; | ||
270 | toggleButton( button ); | ||
271 | } | ||
272 | } else { | ||
273 | |||
274 | if ( button.isHeld ) { | ||
275 | button.isHeld = FALSE; | ||
276 | if ( button.type != ToggleButton ) { | ||
277 | setToggleButton( button, FALSE ); | ||
278 | } | ||
279 | |||
280 | handleCommand( command, button.isDown ); | ||
281 | } | ||
282 | } | ||
283 | } | ||
284 | } | ||
285 | |||
286 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { | 246 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { |
287 | mouseMoveEvent( event ); | 247 | mouseMoveEvent( event ); |
288 | } | 248 | } |
289 | 249 | ||
290 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { | 250 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { |
291 | if ( mediaPlayerState.isFullscreen() ) { | 251 | if ( mediaPlayerState.isFullscreen() ) { |
292 | mediaPlayerState.setFullscreen( FALSE ); | 252 | mediaPlayerState.setFullscreen( FALSE ); |
293 | makeVisible(); | 253 | makeVisible(); |
294 | } | 254 | } |
295 | mouseMoveEvent( event ); | 255 | mouseMoveEvent( event ); |
296 | } | 256 | } |
297 | 257 | ||
298 | void VideoWidget::showEvent( QShowEvent* ) { | 258 | void VideoWidget::showEvent( QShowEvent* ) { |
299 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); | 259 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); |
300 | mouseMoveEvent( &event ); | 260 | mouseMoveEvent( &event ); |
301 | } | 261 | } |
302 | 262 | ||
303 | 263 | ||
304 | void VideoWidget::backToNormal() { | 264 | void VideoWidget::backToNormal() { |
305 | mediaPlayerState.setFullscreen( FALSE ); | 265 | mediaPlayerState.setFullscreen( FALSE ); |
306 | makeVisible(); | 266 | makeVisible(); |
307 | } | 267 | } |
308 | 268 | ||
309 | void VideoWidget::makeVisible() { | 269 | void VideoWidget::makeVisible() { |
310 | if ( mediaPlayerState.isFullscreen() ) { | 270 | if ( mediaPlayerState.isFullscreen() ) { |
311 | setBackgroundMode( QWidget::NoBackground ); | 271 | setBackgroundMode( QWidget::NoBackground ); |
312 | showFullScreen(); | 272 | showFullScreen(); |
313 | resize( qApp->desktop()->size() ); | 273 | resize( qApp->desktop()->size() ); |
314 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); | 274 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); |
315 | 275 | ||
316 | slider->hide(); | 276 | slider->hide(); |
317 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 277 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h index ef88186..7d50ea0 100644 --- a/noncore/multimedia/opieplayer2/videowidget.h +++ b/noncore/multimedia/opieplayer2/videowidget.h | |||
@@ -47,57 +47,56 @@ class QSlider; | |||
47 | class VideoWidget : public MediaWidget { | 47 | class VideoWidget : public MediaWidget { |
48 | Q_OBJECT | 48 | Q_OBJECT |
49 | public: | 49 | public: |
50 | VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); | 50 | VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); |
51 | ~VideoWidget(); | 51 | ~VideoWidget(); |
52 | 52 | ||
53 | 53 | ||
54 | XineVideoWidget* vidWidget(); | 54 | XineVideoWidget* vidWidget(); |
55 | public slots: | 55 | public slots: |
56 | void updateSlider( long, long ); | 56 | void updateSlider( long, long ); |
57 | void sliderPressed( ); | 57 | void sliderPressed( ); |
58 | void sliderReleased( ); | 58 | void sliderReleased( ); |
59 | void setFullscreen( bool b ); | 59 | void setFullscreen( bool b ); |
60 | virtual void makeVisible(); | 60 | virtual void makeVisible(); |
61 | void backToNormal(); | 61 | void backToNormal(); |
62 | void setPosition( long ); | 62 | void setPosition( long ); |
63 | 63 | ||
64 | public: | 64 | public: |
65 | virtual void setPlaying( bool b); | 65 | virtual void setPlaying( bool b); |
66 | virtual void setLength( long ); | 66 | virtual void setLength( long ); |
67 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); | 67 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); |
68 | 68 | ||
69 | signals: | 69 | signals: |
70 | void moreClicked(); | 70 | void moreClicked(); |
71 | void lessClicked(); | 71 | void lessClicked(); |
72 | void sliderMoved( long ); | 72 | void sliderMoved( long ); |
73 | void videoResized ( const QSize &s ); | 73 | void videoResized ( const QSize &s ); |
74 | 74 | ||
75 | protected: | 75 | protected: |
76 | 76 | ||
77 | void resizeEvent( QResizeEvent * ); | 77 | void resizeEvent( QResizeEvent * ); |
78 | void showEvent( QShowEvent *se ); | 78 | void showEvent( QShowEvent *se ); |
79 | void mouseMoveEvent( QMouseEvent *event ); | ||
80 | void mousePressEvent( QMouseEvent *event ); | 79 | void mousePressEvent( QMouseEvent *event ); |
81 | void mouseReleaseEvent( QMouseEvent *event ); | 80 | void mouseReleaseEvent( QMouseEvent *event ); |
82 | void keyReleaseEvent( QKeyEvent *e); | 81 | void keyReleaseEvent( QKeyEvent *e); |
83 | 82 | ||
84 | private: | 83 | private: |
85 | // Ticker songInfo; | 84 | // Ticker songInfo; |
86 | QImage imgUp; | 85 | QImage imgUp; |
87 | QImage imgDn; | 86 | QImage imgDn; |
88 | QString skin; | 87 | QString skin; |
89 | 88 | ||
90 | 89 | ||
91 | 90 | ||
92 | QString backgroundPix; | 91 | QString backgroundPix; |
93 | QSlider *slider; | 92 | QSlider *slider; |
94 | QImage *currentFrame; | 93 | QImage *currentFrame; |
95 | int scaledWidth; | 94 | int scaledWidth; |
96 | int scaledHeight; | 95 | int scaledHeight; |
97 | XineVideoWidget* videoFrame; | 96 | XineVideoWidget* videoFrame; |
98 | }; | 97 | }; |
99 | 98 | ||
100 | #endif // VIDEO_WIDGET_H | 99 | #endif // VIDEO_WIDGET_H |
101 | 100 | ||
102 | 101 | ||
103 | 102 | ||