summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp45
1 files changed, 29 insertions, 16 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index 8b25a4c..30e4daa 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -64,50 +64,50 @@
64#include "audiowidget.h" 64#include "audiowidget.h"
65#include "videowidget.h" 65#include "videowidget.h"
66 66
67#include <unistd.h> 67#include <unistd.h>
68#include <sys/file.h> 68#include <sys/file.h>
69#include <sys/ioctl.h> 69#include <sys/ioctl.h>
70#include <sys/soundcard.h> 70#include <sys/soundcard.h>
71 71
72// for setBacklight() 72// for setBacklight()
73#include <linux/fb.h> 73#include <linux/fb.h>
74#include <sys/types.h> 74#include <sys/types.h>
75#include <sys/stat.h> 75#include <sys/stat.h>
76#include <stdlib.h> 76#include <stdlib.h>
77 77
78#define BUTTONS_ON_TOOLBAR 78#define BUTTONS_ON_TOOLBAR
79#define SIDE_BUTTONS 79#define SIDE_BUTTONS
80#define CAN_SAVE_LOAD_PLAYLISTS 80#define CAN_SAVE_LOAD_PLAYLISTS
81 81
82extern AudioWidget *audioUI; 82extern AudioWidget *audioUI;
83extern VideoWidget *videoUI; 83extern VideoWidget *videoUI;
84extern MediaPlayerState *mediaPlayerState; 84extern MediaPlayerState *mediaPlayerState;
85 85
86static inline QString fullBaseName ( const QFileInfo &fi ) 86static inline QString fullBaseName ( const QFileInfo &fi )
87{ 87{
88 QString str = fi. fileName ( ); 88 QString str = fi. fileName ( );
89 return str. left ( str. findRev ( '.' )); 89 return str. left ( str. findRev ( '.' ));
90} 90}
91 91
92 92
93QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg"; 93QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg";
94// class myFileSelector { 94// class myFileSelector {
95 95
96// }; 96// };
97class PlayListWidgetPrivate { 97class PlayListWidgetPrivate {
98public: 98public:
99 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; 99 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove;
100 QFrame *playListFrame; 100 QFrame *playListFrame;
101 FileSelector *files; 101 FileSelector *files;
102 PlayListSelection *selectedFiles; 102 PlayListSelection *selectedFiles;
103 bool setDocumentUsed; 103 bool setDocumentUsed;
104 DocLnk *current; 104 DocLnk *current;
105}; 105};
106 106
107 107
108class ToolButton : public QToolButton { 108class ToolButton : public QToolButton {
109public: 109public:
110 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) 110 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE )
111 : QToolButton( parent, name ) { 111 : QToolButton( parent, name ) {
112 setTextLabel( name ); 112 setTextLabel( name );
113 setPixmap( Resource::loadPixmap( icon ) ); 113 setPixmap( Resource::loadPixmap( icon ) );
@@ -446,66 +446,78 @@ void PlayListWidget::addAllMusicToList() {
446 if(QFileInfo(dit.current()->file()).exists()) 446 if(QFileInfo(dit.current()->file()).exists())
447 d->selectedFiles->addToSelection( **dit ); 447 d->selectedFiles->addToSelection( **dit );
448 tabWidget->setCurrentPage(0); 448 tabWidget->setCurrentPage(0);
449 449
450 writeCurrentM3u(); 450 writeCurrentM3u();
451 d->selectedFiles->first(); 451 d->selectedFiles->first();
452} 452}
453 453
454 454
455void PlayListWidget::addAllVideoToList() { 455void PlayListWidget::addAllVideoToList() {
456 QListIterator<DocLnk> dit( vFiles.children() ); 456 QListIterator<DocLnk> dit( vFiles.children() );
457 for ( ; dit.current(); ++dit ) 457 for ( ; dit.current(); ++dit )
458 if(QFileInfo( dit.current()->file()).exists()) 458 if(QFileInfo( dit.current()->file()).exists())
459 d->selectedFiles->addToSelection( **dit ); 459 d->selectedFiles->addToSelection( **dit );
460 tabWidget->setCurrentPage(0); 460 tabWidget->setCurrentPage(0);
461 461
462 writeCurrentM3u(); 462 writeCurrentM3u();
463 d->selectedFiles->first(); 463 d->selectedFiles->first();
464} 464}
465 465
466 466
467void PlayListWidget::setDocument(const QString& fileref) { 467void PlayListWidget::setDocument(const QString& fileref) {
468 qDebug(fileref); 468 qDebug(fileref);
469 fromSetDocument = TRUE; 469 fromSetDocument = TRUE;
470 if ( fileref.isNull() ) { 470 QFileInfo fileInfo(fileref);
471 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); 471 if ( !fileInfo.exists() ) {
472 QMessageBox::critical( 0, tr( "Invalid File" ),
473 tr( "There was a problem in getting the file." ) );
472 return; 474 return;
473 } 475 }
474// qDebug("setDocument "+fileref); 476// qDebug("setDocument "+fileref);
475 if(fileref.find("m3u",0,TRUE) != -1) { //is m3u 477 QString extension = fileInfo.extension(false);
478 if( extension.find( "m3u", 0, false) != -1) { //is m3u
476 readm3u( fileref); 479 readm3u( fileref);
477 } 480 }
478 else if(fileref.find("pls",0,TRUE) != -1) { //is pls 481 else if( extension.find( "pls", 0, false) != -1 ) { //is pls
479 readPls( fileref); 482 readPls( fileref);
480 } 483 }
481 else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist 484 else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist
482 clearList(); 485 clearList();
483 loadList(DocLnk(fileref)); 486 DocLnk lnk;
487 lnk.setName( fileInfo.baseName() ); //sets name
488 lnk.setFile( fileref ); //sets file name
489 //addToSelection( lnk );
490
491 loadList( lnk);
484 d->selectedFiles->first(); 492 d->selectedFiles->first();
485 } else { 493 } else {
486 clearList(); 494 clearList();
487 addToSelection( DocLnk( fileref ) ); 495 DocLnk lnk;
496 lnk.setName( fileInfo.baseName() ); //sets name
497 lnk.setFile( fileref ); //sets file name
498 addToSelection( lnk );
499// addToSelection( DocLnk( fileref ) );
488 d->setDocumentUsed = TRUE; 500 d->setDocumentUsed = TRUE;
489 mediaPlayerState->setPlaying( FALSE ); 501 mediaPlayerState->setPlaying( FALSE );
490 qApp->processEvents(); 502 qApp->processEvents();
491 mediaPlayerState->setPlaying( TRUE ); 503 mediaPlayerState->setPlaying( TRUE );
492 qApp->processEvents(); 504 qApp->processEvents();
493 setCaption(tr("OpiePlayer")); 505 setCaption(tr("OpiePlayer"));
494 } 506 }
495} 507}
496 508
497 509
498void PlayListWidget::setActiveWindow() { 510void PlayListWidget::setActiveWindow() {
499 qDebug("SETTING active window"); 511 qDebug("SETTING active window");
500 512
501 // When we get raised we need to ensure that it switches views 513 // When we get raised we need to ensure that it switches views
502 char origView = mediaPlayerState->view(); 514 char origView = mediaPlayerState->view();
503 mediaPlayerState->setView( 'l' ); // invalidate 515 mediaPlayerState->setView( 'l' ); // invalidate
504 mediaPlayerState->setView( origView ); // now switch back 516 mediaPlayerState->setView( origView ); // now switch back
505} 517}
506 518
507 519
508void PlayListWidget::useSelectedDocument() { 520void PlayListWidget::useSelectedDocument() {
509 d->setDocumentUsed = FALSE; 521 d->setDocumentUsed = FALSE;
510} 522}
511 523
@@ -1170,57 +1182,58 @@ void PlayListWidget::writeCurrentM3u() {
1170 qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); 1182 qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file());
1171 m3uList->add( d->selectedFiles->current()->file() ); 1183 m3uList->add( d->selectedFiles->current()->file() );
1172 } 1184 }
1173 while ( d->selectedFiles->next() ); 1185 while ( d->selectedFiles->next() );
1174 qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); 1186 qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" );
1175 m3uList->write(); 1187 m3uList->write();
1176 m3uList->close(); 1188 m3uList->close();
1177 1189
1178 if(m3uList) delete m3uList; 1190 if(m3uList) delete m3uList;
1179 } 1191 }
1180} 1192}
1181 1193
1182 /* 1194 /*
1183 writes current playlist to m3u file */ 1195 writes current playlist to m3u file */
1184void PlayListWidget::writem3u() { 1196void PlayListWidget::writem3u() {
1185 InputDialog *fileDlg; 1197 InputDialog *fileDlg;
1186 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); 1198 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
1187 fileDlg->exec(); 1199 fileDlg->exec();
1188 QString name, filename, list; 1200 QString name, filename, list;
1189 Om3u *m3uList; 1201 Om3u *m3uList;
1190 1202
1191 if( fileDlg->result() == 1 ) { 1203 if( fileDlg->result() == 1 ) {
1192 name = fileDlg->text(); 1204 name = fileDlg->text();
1193// qDebug( filename ); 1205// qDebug( filename );
1194 1206 if( name.find("/",0,true) != -1) {// assume they specify a file path
1195 if( name.left( 1) != "/" ) { 1207 filename = name;
1196 filename = QPEApplication::documentDir() + "/" + name; 1208 name = name.right(name.length()- name.findRev("/",-1,true) - 1 );
1197 }
1198
1199 if( name.right( 3 ) != "m3u" ) {
1200 filename = QPEApplication::documentDir() + "/" +name+".m3u";
1201 } 1209 }
1210 else //otherwise dump it somewhere noticable
1211 filename = QPEApplication::documentDir() + "/" + name;
1202 1212
1213 if( filename.right( 3 ) != "m3u" ) //needs filename extension
1214 filename += ".m3u";
1215
1203 if( d->selectedFiles->first()) { 1216 if( d->selectedFiles->first()) {
1204 m3uList = new Om3u(filename, IO_ReadWrite); 1217 m3uList = new Om3u(filename, IO_ReadWrite);
1205 1218
1206 do { 1219 do {
1207 m3uList->add( d->selectedFiles->current()->file()); 1220 m3uList->add( d->selectedFiles->current()->file());
1208 } 1221 }
1209 while ( d->selectedFiles->next() ); 1222 while ( d->selectedFiles->next() );
1210 // qDebug( list ); 1223 // qDebug( list );
1211 m3uList->write(); 1224 m3uList->write();
1212 m3uList->close(); 1225 m3uList->close();
1213 if(m3uList) delete m3uList; 1226 if(m3uList) delete m3uList;
1214 1227
1215 if(fileDlg) delete fileDlg; 1228 if(fileDlg) delete fileDlg;
1216 1229
1217 DocLnk lnk; 1230 DocLnk lnk;
1218 lnk.setFile( filename); 1231 lnk.setFile( filename);
1219 lnk.setIcon("opieplayer2/playlist2"); 1232 lnk.setIcon("opieplayer2/playlist2");
1220 lnk.setName( name); //sets file name 1233 lnk.setName( name); //sets file name
1221 1234
1222 // qDebug(filename); 1235 // qDebug(filename);
1223 Config config( "OpiePlayer" ); 1236 Config config( "OpiePlayer" );
1224 config.setGroup( "PlayList" ); 1237 config.setGroup( "PlayList" );
1225 1238
1226 config.writeEntry("CurrentPlaylist",filename); 1239 config.writeEntry("CurrentPlaylist",filename);