summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp1
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp108
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.h2
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
@@ -159,3 +159,2 @@ void MediaPlayer::next() {
159 } 159 }
160 qApp->processEvents();
161} 160}
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
@@ -87,2 +87,4 @@ PlayListWidget::PlayListWidget(QWidget* parent, const char* name, WFlags fl )
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);
@@ -664,8 +666,3 @@ void PlayListWidget::openURL() {
664 666
665void PlayListWidget::openFile() { 667static MimeTypes fileSelectorMimeTypes() {
666
667 QString filename, name;
668
669 Config cfg( "OpiePlayer" );
670 cfg.setGroup("Dialog");
671 MimeTypes types; 668 MimeTypes types;
@@ -686,24 +683,29 @@ void PlayListWidget::openFile() {
686 683
687 QString str = OFileDialog::getOpenFileName( 1, 684 return types;
688 cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"",
689 types, 0 );
690
691 if(str.left(2) == "//") {
692 str=str.right(str.length()-1);
693 } 685 }
694 cfg.writeEntry( "LastDirectory" ,QFileInfo( str ).dirPath() );
695 686
696 if( !str.isEmpty() ) { 687void PlayListWidget::openFile() {
697 688
698 odebug << "Selected filename is " + str << oendl; 689 QString filename, name;
699 filename = str;
700 DocLnk lnk;
701 690
702 if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { 691 Config cfg( "OpiePlayer" );
703 readListFromFile( filename ); 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
705
706 if( str.right( 3) == "m3u" || str.right(3) == "pls" ) {
707 readListFromFile( str );
704 } else { 708 } else {
705 lnk.setName( QFileInfo(filename).baseName() ); //sets name 709 QFileInfo info( str );
706 lnk.setFile( filename ); //sets file name 710 DocLnk lnk = addFileToPlaylist( str, info.baseName() );
707 d->selectedFiles->addToSelection( lnk );
708 writeCurrentM3u();
709 d->selectedFiles->setSelectedItem( lnk.name() ); 711 d->selectedFiles->setSelectedItem( lnk.name() );
@@ -711,4 +713,25 @@ void PlayListWidget::openFile() {
711 } 713 }
712}
713 714
715void PlayListWidget::openDirectory() {
716 QString str = OFileDialog::getDirectory( OFileSelector::DirectorySelector,
717 QString::null, 0,
718 tr( "Add Files from Directory"));
719
720 if(str.isEmpty() )
721 return;
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);
726
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" )
731 readListFromFile( filename );
732 else {
733 addFileToPlaylist( filename, QFileInfo(*it).baseName() );
734 }
735 }
736}
714 737
@@ -787,5 +810,2 @@ void PlayListWidget::readListFromFile( const QString &filename ) {
787void PlayListWidget::writem3u() { 810void PlayListWidget::writem3u() {
788 //InputDilog *fileDlg;
789 //fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
790 //fileDlg->exec();
791 811
@@ -793,23 +813,9 @@ void PlayListWidget::writem3u() {
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
@@ -1009,3 +1015,2 @@ QString PlayListWidget::currentFileListPathName() const {
1009void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { 1015void 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 );
@@ -1050 +1055,12 @@ void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) {
1050} 1055}
1056
1057DocLnk 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
@@ -112,2 +112,3 @@ private slots:
112 void openURL(); 112 void openURL();
113 void openDirectory();
113 void setDocument( const QString& fileref ); 114 void setDocument( const QString& fileref );
@@ -132,2 +133,3 @@ private slots:
132private: 133private:
134 DocLnk addFileToPlaylist(const QString& directory, const QString& name);
133 bool fromSetDocument; 135 bool fromSetDocument;