author | bipolar <bipolar> | 2002-03-03 17:13:17 (UTC) |
---|---|---|
committer | bipolar <bipolar> | 2002-03-03 17:13:17 (UTC) |
commit | a99347380a9006ec81a9dba2340d6aaab690a86e (patch) (side-by-side diff) | |
tree | 73fdc2eff476fba2113172ed881dd64a4031def6 /core/multimedia/opieplayer/playlistwidget.cpp | |
parent | 0e245156b28b70be5cd98a58a9256fe5e2739562 (diff) | |
download | opie-a99347380a9006ec81a9dba2340d6aaab690a86e.zip opie-a99347380a9006ec81a9dba2340d6aaab690a86e.tar.gz opie-a99347380a9006ec81a9dba2340d6aaab690a86e.tar.bz2 |
commited by ljp (llornkcor) reverted to qpe's interface for compatibility. Added playlist features:
save, remove, and have different ones. Uncommented code for background image and added opielogo.
Diffstat (limited to 'core/multimedia/opieplayer/playlistwidget.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 263 |
1 files changed, 188 insertions, 75 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 202f351..7862d8d 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp @@ -19,2 +19,3 @@ **********************************************************************/ +// code added by L. J. Potter Sat 03-02-2002 06:17:54 @@ -42,2 +43,5 @@ #include <qpoint.h> +#include <qlineedit.h> +#include <qpushbutton.h> + //#include <qtimer.h> @@ -48,2 +52,5 @@ +#include "fileBrowser.h" +#include "inputDialog.h" + #include <stdlib.h> @@ -121,7 +128,21 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) bar->setLabel( tr( "Play Operations" ) ); - d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ),"mpegplayer/add_to_playlist",this , SLOT(addSelected()) ); - d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "mpegplayer/remove_from_playlist", this , SLOT(removeSelected()) ); - d->tbPlay = new ToolButton( bar, tr( "Play" ),"mpegplayer/play", mediaPlayerState, SLOT( setPlaying(bool)), TRUE ); - d->tbShuffle = new ToolButton( bar, tr( "Randomize" ), "mpegplayer/shuffle", mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); - d->tbLoop = new ToolButton( bar, tr( "Loop" ),"mpegplayer/loop", mediaPlayerState, SLOT(setLooping(bool)), TRUE ); +// d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "mpegplayer/play_current_list", +// this , SLOT( addSelected()) ); + tbDeletePlaylist = new QPushButton( Resource::loadIconSet("close"),"",bar,"close"); + tbDeletePlaylist->setFlat(TRUE); + tbDeletePlaylist->setFixedSize(20,20); + connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); + + d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "mpegplayer/add_to_playlist", + this , SLOT(addSelected()) ); + d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "mpegplayer/remove_from_playlist", + this , SLOT(removeSelected()) ); +// d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); + d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", + this , SLOT( btnPlay(bool) ), TRUE ); + d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"mpegplayer/shuffle", + mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); + d->tbLoop = new ToolButton( bar, tr( "Loop" ),"mpegplayer/loop", + mediaPlayerState, SLOT(setLooping(bool)), TRUE ); + tbDeletePlaylist->hide(); @@ -134,3 +155,3 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); - new MenuItem( pmPlayList, tr( "Load PlayList" ), this, SLOT( loadList() ) ); + // new MenuItem( pmPlayList, tr( "Load PlayList" ), this, SLOT( loadList() ) ); @@ -230,2 +251,13 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) } + +//playlists list + QWidget *LTab; + 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 @@ -233,17 +265,15 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) -// connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); -// connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); - connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); - connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( addToSelection( 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( rightButtonPressed( QListViewItem *, const QPoint&, int ) ), - this, SLOT( addToSelection( QListViewItem *, const QPoint&, int )) ); - connect( videoView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint&, int ) ), - this, SLOT( addToSelection( QListViewItem *, const QPoint&, int )) ); +// connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); +// connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); + connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); + connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); - // connect( d->files, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); - // connect( d->files, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); @@ -251,10 +281,5 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); - -// connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), fullScreenButton, SLOT( setOn( bool ) ) ); -// connect( mediaPlayerState, SIGNAL( scaledToggled( bool ) ), scaleButton, SLOT( setEnabled( bool ) ) ); -// connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), fullScreenButton, SLOT( setEnabled( bool ) ) ); - connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); - connect( d->selectedFiles, SIGNAL( clicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); + connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); // connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); @@ -289,2 +314,5 @@ void PlayListWidget::initializeStates() { // setPlaylist( mediaPlayerState->playlist() ); + setPlaylist( true); + d->selectedFiles->first(); + } @@ -304,3 +332,2 @@ void PlayListWidget::readConfig( Config& cfg ) { d->selectedFiles->addToSelection( lnk ); - } @@ -341,2 +368,4 @@ void PlayListWidget::writeConfig( Config& cfg ) const { cfg.writeEntry("NumberOfFiles", noOfFiles ); + + } @@ -345,2 +374,3 @@ void PlayListWidget::writeConfig( Config& cfg ) const { void PlayListWidget::addToSelection( const DocLnk& lnk ) { + qDebug("add"); d->setDocumentUsed = FALSE; @@ -353,12 +383,2 @@ void PlayListWidget::addToSelection( const DocLnk& lnk ) { -void PlayListWidget::addToSelection( QListViewItem *it ,const QPoint & p, int index) { - qDebug("add"); -// d->selectedFiles->addToSelection( lnk ); - // } -// else -// mediaPlayerState->setPlaying( TRUE ); -// -} - - void PlayListWidget::clearList() { @@ -428,9 +448,13 @@ void PlayListWidget::useSelectedDocument() { const DocLnk *PlayListWidget::current() { - if ( mediaPlayerState->playlist() ) + +// qDebug("in Playlist widget ::current"); + if ( mediaPlayerState->playlist() ) { return d->selectedFiles->current(); + } else if ( d->setDocumentUsed && d->current ) { return d->current; - } else + } else { return d->files->selected(); } +} @@ -503,5 +527,20 @@ bool PlayListWidget::last() { void PlayListWidget::saveList() { + QString filename; -// pseudo code -// filename = QLineEdit->getText(); + InputDialog *fileDlg; + fileDlg=new InputDialog(this,"Save Playlist",TRUE, 0); + fileDlg->exec(); + if( fileDlg->result() == 1 ) { + filename = fileDlg->LineEdit1->text();//+".playlist"; + qDebug("saving playlist "+filename+".playlist"); + +// DocLnk *lnk; +// lnk.setName( filename); //sets file name +// // lnk.setComment(title); +// lnk.setFile( filename+".playlist"); //sets File property +// lnk.setType("player/plain");// hey is this a REGISTERED mime type?!?!? ;D +// lnk.setIcon("MPEGPlayer"); +// if(!lnk.writeLink()) +// qDebug("Writing doclink did not work"); + Config cfg( filename + ".playlist" ); @@ -509,10 +548,23 @@ void PlayListWidget::saveList() { } + DocLnk lnk; + lnk.setName( filename); //sets file name +// lnk.setComment(title); + lnk.setFile(QPEApplication::qpeDir()+"Settings/"+filename+".playlist.conf"); //sets File property + lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D + lnk.setIcon("MPEGPlayer"); + if(!lnk.writeLink()) + qDebug("Writing doclink did not work"); + if(fileDlg) + delete fileDlg; +} -void PlayListWidget::loadList() { - QString filename; -// pseudo code -// filename = FileSelector->openFile( "*.playlist" ); - Config cfg( filename + ".playlist" ); + +void PlayListWidget::loadList( const DocLnk & lnk) { + + clearList(); + Config cfg( lnk.file()); readConfig( cfg ); + tabWidget->setCurrentPage(0); + setCaption("OpiePlayer: "+lnk.name()); } @@ -536,5 +588,4 @@ void PlayListWidget::setView( char view ) { void PlayListWidget::addSelected() { -// QMessageBox::message("Note","Bozo the clown thinks\nthere's something actually here"); - int tabPage=tabWidget->currentPageIndex(); - switch (tabPage) { + + switch (tabWidget->currentPageIndex()) { case 0: //playlist @@ -559,3 +610,3 @@ void PlayListWidget::playIt( QListViewItem *it) { // d->setDocumentUsed = FALSE; - mediaPlayerState->setPlaying(true); + mediaPlayerState->setPlaying(TRUE); } @@ -566,8 +617,9 @@ void PlayListWidget::addToSelection( QListViewItem *it) { if(it) { - qDebug("add to selection"); - int tabPage=tabWidget->currentPageIndex(); - switch (tabPage) { +// qDebug("add to selection"); + switch (tabWidget->currentPageIndex()) { case 1: { +// qDebug("case 1"); QListIterator<DocLnk> dit( files.children() ); for ( ; dit.current(); ++dit ) { +// qDebug(dit.current()->name()); if( dit.current()->name() == it->text(0)) { @@ -579,5 +631,6 @@ void PlayListWidget::addToSelection( QListViewItem *it) { case 2: { +// qDebug("case 2"); QListIterator<DocLnk> dit( vFiles.children() ); for ( ; dit.current(); ++dit ) { - qDebug(dit.current()->name()); +// qDebug(dit.current()->name()); if( dit.current()->name() == it->text(0)) { @@ -598,6 +651,7 @@ void PlayListWidget::tabChanged(QWidget *widg) { - int tabPage=tabWidget->currentPageIndex(); - switch (tabPage) { + switch ( tabWidget->currentPageIndex()) { case 0: { + if( !tbDeletePlaylist->isHidden()) + tbDeletePlaylist->hide(); d->tbRemoveFromList->setEnabled(TRUE); @@ -608,2 +662,4 @@ void PlayListWidget::tabChanged(QWidget *widg) { { + if( !tbDeletePlaylist->isHidden()) + tbDeletePlaylist->hide(); d->tbRemoveFromList->setEnabled(FALSE); @@ -614,2 +670,4 @@ void PlayListWidget::tabChanged(QWidget *widg) { { + if( !tbDeletePlaylist->isHidden()) + tbDeletePlaylist->hide(); d->tbRemoveFromList->setEnabled(FALSE); @@ -618,2 +676,9 @@ void PlayListWidget::tabChanged(QWidget *widg) { break; + case 3: + { + if( tbDeletePlaylist->isHidden()) + tbDeletePlaylist->show(); + playLists->reread(); + } + break; }; @@ -621,29 +686,77 @@ void PlayListWidget::tabChanged(QWidget *widg) { -// void PlayListWidget::cancelMenuTimer() { -// if( menuTimer->isActive() ) -// menuTimer->stop(); -// } +/* + list is right clicked*/ +void PlayListWidget::fauxPlay(QListViewItem *it) { -// void PlayListWidget::showFileMenu() { - -// } + switch (tabWidget->currentPageIndex()) { + case 0: //playlist + break; + case 1: { //audio + QListIterator<DocLnk> dit( files.children() ); + for ( ; dit.current(); ++dit ) { +// qDebug(dit.current()->name()); + if( dit.current()->name() == it->text(0)) { + d->selectedFiles->addToSelection( **dit ); + } + } + } + break; + case 2: { // video + QListIterator<DocLnk> dit( vFiles.children() ); + for ( ; dit.current(); ++dit ) { +// qDebug(dit.current()->name()); + if( dit.current()->name() == it->text(0)) { + d->selectedFiles->addToSelection( **dit ); + } + } + } + break; + }; + mediaPlayerState->setPlaying( TRUE ); +// tabWidget->setCurrentPage(0); + d->selectedFiles->removeSelected(); +} -// void PlayListWidget::contentsMousePressEvent( QMouseEvent * e ) -// { -// // QListView::contentsMousePressEvent( e ); -// menuTimer->start( 750, TRUE ); -// } +/* + play button is pressed*/ +void PlayListWidget::btnPlay(bool b) { // this is fugly + switch ( tabWidget->currentPageIndex()) { + case 0: + { + mediaPlayerState->setPlaying(b); + } + break; + case 1: + { + addToSelection( audioView->selectedItem() ); + mediaPlayerState->setPlaying(b); + d->selectedFiles->removeSelected( ); + tabWidget->setCurrentPage(1); + } + break; + case 2: + { + addToSelection( videoView->selectedItem() ); + mediaPlayerState->setPlaying(b); + d->selectedFiles->removeSelected( ); + tabWidget->setCurrentPage(2); + } + break; + }; +} -// void PlayListWidget::contentsMouseReleaseEvent( QMouseEvent * e ) -// { -// // QListView::contentsMouseReleaseEvent( e ); -// menuTimer->stop(); -// } -// // void PlayListWidget::setFullScreen() { -// mediaPlayerState->toggleFullscreen( ); -// } +void PlayListWidget::deletePlaylist() { + switch( QMessageBox::information( this, (tr("Remove Playlist?")), + (tr("You really want to delete\nthis playlist?")), + (tr("Yes")), (tr("No")), 0 )){ + case 0: // Yes clicked, + QFile().remove(playLists->selected()->file()); + QFile().remove(playLists->selected()->linkFile()); + playLists->reread(); + break; + case 1: // Cancel + break; + }; -// void PlayListWidget::setScaled() { -// mediaPlayerState->toggleScaled(); -// } +} |