summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp75
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.h2
-rw-r--r--noncore/multimedia/opieplayer2/main.cpp4
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.cpp10
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.h5
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp75
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.h2
7 files changed, 87 insertions, 86 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index f4edb79..d9beb90 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -41,25 +41,24 @@
41#include <qbutton.h> 41#include <qbutton.h>
42#include <qpainter.h> 42#include <qpainter.h>
43#include <qframe.h> 43#include <qframe.h>
44#include <qlayout.h> 44#include <qlayout.h>
45#include <qdir.h> 45#include <qdir.h>
46#include <stdlib.h> 46#include <stdlib.h>
47#include <stdio.h> 47#include <stdio.h>
48 48
49#include "audiowidget.h" 49#include "audiowidget.h"
50#include "mediaplayerstate.h" 50#include "mediaplayerstate.h"
51#include "playlistwidget.h" 51#include "playlistwidget.h"
52 52
53extern MediaPlayerState *mediaPlayerState;
54extern PlayListWidget *playList; 53extern PlayListWidget *playList;
55 54
56static const int xo = -2; // movable x offset 55static const int xo = -2; // movable x offset
57static const int yo = 22; // movable y offset 56static const int yo = 22; // movable y offset
58 57
59struct MediaButton { 58struct MediaButton {
60 bool isToggle, isHeld, isDown; 59 bool isToggle, isHeld, isDown;
61}; 60};
62 61
63//Layout information for the audioButtons (and if it is a toggle button or not) 62//Layout information for the audioButtons (and if it is a toggle button or not)
64MediaButton audioButtons[] = { 63MediaButton audioButtons[] = {
65 { TRUE, FALSE, FALSE }, // play 64 { TRUE, FALSE, FALSE }, // play
@@ -81,27 +80,27 @@ const char * const skin_mask_file_names[10] = {
81 80
82 81
83static void changeTextColor( QWidget *w ) { 82static void changeTextColor( QWidget *w ) {
84 QPalette p = w->palette(); 83 QPalette p = w->palette();
85 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); 84 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) );
86 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); 85 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) );
87 w->setPalette( p ); 86 w->setPalette( p );
88} 87}
89 88
90static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); 89static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton));
91 90
92 91
93AudioWidget::AudioWidget(QWidget* parent, const char* name) : 92AudioWidget::AudioWidget( MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) :
94 93
95 MediaWidget( parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { 94 MediaWidget( mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) {
96 95
97 setCaption( tr("OpiePlayer") ); 96 setCaption( tr("OpiePlayer") );
98 97
99 Config cfg("OpiePlayer"); 98 Config cfg("OpiePlayer");
100 cfg.setGroup("Options"); 99 cfg.setGroup("Options");
101 skin = cfg.readEntry("Skin","default"); 100 skin = cfg.readEntry("Skin","default");
102 //skin = "scaleTest"; 101 //skin = "scaleTest";
103 // color of background, frame, degree of transparency 102 // color of background, frame, degree of transparency
104 103
105 QString skinPath = "opieplayer2/skins/" + skin; 104 QString skinPath = "opieplayer2/skins/" + skin;
106 pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 105 pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
107 imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); 106 imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) );
@@ -150,38 +149,38 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name) :
150// Config cofg("qpe"); 149// Config cofg("qpe");
151// cofg.setGroup("Appearance"); 150// cofg.setGroup("Appearance");
152// QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); 151// QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) );
153 152
154 time.setFocusPolicy( QWidget::NoFocus ); 153 time.setFocusPolicy( QWidget::NoFocus );
155 time.setAlignment( Qt::AlignCenter ); 154 time.setAlignment( Qt::AlignCenter );
156 155
157// time.setFrame(FALSE); 156// time.setFrame(FALSE);
158// changeTextColor( &time ); 157// changeTextColor( &time );
159 158
160 resizeEvent( NULL ); 159 resizeEvent( NULL );
161 160
162 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); 161 connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
163 connect( mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) ); 162 connect( &mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) );
164 163
165 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); 164 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) );
166 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); 165 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) );
167 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); 166 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) );
168 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); 167 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) );
169 168
170 // Intialise state 169 // Intialise state
171 setLength( mediaPlayerState->length() ); 170 setLength( mediaPlayerState.length() );
172 setPosition( mediaPlayerState->position() ); 171 setPosition( mediaPlayerState.position() );
173 setLooping( mediaPlayerState->isFullscreen() ); 172 setLooping( mediaPlayerState.isFullscreen() );
174 // setPaused( mediaPlayerState->paused() ); 173 // setPaused( mediaPlayerState->paused() );
175 setPlaying( mediaPlayerState->isPlaying() ); 174 setPlaying( mediaPlayerState.isPlaying() );
176 175
177} 176}
178 177
179AudioWidget::~AudioWidget() { 178AudioWidget::~AudioWidget() {
180 179
181 for ( int i = 0; i < 10; i++ ) { 180 for ( int i = 0; i < 10; i++ ) {
182 delete buttonPixUp[i]; 181 delete buttonPixUp[i];
183 delete buttonPixDown[i]; 182 delete buttonPixDown[i];
184 } 183 }
185 for ( int i = 0; i < 10; i++ ) { 184 for ( int i = 0; i < 10; i++ ) {
186 delete masks[i]; 185 delete masks[i];
187 } 186 }
@@ -237,69 +236,69 @@ void AudioWidget::resizeEvent( QResizeEvent * ) {
237static bool audioSliderBeingMoved = FALSE; 236static bool audioSliderBeingMoved = FALSE;
238 237
239 238
240void AudioWidget::sliderPressed() { 239void AudioWidget::sliderPressed() {
241 audioSliderBeingMoved = TRUE; 240 audioSliderBeingMoved = TRUE;
242} 241}
243 242
244 243
245void AudioWidget::sliderReleased() { 244void AudioWidget::sliderReleased() {
246 audioSliderBeingMoved = FALSE; 245 audioSliderBeingMoved = FALSE;
247 if ( slider.width() == 0 ) 246 if ( slider.width() == 0 )
248 return; 247 return;
249 long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); 248 long val = long((double)slider.value() * mediaPlayerState.length() / slider.width());
250 mediaPlayerState->setPosition( val ); 249 mediaPlayerState.setPosition( val );
251} 250}
252 251
253void AudioWidget::setPosition( long i ) { 252void AudioWidget::setPosition( long i ) {
254 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); 253 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i);
255 updateSlider( i, mediaPlayerState->length() ); 254 updateSlider( i, mediaPlayerState.length() );
256} 255}
257 256
258 257
259void AudioWidget::setLength( long max ) { 258void AudioWidget::setLength( long max ) {
260 updateSlider( mediaPlayerState->position(), max ); 259 updateSlider( mediaPlayerState.position(), max );
261} 260}
262 261
263 262
264void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { 263void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) {
265 if ( mediaType == MediaPlayerState::Audio ) { 264 if ( mediaType == MediaPlayerState::Audio ) {
266 // startTimer( 150 ); 265 // startTimer( 150 );
267 showMaximized(); 266 showMaximized();
268 return; 267 return;
269 } 268 }
270 269
271 killTimers(); 270 killTimers();
272 hide(); 271 hide();
273} 272}
274 273
275 274
276void AudioWidget::setSeekable( bool isSeekable ) { 275void AudioWidget::setSeekable( bool isSeekable ) {
277 276
278 if ( !isSeekable ) { 277 if ( !isSeekable ) {
279 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); 278 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>");
280 if( !slider.isHidden()) { 279 if( !slider.isHidden()) {
281 slider.hide(); 280 slider.hide();
282 } 281 }
283 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 282 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
284 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 283 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
285 disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 284 disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
286 disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 285 disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
287 } else { 286 } else {
288 // this stops the slider from being moved, thus 287 // this stops the slider from being moved, thus
289 // does not stop stream when it reaches the end 288 // does not stop stream when it reaches the end
290 slider.show(); 289 slider.show();
291 qDebug( " CONNECT SET POSTION " ); 290 qDebug( " CONNECT SET POSTION " );
292 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 291 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
293 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 292 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
294 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 293 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
295 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 294 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
296 } 295 }
297} 296}
298 297
299 298
300static QString timeAsString( long length ) { 299static QString timeAsString( long length ) {
301 int minutes = length / 60; 300 int minutes = length / 60;
302 int seconds = length % 60; 301 int seconds = length % 60;
303 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); 302 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 );
304} 303}
305 304
@@ -345,45 +344,45 @@ void AudioWidget::toggleButton( int i ) {
345void AudioWidget::paintButton( QPainter *p, int i ) { 344void AudioWidget::paintButton( QPainter *p, int i ) {
346 if ( audioButtons[i].isDown ) { 345 if ( audioButtons[i].isDown ) {
347 p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); 346 p->drawPixmap( xoff, yoff, *buttonPixDown[i] );
348 } else { 347 } else {
349 p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); 348 p->drawPixmap( xoff, yoff, *buttonPixUp[i] );
350 } 349 }
351} 350}
352 351
353 352
354void AudioWidget::skipFor() { 353void AudioWidget::skipFor() {
355 skipDirection = +1; 354 skipDirection = +1;
356 startTimer( 50 ); 355 startTimer( 50 );
357 mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); 356 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 );
358} 357}
359 358
360void AudioWidget::skipBack() { 359void AudioWidget::skipBack() {
361 skipDirection = -1; 360 skipDirection = -1;
362 startTimer( 50 ); 361 startTimer( 50 );
363 mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); 362 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 );
364} 363}
365 364
366 365
367 366
368void AudioWidget::stopSkip() { 367void AudioWidget::stopSkip() {
369 killTimers(); 368 killTimers();
370} 369}
371 370
372 371
373void AudioWidget::timerEvent( QTimerEvent * ) { 372void AudioWidget::timerEvent( QTimerEvent * ) {
374 if ( skipDirection == +1 ) { 373 if ( skipDirection == +1 ) {
375 mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); 374 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 );
376 } else if ( skipDirection == -1 ) { 375 } else if ( skipDirection == -1 ) {
377 mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); 376 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 );
378 } 377 }
379} 378}
380 379
381 380
382void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { 381void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
383 for ( int i = 0; i < numButtons; i++ ) { 382 for ( int i = 0; i < numButtons; i++ ) {
384 if ( event->state() == QMouseEvent::LeftButton ) { 383 if ( event->state() == QMouseEvent::LeftButton ) {
385 // The test to see if the mouse click is inside the button or not 384 // The test to see if the mouse click is inside the button or not
386 int x = event->pos().x() - xoff; 385 int x = event->pos().x() - xoff;
387 int y = event->pos().y() - yoff; 386 int y = event->pos().y() - yoff;
388 387
389 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask.width() 388 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask.width()
@@ -411,38 +410,38 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
411 audioButtons[i].isHeld = FALSE; 410 audioButtons[i].isHeld = FALSE;
412 toggleButton(i); 411 toggleButton(i);
413 } 412 }
414 } else { 413 } else {
415 if ( audioButtons[i].isHeld ) { 414 if ( audioButtons[i].isHeld ) {
416 audioButtons[i].isHeld = FALSE; 415 audioButtons[i].isHeld = FALSE;
417 if ( !audioButtons[i].isToggle ) { 416 if ( !audioButtons[i].isToggle ) {
418 setToggleButton( i, FALSE ); 417 setToggleButton( i, FALSE );
419 } 418 }
420 qDebug("mouseEvent %d", i); 419 qDebug("mouseEvent %d", i);
421 switch (i) { 420 switch (i) {
422 case AudioPlay: 421 case AudioPlay:
423 if( mediaPlayerState->isPaused() ) { 422 if( mediaPlayerState.isPaused() ) {
424 mediaPlayerState->setPaused( FALSE ); 423 mediaPlayerState.setPaused( FALSE );
425 return; 424 return;
426 } else if( !mediaPlayerState->isPaused() ) { 425 } else if( !mediaPlayerState.isPaused() ) {
427 mediaPlayerState->setPaused( TRUE ); 426 mediaPlayerState.setPaused( TRUE );
428 return; 427 return;
429 } 428 }
430 case AudioStop: mediaPlayerState->setPlaying(FALSE); return; 429 case AudioStop: mediaPlayerState.setPlaying(FALSE); return;
431 case AudioNext: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState->setNext(); return; 430 case AudioNext: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return;
432 case AudioPrevious: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState->setPrev(); return; 431 case AudioPrevious: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return;
433 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; 432 case AudioLoop: mediaPlayerState.setLooping(audioButtons[i].isDown); return;
434 case AudioVolumeUp: emit moreReleased(); return; 433 case AudioVolumeUp: emit moreReleased(); return;
435 case AudioVolumeDown: emit lessReleased(); return; 434 case AudioVolumeDown: emit lessReleased(); return;
436 case AudioPlayList: mediaPlayerState->setList(); return; 435 case AudioPlayList: mediaPlayerState.setList(); return;
437 case AudioForward: emit forwardReleased(); return; 436 case AudioForward: emit forwardReleased(); return;
438 case AudioBack: emit backReleased(); return; 437 case AudioBack: emit backReleased(); return;
439 } 438 }
440 } 439 }
441 } 440 }
442 } 441 }
443} 442}
444 443
445 444
446void AudioWidget::mousePressEvent( QMouseEvent *event ) { 445void AudioWidget::mousePressEvent( QMouseEvent *event ) {
447 mouseMoveEvent( event ); 446 mouseMoveEvent( event );
448} 447}
@@ -451,25 +450,25 @@ void AudioWidget::mousePressEvent( QMouseEvent *event ) {
451void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { 450void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) {
452 mouseMoveEvent( event ); 451 mouseMoveEvent( event );
453} 452}
454 453
455 454
456void AudioWidget::showEvent( QShowEvent* ) { 455void AudioWidget::showEvent( QShowEvent* ) {
457 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 456 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
458 mouseMoveEvent( &event ); 457 mouseMoveEvent( &event );
459} 458}
460 459
461 460
462void AudioWidget::closeEvent( QCloseEvent* ) { 461void AudioWidget::closeEvent( QCloseEvent* ) {
463 mediaPlayerState->setList(); 462 mediaPlayerState.setList();
464} 463}
465 464
466 465
467void AudioWidget::paintEvent( QPaintEvent * pe ) { 466void AudioWidget::paintEvent( QPaintEvent * pe ) {
468 if ( !pe->erased() ) { 467 if ( !pe->erased() ) {
469 // Combine with background and double buffer 468 // Combine with background and double buffer
470 QPixmap pix( pe->rect().size() ); 469 QPixmap pix( pe->rect().size() );
471 QPainter p( &pix ); 470 QPainter p( &pix );
472 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 471 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
473 p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() ); 472 p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() );
474 for ( int i = 0; i < numButtons; i++ ) 473 for ( int i = 0; i < numButtons; i++ )
475 paintButton( &p, i ); 474 paintButton( &p, i );
@@ -485,59 +484,59 @@ void AudioWidget::paintEvent( QPaintEvent * pe ) {
485void AudioWidget::keyReleaseEvent( QKeyEvent *e) { 484void AudioWidget::keyReleaseEvent( QKeyEvent *e) {
486 switch ( e->key() ) { 485 switch ( e->key() ) {
487 ////////////////////////////// Zaurus keys 486 ////////////////////////////// Zaurus keys
488 case Key_Home: 487 case Key_Home:
489 break; 488 break;
490 case Key_F9: //activity 489 case Key_F9: //activity
491 hide(); 490 hide();
492 // qDebug("Audio F9"); 491 // qDebug("Audio F9");
493 break; 492 break;
494 case Key_F10: //contacts 493 case Key_F10: //contacts
495 break; 494 break;
496 case Key_F11: //menu 495 case Key_F11: //menu
497 mediaPlayerState->toggleBlank(); 496 mediaPlayerState.toggleBlank();
498 break; 497 break;
499 case Key_F12: //home 498 case Key_F12: //home
500 break; 499 break;
501 case Key_F13: //mail 500 case Key_F13: //mail
502 mediaPlayerState->toggleBlank(); 501 mediaPlayerState.toggleBlank();
503 break; 502 break;
504 case Key_Space: { 503 case Key_Space: {
505 if(mediaPlayerState->isPlaying()) { 504 if(mediaPlayerState.isPlaying()) {
506 // toggleButton(1); 505 // toggleButton(1);
507 mediaPlayerState->setPlaying(FALSE); 506 mediaPlayerState.setPlaying(FALSE);
508 // toggleButton(1); 507 // toggleButton(1);
509 } else { 508 } else {
510 // toggleButton(0); 509 // toggleButton(0);
511 mediaPlayerState->setPlaying(TRUE); 510 mediaPlayerState.setPlaying(TRUE);
512 // toggleButton(0); 511 // toggleButton(0);
513 } 512 }
514 } 513 }
515 break; 514 break;
516 case Key_Down: 515 case Key_Down:
517 // toggleButton(6); 516 // toggleButton(6);
518 emit lessClicked(); 517 emit lessClicked();
519 emit lessReleased(); 518 emit lessReleased();
520 // toggleButton(6); 519 // toggleButton(6);
521 break; 520 break;
522 case Key_Up: 521 case Key_Up:
523 // toggleButton(5); 522 // toggleButton(5);
524 emit moreClicked(); 523 emit moreClicked();
525 emit moreReleased(); 524 emit moreReleased();
526 // toggleButton(5); 525 // toggleButton(5);
527 break; 526 break;
528 case Key_Right: 527 case Key_Right:
529 // toggleButton(3); 528 // toggleButton(3);
530 mediaPlayerState->setNext(); 529 mediaPlayerState.setNext();
531 // toggleButton(3); 530 // toggleButton(3);
532 break; 531 break;
533 case Key_Left: 532 case Key_Left:
534 // toggleButton(4); 533 // toggleButton(4);
535 mediaPlayerState->setPrev(); 534 mediaPlayerState.setPrev();
536 // toggleButton(4); 535 // toggleButton(4);
537 break; 536 break;
538 case Key_Escape: { 537 case Key_Escape: {
539 } 538 }
540 break; 539 break;
541 540
542 }; 541 };
543} 542}
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h
index 83927f1..087d711 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.h
+++ b/noncore/multimedia/opieplayer2/audiowidget.h
@@ -59,25 +59,25 @@ enum AudioButtons {
59 AudioVolumeUp, 59 AudioVolumeUp,
60 AudioVolumeDown, 60 AudioVolumeDown,
61 AudioLoop, 61 AudioLoop,
62 AudioPlayList, 62 AudioPlayList,
63 AudioForward, 63 AudioForward,
64 AudioBack 64 AudioBack
65}; 65};
66}; 66};
67 67
68class AudioWidget : public MediaWidget { 68class AudioWidget : public MediaWidget {
69 Q_OBJECT 69 Q_OBJECT
70public: 70public:
71 AudioWidget( QWidget* parent=0, const char* name=0 ); 71 AudioWidget( MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 );
72 ~AudioWidget(); 72 ~AudioWidget();
73 void setTickerText( const QString &text ) { songInfo.setText( text ); } 73 void setTickerText( const QString &text ) { songInfo.setText( text ); }
74public slots: 74public slots:
75 void updateSlider( long, long ); 75 void updateSlider( long, long );
76 void sliderPressed( ); 76 void sliderPressed( );
77 void sliderReleased( ); 77 void sliderReleased( );
78 void setLooping( bool b) { setToggleButton( AudioLoop, b ); } 78 void setLooping( bool b) { setToggleButton( AudioLoop, b ); }
79 void setPosition( long ); 79 void setPosition( long );
80 void setSeekable( bool ); 80 void setSeekable( bool );
81 81
82public: 82public:
83 virtual void setLength( long ); 83 virtual void setLength( long );
diff --git a/noncore/multimedia/opieplayer2/main.cpp b/noncore/multimedia/opieplayer2/main.cpp
index 02fdbf3..fd47ea5 100644
--- a/noncore/multimedia/opieplayer2/main.cpp
+++ b/noncore/multimedia/opieplayer2/main.cpp
@@ -10,25 +10,25 @@ MediaPlayerState *mediaPlayerState;
10PlayListWidget *playList; 10PlayListWidget *playList;
11AudioWidget *audioUI; 11AudioWidget *audioUI;
12VideoWidget *videoUI; 12VideoWidget *videoUI;
13 13
14int main(int argc, char **argv) { 14int main(int argc, char **argv) {
15 QPEApplication a(argc,argv); 15 QPEApplication a(argc,argv);
16 16
17 MediaPlayerState st( 0, "mediaPlayerState" ); 17 MediaPlayerState st( 0, "mediaPlayerState" );
18 mediaPlayerState = &st; 18 mediaPlayerState = &st;
19 PlayListWidget pl( st, 0, "playList" ); 19 PlayListWidget pl( st, 0, "playList" );
20 playList = &pl; 20 playList = &pl;
21 pl.showMaximized(); 21 pl.showMaximized();
22 AudioWidget aw( 0, "audioUI" ); 22 AudioWidget aw( st, 0, "audioUI" );
23 audioUI = &aw; 23 audioUI = &aw;
24 VideoWidget vw( 0, "videoUI" ); 24 VideoWidget vw( st, 0, "videoUI" );
25 videoUI = &vw; 25 videoUI = &vw;
26 a.processEvents(); 26 a.processEvents();
27 MediaPlayer mp( st, 0, "mediaPlayer" ); 27 MediaPlayer mp( st, 0, "mediaPlayer" );
28 28
29 a.showMainDocumentWidget(&pl); 29 a.showMainDocumentWidget(&pl);
30 30
31 return a.exec(); 31 return a.exec();
32} 32}
33 33
34 34
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp
index 83456a0..d58e87e 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.cpp
+++ b/noncore/multimedia/opieplayer2/mediawidget.cpp
@@ -13,29 +13,29 @@
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20 20
21#include "mediawidget.h" 21#include "mediawidget.h"
22 22
23extern MediaPlayerState *mediaPlayerState; 23extern MediaPlayerState *mediaPlayerState;
24 24
25MediaWidget::MediaWidget( QWidget *parent, const char *name ) 25MediaWidget::MediaWidget( MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name )
26 : QWidget( parent, name ) 26 : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState )
27{ 27{
28 connect( mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ), 28 connect( &mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ),
29 this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) ); 29 this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) );
30 connect( mediaPlayerState, SIGNAL( lengthChanged( long ) ), 30 connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ),
31 this, SLOT( setLength( long ) ) ); 31 this, SLOT( setLength( long ) ) );
32 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), 32 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ),
33 this, SLOT( setPlaying( bool ) ) ); 33 this, SLOT( setPlaying( bool ) ) );
34} 34}
35 35
36MediaWidget::~MediaWidget() 36MediaWidget::~MediaWidget()
37{ 37{
38} 38}
39 39
40/* vim: et sw=4 ts=4 40/* vim: et sw=4 ts=4
41 */ 41 */
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h
index fc5198e..64adba9 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.h
+++ b/noncore/multimedia/opieplayer2/mediawidget.h
@@ -19,24 +19,27 @@
19 19
20#ifndef MEDIAWIDGET_H 20#ifndef MEDIAWIDGET_H
21#define MEDIAWIDGET_H 21#define MEDIAWIDGET_H
22 22
23#include <qwidget.h> 23#include <qwidget.h>
24 24
25#include "mediaplayerstate.h" 25#include "mediaplayerstate.h"
26 26
27class MediaWidget : public QWidget 27class MediaWidget : public QWidget
28{ 28{
29 Q_OBJECT 29 Q_OBJECT
30public: 30public:
31 MediaWidget( QWidget *parent = 0, const char *name = 0 ); 31 MediaWidget( MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 );
32 virtual ~MediaWidget(); 32 virtual ~MediaWidget();
33 33
34public slots: 34public slots:
35 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0; 35 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0;
36 virtual void setLength( long length ) = 0; 36 virtual void setLength( long length ) = 0;
37 virtual void setPlaying( bool playing ) = 0; 37 virtual void setPlaying( bool playing ) = 0;
38
39protected:
40 MediaPlayerState &mediaPlayerState;
38}; 41};
39 42
40#endif // MEDIAWIDGET_H 43#endif // MEDIAWIDGET_H
41/* vim: et sw=4 ts=4 44/* vim: et sw=4 ts=4
42 */ 45 */
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index e0ca243..b4ecb4c 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -44,25 +44,24 @@
44#include "videowidget.h" 44#include "videowidget.h"
45#include "mediaplayerstate.h" 45#include "mediaplayerstate.h"
46#include "playlistwidget.h" 46#include "playlistwidget.h"
47 47
48 48
49#ifdef Q_WS_QWS 49#ifdef Q_WS_QWS
50# define USE_DIRECT_PAINTER 50# define USE_DIRECT_PAINTER
51# include <qdirectpainter_qws.h> 51# include <qdirectpainter_qws.h>
52# include <qgfxraster_qws.h> 52# include <qgfxraster_qws.h>
53#endif 53#endif
54 54
55 55
56extern MediaPlayerState *mediaPlayerState;
57extern PlayListWidget *playList; 56extern PlayListWidget *playList;
58 57
59 58
60static const int xo = 2; // movable x offset 59static const int xo = 2; // movable x offset
61static const int yo = 0; // movable y offset 60static const int yo = 0; // movable y offset
62 61
63 62
64struct MediaButton { 63struct MediaButton {
65 bool isToggle, isHeld, isDown; 64 bool isToggle, isHeld, isDown;
66}; 65};
67 66
68MediaButton videoButtons[] = { 67MediaButton videoButtons[] = {
@@ -73,26 +72,26 @@ MediaButton videoButtons[] = {
73 { FALSE, FALSE, FALSE }, // volUp 72 { FALSE, FALSE, FALSE }, // volUp
74 { FALSE, FALSE, FALSE }, // volDown 73 { FALSE, FALSE, FALSE }, // volDown
75 { TRUE, FALSE, FALSE } // fullscreen 74 { TRUE, FALSE, FALSE } // fullscreen
76}; 75};
77 76
78const char *skinV_mask_file_names[7] = { 77const char *skinV_mask_file_names[7] = {
79"stop","play","back","fwd","up","down","full" 78"stop","play","back","fwd","up","down","full"
80}; 79};
81 80
82static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton)); 81static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton));
83 82
84 83
85VideoWidget::VideoWidget(QWidget* parent, const char* name) : 84VideoWidget::VideoWidget(MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) :
86MediaWidget( parent, name ), scaledWidth( 0 ), scaledHeight( 0 ) { 85MediaWidget( mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ) {
87 86
88 87
89 setCaption( tr("OpiePlayer - Video") ); 88 setCaption( tr("OpiePlayer - Video") );
90 89
91 videoFrame = new XineVideoWidget ( this, "Video frame" ); 90 videoFrame = new XineVideoWidget ( this, "Video frame" );
92 91
93 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); 92 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & )));
94 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); 93 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) );
95 94
96 Config cfg("OpiePlayer"); 95 Config cfg("OpiePlayer");
97 cfg.setGroup("Options"); 96 cfg.setGroup("Options");
98 skin = cfg.readEntry("Skin","default"); 97 skin = cfg.readEntry("Skin","default");
@@ -128,28 +127,28 @@ MediaWidget( parent, name ), scaledWidth( 0 ), scaledHeight( 0 ) {
128 } 127 }
129 128
130 setBackgroundPixmap( *pixBg ); 129 setBackgroundPixmap( *pixBg );
131 130
132 slider = new QSlider( Qt::Horizontal, this ); 131 slider = new QSlider( Qt::Horizontal, this );
133 slider->setMinValue( 0 ); 132 slider->setMinValue( 0 );
134 slider->setMaxValue( 1 ); 133 slider->setMaxValue( 1 );
135 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); 134 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
136 //slider->setFocusPolicy( QWidget::NoFocus ); 135 //slider->setFocusPolicy( QWidget::NoFocus );
137 136
138 resizeEvent( NULL ); 137 resizeEvent( NULL );
139 138
140 setLength( mediaPlayerState->length() ); 139 setLength( mediaPlayerState.length() );
141 setPosition( mediaPlayerState->position() ); 140 setPosition( mediaPlayerState.position() );
142 setFullscreen( mediaPlayerState->isFullscreen() ); 141 setFullscreen( mediaPlayerState.isFullscreen() );
143 setPlaying( mediaPlayerState->isPlaying() ); 142 setPlaying( mediaPlayerState.isPlaying() );
144} 143}
145 144
146 145
147VideoWidget::~VideoWidget() { 146VideoWidget::~VideoWidget() {
148 147
149 for ( int i = 0; i < 7; i++ ) { 148 for ( int i = 0; i < 7; i++ ) {
150 delete buttonPixUp[i]; 149 delete buttonPixUp[i];
151 delete buttonPixDown[i]; 150 delete buttonPixDown[i];
152 } 151 }
153 152
154 delete pixBg; 153 delete pixBg;
155 delete imgUp; 154 delete imgUp;
@@ -212,58 +211,58 @@ void VideoWidget::resizeEvent( QResizeEvent * ) {
212 211
213static bool videoSliderBeingMoved = FALSE; 212static bool videoSliderBeingMoved = FALSE;
214 213
215void VideoWidget::sliderPressed() { 214void VideoWidget::sliderPressed() {
216 videoSliderBeingMoved = TRUE; 215 videoSliderBeingMoved = TRUE;
217} 216}
218 217
219void VideoWidget::sliderReleased() { 218void VideoWidget::sliderReleased() {
220 videoSliderBeingMoved = FALSE; 219 videoSliderBeingMoved = FALSE;
221 if ( slider->width() == 0 ) { 220 if ( slider->width() == 0 ) {
222 return; 221 return;
223 } 222 }
224 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); 223 long val = long((double)slider->value() * mediaPlayerState.length() / slider->width());
225 mediaPlayerState->setPosition( val ); 224 mediaPlayerState.setPosition( val );
226} 225}
227 226
228void VideoWidget::setPosition( long i ) { 227void VideoWidget::setPosition( long i ) {
229 updateSlider( i, mediaPlayerState->length() ); 228 updateSlider( i, mediaPlayerState.length() );
230} 229}
231 230
232 231
233void VideoWidget::setLength( long max ) { 232void VideoWidget::setLength( long max ) {
234 updateSlider( mediaPlayerState->position(), max ); 233 updateSlider( mediaPlayerState.position(), max );
235} 234}
236 235
237void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) 236void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType )
238{ 237{
239 if ( displayType == MediaPlayerState::Video ) { 238 if ( displayType == MediaPlayerState::Video ) {
240 makeVisible(); 239 makeVisible();
241 return; 240 return;
242 } 241 }
243 242
244 // Effectively blank the view next time we show it so it looks nicer 243 // Effectively blank the view next time we show it so it looks nicer
245 scaledWidth = 0; 244 scaledWidth = 0;
246 scaledHeight = 0; 245 scaledHeight = 0;
247 hide(); 246 hide();
248} 247}
249 248
250void VideoWidget::updateSlider( long i, long max ) { 249void VideoWidget::updateSlider( long i, long max ) {
251 // Will flicker too much if we don't do this 250 // Will flicker too much if we don't do this
252 if ( max == 0 ) { 251 if ( max == 0 ) {
253 return; 252 return;
254 } 253 }
255 int width = slider->width(); 254 int width = slider->width();
256 int val = int((double)i * width / max); 255 int val = int((double)i * width / max);
257 if ( !mediaPlayerState->isFullscreen() && !videoSliderBeingMoved ) { 256 if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) {
258 if ( slider->value() != val ) { 257 if ( slider->value() != val ) {
259 slider->setValue( val ); 258 slider->setValue( val );
260 } 259 }
261 if ( slider->maxValue() != width ) { 260 if ( slider->maxValue() != width ) {
262 slider->setMaxValue( width ); 261 slider->setMaxValue( width );
263 } 262 }
264 } 263 }
265} 264}
266 265
267void VideoWidget::setToggleButton( int i, bool down ) { 266void VideoWidget::setToggleButton( int i, bool down ) {
268 if ( down != videoButtons[i].isDown ) { 267 if ( down != videoButtons[i].isDown ) {
269 toggleButton( i ); 268 toggleButton( i );
@@ -314,125 +313,125 @@ void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
314 } 313 }
315 } else { 314 } else {
316 315
317 if ( videoButtons[i].isHeld ) { 316 if ( videoButtons[i].isHeld ) {
318 videoButtons[i].isHeld = FALSE; 317 videoButtons[i].isHeld = FALSE;
319 if ( !videoButtons[i].isToggle ) { 318 if ( !videoButtons[i].isToggle ) {
320 setToggleButton( i, FALSE ); 319 setToggleButton( i, FALSE );
321 } 320 }
322 321
323 switch(i) { 322 switch(i) {
324 323
325 case VideoPlay: { 324 case VideoPlay: {
326 if( mediaPlayerState->isPaused() ) { 325 if( mediaPlayerState.isPaused() ) {
327 setToggleButton( i, FALSE ); 326 setToggleButton( i, FALSE );
328 mediaPlayerState->setPaused( FALSE ); 327 mediaPlayerState.setPaused( FALSE );
329 return; 328 return;
330 } else if( !mediaPlayerState->isPaused() ) { 329 } else if( !mediaPlayerState.isPaused() ) {
331 setToggleButton( i, TRUE ); 330 setToggleButton( i, TRUE );
332 mediaPlayerState->setPaused( TRUE ); 331 mediaPlayerState.setPaused( TRUE );
333 return; 332 return;
334 } else { 333 } else {
335 return; 334 return;
336 } 335 }
337 } 336 }
338 337
339 case VideoStop: mediaPlayerState->setPlaying( FALSE ); return; 338 case VideoStop: mediaPlayerState.setPlaying( FALSE ); return;
340 case VideoNext: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState->setNext(); return; 339 case VideoNext: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return;
341 case VideoPrevious: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState->setPrev(); return; 340 case VideoPrevious: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return;
342 case VideoVolUp: emit moreReleased(); return; 341 case VideoVolUp: emit moreReleased(); return;
343 case VideoVolDown: emit lessReleased(); return; 342 case VideoVolDown: emit lessReleased(); return;
344 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; 343 case VideoFullscreen: mediaPlayerState.setFullscreen( TRUE ); makeVisible(); return;
345 } 344 }
346 } 345 }
347 } 346 }
348 } 347 }
349} 348}
350 349
351void VideoWidget::mousePressEvent( QMouseEvent *event ) { 350void VideoWidget::mousePressEvent( QMouseEvent *event ) {
352 mouseMoveEvent( event ); 351 mouseMoveEvent( event );
353} 352}
354 353
355void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 354void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
356 if ( mediaPlayerState->isFullscreen() ) { 355 if ( mediaPlayerState.isFullscreen() ) {
357 mediaPlayerState->setFullscreen( FALSE ); 356 mediaPlayerState.setFullscreen( FALSE );
358 makeVisible(); 357 makeVisible();
359 } 358 }
360 mouseMoveEvent( event ); 359 mouseMoveEvent( event );
361} 360}
362 361
363void VideoWidget::showEvent( QShowEvent* ) { 362void VideoWidget::showEvent( QShowEvent* ) {
364 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 363 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
365 mouseMoveEvent( &event ); 364 mouseMoveEvent( &event );
366} 365}
367 366
368 367
369 void VideoWidget::backToNormal() { 368 void VideoWidget::backToNormal() {
370 mediaPlayerState->setFullscreen( FALSE ); 369 mediaPlayerState.setFullscreen( FALSE );
371 makeVisible(); 370 makeVisible();
372 } 371 }
373 372
374void VideoWidget::makeVisible() { 373void VideoWidget::makeVisible() {
375 if ( mediaPlayerState->isFullscreen() ) { 374 if ( mediaPlayerState.isFullscreen() ) {
376 setBackgroundMode( QWidget::NoBackground ); 375 setBackgroundMode( QWidget::NoBackground );
377 showFullScreen(); 376 showFullScreen();
378 resize( qApp->desktop()->size() ); 377 resize( qApp->desktop()->size() );
379 videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); 378 videoFrame-> setGeometry ( 0, 0, width ( ), height ( ));
380 379
381 slider->hide(); 380 slider->hide();
382 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 381 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
383 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 382 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
384 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 383 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
385 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 384 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
386 385
387 } else { 386 } else {
388 showNormal(); 387 showNormal();
389 showMaximized(); 388 showMaximized();
390 setBackgroundPixmap( *pixBg ); 389 setBackgroundPixmap( *pixBg );
391 QWidget *d = QApplication::desktop(); 390 QWidget *d = QApplication::desktop();
392 int w = d->width(); 391 int w = d->width();
393 int h = d->height(); 392 int h = d->height();
394 393
395 if(w>h) { 394 if(w>h) {
396 int newW=(w/2)-(246/2); //this will only work with 320x240 395 int newW=(w/2)-(246/2); //this will only work with 320x240
397 videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) ); 396 videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) );
398 } else { 397 } else {
399 videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); 398 videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) );
400 } 399 }
401 400
402 if ( !mediaPlayerState->isSeekable() ) { 401 if ( !mediaPlayerState.isSeekable() ) {
403 if( !slider->isHidden()) { 402 if( !slider->isHidden()) {
404 slider->hide(); 403 slider->hide();
405 } 404 }
406 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 405 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
407 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 406 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
408 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 407 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
409 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 408 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
410 } else { 409 } else {
411 slider->show(); 410 slider->show();
412 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 411 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
413 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 412 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
414 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 413 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
415 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 414 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
416 } 415 }
417 } 416 }
418} 417}
419 418
420 419
421 420
422 421
423void VideoWidget::paintEvent( QPaintEvent * pe) { 422void VideoWidget::paintEvent( QPaintEvent * pe) {
424 QPainter p( this ); 423 QPainter p( this );
425 424
426 if ( mediaPlayerState->isFullscreen() ) { 425 if ( mediaPlayerState.isFullscreen() ) {
427 // Clear the background 426 // Clear the background
428 p.setBrush( QBrush( Qt::black ) ); 427 p.setBrush( QBrush( Qt::black ) );
429 } else { 428 } else {
430 if ( !pe->erased() ) { 429 if ( !pe->erased() ) {
431 // Combine with background and double buffer 430 // Combine with background and double buffer
432 QPixmap pix( pe->rect().size() ); 431 QPixmap pix( pe->rect().size() );
433 QPainter p( &pix ); 432 QPainter p( &pix );
434 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 433 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
435 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); 434 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() );
436 for ( int i = 0; i < numVButtons; i++ ) { 435 for ( int i = 0; i < numVButtons; i++ ) {
437 paintButton( &p, i ); 436 paintButton( &p, i );
438 } 437 }
@@ -440,69 +439,69 @@ void VideoWidget::paintEvent( QPaintEvent * pe) {
440 p2.drawPixmap( pe->rect().topLeft(), pix ); 439 p2.drawPixmap( pe->rect().topLeft(), pix );
441 } else { 440 } else {
442 QPainter p( this ); 441 QPainter p( this );
443 for ( int i = 0; i < numVButtons; i++ ) 442 for ( int i = 0; i < numVButtons; i++ )
444 paintButton( &p, i ); 443 paintButton( &p, i );
445 } 444 }
446 //slider->repaint( TRUE ); 445 //slider->repaint( TRUE );
447 } 446 }
448} 447}
449 448
450 449
451void VideoWidget::closeEvent( QCloseEvent* ) { 450void VideoWidget::closeEvent( QCloseEvent* ) {
452 mediaPlayerState->setList(); 451 mediaPlayerState.setList();
453} 452}
454 453
455 454
456void VideoWidget::keyReleaseEvent( QKeyEvent *e) { 455void VideoWidget::keyReleaseEvent( QKeyEvent *e) {
457 switch ( e->key() ) { 456 switch ( e->key() ) {
458////////////////////////////// Zaurus keys 457////////////////////////////// Zaurus keys
459 case Key_Home: 458 case Key_Home:
460 break; 459 break;
461 case Key_F9: //activity 460 case Key_F9: //activity
462 break; 461 break;
463 case Key_F10: //contacts 462 case Key_F10: //contacts
464// hide(); 463// hide();
465 break; 464 break;
466 case Key_F11: //menu 465 case Key_F11: //menu
467 break; 466 break;
468 case Key_F12: //home 467 case Key_F12: //home
469 break; 468 break;
470 case Key_F13: //mail 469 case Key_F13: //mail
471 break; 470 break;
472 case Key_Space: { 471 case Key_Space: {
473 if(mediaPlayerState->isPlaying()) { 472 if(mediaPlayerState.isPlaying()) {
474 mediaPlayerState->setPlaying(FALSE); 473 mediaPlayerState.setPlaying(FALSE);
475 } else { 474 } else {
476 mediaPlayerState->setPlaying(TRUE); 475 mediaPlayerState.setPlaying(TRUE);
477 } 476 }
478 } 477 }
479 break; 478 break;
480 case Key_Down: 479 case Key_Down:
481// toggleButton(6); 480// toggleButton(6);
482 emit lessClicked(); 481 emit lessClicked();
483 emit lessReleased(); 482 emit lessReleased();
484// toggleButton(6); 483// toggleButton(6);
485 break; 484 break;
486 case Key_Up: 485 case Key_Up:
487// toggleButton(5); 486// toggleButton(5);
488 emit moreClicked(); 487 emit moreClicked();
489 emit moreReleased(); 488 emit moreReleased();
490// toggleButton(5); 489// toggleButton(5);
491 break; 490 break;
492 case Key_Right: 491 case Key_Right:
493 mediaPlayerState->setNext(); 492 mediaPlayerState.setNext();
494 break; 493 break;
495 case Key_Left: 494 case Key_Left:
496 mediaPlayerState->setPrev(); 495 mediaPlayerState.setPrev();
497 break; 496 break;
498 case Key_Escape: 497 case Key_Escape:
499 break; 498 break;
500 499
501 }; 500 };
502} 501}
503 502
504XineVideoWidget* VideoWidget::vidWidget() { 503XineVideoWidget* VideoWidget::vidWidget() {
505 return videoFrame; 504 return videoFrame;
506} 505}
507 506
508 507
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h
index 816ce2e..38eb726 100644
--- a/noncore/multimedia/opieplayer2/videowidget.h
+++ b/noncore/multimedia/opieplayer2/videowidget.h
@@ -47,25 +47,25 @@ enum VideoButtons {
47 VideoPlay, 47 VideoPlay,
48// VideoPause, 48// VideoPause,
49 VideoPrevious, 49 VideoPrevious,
50 VideoNext, 50 VideoNext,
51 VideoVolUp, 51 VideoVolUp,
52 VideoVolDown, 52 VideoVolDown,
53 VideoFullscreen 53 VideoFullscreen
54}; 54};
55 55
56class VideoWidget : public MediaWidget { 56class VideoWidget : public MediaWidget {
57 Q_OBJECT 57 Q_OBJECT
58public: 58public:
59 VideoWidget( QWidget* parent=0, const char* name=0 ); 59 VideoWidget( MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 );
60 ~VideoWidget(); 60 ~VideoWidget();
61 61
62 62
63 XineVideoWidget* vidWidget(); 63 XineVideoWidget* vidWidget();
64public slots: 64public slots:
65 void updateSlider( long, long ); 65 void updateSlider( long, long );
66 void sliderPressed( ); 66 void sliderPressed( );
67 void sliderReleased( ); 67 void sliderReleased( );
68 void setFullscreen( bool b ); 68 void setFullscreen( bool b );
69 void makeVisible(); 69 void makeVisible();
70 void backToNormal(); 70 void backToNormal();
71 void setPosition( long ); 71 void setPosition( long );