summaryrefslogtreecommitdiff
Side-by-side diff
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
@@ -157,7 +157,6 @@ void MediaPlayer::next() {
if(l) mediaPlayerState.setLooping(l);
if(r) mediaPlayerState.setShuffled(r);
}
- qApp->processEvents();
}
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
@@ -85,6 +85,8 @@ PlayListWidget::PlayListWidget(QWidget* parent, const char* name, WFlags fl )
this,SLOT( openFile() ) );
(void)new MenuItem( pmPlayList, tr("Add URL"),
this,SLOT( openURL() ) );
+ (void)new MenuItem( pmPlayList, tr( "Add Directory"),
+ this, SLOT(openDirectory()));
pmPlayList->insertSeparator(-1);
(void)new MenuItem( pmPlayList, tr( "Save Playlist" ),
this, SLOT(writem3u() ) );
@@ -662,12 +664,7 @@ void PlayListWidget::openURL() {
}
-void PlayListWidget::openFile() {
-
- QString filename, name;
-
- Config cfg( "OpiePlayer" );
- cfg.setGroup("Dialog");
+static MimeTypes fileSelectorMimeTypes() {
MimeTypes types;
QStringList audio, video, all;
audio << "audio/*";
@@ -684,33 +681,59 @@ void PlayListWidget::openFile() {
types.insert("Audio", audio );
types.insert("Video", video );
- QString str = OFileDialog::getOpenFileName( 1,
- cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"",
- types, 0 );
-
- if(str.left(2) == "//") {
- str=str.right(str.length()-1);
+ return types;
}
- cfg.writeEntry( "LastDirectory" ,QFileInfo( str ).dirPath() );
- if( !str.isEmpty() ) {
+void PlayListWidget::openFile() {
- odebug << "Selected filename is " + str << oendl;
- filename = str;
- DocLnk lnk;
+ QString filename, name;
- if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) {
- readListFromFile( filename );
+ Config cfg( "OpiePlayer" );
+ cfg.setGroup("Dialog");
+ MimeTypes types = fileSelectorMimeTypes();
+
+
+ QString str = OFileDialog::getOpenFileName( 1, QString::null,
+ QString::null, types, 0,
+ tr("Add File to Playlist") );
+
+ if( str.isEmpty() )
+ return;
+
+ if(str.left(2) == "//") str=str.right(str.length()-1);
+
+
+ if( str.right( 3) == "m3u" || str.right(3) == "pls" ) {
+ readListFromFile( str );
} else {
- lnk.setName( QFileInfo(filename).baseName() ); //sets name
- lnk.setFile( filename ); //sets file name
- d->selectedFiles->addToSelection( lnk );
- writeCurrentM3u();
+ QFileInfo info( str );
+ DocLnk lnk = addFileToPlaylist( str, info.baseName() );
d->selectedFiles->setSelectedItem( lnk.name() );
}
}
-}
+void PlayListWidget::openDirectory() {
+ QString str = OFileDialog::getDirectory( OFileSelector::DirectorySelector,
+ QString::null, 0,
+ tr( "Add Files from Directory"));
+
+ if(str.isEmpty() )
+ return;
+
+ if(str.left(2) == "//") str=str.right(str.length()-1);
+ QDir dir( str );
+ QStringList lst = dir.entryList(QDir::Files|QDir::Readable);
+
+ for ( QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) {
+ QString filename = str + "/" + *it;
+
+ if( filename.right( 3) == "m3u" || filename.right(3) == "pls" )
+ readListFromFile( filename );
+ else {
+ addFileToPlaylist( filename, QFileInfo(*it).baseName() );
+ }
+ }
+}
void PlayListWidget::readListFromFile( const QString &filename ) {
odebug << "read list filename " + filename << oendl;
@@ -785,33 +808,16 @@ void PlayListWidget::readListFromFile( const QString &filename ) {
/*
writes current playlist to m3u file */
void PlayListWidget::writem3u() {
- //InputDilog *fileDlg;
- //fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
- //fileDlg->exec();
Config cfg( "OpiePlayer" );
cfg.setGroup("Dialog");
- MimeTypes types;
- QStringList audio, video, all;
- audio << "audio/*";
- audio << "playlist/plain";
- audio << "audio/x-mpegurl";
+ MimeTypes types = fileSelectorMimeTypes();
- video << "video/*";
- video << "playlist/plain";
+ QString str = OFileDialog::getOpenFileName( 1, QString::null,
+ QString::null, types, 0,
+ tr( "Save Playlist" ));
- all += audio;
- all += video;
- types.insert("All Media Files", all );
- types.insert("Audio", audio );
- types.insert("Video", video );
-
- QString str = OFileDialog::getOpenFileName( 1,
- cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"",
- types, 0 );
if(str.left(2) == "//") str=str.right(str.length()-1);
- cfg.writeEntry("LastDirectory" ,QFileInfo(str).dirPath());
-
QString name, filename, list;
Om3u *m3uList;
@@ -1007,7 +1013,6 @@ QString PlayListWidget::currentFileListPathName() const {
void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) {
- odebug << "qcop message "+msg << oendl;
QDataStream stream ( data, IO_ReadOnly );
if ( msg == "play()" ) { //plays current selection
btnPlay( true);
@@ -1048,3 +1053,14 @@ void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) {
}
}
+
+DocLnk PlayListWidget::addFileToPlaylist( const QString& file,
+ const QString& name ) {
+ DocLnk lnk;
+ lnk.setName( name ); //sets name
+ lnk.setFile( file ); //sets file name
+ d->selectedFiles->addToSelection( lnk );
+ writeCurrentM3u();
+
+ return lnk;
+}
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
@@ -110,6 +110,7 @@ private slots:
void writeCurrentM3u();
void openFile();
void openURL();
+ void openDirectory();
void setDocument( const QString& fileref );
void addToSelection( const DocLnk& ); // Add a media file to the playlist
void addToSelection( QListViewItem* ); // Add a media file to the playlist
@@ -130,6 +131,7 @@ private slots:
void playSelected();
private:
+ DocLnk addFileToPlaylist(const QString& directory, const QString& name);
bool fromSetDocument;
bool insanityBool;
QString setDocFileRef, currentPlayList;