summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 6e2457f..707f4d2 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -702,269 +702,270 @@ void PlayListWidget::openFile() {
702void PlayListWidget::readListFromFile( const QString &filename ) { 702void PlayListWidget::readListFromFile( const QString &filename ) {
703 qDebug( "read list filename " + filename ); 703 qDebug( "read list filename " + filename );
704 QFileInfo fi(filename); 704 QFileInfo fi(filename);
705 Om3u *m3uList; 705 Om3u *m3uList;
706 QString s, name; 706 QString s, name;
707 m3uList = new Om3u( filename, IO_ReadOnly ); 707 m3uList = new Om3u( filename, IO_ReadOnly );
708 if(fi.extension(false).find("m3u",0,false) != -1 ) 708 if(fi.extension(false).find("m3u",0,false) != -1 )
709 m3uList->readM3u(); 709 m3uList->readM3u();
710 else if(fi.extension(false).find("pls",0,false) != -1 ) 710 else if(fi.extension(false).find("pls",0,false) != -1 )
711 m3uList->readPls(); 711 m3uList->readPls();
712 712
713 DocLnk lnk; 713 DocLnk lnk;
714 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 714 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
715 s = *it; 715 s = *it;
716 // qDebug(s); 716 // qDebug(s);
717 if(s.left(4)=="http") { 717 if(s.left(4)=="http") {
718 lnk.setName( s ); //sets file name 718 lnk.setName( s ); //sets file name
719 lnk.setIcon("opieplayer2/musicfile"); 719 lnk.setIcon("opieplayer2/musicfile");
720 lnk.setFile( s ); //sets file name 720 lnk.setFile( s ); //sets file name
721 721
722 } else { //is file 722 } else { //is file
723 lnk.setName( QFileInfo(s).baseName()); 723 lnk.setName( QFileInfo(s).baseName());
724 if(s.left(1) != "/") { 724 if(s.left(1) != "/") {
725 725
726 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); 726 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s);
727 } else { 727 } else {
728 lnk.setFile( s); 728 lnk.setFile( s);
729 } 729 }
730 } 730 }
731 d->selectedFiles->addToSelection( lnk ); 731 d->selectedFiles->addToSelection( lnk );
732 } 732 }
733 Config config( "OpiePlayer" ); 733 Config config( "OpiePlayer" );
734 config.setGroup( "PlayList" ); 734 config.setGroup( "PlayList" );
735 735
736 config.writeEntry("CurrentPlaylist",filename); 736 config.writeEntry("CurrentPlaylist",filename);
737 config.write(); 737 config.write();
738 currentPlayList=filename; 738 currentPlayList=filename;
739 739
740// m3uList->write(); 740// m3uList->write();
741 m3uList->close(); 741 m3uList->close();
742 delete m3uList; 742 delete m3uList;
743 743
744 d->selectedFiles->setSelectedItem( s); 744 d->selectedFiles->setSelectedItem( s);
745 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); 745 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName());
746 746
747} 747}
748 748
749// /* 749// /*
750// reads pls and adds files/urls to playlist */ 750// reads pls and adds files/urls to playlist */
751// void PlayListWidget::readPls( const QString &filename ) { 751// void PlayListWidget::readPls( const QString &filename ) {
752 752
753// qDebug( "pls filename is " + filename ); 753// qDebug( "pls filename is " + filename );
754// Om3u *m3uList; 754// Om3u *m3uList;
755// QString s, name; 755// QString s, name;
756// m3uList = new Om3u( filename, IO_ReadOnly ); 756// m3uList = new Om3u( filename, IO_ReadOnly );
757// m3uList->readPls(); 757// m3uList->readPls();
758 758
759// for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 759// for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
760// s = *it; 760// s = *it;
761// // s.replace( QRegExp( "%20" )," " ); 761// // s.replace( QRegExp( "%20" )," " );
762// DocLnk lnk( s ); 762// DocLnk lnk( s );
763// QFileInfo f( s ); 763// QFileInfo f( s );
764// QString name = f.baseName(); 764// QString name = f.baseName();
765 765
766// if( name.left( 4 ) == "http" ) { 766// if( name.left( 4 ) == "http" ) {
767// name = s.right( s.length() - 7); 767// name = s.right( s.length() - 7);
768// } else { 768// } else {
769// name = s; 769// name = s;
770// } 770// }
771 771
772// name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); 772// name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
773 773
774// lnk.setName( name ); 774// lnk.setName( name );
775// if( s.at( s.length() - 4) == '.') {// if this is probably a file 775// if( s.at( s.length() - 4) == '.') {// if this is probably a file
776// lnk.setFile( s ); 776// lnk.setFile( s );
777// } else { //if its a url 777// } else { //if its a url
778// // if( name.right( 1 ).find( '/' ) == -1) { 778// // if( name.right( 1 ).find( '/' ) == -1) {
779// // s += "/"; 779// // s += "/";
780// // } 780// // }
781// lnk.setFile( s ); 781// lnk.setFile( s );
782// } 782// }
783// lnk.setType( "audio/x-mpegurl" ); 783// lnk.setType( "audio/x-mpegurl" );
784 784
785// lnk.writeLink(); 785// lnk.writeLink();
786// d->selectedFiles->addToSelection( lnk ); 786// d->selectedFiles->addToSelection( lnk );
787// } 787// }
788 788
789// m3uList->close(); 789// m3uList->close();
790// delete m3uList; 790// delete m3uList;
791// } 791// }
792 792
793// /* 793// /*
794// writes current playlist to current m3u file */ 794// writes current playlist to current m3u file */
795 void PlayListWidget::writeCurrentM3u() { 795 void PlayListWidget::writeCurrentM3u() {
796 qDebug("writing to current m3u"); 796 qDebug("writing to current m3u");
797 Config cfg( "OpiePlayer" ); 797 Config cfg( "OpiePlayer" );
798 cfg.setGroup("PlayList"); 798 cfg.setGroup("PlayList");
799 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); 799 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default");
800 800
801 Om3u *m3uList; 801 Om3u *m3uList;
802 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); 802 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate );
803 if( d->selectedFiles->first()) { 803 if( d->selectedFiles->first()) {
804 804
805 do { 805 do {
806 // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); 806 // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file());
807 m3uList->add( d->selectedFiles->current()->file() ); 807 m3uList->add( d->selectedFiles->current()->file() );
808 } 808 }
809 while ( d->selectedFiles->next() ); 809 while ( d->selectedFiles->next() );
810 // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); 810 // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" );
811 m3uList->write(); 811 m3uList->write();
812 m3uList->close(); 812 m3uList->close();
813 } 813 }
814 delete m3uList; 814 delete m3uList;
815 815
816 } 816 }
817 817
818 /* 818 /*
819 writes current playlist to m3u file */ 819 writes current playlist to m3u file */
820void PlayListWidget::writem3u() { 820void PlayListWidget::writem3u() {
821 InputDialog *fileDlg; 821 InputDialog *fileDlg;
822 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); 822 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
823 fileDlg->exec(); 823 fileDlg->exec();
824 QString name, filename, list; 824 QString name, filename, list;
825 Om3u *m3uList; 825 Om3u *m3uList;
826 826
827 if( fileDlg->result() == 1 ) { 827 if( fileDlg->result() == 1 ) {
828 name = fileDlg->text(); 828 name = fileDlg->text();
829// qDebug( filename ); 829// qDebug( filename );
830 830 if( name.find("/",0,true) != -1) {// assume they specify a file path
831 if( name.left( 1) != "/" ) { 831 filename = name;
832 filename = QPEApplication::documentDir() + "/" + name; 832 name = name.right(name.length()- name.findRev("/",-1,true) - 1 );
833 }
834
835 if( name.right( 3 ) != "m3u" ) {
836 filename = QPEApplication::documentDir() + "/" +name+".m3u";
837 } 833 }
834 else //otherwise dump it somewhere noticable
835 filename = QPEApplication::documentDir() + "/" + name;
838 836
839 if( d->selectedFiles->first()) { 837 if( filename.right( 3 ) != "m3u" ) //needs filename extension
840 m3uList = new Om3u(filename, IO_ReadWrite); 838 filename += ".m3u";
839
840 if( d->selectedFiles->first()) { //ramble through playlist view
841 m3uList = new Om3u( filename, IO_ReadWrite);
841 842
842 do { 843 do {
843 m3uList->add( d->selectedFiles->current()->file()); 844 m3uList->add( d->selectedFiles->current()->file());
844 } 845 }
845 while ( d->selectedFiles->next() ); 846 while ( d->selectedFiles->next() );
846 // qDebug( list ); 847 // qDebug( list );
847 m3uList->write(); 848 m3uList->write();
848 m3uList->close(); 849 m3uList->close();
849 delete m3uList; 850 delete m3uList;
850 851
851 delete fileDlg; 852 delete fileDlg;
852 853
853 DocLnk lnk; 854 DocLnk lnk;
854 lnk.setFile( filename); 855 lnk.setFile( filename);
855 lnk.setIcon("opieplayer2/playlist2"); 856 lnk.setIcon("opieplayer2/playlist2");
856 lnk.setName( name); //sets file name 857 lnk.setName( name); //sets file name
857 858
858 // qDebug(filename); 859 // qDebug(filename);
859 Config config( "OpiePlayer" ); 860 Config config( "OpiePlayer" );
860 config.setGroup( "PlayList" ); 861 config.setGroup( "PlayList" );
861 862
862 config.writeEntry("CurrentPlaylist",filename); 863 config.writeEntry("CurrentPlaylist",filename);
863 currentPlayList=filename; 864 currentPlayList=filename;
864 865
865 if(!lnk.writeLink()) { 866 if(!lnk.writeLink()) {
866 qDebug("Writing doclink did not work"); 867 qDebug("Writing doclink did not work");
867 } 868 }
868 869
869 setCaption(tr("OpiePlayer: ") + name); 870 setCaption(tr("OpiePlayer: ") + name);
870 } 871 }
871 } 872 }
872} 873}
873 874
874void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { 875void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) {
875 switch ( e->key() ) { 876 switch ( e->key() ) {
876 ////////////////////////////// Zaurus keys 877 ////////////////////////////// Zaurus keys
877 case Key_F9: //activity 878 case Key_F9: //activity
878 // if(audioUI->isHidden()) 879 // if(audioUI->isHidden())
879 // audioUI->showMaximized(); 880 // audioUI->showMaximized();
880 break; 881 break;
881 case Key_F10: //contacts 882 case Key_F10: //contacts
882 // if( videoUI->isHidden()) 883 // if( videoUI->isHidden())
883 // videoUI->showMaximized(); 884 // videoUI->showMaximized();
884 break; 885 break;
885 case Key_F11: //menu 886 case Key_F11: //menu
886 break; 887 break;
887 case Key_F12: //home 888 case Key_F12: //home
888 // doBlank(); 889 // doBlank();
889 break; 890 break;
890 case Key_F13: //mail 891 case Key_F13: //mail
891 // doUnblank(); 892 // doUnblank();
892 break; 893 break;
893 case Key_Q: //add to playlist 894 case Key_Q: //add to playlist
894 addSelected(); 895 addSelected();
895 break; 896 break;
896 case Key_R: //remove from playlist 897 case Key_R: //remove from playlist
897 removeSelected(); 898 removeSelected();
898 break; 899 break;
899 // case Key_P: //play 900 // case Key_P: //play
900 // qDebug("Play"); 901 // qDebug("Play");
901 // playSelected(); 902 // playSelected();
902 // break; 903 // break;
903 case Key_Space: 904 case Key_Space:
904 // playSelected(); puh 905 // playSelected(); puh
905 break; 906 break;
906 case Key_1: 907 case Key_1:
907 tabWidget->setCurrentPage( 0 ); 908 tabWidget->setCurrentPage( 0 );
908 break; 909 break;
909 case Key_2: 910 case Key_2:
910 tabWidget->setCurrentPage( 1 ); 911 tabWidget->setCurrentPage( 1 );
911 break; 912 break;
912 case Key_3: 913 case Key_3:
913 tabWidget->setCurrentPage( 2 ); 914 tabWidget->setCurrentPage( 2 );
914 break; 915 break;
915 case Key_4: 916 case Key_4:
916 tabWidget->setCurrentPage( 3 ); 917 tabWidget->setCurrentPage( 3 );
917 break; 918 break;
918 case Key_Down: 919 case Key_Down:
919 if ( !d->selectedFiles->next() ) 920 if ( !d->selectedFiles->next() )
920 d->selectedFiles->first(); 921 d->selectedFiles->first();
921 break; 922 break;
922 case Key_Up: 923 case Key_Up:
923 if ( !d->selectedFiles->prev() ) 924 if ( !d->selectedFiles->prev() )
924 // d->selectedFiles->last(); 925 // d->selectedFiles->last();
925 break; 926 break;
926 } 927 }
927} 928}
928 929
929void PlayListWidget::pmViewActivated(int index) { 930void PlayListWidget::pmViewActivated(int index) {
930// qDebug("%d", index); 931// qDebug("%d", index);
931 switch(index) { 932 switch(index) {
932 case -16: 933 case -16:
933 { 934 {
934 mediaPlayerState.toggleFullscreen(); 935 mediaPlayerState.toggleFullscreen();
935 bool b=mediaPlayerState.isFullscreen(); 936 bool b=mediaPlayerState.isFullscreen();
936 pmView->setItemChecked( index, b); 937 pmView->setItemChecked( index, b);
937 Config cfg( "OpiePlayer" ); 938 Config cfg( "OpiePlayer" );
938 cfg.writeEntry( "FullScreen", b ); 939 cfg.writeEntry( "FullScreen", b );
939 } 940 }
940 break; 941 break;
941 }; 942 };
942} 943}
943 944
944void PlayListWidget::populateSkinsMenu() { 945void PlayListWidget::populateSkinsMenu() {
945 int item = 0; 946 int item = 0;
946 defaultSkinIndex = 0; 947 defaultSkinIndex = 0;
947 QString skinName; 948 QString skinName;
948 Config cfg( "OpiePlayer" ); 949 Config cfg( "OpiePlayer" );
949 cfg.setGroup("Options" ); 950 cfg.setGroup("Options" );
950 QString skin = cfg.readEntry( "Skin", "default" ); 951 QString skin = cfg.readEntry( "Skin", "default" );
951 952
952 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); 953 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" );
953 skinsDir.setFilter( QDir::Dirs ); 954 skinsDir.setFilter( QDir::Dirs );
954 skinsDir.setSorting(QDir::Name ); 955 skinsDir.setSorting(QDir::Name );
955 const QFileInfoList *skinslist = skinsDir.entryInfoList(); 956 const QFileInfoList *skinslist = skinsDir.entryInfoList();
956 QFileInfoListIterator it( *skinslist ); 957 QFileInfoListIterator it( *skinslist );
957 QFileInfo *fi; 958 QFileInfo *fi;
958 while ( ( fi = it.current() ) ) { 959 while ( ( fi = it.current() ) ) {
959 skinName = fi->fileName(); 960 skinName = fi->fileName();
960// qDebug( fi->fileName() ); 961// qDebug( fi->fileName() );
961 if( skinName != "." && skinName != ".." && skinName !="CVS" ) { 962 if( skinName != "." && skinName != ".." && skinName !="CVS" ) {
962 item = skinsMenu->insertItem( fi->fileName() ) ; 963 item = skinsMenu->insertItem( fi->fileName() ) ;
963 } 964 }
964 if( skinName == "default" ) { 965 if( skinName == "default" ) {
965 defaultSkinIndex = item; 966 defaultSkinIndex = item;
966 } 967 }
967 if( skinName == skin ) { 968 if( skinName == skin ) {
968 skinsMenu->setItemChecked( item, TRUE ); 969 skinsMenu->setItemChecked( item, TRUE );
969 } 970 }
970 ++it; 971 ++it;