author | simon <simon> | 2002-12-02 20:32:42 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-02 20:32:42 (UTC) |
commit | 6cd1494f86f2f60614c9b9a7b959666dec2500ee (patch) (unidiff) | |
tree | 5f5cdbae8be03210fae087eecec2f6b2d070569c /noncore/multimedia/opieplayer2/audiowidget.cpp | |
parent | abeed050bedee6e2697ea417ed74ab621361da48 (diff) | |
download | opie-6cd1494f86f2f60614c9b9a7b959666dec2500ee.zip opie-6cd1494f86f2f60614c9b9a7b959666dec2500ee.tar.gz opie-6cd1494f86f2f60614c9b9a7b959666dec2500ee.tar.bz2 |
- the audiowidget and the videowidget don't rely on the mediaplayerstate
singleton anymore
Diffstat (limited to 'noncore/multimedia/opieplayer2/audiowidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 75 |
1 files changed, 37 insertions, 38 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 | |||
@@ -50,7 +50,6 @@ | |||
50 | #include "mediaplayerstate.h" | 50 | #include "mediaplayerstate.h" |
51 | #include "playlistwidget.h" | 51 | #include "playlistwidget.h" |
52 | 52 | ||
53 | extern MediaPlayerState *mediaPlayerState; | ||
54 | extern PlayListWidget *playList; | 53 | extern PlayListWidget *playList; |
55 | 54 | ||
56 | static const int xo = -2; // movable x offset | 55 | static const int xo = -2; // movable x offset |
@@ -90,9 +89,9 @@ static void changeTextColor( QWidget *w ) { | |||
90 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); | 89 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); |
91 | 90 | ||
92 | 91 | ||
93 | AudioWidget::AudioWidget(QWidget* parent, const char* name) : | 92 | AudioWidget::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 | ||
@@ -159,8 +158,8 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name) : | |||
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() ) ); |
@@ -168,11 +167,11 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name) : | |||
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 | ||
@@ -246,18 +245,18 @@ void 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 | ||
253 | void AudioWidget::setPosition( long i ) { | 252 | void 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 | ||
259 | void AudioWidget::setLength( long max ) { | 258 | void AudioWidget::setLength( long max ) { |
260 | updateSlider( mediaPlayerState->position(), max ); | 259 | updateSlider( mediaPlayerState.position(), max ); |
261 | } | 260 | } |
262 | 261 | ||
263 | 262 | ||
@@ -280,8 +279,8 @@ void AudioWidget::setSeekable( bool isSeekable ) { | |||
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 { |
@@ -289,8 +288,8 @@ void AudioWidget::setSeekable( bool isSeekable ) { | |||
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 | } |
@@ -354,13 +353,13 @@ void AudioWidget::paintButton( QPainter *p, int i ) { | |||
354 | void AudioWidget::skipFor() { | 353 | void 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 | ||
360 | void AudioWidget::skipBack() { | 359 | void 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 | ||
@@ -372,9 +371,9 @@ void AudioWidget::stopSkip() { | |||
372 | 371 | ||
373 | void AudioWidget::timerEvent( QTimerEvent * ) { | 372 | void 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 | ||
@@ -420,20 +419,20 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { | |||
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 | } |
@@ -460,7 +459,7 @@ void AudioWidget::showEvent( QShowEvent* ) { | |||
460 | 459 | ||
461 | 460 | ||
462 | void AudioWidget::closeEvent( QCloseEvent* ) { | 461 | void AudioWidget::closeEvent( QCloseEvent* ) { |
463 | mediaPlayerState->setList(); | 462 | mediaPlayerState.setList(); |
464 | } | 463 | } |
465 | 464 | ||
466 | 465 | ||
@@ -494,21 +493,21 @@ void AudioWidget::keyReleaseEvent( QKeyEvent *e) { | |||
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 | } |
@@ -527,12 +526,12 @@ void AudioWidget::keyReleaseEvent( QKeyEvent *e) { | |||
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: { |