-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index ac52b07..2df7f27 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -670,267 +670,266 @@ void PlayListWidget::openFile() { | |||
670 | writeCurrentM3u(); | 670 | writeCurrentM3u(); |
671 | d->selectedFiles->setSelectedItem( lnk.name()); | 671 | d->selectedFiles->setSelectedItem( lnk.name()); |
672 | } | 672 | } |
673 | else if( filename.right( 3) == "m3u" ) { | 673 | else if( filename.right( 3) == "m3u" ) { |
674 | readm3u( filename ); | 674 | readm3u( filename ); |
675 | 675 | ||
676 | } else if( filename.right(3) == "pls" ) { | 676 | } else if( filename.right(3) == "pls" ) { |
677 | readPls( filename ); | 677 | readPls( filename ); |
678 | } else { | 678 | } else { |
679 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 679 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
680 | lnk.setFile( filename ); //sets file name | 680 | lnk.setFile( filename ); //sets file name |
681 | d->selectedFiles->addToSelection( lnk); | 681 | d->selectedFiles->addToSelection( lnk); |
682 | writeCurrentM3u(); | 682 | writeCurrentM3u(); |
683 | d->selectedFiles->setSelectedItem( lnk.name()); | 683 | d->selectedFiles->setSelectedItem( lnk.name()); |
684 | } | 684 | } |
685 | } | 685 | } |
686 | 686 | ||
687 | delete fileDlg; | 687 | delete fileDlg; |
688 | } | 688 | } |
689 | 689 | ||
690 | /* | 690 | /* |
691 | reads m3u and shows files/urls to playlist widget */ | 691 | reads m3u and shows files/urls to playlist widget */ |
692 | void PlayListWidget::readm3u( const QString &filename ) { | 692 | void PlayListWidget::readm3u( const QString &filename ) { |
693 | qDebug( "read m3u filename " + filename ); | 693 | qDebug( "read m3u filename " + filename ); |
694 | 694 | ||
695 | Om3u *m3uList; | 695 | Om3u *m3uList; |
696 | QString s, name; | 696 | QString s, name; |
697 | m3uList = new Om3u( filename, IO_ReadOnly ); | 697 | m3uList = new Om3u( filename, IO_ReadOnly ); |
698 | m3uList->readM3u(); | 698 | m3uList->readM3u(); |
699 | DocLnk lnk; | 699 | DocLnk lnk; |
700 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 700 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
701 | s = *it; | 701 | s = *it; |
702 | // qDebug("reading "+ s); | 702 | // qDebug("reading "+ s); |
703 | if(s.left(4)=="http") { | 703 | if(s.left(4)=="http") { |
704 | lnk.setName( s ); //sets file name | 704 | lnk.setName( s ); //sets file name |
705 | lnk.setIcon("opieplayer2/musicfile"); | 705 | lnk.setIcon("opieplayer2/musicfile"); |
706 | lnk.setFile( s ); //sets file name | 706 | lnk.setFile( s ); //sets file name |
707 | 707 | ||
708 | } else { | 708 | } else { |
709 | // if( QFileInfo( s ).exists() ) { | 709 | // if( QFileInfo( s ).exists() ) { |
710 | lnk.setName( QFileInfo(s).baseName()); | 710 | lnk.setName( QFileInfo(s).baseName()); |
711 | // if(s.right(4) == '.') {//if regular file | 711 | // if(s.right(4) == '.') {//if regular file |
712 | if(s.left(1) != "/") { | 712 | if(s.left(1) != "/") { |
713 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); | 713 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); |
714 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 714 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
715 | // lnk.setIcon(MimeType(s).pixmap() ); | 715 | // lnk.setIcon(MimeType(s).pixmap() ); |
716 | // lnk.setIcon("SoundPlayer"); | 716 | // lnk.setIcon("SoundPlayer"); |
717 | } else { | 717 | } else { |
718 | // qDebug("set link2 "+s); | 718 | // qDebug("set link2 "+s); |
719 | lnk.setFile( s); | 719 | lnk.setFile( s); |
720 | // lnk.setIcon(MimeType(s).pixmap() ); | 720 | // lnk.setIcon(MimeType(s).pixmap() ); |
721 | // lnk.setIcon("SoundPlayer"); | 721 | // lnk.setIcon("SoundPlayer"); |
722 | } | 722 | } |
723 | } | 723 | } |
724 | d->selectedFiles->addToSelection( lnk ); | 724 | d->selectedFiles->addToSelection( lnk ); |
725 | } | 725 | } |
726 | Config config( "OpiePlayer" ); | 726 | Config config( "OpiePlayer" ); |
727 | config.setGroup( "PlayList" ); | 727 | config.setGroup( "PlayList" ); |
728 | 728 | ||
729 | config.writeEntry("CurrentPlaylist",filename); | 729 | config.writeEntry("CurrentPlaylist",filename); |
730 | config.write(); | 730 | config.write(); |
731 | currentPlayList=filename; | 731 | currentPlayList=filename; |
732 | 732 | ||
733 | // m3uList->write(); | 733 | // m3uList->write(); |
734 | m3uList->close(); | 734 | m3uList->close(); |
735 | delete m3uList; | 735 | delete m3uList; |
736 | 736 | ||
737 | d->selectedFiles->setSelectedItem( s); | 737 | d->selectedFiles->setSelectedItem( s); |
738 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); | 738 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); |
739 | 739 | ||
740 | } | 740 | } |
741 | 741 | ||
742 | /* | 742 | /* |
743 | reads pls and adds files/urls to playlist */ | 743 | reads pls and adds files/urls to playlist */ |
744 | void PlayListWidget::readPls( const QString &filename ) { | 744 | void PlayListWidget::readPls( const QString &filename ) { |
745 | 745 | ||
746 | qDebug( "pls filename is " + filename ); | 746 | qDebug( "pls filename is " + filename ); |
747 | Om3u *m3uList; | 747 | Om3u *m3uList; |
748 | QString s, name; | 748 | QString s, name; |
749 | m3uList = new Om3u( filename, IO_ReadOnly ); | 749 | m3uList = new Om3u( filename, IO_ReadOnly ); |
750 | m3uList->readPls(); | 750 | m3uList->readPls(); |
751 | 751 | ||
752 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 752 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
753 | s = *it; | 753 | s = *it; |
754 | // s.replace( QRegExp( "%20" )," " ); | 754 | // s.replace( QRegExp( "%20" )," " ); |
755 | DocLnk lnk( s ); | 755 | DocLnk lnk( s ); |
756 | QFileInfo f( s ); | 756 | QFileInfo f( s ); |
757 | QString name = f.baseName(); | 757 | QString name = f.baseName(); |
758 | 758 | ||
759 | if( name.left( 4 ) == "http" ) { | 759 | if( name.left( 4 ) == "http" ) { |
760 | name = s.right( s.length() - 7); | 760 | name = s.right( s.length() - 7); |
761 | } else { | 761 | } else { |
762 | name = s; | 762 | name = s; |
763 | } | 763 | } |
764 | 764 | ||
765 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 765 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
766 | 766 | ||
767 | lnk.setName( name ); | 767 | lnk.setName( name ); |
768 | if( s.at( s.length() - 4) == '.') {// if this is probably a file | 768 | if( s.at( s.length() - 4) == '.') {// if this is probably a file |
769 | lnk.setFile( s ); | 769 | lnk.setFile( s ); |
770 | } else { //if its a url | 770 | } else { //if its a url |
771 | // if( name.right( 1 ).find( '/' ) == -1) { | 771 | // if( name.right( 1 ).find( '/' ) == -1) { |
772 | // s += "/"; | 772 | // s += "/"; |
773 | // } | 773 | // } |
774 | lnk.setFile( s ); | 774 | lnk.setFile( s ); |
775 | } | 775 | } |
776 | lnk.setType( "audio/x-mpegurl" ); | 776 | lnk.setType( "audio/x-mpegurl" ); |
777 | 777 | ||
778 | lnk.writeLink(); | 778 | lnk.writeLink(); |
779 | d->selectedFiles->addToSelection( lnk ); | 779 | d->selectedFiles->addToSelection( lnk ); |
780 | } | 780 | } |
781 | 781 | ||
782 | m3uList->close(); | 782 | m3uList->close(); |
783 | delete m3uList; | 783 | delete m3uList; |
784 | } | 784 | } |
785 | 785 | ||
786 | /* | 786 | /* |
787 | writes current playlist to current m3u file */ | 787 | writes current playlist to current m3u file */ |
788 | void PlayListWidget::writeCurrentM3u() { | 788 | void PlayListWidget::writeCurrentM3u() { |
789 | qDebug("writing to current m3u"); | 789 | qDebug("writing to current m3u"); |
790 | Config cfg( "OpiePlayer" ); | 790 | Config cfg( "OpiePlayer" ); |
791 | cfg.setGroup("PlayList"); | 791 | cfg.setGroup("PlayList"); |
792 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); | 792 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); |
793 | 793 | ||
794 | Om3u *m3uList; | 794 | Om3u *m3uList; |
795 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 795 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
796 | if( d->selectedFiles->first()) { | 796 | if( d->selectedFiles->first()) { |
797 | 797 | ||
798 | do { | 798 | do { |
799 | // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); | 799 | // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); |
800 | m3uList->add( d->selectedFiles->current()->file() ); | 800 | m3uList->add( d->selectedFiles->current()->file() ); |
801 | } | ||
802 | while ( d->selectedFiles->next() ); | ||
803 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | ||
804 | m3uList->write(); | ||
805 | m3uList->close(); | ||
801 | } | 806 | } |
802 | while ( d->selectedFiles->next() ); | ||
803 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | ||
804 | m3uList->write(); | ||
805 | m3uList->close(); | ||
806 | |||
807 | delete m3uList; | 807 | delete m3uList; |
808 | } | ||
809 | 808 | ||
810 | } | 809 | } |
811 | 810 | ||
812 | /* | 811 | /* |
813 | writes current playlist to m3u file */ | 812 | writes current playlist to m3u file */ |
814 | void PlayListWidget::writem3u() { | 813 | void PlayListWidget::writem3u() { |
815 | InputDialog *fileDlg; | 814 | InputDialog *fileDlg; |
816 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 815 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
817 | fileDlg->exec(); | 816 | fileDlg->exec(); |
818 | QString name, filename, list; | 817 | QString name, filename, list; |
819 | Om3u *m3uList; | 818 | Om3u *m3uList; |
820 | 819 | ||
821 | if( fileDlg->result() == 1 ) { | 820 | if( fileDlg->result() == 1 ) { |
822 | name = fileDlg->text(); | 821 | name = fileDlg->text(); |
823 | // qDebug( filename ); | 822 | // qDebug( filename ); |
824 | 823 | ||
825 | if( name.left( 1) != "/" ) { | 824 | if( name.left( 1) != "/" ) { |
826 | filename = QPEApplication::documentDir() + "/" + name; | 825 | filename = QPEApplication::documentDir() + "/" + name; |
827 | } | 826 | } |
828 | 827 | ||
829 | if( name.right( 3 ) != "m3u" ) { | 828 | if( name.right( 3 ) != "m3u" ) { |
830 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; | 829 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; |
831 | } | 830 | } |
832 | 831 | ||
833 | if( d->selectedFiles->first()) { | 832 | if( d->selectedFiles->first()) { |
834 | m3uList = new Om3u(filename, IO_ReadWrite); | 833 | m3uList = new Om3u(filename, IO_ReadWrite); |
835 | 834 | ||
836 | do { | 835 | do { |
837 | m3uList->add( d->selectedFiles->current()->file()); | 836 | m3uList->add( d->selectedFiles->current()->file()); |
838 | } | 837 | } |
839 | while ( d->selectedFiles->next() ); | 838 | while ( d->selectedFiles->next() ); |
840 | // qDebug( list ); | 839 | // qDebug( list ); |
841 | m3uList->write(); | 840 | m3uList->write(); |
842 | m3uList->close(); | 841 | m3uList->close(); |
843 | delete m3uList; | 842 | delete m3uList; |
844 | 843 | ||
845 | delete fileDlg; | 844 | delete fileDlg; |
846 | 845 | ||
847 | DocLnk lnk; | 846 | DocLnk lnk; |
848 | lnk.setFile( filename); | 847 | lnk.setFile( filename); |
849 | lnk.setIcon("opieplayer2/playlist2"); | 848 | lnk.setIcon("opieplayer2/playlist2"); |
850 | lnk.setName( name); //sets file name | 849 | lnk.setName( name); //sets file name |
851 | 850 | ||
852 | // qDebug(filename); | 851 | // qDebug(filename); |
853 | Config config( "OpiePlayer" ); | 852 | Config config( "OpiePlayer" ); |
854 | config.setGroup( "PlayList" ); | 853 | config.setGroup( "PlayList" ); |
855 | 854 | ||
856 | config.writeEntry("CurrentPlaylist",filename); | 855 | config.writeEntry("CurrentPlaylist",filename); |
857 | currentPlayList=filename; | 856 | currentPlayList=filename; |
858 | 857 | ||
859 | if(!lnk.writeLink()) { | 858 | if(!lnk.writeLink()) { |
860 | qDebug("Writing doclink did not work"); | 859 | qDebug("Writing doclink did not work"); |
861 | } | 860 | } |
862 | 861 | ||
863 | setCaption(tr("OpiePlayer: ") + name); | 862 | setCaption(tr("OpiePlayer: ") + name); |
864 | } | 863 | } |
865 | } | 864 | } |
866 | } | 865 | } |
867 | 866 | ||
868 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { | 867 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { |
869 | switch ( e->key() ) { | 868 | switch ( e->key() ) { |
870 | ////////////////////////////// Zaurus keys | 869 | ////////////////////////////// Zaurus keys |
871 | case Key_F9: //activity | 870 | case Key_F9: //activity |
872 | // if(audioUI->isHidden()) | 871 | // if(audioUI->isHidden()) |
873 | // audioUI->showMaximized(); | 872 | // audioUI->showMaximized(); |
874 | break; | 873 | break; |
875 | case Key_F10: //contacts | 874 | case Key_F10: //contacts |
876 | // if( videoUI->isHidden()) | 875 | // if( videoUI->isHidden()) |
877 | // videoUI->showMaximized(); | 876 | // videoUI->showMaximized(); |
878 | break; | 877 | break; |
879 | case Key_F11: //menu | 878 | case Key_F11: //menu |
880 | break; | 879 | break; |
881 | case Key_F12: //home | 880 | case Key_F12: //home |
882 | // doBlank(); | 881 | // doBlank(); |
883 | break; | 882 | break; |
884 | case Key_F13: //mail | 883 | case Key_F13: //mail |
885 | // doUnblank(); | 884 | // doUnblank(); |
886 | break; | 885 | break; |
887 | case Key_Q: //add to playlist | 886 | case Key_Q: //add to playlist |
888 | addSelected(); | 887 | addSelected(); |
889 | break; | 888 | break; |
890 | case Key_R: //remove from playlist | 889 | case Key_R: //remove from playlist |
891 | removeSelected(); | 890 | removeSelected(); |
892 | break; | 891 | break; |
893 | // case Key_P: //play | 892 | // case Key_P: //play |
894 | // qDebug("Play"); | 893 | // qDebug("Play"); |
895 | // playSelected(); | 894 | // playSelected(); |
896 | // break; | 895 | // break; |
897 | case Key_Space: | 896 | case Key_Space: |
898 | // playSelected(); puh | 897 | // playSelected(); puh |
899 | break; | 898 | break; |
900 | case Key_1: | 899 | case Key_1: |
901 | tabWidget->setCurrentPage( 0 ); | 900 | tabWidget->setCurrentPage( 0 ); |
902 | break; | 901 | break; |
903 | case Key_2: | 902 | case Key_2: |
904 | tabWidget->setCurrentPage( 1 ); | 903 | tabWidget->setCurrentPage( 1 ); |
905 | break; | 904 | break; |
906 | case Key_3: | 905 | case Key_3: |
907 | tabWidget->setCurrentPage( 2 ); | 906 | tabWidget->setCurrentPage( 2 ); |
908 | break; | 907 | break; |
909 | case Key_4: | 908 | case Key_4: |
910 | tabWidget->setCurrentPage( 3 ); | 909 | tabWidget->setCurrentPage( 3 ); |
911 | break; | 910 | break; |
912 | case Key_Down: | 911 | case Key_Down: |
913 | if ( !d->selectedFiles->next() ) | 912 | if ( !d->selectedFiles->next() ) |
914 | d->selectedFiles->first(); | 913 | d->selectedFiles->first(); |
915 | break; | 914 | break; |
916 | case Key_Up: | 915 | case Key_Up: |
917 | if ( !d->selectedFiles->prev() ) | 916 | if ( !d->selectedFiles->prev() ) |
918 | // d->selectedFiles->last(); | 917 | // d->selectedFiles->last(); |
919 | break; | 918 | break; |
920 | } | 919 | } |
921 | } | 920 | } |
922 | 921 | ||
923 | void PlayListWidget::pmViewActivated(int index) { | 922 | void PlayListWidget::pmViewActivated(int index) { |
924 | // qDebug("%d", index); | 923 | // qDebug("%d", index); |
925 | switch(index) { | 924 | switch(index) { |
926 | case -16: | 925 | case -16: |
927 | { | 926 | { |
928 | mediaPlayerState.toggleFullscreen(); | 927 | mediaPlayerState.toggleFullscreen(); |
929 | bool b=mediaPlayerState.isFullscreen(); | 928 | bool b=mediaPlayerState.isFullscreen(); |
930 | pmView->setItemChecked( index, b); | 929 | pmView->setItemChecked( index, b); |
931 | Config cfg( "OpiePlayer" ); | 930 | Config cfg( "OpiePlayer" ); |
932 | cfg.writeEntry( "FullScreen", b ); | 931 | cfg.writeEntry( "FullScreen", b ); |
933 | } | 932 | } |
934 | break; | 933 | break; |
935 | }; | 934 | }; |
936 | } | 935 | } |