Diffstat (limited to 'core/multimedia/opieplayer/playlistwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 71 |
1 files changed, 35 insertions, 36 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 70b7cef..2118051 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -606,57 +606,48 @@ bool PlayListWidget::first() { | |||
606 | 606 | ||
607 | 607 | ||
608 | bool PlayListWidget::last() { | 608 | bool PlayListWidget::last() { |
609 | if ( mediaPlayerState->playlist() ) | 609 | if ( mediaPlayerState->playlist() ) |
610 | return d->selectedFiles->last(); | 610 | return d->selectedFiles->last(); |
611 | else | 611 | else |
612 | return mediaPlayerState->looping(); | 612 | return mediaPlayerState->looping(); |
613 | } | 613 | } |
614 | 614 | ||
615 | 615 | ||
616 | void PlayListWidget::saveList() { | 616 | void PlayListWidget::saveList() { |
617 | 617 | ||
618 | QString filename; | 618 | QString filename; |
619 | InputDialog *fileDlg; | 619 | InputDialog *fileDlg; |
620 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); | 620 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); |
621 | fileDlg->exec(); | 621 | fileDlg->exec(); |
622 | if( fileDlg->result() == 1 ) { | 622 | if( fileDlg->result() == 1 ) { |
623 | if ( d->current ) | 623 | if ( d->current ) |
624 | delete d->current; | 624 | delete d->current; |
625 | filename = fileDlg->LineEdit1->text();//+".playlist"; | 625 | filename = fileDlg->LineEdit1->text();//+".playlist"; |
626 | // qDebug("saving playlist "+filename+".playlist"); | 626 | // qDebug("saving playlist "+filename+".playlist"); |
627 | Config cfg( filename +".playlist"); | 627 | Config cfg( filename +".playlist"); |
628 | writeConfig( cfg ); | 628 | writeConfig( cfg ); |
629 | 629 | ||
630 | // qDebug("same name so delete lnk??"); | ||
631 | // if( playLists->selected()->name() == filename) { | ||
632 | |||
633 | // qDebug("same name so delete lnk"); | ||
634 | // QFile().remove(playLists->selected()->file()); | ||
635 | // QFile().remove(playLists->selected()->linkFile()); | ||
636 | // playLists->reread(); | ||
637 | // } | ||
638 | // qDebug("new doclnk"); | ||
639 | DocLnk lnk; | 630 | DocLnk lnk; |
640 | // lnk.setComment( ""); | 631 | // lnk.setComment( ""); |
641 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property | 632 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property |
642 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D | 633 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D |
643 | lnk.setIcon("opieplayer/playlist2"); | 634 | lnk.setIcon("opieplayer/playlist2"); |
644 | lnk.setName( filename); //sets file name | 635 | lnk.setName( filename); //sets file name |
645 | // qDebug(filename); | 636 | // qDebug(filename); |
646 | if(!lnk.writeLink()) | 637 | if(!lnk.writeLink()) |
647 | qDebug("Writing doclink did not work"); | 638 | qDebug("Writing doclink did not work"); |
648 | } | 639 | } |
649 | Config config( "OpiePlayer" ); | 640 | Config config( "OpiePlayer" ); |
650 | config.writeEntry("CurrentPlaylist",filename); | 641 | config.writeEntry("CurrentPlaylist",filename); |
651 | setCaption(tr("OpiePlayer: ")+filename); | 642 | setCaption(tr("OpiePlayer: ")+filename); |
652 | d->selectedFiles->first(); | 643 | d->selectedFiles->first(); |
653 | if(fileDlg) | 644 | if(fileDlg) |
654 | delete fileDlg; | 645 | delete fileDlg; |
655 | } | 646 | } |
656 | 647 | ||
657 | void PlayListWidget::loadList( const DocLnk & lnk) { | 648 | void PlayListWidget::loadList( const DocLnk & lnk) { |
658 | QString name= lnk.name(); | 649 | QString name= lnk.name(); |
659 | // qDebug("currentList is "+name); | 650 | // qDebug("currentList is "+name); |
660 | if( name.length()>1) { | 651 | if( name.length()>1) { |
661 | setCaption("OpiePlayer: "+name); | 652 | setCaption("OpiePlayer: "+name); |
662 | // qDebug("load list "+ name+".playlist"); | 653 | // qDebug("load list "+ name+".playlist"); |
@@ -826,101 +817,103 @@ void PlayListWidget::tabChanged(QWidget *widg) { | |||
826 | playLists->reread(); | 817 | playLists->reread(); |
827 | } | 818 | } |
828 | break; | 819 | break; |
829 | }; | 820 | }; |
830 | } | 821 | } |
831 | 822 | ||
832 | 823 | ||
833 | 824 | ||
834 | void PlayListWidget::btnPlay(bool b) { | 825 | void PlayListWidget::btnPlay(bool b) { |
835 | 826 | ||
836 | // mediaPlayerState->setPlaying(b); | 827 | // mediaPlayerState->setPlaying(b); |
837 | switch ( tabWidget->currentPageIndex()) { | 828 | switch ( tabWidget->currentPageIndex()) { |
838 | case 0: | 829 | case 0: |
839 | { | 830 | { |
840 | mediaPlayerState->setPlaying(b); | 831 | mediaPlayerState->setPlaying(b); |
841 | } | 832 | } |
842 | break; | 833 | break; |
843 | case 1: | 834 | case 1: |
844 | { | 835 | { |
845 | addToSelection( audioView->selectedItem() ); | 836 | addToSelection( audioView->selectedItem() ); |
846 | mediaPlayerState->setPlaying(b); | 837 | mediaPlayerState->setPlaying(b); |
847 | d->selectedFiles->removeSelected( ); | 838 | d->selectedFiles->removeSelected( ); |
848 | tabWidget->setCurrentPage(1); | 839 | tabWidget->setCurrentPage(1); |
849 | d->selectedFiles->unSelect(); | 840 | d->selectedFiles->unSelect(); |
841 | insanityBool=FALSE; | ||
850 | // audioView->clearSelection(); | 842 | // audioView->clearSelection(); |
851 | } | 843 | } |
852 | break; | 844 | break; |
853 | case 2: | 845 | case 2: |
854 | { | 846 | { |
855 | addToSelection( videoView->selectedItem() ); | 847 | addToSelection( videoView->selectedItem() ); |
856 | mediaPlayerState->setPlaying(b); | 848 | mediaPlayerState->setPlaying(b); |
857 | qApp->processEvents(); | 849 | qApp->processEvents(); |
858 | d->selectedFiles->removeSelected( ); | 850 | d->selectedFiles->removeSelected( ); |
859 | tabWidget->setCurrentPage(2); | 851 | tabWidget->setCurrentPage(2); |
860 | d->selectedFiles->unSelect(); | 852 | d->selectedFiles->unSelect(); |
853 | insanityBool=FALSE; | ||
861 | // videoView->clearSelection(); | 854 | // videoView->clearSelection(); |
862 | } | 855 | } |
863 | break; | 856 | break; |
864 | }; | 857 | }; |
865 | } | 858 | } |
866 | 859 | ||
867 | void PlayListWidget::deletePlaylist() { | 860 | void PlayListWidget::deletePlaylist() { |
868 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 861 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
869 | (tr("You really want to delete\nthis playlist?")), | 862 | (tr("You really want to delete\nthis playlist?")), |
870 | (tr("Yes")), (tr("No")), 0 )){ | 863 | (tr("Yes")), (tr("No")), 0 )){ |
871 | case 0: // Yes clicked, | 864 | case 0: // Yes clicked, |
872 | QFile().remove(playLists->selected()->file()); | 865 | QFile().remove(playLists->selected()->file()); |
873 | QFile().remove(playLists->selected()->linkFile()); | 866 | QFile().remove(playLists->selected()->linkFile()); |
874 | playLists->reread(); | 867 | playLists->reread(); |
875 | break; | 868 | break; |
876 | case 1: // Cancel | 869 | case 1: // Cancel |
877 | break; | 870 | break; |
878 | }; | 871 | }; |
879 | 872 | ||
880 | } | 873 | } |
881 | 874 | ||
882 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) | 875 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) |
883 | { | 876 | { |
884 | switch (mouse) { | 877 | switch (mouse) { |
885 | case 1: | 878 | case 1: |
886 | break; | 879 | break; |
887 | case 2:{ | 880 | case 2:{ |
888 | QPopupMenu m; | 881 | QPopupMenu m; |
889 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 882 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
890 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 883 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
891 | m.insertSeparator(); | 884 | m.insertSeparator(); |
892 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 885 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
893 | m.exec( QCursor::pos() ); | 886 | m.exec( QCursor::pos() ); |
894 | } | 887 | } |
895 | break; | 888 | break; |
896 | }; | 889 | }; |
897 | } | 890 | } |
898 | 891 | ||
899 | void PlayListWidget::playSelected() | 892 | void PlayListWidget::playSelected() |
900 | { | 893 | { |
901 | btnPlay( TRUE); | 894 | btnPlay( TRUE); |
902 | d->selectedFiles->unSelect(); | 895 | // d->selectedFiles->unSelect(); |
903 | } | 896 | } |
904 | 897 | ||
905 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) | 898 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) |
906 | { | 899 | { |
907 | switch (mouse) { | 900 | switch (mouse) { |
908 | case 1: | 901 | case 1: |
909 | 902 | ||
910 | break; | 903 | break; |
911 | case 2:{ | 904 | case 2:{ |
912 | QPopupMenu m; | 905 | QPopupMenu m; |
913 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 906 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
914 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 907 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
915 | // m.insertSeparator(); | 908 | // m.insertSeparator(); |
916 | m.exec( QCursor::pos() ); | 909 | m.exec( QCursor::pos() ); |
917 | } | 910 | } |
918 | break; | 911 | break; |
919 | }; | 912 | }; |
920 | 913 | ||
921 | } | 914 | } |
922 | 915 | ||
923 | void PlayListWidget::listDelete() { | 916 | void PlayListWidget::listDelete() { |
924 | Config cfg( "OpiePlayer" ); | 917 | Config cfg( "OpiePlayer" ); |
925 | cfg.setGroup("PlayList"); | 918 | cfg.setGroup("PlayList"); |
926 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 919 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
@@ -1003,80 +996,74 @@ void PlayListWidget::populateVideoView() { | |||
1003 | videoView->clear(); | 996 | videoView->clear(); |
1004 | QString storage; | 997 | QString storage; |
1005 | for ( ; Vdit.current(); ++Vdit ) { | 998 | for ( ; Vdit.current(); ++Vdit ) { |
1006 | for( ; it.current(); ++it ){ | 999 | for( ; it.current(); ++it ){ |
1007 | const QString name = (*it)->name(); | 1000 | const QString name = (*it)->name(); |
1008 | const QString path = (*it)->path(); | 1001 | const QString path = (*it)->path(); |
1009 | if( Vdit.current()->file().find(path) != -1 ) storage=name; | 1002 | if( Vdit.current()->file().find(path) != -1 ) storage=name; |
1010 | } | 1003 | } |
1011 | 1004 | ||
1012 | QListViewItem * newItem; | 1005 | QListViewItem * newItem; |
1013 | if ( QFile( Vdit.current()->file()).exists() ) { | 1006 | if ( QFile( Vdit.current()->file()).exists() ) { |
1014 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); | 1007 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); |
1015 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); | 1008 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); |
1016 | } | 1009 | } |
1017 | } | 1010 | } |
1018 | } | 1011 | } |
1019 | 1012 | ||
1020 | void PlayListWidget::openFile() { | 1013 | void PlayListWidget::openFile() { |
1021 | QString filename, name; | 1014 | QString filename, name; |
1022 | InputDialog *fileDlg; | 1015 | InputDialog *fileDlg; |
1023 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 1016 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
1024 | fileDlg->exec(); | 1017 | fileDlg->exec(); |
1025 | if( fileDlg->result() == 1 ) { | 1018 | if( fileDlg->result() == 1 ) { |
1026 | filename = fileDlg->LineEdit1->text(); | 1019 | filename = fileDlg->LineEdit1->text(); |
1027 | |||
1028 | // InputDialog *fileDlg2; | ||
1029 | // fileDlg2 = new InputDialog(this,tr("Name"),TRUE, 0); | ||
1030 | // fileDlg2->exec(); | ||
1031 | // if( fileDlg2->result() == 1 ) { | ||
1032 | // name = fileDlg2->LineEdit1->text(); | ||
1033 | // } | ||
1034 | //http://205.188.234.129:8030 | 1020 | //http://205.188.234.129:8030 |
1035 | // http://66.28.68.70:8000 | 1021 | // http://66.28.68.70:8000 |
1036 | qDebug(filename); | 1022 | qDebug(filename); |
1037 | DocLnk lnk; | 1023 | if(filename.right(3) == "m3u") |
1038 | // if(filename.left(7) == "http://") | 1024 | readm3u( filename); |
1039 | // name= filename.right(filename.length()-filename.find("http://")-7); | 1025 | else if(filename.right(3) == "pls") |
1040 | // else name = filename; | 1026 | readPls( filename); |
1041 | // qDebug("name is "+name); | 1027 | else { |
1042 | // lnk.setComment(filename); | 1028 | DocLnk lnk; |
1043 | lnk.setName(filename); //sets file name | 1029 | |
1044 | if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3") | 1030 | lnk.setName(filename); //sets file name |
1045 | filename += "/"; | 1031 | if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3") |
1046 | lnk.setFile(filename); //sets File property | 1032 | filename += "/"; |
1047 | 1033 | lnk.setFile(filename); //sets File property | |
1048 | lnk.setType("audio/x-mpegurl"); | 1034 | |
1049 | lnk.setExec("opieplayer"); | 1035 | lnk.setType("audio/x-mpegurl"); |
1050 | lnk.setIcon("opieplayer/MPEGPlayer"); | 1036 | lnk.setExec("opieplayer"); |
1051 | 1037 | lnk.setIcon("opieplayer/MPEGPlayer"); | |
1052 | if(!lnk.writeLink()) | 1038 | |
1053 | qDebug("Writing doclink did not work"); | 1039 | if(!lnk.writeLink()) |
1054 | d->selectedFiles->addToSelection( lnk); | 1040 | qDebug("Writing doclink did not work"); |
1041 | d->selectedFiles->addToSelection( lnk); | ||
1055 | // if(fileDlg2) | 1042 | // if(fileDlg2) |
1056 | // delete fileDlg2; | 1043 | // delete fileDlg2; |
1044 | } | ||
1057 | } | 1045 | } |
1058 | |||
1059 | if(fileDlg) | 1046 | if(fileDlg) |
1060 | delete fileDlg; | 1047 | delete fileDlg; |
1061 | } | 1048 | } |
1062 | 1049 | ||
1063 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) | 1050 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) |
1064 | { | 1051 | { |
1065 | switch ( e->key() ) { | 1052 | switch ( e->key() ) { |
1066 | ////////////////////////////// Zaurus keys | 1053 | ////////////////////////////// Zaurus keys |
1067 | case Key_F9: //activity | 1054 | case Key_F9: //activity |
1068 | // if(audioUI->isHidden()) | 1055 | // if(audioUI->isHidden()) |
1069 | // audioUI->showMaximized(); | 1056 | // audioUI->showMaximized(); |
1070 | break; | 1057 | break; |
1071 | case Key_F10: //contacts | 1058 | case Key_F10: //contacts |
1072 | // if( videoUI->isHidden()) | 1059 | // if( videoUI->isHidden()) |
1073 | // videoUI->showMaximized(); | 1060 | // videoUI->showMaximized(); |
1074 | break; | 1061 | break; |
1075 | case Key_F11: //menu | 1062 | case Key_F11: //menu |
1076 | break; | 1063 | break; |
1077 | case Key_F12: //home | 1064 | case Key_F12: //home |
1078 | // doBlank(); | 1065 | // doBlank(); |
1079 | break; | 1066 | break; |
1080 | case Key_F13: //mail | 1067 | case Key_F13: //mail |
1081 | // doUnblank(); | 1068 | // doUnblank(); |
1082 | break; | 1069 | break; |
@@ -1084,24 +1071,36 @@ void PlayListWidget::keyReleaseEvent( QKeyEvent *e) | |||
1084 | } | 1071 | } |
1085 | } | 1072 | } |
1086 | 1073 | ||
1087 | void PlayListWidget::doBlank() { | 1074 | void PlayListWidget::doBlank() { |
1088 | qDebug("do blanking"); | 1075 | qDebug("do blanking"); |
1089 | fd=open("/dev/fb0",O_RDWR); | 1076 | fd=open("/dev/fb0",O_RDWR); |
1090 | if (fd != -1) { | 1077 | if (fd != -1) { |
1091 | ioctl(fd,FBIOBLANK,1); | 1078 | ioctl(fd,FBIOBLANK,1); |
1092 | // close(fd); | 1079 | // close(fd); |
1093 | } | 1080 | } |
1094 | } | 1081 | } |
1095 | 1082 | ||
1096 | void PlayListWidget::doUnblank() { | 1083 | void PlayListWidget::doUnblank() { |
1097 | // this crashes opieplayer with a segfault | 1084 | // this crashes opieplayer with a segfault |
1098 | // int fd; | 1085 | // int fd; |
1099 | // fd=open("/dev/fb0",O_RDWR); | 1086 | // fd=open("/dev/fb0",O_RDWR); |
1100 | qDebug("do unblanking"); | 1087 | qDebug("do unblanking"); |
1101 | if (fd != -1) { | 1088 | if (fd != -1) { |
1102 | ioctl(fd,FBIOBLANK,0); | 1089 | ioctl(fd,FBIOBLANK,0); |
1103 | close(fd); | 1090 | close(fd); |
1104 | } | 1091 | } |
1105 | QCopEnvelope h("QPE/System", "setBacklight(int)"); | 1092 | QCopEnvelope h("QPE/System", "setBacklight(int)"); |
1106 | h <<-3;// v[1]; // -3 Force on | 1093 | h <<-3;// v[1]; // -3 Force on |
1107 | } | 1094 | } |
1095 | |||
1096 | void PlayListWidget::readm3u(const QString &filename) { | ||
1097 | |||
1098 | } | ||
1099 | |||
1100 | void PlayListWidget::writem3u(const QString &filename) { | ||
1101 | |||
1102 | } | ||
1103 | |||
1104 | void PlayListWidget::readPls(const QString &filename) { | ||
1105 | |||
1106 | } | ||