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 | |
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
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 75 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.h | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/main.cpp | 4 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.cpp | 10 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.h | 5 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 75 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.h | 2 |
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 | |||
@@ -49,9 +49,8 @@ | |||
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 | ||
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 |
57 | static const int yo = 22; // movable y offset | 56 | static const int yo = 22; // movable y offset |
@@ -89,11 +88,11 @@ static void changeTextColor( QWidget *w ) { | |||
89 | 88 | ||
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 | ||
99 | Config cfg("OpiePlayer"); | 98 | Config cfg("OpiePlayer"); |
@@ -158,22 +157,22 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name) : | |||
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 | ||
179 | AudioWidget::~AudioWidget() { | 178 | AudioWidget::~AudioWidget() { |
@@ -245,20 +244,20 @@ void AudioWidget::sliderPressed() { | |||
245 | void AudioWidget::sliderReleased() { | 244 | 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 | ||
264 | void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { | 263 | void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { |
@@ -279,19 +278,19 @@ void AudioWidget::setSeekable( bool 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 | } |
@@ -353,15 +352,15 @@ void AudioWidget::paintButton( QPainter *p, int i ) { | |||
353 | 352 | ||
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 | ||
367 | 366 | ||
@@ -371,11 +370,11 @@ void AudioWidget::stopSkip() { | |||
371 | 370 | ||
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 | ||
381 | 380 | ||
@@ -419,22 +418,22 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { | |||
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 | } |
@@ -459,9 +458,9 @@ void AudioWidget::showEvent( QShowEvent* ) { | |||
459 | } | 458 | } |
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 | ||
467 | void AudioWidget::paintEvent( QPaintEvent * pe ) { | 466 | void AudioWidget::paintEvent( QPaintEvent * pe ) { |
@@ -493,23 +492,23 @@ void AudioWidget::keyReleaseEvent( QKeyEvent *e) { | |||
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; |
@@ -526,14 +525,14 @@ void AudioWidget::keyReleaseEvent( QKeyEvent *e) { | |||
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 | } |
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 | |||
@@ -67,9 +67,9 @@ enum AudioButtons { | |||
67 | 67 | ||
68 | class AudioWidget : public MediaWidget { | 68 | class AudioWidget : public MediaWidget { |
69 | Q_OBJECT | 69 | Q_OBJECT |
70 | public: | 70 | public: |
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 ); } |
74 | public slots: | 74 | public slots: |
75 | void updateSlider( long, long ); | 75 | void updateSlider( long, 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 | |||
@@ -18,11 +18,11 @@ int main(int argc, char **argv) { | |||
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 | ||
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 | |||
@@ -21,16 +21,16 @@ | |||
21 | #include "mediawidget.h" | 21 | #include "mediawidget.h" |
22 | 22 | ||
23 | extern MediaPlayerState *mediaPlayerState; | 23 | extern MediaPlayerState *mediaPlayerState; |
24 | 24 | ||
25 | MediaWidget::MediaWidget( QWidget *parent, const char *name ) | 25 | MediaWidget::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 | ||
36 | MediaWidget::~MediaWidget() | 36 | MediaWidget::~MediaWidget() |
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 | |||
@@ -27,15 +27,18 @@ | |||
27 | class MediaWidget : public QWidget | 27 | class MediaWidget : public QWidget |
28 | { | 28 | { |
29 | Q_OBJECT | 29 | Q_OBJECT |
30 | public: | 30 | public: |
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 | ||
34 | public slots: | 34 | public 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 | |||
39 | protected: | ||
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 |
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 | |||
@@ -52,9 +52,8 @@ | |||
52 | # include <qgfxraster_qws.h> | 52 | # include <qgfxraster_qws.h> |
53 | #endif | 53 | #endif |
54 | 54 | ||
55 | 55 | ||
56 | extern MediaPlayerState *mediaPlayerState; | ||
57 | extern PlayListWidget *playList; | 56 | extern PlayListWidget *playList; |
58 | 57 | ||
59 | 58 | ||
60 | static const int xo = 2; // movable x offset | 59 | static const int xo = 2; // movable x offset |
@@ -81,10 +80,10 @@ const char *skinV_mask_file_names[7] = { | |||
81 | 80 | ||
82 | static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton)); | 81 | static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton)); |
83 | 82 | ||
84 | 83 | ||
85 | VideoWidget::VideoWidget(QWidget* parent, const char* name) : | 84 | VideoWidget::VideoWidget(MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : |
86 | MediaWidget( parent, name ), scaledWidth( 0 ), scaledHeight( 0 ) { | 85 | MediaWidget( mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ) { |
87 | 86 | ||
88 | 87 | ||
89 | setCaption( tr("OpiePlayer - Video") ); | 88 | setCaption( tr("OpiePlayer - Video") ); |
90 | 89 | ||
@@ -136,12 +135,12 @@ MediaWidget( parent, name ), scaledWidth( 0 ), scaledHeight( 0 ) { | |||
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 | ||
147 | VideoWidget::~VideoWidget() { | 146 | VideoWidget::~VideoWidget() { |
@@ -220,19 +219,19 @@ void 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 | ||
228 | void VideoWidget::setPosition( long i ) { | 227 | void VideoWidget::setPosition( long i ) { |
229 | updateSlider( i, mediaPlayerState->length() ); | 228 | updateSlider( i, mediaPlayerState.length() ); |
230 | } | 229 | } |
231 | 230 | ||
232 | 231 | ||
233 | void VideoWidget::setLength( long max ) { | 232 | void VideoWidget::setLength( long max ) { |
234 | updateSlider( mediaPlayerState->position(), max ); | 233 | updateSlider( mediaPlayerState.position(), max ); |
235 | } | 234 | } |
236 | 235 | ||
237 | void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) | 236 | void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) |
238 | { | 237 | { |
@@ -253,9 +252,9 @@ void VideoWidget::updateSlider( long i, long max ) { | |||
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 ) { |
@@ -322,27 +321,27 @@ void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | |||
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 | } |
@@ -352,10 +351,10 @@ void VideoWidget::mousePressEvent( QMouseEvent *event ) { | |||
352 | mouseMoveEvent( event ); | 351 | mouseMoveEvent( event ); |
353 | } | 352 | } |
354 | 353 | ||
355 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { | 354 | void 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 | } |
@@ -366,22 +365,22 @@ void VideoWidget::showEvent( QShowEvent* ) { | |||
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 | ||
374 | void VideoWidget::makeVisible() { | 373 | void 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 { |
@@ -398,20 +397,20 @@ void VideoWidget::makeVisible() { | |||
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 | } |
@@ -422,9 +421,9 @@ void VideoWidget::makeVisible() { | |||
422 | 421 | ||
423 | void VideoWidget::paintEvent( QPaintEvent * pe) { | 422 | void 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() ) { |
@@ -448,9 +447,9 @@ void VideoWidget::paintEvent( QPaintEvent * pe) { | |||
448 | } | 447 | } |
449 | 448 | ||
450 | 449 | ||
451 | void VideoWidget::closeEvent( QCloseEvent* ) { | 450 | void VideoWidget::closeEvent( QCloseEvent* ) { |
452 | mediaPlayerState->setList(); | 451 | mediaPlayerState.setList(); |
453 | } | 452 | } |
454 | 453 | ||
455 | 454 | ||
456 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { | 455 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { |
@@ -469,12 +468,12 @@ void VideoWidget::keyReleaseEvent( QKeyEvent *e) { | |||
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: |
@@ -489,12 +488,12 @@ void VideoWidget::keyReleaseEvent( QKeyEvent *e) { | |||
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 | ||
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 | |||
@@ -55,9 +55,9 @@ enum VideoButtons { | |||
55 | 55 | ||
56 | class VideoWidget : public MediaWidget { | 56 | class VideoWidget : public MediaWidget { |
57 | Q_OBJECT | 57 | Q_OBJECT |
58 | public: | 58 | public: |
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(); |