summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp57
-rw-r--r--core/multimedia/opieplayer/playlistwidget.h2
2 files changed, 45 insertions, 14 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index eeaed33..ae25fe3 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -156,50 +156,51 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
// this , SLOT( addSelected()) );
tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close");
tbDeletePlaylist->setFlat(TRUE);
tbDeletePlaylist->setFixedSize(20,20);
d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist",
this , SLOT(addSelected()) );
d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist",
this , SLOT(removeSelected()) );
// d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE );
d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play",
this , SLOT( btnPlay(bool) ), TRUE );
d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle",
mediaPlayerState, SLOT(setShuffled(bool)), TRUE );
d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop",
mediaPlayerState, SLOT(setLooping(bool)), TRUE );
tbDeletePlaylist->hide();
QPopupMenu *pmPlayList = new QPopupMenu( this );
menu->insertItem( tr( "File" ), pmPlayList );
new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) );
new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) );
new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) );
-// pmPlayList->insertSeparator(-1);
+ pmPlayList->insertSeparator(-1);
new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) );
+ new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) );
pmPlayList->insertSeparator(-1);
new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) );
pmPlayList->insertSeparator(-1);
new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) );
new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) );
QPopupMenu *pmView = new QPopupMenu( this );
menu->insertItem( tr( "View" ), pmView );
fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0);
fullScreenButton->addTo(pmView);
scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0);
scaleButton->addTo(pmView);
QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton );
QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton );
QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton );
tabWidget = new QTabWidget( hbox6, "tabWidget" );
tabWidget->setTabShape(QTabWidget::Triangular);
QWidget *pTab;
pTab = new QWidget( tabWidget, "pTab" );
@@ -831,57 +832,55 @@ void PlayListWidget::tabChanged(QWidget *widg) {
videoView->clear();
populateVideoView();
if( !tbDeletePlaylist->isHidden())
tbDeletePlaylist->hide();
d->tbRemoveFromList->setEnabled(FALSE);
d->tbAddToList->setEnabled(TRUE);
}
break;
case 3:
{
if( tbDeletePlaylist->isHidden())
tbDeletePlaylist->show();
playLists->reread();
}
break;
};
}
void PlayListWidget::btnPlay(bool b) {
// mediaPlayerState->setPlaying(b);
switch ( tabWidget->currentPageIndex()) {
case 0:
{
- qDebug("here we are");
- if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1
- || d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) {
+// if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1
+// if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) {
QMessageBox::message("Note","You are trying to play\na malformed url.");
-
- } else {
-
+// } else {
mediaPlayerState->setPlaying(b);
- } }
+// }
+ }
break;
case 1:
{
addToSelection( audioView->currentItem() );
mediaPlayerState->setPlaying(b);
d->selectedFiles->removeSelected( );
tabWidget->setCurrentPage(1);
d->selectedFiles->unSelect();
insanityBool=FALSE;
}// audioView->clearSelection();
break;
case 2:
{
addToSelection( videoView->currentItem() );
mediaPlayerState->setPlaying(b);
qApp->processEvents();
d->selectedFiles->removeSelected( );
tabWidget->setCurrentPage(2);
d->selectedFiles->unSelect();
insanityBool=FALSE;
}// videoView->clearSelection();
break;
};
@@ -1248,74 +1247,106 @@ void PlayListWidget::readm3u(const QString &filename) {
else
name=s;
// name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1);
lnk.setName(name);
if(s.at(s.length()-4) == '.')
lnk.setFile( s);
else
lnk.setFile( s+"/");
// lnk.setFile( filename);
// lnk.setComment( s+"/");
lnk.setType("audio/x-mpegurl");
lnk.writeLink();
// lnk.setIcon( "opieplayer/MPEGPlayer");
// qDebug("add "+s);
d->selectedFiles->addToSelection( lnk);
}
i++;
}
}
}
}
f.close();
}
-void PlayListWidget::writem3u(const QString &filename) {
+void PlayListWidget::writem3u() {
+
+ InputDialog *fileDlg;
+ fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0);
+ fileDlg->exec();
+ QString filename,list;
+ if( fileDlg->result() == 1 ) {
+ filename = fileDlg->LineEdit1->text();
+ qDebug(filename);
+ int noOfFiles = 0;
+ d->selectedFiles->first();
+ do {
+// we dont check for existance because of url's
+// qDebug(d->selectedFiles->current()->file());
+ list += d->selectedFiles->current()->file()+"\n";
+ noOfFiles++;
+ }
+ while ( d->selectedFiles->next() );
+ qDebug(list);
+ if(filename.left(1) != "/")
+ filename=QPEApplication::documentDir()+"/"+filename;
+ if(filename.right(3) != "m3u")
+ filename=filename+".m3u";
+ QFile f(filename);
+ f.open(IO_WriteOnly);
+ f.writeBlock(list, list.length());
+ f.close();
+ }
+ if(fileDlg) delete fileDlg;
}
void PlayListWidget::readPls(const QString &filename) {
qDebug("pls filename is "+filename);
QFile f(filename);
if(f.open(IO_ReadOnly)) {
QTextStream t(&f);
QString s;//, first, second;
int i=0;
while ( !t.atEnd()) {
s=t.readLine();
if(s.left(4) == "File") {
s=s.right(s.length() - 6);
s.replace(QRegExp("%20")," ");
qDebug("adding "+s+" to playlist");
// numberofentries=2
// File1=http
// Title
// Length
// Version
// File2=http
s=s.replace( QRegExp("\\"),"/");
-// Lview->insertLine(t.readLine(),-1);
-// s=t.readLine();
-// s=s.right(s.length()-2);
DocLnk lnk( s );
QFileInfo f(s);
QString name = f.baseName();
+ if(name.left(4)=="http")
+ name = s.right( s.length() - 7);
+ else
+ name=s;
name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1);
// QFileInfo f(s);
// QString name = f.baseName();
-// // name = name.left(name.length()-4);
+// name = name.left(name.length()-4);
// name = name.right(name.findRev("/",0,TRUE));
lnk.setName( name);
+ if(s.at(s.length()-4) == '.')
+ lnk.setFile( s);
+ else
lnk.setFile( s+"/");
lnk.setType("audio/x-mpegurl");
qDebug("DocLnk add "+name);
d->selectedFiles->addToSelection( lnk);
}
}
i++;
}
}
diff --git a/core/multimedia/opieplayer/playlistwidget.h b/core/multimedia/opieplayer/playlistwidget.h
index 5837ed3..7718a8c 100644
--- a/core/multimedia/opieplayer/playlistwidget.h
+++ b/core/multimedia/opieplayer/playlistwidget.h
@@ -54,59 +54,59 @@ public:
// retrieve the current playlist entry (media file link)
const DocLnk *current();
void useSelectedDocument();
/* QTimer * menuTimer; */
FileSelector* playLists;
QPushButton *tbDeletePlaylist;
int fd, selected;
public slots:
bool first();
bool last();
bool next();
bool prev();
/* void setFullScreen(); */
/* void setScaled(); */
protected:
/* void contentsMousePressEvent( QMouseEvent * e ); */
/* void contentsMouseReleaseEvent( QMouseEvent * e ); */
void keyReleaseEvent( QKeyEvent *e);
void keyPressEvent( QKeyEvent *e);
private:
bool audioScan, videoScan;
void doBlank();
void doUnblank();
void readm3u(const QString &);
- void writem3u(const QString &);
void readPls(const QString &);
void initializeStates();
void readConfig( Config& cfg );
void writeConfig( Config& cfg ) const;
PlayListWidgetPrivate *d; // Private implementation data
void populateAudioView();
void populateVideoView();
private slots:
+ void writem3u();
void scanForAudio();
void scanForVideo();
void openFile();
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
void setActiveWindow(); // need to handle this to show the right view
void setPlaylist( bool ); // Show/Hide the playlist
void setView( char );
void clearList();
void addAllToList();
void addAllMusicToList();
void addAllVideoToList();
void saveList(); // Save the playlist
void loadList( const DocLnk &); // Load a playlist
void playIt( QListViewItem *);
void btnPlay(bool);
void deletePlaylist();
void addSelected();
void removeSelected();
void tabChanged(QWidget*);
void viewPressed( int, QListViewItem *, const QPoint&, int);
void playlistViewPressed( int, QListViewItem *, const QPoint&, int);