Diffstat (limited to 'core/multimedia/opieplayer/playlistwidget.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index c6de5e6..5d0f6de 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -360,22 +360,23 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
360 | readConfig( cfg ); | 360 | readConfig( cfg ); |
361 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); | 361 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); |
362 | loadList(DocLnk( currentPlaylist)); | 362 | loadList(DocLnk( currentPlaylist)); |
363 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlaylist))); | 363 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlaylist))); |
364 | 364 | ||
365 | initializeStates(); | 365 | initializeStates(); |
366 | // audioUI->setFocus(); | ||
366 | } | 367 | } |
367 | 368 | ||
368 | 369 | ||
369 | PlayListWidget::~PlayListWidget() { | 370 | PlayListWidget::~PlayListWidget() { |
370 | Config cfg( "OpiePlayer" ); | 371 | Config cfg( "OpiePlayer" ); |
371 | writeConfig( cfg ); | 372 | writeConfig( cfg ); |
372 | 373 | ||
373 | if ( d->current ) | 374 | if ( d->current ) |
374 | delete d->current; | 375 | delete d->current; |
375 | delete d; | 376 | if(d) delete d; |
376 | } | 377 | } |
377 | 378 | ||
378 | 379 | ||
379 | void PlayListWidget::initializeStates() { | 380 | void PlayListWidget::initializeStates() { |
380 | 381 | ||
381 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 382 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
@@ -491,21 +492,28 @@ void PlayListWidget::addAllVideoToList() { | |||
491 | writeCurrentM3u(); | 492 | writeCurrentM3u(); |
492 | d->selectedFiles->first(); | 493 | d->selectedFiles->first(); |
493 | } | 494 | } |
494 | 495 | ||
495 | 496 | ||
496 | void PlayListWidget::setDocument(const QString& fileref) { | 497 | void PlayListWidget::setDocument(const QString& fileref) { |
497 | qDebug(fileref); | 498 | fromSetDocument = true; |
498 | fromSetDocument = TRUE; | 499 | d->setDocumentUsed = TRUE; |
500 | mediaPlayerState->setPlaying( FALSE ); | ||
501 | qApp->processEvents(); | ||
502 | mediaPlayerState->setPlaying( TRUE ); | ||
503 | } | ||
504 | |||
505 | void PlayListWidget::setDocumentEx(const QString& fileref) { | ||
506 | |||
499 | QFileInfo fileInfo(fileref); | 507 | QFileInfo fileInfo(fileref); |
500 | if ( !fileInfo.exists() ) { | 508 | if ( !fileInfo.exists() ) { |
501 | QMessageBox::critical( 0, tr( "Invalid File" ), | 509 | QMessageBox::critical( 0, tr( "Invalid File" ), |
502 | tr( "There was a problem in getting the file." ) ); | 510 | tr( "There was a problem in getting the file." ) ); |
503 | return; | 511 | return; |
504 | } | 512 | } |
505 | // qDebug("setDocument "+fileref); | 513 | qDebug("setDocument "+fileref); |
506 | QString extension = fileInfo.extension(false); | 514 | QString extension = fileInfo.extension(false); |
507 | if( extension.find( "m3u", 0, false) != -1) { //is m3u | 515 | if( extension.find( "m3u", 0, false) != -1) { //is m3u |
508 | readm3u( fileref); | 516 | readm3u( fileref); |
509 | } | 517 | } |
510 | else if( extension.find( "pls", 0, false) != -1 ) { //is pls | 518 | else if( extension.find( "pls", 0, false) != -1 ) { //is pls |
511 | readPls( fileref); | 519 | readPls( fileref); |
@@ -527,13 +535,13 @@ void PlayListWidget::setDocument(const QString& fileref) { | |||
527 | addToSelection( lnk ); | 535 | addToSelection( lnk ); |
528 | // addToSelection( DocLnk( fileref ) ); | 536 | // addToSelection( DocLnk( fileref ) ); |
529 | d->setDocumentUsed = TRUE; | 537 | d->setDocumentUsed = TRUE; |
530 | mediaPlayerState->setPlaying( FALSE ); | 538 | mediaPlayerState->setPlaying( FALSE ); |
531 | qApp->processEvents(); | 539 | qApp->processEvents(); |
532 | mediaPlayerState->setPlaying( TRUE ); | 540 | mediaPlayerState->setPlaying( TRUE ); |
533 | qApp->processEvents(); | 541 | // qApp->processEvents(); |
534 | setCaption(tr("OpiePlayer")); | 542 | setCaption(tr("OpiePlayer")); |
535 | } | 543 | } |
536 | } | 544 | } |
537 | 545 | ||
538 | 546 | ||
539 | void PlayListWidget::setActiveWindow() { | 547 | void PlayListWidget::setActiveWindow() { |
@@ -756,13 +764,13 @@ void PlayListWidget::removeSelected() { | |||
756 | } | 764 | } |
757 | 765 | ||
758 | void PlayListWidget::playIt( QListViewItem *) { | 766 | void PlayListWidget::playIt( QListViewItem *) { |
759 | // d->setDocumentUsed = FALSE; | 767 | // d->setDocumentUsed = FALSE; |
760 | // mediaPlayerState->curPosition =0; | 768 | // mediaPlayerState->curPosition =0; |
761 | qDebug("playIt"); | 769 | qDebug("playIt"); |
762 | mediaPlayerState->setPlaying(FALSE); | 770 | // mediaPlayerState->setPlaying(FALSE); |
763 | mediaPlayerState->setPlaying(TRUE); | 771 | mediaPlayerState->setPlaying(TRUE); |
764 | d->selectedFiles->unSelect(); | 772 | d->selectedFiles->unSelect(); |
765 | } | 773 | } |
766 | 774 | ||
767 | void PlayListWidget::addToSelection( QListViewItem *it) { | 775 | void PlayListWidget::addToSelection( QListViewItem *it) { |
768 | d->setDocumentUsed = FALSE; | 776 | d->setDocumentUsed = FALSE; |
@@ -779,12 +787,13 @@ void PlayListWidget::addToSelection( QListViewItem *it) { | |||
779 | 787 | ||
780 | filename=it->text(3); | 788 | filename=it->text(3); |
781 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name | 789 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name |
782 | lnk.setFile( filename ); //sets file name | 790 | lnk.setFile( filename ); //sets file name |
783 | d->selectedFiles->addToSelection( lnk); | 791 | d->selectedFiles->addToSelection( lnk); |
784 | 792 | ||
793 | if(tabWidget->currentPageIndex() == 0) | ||
785 | writeCurrentM3u(); | 794 | writeCurrentM3u(); |
786 | // tabWidget->setCurrentPage(0); | 795 | // tabWidget->setCurrentPage(0); |
787 | 796 | ||
788 | } | 797 | } |
789 | } | 798 | } |
790 | 799 | ||
@@ -828,13 +837,13 @@ void PlayListWidget::tabChanged(QWidget *) { | |||
828 | } | 837 | } |
829 | break; | 838 | break; |
830 | }; | 839 | }; |
831 | } | 840 | } |
832 | 841 | ||
833 | void PlayListWidget::btnPlay(bool b) { | 842 | void PlayListWidget::btnPlay(bool b) { |
834 | qDebug("<<<<<<<<<<<<<<<BtnPlay"); | 843 | qDebug("<<<<<<<<<<<<<<<BtnPlay %d", b); |
835 | // mediaPlayerState->setPlaying(b); | 844 | // mediaPlayerState->setPlaying(b); |
836 | switch ( tabWidget->currentPageIndex()) { | 845 | switch ( tabWidget->currentPageIndex()) { |
837 | case 0: | 846 | case 0: |
838 | { | 847 | { |
839 | qDebug("1"); | 848 | qDebug("1"); |
840 | // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 | 849 | // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 |
@@ -849,25 +858,25 @@ void PlayListWidget::btnPlay(bool b) { | |||
849 | break; | 858 | break; |
850 | case 1: | 859 | case 1: |
851 | { | 860 | { |
852 | qDebug("2"); | 861 | qDebug("2"); |
853 | // d->selectedFiles->unSelect(); | 862 | // d->selectedFiles->unSelect(); |
854 | addToSelection( audioView->currentItem() ); | 863 | addToSelection( audioView->currentItem() ); |
855 | mediaPlayerState->setPlaying(true); | 864 | mediaPlayerState->setPlaying( b); |
856 | d->selectedFiles->removeSelected( ); | 865 | d->selectedFiles->removeSelected( ); |
857 | d->selectedFiles->unSelect(); | 866 | d->selectedFiles->unSelect(); |
858 | tabWidget->setCurrentPage(1); | 867 | tabWidget->setCurrentPage(1); |
859 | insanityBool=FALSE; | 868 | insanityBool=FALSE; |
860 | }// audioView->clearSelection(); | 869 | }// audioView->clearSelection(); |
861 | break; | 870 | break; |
862 | case 2: | 871 | case 2: |
863 | { | 872 | { |
864 | qDebug("3"); | 873 | qDebug("3"); |
865 | 874 | ||
866 | addToSelection( videoView->currentItem() ); | 875 | addToSelection( videoView->currentItem() ); |
867 | mediaPlayerState->setPlaying(true); | 876 | mediaPlayerState->setPlaying( b); |
868 | // qApp->processEvents(); | 877 | // qApp->processEvents(); |
869 | d->selectedFiles->removeSelected( ); | 878 | d->selectedFiles->removeSelected( ); |
870 | d->selectedFiles->unSelect(); | 879 | d->selectedFiles->unSelect(); |
871 | tabWidget->setCurrentPage(2); | 880 | tabWidget->setCurrentPage(2); |
872 | insanityBool=FALSE; | 881 | insanityBool=FALSE; |
873 | }// videoView->clearSelection(); | 882 | }// videoView->clearSelection(); |
@@ -1456,13 +1465,13 @@ void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { | |||
1456 | if ( msg == "play()" ) { //plays current selection | 1465 | if ( msg == "play()" ) { //plays current selection |
1457 | btnPlay( true); | 1466 | btnPlay( true); |
1458 | } else if ( msg == "stop()" ) { | 1467 | } else if ( msg == "stop()" ) { |
1459 | mediaPlayerState->setPlaying( false); | 1468 | mediaPlayerState->setPlaying( false); |
1460 | } else if ( msg == "togglePause()" ) { | 1469 | } else if ( msg == "togglePause()" ) { |
1461 | mediaPlayerState->togglePaused(); | 1470 | mediaPlayerState->togglePaused(); |
1462 | } else if ( msg == "next()" ) { //select next in list | 1471 | } else if ( msg == "next()" ) { //select next in lis |
1463 | mediaPlayerState->setNext(); | 1472 | mediaPlayerState->setNext(); |
1464 | } else if ( msg == "prev()" ) { //select previous in list | 1473 | } else if ( msg == "prev()" ) { //select previous in list |
1465 | mediaPlayerState->setPrev(); | 1474 | mediaPlayerState->setPrev(); |
1466 | } else if ( msg == "toggleLooping()" ) { //loop or not loop | 1475 | } else if ( msg == "toggleLooping()" ) { //loop or not loop |
1467 | mediaPlayerState->toggleLooping(); | 1476 | mediaPlayerState->toggleLooping(); |
1468 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled | 1477 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled |
@@ -1473,22 +1482,24 @@ void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { | |||
1473 | } else if ( msg == "volDown()" ) { //volume less | 1482 | } else if ( msg == "volDown()" ) { //volume less |
1474 | // emit lessClicked(); | 1483 | // emit lessClicked(); |
1475 | // emit lessReleased(); | 1484 | // emit lessReleased(); |
1476 | } else if ( msg == "play(QString)" ) { //play this now | 1485 | } else if ( msg == "play(QString)" ) { //play this now |
1477 | QString file; | 1486 | QString file; |
1478 | stream >> file; | 1487 | stream >> file; |
1479 | setDocument( (const QString &) file); | 1488 | setDocumentEx( (const QString &) file); |
1480 | } else if ( msg == "add(QString)" ) { //add to playlist | 1489 | } else if ( msg == "add(QString)" ) { //add to playlist |
1481 | QString file; | 1490 | QString file; |
1482 | stream >> file; | 1491 | stream >> file; |
1483 | QFileInfo fileInfo(file); | 1492 | QFileInfo fileInfo(file); |
1484 | DocLnk lnk; | 1493 | DocLnk lnk; |
1485 | lnk.setName( fileInfo.baseName() ); //sets name | 1494 | lnk.setName( fileInfo.baseName() ); //sets name |
1486 | lnk.setFile( file ); //sets file name | 1495 | lnk.setFile( file ); //sets file name |
1487 | addToSelection( lnk ); | 1496 | addToSelection( lnk ); |
1488 | } else if ( msg == "rem(QString)" ) { //remove from playlist | 1497 | } else if ( msg == "rem(QString)" ) { //remove from playlist |
1489 | QString file; | 1498 | QString file; |
1490 | stream >> file; | 1499 | stream >> file; |
1491 | 1500 | ||
1501 | } else if ( msg == "setDocument(QString)" ) { //loop or not loop | ||
1502 | QCopEnvelope h("QPE/Application/opieplayer", "raise()"); | ||
1492 | } | 1503 | } |
1493 | 1504 | ||
1494 | } | 1505 | } |