-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.cpp | 1 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 108 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.h | 2 |
3 files changed, 64 insertions, 47 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index b8023ca..043d8ba 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp | |||
@@ -156,9 +156,8 @@ void MediaPlayer::next() { | |||
156 | mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); | 156 | mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); |
157 | if(l) mediaPlayerState.setLooping(l); | 157 | if(l) mediaPlayerState.setLooping(l); |
158 | if(r) mediaPlayerState.setShuffled(r); | 158 | if(r) mediaPlayerState.setShuffled(r); |
159 | } | 159 | } |
160 | qApp->processEvents(); | ||
161 | } | 160 | } |
162 | 161 | ||
163 | 162 | ||
164 | void MediaPlayer::startDecreasingVolume() { | 163 | void MediaPlayer::startDecreasingVolume() { |
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 37b998f..dc2c496 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -84,8 +84,10 @@ PlayListWidget::PlayListWidget(QWidget* parent, const char* name, WFlags fl ) | |||
84 | (void)new MenuItem( pmPlayList, tr( "Add File" ), | 84 | (void)new MenuItem( pmPlayList, tr( "Add File" ), |
85 | this,SLOT( openFile() ) ); | 85 | this,SLOT( openFile() ) ); |
86 | (void)new MenuItem( pmPlayList, tr("Add URL"), | 86 | (void)new MenuItem( pmPlayList, tr("Add URL"), |
87 | this,SLOT( openURL() ) ); | 87 | this,SLOT( openURL() ) ); |
88 | (void)new MenuItem( pmPlayList, tr( "Add Directory"), | ||
89 | this, SLOT(openDirectory())); | ||
88 | pmPlayList->insertSeparator(-1); | 90 | pmPlayList->insertSeparator(-1); |
89 | (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), | 91 | (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), |
90 | this, SLOT(writem3u() ) ); | 92 | this, SLOT(writem3u() ) ); |
91 | pmPlayList->insertSeparator(-1); | 93 | pmPlayList->insertSeparator(-1); |
@@ -661,14 +663,9 @@ void PlayListWidget::openURL() { | |||
661 | delete fileDlg; | 663 | delete fileDlg; |
662 | } | 664 | } |
663 | 665 | ||
664 | 666 | ||
665 | void PlayListWidget::openFile() { | 667 | static MimeTypes fileSelectorMimeTypes() { |
666 | |||
667 | QString filename, name; | ||
668 | |||
669 | Config cfg( "OpiePlayer" ); | ||
670 | cfg.setGroup("Dialog"); | ||
671 | MimeTypes types; | 668 | MimeTypes types; |
672 | QStringList audio, video, all; | 669 | QStringList audio, video, all; |
673 | audio << "audio/*"; | 670 | audio << "audio/*"; |
674 | audio << "playlist/plain"; | 671 | audio << "playlist/plain"; |
@@ -683,36 +680,62 @@ void PlayListWidget::openFile() { | |||
683 | types.insert("All Media Files", all ); | 680 | types.insert("All Media Files", all ); |
684 | types.insert("Audio", audio ); | 681 | types.insert("Audio", audio ); |
685 | types.insert("Video", video ); | 682 | types.insert("Video", video ); |
686 | 683 | ||
687 | QString str = OFileDialog::getOpenFileName( 1, | 684 | return types; |
688 | cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", | 685 | } |
689 | types, 0 ); | 686 | |
687 | void PlayListWidget::openFile() { | ||
688 | |||
689 | QString filename, name; | ||
690 | |||
691 | Config cfg( "OpiePlayer" ); | ||
692 | cfg.setGroup("Dialog"); | ||
693 | MimeTypes types = fileSelectorMimeTypes(); | ||
694 | |||
695 | |||
696 | QString str = OFileDialog::getOpenFileName( 1, QString::null, | ||
697 | QString::null, types, 0, | ||
698 | tr("Add File to Playlist") ); | ||
699 | |||
700 | if( str.isEmpty() ) | ||
701 | return; | ||
702 | |||
703 | if(str.left(2) == "//") str=str.right(str.length()-1); | ||
704 | |||
690 | 705 | ||
691 | if(str.left(2) == "//") { | 706 | if( str.right( 3) == "m3u" || str.right(3) == "pls" ) { |
692 | str=str.right(str.length()-1); | 707 | readListFromFile( str ); |
708 | } else { | ||
709 | QFileInfo info( str ); | ||
710 | DocLnk lnk = addFileToPlaylist( str, info.baseName() ); | ||
711 | d->selectedFiles->setSelectedItem( lnk.name() ); | ||
693 | } | 712 | } |
694 | cfg.writeEntry( "LastDirectory" ,QFileInfo( str ).dirPath() ); | 713 | } |
695 | 714 | ||
696 | if( !str.isEmpty() ) { | 715 | void PlayListWidget::openDirectory() { |
716 | QString str = OFileDialog::getDirectory( OFileSelector::DirectorySelector, | ||
717 | QString::null, 0, | ||
718 | tr( "Add Files from Directory")); | ||
697 | 719 | ||
698 | odebug << "Selected filename is " + str << oendl; | 720 | if(str.isEmpty() ) |
699 | filename = str; | 721 | return; |
700 | DocLnk lnk; | 722 | |
723 | if(str.left(2) == "//") str=str.right(str.length()-1); | ||
724 | QDir dir( str ); | ||
725 | QStringList lst = dir.entryList(QDir::Files|QDir::Readable); | ||
701 | 726 | ||
702 | if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { | 727 | for ( QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { |
728 | QString filename = str + "/" + *it; | ||
729 | |||
730 | if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) | ||
703 | readListFromFile( filename ); | 731 | readListFromFile( filename ); |
704 | } else { | 732 | else { |
705 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 733 | addFileToPlaylist( filename, QFileInfo(*it).baseName() ); |
706 | lnk.setFile( filename ); //sets file name | ||
707 | d->selectedFiles->addToSelection( lnk ); | ||
708 | writeCurrentM3u(); | ||
709 | d->selectedFiles->setSelectedItem( lnk.name() ); | ||
710 | } | 734 | } |
711 | } | 735 | } |
712 | } | 736 | } |
713 | 737 | ||
714 | |||
715 | void PlayListWidget::readListFromFile( const QString &filename ) { | 738 | void PlayListWidget::readListFromFile( const QString &filename ) { |
716 | odebug << "read list filename " + filename << oendl; | 739 | odebug << "read list filename " + filename << oendl; |
717 | QFileInfo fi(filename); | 740 | QFileInfo fi(filename); |
718 | Om3u *m3uList; | 741 | Om3u *m3uList; |
@@ -784,35 +807,18 @@ void PlayListWidget::readListFromFile( const QString &filename ) { | |||
784 | 807 | ||
785 | /* | 808 | /* |
786 | writes current playlist to m3u file */ | 809 | writes current playlist to m3u file */ |
787 | void PlayListWidget::writem3u() { | 810 | void PlayListWidget::writem3u() { |
788 | //InputDilog *fileDlg; | ||
789 | //fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | ||
790 | //fileDlg->exec(); | ||
791 | 811 | ||
792 | Config cfg( "OpiePlayer" ); | 812 | Config cfg( "OpiePlayer" ); |
793 | cfg.setGroup("Dialog"); | 813 | cfg.setGroup("Dialog"); |
794 | MimeTypes types; | 814 | MimeTypes types = fileSelectorMimeTypes(); |
795 | QStringList audio, video, all; | ||
796 | audio << "audio/*"; | ||
797 | audio << "playlist/plain"; | ||
798 | audio << "audio/x-mpegurl"; | ||
799 | 815 | ||
800 | video << "video/*"; | 816 | QString str = OFileDialog::getOpenFileName( 1, QString::null, |
801 | video << "playlist/plain"; | 817 | QString::null, types, 0, |
818 | tr( "Save Playlist" )); | ||
802 | 819 | ||
803 | all += audio; | ||
804 | all += video; | ||
805 | types.insert("All Media Files", all ); | ||
806 | types.insert("Audio", audio ); | ||
807 | types.insert("Video", video ); | ||
808 | |||
809 | QString str = OFileDialog::getOpenFileName( 1, | ||
810 | cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", | ||
811 | types, 0 ); | ||
812 | if(str.left(2) == "//") str=str.right(str.length()-1); | 820 | if(str.left(2) == "//") str=str.right(str.length()-1); |
813 | cfg.writeEntry("LastDirectory" ,QFileInfo(str).dirPath()); | ||
814 | |||
815 | 821 | ||
816 | QString name, filename, list; | 822 | QString name, filename, list; |
817 | Om3u *m3uList; | 823 | Om3u *m3uList; |
818 | 824 | ||
@@ -1006,9 +1012,8 @@ QString PlayListWidget::currentFileListPathName() const { | |||
1006 | } | 1012 | } |
1007 | 1013 | ||
1008 | 1014 | ||
1009 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { | 1015 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { |
1010 | odebug << "qcop message "+msg << oendl; | ||
1011 | QDataStream stream ( data, IO_ReadOnly ); | 1016 | QDataStream stream ( data, IO_ReadOnly ); |
1012 | if ( msg == "play()" ) { //plays current selection | 1017 | if ( msg == "play()" ) { //plays current selection |
1013 | btnPlay( true); | 1018 | btnPlay( true); |
1014 | } else if ( msg == "stop()" ) { | 1019 | } else if ( msg == "stop()" ) { |
@@ -1047,4 +1052,15 @@ void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { | |||
1047 | 1052 | ||
1048 | } | 1053 | } |
1049 | 1054 | ||
1050 | } | 1055 | } |
1056 | |||
1057 | DocLnk PlayListWidget::addFileToPlaylist( const QString& file, | ||
1058 | const QString& name ) { | ||
1059 | DocLnk lnk; | ||
1060 | lnk.setName( name ); //sets name | ||
1061 | lnk.setFile( file ); //sets file name | ||
1062 | d->selectedFiles->addToSelection( lnk ); | ||
1063 | writeCurrentM3u(); | ||
1064 | |||
1065 | return lnk; | ||
1066 | } | ||
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h index 29f3e8d..1f5ba92 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.h +++ b/noncore/multimedia/opieplayer2/playlistwidget.h | |||
@@ -109,8 +109,9 @@ private slots: | |||
109 | void writem3u(); | 109 | void writem3u(); |
110 | void writeCurrentM3u(); | 110 | void writeCurrentM3u(); |
111 | void openFile(); | 111 | void openFile(); |
112 | void openURL(); | 112 | void openURL(); |
113 | void openDirectory(); | ||
113 | void setDocument( const QString& fileref ); | 114 | void setDocument( const QString& fileref ); |
114 | void addToSelection( const DocLnk& ); // Add a media file to the playlist | 115 | void addToSelection( const DocLnk& ); // Add a media file to the playlist |
115 | void addToSelection( QListViewItem* ); // Add a media file to the playlist | 116 | void addToSelection( QListViewItem* ); // Add a media file to the playlist |
116 | void clearList(); | 117 | void clearList(); |
@@ -129,8 +130,9 @@ private slots: | |||
129 | void playlistViewPressed( int, QListViewItem *, const QPoint&, int); | 130 | void playlistViewPressed( int, QListViewItem *, const QPoint&, int); |
130 | void playSelected(); | 131 | void playSelected(); |
131 | 132 | ||
132 | private: | 133 | private: |
134 | DocLnk addFileToPlaylist(const QString& directory, const QString& name); | ||
133 | bool fromSetDocument; | 135 | bool fromSetDocument; |
134 | bool insanityBool; | 136 | bool insanityBool; |
135 | QString setDocFileRef, currentPlayList; | 137 | QString setDocFileRef, currentPlayList; |
136 | int selected; | 138 | int selected; |