-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 1fc7dd8..efea385 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -699,769 +699,769 @@ void PlayListWidget::setPlaylist( bool shown ) { | |||
699 | if ( shown ) | 699 | if ( shown ) |
700 | d->playListFrame->show(); | 700 | d->playListFrame->show(); |
701 | else | 701 | else |
702 | d->playListFrame->hide(); | 702 | d->playListFrame->hide(); |
703 | } | 703 | } |
704 | 704 | ||
705 | void PlayListWidget::setView( char view ) { | 705 | void PlayListWidget::setView( char view ) { |
706 | if ( view == 'l' ) | 706 | if ( view == 'l' ) |
707 | showMaximized(); | 707 | showMaximized(); |
708 | else | 708 | else |
709 | hide(); | 709 | hide(); |
710 | } | 710 | } |
711 | 711 | ||
712 | void PlayListWidget::addSelected() { | 712 | void PlayListWidget::addSelected() { |
713 | DocLnk lnk; | 713 | DocLnk lnk; |
714 | QString filename; | 714 | QString filename; |
715 | switch (tabWidget->currentPageIndex()) { | 715 | switch (tabWidget->currentPageIndex()) { |
716 | 716 | ||
717 | case 0: //playlist | 717 | case 0: //playlist |
718 | return; | 718 | return; |
719 | break; | 719 | break; |
720 | case 1: { //audio | 720 | case 1: { //audio |
721 | QListViewItemIterator it( audioView ); | 721 | QListViewItemIterator it( audioView ); |
722 | for ( ; it.current(); ++it ) { | 722 | for ( ; it.current(); ++it ) { |
723 | if ( it.current()->isSelected() ) { | 723 | if ( it.current()->isSelected() ) { |
724 | filename = it.current()->text(3); | 724 | filename = it.current()->text(3); |
725 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 725 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
726 | lnk.setFile( filename ); //sets file name | 726 | lnk.setFile( filename ); //sets file name |
727 | d->selectedFiles->addToSelection( lnk); | 727 | d->selectedFiles->addToSelection( lnk); |
728 | } | 728 | } |
729 | } | 729 | } |
730 | audioView->clearSelection(); | 730 | audioView->clearSelection(); |
731 | // d->selectedFiles->next(); | 731 | // d->selectedFiles->next(); |
732 | } | 732 | } |
733 | break; | 733 | break; |
734 | 734 | ||
735 | case 2: { // video | 735 | case 2: { // video |
736 | QListViewItemIterator it( videoView ); | 736 | QListViewItemIterator it( videoView ); |
737 | for ( ; it.current(); ++it ) { | 737 | for ( ; it.current(); ++it ) { |
738 | if ( it.current()->isSelected() ) { | 738 | if ( it.current()->isSelected() ) { |
739 | 739 | ||
740 | filename = it.current()->text(3); | 740 | filename = it.current()->text(3); |
741 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 741 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
742 | lnk.setFile( filename ); //sets file name | 742 | lnk.setFile( filename ); //sets file name |
743 | d->selectedFiles->addToSelection( lnk); | 743 | d->selectedFiles->addToSelection( lnk); |
744 | } | 744 | } |
745 | } | 745 | } |
746 | videoView->clearSelection(); | 746 | videoView->clearSelection(); |
747 | } | 747 | } |
748 | break; | 748 | break; |
749 | }; | 749 | }; |
750 | // tabWidget->setCurrentPage(0); | 750 | // tabWidget->setCurrentPage(0); |
751 | writeCurrentM3u(); | 751 | writeCurrentM3u(); |
752 | 752 | ||
753 | } | 753 | } |
754 | 754 | ||
755 | void PlayListWidget::removeSelected() { | 755 | void PlayListWidget::removeSelected() { |
756 | d->selectedFiles->removeSelected( ); | 756 | d->selectedFiles->removeSelected( ); |
757 | } | 757 | } |
758 | 758 | ||
759 | void PlayListWidget::playIt( QListViewItem *) { | 759 | void PlayListWidget::playIt( QListViewItem *) { |
760 | // d->setDocumentUsed = FALSE; | 760 | // d->setDocumentUsed = FALSE; |
761 | // mediaPlayerState->curPosition =0; | 761 | // mediaPlayerState->curPosition =0; |
762 | // mediaPlayerState->setPlaying(FALSE); | 762 | // mediaPlayerState->setPlaying(FALSE); |
763 | mediaPlayerState->setPlaying(TRUE); | 763 | mediaPlayerState->setPlaying(TRUE); |
764 | d->selectedFiles->unSelect(); | 764 | d->selectedFiles->unSelect(); |
765 | } | 765 | } |
766 | 766 | ||
767 | void PlayListWidget::addToSelection( QListViewItem *it) { | 767 | void PlayListWidget::addToSelection( QListViewItem *it) { |
768 | d->setDocumentUsed = FALSE; | 768 | d->setDocumentUsed = FALSE; |
769 | 769 | ||
770 | if(it) { | 770 | if(it) { |
771 | switch ( tabWidget->currentPageIndex()) { | 771 | switch ( tabWidget->currentPageIndex()) { |
772 | case 0: //playlist | 772 | case 0: //playlist |
773 | return; | 773 | return; |
774 | break; | 774 | break; |
775 | }; | 775 | }; |
776 | // case 1: { | 776 | // case 1: { |
777 | DocLnk lnk; | 777 | DocLnk lnk; |
778 | QString filename; | 778 | QString filename; |
779 | 779 | ||
780 | filename=it->text(3); | 780 | filename=it->text(3); |
781 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name | 781 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name |
782 | lnk.setFile( filename ); //sets file name | 782 | lnk.setFile( filename ); //sets file name |
783 | d->selectedFiles->addToSelection( lnk); | 783 | d->selectedFiles->addToSelection( lnk); |
784 | 784 | ||
785 | if(tabWidget->currentPageIndex() == 0) | 785 | if(tabWidget->currentPageIndex() == 0) |
786 | writeCurrentM3u(); | 786 | writeCurrentM3u(); |
787 | // tabWidget->setCurrentPage(0); | 787 | // tabWidget->setCurrentPage(0); |
788 | 788 | ||
789 | } | 789 | } |
790 | } | 790 | } |
791 | 791 | ||
792 | void PlayListWidget::tabChanged(QWidget *) { | 792 | void PlayListWidget::tabChanged(QWidget *) { |
793 | 793 | ||
794 | switch ( tabWidget->currentPageIndex()) { | 794 | switch ( tabWidget->currentPageIndex()) { |
795 | case 0: | 795 | case 0: |
796 | { | 796 | { |
797 | if( !tbDeletePlaylist->isHidden()) | 797 | if( !tbDeletePlaylist->isHidden()) |
798 | tbDeletePlaylist->hide(); | 798 | tbDeletePlaylist->hide(); |
799 | d->tbRemoveFromList->setEnabled(TRUE); | 799 | d->tbRemoveFromList->setEnabled(TRUE); |
800 | d->tbAddToList->setEnabled(FALSE); | 800 | d->tbAddToList->setEnabled(FALSE); |
801 | } | 801 | } |
802 | break; | 802 | break; |
803 | case 1: | 803 | case 1: |
804 | { | 804 | { |
805 | audioView->clear(); | 805 | audioView->clear(); |
806 | populateAudioView(); | 806 | populateAudioView(); |
807 | 807 | ||
808 | if( !tbDeletePlaylist->isHidden()) | 808 | if( !tbDeletePlaylist->isHidden()) |
809 | tbDeletePlaylist->hide(); | 809 | tbDeletePlaylist->hide(); |
810 | d->tbRemoveFromList->setEnabled(FALSE); | 810 | d->tbRemoveFromList->setEnabled(FALSE); |
811 | d->tbAddToList->setEnabled(TRUE); | 811 | d->tbAddToList->setEnabled(TRUE); |
812 | } | 812 | } |
813 | break; | 813 | break; |
814 | case 2: | 814 | case 2: |
815 | { | 815 | { |
816 | videoView->clear(); | 816 | videoView->clear(); |
817 | populateVideoView(); | 817 | populateVideoView(); |
818 | if( !tbDeletePlaylist->isHidden()) | 818 | if( !tbDeletePlaylist->isHidden()) |
819 | tbDeletePlaylist->hide(); | 819 | tbDeletePlaylist->hide(); |
820 | d->tbRemoveFromList->setEnabled(FALSE); | 820 | d->tbRemoveFromList->setEnabled(FALSE); |
821 | d->tbAddToList->setEnabled(TRUE); | 821 | d->tbAddToList->setEnabled(TRUE); |
822 | } | 822 | } |
823 | break; | 823 | break; |
824 | case 3: | 824 | case 3: |
825 | { | 825 | { |
826 | if( tbDeletePlaylist->isHidden()) | 826 | if( tbDeletePlaylist->isHidden()) |
827 | tbDeletePlaylist->show(); | 827 | tbDeletePlaylist->show(); |
828 | playLists->reread(); | 828 | playLists->reread(); |
829 | } | 829 | } |
830 | break; | 830 | break; |
831 | }; | 831 | }; |
832 | } | 832 | } |
833 | 833 | ||
834 | void PlayListWidget::btnPlay(bool b) { | 834 | void PlayListWidget::btnPlay(bool b) { |
835 | // mediaPlayerState->setPlaying(b); | 835 | // mediaPlayerState->setPlaying(b); |
836 | switch ( tabWidget->currentPageIndex()) { | 836 | switch ( tabWidget->currentPageIndex()) { |
837 | case 0: | 837 | case 0: |
838 | { | 838 | { |
839 | // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 | 839 | // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 |
840 | // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { | 840 | // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { |
841 | // QMessageBox::message("Note","You are trying to play\na malformed url."); | 841 | // QMessageBox::message("Note","You are trying to play\na malformed url."); |
842 | // } else { | 842 | // } else { |
843 | mediaPlayerState->setPlaying(b); | 843 | mediaPlayerState->setPlaying(b); |
844 | insanityBool=FALSE; | 844 | insanityBool=FALSE; |
845 | qDebug("insanity"); | 845 | qDebug("insanity"); |
846 | // } | 846 | // } |
847 | } | 847 | } |
848 | break; | 848 | break; |
849 | case 1: | 849 | case 1: |
850 | { | 850 | { |
851 | // d->selectedFiles->unSelect(); | 851 | // d->selectedFiles->unSelect(); |
852 | addToSelection( audioView->currentItem() ); | 852 | addToSelection( audioView->currentItem() ); |
853 | mediaPlayerState->setPlaying( b); | 853 | mediaPlayerState->setPlaying( b); |
854 | d->selectedFiles->removeSelected( ); | 854 | d->selectedFiles->removeSelected( ); |
855 | d->selectedFiles->unSelect(); | 855 | d->selectedFiles->unSelect(); |
856 | tabWidget->setCurrentPage(1); | 856 | tabWidget->setCurrentPage(1); |
857 | insanityBool=FALSE; | 857 | insanityBool=FALSE; |
858 | }// audioView->clearSelection(); | 858 | }// audioView->clearSelection(); |
859 | break; | 859 | break; |
860 | case 2: | 860 | case 2: |
861 | { | 861 | { |
862 | 862 | ||
863 | addToSelection( videoView->currentItem() ); | 863 | addToSelection( videoView->currentItem() ); |
864 | mediaPlayerState->setPlaying( b); | 864 | mediaPlayerState->setPlaying( b); |
865 | // qApp->processEvents(); | 865 | // qApp->processEvents(); |
866 | d->selectedFiles->removeSelected( ); | 866 | d->selectedFiles->removeSelected( ); |
867 | d->selectedFiles->unSelect(); | 867 | d->selectedFiles->unSelect(); |
868 | tabWidget->setCurrentPage(2); | 868 | tabWidget->setCurrentPage(2); |
869 | insanityBool=FALSE; | 869 | insanityBool=FALSE; |
870 | }// videoView->clearSelection(); | 870 | }// videoView->clearSelection(); |
871 | break; | 871 | break; |
872 | }; | 872 | }; |
873 | 873 | ||
874 | } | 874 | } |
875 | 875 | ||
876 | void PlayListWidget::deletePlaylist() { | 876 | void PlayListWidget::deletePlaylist() { |
877 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 877 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
878 | (tr("You really want to delete\nthis playlist?")), | 878 | (tr("You really want to delete\nthis playlist?")), |
879 | (tr("Yes")), (tr("No")), 0 )){ | 879 | (tr("Yes")), (tr("No")), 0 )){ |
880 | case 0: // Yes clicked, | 880 | case 0: // Yes clicked, |
881 | QFile().remove(playLists->selectedDocument().file()); | 881 | QFile().remove(playLists->selectedDocument().file()); |
882 | QFile().remove(playLists->selectedDocument().linkFile()); | 882 | QFile().remove(playLists->selectedDocument().linkFile()); |
883 | playLists->reread(); | 883 | playLists->reread(); |
884 | break; | 884 | break; |
885 | case 1: // Cancel | 885 | case 1: // Cancel |
886 | break; | 886 | break; |
887 | }; | 887 | }; |
888 | } | 888 | } |
889 | 889 | ||
890 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int ) | 890 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int ) |
891 | { | 891 | { |
892 | switch (mouse) { | 892 | switch (mouse) { |
893 | case 1: | 893 | case 1: |
894 | break; | 894 | break; |
895 | case 2:{ | 895 | case 2:{ |
896 | 896 | ||
897 | QPopupMenu m; | 897 | QPopupMenu m; |
898 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 898 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
899 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 899 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
900 | m.insertSeparator(); | 900 | m.insertSeparator(); |
901 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) | 901 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) |
902 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 902 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
903 | 903 | ||
904 | m.exec( QCursor::pos() ); | 904 | m.exec( QCursor::pos() ); |
905 | } | 905 | } |
906 | break; | 906 | break; |
907 | }; | 907 | }; |
908 | } | 908 | } |
909 | 909 | ||
910 | void PlayListWidget::playSelected() | 910 | void PlayListWidget::playSelected() |
911 | { | 911 | { |
912 | btnPlay( true); | 912 | btnPlay( true); |
913 | // d->selectedFiles->unSelect(); | 913 | // d->selectedFiles->unSelect(); |
914 | } | 914 | } |
915 | 915 | ||
916 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int) | 916 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int) |
917 | { | 917 | { |
918 | switch (mouse) { | 918 | switch (mouse) { |
919 | case 1: | 919 | case 1: |
920 | 920 | ||
921 | break; | 921 | break; |
922 | case 2:{ | 922 | case 2:{ |
923 | QPopupMenu m; | 923 | QPopupMenu m; |
924 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 924 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
925 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 925 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
926 | // m.insertSeparator(); | 926 | // m.insertSeparator(); |
927 | // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 927 | // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
928 | m.exec( QCursor::pos() ); | 928 | m.exec( QCursor::pos() ); |
929 | } | 929 | } |
930 | break; | 930 | break; |
931 | }; | 931 | }; |
932 | 932 | ||
933 | } | 933 | } |
934 | 934 | ||
935 | void PlayListWidget::listDelete() { | 935 | void PlayListWidget::listDelete() { |
936 | Config cfg( "OpiePlayer" ); | 936 | Config cfg( "OpiePlayer" ); |
937 | cfg.setGroup("PlayList"); | 937 | cfg.setGroup("PlayList"); |
938 | currentPlayList = cfg.readEntry("CurrentPlaylist",""); | 938 | currentPlayList = cfg.readEntry("CurrentPlaylist",""); |
939 | QString file; | 939 | QString file; |
940 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 940 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
941 | switch ( tabWidget->currentPageIndex()) { | 941 | switch ( tabWidget->currentPageIndex()) { |
942 | case 0: | 942 | case 0: |
943 | break; | 943 | break; |
944 | case 1: | 944 | case 1: |
945 | { | 945 | { |
946 | file = audioView->currentItem()->text(0); | 946 | file = audioView->currentItem()->text(0); |
947 | QListIterator<DocLnk> Pdit( files.children() ); | 947 | QListIterator<DocLnk> Pdit( files.children() ); |
948 | for ( ; Pdit.current(); ++Pdit ) { | 948 | for ( ; Pdit.current(); ++Pdit ) { |
949 | if( Pdit.current()->name() == file) { | 949 | if( Pdit.current()->name() == file) { |
950 | LnkProperties prop( Pdit.current() ); | 950 | LnkProperties prop( Pdit.current() ); |
951 | prop.showMaximized(); | 951 | prop.showMaximized(); |
952 | prop.exec(); | 952 | prop.exec(); |
953 | } | 953 | } |
954 | } | 954 | } |
955 | populateAudioView(); | 955 | populateAudioView(); |
956 | } | 956 | } |
957 | break; | 957 | break; |
958 | case 2: | 958 | case 2: |
959 | { | 959 | { |
960 | // file = videoView->selectedItem()->text(0); | 960 | // file = videoView->selectedItem()->text(0); |
961 | // for ( int i = 0; i < noOfFiles; i++ ) { | 961 | // for ( int i = 0; i < noOfFiles; i++ ) { |
962 | // QString entryName; | 962 | // QString entryName; |
963 | // entryName.sprintf( "File%i", i + 1 ); | 963 | // entryName.sprintf( "File%i", i + 1 ); |
964 | // QString linkFile = cfg.readEntry( entryName ); | 964 | // QString linkFile = cfg.readEntry( entryName ); |
965 | // AppLnk lnk( AppLnk(linkFile)); | 965 | // AppLnk lnk( AppLnk(linkFile)); |
966 | // if( lnk.name() == file ) { | 966 | // if( lnk.name() == file ) { |
967 | // LnkProperties prop( &lnk); | 967 | // LnkProperties prop( &lnk); |
968 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 968 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
969 | // prop.showMaximized(); | 969 | // prop.showMaximized(); |
970 | // prop.exec(); | 970 | // prop.exec(); |
971 | // } | 971 | // } |
972 | // } | 972 | // } |
973 | } | 973 | } |
974 | break; | 974 | break; |
975 | }; | 975 | }; |
976 | } | 976 | } |
977 | 977 | ||
978 | void PlayListWidget::scanForAudio() { | 978 | void PlayListWidget::scanForAudio() { |
979 | // qDebug("scan for audio"); | 979 | // qDebug("scan for audio"); |
980 | files.detachChildren(); | 980 | files.detachChildren(); |
981 | QListIterator<DocLnk> sdit( files.children() ); | 981 | QListIterator<DocLnk> sdit( files.children() ); |
982 | for ( ; sdit.current(); ++sdit ) { | 982 | for ( ; sdit.current(); ++sdit ) { |
983 | delete sdit.current(); | 983 | delete sdit.current(); |
984 | } | 984 | } |
985 | Global::findDocuments( &files, audioMimes); | 985 | Global::findDocuments( &files, audioMimes); |
986 | audioScan = true; | 986 | audioScan = true; |
987 | } | 987 | } |
988 | void PlayListWidget::scanForVideo() { | 988 | void PlayListWidget::scanForVideo() { |
989 | // qDebug("scan for video"); | 989 | // qDebug("scan for video"); |
990 | vFiles.detachChildren(); | 990 | vFiles.detachChildren(); |
991 | QListIterator<DocLnk> sdit( vFiles.children() ); | 991 | QListIterator<DocLnk> sdit( vFiles.children() ); |
992 | for ( ; sdit.current(); ++sdit ) { | 992 | for ( ; sdit.current(); ++sdit ) { |
993 | delete sdit.current(); | 993 | delete sdit.current(); |
994 | } | 994 | } |
995 | Global::findDocuments(&vFiles, "video/*"); | 995 | Global::findDocuments(&vFiles, "video/*"); |
996 | videoScan = true; | 996 | videoScan = true; |
997 | } | 997 | } |
998 | 998 | ||
999 | void PlayListWidget::populateAudioView() { | 999 | void PlayListWidget::populateAudioView() { |
1000 | 1000 | ||
1001 | audioView->clear(); | 1001 | audioView->clear(); |
1002 | StorageInfo storageInfo; | 1002 | StorageInfo storageInfo; |
1003 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 1003 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
1004 | if(!audioScan) scanForAudio(); | 1004 | if(!audioScan) scanForAudio(); |
1005 | 1005 | ||
1006 | QListIterator<DocLnk> dit( files.children() ); | 1006 | QListIterator<DocLnk> dit( files.children() ); |
1007 | QListIterator<FileSystem> it ( fs ); | 1007 | QListIterator<FileSystem> it ( fs ); |
1008 | 1008 | ||
1009 | QString storage; | 1009 | QString storage; |
1010 | for ( ; dit.current(); ++dit ) { | 1010 | for ( ; dit.current(); ++dit ) { |
1011 | for( ; it.current(); ++it ){ | 1011 | for( ; it.current(); ++it ){ |
1012 | const QString name = (*it)->name(); | 1012 | const QString name = (*it)->name(); |
1013 | const QString path = (*it)->path(); | 1013 | const QString path = (*it)->path(); |
1014 | if(dit.current()->file().find(path) != -1 ) storage=name; | 1014 | if(dit.current()->file().find(path) != -1 ) storage=name; |
1015 | } | 1015 | } |
1016 | 1016 | ||
1017 | QListViewItem * newItem; | 1017 | QListViewItem * newItem; |
1018 | if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { | 1018 | if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { |
1019 | long size; | 1019 | long size; |
1020 | if( dit.current()->file().left(4) == "http" ) | 1020 | if( dit.current()->file().left(4) == "http" ) |
1021 | size=0; | 1021 | size=0; |
1022 | else | 1022 | else |
1023 | size = QFile( dit.current()->file() ).size(); | 1023 | size = QFile( dit.current()->file() ).size(); |
1024 | // qDebug(dit.current()->name()); | 1024 | // qDebug(dit.current()->name()); |
1025 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 1025 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
1026 | QString::number(size ), storage, dit.current()->file()); | 1026 | QString::number(size ), storage, dit.current()->file()); |
1027 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); | 1027 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); |
1028 | } | 1028 | } |
1029 | } | 1029 | } |
1030 | 1030 | ||
1031 | } | 1031 | } |
1032 | 1032 | ||
1033 | void PlayListWidget::populateVideoView() { | 1033 | void PlayListWidget::populateVideoView() { |
1034 | videoView->clear(); | 1034 | videoView->clear(); |
1035 | StorageInfo storageInfo; | 1035 | StorageInfo storageInfo; |
1036 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 1036 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
1037 | 1037 | ||
1038 | if(!videoScan ) scanForVideo(); | 1038 | if(!videoScan ) scanForVideo(); |
1039 | 1039 | ||
1040 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 1040 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
1041 | QListIterator<FileSystem> it ( fs ); | 1041 | QListIterator<FileSystem> it ( fs ); |
1042 | videoView->clear(); | 1042 | videoView->clear(); |
1043 | QString storage; | 1043 | QString storage; |
1044 | for ( ; Vdit.current(); ++Vdit ) { | 1044 | for ( ; Vdit.current(); ++Vdit ) { |
1045 | for( ; it.current(); ++it ){ | 1045 | for( ; it.current(); ++it ){ |
1046 | const QString name = (*it)->name(); | 1046 | const QString name = (*it)->name(); |
1047 | const QString path = (*it)->path(); | 1047 | const QString path = (*it)->path(); |
1048 | if( Vdit.current()->file().find(path) != -1 ) storage=name; | 1048 | if( Vdit.current()->file().find(path) != -1 ) storage=name; |
1049 | } | 1049 | } |
1050 | 1050 | ||
1051 | QListViewItem * newItem; | 1051 | QListViewItem * newItem; |
1052 | if ( QFile( Vdit.current()->file()).exists() ) { | 1052 | if ( QFile( Vdit.current()->file()).exists() ) { |
1053 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 1053 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
1054 | QString::number( QFile( Vdit.current()->file() ).size() ), | 1054 | QString::number( QFile( Vdit.current()->file() ).size() ), |
1055 | storage, Vdit.current()->file()); | 1055 | storage, Vdit.current()->file()); |
1056 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); | 1056 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); |
1057 | } | 1057 | } |
1058 | } | 1058 | } |
1059 | } | 1059 | } |
1060 | 1060 | ||
1061 | void PlayListWidget::openFile() { | 1061 | void PlayListWidget::openFile() { |
1062 | QString filename, name; | 1062 | QString filename, name; |
1063 | InputDialog *fileDlg; | 1063 | InputDialog *fileDlg; |
1064 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 1064 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
1065 | fileDlg->exec(); | 1065 | fileDlg->exec(); |
1066 | if( fileDlg->result() == 1 ) { | 1066 | if( fileDlg->result() == 1 ) { |
1067 | filename = fileDlg->text(); | 1067 | filename = fileDlg->text(); |
1068 | // qDebug( "Selected filename is " + filename ); | 1068 | // qDebug( "Selected filename is " + filename ); |
1069 | DocLnk lnk; | 1069 | DocLnk lnk; |
1070 | Config cfg( "OpiePlayer" ); | 1070 | Config cfg( "OpiePlayer" ); |
1071 | cfg.setGroup("PlayList"); | 1071 | cfg.setGroup("PlayList"); |
1072 | 1072 | ||
1073 | QString m3uFile; | 1073 | QString m3uFile; |
1074 | m3uFile = filename; | 1074 | m3uFile = filename; |
1075 | if(filename.left(4) == "http") { | 1075 | if(filename.left(4) == "http") { |
1076 | if(filename.find(":",8,TRUE) != -1) { //found a port | 1076 | if(filename.find(":",8,TRUE) != -1) { //found a port |
1077 | 1077 | ||
1078 | m3uFile = filename; | 1078 | m3uFile = filename; |
1079 | if( m3uFile.right( 1 ).find( '/' ) == -1) { | 1079 | if( m3uFile.right( 1 ).find( '/' ) == -1) { |
1080 | m3uFile += "/"; | 1080 | m3uFile += "/"; |
1081 | } | 1081 | } |
1082 | filename = m3uFile; | 1082 | filename = m3uFile; |
1083 | = } | 1083 | } |
1084 | lnk.setName( m3uFile ); //sets name | 1084 | lnk.setName( m3uFile ); //sets name |
1085 | lnk.setFile( filename ); //sets file name | 1085 | lnk.setFile( filename ); //sets file name |
1086 | lnk.setIcon("opieplayer2/musicfile"); | 1086 | lnk.setIcon("opieplayer2/musicfile"); |
1087 | d->selectedFiles->addToSelection( lnk ); | 1087 | d->selectedFiles->addToSelection( lnk ); |
1088 | writeCurrentM3u(); | 1088 | writeCurrentM3u(); |
1089 | } | 1089 | } |
1090 | else if( filename.right( 3) == "m3u" ) { | 1090 | else if( filename.right( 3) == "m3u" ) { |
1091 | readm3u( filename ); | 1091 | readm3u( filename ); |
1092 | 1092 | ||
1093 | } else if( filename.right(3) == "pls" ) { | 1093 | } else if( filename.right(3) == "pls" ) { |
1094 | readPls( filename ); | 1094 | readPls( filename ); |
1095 | } else { | 1095 | } else { |
1096 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name | 1096 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name |
1097 | lnk.setFile( filename ); //sets file name | 1097 | lnk.setFile( filename ); //sets file name |
1098 | d->selectedFiles->addToSelection( lnk); | 1098 | d->selectedFiles->addToSelection( lnk); |
1099 | lnk.removeLinkFile(); | 1099 | lnk.removeLinkFile(); |
1100 | writeCurrentM3u(); | 1100 | writeCurrentM3u(); |
1101 | } | 1101 | } |
1102 | } | 1102 | } |
1103 | 1103 | ||
1104 | if( fileDlg ) { | 1104 | if( fileDlg ) { |
1105 | delete fileDlg; | 1105 | delete fileDlg; |
1106 | } | 1106 | } |
1107 | } | 1107 | } |
1108 | 1108 | ||
1109 | 1109 | ||
1110 | /* | 1110 | /* |
1111 | reads m3u and shows files/urls to playlist widget */ | 1111 | reads m3u and shows files/urls to playlist widget */ |
1112 | void PlayListWidget::readm3u( const QString &filename ) { | 1112 | void PlayListWidget::readm3u( const QString &filename ) { |
1113 | // qDebug( "read m3u filename " + filename ); | 1113 | // qDebug( "read m3u filename " + filename ); |
1114 | 1114 | ||
1115 | Om3u *m3uList; | 1115 | Om3u *m3uList; |
1116 | QString s, name; | 1116 | QString s, name; |
1117 | m3uList = new Om3u( filename, IO_ReadOnly ); | 1117 | m3uList = new Om3u( filename, IO_ReadOnly ); |
1118 | m3uList->readM3u(); | 1118 | m3uList->readM3u(); |
1119 | DocLnk lnk; | 1119 | DocLnk lnk; |
1120 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 1120 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
1121 | s = *it; | 1121 | s = *it; |
1122 | // qDebug("reading "+ s); | 1122 | // qDebug("reading "+ s); |
1123 | if(s.left(4)=="http") { | 1123 | if(s.left(4)=="http") { |
1124 | lnk.setName( s ); //sets file name | 1124 | lnk.setName( s ); //sets file name |
1125 | lnk.setIcon("opieplayer2/musicfile"); | 1125 | lnk.setIcon("opieplayer2/musicfile"); |
1126 | 1126 | ||
1127 | // if(s.right(4) != '.' || s.right(5) != '.') | 1127 | // if(s.right(4) != '.' || s.right(5) != '.') |
1128 | if(s.right(4) != '.' || s.right(5) != '.' ) | 1128 | if(s.right(4) != '.' || s.right(5) != '.' ) |
1129 | if( s.right(1) != "/") | 1129 | if( s.right(1) != "/") |
1130 | lnk.setFile( s+"/"); //if url with no extension | 1130 | lnk.setFile( s+"/"); //if url with no extension |
1131 | else | 1131 | else |
1132 | lnk.setFile( s ); //sets file name | 1132 | lnk.setFile( s ); //sets file name |
1133 | 1133 | ||
1134 | } else { | 1134 | } else { |
1135 | // if( QFileInfo( s ).exists() ) { | 1135 | // if( QFileInfo( s ).exists() ) { |
1136 | lnk.setName( fullBaseName ( QFileInfo(s))); | 1136 | lnk.setName( fullBaseName ( QFileInfo(s))); |
1137 | // if(s.right(4) == '.') {//if regular file | 1137 | // if(s.right(4) == '.') {//if regular file |
1138 | if(s.left(1) != "/") { | 1138 | if(s.left(1) != "/") { |
1139 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); | 1139 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); |
1140 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 1140 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
1141 | lnk.setIcon("SoundPlayer"); | 1141 | lnk.setIcon("SoundPlayer"); |
1142 | } else { | 1142 | } else { |
1143 | // qDebug("set link2 "+s); | 1143 | // qDebug("set link2 "+s); |
1144 | lnk.setFile( s); | 1144 | lnk.setFile( s); |
1145 | lnk.setIcon("SoundPlayer"); | 1145 | lnk.setIcon("SoundPlayer"); |
1146 | } | 1146 | } |
1147 | } | 1147 | } |
1148 | d->selectedFiles->addToSelection( lnk ); | 1148 | d->selectedFiles->addToSelection( lnk ); |
1149 | } | 1149 | } |
1150 | Config config( "OpiePlayer" ); | 1150 | Config config( "OpiePlayer" ); |
1151 | config.setGroup( "PlayList" ); | 1151 | config.setGroup( "PlayList" ); |
1152 | 1152 | ||
1153 | config.writeEntry("CurrentPlaylist",filename); | 1153 | config.writeEntry("CurrentPlaylist",filename); |
1154 | config.write(); | 1154 | config.write(); |
1155 | currentPlayList=filename; | 1155 | currentPlayList=filename; |
1156 | 1156 | ||
1157 | // m3uList->write(); | 1157 | // m3uList->write(); |
1158 | m3uList->close(); | 1158 | m3uList->close(); |
1159 | if(m3uList) delete m3uList; | 1159 | if(m3uList) delete m3uList; |
1160 | 1160 | ||
1161 | d->selectedFiles->setSelectedItem( s); | 1161 | d->selectedFiles->setSelectedItem( s); |
1162 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(filename))); | 1162 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(filename))); |
1163 | 1163 | ||
1164 | } | 1164 | } |
1165 | 1165 | ||
1166 | /* | 1166 | /* |
1167 | reads pls and adds files/urls to playlist */ | 1167 | reads pls and adds files/urls to playlist */ |
1168 | void PlayListWidget::readPls( const QString &filename ) { | 1168 | void PlayListWidget::readPls( const QString &filename ) { |
1169 | 1169 | ||
1170 | // qDebug( "pls filename is " + filename ); | 1170 | // qDebug( "pls filename is " + filename ); |
1171 | Om3u *m3uList; | 1171 | Om3u *m3uList; |
1172 | QString s, name; | 1172 | QString s, name; |
1173 | m3uList = new Om3u( filename, IO_ReadOnly ); | 1173 | m3uList = new Om3u( filename, IO_ReadOnly ); |
1174 | m3uList->readPls(); | 1174 | m3uList->readPls(); |
1175 | 1175 | ||
1176 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 1176 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
1177 | s = *it; | 1177 | s = *it; |
1178 | // s.replace( QRegExp( "%20" )," " ); | 1178 | // s.replace( QRegExp( "%20" )," " ); |
1179 | DocLnk lnk( s ); | 1179 | DocLnk lnk( s ); |
1180 | QFileInfo f( s ); | 1180 | QFileInfo f( s ); |
1181 | QString name = fullBaseName ( f); | 1181 | QString name = fullBaseName ( f); |
1182 | 1182 | ||
1183 | if( name.left( 4 ) == "http" ) { | 1183 | if( name.left( 4 ) == "http" ) { |
1184 | name = s.right( s.length() - 7); | 1184 | name = s.right( s.length() - 7); |
1185 | } else { | 1185 | } else { |
1186 | name = s; | 1186 | name = s; |
1187 | } | 1187 | } |
1188 | 1188 | ||
1189 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 1189 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
1190 | 1190 | ||
1191 | lnk.setName( name ); | 1191 | lnk.setName( name ); |
1192 | if( s.at( s.length() - 4) == '.') {// if this is probably a file | 1192 | if( s.at( s.length() - 4) == '.') {// if this is probably a file |
1193 | lnk.setFile( s ); | 1193 | lnk.setFile( s ); |
1194 | } else { //if its a url | 1194 | } else { //if its a url |
1195 | if( name.right( 1 ).find( '/' ) == -1) { | 1195 | if( name.right( 1 ).find( '/' ) == -1) { |
1196 | s += "/"; | 1196 | s += "/"; |
1197 | } | 1197 | } |
1198 | lnk.setFile( s ); | 1198 | lnk.setFile( s ); |
1199 | } | 1199 | } |
1200 | lnk.setType( "audio/x-mpegurl" ); | 1200 | lnk.setType( "audio/x-mpegurl" ); |
1201 | 1201 | ||
1202 | lnk.writeLink(); | 1202 | lnk.writeLink(); |
1203 | d->selectedFiles->addToSelection( lnk ); | 1203 | d->selectedFiles->addToSelection( lnk ); |
1204 | } | 1204 | } |
1205 | 1205 | ||
1206 | m3uList->close(); | 1206 | m3uList->close(); |
1207 | if(m3uList) delete m3uList; | 1207 | if(m3uList) delete m3uList; |
1208 | } | 1208 | } |
1209 | 1209 | ||
1210 | /* | 1210 | /* |
1211 | writes current playlist to current m3u file */ | 1211 | writes current playlist to current m3u file */ |
1212 | void PlayListWidget::writeCurrentM3u() { | 1212 | void PlayListWidget::writeCurrentM3u() { |
1213 | // qDebug("writing to current m3u"); | 1213 | // qDebug("writing to current m3u"); |
1214 | Config cfg( "OpiePlayer" ); | 1214 | Config cfg( "OpiePlayer" ); |
1215 | cfg.setGroup("PlayList"); | 1215 | cfg.setGroup("PlayList"); |
1216 | currentPlayList = cfg.readEntry("CurrentPlaylist",""); | 1216 | currentPlayList = cfg.readEntry("CurrentPlaylist",""); |
1217 | Om3u *m3uList; | 1217 | Om3u *m3uList; |
1218 | m3uList = new Om3u( currentPlayList, IO_ReadWrite | IO_Truncate ); | 1218 | m3uList = new Om3u( currentPlayList, IO_ReadWrite | IO_Truncate ); |
1219 | 1219 | ||
1220 | if( d->selectedFiles->first()) { | 1220 | if( d->selectedFiles->first()) { |
1221 | do { | 1221 | do { |
1222 | // qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); | 1222 | // qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); |
1223 | m3uList->add( d->selectedFiles->current()->file() ); | 1223 | m3uList->add( d->selectedFiles->current()->file() ); |
1224 | } | 1224 | } |
1225 | while ( d->selectedFiles->next() ); | 1225 | while ( d->selectedFiles->next() ); |
1226 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | 1226 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); |
1227 | m3uList->write(); | 1227 | m3uList->write(); |
1228 | m3uList->close(); | 1228 | m3uList->close(); |
1229 | 1229 | ||
1230 | if(m3uList) delete m3uList; | 1230 | if(m3uList) delete m3uList; |
1231 | } | 1231 | } |
1232 | } | 1232 | } |
1233 | 1233 | ||
1234 | /* | 1234 | /* |
1235 | writes current playlist to m3u file */ | 1235 | writes current playlist to m3u file */ |
1236 | void PlayListWidget::writem3u() { | 1236 | void PlayListWidget::writem3u() { |
1237 | InputDialog *fileDlg; | 1237 | InputDialog *fileDlg; |
1238 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 1238 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
1239 | fileDlg->exec(); | 1239 | fileDlg->exec(); |
1240 | QString name, filename, list; | 1240 | QString name, filename, list; |
1241 | Om3u *m3uList; | 1241 | Om3u *m3uList; |
1242 | 1242 | ||
1243 | if( fileDlg->result() == 1 ) { | 1243 | if( fileDlg->result() == 1 ) { |
1244 | name = fileDlg->text(); | 1244 | name = fileDlg->text(); |
1245 | // qDebug( filename ); | 1245 | // qDebug( filename ); |
1246 | if( name.find("/",0,true) != -1) {// assume they specify a file path | 1246 | if( name.find("/",0,true) != -1) {// assume they specify a file path |
1247 | filename = name; | 1247 | filename = name; |
1248 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); | 1248 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); |
1249 | } | 1249 | } |
1250 | else //otherwise dump it somewhere noticable | 1250 | else //otherwise dump it somewhere noticable |
1251 | filename = QPEApplication::documentDir() + "/" + name; | 1251 | filename = QPEApplication::documentDir() + "/" + name; |
1252 | 1252 | ||
1253 | if( filename.right( 3 ) != "m3u" ) //needs filename extension | 1253 | if( filename.right( 3 ) != "m3u" ) //needs filename extension |
1254 | filename += ".m3u"; | 1254 | filename += ".m3u"; |
1255 | 1255 | ||
1256 | if( d->selectedFiles->first()) { | 1256 | if( d->selectedFiles->first()) { |
1257 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); | 1257 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); |
1258 | 1258 | ||
1259 | do { | 1259 | do { |
1260 | m3uList->add( d->selectedFiles->current()->file()); | 1260 | m3uList->add( d->selectedFiles->current()->file()); |
1261 | } | 1261 | } |
1262 | while ( d->selectedFiles->next() ); | 1262 | while ( d->selectedFiles->next() ); |
1263 | // qDebug( list ); | 1263 | // qDebug( list ); |
1264 | m3uList->write(); | 1264 | m3uList->write(); |
1265 | m3uList->close(); | 1265 | m3uList->close(); |
1266 | if(m3uList) delete m3uList; | 1266 | if(m3uList) delete m3uList; |
1267 | 1267 | ||
1268 | if(fileDlg) delete fileDlg; | 1268 | if(fileDlg) delete fileDlg; |
1269 | 1269 | ||
1270 | DocLnk lnk; | 1270 | DocLnk lnk; |
1271 | lnk.setFile( filename); | 1271 | lnk.setFile( filename); |
1272 | lnk.setIcon("opieplayer2/playlist2"); | 1272 | lnk.setIcon("opieplayer2/playlist2"); |
1273 | lnk.setName( name); //sets file name | 1273 | lnk.setName( name); //sets file name |
1274 | 1274 | ||
1275 | // qDebug(filename); | 1275 | // qDebug(filename); |
1276 | Config config( "OpiePlayer" ); | 1276 | Config config( "OpiePlayer" ); |
1277 | config.setGroup( "PlayList" ); | 1277 | config.setGroup( "PlayList" ); |
1278 | 1278 | ||
1279 | config.writeEntry("CurrentPlaylist",filename); | 1279 | config.writeEntry("CurrentPlaylist",filename); |
1280 | currentPlayList=filename; | 1280 | currentPlayList=filename; |
1281 | 1281 | ||
1282 | if(!lnk.writeLink()) { | 1282 | if(!lnk.writeLink()) { |
1283 | // qDebug("Writing doclink did not work"); | 1283 | // qDebug("Writing doclink did not work"); |
1284 | } | 1284 | } |
1285 | 1285 | ||
1286 | setCaption(tr("OpiePlayer: ") + name); | 1286 | setCaption(tr("OpiePlayer: ") + name); |
1287 | } | 1287 | } |
1288 | } | 1288 | } |
1289 | } | 1289 | } |
1290 | 1290 | ||
1291 | 1291 | ||
1292 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) | 1292 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) |
1293 | { | 1293 | { |
1294 | switch ( e->key() ) { | 1294 | switch ( e->key() ) { |
1295 | ////////////////////////////// Zaurus keys | 1295 | ////////////////////////////// Zaurus keys |
1296 | case Key_F9: //activity | 1296 | case Key_F9: //activity |
1297 | // if(audioUI->isHidden()) | 1297 | // if(audioUI->isHidden()) |
1298 | // audioUI->showMaximized(); | 1298 | // audioUI->showMaximized(); |
1299 | break; | 1299 | break; |
1300 | case Key_F10: //contacts | 1300 | case Key_F10: //contacts |
1301 | // if( videoUI->isHidden()) | 1301 | // if( videoUI->isHidden()) |
1302 | // videoUI->showMaximized(); | 1302 | // videoUI->showMaximized(); |
1303 | break; | 1303 | break; |
1304 | case Key_F11: //menu | 1304 | case Key_F11: //menu |
1305 | break; | 1305 | break; |
1306 | case Key_F12: //home | 1306 | case Key_F12: //home |
1307 | // doBlank(); | 1307 | // doBlank(); |
1308 | break; | 1308 | break; |
1309 | case Key_F13: //mail | 1309 | case Key_F13: //mail |
1310 | // doUnblank(); | 1310 | // doUnblank(); |
1311 | break; | 1311 | break; |
1312 | case Key_Q: //add to playlist | 1312 | case Key_Q: //add to playlist |
1313 | addSelected(); | 1313 | addSelected(); |
1314 | break; | 1314 | break; |
1315 | case Key_R: //remove from playlist | 1315 | case Key_R: //remove from playlist |
1316 | removeSelected(); | 1316 | removeSelected(); |
1317 | break; | 1317 | break; |
1318 | // case Key_P: //play | 1318 | // case Key_P: //play |
1319 | // qDebug("Play"); | 1319 | // qDebug("Play"); |
1320 | // playSelected(); | 1320 | // playSelected(); |
1321 | // break; | 1321 | // break; |
1322 | case Key_Space: | 1322 | case Key_Space: |
1323 | // playSelected(); puh | 1323 | // playSelected(); puh |
1324 | break; | 1324 | break; |
1325 | case Key_1: | 1325 | case Key_1: |
1326 | tabWidget->setCurrentPage(0); | 1326 | tabWidget->setCurrentPage(0); |
1327 | break; | 1327 | break; |
1328 | case Key_2: | 1328 | case Key_2: |
1329 | tabWidget->setCurrentPage(1); | 1329 | tabWidget->setCurrentPage(1); |
1330 | break; | 1330 | break; |
1331 | case Key_3: | 1331 | case Key_3: |
1332 | tabWidget->setCurrentPage(2); | 1332 | tabWidget->setCurrentPage(2); |
1333 | break; | 1333 | break; |
1334 | case Key_4: | 1334 | case Key_4: |
1335 | tabWidget->setCurrentPage(3); | 1335 | tabWidget->setCurrentPage(3); |
1336 | break; | 1336 | break; |
1337 | case Key_Down: | 1337 | case Key_Down: |
1338 | if ( !d->selectedFiles->next() ) | 1338 | if ( !d->selectedFiles->next() ) |
1339 | d->selectedFiles->first(); | 1339 | d->selectedFiles->first(); |
1340 | 1340 | ||
1341 | break; | 1341 | break; |
1342 | case Key_Up: | 1342 | case Key_Up: |
1343 | if ( !d->selectedFiles->prev() ) | 1343 | if ( !d->selectedFiles->prev() ) |
1344 | // d->selectedFiles->last(); | 1344 | // d->selectedFiles->last(); |
1345 | 1345 | ||
1346 | break; | 1346 | break; |
1347 | 1347 | ||
1348 | } | 1348 | } |
1349 | } | 1349 | } |
1350 | 1350 | ||
1351 | void PlayListWidget::keyPressEvent( QKeyEvent *) | 1351 | void PlayListWidget::keyPressEvent( QKeyEvent *) |
1352 | { | 1352 | { |
1353 | // qDebug("Key press"); | 1353 | // qDebug("Key press"); |
1354 | // switch ( e->key() ) { | 1354 | // switch ( e->key() ) { |
1355 | // ////////////////////////////// Zaurus keys | 1355 | // ////////////////////////////// Zaurus keys |
1356 | // case Key_A: //add to playlist | 1356 | // case Key_A: //add to playlist |
1357 | // qDebug("Add"); | 1357 | // qDebug("Add"); |
1358 | // addSelected(); | 1358 | // addSelected(); |
1359 | // break; | 1359 | // break; |
1360 | // case Key_R: //remove from playlist | 1360 | // case Key_R: //remove from playlist |
1361 | // removeSelected(); | 1361 | // removeSelected(); |
1362 | // break; | 1362 | // break; |
1363 | // case Key_P: //play | 1363 | // case Key_P: //play |
1364 | // qDebug("Play"); | 1364 | // qDebug("Play"); |
1365 | // playSelected(); | 1365 | // playSelected(); |
1366 | // break; | 1366 | // break; |
1367 | // case Key_Space: | 1367 | // case Key_Space: |
1368 | // qDebug("Play"); | 1368 | // qDebug("Play"); |
1369 | // playSelected(); | 1369 | // playSelected(); |
1370 | // break; | 1370 | // break; |
1371 | // } | 1371 | // } |
1372 | } | 1372 | } |
1373 | 1373 | ||
1374 | void PlayListWidget::doBlank() { | 1374 | void PlayListWidget::doBlank() { |
1375 | // qDebug("do blanking"); | 1375 | // qDebug("do blanking"); |
1376 | fd=open("/dev/fb0",O_RDWR); | 1376 | fd=open("/dev/fb0",O_RDWR); |
1377 | if (fd != -1) { | 1377 | if (fd != -1) { |
1378 | ioctl(fd,FBIOBLANK,1); | 1378 | ioctl(fd,FBIOBLANK,1); |
1379 | // close(fd); | 1379 | // close(fd); |
1380 | } | 1380 | } |
1381 | } | 1381 | } |
1382 | 1382 | ||
1383 | void PlayListWidget::doUnblank() { | 1383 | void PlayListWidget::doUnblank() { |
1384 | // this crashes opieplayer with a segfault | 1384 | // this crashes opieplayer with a segfault |
1385 | // int fd; | 1385 | // int fd; |
1386 | // fd=open("/dev/fb0",O_RDWR); | 1386 | // fd=open("/dev/fb0",O_RDWR); |
1387 | // qDebug("do unblanking"); | 1387 | // qDebug("do unblanking"); |
1388 | if (fd != -1) { | 1388 | if (fd != -1) { |
1389 | ioctl(fd,FBIOBLANK,0); | 1389 | ioctl(fd,FBIOBLANK,0); |
1390 | close(fd); | 1390 | close(fd); |
1391 | } | 1391 | } |
1392 | QCopEnvelope h("QPE/System", "setBacklight(int)"); | 1392 | QCopEnvelope h("QPE/System", "setBacklight(int)"); |
1393 | h <<-3;// v[1]; // -3 Force on | 1393 | h <<-3;// v[1]; // -3 Force on |
1394 | } | 1394 | } |
1395 | 1395 | ||
1396 | void PlayListWidget::populateSkinsMenu() { | 1396 | void PlayListWidget::populateSkinsMenu() { |
1397 | int item = 0; | 1397 | int item = 0; |
1398 | defaultSkinIndex = 0; | 1398 | defaultSkinIndex = 0; |
1399 | QString skinName; | 1399 | QString skinName; |
1400 | Config cfg( "OpiePlayer" ); | 1400 | Config cfg( "OpiePlayer" ); |
1401 | cfg.setGroup("Options" ); | 1401 | cfg.setGroup("Options" ); |
1402 | QString skin = cfg.readEntry( "Skin", "default" ); | 1402 | QString skin = cfg.readEntry( "Skin", "default" ); |
1403 | 1403 | ||
1404 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); | 1404 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); |
1405 | skinsDir.setFilter( QDir::Dirs ); | 1405 | skinsDir.setFilter( QDir::Dirs ); |
1406 | skinsDir.setSorting(QDir::Name ); | 1406 | skinsDir.setSorting(QDir::Name ); |
1407 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); | 1407 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); |
1408 | QFileInfoListIterator it( *skinslist ); | 1408 | QFileInfoListIterator it( *skinslist ); |
1409 | QFileInfo *fi; | 1409 | QFileInfo *fi; |
1410 | while ( ( fi = it.current() ) ) { | 1410 | while ( ( fi = it.current() ) ) { |
1411 | skinName = fi->fileName(); | 1411 | skinName = fi->fileName(); |
1412 | // qDebug( fi->fileName() ); | 1412 | // qDebug( fi->fileName() ); |
1413 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { | 1413 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { |
1414 | item = skinsMenu->insertItem( fi->fileName() ) ; | 1414 | item = skinsMenu->insertItem( fi->fileName() ) ; |
1415 | } | 1415 | } |
1416 | if( skinName == "default" ) { | 1416 | if( skinName == "default" ) { |
1417 | defaultSkinIndex = item; | 1417 | defaultSkinIndex = item; |
1418 | } | 1418 | } |
1419 | if( skinName == skin ) { | 1419 | if( skinName == skin ) { |
1420 | skinsMenu->setItemChecked( item, TRUE ); | 1420 | skinsMenu->setItemChecked( item, TRUE ); |
1421 | } | 1421 | } |
1422 | ++it; | 1422 | ++it; |
1423 | } | 1423 | } |
1424 | } | 1424 | } |
1425 | 1425 | ||
1426 | void PlayListWidget::skinsMenuActivated( int item ) { | 1426 | void PlayListWidget::skinsMenuActivated( int item ) { |
1427 | for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { | 1427 | for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { |
1428 | skinsMenu->setItemChecked( i, FALSE ); | 1428 | skinsMenu->setItemChecked( i, FALSE ); |
1429 | } | 1429 | } |
1430 | skinsMenu->setItemChecked( item, TRUE ); | 1430 | skinsMenu->setItemChecked( item, TRUE ); |
1431 | 1431 | ||
1432 | Config cfg( "OpiePlayer" ); | 1432 | Config cfg( "OpiePlayer" ); |
1433 | cfg.setGroup("Options"); | 1433 | cfg.setGroup("Options"); |
1434 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); | 1434 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); |
1435 | } | 1435 | } |
1436 | 1436 | ||
1437 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { | 1437 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { |
1438 | // qDebug("qcop message "+msg ); | 1438 | // qDebug("qcop message "+msg ); |
1439 | QDataStream stream ( data, IO_ReadOnly ); | 1439 | QDataStream stream ( data, IO_ReadOnly ); |
1440 | if ( msg == "play()" ) { //plays current selection | 1440 | if ( msg == "play()" ) { //plays current selection |
1441 | btnPlay( true); | 1441 | btnPlay( true); |
1442 | } else if ( msg == "stop()" ) { | 1442 | } else if ( msg == "stop()" ) { |
1443 | mediaPlayerState->setPlaying( false); | 1443 | mediaPlayerState->setPlaying( false); |
1444 | } else if ( msg == "togglePause()" ) { | 1444 | } else if ( msg == "togglePause()" ) { |
1445 | mediaPlayerState->togglePaused(); | 1445 | mediaPlayerState->togglePaused(); |
1446 | } else if ( msg == "next()" ) { //select next in lis | 1446 | } else if ( msg == "next()" ) { //select next in lis |
1447 | mediaPlayerState->setNext(); | 1447 | mediaPlayerState->setNext(); |
1448 | } else if ( msg == "prev()" ) { //select previous in list | 1448 | } else if ( msg == "prev()" ) { //select previous in list |
1449 | mediaPlayerState->setPrev(); | 1449 | mediaPlayerState->setPrev(); |
1450 | } else if ( msg == "toggleLooping()" ) { //loop or not loop | 1450 | } else if ( msg == "toggleLooping()" ) { //loop or not loop |
1451 | mediaPlayerState->toggleLooping(); | 1451 | mediaPlayerState->toggleLooping(); |
1452 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled | 1452 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled |
1453 | mediaPlayerState->toggleShuffled(); | 1453 | mediaPlayerState->toggleShuffled(); |
1454 | } else if ( msg == "volUp()" ) { //volume more | 1454 | } else if ( msg == "volUp()" ) { //volume more |
1455 | // emit moreClicked(); | 1455 | // emit moreClicked(); |
1456 | // emit moreReleased(); | 1456 | // emit moreReleased(); |
1457 | } else if ( msg == "volDown()" ) { //volume less | 1457 | } else if ( msg == "volDown()" ) { //volume less |
1458 | // emit lessClicked(); | 1458 | // emit lessClicked(); |
1459 | // emit lessReleased(); | 1459 | // emit lessReleased(); |
1460 | } else if ( msg == "play(QString)" ) { //play this now | 1460 | } else if ( msg == "play(QString)" ) { //play this now |
1461 | QString file; | 1461 | QString file; |
1462 | stream >> file; | 1462 | stream >> file; |
1463 | setDocumentEx( (const QString &) file); | 1463 | setDocumentEx( (const QString &) file); |
1464 | } else if ( msg == "add(QString)" ) { //add to playlist | 1464 | } else if ( msg == "add(QString)" ) { //add to playlist |
1465 | QString file; | 1465 | QString file; |
1466 | stream >> file; | 1466 | stream >> file; |
1467 | QFileInfo fileInfo(file); | 1467 | QFileInfo fileInfo(file); |