-rw-r--r-- | core/multimedia/opieplayer/main.cpp | 2 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 48 |
2 files changed, 37 insertions, 13 deletions
diff --git a/core/multimedia/opieplayer/main.cpp b/core/multimedia/opieplayer/main.cpp index 4f43ff6..18cd7a6 100644 --- a/core/multimedia/opieplayer/main.cpp +++ b/core/multimedia/opieplayer/main.cpp @@ -46,9 +46,9 @@ int main(int argc, char **argv) { LoopControl lc( 0, "loopControl" ); loopControl = &lc; MediaPlayer mp( 0, "mediaPlayer" ); - pl.setCaption( MediaPlayer::tr("OpiePlayer") ); +// pl.setCaption( MediaPlayer::tr("OpiePlayer") ); a.showMainDocumentWidget(&pl); return a.exec(); } diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index cb58888..9969526 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp @@ -17,9 +17,8 @@ ** not clear to you. ** **********************************************************************/ // code added by L. J. Potter Sat 03-02-2002 06:17:54 - #include <qpe/qpemenubar.h> #include <qpe/qpetoolbar.h> #include <qpe/fileselector.h> #include <qpe/qpeapplication.h> @@ -255,20 +254,21 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) LTab = new QWidget( tabWidget, "LTab" ); playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy playLists->setMinimumSize(233,260);; tabWidget->insertTab(LTab,"Lists"); + connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); // connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); // add the library area QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); - connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), - this, SLOT( fauxPlay( QListViewItem *) ) ); - connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), - this, SLOT( fauxPlay( QListViewItem *)) ); +// connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), +// this, SLOT( fauxPlay( QListViewItem *) ) ); +// connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), +// this, SLOT( fauxPlay( QListViewItem *)) ); // connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); // connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); @@ -287,8 +287,12 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) setCentralWidget( vbox5 ); Config cfg( "MediaPlayer" ); readConfig( cfg ); + QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); +// qDebug("currentList is "+currentPlaylist); + loadList(DocLnk( currentPlaylist)); + setCaption("OpiePlayer: "+ currentPlaylist ); initializeStates(); } @@ -296,8 +300,9 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) PlayListWidget::~PlayListWidget() { Config cfg( "MediaPlayer" ); writeConfig( cfg ); + if ( d->current ) delete d->current; delete d; } @@ -313,9 +318,8 @@ void PlayListWidget::initializeStates() { // d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); // setPlaylist( mediaPlayerState->playlist() ); setPlaylist( true); d->selectedFiles->first(); - } void PlayListWidget::readConfig( Config& cfg ) { @@ -371,9 +375,9 @@ void PlayListWidget::writeConfig( Config& cfg ) const { } void PlayListWidget::addToSelection( const DocLnk& lnk ) { - qDebug("add"); +// qDebug("add"); d->setDocumentUsed = FALSE; if ( mediaPlayerState->playlist() ) d->selectedFiles->addToSelection( lnk ); else @@ -418,8 +422,9 @@ void PlayListWidget::setDocument(const QString& fileref) { if ( fileref.isNull() ) { QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); return; } +// qDebug("setDocument"); if(fileref.find("playlist",0,TRUE) == -1) { addToSelection( DocLnk( fileref ) ); d->setDocumentUsed = TRUE; qApp->processEvents(); @@ -535,12 +540,21 @@ void PlayListWidget::saveList() { InputDialog *fileDlg; fileDlg=new InputDialog(this,"Save Playlist",TRUE, 0); fileDlg->exec(); if( fileDlg->result() == 1 ) { + if ( d->current ) + delete d->current; filename = fileDlg->LineEdit1->text();//+".playlist"; - qDebug("saving playlist "+filename+".playlist"); +// qDebug("saving playlist "+filename+".playlist"); Config cfg( filename +".playlist"); writeConfig( cfg ); + if( playLists->selected()->name() == filename) { +// qDebug("same name so delete lnk"); + QFile().remove(playLists->selected()->file()); + QFile().remove(playLists->selected()->linkFile()); + playLists->reread(); + } + DocLnk lnk; // lnk.setComment( ""); lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D @@ -548,22 +562,32 @@ void PlayListWidget::saveList() { lnk.setName( filename); //sets file name if(!lnk.writeLink()) qDebug("Writing doclink did not work"); } - + Config config( "MediaPlayer" ); + config.writeEntry("CurrentPlaylist",filename); + setCaption("OpiePlayer: "+filename); + d->selectedFiles->first(); if(fileDlg) delete fileDlg; } void PlayListWidget::loadList( const DocLnk & lnk) { - qDebug("load list "+ lnk.name()+".playlist"); + QString name= lnk.name(); +// qDebug("currentList is "+name); + if( name.length()>1) { + setCaption("OpiePlayer: "+name); +// qDebug("load list "+ name+".playlist"); clearList(); - Config cfg( lnk.name()+".playlist"); + Config cfg( name+".playlist"); readConfig(cfg); tabWidget->setCurrentPage(0); - setCaption("OpiePlayer: "+lnk.name()); + Config config( "MediaPlayer" ); + config.writeEntry("CurrentPlaylist", name); + d->selectedFiles->first(); + } } void PlayListWidget::setPlaylist( bool shown ) { |