author | llornkcor <llornkcor> | 2005-01-08 19:56:24 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2005-01-08 19:56:24 (UTC) |
commit | 60a617583d0ccc793d9ea4465998d90ec208db58 (patch) (unidiff) | |
tree | 58b125c9526c9dff30efbfa427c92c49f2995aee | |
parent | 955213d274c2f0c11d0f153e2fed5df5170e50f6 (diff) | |
download | opie-60a617583d0ccc793d9ea4465998d90ec208db58.zip opie-60a617583d0ccc793d9ea4465998d90ec208db58.tar.gz opie-60a617583d0ccc793d9ea4465998d90ec208db58.tar.bz2 |
check for skins directory and fail nicely if not found
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 2e9553f..5f4159c 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -697,370 +697,375 @@ void PlayListWidget::openFile() { | |||
697 | QString::null, types, 0, | 697 | QString::null, types, 0, |
698 | tr("Add File to Playlist") ); | 698 | tr("Add File to Playlist") ); |
699 | 699 | ||
700 | if( str.isEmpty() ) | 700 | if( str.isEmpty() ) |
701 | return; | 701 | return; |
702 | 702 | ||
703 | if(str.left(2) == "//") str=str.right(str.length()-1); | 703 | if(str.left(2) == "//") str=str.right(str.length()-1); |
704 | 704 | ||
705 | 705 | ||
706 | if( str.right( 3) == "m3u" || str.right(3) == "pls" ) { | 706 | if( str.right( 3) == "m3u" || str.right(3) == "pls" ) { |
707 | readListFromFile( str ); | 707 | readListFromFile( str ); |
708 | } else { | 708 | } else { |
709 | QFileInfo info( str ); | 709 | QFileInfo info( str ); |
710 | DocLnk lnk = addFileToPlaylist( str, info.baseName() ); | 710 | DocLnk lnk = addFileToPlaylist( str, info.baseName() ); |
711 | d->selectedFiles->setSelectedItem( lnk.name() ); | 711 | d->selectedFiles->setSelectedItem( lnk.name() ); |
712 | } | 712 | } |
713 | } | 713 | } |
714 | 714 | ||
715 | void PlayListWidget::openDirectory() { | 715 | void PlayListWidget::openDirectory() { |
716 | QString str = OFileDialog::getDirectory( OFileSelector::DirectorySelector, | 716 | QString str = OFileDialog::getDirectory( OFileSelector::DirectorySelector, |
717 | QString::null, 0, | 717 | QString::null, 0, |
718 | tr( "Add Files from Directory")); | 718 | tr( "Add Files from Directory")); |
719 | 719 | ||
720 | if(str.isEmpty() ) | 720 | if(str.isEmpty() ) |
721 | return; | 721 | return; |
722 | 722 | ||
723 | if(str.left(2) == "//") str=str.right(str.length()-1); | 723 | if(str.left(2) == "//") str=str.right(str.length()-1); |
724 | QDir dir( str ); | 724 | QDir dir( str ); |
725 | QStringList lst = dir.entryList(QDir::Files|QDir::Readable); | 725 | QStringList lst = dir.entryList(QDir::Files|QDir::Readable); |
726 | 726 | ||
727 | for ( QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { | 727 | for ( QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { |
728 | QString filename = str + "/" + *it; | 728 | QString filename = str + "/" + *it; |
729 | 729 | ||
730 | if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) | 730 | if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) |
731 | readListFromFile( filename ); | 731 | readListFromFile( filename ); |
732 | else { | 732 | else { |
733 | addFileToPlaylist( filename, QFileInfo(*it).baseName() ); | 733 | addFileToPlaylist( filename, QFileInfo(*it).baseName() ); |
734 | } | 734 | } |
735 | } | 735 | } |
736 | } | 736 | } |
737 | 737 | ||
738 | void PlayListWidget::readListFromFile( const QString &filename ) { | 738 | void PlayListWidget::readListFromFile( const QString &filename ) { |
739 | odebug << "read list filename " + filename << oendl; | 739 | odebug << "read list filename " + filename << oendl; |
740 | QFileInfo fi(filename); | 740 | QFileInfo fi(filename); |
741 | Om3u *m3uList; | 741 | Om3u *m3uList; |
742 | QString s, name; | 742 | QString s, name; |
743 | m3uList = new Om3u( filename, IO_ReadOnly ); | 743 | m3uList = new Om3u( filename, IO_ReadOnly ); |
744 | if(fi.extension(false).find("m3u",0,false) != -1 ) | 744 | if(fi.extension(false).find("m3u",0,false) != -1 ) |
745 | m3uList->readM3u(); | 745 | m3uList->readM3u(); |
746 | else if(fi.extension(false).find("pls",0,false) != -1 ) | 746 | else if(fi.extension(false).find("pls",0,false) != -1 ) |
747 | m3uList->readPls(); | 747 | m3uList->readPls(); |
748 | 748 | ||
749 | DocLnk lnk; | 749 | DocLnk lnk; |
750 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 750 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
751 | s = *it; | 751 | s = *it; |
752 | // odebug << s << oendl; | 752 | // odebug << s << oendl; |
753 | if(s.left(4)=="http") { | 753 | if(s.left(4)=="http") { |
754 | lnk.setName( s ); //sets file name | 754 | lnk.setName( s ); //sets file name |
755 | lnk.setIcon("opieplayer2/musicfile"); | 755 | lnk.setIcon("opieplayer2/musicfile"); |
756 | lnk.setFile( s ); //sets file name | 756 | lnk.setFile( s ); //sets file name |
757 | 757 | ||
758 | } else { //is file | 758 | } else { //is file |
759 | lnk.setName( QFileInfo(s).baseName()); | 759 | lnk.setName( QFileInfo(s).baseName()); |
760 | if(s.left(1) != "/") { | 760 | if(s.left(1) != "/") { |
761 | 761 | ||
762 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 762 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
763 | } else { | 763 | } else { |
764 | lnk.setFile( s); | 764 | lnk.setFile( s); |
765 | } | 765 | } |
766 | } | 766 | } |
767 | d->selectedFiles->addToSelection( lnk ); | 767 | d->selectedFiles->addToSelection( lnk ); |
768 | } | 768 | } |
769 | Config config( "OpiePlayer" ); | 769 | Config config( "OpiePlayer" ); |
770 | config.setGroup( "PlayList" ); | 770 | config.setGroup( "PlayList" ); |
771 | 771 | ||
772 | config.writeEntry("CurrentPlaylist",filename); | 772 | config.writeEntry("CurrentPlaylist",filename); |
773 | config.write(); | 773 | config.write(); |
774 | currentPlayList=filename; | 774 | currentPlayList=filename; |
775 | 775 | ||
776 | m3uList->close(); | 776 | m3uList->close(); |
777 | delete m3uList; | 777 | delete m3uList; |
778 | 778 | ||
779 | d->selectedFiles->setSelectedItem( s); | 779 | d->selectedFiles->setSelectedItem( s); |
780 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); | 780 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); |
781 | 781 | ||
782 | } | 782 | } |
783 | 783 | ||
784 | // writes current playlist to current m3u file */ | 784 | // writes current playlist to current m3u file */ |
785 | void PlayListWidget::writeCurrentM3u() { | 785 | void PlayListWidget::writeCurrentM3u() { |
786 | odebug << "writing to current m3u" << oendl; | 786 | odebug << "writing to current m3u" << oendl; |
787 | Config cfg( "OpiePlayer" ); | 787 | Config cfg( "OpiePlayer" ); |
788 | cfg.setGroup("PlayList"); | 788 | cfg.setGroup("PlayList"); |
789 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); | 789 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); |
790 | 790 | ||
791 | Om3u *m3uList; | 791 | Om3u *m3uList; |
792 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 792 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
793 | if( d->selectedFiles->first()) { | 793 | if( d->selectedFiles->first()) { |
794 | 794 | ||
795 | do { | 795 | do { |
796 | // odebug << "add writeCurrentM3u " +d->selectedFiles->current()->file() << oendl; | 796 | // odebug << "add writeCurrentM3u " +d->selectedFiles->current()->file() << oendl; |
797 | m3uList->add( d->selectedFiles->current()->file() ); | 797 | m3uList->add( d->selectedFiles->current()->file() ); |
798 | } | 798 | } |
799 | while ( d->selectedFiles->next() ); | 799 | while ( d->selectedFiles->next() ); |
800 | // odebug << "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" << oendl; | 800 | // odebug << "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" << oendl; |
801 | m3uList->write(); | 801 | m3uList->write(); |
802 | m3uList->close(); | 802 | m3uList->close(); |
803 | } | 803 | } |
804 | delete m3uList; | 804 | delete m3uList; |
805 | 805 | ||
806 | } | 806 | } |
807 | 807 | ||
808 | /* | 808 | /* |
809 | writes current playlist to m3u file */ | 809 | writes current playlist to m3u file */ |
810 | void PlayListWidget::writem3u() { | 810 | void PlayListWidget::writem3u() { |
811 | 811 | ||
812 | Config cfg( "OpiePlayer" ); | 812 | Config cfg( "OpiePlayer" ); |
813 | cfg.setGroup("Dialog"); | 813 | cfg.setGroup("Dialog"); |
814 | MimeTypes types = fileSelectorMimeTypes(); | 814 | MimeTypes types = fileSelectorMimeTypes(); |
815 | 815 | ||
816 | QString str = OFileDialog::getOpenFileName( 1, QString::null, | 816 | QString str = OFileDialog::getOpenFileName( 1, QString::null, |
817 | QString::null, types, 0, | 817 | QString::null, types, 0, |
818 | tr( "Save Playlist" )); | 818 | tr( "Save Playlist" )); |
819 | 819 | ||
820 | if(str.left(2) == "//") str=str.right(str.length()-1); | 820 | if(str.left(2) == "//") str=str.right(str.length()-1); |
821 | 821 | ||
822 | QString name, filename, list; | 822 | QString name, filename, list; |
823 | Om3u *m3uList; | 823 | Om3u *m3uList; |
824 | 824 | ||
825 | if( !str.isEmpty() ) { | 825 | if( !str.isEmpty() ) { |
826 | name = str; | 826 | name = str; |
827 | // name = fileDlg->text(); | 827 | // name = fileDlg->text(); |
828 | // odebug << filename << oendl; | 828 | // odebug << filename << oendl; |
829 | if( name.find("/",0,true) != -1) {// assume they specify a file path | 829 | if( name.find("/",0,true) != -1) {// assume they specify a file path |
830 | filename = name; | 830 | filename = name; |
831 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); | 831 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); |
832 | } | 832 | } |
833 | else //otherwise dump it somewhere noticable | 833 | else //otherwise dump it somewhere noticable |
834 | filename = QPEApplication::documentDir() + "/" + name; | 834 | filename = QPEApplication::documentDir() + "/" + name; |
835 | 835 | ||
836 | if( filename.right( 3 ) != "m3u" ) //needs filename extension | 836 | if( filename.right( 3 ) != "m3u" ) //needs filename extension |
837 | filename += ".m3u"; | 837 | filename += ".m3u"; |
838 | 838 | ||
839 | if( d->selectedFiles->first()) { //ramble through playlist view | 839 | if( d->selectedFiles->first()) { //ramble through playlist view |
840 | m3uList = new Om3u( filename, IO_ReadWrite | IO_Truncate); | 840 | m3uList = new Om3u( filename, IO_ReadWrite | IO_Truncate); |
841 | 841 | ||
842 | do { | 842 | do { |
843 | m3uList->add( d->selectedFiles->current()->file()); | 843 | m3uList->add( d->selectedFiles->current()->file()); |
844 | } | 844 | } |
845 | while ( d->selectedFiles->next() ); | 845 | while ( d->selectedFiles->next() ); |
846 | // odebug << list << oendl; | 846 | // odebug << list << oendl; |
847 | m3uList->write(); | 847 | m3uList->write(); |
848 | m3uList->close(); | 848 | m3uList->close(); |
849 | delete m3uList; | 849 | delete m3uList; |
850 | 850 | ||
851 | //delete fileDlg; | 851 | //delete fileDlg; |
852 | 852 | ||
853 | DocLnk lnk; | 853 | DocLnk lnk; |
854 | lnk.setFile( filename); | 854 | lnk.setFile( filename); |
855 | lnk.setIcon("opieplayer2/playlist2"); | 855 | lnk.setIcon("opieplayer2/playlist2"); |
856 | lnk.setName( name); //sets file name | 856 | lnk.setName( name); //sets file name |
857 | 857 | ||
858 | // odebug << filename << oendl; | 858 | // odebug << filename << oendl; |
859 | Config config( "OpiePlayer" ); | 859 | Config config( "OpiePlayer" ); |
860 | config.setGroup( "PlayList" ); | 860 | config.setGroup( "PlayList" ); |
861 | 861 | ||
862 | config.writeEntry("CurrentPlaylist",filename); | 862 | config.writeEntry("CurrentPlaylist",filename); |
863 | currentPlayList=filename; | 863 | currentPlayList=filename; |
864 | 864 | ||
865 | if(!lnk.writeLink()) { | 865 | if(!lnk.writeLink()) { |
866 | odebug << "Writing doclink did not work" << oendl; | 866 | odebug << "Writing doclink did not work" << oendl; |
867 | } | 867 | } |
868 | 868 | ||
869 | setCaption(tr("OpiePlayer: ") + name); | 869 | setCaption(tr("OpiePlayer: ") + name); |
870 | } | 870 | } |
871 | } | 871 | } |
872 | } | 872 | } |
873 | 873 | ||
874 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { | 874 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { |
875 | switch ( e->key() ) { | 875 | switch ( e->key() ) { |
876 | ////////////////////////////// Zaurus keys | 876 | ////////////////////////////// Zaurus keys |
877 | case Key_F9: //activity | 877 | case Key_F9: //activity |
878 | // if(audioUI->isHidden()) | 878 | // if(audioUI->isHidden()) |
879 | // audioUI->showMaximized(); | 879 | // audioUI->showMaximized(); |
880 | break; | 880 | break; |
881 | case Key_F10: //contacts | 881 | case Key_F10: //contacts |
882 | // if( videoUI->isHidden()) | 882 | // if( videoUI->isHidden()) |
883 | // videoUI->showMaximized(); | 883 | // videoUI->showMaximized(); |
884 | break; | 884 | break; |
885 | case Key_F11: //menu | 885 | case Key_F11: //menu |
886 | break; | 886 | break; |
887 | case Key_F12: //home | 887 | case Key_F12: //home |
888 | // doBlank(); | 888 | // doBlank(); |
889 | break; | 889 | break; |
890 | case Key_F13: //mail | 890 | case Key_F13: //mail |
891 | // doUnblank(); | 891 | // doUnblank(); |
892 | break; | 892 | break; |
893 | case Key_Q: //add to playlist | 893 | case Key_Q: //add to playlist |
894 | addSelected(); | 894 | addSelected(); |
895 | break; | 895 | break; |
896 | case Key_R: //remove from playlist | 896 | case Key_R: //remove from playlist |
897 | removeSelected(); | 897 | removeSelected(); |
898 | break; | 898 | break; |
899 | // case Key_P: //play | 899 | // case Key_P: //play |
900 | // odebug << "Play" << oendl; | 900 | // odebug << "Play" << oendl; |
901 | // playSelected(); | 901 | // playSelected(); |
902 | // break; | 902 | // break; |
903 | case Key_Space: | 903 | case Key_Space: |
904 | // playSelected(); puh | 904 | // playSelected(); puh |
905 | break; | 905 | break; |
906 | case Key_1: | 906 | case Key_1: |
907 | tabWidget->setCurrentPage( 0 ); | 907 | tabWidget->setCurrentPage( 0 ); |
908 | break; | 908 | break; |
909 | case Key_2: | 909 | case Key_2: |
910 | tabWidget->setCurrentPage( 1 ); | 910 | tabWidget->setCurrentPage( 1 ); |
911 | break; | 911 | break; |
912 | case Key_3: | 912 | case Key_3: |
913 | tabWidget->setCurrentPage( 2 ); | 913 | tabWidget->setCurrentPage( 2 ); |
914 | break; | 914 | break; |
915 | case Key_4: | 915 | case Key_4: |
916 | tabWidget->setCurrentPage( 3 ); | 916 | tabWidget->setCurrentPage( 3 ); |
917 | break; | 917 | break; |
918 | case Key_Down: | 918 | case Key_Down: |
919 | if ( !d->selectedFiles->next() ) | 919 | if ( !d->selectedFiles->next() ) |
920 | d->selectedFiles->first(); | 920 | d->selectedFiles->first(); |
921 | break; | 921 | break; |
922 | case Key_Up: | 922 | case Key_Up: |
923 | if ( !d->selectedFiles->prev() ) | 923 | if ( !d->selectedFiles->prev() ) |
924 | // d->selectedFiles->last(); | 924 | // d->selectedFiles->last(); |
925 | break; | 925 | break; |
926 | } | 926 | } |
927 | } | 927 | } |
928 | 928 | ||
929 | void PlayListWidget::pmViewActivated(int index) { | 929 | void PlayListWidget::pmViewActivated(int index) { |
930 | // odebug << "" << index << "" << oendl; | 930 | // odebug << "" << index << "" << oendl; |
931 | switch(index) { | 931 | switch(index) { |
932 | case -16: | 932 | case -16: |
933 | { | 933 | { |
934 | mediaPlayerState->toggleFullscreen(); | 934 | mediaPlayerState->toggleFullscreen(); |
935 | bool b=mediaPlayerState->isFullscreen(); | 935 | bool b=mediaPlayerState->isFullscreen(); |
936 | pmView->setItemChecked( index, b); | 936 | pmView->setItemChecked( index, b); |
937 | Config cfg( "OpiePlayer" ); | 937 | Config cfg( "OpiePlayer" ); |
938 | cfg.writeEntry( "FullScreen", b ); | 938 | cfg.writeEntry( "FullScreen", b ); |
939 | } | 939 | } |
940 | break; | 940 | break; |
941 | }; | 941 | }; |
942 | } | 942 | } |
943 | 943 | ||
944 | void PlayListWidget::populateSkinsMenu() { | 944 | void PlayListWidget::populateSkinsMenu() { |
945 | int item = 0; | 945 | int item = 0; |
946 | defaultSkinIndex = 0; | 946 | defaultSkinIndex = 0; |
947 | QString skinName; | 947 | QString skinName; |
948 | Config cfg( "OpiePlayer" ); | 948 | Config cfg( "OpiePlayer" ); |
949 | cfg.setGroup("Options" ); | 949 | cfg.setGroup("Options" ); |
950 | QString skin = cfg.readEntry( "Skin", "default" ); | 950 | QString skin = cfg.readEntry( "Skin", "default" ); |
951 | 951 | ||
952 | QDir skinsDir( QPEApplication::qpeDir() + "pics/opieplayer2/skins" ); | 952 | QDir skinsDir( QPEApplication::qpeDir() + "pics/opieplayer2/skins" ); |
953 | if(!skinsDir.exists()) { | ||
954 | QMessageBox::critical( 0, tr("Opieplayer Error"), | ||
955 | tr("<p><b>Opieplayer2 skin not found!</b></p><p>Please install an opieplayer2 skin package.</p>") ); | ||
956 | exit(1) ; | ||
957 | } | ||
953 | skinsDir.setFilter( QDir::Dirs ); | 958 | skinsDir.setFilter( QDir::Dirs ); |
954 | skinsDir.setSorting(QDir::Name ); | 959 | skinsDir.setSorting(QDir::Name ); |
955 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); | 960 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); |
956 | QFileInfoListIterator it( *skinslist ); | 961 | QFileInfoListIterator it( *skinslist ); |
957 | QFileInfo *fi; | 962 | QFileInfo *fi; |
958 | while ( ( fi = it.current() ) ) { | 963 | while ( ( fi = it.current() ) ) { |
959 | skinName = fi->fileName(); | 964 | skinName = fi->fileName(); |
960 | // odebug << fi->fileName() << oendl; | 965 | // odebug << fi->fileName() << oendl; |
961 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { | 966 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { |
962 | item = skinsMenu->insertItem( fi->fileName() ) ; | 967 | item = skinsMenu->insertItem( fi->fileName() ) ; |
963 | } | 968 | } |
964 | if( skinName == "default" ) { | 969 | if( skinName == "default" ) { |
965 | defaultSkinIndex = item; | 970 | defaultSkinIndex = item; |
966 | } | 971 | } |
967 | if( skinName == skin ) { | 972 | if( skinName == skin ) { |
968 | skinsMenu->setItemChecked( item, TRUE ); | 973 | skinsMenu->setItemChecked( item, TRUE ); |
969 | } | 974 | } |
970 | ++it; | 975 | ++it; |
971 | } | 976 | } |
972 | } | 977 | } |
973 | 978 | ||
974 | void PlayListWidget::skinsMenuActivated( int item ) { | 979 | void PlayListWidget::skinsMenuActivated( int item ) { |
975 | for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { | 980 | for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { |
976 | skinsMenu->setItemChecked( i, FALSE ); | 981 | skinsMenu->setItemChecked( i, FALSE ); |
977 | } | 982 | } |
978 | skinsMenu->setItemChecked( item, TRUE ); | 983 | skinsMenu->setItemChecked( item, TRUE ); |
979 | 984 | ||
980 | { | 985 | { |
981 | Config cfg( "OpiePlayer" ); | 986 | Config cfg( "OpiePlayer" ); |
982 | cfg.setGroup("Options"); | 987 | cfg.setGroup("Options"); |
983 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); | 988 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); |
984 | } | 989 | } |
985 | 990 | ||
986 | emit skinSelected(); | 991 | emit skinSelected(); |
987 | } | 992 | } |
988 | 993 | ||
989 | PlayListWidget::TabType PlayListWidget::currentTab() const | 994 | PlayListWidget::TabType PlayListWidget::currentTab() const |
990 | { | 995 | { |
991 | static const TabType indexToTabType[ TabTypeCount ] = | 996 | static const TabType indexToTabType[ TabTypeCount ] = |
992 | { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; | 997 | { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; |
993 | 998 | ||
994 | int index = tabWidget->currentPageIndex(); | 999 | int index = tabWidget->currentPageIndex(); |
995 | assert( index < TabTypeCount && index >= 0 ); | 1000 | assert( index < TabTypeCount && index >= 0 ); |
996 | 1001 | ||
997 | return indexToTabType[ index ]; | 1002 | return indexToTabType[ index ]; |
998 | } | 1003 | } |
999 | 1004 | ||
1000 | PlayListWidget::Entry PlayListWidget::currentEntry() const | 1005 | PlayListWidget::Entry PlayListWidget::currentEntry() const |
1001 | { | 1006 | { |
1002 | if ( currentTab() == CurrentPlayList ) { | 1007 | if ( currentTab() == CurrentPlayList ) { |
1003 | const DocLnk *lnk = current(); | 1008 | const DocLnk *lnk = current(); |
1004 | return Entry( lnk->name(), lnk->file() ); | 1009 | return Entry( lnk->name(), lnk->file() ); |
1005 | } | 1010 | } |
1006 | 1011 | ||
1007 | return Entry( currentFileListPathName() ); | 1012 | return Entry( currentFileListPathName() ); |
1008 | } | 1013 | } |
1009 | 1014 | ||
1010 | QString PlayListWidget::currentFileListPathName() const { | 1015 | QString PlayListWidget::currentFileListPathName() const { |
1011 | return currentFileListView->currentItem()->text( 3 ); | 1016 | return currentFileListView->currentItem()->text( 3 ); |
1012 | } | 1017 | } |
1013 | 1018 | ||
1014 | 1019 | ||
1015 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { | 1020 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { |
1016 | QDataStream stream ( data, IO_ReadOnly ); | 1021 | QDataStream stream ( data, IO_ReadOnly ); |
1017 | if ( msg == "play()" ) { //plays current selection | 1022 | if ( msg == "play()" ) { //plays current selection |
1018 | btnPlay( true); | 1023 | btnPlay( true); |
1019 | } else if ( msg == "stop()" ) { | 1024 | } else if ( msg == "stop()" ) { |
1020 | mediaPlayerState->setPlaying( false); | 1025 | mediaPlayerState->setPlaying( false); |
1021 | } else if ( msg == "togglePause()" ) { | 1026 | } else if ( msg == "togglePause()" ) { |
1022 | mediaPlayerState->togglePaused(); | 1027 | mediaPlayerState->togglePaused(); |
1023 | } else if ( msg == "next()" ) { //select next in list | 1028 | } else if ( msg == "next()" ) { //select next in list |
1024 | mediaPlayerState->setNext(); | 1029 | mediaPlayerState->setNext(); |
1025 | } else if ( msg == "prev()" ) { //select previous in list | 1030 | } else if ( msg == "prev()" ) { //select previous in list |
1026 | mediaPlayerState->setPrev(); | 1031 | mediaPlayerState->setPrev(); |
1027 | } else if ( msg == "toggleLooping()" ) { //loop or not loop | 1032 | } else if ( msg == "toggleLooping()" ) { //loop or not loop |
1028 | mediaPlayerState->toggleLooping(); | 1033 | mediaPlayerState->toggleLooping(); |
1029 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled | 1034 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled |
1030 | mediaPlayerState->toggleShuffled(); | 1035 | mediaPlayerState->toggleShuffled(); |
1031 | } else if ( msg == "volUp()" ) { //volume more | 1036 | } else if ( msg == "volUp()" ) { //volume more |
1032 | // emit moreClicked(); | 1037 | // emit moreClicked(); |
1033 | // emit moreReleased(); | 1038 | // emit moreReleased(); |
1034 | } else if ( msg == "volDown()" ) { //volume less | 1039 | } else if ( msg == "volDown()" ) { //volume less |
1035 | // emit lessClicked(); | 1040 | // emit lessClicked(); |
1036 | // emit lessReleased(); | 1041 | // emit lessReleased(); |
1037 | } else if ( msg == "play(QString)" ) { //play this now | 1042 | } else if ( msg == "play(QString)" ) { //play this now |
1038 | QString file; | 1043 | QString file; |
1039 | stream >> file; | 1044 | stream >> file; |
1040 | setDocument( (const QString &) file); | 1045 | setDocument( (const QString &) file); |
1041 | } else if ( msg == "add(QString)" ) { //add to playlist | 1046 | } else if ( msg == "add(QString)" ) { //add to playlist |
1042 | QString file; | 1047 | QString file; |
1043 | stream >> file; | 1048 | stream >> file; |
1044 | QFileInfo fileInfo(file); | 1049 | QFileInfo fileInfo(file); |
1045 | DocLnk lnk; | 1050 | DocLnk lnk; |
1046 | lnk.setName( fileInfo.baseName() ); //sets name | 1051 | lnk.setName( fileInfo.baseName() ); //sets name |
1047 | lnk.setFile( file ); //sets file name | 1052 | lnk.setFile( file ); //sets file name |
1048 | addToSelection( lnk ); | 1053 | addToSelection( lnk ); |
1049 | } else if ( msg == "rem(QString)" ) { //remove from playlist | 1054 | } else if ( msg == "rem(QString)" ) { //remove from playlist |
1050 | QString file; | 1055 | QString file; |
1051 | stream >> file; | 1056 | stream >> file; |
1052 | 1057 | ||
1053 | } | 1058 | } |
1054 | 1059 | ||
1055 | } | 1060 | } |
1056 | 1061 | ||
1057 | DocLnk PlayListWidget::addFileToPlaylist( const QString& file, | 1062 | DocLnk PlayListWidget::addFileToPlaylist( const QString& file, |
1058 | const QString& name ) { | 1063 | const QString& name ) { |
1059 | DocLnk lnk; | 1064 | DocLnk lnk; |
1060 | lnk.setName( name ); //sets name | 1065 | lnk.setName( name ); //sets name |
1061 | lnk.setFile( file ); //sets file name | 1066 | lnk.setFile( file ); //sets file name |
1062 | d->selectedFiles->addToSelection( lnk ); | 1067 | d->selectedFiles->addToSelection( lnk ); |
1063 | writeCurrentM3u(); | 1068 | writeCurrentM3u(); |
1064 | 1069 | ||
1065 | return lnk; | 1070 | return lnk; |
1066 | } | 1071 | } |