author | zecke <zecke> | 2004-09-24 16:03:38 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-09-24 16:03:38 (UTC) |
commit | 0b9478d52735eb62a4ead580344b989ecf03d356 (patch) (side-by-side diff) | |
tree | 1f95262623d3513dc6a061a62be65f891d023217 | |
parent | 2911cb18af1fad00bc3557cffe2d2d2ec3a9d346 (diff) | |
download | opie-0b9478d52735eb62a4ead580344b989ecf03d356.zip opie-0b9478d52735eb62a4ead580344b989ecf03d356.tar.gz opie-0b9478d52735eb62a4ead580344b989ecf03d356.tar.bz2 |
-remove qApp->processEvents when starting playing
Revamp Adding Files and Add Directory
-Remove custom code to save the last Directory Used
-Share MimeType creating code
-Add Method to add a File to the Playlist and use it
for AddFile and Add Directory
-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 @@ -159,3 +159,2 @@ void MediaPlayer::next() { } - 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 @@ -87,2 +87,4 @@ PlayListWidget::PlayListWidget(QWidget* parent, const char* name, WFlags fl ) this,SLOT( openURL() ) ); + (void)new MenuItem( pmPlayList, tr( "Add Directory"), + this, SLOT(openDirectory())); pmPlayList->insertSeparator(-1); @@ -664,8 +666,3 @@ void PlayListWidget::openURL() { -void PlayListWidget::openFile() { - - QString filename, name; - - Config cfg( "OpiePlayer" ); - cfg.setGroup("Dialog"); +static MimeTypes fileSelectorMimeTypes() { MimeTypes types; @@ -686,25 +683,52 @@ void PlayListWidget::openFile() { - QString str = OFileDialog::getOpenFileName( 1, - cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", - types, 0 ); + return types; +} + +void PlayListWidget::openFile() { + + QString filename, name; + + 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.left(2) == "//") { - str=str.right(str.length()-1); + if( str.right( 3) == "m3u" || str.right(3) == "pls" ) { + readListFromFile( str ); + } else { + QFileInfo info( str ); + DocLnk lnk = addFileToPlaylist( str, info.baseName() ); + d->selectedFiles->setSelectedItem( lnk.name() ); } - cfg.writeEntry( "LastDirectory" ,QFileInfo( str ).dirPath() ); +} - if( !str.isEmpty() ) { +void PlayListWidget::openDirectory() { + QString str = OFileDialog::getDirectory( OFileSelector::DirectorySelector, + QString::null, 0, + tr( "Add Files from Directory")); - odebug << "Selected filename is " + str << oendl; - filename = str; - DocLnk lnk; + 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); - if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { + 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 { - lnk.setName( QFileInfo(filename).baseName() ); //sets name - lnk.setFile( filename ); //sets file name - d->selectedFiles->addToSelection( lnk ); - writeCurrentM3u(); - d->selectedFiles->setSelectedItem( lnk.name() ); + else { + addFileToPlaylist( filename, QFileInfo(*it).baseName() ); } @@ -713,3 +737,2 @@ void PlayListWidget::openFile() { - void PlayListWidget::readListFromFile( const QString &filename ) { @@ -787,5 +810,2 @@ void PlayListWidget::readListFromFile( const QString &filename ) { void PlayListWidget::writem3u() { - //InputDilog *fileDlg; - //fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); - //fileDlg->exec(); @@ -793,23 +813,9 @@ void PlayListWidget::writem3u() { 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()); - @@ -1009,3 +1015,2 @@ QString PlayListWidget::currentFileListPathName() const { void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { - odebug << "qcop message "+msg << oendl; QDataStream stream ( data, IO_ReadOnly ); @@ -1050 +1055,12 @@ 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 @@ -112,2 +112,3 @@ private slots: void openURL(); + void openDirectory(); void setDocument( const QString& fileref ); @@ -132,2 +133,3 @@ private slots: private: + DocLnk addFileToPlaylist(const QString& directory, const QString& name); bool fromSetDocument; |