-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 13 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.h | 1 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.cpp | 10 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.h | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 15 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.h | 1 |
6 files changed, 14 insertions, 28 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index 12f91a9..5cc2814 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp | |||
@@ -284,73 +284,64 @@ static QString timeAsString( long length ) { | |||
284 | 284 | ||
285 | void AudioWidget::updateSlider( long i, long max ) { | 285 | void AudioWidget::updateSlider( long i, long max ) { |
286 | 286 | ||
287 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); | 287 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); |
288 | // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; | 288 | // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; |
289 | 289 | ||
290 | if ( max == 0 ) { | 290 | if ( max == 0 ) { |
291 | return; | 291 | return; |
292 | } | 292 | } |
293 | // Will flicker too much if we don't do this | 293 | // Will flicker too much if we don't do this |
294 | // Scale to something reasonable | 294 | // Scale to something reasonable |
295 | int width = slider.width(); | 295 | int width = slider.width(); |
296 | int val = int((double)i * width / max); | 296 | int val = int((double)i * width / max); |
297 | if ( !audioSliderBeingMoved ) { | 297 | if ( !audioSliderBeingMoved ) { |
298 | if ( slider.value() != val ) { | 298 | if ( slider.value() != val ) { |
299 | slider.setValue( val ); | 299 | slider.setValue( val ); |
300 | } | 300 | } |
301 | 301 | ||
302 | if ( slider.maxValue() != width ) { | 302 | if ( slider.maxValue() != width ) { |
303 | slider.setMaxValue( width ); | 303 | slider.setMaxValue( width ); |
304 | } | 304 | } |
305 | } | 305 | } |
306 | } | 306 | } |
307 | 307 | ||
308 | 308 | ||
309 | void AudioWidget::setToggleButton( int i, bool down ) { | 309 | void AudioWidget::setToggleButton( int i, bool down ) { |
310 | qDebug("setToggleButton %d", i); | 310 | qDebug("setToggleButton %d", i); |
311 | if ( down != buttons[i].isDown ) { | 311 | if ( down != buttons[i].isDown ) { |
312 | toggleButton( i ); | 312 | toggleButton( i ); |
313 | } | 313 | } |
314 | } | 314 | } |
315 | 315 | ||
316 | void AudioWidget::paintButton( QPainter &p, int i ) { | ||
317 | if ( buttons[i].isDown ) { | ||
318 | p.drawPixmap( upperLeftOfButtonMask, buttons[i].pixDown ); | ||
319 | } else { | ||
320 | p.drawPixmap( upperLeftOfButtonMask, buttons[i].pixUp ); | ||
321 | } | ||
322 | } | ||
323 | |||
324 | |||
325 | void AudioWidget::skipFor() { | 316 | void AudioWidget::skipFor() { |
326 | skipDirection = +1; | 317 | skipDirection = +1; |
327 | startTimer( 50 ); | 318 | startTimer( 50 ); |
328 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); | 319 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); |
329 | } | 320 | } |
330 | 321 | ||
331 | void AudioWidget::skipBack() { | 322 | void AudioWidget::skipBack() { |
332 | skipDirection = -1; | 323 | skipDirection = -1; |
333 | startTimer( 50 ); | 324 | startTimer( 50 ); |
334 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); | 325 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); |
335 | } | 326 | } |
336 | 327 | ||
337 | 328 | ||
338 | 329 | ||
339 | void AudioWidget::stopSkip() { | 330 | void AudioWidget::stopSkip() { |
340 | killTimers(); | 331 | killTimers(); |
341 | } | 332 | } |
342 | 333 | ||
343 | 334 | ||
344 | void AudioWidget::timerEvent( QTimerEvent * ) { | 335 | void AudioWidget::timerEvent( QTimerEvent * ) { |
345 | if ( skipDirection == +1 ) { | 336 | if ( skipDirection == +1 ) { |
346 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); | 337 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); |
347 | } else if ( skipDirection == -1 ) { | 338 | } else if ( skipDirection == -1 ) { |
348 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); | 339 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); |
349 | } | 340 | } |
350 | } | 341 | } |
351 | 342 | ||
352 | 343 | ||
353 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { | 344 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { |
354 | for ( unsigned int i = 0; i < buttons.count(); i++ ) { | 345 | for ( unsigned int i = 0; i < buttons.count(); i++ ) { |
355 | if ( event->state() == QMouseEvent::LeftButton ) { | 346 | if ( event->state() == QMouseEvent::LeftButton ) { |
356 | // The test to see if the mouse click is inside the button or not | 347 | // The test to see if the mouse click is inside the button or not |
@@ -386,71 +377,71 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { | |||
386 | qDebug("mouseEvent %d", i); | 377 | qDebug("mouseEvent %d", i); |
387 | handleCommand( static_cast<Command>( i ), buttons[ i ].isDown ); | 378 | handleCommand( static_cast<Command>( i ), buttons[ i ].isDown ); |
388 | } | 379 | } |
389 | } | 380 | } |
390 | } | 381 | } |
391 | } | 382 | } |
392 | 383 | ||
393 | 384 | ||
394 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { | 385 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { |
395 | mouseMoveEvent( event ); | 386 | mouseMoveEvent( event ); |
396 | } | 387 | } |
397 | 388 | ||
398 | 389 | ||
399 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { | 390 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { |
400 | mouseMoveEvent( event ); | 391 | mouseMoveEvent( event ); |
401 | } | 392 | } |
402 | 393 | ||
403 | 394 | ||
404 | void AudioWidget::showEvent( QShowEvent* ) { | 395 | void AudioWidget::showEvent( QShowEvent* ) { |
405 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); | 396 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); |
406 | mouseMoveEvent( &event ); | 397 | mouseMoveEvent( &event ); |
407 | } | 398 | } |
408 | 399 | ||
409 | 400 | ||
410 | void AudioWidget::paintEvent( QPaintEvent * pe ) { | 401 | void AudioWidget::paintEvent( QPaintEvent * pe ) { |
411 | if ( !pe->erased() ) { | 402 | if ( !pe->erased() ) { |
412 | // Combine with background and double buffer | 403 | // Combine with background and double buffer |
413 | QPixmap pix( pe->rect().size() ); | 404 | QPixmap pix( pe->rect().size() ); |
414 | QPainter p( &pix ); | 405 | QPainter p( &pix ); |
415 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | 406 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); |
416 | p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() ); | 407 | p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() ); |
417 | for ( unsigned int i = 0; i < buttons.count(); i++ ) | 408 | for ( unsigned int i = 0; i < buttons.count(); i++ ) |
418 | paintButton( p, i ); | 409 | paintButton( p, buttons[ i ] ); |
419 | QPainter p2( this ); | 410 | QPainter p2( this ); |
420 | p2.drawPixmap( pe->rect().topLeft(), pix ); | 411 | p2.drawPixmap( pe->rect().topLeft(), pix ); |
421 | } else { | 412 | } else { |
422 | QPainter p( this ); | 413 | QPainter p( this ); |
423 | for ( unsigned int i = 0; i < buttons.count(); i++ ) | 414 | for ( unsigned int i = 0; i < buttons.count(); i++ ) |
424 | paintButton( p, i ); | 415 | paintButton( p, buttons[ i ] ); |
425 | } | 416 | } |
426 | } | 417 | } |
427 | 418 | ||
428 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { | 419 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { |
429 | switch ( e->key() ) { | 420 | switch ( e->key() ) { |
430 | ////////////////////////////// Zaurus keys | 421 | ////////////////////////////// Zaurus keys |
431 | case Key_Home: | 422 | case Key_Home: |
432 | break; | 423 | break; |
433 | case Key_F9: //activity | 424 | case Key_F9: //activity |
434 | hide(); | 425 | hide(); |
435 | // qDebug("Audio F9"); | 426 | // qDebug("Audio F9"); |
436 | break; | 427 | break; |
437 | case Key_F10: //contacts | 428 | case Key_F10: //contacts |
438 | break; | 429 | break; |
439 | case Key_F11: //menu | 430 | case Key_F11: //menu |
440 | mediaPlayerState.toggleBlank(); | 431 | mediaPlayerState.toggleBlank(); |
441 | break; | 432 | break; |
442 | case Key_F12: //home | 433 | case Key_F12: //home |
443 | break; | 434 | break; |
444 | case Key_F13: //mail | 435 | case Key_F13: //mail |
445 | mediaPlayerState.toggleBlank(); | 436 | mediaPlayerState.toggleBlank(); |
446 | break; | 437 | break; |
447 | case Key_Space: { | 438 | case Key_Space: { |
448 | mediaPlayerState.togglePaused(); | 439 | mediaPlayerState.togglePaused(); |
449 | } | 440 | } |
450 | break; | 441 | break; |
451 | case Key_Down: | 442 | case Key_Down: |
452 | // toggleButton(6); | 443 | // toggleButton(6); |
453 | emit lessClicked(); | 444 | emit lessClicked(); |
454 | emit lessReleased(); | 445 | emit lessReleased(); |
455 | // toggleButton(6); | 446 | // toggleButton(6); |
456 | break; | 447 | break; |
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h index 332fb4b..7a775cd 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.h +++ b/noncore/multimedia/opieplayer2/audiowidget.h | |||
@@ -63,49 +63,48 @@ public slots: | |||
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(); | 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 ); | 81 | void paintEvent( QPaintEvent *pe ); |
82 | void showEvent( QShowEvent *se ); | 82 | void showEvent( QShowEvent *se ); |
83 | void resizeEvent( QResizeEvent *re ); | 83 | void resizeEvent( QResizeEvent *re ); |
84 | void mouseMoveEvent( QMouseEvent *event ); | 84 | void mouseMoveEvent( QMouseEvent *event ); |
85 | void mousePressEvent( QMouseEvent *event ); | 85 | void mousePressEvent( QMouseEvent *event ); |
86 | void mouseReleaseEvent( QMouseEvent *event ); | 86 | void mouseReleaseEvent( QMouseEvent *event ); |
87 | void timerEvent( QTimerEvent *event ); | 87 | void timerEvent( QTimerEvent *event ); |
88 | void keyReleaseEvent( QKeyEvent *e); | 88 | void keyReleaseEvent( QKeyEvent *e); |
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 setToggleButton( int, bool ); | 94 | void setToggleButton( int, bool ); |
95 | virtual void paintButton( QPainter &p, int i ); | ||
96 | int skipDirection; | 95 | int skipDirection; |
97 | QString skin; | 96 | QString skin; |
98 | QPixmap pixBg; | 97 | QPixmap pixBg; |
99 | QImage imgUp; | 98 | QImage imgUp; |
100 | QImage imgDn; | 99 | QImage imgDn; |
101 | 100 | ||
102 | OTicker songInfo; | 101 | OTicker songInfo; |
103 | QSlider slider; | 102 | QSlider slider; |
104 | QLineEdit time; | 103 | QLineEdit time; |
105 | bool isStreaming : 1; | 104 | bool isStreaming : 1; |
106 | bool audioSliderBeingMoved : 1; | 105 | bool audioSliderBeingMoved : 1; |
107 | }; | 106 | }; |
108 | 107 | ||
109 | 108 | ||
110 | #endif // AUDIO_WIDGET_H | 109 | #endif // AUDIO_WIDGET_H |
111 | 110 | ||
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp index 62266ad..f977b61 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.cpp +++ b/noncore/multimedia/opieplayer2/mediawidget.cpp | |||
@@ -42,43 +42,51 @@ MediaWidget::~MediaWidget() | |||
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::handleCommand( Command command, bool buttonDown ) | 47 | void MediaWidget::handleCommand( Command command, bool buttonDown ) |
48 | { | 48 | { |
49 | switch ( command ) { | 49 | switch ( command ) { |
50 | case Play: mediaPlayerState.togglePaused(); | 50 | case Play: mediaPlayerState.togglePaused(); |
51 | case Stop: mediaPlayerState.setPlaying(FALSE); return; | 51 | case Stop: mediaPlayerState.setPlaying(FALSE); return; |
52 | case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; | 52 | case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; |
53 | case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; | 53 | case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; |
54 | case Loop: mediaPlayerState.setLooping( buttonDown ); return; | 54 | case Loop: mediaPlayerState.setLooping( buttonDown ); return; |
55 | case VolumeUp: emit moreReleased(); return; | 55 | case VolumeUp: emit moreReleased(); return; |
56 | case VolumeDown: emit lessReleased(); return; | 56 | case VolumeDown: emit lessReleased(); return; |
57 | case PlayList: mediaPlayerState.setList(); return; | 57 | case PlayList: mediaPlayerState.setList(); return; |
58 | case Forward: emit forwardReleased(); return; | 58 | case Forward: emit forwardReleased(); return; |
59 | case Back: emit backReleased(); return; | 59 | case Back: emit backReleased(); return; |
60 | } | 60 | } |
61 | } | 61 | } |
62 | 62 | ||
63 | bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const | 63 | bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const |
64 | { | 64 | { |
65 | return ( position.x() > 0 && position.y() > 0 && | 65 | return ( position.x() > 0 && position.y() > 0 && |
66 | position.x() < buttonMask.width() && | 66 | position.x() < buttonMask.width() && |
67 | position.y() < buttonMask.height() && | 67 | position.y() < buttonMask.height() && |
68 | buttonMask.pixelIndex( position.x(), position.y() ) == buttonId + 1 ); | 68 | buttonMask.pixelIndex( position.x(), position.y() ) == buttonId + 1 ); |
69 | } | 69 | } |
70 | 70 | ||
71 | void MediaWidget::paintButton( int buttonId ) | 71 | void MediaWidget::paintButton( int buttonId ) |
72 | { | 72 | { |
73 | QPainter p( this ); | 73 | QPainter p( this ); |
74 | paintButton( p, buttonId ); | 74 | paintButton( p, buttons[ buttonId ] ); |
75 | } | ||
76 | |||
77 | void MediaWidget::paintButton( QPainter &p, const Button &button ) | ||
78 | { | ||
79 | if ( button.isDown ) | ||
80 | p.drawPixmap( upperLeftOfButtonMask, button.pixDown ); | ||
81 | else | ||
82 | p.drawPixmap( upperLeftOfButtonMask, button.pixUp ); | ||
75 | } | 83 | } |
76 | 84 | ||
77 | void MediaWidget::toggleButton( int buttonId ) | 85 | void MediaWidget::toggleButton( int buttonId ) |
78 | { | 86 | { |
79 | buttons[ buttonId ].isDown = !buttons[ buttonId ].isDown; | 87 | buttons[ buttonId ].isDown = !buttons[ buttonId ].isDown; |
80 | paintButton( buttonId ); | 88 | paintButton( buttonId ); |
81 | } | 89 | } |
82 | 90 | ||
83 | /* vim: et sw=4 ts=4 | 91 | /* vim: et sw=4 ts=4 |
84 | */ | 92 | */ |
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h index 49bf024..163f449 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.h +++ b/noncore/multimedia/opieplayer2/mediawidget.h | |||
@@ -57,49 +57,49 @@ public: | |||
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 | 80 | ||
81 | protected: | 81 | protected: |
82 | virtual void closeEvent( QCloseEvent * ); | 82 | virtual void closeEvent( QCloseEvent * ); |
83 | 83 | ||
84 | void handleCommand( Command command, bool buttonDown ); | 84 | void handleCommand( Command command, bool buttonDown ); |
85 | 85 | ||
86 | bool isOverButton( const QPoint &position, int buttonId ) const; | 86 | bool isOverButton( const QPoint &position, int buttonId ) const; |
87 | 87 | ||
88 | void paintButton( int buttonId ); | 88 | void paintButton( int buttonId ); |
89 | virtual void paintButton( QPainter &p, int i ) = 0; | 89 | void paintButton( QPainter &p, const Button &button ); |
90 | 90 | ||
91 | void toggleButton( int buttonId ); | 91 | void toggleButton( int buttonId ); |
92 | 92 | ||
93 | MediaPlayerState &mediaPlayerState; | 93 | MediaPlayerState &mediaPlayerState; |
94 | PlayListWidget &playList; | 94 | PlayListWidget &playList; |
95 | 95 | ||
96 | ButtonMap buttons; | 96 | ButtonMap buttons; |
97 | 97 | ||
98 | QImage buttonMask; | 98 | QImage buttonMask; |
99 | 99 | ||
100 | QPoint upperLeftOfButtonMask; | 100 | QPoint upperLeftOfButtonMask; |
101 | }; | 101 | }; |
102 | 102 | ||
103 | #endif // MEDIAWIDGET_H | 103 | #endif // MEDIAWIDGET_H |
104 | /* vim: et sw=4 ts=4 | 104 | /* vim: et sw=4 ts=4 |
105 | */ | 105 | */ |
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index 3baa087..a483434 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp | |||
@@ -219,75 +219,64 @@ void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) | |||
219 | return; | 219 | return; |
220 | } | 220 | } |
221 | 221 | ||
222 | // Effectively blank the view next time we show it so it looks nicer | 222 | // Effectively blank the view next time we show it so it looks nicer |
223 | scaledWidth = 0; | 223 | scaledWidth = 0; |
224 | scaledHeight = 0; | 224 | scaledHeight = 0; |
225 | hide(); | 225 | hide(); |
226 | } | 226 | } |
227 | 227 | ||
228 | void VideoWidget::updateSlider( long i, long max ) { | 228 | void VideoWidget::updateSlider( long i, long max ) { |
229 | // Will flicker too much if we don't do this | 229 | // Will flicker too much if we don't do this |
230 | if ( max == 0 ) { | 230 | if ( max == 0 ) { |
231 | return; | 231 | return; |
232 | } | 232 | } |
233 | int width = slider->width(); | 233 | int width = slider->width(); |
234 | int val = int((double)i * width / max); | 234 | int val = int((double)i * width / max); |
235 | if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { | 235 | if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { |
236 | if ( slider->value() != val ) { | 236 | if ( slider->value() != val ) { |
237 | slider->setValue( val ); | 237 | slider->setValue( val ); |
238 | } | 238 | } |
239 | if ( slider->maxValue() != width ) { | 239 | if ( slider->maxValue() != width ) { |
240 | slider->setMaxValue( width ); | 240 | slider->setMaxValue( width ); |
241 | } | 241 | } |
242 | } | 242 | } |
243 | } | 243 | } |
244 | 244 | ||
245 | void VideoWidget::setToggleButton( int i, bool down ) { | 245 | void VideoWidget::setToggleButton( int i, bool down ) { |
246 | if ( down != buttons[i].isDown ) { | 246 | if ( down != buttons[i].isDown ) { |
247 | toggleButton( i ); | 247 | toggleButton( i ); |
248 | } | 248 | } |
249 | } | 249 | } |
250 | 250 | ||
251 | void VideoWidget::paintButton( QPainter &p, int i ) { | ||
252 | |||
253 | Button &button = buttons[ i ]; | ||
254 | |||
255 | if ( button.isDown ) { | ||
256 | p.drawPixmap( upperLeftOfButtonMask, button.pixDown ); | ||
257 | } else { | ||
258 | p.drawPixmap( upperLeftOfButtonMask, button.pixUp ); | ||
259 | } | ||
260 | } | ||
261 | |||
262 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | 251 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { |
263 | for ( unsigned int i = 0; i < buttons.count(); i++ ) { | 252 | for ( unsigned int i = 0; i < buttons.count(); i++ ) { |
264 | if ( event->state() == QMouseEvent::LeftButton ) { | 253 | if ( event->state() == QMouseEvent::LeftButton ) { |
265 | // The test to see if the mouse click is inside the button or not | 254 | // The test to see if the mouse click is inside the button or not |
266 | bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i ); | 255 | bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i ); |
267 | 256 | ||
268 | if ( isOnButton && !buttons[i].isHeld ) { | 257 | if ( isOnButton && !buttons[i].isHeld ) { |
269 | buttons[i].isHeld = TRUE; | 258 | buttons[i].isHeld = TRUE; |
270 | toggleButton(i); | 259 | toggleButton(i); |
271 | 260 | ||
272 | switch (i) { | 261 | switch (i) { |
273 | case VideoVolUp: | 262 | case VideoVolUp: |
274 | emit moreClicked(); | 263 | emit moreClicked(); |
275 | return; | 264 | return; |
276 | case VideoVolDown: | 265 | case VideoVolDown: |
277 | emit lessClicked(); | 266 | emit lessClicked(); |
278 | return; | 267 | return; |
279 | } | 268 | } |
280 | } else if ( !isOnButton && buttons[i].isHeld ) { | 269 | } else if ( !isOnButton && buttons[i].isHeld ) { |
281 | buttons[i].isHeld = FALSE; | 270 | buttons[i].isHeld = FALSE; |
282 | toggleButton(i); | 271 | toggleButton(i); |
283 | } | 272 | } |
284 | } else { | 273 | } else { |
285 | 274 | ||
286 | if ( buttons[i].isHeld ) { | 275 | if ( buttons[i].isHeld ) { |
287 | buttons[i].isHeld = FALSE; | 276 | buttons[i].isHeld = FALSE; |
288 | if ( buttons[i].type != ToggleButton ) { | 277 | if ( buttons[i].type != ToggleButton ) { |
289 | setToggleButton( i, FALSE ); | 278 | setToggleButton( i, FALSE ); |
290 | } | 279 | } |
291 | 280 | ||
292 | switch(i) { | 281 | switch(i) { |
293 | 282 | ||
@@ -374,72 +363,72 @@ void VideoWidget::makeVisible() { | |||
374 | } | 363 | } |
375 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 364 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
376 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 365 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
377 | disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 366 | disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
378 | disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 367 | disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
379 | } else { | 368 | } else { |
380 | slider->show(); | 369 | slider->show(); |
381 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 370 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
382 | connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 371 | connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
383 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 372 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
384 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 373 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
385 | } | 374 | } |
386 | } | 375 | } |
387 | } | 376 | } |
388 | 377 | ||
389 | 378 | ||
390 | 379 | ||
391 | 380 | ||
392 | void VideoWidget::paintEvent( QPaintEvent * pe) { | 381 | void VideoWidget::paintEvent( QPaintEvent * pe) { |
393 | QPainter p( this ); | 382 | QPainter p( this ); |
394 | 383 | ||
395 | if ( mediaPlayerState.isFullscreen() ) { | 384 | if ( mediaPlayerState.isFullscreen() ) { |
396 | // Clear the background | 385 | // Clear the background |
397 | p.setBrush( QBrush( Qt::black ) ); | 386 | p.setBrush( QBrush( Qt::black ) ); |
398 | } else { | 387 | } else { |
399 | if ( !pe->erased() ) { | 388 | if ( !pe->erased() ) { |
400 | // Combine with background and double buffer | 389 | // Combine with background and double buffer |
401 | QPixmap pix( pe->rect().size() ); | 390 | QPixmap pix( pe->rect().size() ); |
402 | QPainter p( &pix ); | 391 | QPainter p( &pix ); |
403 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | 392 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); |
404 | p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() ); | 393 | p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() ); |
405 | for ( unsigned int i = 0; i < buttons.count(); i++ ) { | 394 | for ( unsigned int i = 0; i < buttons.count(); i++ ) { |
406 | paintButton( p, i ); | 395 | paintButton( p, buttons[ i ] ); |
407 | } | 396 | } |
408 | QPainter p2( this ); | 397 | QPainter p2( this ); |
409 | p2.drawPixmap( pe->rect().topLeft(), pix ); | 398 | p2.drawPixmap( pe->rect().topLeft(), pix ); |
410 | } else { | 399 | } else { |
411 | QPainter p( this ); | 400 | QPainter p( this ); |
412 | for ( unsigned int i = 0; i < buttons.count(); i++ ) | 401 | for ( unsigned int i = 0; i < buttons.count(); i++ ) |
413 | paintButton( p, i ); | 402 | paintButton( p, buttons[ i ] ); |
414 | } | 403 | } |
415 | //slider->repaint( TRUE ); | 404 | //slider->repaint( TRUE ); |
416 | } | 405 | } |
417 | } | 406 | } |
418 | 407 | ||
419 | 408 | ||
420 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { | 409 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { |
421 | switch ( e->key() ) { | 410 | switch ( e->key() ) { |
422 | ////////////////////////////// Zaurus keys | 411 | ////////////////////////////// Zaurus keys |
423 | case Key_Home: | 412 | case Key_Home: |
424 | break; | 413 | break; |
425 | case Key_F9: //activity | 414 | case Key_F9: //activity |
426 | break; | 415 | break; |
427 | case Key_F10: //contacts | 416 | case Key_F10: //contacts |
428 | // hide(); | 417 | // hide(); |
429 | break; | 418 | break; |
430 | case Key_F11: //menu | 419 | case Key_F11: //menu |
431 | break; | 420 | break; |
432 | case Key_F12: //home | 421 | case Key_F12: //home |
433 | break; | 422 | break; |
434 | case Key_F13: //mail | 423 | case Key_F13: //mail |
435 | break; | 424 | break; |
436 | case Key_Space: { | 425 | case Key_Space: { |
437 | if(mediaPlayerState.isPlaying()) { | 426 | if(mediaPlayerState.isPlaying()) { |
438 | mediaPlayerState.setPlaying(FALSE); | 427 | mediaPlayerState.setPlaying(FALSE); |
439 | } else { | 428 | } else { |
440 | mediaPlayerState.setPlaying(TRUE); | 429 | mediaPlayerState.setPlaying(TRUE); |
441 | } | 430 | } |
442 | } | 431 | } |
443 | break; | 432 | break; |
444 | case Key_Down: | 433 | case Key_Down: |
445 | // toggleButton(6); | 434 | // toggleButton(6); |
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h index 937feac..a271120 100644 --- a/noncore/multimedia/opieplayer2/videowidget.h +++ b/noncore/multimedia/opieplayer2/videowidget.h | |||
@@ -74,47 +74,46 @@ public slots: | |||
74 | 74 | ||
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 ); | 91 | void paintEvent( QPaintEvent *pe ); |
92 | void showEvent( QShowEvent *se ); | 92 | void showEvent( QShowEvent *se ); |
93 | void mouseMoveEvent( QMouseEvent *event ); | 93 | void mouseMoveEvent( QMouseEvent *event ); |
94 | void mousePressEvent( QMouseEvent *event ); | 94 | void mousePressEvent( QMouseEvent *event ); |
95 | void mouseReleaseEvent( QMouseEvent *event ); | 95 | void mouseReleaseEvent( QMouseEvent *event ); |
96 | void keyReleaseEvent( QKeyEvent *e); | 96 | void keyReleaseEvent( QKeyEvent *e); |
97 | 97 | ||
98 | private: | 98 | 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 | QString skin; | 103 | QString skin; |
104 | 104 | ||
105 | 105 | ||
106 | virtual void paintButton( QPainter &p, int i ); | ||
107 | void setToggleButton( int, bool ); | 106 | void setToggleButton( int, bool ); |
108 | 107 | ||
109 | QString backgroundPix; | 108 | QString backgroundPix; |
110 | QSlider *slider; | 109 | QSlider *slider; |
111 | QImage *currentFrame; | 110 | QImage *currentFrame; |
112 | int scaledWidth; | 111 | int scaledWidth; |
113 | int scaledHeight; | 112 | int scaledHeight; |
114 | XineVideoWidget* videoFrame; | 113 | XineVideoWidget* videoFrame; |
115 | }; | 114 | }; |
116 | 115 | ||
117 | #endif // VIDEO_WIDGET_H | 116 | #endif // VIDEO_WIDGET_H |
118 | 117 | ||
119 | 118 | ||
120 | 119 | ||