author | llornkcor <llornkcor> | 2002-04-20 18:14:30 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-04-20 18:14:30 (UTC) |
commit | b37f1e1eec635165da7dbf06e968cd5368d92d4e (patch) (unidiff) | |
tree | 4c1c31a976c8222f6a79b5bdfa50cc248a6f7feb /core/multimedia | |
parent | 0b076b2dcf35142383f6058c9be2968a7dfffca7 (diff) | |
download | opie-b37f1e1eec635165da7dbf06e968cd5368d92d4e.zip opie-b37f1e1eec635165da7dbf06e968cd5368d92d4e.tar.gz opie-b37f1e1eec635165da7dbf06e968cd5368d92d4e.tar.bz2 |
added file/url input
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 52 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.h | 1 |
2 files changed, 46 insertions, 7 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 | |||
@@ -154,14 +154,16 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
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 | // pmPlayList->insertSeparator(-1); | ||
160 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); | 161 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); |
161 | // new MenuItem( pmPlayList, tr( "Load PlayList" ), this, SLOT( loadList() ) ); | 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()) ); |
@@ -417,32 +419,39 @@ void PlayListWidget::addAllVideoToList() { | |||
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 | ||
422 | void PlayListWidget::setDocument(const QString& fileref) { | 424 | void 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 | ||
447 | void PlayListWidget::setActiveWindow() { | 456 | void 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 |
@@ -962,6 +971,35 @@ void PlayListWidget::populateVideoView() { | |||
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 | |||
978 | void 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 | |||
@@ -73,12 +73,13 @@ private: | |||
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(); |
78 | private slots: | 78 | private 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 ); |