Diffstat (limited to 'core/multimedia/opieplayer/playlistwidget.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 142 |
1 files changed, 57 insertions, 85 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 7ea95ab..1fc7dd8 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp @@ -308,5 +308,5 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) QWidget *LTab; LTab = new QWidget( tabWidget, "LTab" ); - playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy + playLists = new FileSelector( "playlist/plain;audio/x-mpegurl", LTab, "fileselector" , FALSE, FALSE); QGridLayout *layoutL = new QGridLayout( LTab ); @@ -314,5 +314,4 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) layoutL->setMargin( 2); layoutL->addMultiCellWidget( playLists, 0, 0, 0, 1 ); -// playLists->setMinimumSize(233,260); tabWidget->insertTab(LTab,tr("Lists")); @@ -359,10 +358,10 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) Config cfg( "OpiePlayer" ); readConfig( cfg ); - QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); - loadList(DocLnk( currentPlaylist)); - setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlaylist))); + + currentPlayList = cfg.readEntry("CurrentPlaylist","default"); + loadList(DocLnk( currentPlayList)); + setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlayList))); initializeStates(); - // audioUI->setFocus(); } @@ -422,13 +421,14 @@ void PlayListWidget::writeConfig( Config& cfg ) const { // the way writing lnks doesn't really check for out // of disk space, but check it anyway. - if ( !lnk->writeLink() ) { - QMessageBox::critical( 0, tr("Out of space"), - tr( "There was a problem saving " - "the playlist.\n" - "Your playlist " - "may be missing some entries\n" - "the next time you start it." ) - ); - } +// if ( !lnk->writeLink() ) { +// QMessageBox::critical( 0, tr("Out of space"), +// tr( "There was a problem saving " +// "the playlist.\n" +// "Your playlist " +// "may be missing some entries\n" +// "the next time you start it." ) +// ); +// } + } noOfFiles++; @@ -448,4 +448,5 @@ void PlayListWidget::addToSelection( const DocLnk& lnk ) { else mediaPlayerState->setPlaying( true); + } @@ -454,4 +455,9 @@ void PlayListWidget::clearList() { while ( first() ) d->selectedFiles->removeSelected(); + Config cfg( "OpiePlayer" ); + cfg.setGroup("PlayList"); + cfg.writeEntry("CurrentPlaylist",""); + currentPlayList=""; + } @@ -498,12 +504,11 @@ void PlayListWidget::setDocument(const QString& fileref) { fromSetDocument = true; d->setDocumentUsed = TRUE; - d->selectedFiles->setSelected(d->selectedFiles->firstChild(),true ); - mediaPlayerState->setPlaying( FALSE ); - qApp->processEvents(); - mediaPlayerState->setPlaying( TRUE ); + setDocumentEx(fileref); } void PlayListWidget::setDocumentEx(const QString& fileref) { - + qDebug("opieplayer receive "+fileref); + clearList(); + DocLnk lnk; QFileInfo fileInfo(fileref); if ( !fileInfo.exists() ) { @@ -512,5 +517,5 @@ void PlayListWidget::setDocumentEx(const QString& fileref) { return; } - qDebug("setDocument "+fileref); + // qDebug("<<<<<<<<<<<<<<<<<<<<<<setDocument "+fileref); QString extension = fileInfo.extension(false); if( extension.find( "m3u", 0, false) != -1) { //is m3u @@ -522,7 +527,7 @@ void PlayListWidget::setDocumentEx(const QString& fileref) { else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist clearList(); - DocLnk lnk; lnk.setName( fileInfo.baseName() ); //sets name lnk.setFile( fileref ); //sets file name + lnk.setIcon("Sound"); //addToSelection( lnk ); @@ -530,23 +535,29 @@ void PlayListWidget::setDocumentEx(const QString& fileref) { d->selectedFiles->first(); } else { - clearList(); - DocLnk lnk; + if( fileref.find(".desktop",0,TRUE) != -1) { + lnk = DocLnk(fileref); + } else { lnk.setName( fileInfo.baseName() ); //sets name lnk.setFile( fileref ); //sets file name + lnk.setIcon("Sound"); + } + addToSelection( lnk ); // addToSelection( DocLnk( fileref ) ); + lnk.removeLinkFile(); + // qApp->processEvents(); + } + setCaption(tr("OpiePlayer")); d->setDocumentUsed = TRUE; + d->selectedFiles->setSelected(d->selectedFiles->firstChild(),true ); mediaPlayerState->setPlaying( FALSE ); qApp->processEvents(); mediaPlayerState->setPlaying( TRUE ); - // qApp->processEvents(); - setCaption(tr("OpiePlayer")); - } + } void PlayListWidget::setActiveWindow() { - qDebug("SETTING active window"); - + // qDebug("SETTING active window"); // When we get raised we need to ensure that it switches views char origView = mediaPlayerState->view(); @@ -562,24 +573,8 @@ void PlayListWidget::useSelectedDocument() { const DocLnk *PlayListWidget::current() { // this is fugly - -// if( fromSetDocument) { -// qDebug("from setDoc"); -// DocLnkSet files; -// Global::findDocuments(&files, "video/*;audio/*"); -// QListIterator<DocLnk> dit( files.children() ); -// for ( ; dit.current(); ++dit ) { -// if(dit.current()->linkFile() == setDocFileRef) { -// qDebug(setDocFileRef); -// return dit; -// } -// } -// } else - - qDebug("current"); - switch (tabWidget->currentPageIndex()) { case 0: //playlist { - qDebug("playlist"); + // qDebug("playlist"); if ( mediaPlayerState->playlist() ) { return d->selectedFiles->current(); @@ -594,9 +589,8 @@ const DocLnk *PlayListWidget::current() { // this is fugly case 1://audio { - qDebug("audioView"); + // qDebug("audioView"); QListIterator<DocLnk> dit( files.children() ); for ( ; dit.current(); ++dit ) { if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { - qDebug("here"); insanityBool=TRUE; return dit; @@ -607,5 +601,4 @@ const DocLnk *PlayListWidget::current() { // this is fugly case 2: // video { - qDebug("videoView"); QListIterator<DocLnk> Vdit( vFiles.children() ); for ( ; Vdit.current(); ++Vdit ) { @@ -718,5 +711,4 @@ void PlayListWidget::setView( char view ) { void PlayListWidget::addSelected() { - qDebug("addSelected"); DocLnk lnk; QString filename; @@ -768,5 +760,4 @@ void PlayListWidget::playIt( QListViewItem *) { // d->setDocumentUsed = FALSE; // mediaPlayerState->curPosition =0; - qDebug("playIt"); // mediaPlayerState->setPlaying(FALSE); mediaPlayerState->setPlaying(TRUE); @@ -842,10 +833,8 @@ void PlayListWidget::tabChanged(QWidget *) { void PlayListWidget::btnPlay(bool b) { - qDebug("<<<<<<<<<<<<<<<BtnPlay %d", b); // mediaPlayerState->setPlaying(b); switch ( tabWidget->currentPageIndex()) { case 0: { - qDebug("1"); // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { @@ -860,5 +849,4 @@ void PlayListWidget::btnPlay(bool b) { case 1: { - qDebug("2"); // d->selectedFiles->unSelect(); addToSelection( audioView->currentItem() ); @@ -872,5 +860,4 @@ void PlayListWidget::btnPlay(bool b) { case 2: { - qDebug("3"); addToSelection( videoView->currentItem() ); @@ -923,5 +910,4 @@ void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int void PlayListWidget::playSelected() { - qDebug("playSelected"); btnPlay( true); // d->selectedFiles->unSelect(); @@ -950,5 +936,5 @@ void PlayListWidget::listDelete() { Config cfg( "OpiePlayer" ); cfg.setGroup("PlayList"); - QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); + currentPlayList = cfg.readEntry("CurrentPlaylist",""); QString file; // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); @@ -1074,5 +1060,4 @@ void PlayListWidget::populateVideoView() { void PlayListWidget::openFile() { - qDebug("<<<<<<<<<OPEN File"); QString filename, name; InputDialog *fileDlg; @@ -1081,6 +1066,5 @@ void PlayListWidget::openFile() { if( fileDlg->result() == 1 ) { filename = fileDlg->text(); - qDebug( "Selected filename is " + filename ); -// Om3u *m3uList; + // qDebug( "Selected filename is " + filename ); DocLnk lnk; Config cfg( "OpiePlayer" ); @@ -1092,5 +1076,4 @@ void PlayListWidget::openFile() { if(filename.find(":",8,TRUE) != -1) { //found a port -// m3uFile = filename.left( filename.find( ":",8,TRUE)); m3uFile = filename; if( m3uFile.right( 1 ).find( '/' ) == -1) { @@ -1098,13 +1081,5 @@ void PlayListWidget::openFile() { } filename = m3uFile; -// qDebug("1 "+m3uFile); -// } else if(filename.left(4) == "http"){ -// m3uFile=filename; -// m3uFile = m3uFile.right( m3uFile.length() - 7); -// qDebug("2 "+m3uFile); -// } else{ -// m3uFile=filename; -// qDebug("3 "+m3uFile); - } + = } lnk.setName( m3uFile ); //sets name lnk.setFile( filename ); //sets file name @@ -1122,4 +1097,5 @@ void PlayListWidget::openFile() { lnk.setFile( filename ); //sets file name d->selectedFiles->addToSelection( lnk); + lnk.removeLinkFile(); writeCurrentM3u(); } @@ -1135,5 +1111,5 @@ void PlayListWidget::openFile() { reads m3u and shows files/urls to playlist widget */ void PlayListWidget::readm3u( const QString &filename ) { - qDebug( "read m3u filename " + filename ); + // qDebug( "read m3u filename " + filename ); Om3u *m3uList; @@ -1192,5 +1168,5 @@ reads pls and adds files/urls to playlist */ void PlayListWidget::readPls( const QString &filename ) { - qDebug( "pls filename is " + filename ); + // qDebug( "pls filename is " + filename ); Om3u *m3uList; QString s, name; @@ -1235,18 +1211,18 @@ void PlayListWidget::readPls( const QString &filename ) { writes current playlist to current m3u file */ void PlayListWidget::writeCurrentM3u() { - qDebug("writing to current m3u"); + // qDebug("writing to current m3u"); Config cfg( "OpiePlayer" ); cfg.setGroup("PlayList"); - QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); + currentPlayList = cfg.readEntry("CurrentPlaylist",""); Om3u *m3uList; - m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); + m3uList = new Om3u( currentPlayList, IO_ReadWrite | IO_Truncate ); if( d->selectedFiles->first()) { do { - qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); + // qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); m3uList->add( d->selectedFiles->current()->file() ); } while ( d->selectedFiles->next() ); - qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); + // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); m3uList->write(); m3uList->close(); @@ -1305,5 +1281,5 @@ void PlayListWidget::writem3u() { if(!lnk.writeLink()) { - qDebug("Writing doclink did not work"); + // qDebug("Writing doclink did not work"); } @@ -1335,5 +1311,4 @@ void PlayListWidget::keyReleaseEvent( QKeyEvent *e) break; case Key_Q: //add to playlist - qDebug("Add"); addSelected(); break; @@ -1346,5 +1321,4 @@ void PlayListWidget::keyReleaseEvent( QKeyEvent *e) // break; case Key_Space: - qDebug("Play"); // playSelected(); puh break; @@ -1399,5 +1373,5 @@ void PlayListWidget::keyPressEvent( QKeyEvent *) void PlayListWidget::doBlank() { - qDebug("do blanking"); + // qDebug("do blanking"); fd=open("/dev/fb0",O_RDWR); if (fd != -1) { @@ -1411,5 +1385,5 @@ void PlayListWidget::doUnblank() { // int fd; // fd=open("/dev/fb0",O_RDWR); - qDebug("do unblanking"); + // qDebug("do unblanking"); if (fd != -1) { ioctl(fd,FBIOBLANK,0); @@ -1462,5 +1436,5 @@ void PlayListWidget::skinsMenuActivated( int item ) { void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { - qDebug("qcop message "+msg ); + // qDebug("qcop message "+msg ); QDataStream stream ( data, IO_ReadOnly ); if ( msg == "play()" ) { //plays current selection @@ -1499,8 +1473,6 @@ void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { QString file; stream >> file; - } else if ( msg == "setDocument(QString)" ) { //loop or not loop QCopEnvelope h("QPE/Application/opieplayer", "raise()"); } - } |