summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp62
-rw-r--r--core/multimedia/opieplayer/playlistwidget.h1
2 files changed, 51 insertions, 12 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index d9a70ce..11f9752 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -132,54 +132,56 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
132 QPEToolBar *bar = new QPEToolBar( this ); 132 QPEToolBar *bar = new QPEToolBar( this );
133 bar->setLabel( tr( "Play Operations" ) ); 133 bar->setLabel( tr( "Play Operations" ) );
134// d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "mpegplayer/play_current_list", 134// d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "mpegplayer/play_current_list",
135// this , SLOT( addSelected()) ); 135// this , SLOT( addSelected()) );
136 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); 136 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close");
137 tbDeletePlaylist->setFlat(TRUE); 137 tbDeletePlaylist->setFlat(TRUE);
138 tbDeletePlaylist->setFixedSize(20,20); 138 tbDeletePlaylist->setFixedSize(20,20);
139 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); 139 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist()));
140 140
141 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "mpegplayer/add_to_playlist", 141 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "mpegplayer/add_to_playlist",
142 this , SLOT(addSelected()) ); 142 this , SLOT(addSelected()) );
143 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "mpegplayer/remove_from_playlist", 143 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "mpegplayer/remove_from_playlist",
144 this , SLOT(removeSelected()) ); 144 this , SLOT(removeSelected()) );
145// d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); 145// d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE );
146 d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", 146 d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play",
147 this , SLOT( btnPlay(bool) ), TRUE ); 147 this , SLOT( btnPlay(bool) ), TRUE );
148 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"mpegplayer/shuffle", 148 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"mpegplayer/shuffle",
149 mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); 149 mediaPlayerState, SLOT(setShuffled(bool)), TRUE );
150 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"mpegplayer/loop", 150 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"mpegplayer/loop",
151 mediaPlayerState, SLOT(setLooping(bool)), TRUE ); 151 mediaPlayerState, SLOT(setLooping(bool)), TRUE );
152 tbDeletePlaylist->hide(); 152 tbDeletePlaylist->hide();
153 153
154 QPopupMenu *pmPlayList = new QPopupMenu( this ); 154 QPopupMenu *pmPlayList = new QPopupMenu( this );
155 menu->insertItem( tr( "File" ), pmPlayList ); 155 menu->insertItem( tr( "File" ), pmPlayList );
156 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 156 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
157 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); 157 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) );
158 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); 158 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) );
159 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); 159 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) );
160 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); 160// pmPlayList->insertSeparator(-1);
161 // new MenuItem( pmPlayList, tr( "Load PlayList" ), this, SLOT( loadList() ) ); 161 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) );
162 pmPlayList->insertSeparator(-1);
163 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) );
162 164
163 QPopupMenu *pmView = new QPopupMenu( this ); 165 QPopupMenu *pmView = new QPopupMenu( this );
164 menu->insertItem( tr( "View" ), pmView ); 166 menu->insertItem( tr( "View" ), pmView );
165 167
166 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); 168 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0);
167 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); 169 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) );
168 fullScreenButton->addTo(pmView); 170 fullScreenButton->addTo(pmView);
169 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("mpegplayer/scale"), QString::null, 0, this, 0); 171 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("mpegplayer/scale"), QString::null, 0, this, 0);
170 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); 172 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) );
171 scaleButton->addTo(pmView); 173 scaleButton->addTo(pmView);
172 174
173 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); 175 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton );
174 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); 176 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton );
175 177
176 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); 178 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton );
177 179
178 tabWidget = new QTabWidget( hbox6, "tabWidget" ); 180 tabWidget = new QTabWidget( hbox6, "tabWidget" );
179 tabWidget->setTabShape(QTabWidget::Triangular); 181 tabWidget->setTabShape(QTabWidget::Triangular);
180 182
181 QWidget *pTab; 183 QWidget *pTab;
182 pTab = new QWidget( tabWidget, "pTab" ); 184 pTab = new QWidget( tabWidget, "pTab" );
183// playlistView = new QListView( pTab, "playlistview" ); 185// playlistView = new QListView( pTab, "playlistview" );
184// playlistView->setMinimumSize(236,260); 186// playlistView->setMinimumSize(236,260);
185 tabWidget->insertTab( pTab,"Playlist"); 187 tabWidget->insertTab( pTab,"Playlist");
@@ -399,68 +401,75 @@ void PlayListWidget::addAllToList() {
399 Global::findDocuments(&filesAll, "video/*;audio/*"); 401 Global::findDocuments(&filesAll, "video/*;audio/*");
400 QListIterator<DocLnk> Adit( filesAll.children() ); 402 QListIterator<DocLnk> Adit( filesAll.children() );
401 for ( ; Adit.current(); ++Adit ) 403 for ( ; Adit.current(); ++Adit )
402 d->selectedFiles->addToSelection( **Adit ); 404 d->selectedFiles->addToSelection( **Adit );
403} 405}
404 406
405 407
406void PlayListWidget::addAllMusicToList() { 408void PlayListWidget::addAllMusicToList() {
407// DocLnkSet files; 409// DocLnkSet files;
408// Global::findDocuments(&files, "audio/*"); 410// Global::findDocuments(&files, "audio/*");
409 QListIterator<DocLnk> dit( files.children() ); 411 QListIterator<DocLnk> dit( files.children() );
410 for ( ; dit.current(); ++dit ) 412 for ( ; dit.current(); ++dit )
411 d->selectedFiles->addToSelection( **dit ); 413 d->selectedFiles->addToSelection( **dit );
412} 414}
413 415
414 416
415void PlayListWidget::addAllVideoToList() { 417void PlayListWidget::addAllVideoToList() {
416 QListIterator<DocLnk> dit( vFiles.children() ); 418 QListIterator<DocLnk> dit( vFiles.children() );
417 for ( ; dit.current(); ++dit ) 419 for ( ; dit.current(); ++dit )
418 d->selectedFiles->addToSelection( **dit ); 420 d->selectedFiles->addToSelection( **dit );
419} 421}
420 422
421 423
422void PlayListWidget::setDocument(const QString& fileref) { 424void PlayListWidget::setDocument(const QString& fileref) {
425 qDebug(fileref);
423 fromSetDocument = TRUE; 426 fromSetDocument = TRUE;
424 if ( fileref.isNull() ) { 427 if ( fileref.isNull() ) {
425 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); 428 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) );
426 return; 429 return;
427 } 430 }
428// qDebug("setDocument "+fileref); 431// qDebug("setDocument "+fileref);
429 if(fileref.find("playlist",0,TRUE) == -1) { 432 if(fileref.find("m3u",0,TRUE) != -1) { //is m3u
433 clearList();
434 addToSelection( DocLnk( fileref ) );
435 d->setDocumentUsed = TRUE;
436 d->selectedFiles->first();
437 qApp->processEvents();
438 }
439 else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist
440 clearList();
441 loadList(DocLnk(fileref));
442 d->selectedFiles->first();
443 } else {
430 clearList(); 444 clearList();
431 addToSelection( DocLnk( fileref ) ); 445 addToSelection( DocLnk( fileref ) );
432 d->setDocumentUsed = TRUE; 446 d->setDocumentUsed = TRUE;
433 mediaPlayerState->setPlaying( FALSE ); 447 mediaPlayerState->setPlaying( FALSE );
434 qApp->processEvents(); 448 qApp->processEvents();
435 mediaPlayerState->setPlaying( TRUE ); 449 mediaPlayerState->setPlaying( TRUE );
436 qApp->processEvents(); 450 qApp->processEvents();
437 setCaption(tr("OpiePlayer")); 451 setCaption(tr("OpiePlayer"));
438
439 } else { //is playlist
440 clearList();
441 loadList(DocLnk(fileref));
442 d->selectedFiles->first();
443 } 452 }
444} 453}
445 454
446 455
447void PlayListWidget::setActiveWindow() { 456void PlayListWidget::setActiveWindow() {
448 // When we get raised we need to ensure that it switches views 457 // When we get raised we need to ensure that it switches views
449 char origView = mediaPlayerState->view(); 458 char origView = mediaPlayerState->view();
450 mediaPlayerState->setView( 'l' ); // invalidate 459 mediaPlayerState->setView( 'l' ); // invalidate
451 mediaPlayerState->setView( origView ); // now switch back 460 mediaPlayerState->setView( origView ); // now switch back
452} 461}
453 462
454 463
455void PlayListWidget::useSelectedDocument() { 464void PlayListWidget::useSelectedDocument() {
456 d->setDocumentUsed = FALSE; 465 d->setDocumentUsed = FALSE;
457} 466}
458 467
459 468
460const DocLnk *PlayListWidget::current() { // this is fugly 469const DocLnk *PlayListWidget::current() { // this is fugly
461 470
462// if( fromSetDocument) { 471// if( fromSetDocument) {
463// qDebug("from setDoc"); 472// qDebug("from setDoc");
464// DocLnkSet files; 473// DocLnkSet files;
465// Global::findDocuments(&files, "video/*;audio/*"); 474// Global::findDocuments(&files, "video/*;audio/*");
466// QListIterator<DocLnk> dit( files.children() ); 475// QListIterator<DocLnk> dit( files.children() );
@@ -944,24 +953,53 @@ void PlayListWidget::populateAudioView() {
944 953
945void PlayListWidget::populateVideoView() { 954void PlayListWidget::populateVideoView() {
946 StorageInfo storageInfo; 955 StorageInfo storageInfo;
947 const QList<FileSystem> &fs = storageInfo.fileSystems(); 956 const QList<FileSystem> &fs = storageInfo.fileSystems();
948 957
949 Global::findDocuments(&vFiles, "video/*"); 958 Global::findDocuments(&vFiles, "video/*");
950 QListIterator<DocLnk> Vdit( vFiles.children() ); 959 QListIterator<DocLnk> Vdit( vFiles.children() );
951 QListIterator<FileSystem> it ( fs ); 960 QListIterator<FileSystem> it ( fs );
952 videoView->clear(); 961 videoView->clear();
953 QString storage; 962 QString storage;
954 for ( ; Vdit.current(); ++Vdit ) { 963 for ( ; Vdit.current(); ++Vdit ) {
955 for( ; it.current(); ++it ){ 964 for( ; it.current(); ++it ){
956 const QString name = (*it)->name(); 965 const QString name = (*it)->name();
957 const QString path = (*it)->path(); 966 const QString path = (*it)->path();
958 if( Vdit.current()->file().find(path) != -1 ) storage=name; 967 if( Vdit.current()->file().find(path) != -1 ) storage=name;
959 } 968 }
960 969
961 QListViewItem * newItem; 970 QListViewItem * newItem;
962 if ( QFile( Vdit.current()->file()).exists() ) { 971 if ( QFile( Vdit.current()->file()).exists() ) {
963 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); 972 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage);
964 newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" )); 973 newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" ));
965 } 974 }
966 } 975 }
967} 976}
977
978void PlayListWidget::openFile() {
979 QString filename;
980 InputDialog *fileDlg;
981 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
982 fileDlg->exec();
983 if( fileDlg->result() == 1 ) {
984 filename = fileDlg->LineEdit1->text();
985 }
986 qDebug(filename);
987 DocLnk lnk;
988 QString name = filename.right(filename.length()-filename.find("http://")-7);
989 lnk.setName( name); //sets file name
990// lnk.setComment();
991 lnk.setFile(filename); //sets File property
992// problem is, the launcher sees this as a broken link and does not display it :(
993
994 lnk.setType("audio/x-mpegurl");
995 lnk.setExec("opieplayer");
996 lnk.setIcon("opieplayer/MPEGPlayer");
997 QString cmd="touch "+QPEApplication::documentDir()+"audio/x-mpegurl/"+name;
998 system( cmd.latin1());
999// d->selectedFiles->addToSelection( **dit );
1000
1001 if(!lnk.writeLink())
1002 qDebug("Writing doclink did not work");
1003 if(fileDlg)
1004 delete fileDlg;
1005}
diff --git a/core/multimedia/opieplayer/playlistwidget.h b/core/multimedia/opieplayer/playlistwidget.h
index 186ca1b..02cdba6 100644
--- a/core/multimedia/opieplayer/playlistwidget.h
+++ b/core/multimedia/opieplayer/playlistwidget.h
@@ -55,48 +55,49 @@ public:
55 const DocLnk *current(); 55 const DocLnk *current();
56 void useSelectedDocument(); 56 void useSelectedDocument();
57/* QTimer * menuTimer; */ 57/* QTimer * menuTimer; */
58 FileSelector* playLists; 58 FileSelector* playLists;
59 QPushButton *tbDeletePlaylist; 59 QPushButton *tbDeletePlaylist;
60public slots: 60public slots:
61 bool first(); 61 bool first();
62 bool last(); 62 bool last();
63 bool next(); 63 bool next();
64 bool prev(); 64 bool prev();
65/* void setFullScreen(); */ 65/* void setFullScreen(); */
66/* void setScaled(); */ 66/* void setScaled(); */
67protected: 67protected:
68/* void contentsMousePressEvent( QMouseEvent * e ); */ 68/* void contentsMousePressEvent( QMouseEvent * e ); */
69/* void contentsMouseReleaseEvent( QMouseEvent * e ); */ 69/* void contentsMouseReleaseEvent( QMouseEvent * e ); */
70 70
71private: 71private:
72 void initializeStates(); 72 void initializeStates();
73 void readConfig( Config& cfg ); 73 void readConfig( Config& cfg );
74 void writeConfig( Config& cfg ) const; 74 void writeConfig( Config& cfg ) const;
75 PlayListWidgetPrivate *d; // Private implementation data 75 PlayListWidgetPrivate *d; // Private implementation data
76 void populateAudioView(); 76 void populateAudioView();
77 void populateVideoView(); 77 void populateVideoView();
78private slots: 78private slots:
79 void openFile();
79 void setDocument( const QString& fileref ); 80 void setDocument( const QString& fileref );
80 void addToSelection( const DocLnk& ); // Add a media file to the playlist 81 void addToSelection( const DocLnk& ); // Add a media file to the playlist
81 void addToSelection( QListViewItem* ); // Add a media file to the playlist 82 void addToSelection( QListViewItem* ); // Add a media file to the playlist
82 void setActiveWindow(); // need to handle this to show the right view 83 void setActiveWindow(); // need to handle this to show the right view
83 void setPlaylist( bool ); // Show/Hide the playlist 84 void setPlaylist( bool ); // Show/Hide the playlist
84 void setView( char ); 85 void setView( char );
85 void clearList(); 86 void clearList();
86 void addAllToList(); 87 void addAllToList();
87 void addAllMusicToList(); 88 void addAllMusicToList();
88 void addAllVideoToList(); 89 void addAllVideoToList();
89 void saveList(); // Save the playlist 90 void saveList(); // Save the playlist
90 void loadList( const DocLnk &); // Load a playlist 91 void loadList( const DocLnk &); // Load a playlist
91 void playIt( QListViewItem *); 92 void playIt( QListViewItem *);
92 93
93 void btnPlay(bool); 94 void btnPlay(bool);
94 void deletePlaylist(); 95 void deletePlaylist();
95 void addSelected(); 96 void addSelected();
96 void removeSelected(); 97 void removeSelected();
97 void tabChanged(QWidget*); 98 void tabChanged(QWidget*);
98 void viewPressed( int, QListViewItem *, const QPoint&, int); 99 void viewPressed( int, QListViewItem *, const QPoint&, int);
99 void playlistViewPressed( int, QListViewItem *, const QPoint&, int); 100 void playlistViewPressed( int, QListViewItem *, const QPoint&, int);
100 void playSelected(); 101 void playSelected();
101 void listDelete(); 102 void listDelete();
102 103