Diffstat (limited to 'noncore/multimedia/opieplayer2/playlistwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 69 |
1 files changed, 39 insertions, 30 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index a1a1016..9a9e1ec 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -38,19 +38,24 @@ | |||
38 | #include <qmessagebox.h> | 38 | #include <qmessagebox.h> |
39 | 39 | ||
40 | #include "playlistselection.h" | 40 | #include "playlistselection.h" |
41 | #include "playlistwidget.h" | 41 | #include "playlistwidget.h" |
42 | #include "mediaplayer.h" | ||
42 | #include "mediaplayerstate.h" | 43 | #include "mediaplayerstate.h" |
43 | #include "inputDialog.h" | 44 | #include "inputDialog.h" |
44 | #include "om3u.h" | 45 | #include "om3u.h" |
45 | #include "playlistfileview.h" | 46 | #include "playlistfileview.h" |
46 | 47 | ||
47 | //only needed for the random play | 48 | //only needed for the random play |
48 | #include <assert.h> | 49 | #include <assert.h> |
49 | 50 | ||
50 | PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) | 51 | PlayListWidget::PlayListWidget(QWidget* parent, const char* name, WFlags fl ) |
51 | : PlayListWidgetGui( mediaPlayerState, parent, name ) , currentFileListView( 0 ) | 52 | : PlayListWidgetGui( parent, "playList" ) , currentFileListView( 0 ) |
52 | { | 53 | { |
54 | mediaPlayerState = new MediaPlayerState(0, "mediaPlayerState" ); | ||
55 | m_mp = new MediaPlayer(*this, *mediaPlayerState, 0, "mediaPlayer"); | ||
56 | |||
57 | |||
53 | 58 | ||
54 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), | 59 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), |
55 | "opieplayer2/add_to_playlist", | 60 | "opieplayer2/add_to_playlist", |
56 | this , SLOT(addSelected() ) ); | 61 | this , SLOT(addSelected() ) ); |
@@ -59,11 +64,11 @@ PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* par | |||
59 | this , SLOT(removeSelected() ) ); | 64 | this , SLOT(removeSelected() ) ); |
60 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", | 65 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", |
61 | this , SLOT( btnPlay( bool) ), TRUE ); | 66 | this , SLOT( btnPlay( bool) ), TRUE ); |
62 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", | 67 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", |
63 | &mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); | 68 | mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); |
64 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", | 69 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", |
65 | &mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); | 70 | mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); |
66 | 71 | ||
67 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 72 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
68 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), | 73 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), |
69 | this, SLOT( addAllMusicToList() ) ); | 74 | this, SLOT( addAllMusicToList() ) ); |
@@ -85,13 +90,13 @@ PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* par | |||
85 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), | 90 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), |
86 | videoView, SLOT( scanFiles() ) ); | 91 | videoView, SLOT( scanFiles() ) ); |
87 | 92 | ||
88 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), | 93 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), |
89 | &mediaPlayerState, SLOT( toggleFullscreen() ) ); | 94 | mediaPlayerState, SLOT( toggleFullscreen() ) ); |
90 | 95 | ||
91 | Config cfg( "OpiePlayer" ); | 96 | Config cfg( "OpiePlayer" ); |
92 | bool b= cfg.readBoolEntry("FullScreen", 0); | 97 | bool b= cfg.readBoolEntry("FullScreen", 0); |
93 | mediaPlayerState.setFullscreen( b ); | 98 | mediaPlayerState->setFullscreen( b ); |
94 | pmView->setItemChecked( -16, b ); | 99 | pmView->setItemChecked( -16, b ); |
95 | 100 | ||
96 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", | 101 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", |
97 | d->selectedFiles, SLOT(moveSelectedUp() ) ); | 102 | d->selectedFiles, SLOT(moveSelectedUp() ) ); |
@@ -124,18 +129,21 @@ PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* par | |||
124 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), | 129 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), |
125 | this, SLOT( loadList( const DocLnk & ) ) ); | 130 | this, SLOT( loadList( const DocLnk & ) ) ); |
126 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), | 131 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), |
127 | this, SLOT( tabChanged( QWidget* ) ) ); | 132 | this, SLOT( tabChanged( QWidget* ) ) ); |
128 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), | 133 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), |
129 | d->tbPlay, SLOT( setOn( bool ) ) ); | 134 | d->tbPlay, SLOT( setOn( bool ) ) ); |
130 | connect( &mediaPlayerState, SIGNAL( loopingToggled( bool ) ), | 135 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), |
131 | d->tbLoop, SLOT( setOn( bool ) ) ); | 136 | d->tbLoop, SLOT( setOn( bool ) ) ); |
132 | connect( &mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), | 137 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), |
133 | d->tbShuffle, SLOT( setOn( bool ) ) ); | 138 | d->tbShuffle, SLOT( setOn( bool ) ) ); |
134 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), | 139 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), |
135 | this, SLOT( playIt( QListViewItem *) ) ); | 140 | this, SLOT( playIt( QListViewItem *) ) ); |
136 | connect ( gammaSlider, SIGNAL( valueChanged( int ) ), | 141 | connect ( gammaSlider, SIGNAL( valueChanged( int ) ), |
137 | &mediaPlayerState, SLOT( setVideoGamma( int ) ) ); | 142 | mediaPlayerState, SLOT( setVideoGamma( int ) ) ); |
143 | |||
144 | connect( this, SIGNAL(skinSelected() ), | ||
145 | m_mp, SLOT( reloadSkins() ) ); | ||
138 | 146 | ||
139 | // see which skins are installed | 147 | // see which skins are installed |
140 | populateSkinsMenu(); | 148 | populateSkinsMenu(); |
141 | initializeStates(); | 149 | initializeStates(); |
@@ -154,15 +162,16 @@ PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* par | |||
154 | 162 | ||
155 | 163 | ||
156 | PlayListWidget::~PlayListWidget() { | 164 | PlayListWidget::~PlayListWidget() { |
157 | delete d; | 165 | delete d; |
166 | delete m_mp; | ||
158 | } | 167 | } |
159 | 168 | ||
160 | 169 | ||
161 | void PlayListWidget::initializeStates() { | 170 | void PlayListWidget::initializeStates() { |
162 | d->tbPlay->setOn( mediaPlayerState.isPlaying() ); | 171 | d->tbPlay->setOn( mediaPlayerState->isPlaying() ); |
163 | d->tbLoop->setOn( mediaPlayerState.isLooping() ); | 172 | d->tbLoop->setOn( mediaPlayerState->isLooping() ); |
164 | d->tbShuffle->setOn( mediaPlayerState.isShuffled() ); | 173 | d->tbShuffle->setOn( mediaPlayerState->isShuffled() ); |
165 | d->playListFrame->show(); | 174 | d->playListFrame->show(); |
166 | } | 175 | } |
167 | 176 | ||
168 | void PlayListWidget::writeDefaultPlaylist() { | 177 | void PlayListWidget::writeDefaultPlaylist() { |
@@ -340,10 +349,10 @@ void PlayListWidget::setDocument( const QString& fileref ) { | |||
340 | addToSelection( lnk ); | 349 | addToSelection( lnk ); |
341 | writeCurrentM3u(); | 350 | writeCurrentM3u(); |
342 | 351 | ||
343 | d->setDocumentUsed = TRUE; | 352 | d->setDocumentUsed = TRUE; |
344 | mediaPlayerState.setPlaying( FALSE ); | 353 | mediaPlayerState->setPlaying( FALSE ); |
345 | mediaPlayerState.setPlaying( TRUE ); | 354 | mediaPlayerState->setPlaying( TRUE ); |
346 | } | 355 | } |
347 | } | 356 | } |
348 | 357 | ||
349 | 358 | ||
@@ -365,9 +374,9 @@ const DocLnk *PlayListWidget::current() const { // this is fugly | |||
365 | } | 374 | } |
366 | 375 | ||
367 | 376 | ||
368 | bool PlayListWidget::prev() { | 377 | bool PlayListWidget::prev() { |
369 | if ( mediaPlayerState.isShuffled() ) { | 378 | if ( mediaPlayerState->isShuffled() ) { |
370 | const DocLnk *cur = current(); | 379 | const DocLnk *cur = current(); |
371 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 380 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
372 | for ( int i = 0; i < j; i++ ) { | 381 | for ( int i = 0; i < j; i++ ) { |
373 | if ( !d->selectedFiles->next() ) | 382 | if ( !d->selectedFiles->next() ) |
@@ -379,9 +388,9 @@ bool PlayListWidget::prev() { | |||
379 | } | 388 | } |
380 | return TRUE; | 389 | return TRUE; |
381 | } else { | 390 | } else { |
382 | if ( !d->selectedFiles->prev() ) { | 391 | if ( !d->selectedFiles->prev() ) { |
383 | if ( mediaPlayerState.isLooping() ) { | 392 | if ( mediaPlayerState->isLooping() ) { |
384 | return d->selectedFiles->last(); | 393 | return d->selectedFiles->last(); |
385 | } else { | 394 | } else { |
386 | return FALSE; | 395 | return FALSE; |
387 | } | 396 | } |
@@ -392,13 +401,13 @@ bool PlayListWidget::prev() { | |||
392 | 401 | ||
393 | 402 | ||
394 | bool PlayListWidget::next() { | 403 | bool PlayListWidget::next() { |
395 | //qDebug("<<<<<<<<<<<<next()"); | 404 | //qDebug("<<<<<<<<<<<<next()"); |
396 | if ( mediaPlayerState.isShuffled() ) { | 405 | if ( mediaPlayerState->isShuffled() ) { |
397 | return prev(); | 406 | return prev(); |
398 | } else { | 407 | } else { |
399 | if ( !d->selectedFiles->next() ) { | 408 | if ( !d->selectedFiles->next() ) { |
400 | if ( mediaPlayerState.isLooping() ) { | 409 | if ( mediaPlayerState->isLooping() ) { |
401 | return d->selectedFiles->first(); | 410 | return d->selectedFiles->first(); |
402 | } else { | 411 | } else { |
403 | return FALSE; | 412 | return FALSE; |
404 | } | 413 | } |
@@ -462,10 +471,10 @@ void PlayListWidget::removeSelected() { | |||
462 | 471 | ||
463 | 472 | ||
464 | void PlayListWidget::playIt( QListViewItem *it) { | 473 | void PlayListWidget::playIt( QListViewItem *it) { |
465 | if(!it) return; | 474 | if(!it) return; |
466 | mediaPlayerState.setPlaying(FALSE); | 475 | mediaPlayerState->setPlaying(FALSE); |
467 | mediaPlayerState.setPlaying(TRUE); | 476 | mediaPlayerState->setPlaying(TRUE); |
468 | d->selectedFiles->unSelect(); | 477 | d->selectedFiles->unSelect(); |
469 | } | 478 | } |
470 | 479 | ||
471 | 480 | ||
@@ -564,9 +573,9 @@ void PlayListWidget::tabChanged(QWidget *) { | |||
564 | 573 | ||
565 | 574 | ||
566 | void PlayListWidget::btnPlay(bool b) { | 575 | void PlayListWidget::btnPlay(bool b) { |
567 | // mediaPlayerState->setPlaying(false); | 576 | // mediaPlayerState->setPlaying(false); |
568 | mediaPlayerState.setPlaying(b); | 577 | mediaPlayerState->setPlaying(b); |
569 | insanityBool=FALSE; | 578 | insanityBool=FALSE; |
570 | } | 579 | } |
571 | 580 | ||
572 | void PlayListWidget::deletePlaylist() { | 581 | void PlayListWidget::deletePlaylist() { |
@@ -908,10 +917,10 @@ void PlayListWidget::pmViewActivated(int index) { | |||
908 | // qDebug("%d", index); | 917 | // qDebug("%d", index); |
909 | switch(index) { | 918 | switch(index) { |
910 | case -16: | 919 | case -16: |
911 | { | 920 | { |
912 | mediaPlayerState.toggleFullscreen(); | 921 | mediaPlayerState->toggleFullscreen(); |
913 | bool b=mediaPlayerState.isFullscreen(); | 922 | bool b=mediaPlayerState->isFullscreen(); |
914 | pmView->setItemChecked( index, b); | 923 | pmView->setItemChecked( index, b); |
915 | Config cfg( "OpiePlayer" ); | 924 | Config cfg( "OpiePlayer" ); |
916 | cfg.writeEntry( "FullScreen", b ); | 925 | cfg.writeEntry( "FullScreen", b ); |
917 | } | 926 | } |
@@ -995,19 +1004,19 @@ void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { | |||
995 | QDataStream stream ( data, IO_ReadOnly ); | 1004 | QDataStream stream ( data, IO_ReadOnly ); |
996 | if ( msg == "play()" ) { //plays current selection | 1005 | if ( msg == "play()" ) { //plays current selection |
997 | btnPlay( true); | 1006 | btnPlay( true); |
998 | } else if ( msg == "stop()" ) { | 1007 | } else if ( msg == "stop()" ) { |
999 | mediaPlayerState.setPlaying( false); | 1008 | mediaPlayerState->setPlaying( false); |
1000 | } else if ( msg == "togglePause()" ) { | 1009 | } else if ( msg == "togglePause()" ) { |
1001 | mediaPlayerState.togglePaused(); | 1010 | mediaPlayerState->togglePaused(); |
1002 | } else if ( msg == "next()" ) { //select next in list | 1011 | } else if ( msg == "next()" ) { //select next in list |
1003 | mediaPlayerState.setNext(); | 1012 | mediaPlayerState->setNext(); |
1004 | } else if ( msg == "prev()" ) { //select previous in list | 1013 | } else if ( msg == "prev()" ) { //select previous in list |
1005 | mediaPlayerState.setPrev(); | 1014 | mediaPlayerState->setPrev(); |
1006 | } else if ( msg == "toggleLooping()" ) { //loop or not loop | 1015 | } else if ( msg == "toggleLooping()" ) { //loop or not loop |
1007 | mediaPlayerState.toggleLooping(); | 1016 | mediaPlayerState->toggleLooping(); |
1008 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled | 1017 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled |
1009 | mediaPlayerState.toggleShuffled(); | 1018 | mediaPlayerState->toggleShuffled(); |
1010 | } else if ( msg == "volUp()" ) { //volume more | 1019 | } else if ( msg == "volUp()" ) { //volume more |
1011 | // emit moreClicked(); | 1020 | // emit moreClicked(); |
1012 | // emit moreReleased(); | 1021 | // emit moreReleased(); |
1013 | } else if ( msg == "volDown()" ) { //volume less | 1022 | } else if ( msg == "volDown()" ) { //volume less |