author | llornkcor <llornkcor> | 2003-06-11 03:25:10 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-06-11 03:25:10 (UTC) |
commit | bb6afc95ea64329f8fb9b7af8727b0c13747dde0 (patch) (unidiff) | |
tree | cd9285a4860ce024a2f126da4b843c18cdeb533b /core/multimedia | |
parent | d47a08d2f8944deb1ee0945075c3443de82442ea (diff) | |
download | opie-bb6afc95ea64329f8fb9b7af8727b0c13747dde0.zip opie-bb6afc95ea64329f8fb9b7af8727b0c13747dde0.tar.gz opie-bb6afc95ea64329f8fb9b7af8727b0c13747dde0.tar.bz2 |
fix setDocument handling
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 39 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.h | 1 |
2 files changed, 26 insertions, 14 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 | |||
@@ -354,34 +354,35 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
354 | 354 | ||
355 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | 355 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); |
356 | 356 | ||
357 | setCentralWidget( vbox5 ); | 357 | setCentralWidget( vbox5 ); |
358 | 358 | ||
359 | Config cfg( "OpiePlayer" ); | 359 | Config cfg( "OpiePlayer" ); |
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() ); |
382 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 383 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
383 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 384 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
384 | setPlaylist( true); | 385 | setPlaylist( true); |
385 | } | 386 | } |
386 | 387 | ||
387 | 388 | ||
@@ -485,33 +486,40 @@ void PlayListWidget::addAllVideoToList() { | |||
485 | QListIterator<DocLnk> dit( vFiles.children() ); | 486 | QListIterator<DocLnk> dit( vFiles.children() ); |
486 | for ( ; dit.current(); ++dit ) | 487 | for ( ; dit.current(); ++dit ) |
487 | if(QFileInfo( dit.current()->file()).exists()) | 488 | if(QFileInfo( dit.current()->file()).exists()) |
488 | d->selectedFiles->addToSelection( **dit ); | 489 | d->selectedFiles->addToSelection( **dit ); |
489 | tabWidget->setCurrentPage(0); | 490 | tabWidget->setCurrentPage(0); |
490 | 491 | ||
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); |
512 | } | 520 | } |
513 | else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist | 521 | else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist |
514 | clearList(); | 522 | clearList(); |
515 | DocLnk lnk; | 523 | DocLnk lnk; |
516 | lnk.setName( fileInfo.baseName() ); //sets name | 524 | lnk.setName( fileInfo.baseName() ); //sets name |
517 | lnk.setFile( fileref ); //sets file name | 525 | lnk.setFile( fileref ); //sets file name |
@@ -521,25 +529,25 @@ void PlayListWidget::setDocument(const QString& fileref) { | |||
521 | d->selectedFiles->first(); | 529 | d->selectedFiles->first(); |
522 | } else { | 530 | } else { |
523 | clearList(); | 531 | clearList(); |
524 | DocLnk lnk; | 532 | DocLnk lnk; |
525 | lnk.setName( fileInfo.baseName() ); //sets name | 533 | lnk.setName( fileInfo.baseName() ); //sets name |
526 | lnk.setFile( fileref ); //sets file name | 534 | lnk.setFile( fileref ); //sets file name |
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() { |
540 | qDebug("SETTING active window"); | 548 | qDebug("SETTING active window"); |
541 | 549 | ||
542 | // When we get raised we need to ensure that it switches views | 550 | // When we get raised we need to ensure that it switches views |
543 | char origView = mediaPlayerState->view(); | 551 | char origView = mediaPlayerState->view(); |
544 | mediaPlayerState->setView( 'l' ); // invalidate | 552 | mediaPlayerState->setView( 'l' ); // invalidate |
545 | mediaPlayerState->setView( origView ); // now switch back | 553 | mediaPlayerState->setView( origView ); // now switch back |
@@ -750,48 +758,49 @@ void PlayListWidget::addSelected() { | |||
750 | writeCurrentM3u(); | 758 | writeCurrentM3u(); |
751 | 759 | ||
752 | } | 760 | } |
753 | 761 | ||
754 | void PlayListWidget::removeSelected() { | 762 | void PlayListWidget::removeSelected() { |
755 | d->selectedFiles->removeSelected( ); | 763 | d->selectedFiles->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; |
769 | 777 | ||
770 | if(it) { | 778 | if(it) { |
771 | switch ( tabWidget->currentPageIndex()) { | 779 | switch ( tabWidget->currentPageIndex()) { |
772 | case 0: //playlist | 780 | case 0: //playlist |
773 | return; | 781 | return; |
774 | break; | 782 | break; |
775 | }; | 783 | }; |
776 | // case 1: { | 784 | // case 1: { |
777 | DocLnk lnk; | 785 | DocLnk lnk; |
778 | QString filename; | 786 | QString filename; |
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 | ||
785 | writeCurrentM3u(); | 793 | if(tabWidget->currentPageIndex() == 0) |
794 | writeCurrentM3u(); | ||
786 | // tabWidget->setCurrentPage(0); | 795 | // tabWidget->setCurrentPage(0); |
787 | 796 | ||
788 | } | 797 | } |
789 | } | 798 | } |
790 | 799 | ||
791 | void PlayListWidget::tabChanged(QWidget *) { | 800 | void PlayListWidget::tabChanged(QWidget *) { |
792 | 801 | ||
793 | switch ( tabWidget->currentPageIndex()) { | 802 | switch ( tabWidget->currentPageIndex()) { |
794 | case 0: | 803 | case 0: |
795 | { | 804 | { |
796 | if( !tbDeletePlaylist->isHidden()) | 805 | if( !tbDeletePlaylist->isHidden()) |
797 | tbDeletePlaylist->hide(); | 806 | tbDeletePlaylist->hide(); |
@@ -822,58 +831,58 @@ void PlayListWidget::tabChanged(QWidget *) { | |||
822 | break; | 831 | break; |
823 | case 3: | 832 | case 3: |
824 | { | 833 | { |
825 | if( tbDeletePlaylist->isHidden()) | 834 | if( tbDeletePlaylist->isHidden()) |
826 | tbDeletePlaylist->show(); | 835 | tbDeletePlaylist->show(); |
827 | playLists->reread(); | 836 | playLists->reread(); |
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 |
841 | // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { | 850 | // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { |
842 | // QMessageBox::message("Note","You are trying to play\na malformed url."); | 851 | // QMessageBox::message("Note","You are trying to play\na malformed url."); |
843 | // } else { | 852 | // } else { |
844 | mediaPlayerState->setPlaying(b); | 853 | mediaPlayerState->setPlaying(b); |
845 | insanityBool=FALSE; | 854 | insanityBool=FALSE; |
846 | qDebug("insanity"); | 855 | qDebug("insanity"); |
847 | // } | 856 | // } |
848 | } | 857 | } |
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(); |
874 | break; | 883 | break; |
875 | }; | 884 | }; |
876 | 885 | ||
877 | } | 886 | } |
878 | 887 | ||
879 | void PlayListWidget::deletePlaylist() { | 888 | void PlayListWidget::deletePlaylist() { |
@@ -1450,45 +1459,47 @@ void PlayListWidget::skinsMenuActivated( int item ) { | |||
1450 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); | 1459 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); |
1451 | } | 1460 | } |
1452 | 1461 | ||
1453 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { | 1462 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { |
1454 | qDebug("qcop message "+msg ); | 1463 | qDebug("qcop message "+msg ); |
1455 | QDataStream stream ( data, IO_ReadOnly ); | 1464 | QDataStream stream ( data, IO_ReadOnly ); |
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 |
1469 | mediaPlayerState->toggleShuffled(); | 1478 | mediaPlayerState->toggleShuffled(); |
1470 | } else if ( msg == "volUp()" ) { //volume more | 1479 | } else if ( msg == "volUp()" ) { //volume more |
1471 | // emit moreClicked(); | 1480 | // emit moreClicked(); |
1472 | // emit moreReleased(); | 1481 | // emit moreReleased(); |
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 | } |
diff --git a/core/multimedia/opieplayer/playlistwidget.h b/core/multimedia/opieplayer/playlistwidget.h index e66bcb9..0c0e367 100644 --- a/core/multimedia/opieplayer/playlistwidget.h +++ b/core/multimedia/opieplayer/playlistwidget.h | |||
@@ -93,24 +93,25 @@ private: | |||
93 | void populateVideoView(); | 93 | void populateVideoView(); |
94 | private slots: | 94 | private slots: |
95 | 95 | ||
96 | void qcopReceive(const QCString&, const QByteArray&); | 96 | void qcopReceive(const QCString&, const QByteArray&); |
97 | void populateSkinsMenu(); | 97 | void populateSkinsMenu(); |
98 | void skinsMenuActivated(int); | 98 | void skinsMenuActivated(int); |
99 | void writem3u(); | 99 | void writem3u(); |
100 | void writeCurrentM3u(); | 100 | void writeCurrentM3u(); |
101 | void scanForAudio(); | 101 | void scanForAudio(); |
102 | void scanForVideo(); | 102 | void scanForVideo(); |
103 | void openFile(); | 103 | void openFile(); |
104 | void setDocument( const QString& fileref ); | 104 | void setDocument( const QString& fileref ); |
105 | void setDocumentEx( const QString& fileref ); | ||
105 | void addToSelection( const DocLnk& ); // Add a media file to the playlist | 106 | void addToSelection( const DocLnk& ); // Add a media file to the playlist |
106 | void addToSelection( QListViewItem* ); // Add a media file to the playlist | 107 | void addToSelection( QListViewItem* ); // Add a media file to the playlist |
107 | void setActiveWindow(); // need to handle this to show the right view | 108 | void setActiveWindow(); // need to handle this to show the right view |
108 | void setPlaylist( bool ); // Show/Hide the playlist | 109 | void setPlaylist( bool ); // Show/Hide the playlist |
109 | void setView( char ); | 110 | void setView( char ); |
110 | void clearList(); | 111 | void clearList(); |
111 | void addAllToList(); | 112 | void addAllToList(); |
112 | void addAllMusicToList(); | 113 | void addAllMusicToList(); |
113 | void addAllVideoToList(); | 114 | void addAllVideoToList(); |
114 | void saveList(); // Save the playlist | 115 | void saveList(); // Save the playlist |
115 | void loadList( const DocLnk &); // Load a playlist | 116 | void loadList( const DocLnk &); // Load a playlist |
116 | void playIt( QListViewItem *); | 117 | void playIt( QListViewItem *); |