summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-10-09 23:36:52 (UTC)
committer llornkcor <llornkcor>2002-10-09 23:36:52 (UTC)
commit4c7d8f663ee98751da0f8264ea1d49799463f0bf (patch) (unidiff)
treeb2fd7207dd9b59643b144aca03098e7b10550c5c
parentd624bf47913f76c881f28c6498cec4ad3c007a9b (diff)
downloadopie-4c7d8f663ee98751da0f8264ea1d49799463f0bf.zip
opie-4c7d8f663ee98751da0f8264ea1d49799463f0bf.tar.gz
opie-4c7d8f663ee98751da0f8264ea1d49799463f0bf.tar.bz2
remove op2 crash feature when cancelling playlist save
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index d53c423..e28efd0 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -712,342 +712,343 @@ void PlayListWidget::openFile() {
712 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 712 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
713 fileDlg->exec(); 713 fileDlg->exec();
714 if( fileDlg->result() == 1 ) { 714 if( fileDlg->result() == 1 ) {
715 filename = fileDlg->text(); 715 filename = fileDlg->text();
716 qDebug( "Selected filename is " + filename ); 716 qDebug( "Selected filename is " + filename );
717 Om3u *m3uList; 717 Om3u *m3uList;
718 DocLnk lnk; 718 DocLnk lnk;
719 Config cfg( "OpiePlayer" ); 719 Config cfg( "OpiePlayer" );
720 cfg.setGroup("PlayList"); 720 cfg.setGroup("PlayList");
721 721
722 if(filename.left(4) == "http") { 722 if(filename.left(4) == "http") {
723 QString m3uFile, m3uFilePath; 723 QString m3uFile, m3uFilePath;
724 if(filename.find(":",8,TRUE) != -1) { //found a port 724 if(filename.find(":",8,TRUE) != -1) { //found a port
725 m3uFile = filename.left( filename.find( ":",8,TRUE)); 725 m3uFile = filename.left( filename.find( ":",8,TRUE));
726 m3uFile = m3uFile.right( 7); 726 m3uFile = m3uFile.right( 7);
727 } else if(filename.left(4) == "http"){ 727 } else if(filename.left(4) == "http"){
728 m3uFile=filename; 728 m3uFile=filename;
729 m3uFile = m3uFile.right( m3uFile.length() - 7); 729 m3uFile = m3uFile.right( m3uFile.length() - 7);
730 } else{ 730 } else{
731 m3uFile=filename; 731 m3uFile=filename;
732 } 732 }
733 733
734// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); 734// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile);
735 lnk.setName( filename ); //sets name 735 lnk.setName( filename ); //sets name
736 lnk.setFile( filename ); //sets file name 736 lnk.setFile( filename ); //sets file name
737 lnk.setIcon("opieplayer2/musicfile"); 737 lnk.setIcon("opieplayer2/musicfile");
738 d->selectedFiles->addToSelection( lnk ); 738 d->selectedFiles->addToSelection( lnk );
739 writeCurrentM3u(); 739 writeCurrentM3u();
740 } 740 }
741 else if( filename.right( 3) == "m3u" ) { 741 else if( filename.right( 3) == "m3u" ) {
742 readm3u( filename ); 742 readm3u( filename );
743 743
744 } else if( filename.right(3) == "pls" ) { 744 } else if( filename.right(3) == "pls" ) {
745 readPls( filename ); 745 readPls( filename );
746 } else { 746 } else {
747 d->selectedFiles->addToSelection( DocLnk(filename) ); 747 d->selectedFiles->addToSelection( DocLnk(filename) );
748 writeCurrentM3u(); 748 writeCurrentM3u();
749 } 749 }
750 } 750 }
751 751
752 if( fileDlg ) { 752 if( fileDlg ) {
753 delete fileDlg; 753 delete fileDlg;
754 } 754 }
755} 755}
756 756
757/* 757/*
758reads m3u and shows files/urls to playlist widget */ 758reads m3u and shows files/urls to playlist widget */
759void PlayListWidget::readm3u( const QString &filename ) { 759void PlayListWidget::readm3u( const QString &filename ) {
760 qDebug( "read m3u filename " + filename ); 760 qDebug( "read m3u filename " + filename );
761 761
762 Om3u *m3uList; 762 Om3u *m3uList;
763 QString s, name; 763 QString s, name;
764 m3uList = new Om3u( filename, IO_ReadOnly ); 764 m3uList = new Om3u( filename, IO_ReadOnly );
765 m3uList->readM3u(); 765 m3uList->readM3u();
766 DocLnk lnk; 766 DocLnk lnk;
767 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 767 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
768 s = *it; 768 s = *it;
769// s.replace( QRegExp( "%20" )," " ); 769// s.replace( QRegExp( "%20" )," " );
770// qDebug("reading "+ s); 770// qDebug("reading "+ s);
771 if(s.left(4)=="http") { 771 if(s.left(4)=="http") {
772 lnk.setName( s ); //sets file name 772 lnk.setName( s ); //sets file name
773 lnk.setFile( s ); //sets file name 773 lnk.setFile( s ); //sets file name
774 lnk.setIcon("opieplayer2/musicfile"); 774 lnk.setIcon("opieplayer2/musicfile");
775 } 775 }
776 else { 776 else {
777 if( QFileInfo( s ).exists() ) { 777 if( QFileInfo( s ).exists() ) {
778 lnk.setName( QFileInfo(s).baseName()); 778 lnk.setName( QFileInfo(s).baseName());
779// qDebug("set link "+s); 779// qDebug("set link "+s);
780 if(s.at(s.length()-4) == '.') //if regular file 780 if(s.at(s.length()-4) == '.') //if regular file
781 lnk.setFile( s); 781 lnk.setFile( s);
782 else 782 else
783 lnk.setFile( s+"/"); //if url with no extension 783 lnk.setFile( s+"/"); //if url with no extension
784 } 784 }
785 } 785 }
786 d->selectedFiles->addToSelection( lnk ); 786 d->selectedFiles->addToSelection( lnk );
787 } 787 }
788 Config config( "OpiePlayer" ); 788 Config config( "OpiePlayer" );
789 config.setGroup( "PlayList" ); 789 config.setGroup( "PlayList" );
790 790
791 config.writeEntry("CurrentPlaylist",filename); 791 config.writeEntry("CurrentPlaylist",filename);
792 config.write(); 792 config.write();
793 currentPlayList=filename; 793 currentPlayList=filename;
794 794
795// m3uList->write(); 795// m3uList->write();
796 m3uList->close(); 796 m3uList->close();
797 if(m3uList) delete m3uList; 797 if(m3uList) delete m3uList;
798 798
799 d->selectedFiles->setSelectedItem( s); 799 d->selectedFiles->setSelectedItem( s);
800 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); 800 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName());
801 801
802} 802}
803 803
804/* 804/*
805reads pls and adds files/urls to playlist */ 805reads pls and adds files/urls to playlist */
806void PlayListWidget::readPls( const QString &filename ) { 806void PlayListWidget::readPls( const QString &filename ) {
807 807
808 qDebug( "pls filename is " + filename ); 808 qDebug( "pls filename is " + filename );
809 Om3u *m3uList; 809 Om3u *m3uList;
810 QString s, name; 810 QString s, name;
811 m3uList = new Om3u( filename, IO_ReadOnly ); 811 m3uList = new Om3u( filename, IO_ReadOnly );
812 m3uList->readPls(); 812 m3uList->readPls();
813 813
814 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 814 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
815 s = *it; 815 s = *it;
816 // s.replace( QRegExp( "%20" )," " ); 816 // s.replace( QRegExp( "%20" )," " );
817 DocLnk lnk( s ); 817 DocLnk lnk( s );
818 QFileInfo f( s ); 818 QFileInfo f( s );
819 QString name = f.baseName(); 819 QString name = f.baseName();
820 820
821 if( name.left( 4 ) == "http" ) { 821 if( name.left( 4 ) == "http" ) {
822 name = s.right( s.length() - 7); 822 name = s.right( s.length() - 7);
823 } else { 823 } else {
824 name = s; 824 name = s;
825 } 825 }
826 826
827 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); 827 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
828 828
829 lnk.setName( name ); 829 lnk.setName( name );
830 if( s.at( s.length() - 4) == '.') {// if this is probably a file 830 if( s.at( s.length() - 4) == '.') {// if this is probably a file
831 lnk.setFile( s ); 831 lnk.setFile( s );
832 } else { //if its a url 832 } else { //if its a url
833 if( name.right( 1 ).find( '/' ) == -1) { 833 if( name.right( 1 ).find( '/' ) == -1) {
834 s += "/"; 834 s += "/";
835 } 835 }
836 lnk.setFile( s ); 836 lnk.setFile( s );
837 } 837 }
838 lnk.setType( "audio/x-mpegurl" ); 838 lnk.setType( "audio/x-mpegurl" );
839 839
840 lnk.writeLink(); 840 lnk.writeLink();
841 d->selectedFiles->addToSelection( lnk ); 841 d->selectedFiles->addToSelection( lnk );
842 } 842 }
843 843
844 m3uList->close(); 844 m3uList->close();
845 if(m3uList) delete m3uList; 845 if(m3uList) delete m3uList;
846} 846}
847 847
848/* 848/*
849 writes current playlist to current m3u file */ 849 writes current playlist to current m3u file */
850void PlayListWidget::writeCurrentM3u() { 850void PlayListWidget::writeCurrentM3u() {
851 qDebug("writing to current m3u"); 851 qDebug("writing to current m3u");
852 Config cfg( "OpiePlayer" ); 852 Config cfg( "OpiePlayer" );
853 cfg.setGroup("PlayList"); 853 cfg.setGroup("PlayList");
854 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 854 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
855 855
856 Om3u *m3uList; 856 Om3u *m3uList;
857 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); 857 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate );
858 d->selectedFiles->first(); 858 d->selectedFiles->first();
859 qDebug( d->selectedFiles->current()->file()); 859 qDebug( d->selectedFiles->current()->file());
860 do { 860 do {
861 qDebug( d->selectedFiles->current()->file()); 861 qDebug( d->selectedFiles->current()->file());
862 m3uList->add( d->selectedFiles->current()->file() ); 862 m3uList->add( d->selectedFiles->current()->file() );
863 } 863 }
864 while ( d->selectedFiles->next() ); 864 while ( d->selectedFiles->next() );
865 qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); 865 qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" );
866 m3uList->write(); 866 m3uList->write();
867 m3uList->close(); 867 m3uList->close();
868 868
869 if(m3uList) delete m3uList; 869 if(m3uList) delete m3uList;
870} 870}
871 871
872 /* 872 /*
873 writes current playlist to m3u file */ 873 writes current playlist to m3u file */
874void PlayListWidget::writem3u() { 874void PlayListWidget::writem3u() {
875 InputDialog *fileDlg; 875 InputDialog *fileDlg;
876 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); 876 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
877 fileDlg->exec(); 877 fileDlg->exec();
878 QString name, filename, list; 878 QString name, filename, list;
879 Om3u *m3uList; 879 Om3u *m3uList;
880 880
881 if( fileDlg->result() == 1 ) { 881 if( fileDlg->result() == 1 ) {
882 name = fileDlg->text(); 882 name = fileDlg->text();
883// qDebug( filename ); 883// qDebug( filename );
884 884
885 if( name.left( 1) != "/" ) { 885 if( name.left( 1) != "/" ) {
886 filename = QPEApplication::documentDir() + "/" + name; 886 filename = QPEApplication::documentDir() + "/" + name;
887 } 887 }
888 888
889 if( name.right( 3 ) != "m3u" ) { 889 if( name.right( 3 ) != "m3u" ) {
890 filename = QPEApplication::documentDir() + "/" +name+".m3u"; 890 filename = QPEApplication::documentDir() + "/" +name+".m3u";
891 } 891 }
892 892
893 m3uList = new Om3u(filename, IO_ReadWrite); 893 m3uList = new Om3u(filename, IO_ReadWrite);
894 894
895 d->selectedFiles->first(); 895 d->selectedFiles->first();
896 896
897 do { 897 do {
898 m3uList->add( d->selectedFiles->current()->file()); 898 m3uList->add( d->selectedFiles->current()->file());
899 } 899 }
900 while ( d->selectedFiles->next() ); 900 while ( d->selectedFiles->next() );
901// qDebug( list ); 901// qDebug( list );
902 m3uList->write(); 902 m3uList->write();
903 m3uList->close(); 903 m3uList->close();
904
905 }
906 if(m3uList) delete m3uList; 904 if(m3uList) delete m3uList;
905
907 if(fileDlg) delete fileDlg; 906 if(fileDlg) delete fileDlg;
908 907
909 DocLnk lnk; 908 DocLnk lnk;
910 lnk.setFile( filename); 909 lnk.setFile( filename);
911 lnk.setIcon("opieplayer2/playlist2"); 910 lnk.setIcon("opieplayer2/playlist2");
912 lnk.setName( name); //sets file name 911 lnk.setName( name); //sets file name
913 912
914// qDebug(filename); 913// qDebug(filename);
915 Config config( "OpiePlayer" ); 914 Config config( "OpiePlayer" );
916 config.setGroup( "PlayList" ); 915 config.setGroup( "PlayList" );
917 916
918 config.writeEntry("CurrentPlaylist",filename); 917 config.writeEntry("CurrentPlaylist",filename);
919 currentPlayList=filename; 918 currentPlayList=filename;
920 919
921 if(!lnk.writeLink()) { 920 if(!lnk.writeLink()) {
922 qDebug("Writing doclink did not work"); 921 qDebug("Writing doclink did not work");
923 } 922 }
924 923
925 setCaption(tr("OpiePlayer: ") + name); 924 setCaption(tr("OpiePlayer: ") + name);
925 }
926
926} 927}
927 928
928void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { 929void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) {
929 switch ( e->key() ) { 930 switch ( e->key() ) {
930 ////////////////////////////// Zaurus keys 931 ////////////////////////////// Zaurus keys
931 case Key_F9: //activity 932 case Key_F9: //activity
932 // if(audioUI->isHidden()) 933 // if(audioUI->isHidden())
933 // audioUI->showMaximized(); 934 // audioUI->showMaximized();
934 break; 935 break;
935 case Key_F10: //contacts 936 case Key_F10: //contacts
936 // if( videoUI->isHidden()) 937 // if( videoUI->isHidden())
937 // videoUI->showMaximized(); 938 // videoUI->showMaximized();
938 break; 939 break;
939 case Key_F11: //menu 940 case Key_F11: //menu
940 break; 941 break;
941 case Key_F12: //home 942 case Key_F12: //home
942 // doBlank(); 943 // doBlank();
943 break; 944 break;
944 case Key_F13: //mail 945 case Key_F13: //mail
945 // doUnblank(); 946 // doUnblank();
946 break; 947 break;
947 case Key_Q: //add to playlist 948 case Key_Q: //add to playlist
948 addSelected(); 949 addSelected();
949 break; 950 break;
950 case Key_R: //remove from playlist 951 case Key_R: //remove from playlist
951 removeSelected(); 952 removeSelected();
952 break; 953 break;
953 // case Key_P: //play 954 // case Key_P: //play
954 // qDebug("Play"); 955 // qDebug("Play");
955 // playSelected(); 956 // playSelected();
956 // break; 957 // break;
957 case Key_Space: 958 case Key_Space:
958 // playSelected(); puh 959 // playSelected(); puh
959 break; 960 break;
960 case Key_1: 961 case Key_1:
961 tabWidget->setCurrentPage( 0 ); 962 tabWidget->setCurrentPage( 0 );
962 break; 963 break;
963 case Key_2: 964 case Key_2:
964 tabWidget->setCurrentPage( 1 ); 965 tabWidget->setCurrentPage( 1 );
965 break; 966 break;
966 case Key_3: 967 case Key_3:
967 tabWidget->setCurrentPage( 2 ); 968 tabWidget->setCurrentPage( 2 );
968 break; 969 break;
969 case Key_4: 970 case Key_4:
970 tabWidget->setCurrentPage( 3 ); 971 tabWidget->setCurrentPage( 3 );
971 break; 972 break;
972 case Key_Down: 973 case Key_Down:
973 if ( !d->selectedFiles->next() ) 974 if ( !d->selectedFiles->next() )
974 d->selectedFiles->first(); 975 d->selectedFiles->first();
975 break; 976 break;
976 case Key_Up: 977 case Key_Up:
977 if ( !d->selectedFiles->prev() ) 978 if ( !d->selectedFiles->prev() )
978 // d->selectedFiles->last(); 979 // d->selectedFiles->last();
979 break; 980 break;
980 } 981 }
981} 982}
982 983
983void PlayListWidget::pmViewActivated(int index) { 984void PlayListWidget::pmViewActivated(int index) {
984// qDebug("%d", index); 985// qDebug("%d", index);
985 switch(index) { 986 switch(index) {
986 case -16: 987 case -16:
987 { 988 {
988 mediaPlayerState->toggleFullscreen(); 989 mediaPlayerState->toggleFullscreen();
989 bool b=mediaPlayerState->fullscreen(); 990 bool b=mediaPlayerState->fullscreen();
990 pmView->setItemChecked( index, b); 991 pmView->setItemChecked( index, b);
991 Config cfg( "OpiePlayer" ); 992 Config cfg( "OpiePlayer" );
992 cfg.writeEntry( "FullScreen", b ); 993 cfg.writeEntry( "FullScreen", b );
993 } 994 }
994 break; 995 break;
995 }; 996 };
996} 997}
997 998
998void PlayListWidget::populateSkinsMenu() { 999void PlayListWidget::populateSkinsMenu() {
999 int item = 0; 1000 int item = 0;
1000 defaultSkinIndex = 0; 1001 defaultSkinIndex = 0;
1001 QString skinName; 1002 QString skinName;
1002 Config cfg( "OpiePlayer" ); 1003 Config cfg( "OpiePlayer" );
1003 cfg.setGroup("Options" ); 1004 cfg.setGroup("Options" );
1004 QString skin = cfg.readEntry( "Skin", "default" ); 1005 QString skin = cfg.readEntry( "Skin", "default" );
1005 1006
1006 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); 1007 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" );
1007 skinsDir.setFilter( QDir::Dirs ); 1008 skinsDir.setFilter( QDir::Dirs );
1008 skinsDir.setSorting(QDir::Name ); 1009 skinsDir.setSorting(QDir::Name );
1009 const QFileInfoList *skinslist = skinsDir.entryInfoList(); 1010 const QFileInfoList *skinslist = skinsDir.entryInfoList();
1010 QFileInfoListIterator it( *skinslist ); 1011 QFileInfoListIterator it( *skinslist );
1011 QFileInfo *fi; 1012 QFileInfo *fi;
1012 while ( ( fi = it.current() ) ) { 1013 while ( ( fi = it.current() ) ) {
1013 skinName = fi->fileName(); 1014 skinName = fi->fileName();
1014// qDebug( fi->fileName() ); 1015// qDebug( fi->fileName() );
1015 if( skinName != "." && skinName != ".." && skinName !="CVS" ) { 1016 if( skinName != "." && skinName != ".." && skinName !="CVS" ) {
1016 item = skinsMenu->insertItem( fi->fileName() ) ; 1017 item = skinsMenu->insertItem( fi->fileName() ) ;
1017 } 1018 }
1018 if( skinName == "default" ) { 1019 if( skinName == "default" ) {
1019 defaultSkinIndex = item; 1020 defaultSkinIndex = item;
1020 } 1021 }
1021 if( skinName == skin ) { 1022 if( skinName == skin ) {
1022 skinsMenu->setItemChecked( item, TRUE ); 1023 skinsMenu->setItemChecked( item, TRUE );
1023 } 1024 }
1024 ++it; 1025 ++it;
1025 } 1026 }
1026} 1027}
1027 1028
1028void PlayListWidget::skinsMenuActivated( int item ) { 1029void PlayListWidget::skinsMenuActivated( int item ) {
1029 for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { 1030 for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) {
1030 skinsMenu->setItemChecked( i, FALSE ); 1031 skinsMenu->setItemChecked( i, FALSE );
1031 } 1032 }
1032 skinsMenu->setItemChecked( item, TRUE ); 1033 skinsMenu->setItemChecked( item, TRUE );
1033 1034
1034 Config cfg( "OpiePlayer" ); 1035 Config cfg( "OpiePlayer" );
1035 cfg.setGroup("Options"); 1036 cfg.setGroup("Options");
1036 cfg.writeEntry("Skin", skinsMenu->text( item ) ); 1037 cfg.writeEntry("Skin", skinsMenu->text( item ) );
1037} 1038}
1038 1039
1039int PlayListWidget::whichList() { 1040int PlayListWidget::whichList() {
1040 return tabWidget->currentPageIndex(); 1041 return tabWidget->currentPageIndex();
1041} 1042}
1042 1043
1043QString PlayListWidget::currentFileListPathName() { 1044QString PlayListWidget::currentFileListPathName() {
1044 switch (whichList()) { 1045 switch (whichList()) {
1045 case 1: 1046 case 1:
1046 return audioView->currentItem()->text(3); 1047 return audioView->currentItem()->text(3);
1047 break; 1048 break;
1048 case 2: 1049 case 2:
1049 return videoView->currentItem()->text(3); 1050 return videoView->currentItem()->text(3);
1050 break; 1051 break;
1051 }; 1052 };
1052 return ""; 1053 return "";
1053} 1054}