summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-08 22:53:07 (UTC)
committer simon <simon>2002-12-08 22:53:07 (UTC)
commitcb1b7bf6f4dd465cc4f5b268893def8b11ce0bde (patch) (unidiff)
tree9e6497f79f24c690b5fdb737be5d38a3d5efcee5
parent786bc677f61983414df8a4613cc525c4bcd2a054 (diff)
downloadopie-cb1b7bf6f4dd465cc4f5b268893def8b11ce0bde.zip
opie-cb1b7bf6f4dd465cc4f5b268893def8b11ce0bde.tar.gz
opie-cb1b7bf6f4dd465cc4f5b268893def8b11ce0bde.tar.bz2
- some preparations for further code cleanups for paintButton calls
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp12
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.h2
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.h3
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp12
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.h2
5 files changed, 17 insertions, 14 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index d083273..10b1e58 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -291,105 +291,105 @@ void AudioWidget::setSeekable( bool isSeekable ) {
291 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 291 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
292 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 292 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
293 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 293 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
294 } 294 }
295} 295}
296 296
297 297
298static QString timeAsString( long length ) { 298static QString timeAsString( long length ) {
299 int minutes = length / 60; 299 int minutes = length / 60;
300 int seconds = length % 60; 300 int seconds = length % 60;
301 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); 301 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 );
302} 302}
303 303
304void AudioWidget::updateSlider( long i, long max ) { 304void AudioWidget::updateSlider( long i, long max ) {
305 305
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
328void AudioWidget::setToggleButton( int i, bool down ) { 328void AudioWidget::setToggleButton( int i, bool down ) {
329 qDebug("setToggleButton %d", i); 329 qDebug("setToggleButton %d", i);
330 if ( down != buttons[i].isDown ) { 330 if ( down != buttons[i].isDown ) {
331 toggleButton( i ); 331 toggleButton( i );
332 } 332 }
333} 333}
334 334
335 335
336void AudioWidget::toggleButton( int i ) { 336void AudioWidget::toggleButton( int i ) {
337 buttons[i].isDown = !buttons[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
343void AudioWidget::paintButton( QPainter *p, int i ) { 343void AudioWidget::paintButton( QPainter &p, int i ) {
344 if ( buttons[i].isDown ) { 344 if ( buttons[i].isDown ) {
345 p->drawPixmap( upperLeftOfButtonMask, *buttonPixDown[i] ); 345 p.drawPixmap( upperLeftOfButtonMask, *buttonPixDown[i] );
346 } else { 346 } else {
347 p->drawPixmap( upperLeftOfButtonMask, *buttonPixUp[i] ); 347 p.drawPixmap( upperLeftOfButtonMask, *buttonPixUp[i] );
348 } 348 }
349} 349}
350 350
351 351
352void AudioWidget::skipFor() { 352void 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
358void AudioWidget::skipBack() { 358void 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
366void AudioWidget::stopSkip() { 366void AudioWidget::stopSkip() {
367 killTimers(); 367 killTimers();
368} 368}
369 369
370 370
371void AudioWidget::timerEvent( QTimerEvent * ) { 371void 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
380void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { 380void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
381 for ( unsigned int i = 0; i < buttons.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 bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i ); 384 bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i );
385 385
386 if ( isOnButton && !buttons[i].isHeld ) { 386 if ( isOnButton && !buttons[i].isHeld ) {
387 buttons[i].isHeld = TRUE; 387 buttons[i].isHeld = TRUE;
388 toggleButton(i); 388 toggleButton(i);
389 switch (i) { 389 switch (i) {
390 case VolumeUp: 390 case VolumeUp:
391 emit moreClicked(); 391 emit moreClicked();
392 return; 392 return;
393 case VolumeDown: 393 case VolumeDown:
394 emit lessClicked(); 394 emit lessClicked();
395 return; 395 return;
@@ -397,103 +397,103 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
397 emit forwardClicked(); 397 emit forwardClicked();
398 return; 398 return;
399 case Back: 399 case Back:
400 emit backClicked(); 400 emit backClicked();
401 return; 401 return;
402 } 402 }
403 } else if ( !isOnButton && buttons[i].isHeld ) { 403 } else if ( !isOnButton && buttons[i].isHeld ) {
404 buttons[i].isHeld = FALSE; 404 buttons[i].isHeld = FALSE;
405 toggleButton(i); 405 toggleButton(i);
406 } 406 }
407 } else { 407 } else {
408 if ( buttons[i].isHeld ) { 408 if ( buttons[i].isHeld ) {
409 buttons[i].isHeld = FALSE; 409 buttons[i].isHeld = FALSE;
410 if ( !buttons[i].isToggle ) { 410 if ( !buttons[i].isToggle ) {
411 setToggleButton( i, FALSE ); 411 setToggleButton( i, FALSE );
412 } 412 }
413 qDebug("mouseEvent %d", i); 413 qDebug("mouseEvent %d", i);
414 handleCommand( static_cast<Command>( i ), buttons[ i ].isDown ); 414 handleCommand( static_cast<Command>( i ), buttons[ i ].isDown );
415 } 415 }
416 } 416 }
417 } 417 }
418} 418}
419 419
420 420
421void AudioWidget::mousePressEvent( QMouseEvent *event ) { 421void AudioWidget::mousePressEvent( QMouseEvent *event ) {
422 mouseMoveEvent( event ); 422 mouseMoveEvent( event );
423} 423}
424 424
425 425
426void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { 426void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) {
427 mouseMoveEvent( event ); 427 mouseMoveEvent( event );
428} 428}
429 429
430 430
431void AudioWidget::showEvent( QShowEvent* ) { 431void AudioWidget::showEvent( QShowEvent* ) {
432 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 432 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
433 mouseMoveEvent( &event ); 433 mouseMoveEvent( &event );
434} 434}
435 435
436 436
437void AudioWidget::paintEvent( QPaintEvent * pe ) { 437void AudioWidget::paintEvent( QPaintEvent * pe ) {
438 if ( !pe->erased() ) { 438 if ( !pe->erased() ) {
439 // Combine with background and double buffer 439 // Combine with background and double buffer
440 QPixmap pix( pe->rect().size() ); 440 QPixmap pix( pe->rect().size() );
441 QPainter p( &pix ); 441 QPainter p( &pix );
442 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 442 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
443 p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() ); 443 p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() );
444 for ( unsigned int i = 0; i < buttons.size(); i++ ) 444 for ( unsigned int i = 0; i < buttons.size(); i++ )
445 paintButton( &p, i ); 445 paintButton( p, i );
446 QPainter p2( this ); 446 QPainter p2( this );
447 p2.drawPixmap( pe->rect().topLeft(), pix ); 447 p2.drawPixmap( pe->rect().topLeft(), pix );
448 } else { 448 } else {
449 QPainter p( this ); 449 QPainter p( this );
450 for ( unsigned int i = 0; i < buttons.size(); i++ ) 450 for ( unsigned int i = 0; i < buttons.size(); i++ )
451 paintButton( &p, i ); 451 paintButton( p, i );
452 } 452 }
453} 453}
454 454
455void AudioWidget::keyReleaseEvent( QKeyEvent *e) { 455void AudioWidget::keyReleaseEvent( QKeyEvent *e) {
456 switch ( e->key() ) { 456 switch ( e->key() ) {
457 ////////////////////////////// Zaurus keys 457 ////////////////////////////// Zaurus keys
458 case Key_Home: 458 case Key_Home:
459 break; 459 break;
460 case Key_F9: //activity 460 case Key_F9: //activity
461 hide(); 461 hide();
462 // qDebug("Audio F9"); 462 // qDebug("Audio F9");
463 break; 463 break;
464 case Key_F10: //contacts 464 case Key_F10: //contacts
465 break; 465 break;
466 case Key_F11: //menu 466 case Key_F11: //menu
467 mediaPlayerState.toggleBlank(); 467 mediaPlayerState.toggleBlank();
468 break; 468 break;
469 case Key_F12: //home 469 case Key_F12: //home
470 break; 470 break;
471 case Key_F13: //mail 471 case Key_F13: //mail
472 mediaPlayerState.toggleBlank(); 472 mediaPlayerState.toggleBlank();
473 break; 473 break;
474 case Key_Space: { 474 case Key_Space: {
475 if(mediaPlayerState.isPlaying()) { 475 if(mediaPlayerState.isPlaying()) {
476 // toggleButton(1); 476 // toggleButton(1);
477 mediaPlayerState.setPlaying(FALSE); 477 mediaPlayerState.setPlaying(FALSE);
478 // toggleButton(1); 478 // toggleButton(1);
479 } else { 479 } else {
480 // toggleButton(0); 480 // toggleButton(0);
481 mediaPlayerState.setPlaying(TRUE); 481 mediaPlayerState.setPlaying(TRUE);
482 // toggleButton(0); 482 // toggleButton(0);
483 } 483 }
484 } 484 }
485 break; 485 break;
486 case Key_Down: 486 case Key_Down:
487 // toggleButton(6); 487 // toggleButton(6);
488 emit lessClicked(); 488 emit lessClicked();
489 emit lessReleased(); 489 emit lessReleased();
490 // toggleButton(6); 490 // toggleButton(6);
491 break; 491 break;
492 case Key_Up: 492 case Key_Up:
493 // toggleButton(5); 493 // toggleButton(5);
494 emit moreClicked(); 494 emit moreClicked();
495 emit moreReleased(); 495 emit moreReleased();
496 // toggleButton(5); 496 // toggleButton(5);
497 break; 497 break;
498 case Key_Right: 498 case Key_Right:
499 // toggleButton(3); 499 // toggleButton(3);
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h
index acf2dda..a1a839c 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.h
+++ b/noncore/multimedia/opieplayer2/audiowidget.h
@@ -48,68 +48,68 @@
48#include "mediawidget.h" 48#include "mediawidget.h"
49 49
50class QPixmap; 50class QPixmap;
51 51
52class AudioWidget : public MediaWidget { 52class AudioWidget : public MediaWidget {
53 Q_OBJECT 53 Q_OBJECT
54public: 54public:
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 ); }
58public slots: 58public 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
66public: 66public:
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
71signals: 71signals:
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
78protected: 78protected:
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);
89private slots: 89private slots:
90 void skipFor(); 90 void skipFor();
91 void skipBack(); 91 void skipBack();
92 void stopSkip(); 92 void stopSkip();
93private: 93private:
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 virtual 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 QBitmap *masks[10]; 102 QBitmap *masks[10];
103 QPixmap *buttonPixUp[10]; 103 QPixmap *buttonPixUp[10];
104 QPixmap *buttonPixDown[10]; 104 QPixmap *buttonPixDown[10];
105 105
106 QPixmap *pixmaps[4]; 106 QPixmap *pixmaps[4];
107 OTicker songInfo; 107 OTicker songInfo;
108 QSlider slider; 108 QSlider slider;
109 QLineEdit time; 109 QLineEdit time;
110 bool isStreaming : 1; 110 bool isStreaming : 1;
111}; 111};
112 112
113 113
114#endif // AUDIO_WIDGET_H 114#endif // AUDIO_WIDGET_H
115 115
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h
index 6e12a3b..066d2ac 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.h
+++ b/noncore/multimedia/opieplayer2/mediawidget.h
@@ -22,61 +22,64 @@
22 22
23#ifndef MEDIAWIDGET_H 23#ifndef MEDIAWIDGET_H
24#define MEDIAWIDGET_H 24#define MEDIAWIDGET_H
25 25
26#include <qwidget.h> 26#include <qwidget.h>
27 27
28#include "mediaplayerstate.h" 28#include "mediaplayerstate.h"
29#include "playlistwidget.h" 29#include "playlistwidget.h"
30 30
31#include <vector> 31#include <vector>
32 32
33class MediaWidget : public QWidget 33class MediaWidget : public QWidget
34{ 34{
35 Q_OBJECT 35 Q_OBJECT
36public: 36public:
37 enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back }; 37 enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back };
38 38
39 struct Button 39 struct Button
40 { 40 {
41 Button() : isToggle( false ), isHeld( false ), isDown( false ) {} 41 Button() : isToggle( false ), isHeld( false ), isDown( false ) {}
42 42
43 bool isToggle : 1; 43 bool isToggle : 1;
44 bool isHeld : 1; 44 bool isHeld : 1;
45 bool isDown : 1; 45 bool isDown : 1;
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
52public slots: 52public 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
57signals: 57signals:
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
63protected: 63protected:
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 bool isOverButton( const QPoint &position, int buttonId ) const; 68 bool isOverButton( const QPoint &position, int buttonId ) const;
69 69
70 void paintButton( int buttonId );
71 virtual void paintButton( QPainter &p, int i ) = 0;
72
70 MediaPlayerState &mediaPlayerState; 73 MediaPlayerState &mediaPlayerState;
71 PlayListWidget &playList; 74 PlayListWidget &playList;
72 75
73 ButtonVector buttons; 76 ButtonVector buttons;
74 77
75 QImage buttonMask; 78 QImage buttonMask;
76 79
77 QPoint upperLeftOfButtonMask; 80 QPoint upperLeftOfButtonMask;
78}; 81};
79 82
80#endif // MEDIAWIDGET_H 83#endif // MEDIAWIDGET_H
81/* vim: et sw=4 ts=4 84/* vim: et sw=4 ts=4
82 */ 85 */
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index 6451ac4..3e677c6 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -221,105 +221,105 @@ void VideoWidget::sliderReleased() {
221void VideoWidget::setPosition( long i ) { 221void VideoWidget::setPosition( long i ) {
222 updateSlider( i, mediaPlayerState.length() ); 222 updateSlider( i, mediaPlayerState.length() );
223} 223}
224 224
225 225
226void VideoWidget::setLength( long max ) { 226void VideoWidget::setLength( long max ) {
227 updateSlider( mediaPlayerState.position(), max ); 227 updateSlider( mediaPlayerState.position(), max );
228} 228}
229 229
230void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) 230void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType )
231{ 231{
232 if ( displayType == MediaPlayerState::Video ) { 232 if ( displayType == MediaPlayerState::Video ) {
233 makeVisible(); 233 makeVisible();
234 return; 234 return;
235 } 235 }
236 236
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
243void VideoWidget::updateSlider( long i, long max ) { 243void 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
260void VideoWidget::setToggleButton( int i, bool down ) { 260void VideoWidget::setToggleButton( int i, bool down ) {
261 if ( down != buttons[i].isDown ) { 261 if ( down != buttons[i].isDown ) {
262 toggleButton( i ); 262 toggleButton( i );
263 } 263 }
264} 264}
265 265
266void VideoWidget::toggleButton( int i ) { 266void VideoWidget::toggleButton( int i ) {
267 buttons[i].isDown = !buttons[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
272void VideoWidget::paintButton( QPainter *p, int i ) { 272void VideoWidget::paintButton( QPainter &p, int i ) {
273 273
274 if ( buttons[i].isDown ) { 274 if ( buttons[i].isDown ) {
275 p->drawPixmap( upperLeftOfButtonMask, *buttonPixDown[i] ); 275 p.drawPixmap( upperLeftOfButtonMask, *buttonPixDown[i] );
276 } else { 276 } else {
277 p->drawPixmap( upperLeftOfButtonMask, *buttonPixUp[i] ); 277 p.drawPixmap( upperLeftOfButtonMask, *buttonPixUp[i] );
278 } 278 }
279} 279}
280 280
281void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { 281void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
282 for ( unsigned int i = 0; i < buttons.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 bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i ); 285 bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i );
286 286
287 if ( isOnButton && !buttons[i].isHeld ) { 287 if ( isOnButton && !buttons[i].isHeld ) {
288 buttons[i].isHeld = TRUE; 288 buttons[i].isHeld = TRUE;
289 toggleButton(i); 289 toggleButton(i);
290 290
291 switch (i) { 291 switch (i) {
292 case VideoVolUp: 292 case VideoVolUp:
293 emit moreClicked(); 293 emit moreClicked();
294 return; 294 return;
295 case VideoVolDown: 295 case VideoVolDown:
296 emit lessClicked(); 296 emit lessClicked();
297 return; 297 return;
298 } 298 }
299 } else if ( !isOnButton && buttons[i].isHeld ) { 299 } else if ( !isOnButton && buttons[i].isHeld ) {
300 buttons[i].isHeld = FALSE; 300 buttons[i].isHeld = FALSE;
301 toggleButton(i); 301 toggleButton(i);
302 } 302 }
303 } else { 303 } else {
304 304
305 if ( buttons[i].isHeld ) { 305 if ( buttons[i].isHeld ) {
306 buttons[i].isHeld = FALSE; 306 buttons[i].isHeld = FALSE;
307 if ( !buttons[i].isToggle ) { 307 if ( !buttons[i].isToggle ) {
308 setToggleButton( i, FALSE ); 308 setToggleButton( i, FALSE );
309 } 309 }
310 310
311 switch(i) { 311 switch(i) {
312 312
313 case VideoPlay: { 313 case VideoPlay: {
314 if( mediaPlayerState.isPaused() ) { 314 if( mediaPlayerState.isPaused() ) {
315 setToggleButton( i, FALSE ); 315 setToggleButton( i, FALSE );
316 mediaPlayerState.setPaused( FALSE ); 316 mediaPlayerState.setPaused( FALSE );
317 return; 317 return;
318 } else if( !mediaPlayerState.isPaused() ) { 318 } else if( !mediaPlayerState.isPaused() ) {
319 setToggleButton( i, TRUE ); 319 setToggleButton( i, TRUE );
320 mediaPlayerState.setPaused( TRUE ); 320 mediaPlayerState.setPaused( TRUE );
321 return; 321 return;
322 } else { 322 } else {
323 return; 323 return;
324 } 324 }
325 } 325 }
@@ -377,104 +377,104 @@ void VideoWidget::makeVisible() {
377 showMaximized(); 377 showMaximized();
378 setBackgroundPixmap( pixBg ); 378 setBackgroundPixmap( pixBg );
379 QWidget *d = QApplication::desktop(); 379 QWidget *d = QApplication::desktop();
380 int w = d->width(); 380 int w = d->width();
381 int h = d->height(); 381 int h = d->height();
382 382
383 if(w>h) { 383 if(w>h) {
384 int newW=(w/2)-(246/2); //this will only work with 320x240 384 int newW=(w/2)-(246/2); //this will only work with 320x240
385 videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) ); 385 videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) );
386 } else { 386 } else {
387 videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); 387 videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) );
388 } 388 }
389 389
390 if ( !mediaPlayerState.isSeekable() ) { 390 if ( !mediaPlayerState.isSeekable() ) {
391 if( !slider->isHidden()) { 391 if( !slider->isHidden()) {
392 slider->hide(); 392 slider->hide();
393 } 393 }
394 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 394 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
395 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 395 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
396 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 396 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
397 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 397 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
398 } else { 398 } else {
399 slider->show(); 399 slider->show();
400 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 400 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
401 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 401 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
402 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 402 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
403 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 403 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
404 } 404 }
405 } 405 }
406} 406}
407 407
408 408
409 409
410 410
411void VideoWidget::paintEvent( QPaintEvent * pe) { 411void VideoWidget::paintEvent( QPaintEvent * pe) {
412 QPainter p( this ); 412 QPainter p( this );
413 413
414 if ( mediaPlayerState.isFullscreen() ) { 414 if ( mediaPlayerState.isFullscreen() ) {
415 // Clear the background 415 // Clear the background
416 p.setBrush( QBrush( Qt::black ) ); 416 p.setBrush( QBrush( Qt::black ) );
417 } else { 417 } else {
418 if ( !pe->erased() ) { 418 if ( !pe->erased() ) {
419 // Combine with background and double buffer 419 // Combine with background and double buffer
420 QPixmap pix( pe->rect().size() ); 420 QPixmap pix( pe->rect().size() );
421 QPainter p( &pix ); 421 QPainter p( &pix );
422 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 422 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
423 p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() ); 423 p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() );
424 for ( unsigned int i = 0; i < buttons.size(); i++ ) { 424 for ( unsigned int i = 0; i < buttons.size(); i++ ) {
425 paintButton( &p, i ); 425 paintButton( p, i );
426 } 426 }
427 QPainter p2( this ); 427 QPainter p2( this );
428 p2.drawPixmap( pe->rect().topLeft(), pix ); 428 p2.drawPixmap( pe->rect().topLeft(), pix );
429 } else { 429 } else {
430 QPainter p( this ); 430 QPainter p( this );
431 for ( unsigned int i = 0; i < buttons.size(); i++ ) 431 for ( unsigned int i = 0; i < buttons.size(); i++ )
432 paintButton( &p, i ); 432 paintButton( p, i );
433 } 433 }
434 //slider->repaint( TRUE ); 434 //slider->repaint( TRUE );
435 } 435 }
436} 436}
437 437
438 438
439void VideoWidget::keyReleaseEvent( QKeyEvent *e) { 439void VideoWidget::keyReleaseEvent( QKeyEvent *e) {
440 switch ( e->key() ) { 440 switch ( e->key() ) {
441////////////////////////////// Zaurus keys 441////////////////////////////// Zaurus keys
442 case Key_Home: 442 case Key_Home:
443 break; 443 break;
444 case Key_F9: //activity 444 case Key_F9: //activity
445 break; 445 break;
446 case Key_F10: //contacts 446 case Key_F10: //contacts
447// hide(); 447// hide();
448 break; 448 break;
449 case Key_F11: //menu 449 case Key_F11: //menu
450 break; 450 break;
451 case Key_F12: //home 451 case Key_F12: //home
452 break; 452 break;
453 case Key_F13: //mail 453 case Key_F13: //mail
454 break; 454 break;
455 case Key_Space: { 455 case Key_Space: {
456 if(mediaPlayerState.isPlaying()) { 456 if(mediaPlayerState.isPlaying()) {
457 mediaPlayerState.setPlaying(FALSE); 457 mediaPlayerState.setPlaying(FALSE);
458 } else { 458 } else {
459 mediaPlayerState.setPlaying(TRUE); 459 mediaPlayerState.setPlaying(TRUE);
460 } 460 }
461 } 461 }
462 break; 462 break;
463 case Key_Down: 463 case Key_Down:
464// toggleButton(6); 464// toggleButton(6);
465 emit lessClicked(); 465 emit lessClicked();
466 emit lessReleased(); 466 emit lessReleased();
467// toggleButton(6); 467// toggleButton(6);
468 break; 468 break;
469 case Key_Up: 469 case Key_Up:
470// toggleButton(5); 470// toggleButton(5);
471 emit moreClicked(); 471 emit moreClicked();
472 emit moreReleased(); 472 emit moreReleased();
473// toggleButton(5); 473// toggleButton(5);
474 break; 474 break;
475 case Key_Right: 475 case Key_Right:
476 mediaPlayerState.setNext(); 476 mediaPlayerState.setNext();
477 break; 477 break;
478 case Key_Left: 478 case Key_Left:
479 mediaPlayerState.setPrev(); 479 mediaPlayerState.setPrev();
480 break; 480 break;
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h
index 2a9f1e0..28f720b 100644
--- a/noncore/multimedia/opieplayer2/videowidget.h
+++ b/noncore/multimedia/opieplayer2/videowidget.h
@@ -62,65 +62,65 @@ public:
62 ~VideoWidget(); 62 ~VideoWidget();
63 63
64 64
65 XineVideoWidget* vidWidget(); 65 XineVideoWidget* vidWidget();
66public slots: 66public slots:
67 void updateSlider( long, long ); 67 void updateSlider( long, long );
68 void sliderPressed( ); 68 void sliderPressed( );
69 void sliderReleased( ); 69 void sliderReleased( );
70 void setFullscreen( bool b ); 70 void setFullscreen( bool b );
71 void makeVisible(); 71 void makeVisible();
72 void backToNormal(); 72 void backToNormal();
73 void setPosition( long ); 73 void setPosition( long );
74 74
75public: 75public:
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
80signals: 80signals:
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
88protected: 88protected:
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
98private: 98private:
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 QBitmap *masks[7]; 103 QBitmap *masks[7];
104 QPixmap *buttonPixUp[7]; 104 QPixmap *buttonPixUp[7];
105 QPixmap *buttonPixDown[7]; 105 QPixmap *buttonPixDown[7];
106 QString skin; 106 QString skin;
107// QPixmap *pixmaps[4]; 107// QPixmap *pixmaps[4];
108 108
109 109
110 void paintButton( QPainter *p, int i ); 110 virtual void paintButton( QPainter &p, int i );
111 void toggleButton( int ); 111 void toggleButton( int );
112 void setToggleButton( int, bool ); 112 void setToggleButton( int, bool );
113 113
114 QString backgroundPix; 114 QString backgroundPix;
115 QSlider *slider; 115 QSlider *slider;
116 QPixmap *pixmaps[3]; 116 QPixmap *pixmaps[3];
117 QImage *currentFrame; 117 QImage *currentFrame;
118 int scaledWidth; 118 int scaledWidth;
119 int scaledHeight; 119 int scaledHeight;
120 XineVideoWidget* videoFrame; 120 XineVideoWidget* videoFrame;
121}; 121};
122 122
123#endif // VIDEO_WIDGET_H 123#endif // VIDEO_WIDGET_H
124 124
125 125
126 126