summaryrefslogtreecommitdiff
authorharlekin <harlekin>2003-06-18 21:01:43 (UTC)
committer harlekin <harlekin>2003-06-18 21:01:43 (UTC)
commiteff530015d448c27d060824c8ed58bbd7a4b40b9 (patch) (unidiff)
treea5672a3ac374c5c501dbf93482692bcd4565bdb0
parent9bfda722eeba2f5861393e9f5f41170fab502da8 (diff)
downloadopie-eff530015d448c27d060824c8ed58bbd7a4b40b9.zip
opie-eff530015d448c27d060824c8ed58bbd7a4b40b9.tar.gz
opie-eff530015d448c27d060824c8ed58bbd7a4b40b9.tar.bz2
give save playlist the normal ofileselector too
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp46
1 files changed, 35 insertions, 11 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 4e31670..4ee784e 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -38,106 +38,104 @@
38#include <qpe/global.h> 38#include <qpe/global.h>
39#include <qpe/resource.h> 39#include <qpe/resource.h>
40#include <qpe/config.h> 40#include <qpe/config.h>
41 41
42#include <opie/ofiledialog.h> 42#include <opie/ofiledialog.h>
43 43
44#include <qdatetime.h> 44#include <qdatetime.h>
45#include <qdir.h> 45#include <qdir.h>
46#include <qmessagebox.h> 46#include <qmessagebox.h>
47#include <qregexp.h> 47#include <qregexp.h>
48#include <qtextstream.h> 48#include <qtextstream.h>
49 49
50#include "playlistselection.h" 50#include "playlistselection.h"
51#include "playlistwidget.h" 51#include "playlistwidget.h"
52#include "mediaplayerstate.h" 52#include "mediaplayerstate.h"
53#include "inputDialog.h" 53#include "inputDialog.h"
54#include "om3u.h" 54#include "om3u.h"
55#include "playlistfileview.h" 55#include "playlistfileview.h"
56 56
57//only needed for the random play 57//only needed for the random play
58#include <stdlib.h> 58#include <stdlib.h>
59#include <assert.h> 59#include <assert.h>
60 60
61PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) 61PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name )
62 : PlayListWidgetGui( mediaPlayerState, parent, name ) , currentFileListView( 0 ) 62 : PlayListWidgetGui( mediaPlayerState, parent, name ) , currentFileListView( 0 )
63{ 63{
64 64
65 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), 65 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ),
66 "opieplayer2/add_to_playlist", 66 "opieplayer2/add_to_playlist",
67 this , SLOT(addSelected() ) ); 67 this , SLOT(addSelected() ) );
68 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), 68 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ),
69 "opieplayer2/remove_from_playlist", 69 "opieplayer2/remove_from_playlist",
70 this , SLOT(removeSelected() ) ); 70 this , SLOT(removeSelected() ) );
71 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", 71 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play",
72 this , SLOT( btnPlay( bool) ), TRUE ); 72 this , SLOT( btnPlay( bool) ), TRUE );
73 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", 73 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle",
74 &mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); 74 &mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE );
75 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", 75 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop",
76 &mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); 76 &mediaPlayerState, SLOT( setLooping( bool ) ), TRUE );
77 77
78 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 78 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
79 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), 79 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ),
80 this, SLOT( addAllMusicToList() ) ); 80 this, SLOT( addAllMusicToList() ) );
81 (void)new MenuItem( pmPlayList, tr( "Add all video files" ), 81 (void)new MenuItem( pmPlayList, tr( "Add all video files" ),
82 this, SLOT( addAllVideoToList() ) ); 82 this, SLOT( addAllVideoToList() ) );
83 (void)new MenuItem( pmPlayList, tr( "Add all files" ), 83 (void)new MenuItem( pmPlayList, tr( "Add all files" ),
84 this, SLOT( addAllToList() ) ); 84 this, SLOT( addAllToList() ) );
85 pmPlayList->insertSeparator(-1); 85 pmPlayList->insertSeparator(-1);
86// (void)new MenuItem( pmPlayList, tr( "Save PlayList" ),
87// this, SLOT( saveList() ) );
88 (void)new MenuItem( pmPlayList, tr( "Save Playlist" ),
89 this, SLOT(writem3u() ) );
90 pmPlayList->insertSeparator(-1);
91 (void)new MenuItem( pmPlayList, tr( "Add File" ), 86 (void)new MenuItem( pmPlayList, tr( "Add File" ),
92 this,SLOT( openFile() ) ); 87 this,SLOT( openFile() ) );
93 (void)new MenuItem( pmPlayList, tr("Add URL"), 88 (void)new MenuItem( pmPlayList, tr("Add URL"),
94 this,SLOT( openURL() ) ); 89 this,SLOT( openURL() ) );
95 pmPlayList->insertSeparator(-1); 90 pmPlayList->insertSeparator(-1);
91 (void)new MenuItem( pmPlayList, tr( "Save Playlist" ),
92 this, SLOT(writem3u() ) );
93 pmPlayList->insertSeparator(-1);
96 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), 94 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ),
97 audioView, SLOT( scanFiles() ) ); 95 audioView, SLOT( scanFiles() ) );
98 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), 96 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ),
99 videoView, SLOT( scanFiles() ) ); 97 videoView, SLOT( scanFiles() ) );
100 98
101 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), 99 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"),
102 &mediaPlayerState, SLOT( toggleFullscreen() ) ); 100 &mediaPlayerState, SLOT( toggleFullscreen() ) );
103 101
104 Config cfg( "OpiePlayer" ); 102 Config cfg( "OpiePlayer" );
105 bool b= cfg.readBoolEntry("FullScreen", 0); 103 bool b= cfg.readBoolEntry("FullScreen", 0);
106 mediaPlayerState.setFullscreen( b ); 104 mediaPlayerState.setFullscreen( b );
107 pmView->setItemChecked( -16, b ); 105 pmView->setItemChecked( -16, b );
108 106
109 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", 107 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up",
110 d->selectedFiles, SLOT(moveSelectedUp() ) ); 108 d->selectedFiles, SLOT(moveSelectedUp() ) );
111 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", 109 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut",
112 d->selectedFiles, SLOT(removeSelected() ) ); 110 d->selectedFiles, SLOT(removeSelected() ) );
113 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", 111 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down",
114 d->selectedFiles, SLOT(moveSelectedDown() ) ); 112 d->selectedFiles, SLOT(moveSelectedDown() ) );
115 // QVBox *stretch2 = new QVBox( vbox1 ); 113 // QVBox *stretch2 = new QVBox( vbox1 );
116 114
117 connect( tbDeletePlaylist, ( SIGNAL( released() ) ), 115 connect( tbDeletePlaylist, ( SIGNAL( released() ) ),
118 SLOT( deletePlaylist() ) ); 116 SLOT( deletePlaylist() ) );
119 connect( pmView, SIGNAL( activated( int ) ), 117 connect( pmView, SIGNAL( activated( int ) ),
120 this, SLOT( pmViewActivated( int ) ) ); 118 this, SLOT( pmViewActivated( int ) ) );
121 connect( skinsMenu, SIGNAL( activated( int ) ) , 119 connect( skinsMenu, SIGNAL( activated( int ) ) ,
122 this, SLOT( skinsMenuActivated( int ) ) ); 120 this, SLOT( skinsMenuActivated( int ) ) );
123 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), 121 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ),
124 this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); 122 this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) );
125 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), 123 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ),
126 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); 124 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) );
127 connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), 125 connect( audioView, SIGNAL( returnPressed( QListViewItem *) ),
128 this,SLOT( playIt( QListViewItem *) ) ); 126 this,SLOT( playIt( QListViewItem *) ) );
129 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), 127 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ),
130 this, SLOT( addToSelection( QListViewItem *) ) ); 128 this, SLOT( addToSelection( QListViewItem *) ) );
131 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), 129 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ),
132 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); 130 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) );
133 connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), 131 connect( videoView, SIGNAL( returnPressed( QListViewItem *) ),
134 this,SLOT( playIt( QListViewItem *) ) ); 132 this,SLOT( playIt( QListViewItem *) ) );
135 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), 133 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ),
136 this, SLOT( addToSelection( QListViewItem *) ) ); 134 this, SLOT( addToSelection( QListViewItem *) ) );
137 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), 135 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ),
138 this, SLOT( loadList( const DocLnk & ) ) ); 136 this, SLOT( loadList( const DocLnk & ) ) );
139 connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), 137 connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ),
140 this, SLOT( tabChanged( QWidget* ) ) ); 138 this, SLOT( tabChanged( QWidget* ) ) );
141 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), 139 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ),
142 d->tbPlay, SLOT( setOn( bool ) ) ); 140 d->tbPlay, SLOT( setOn( bool ) ) );
143 connect( &mediaPlayerState, SIGNAL( loopingToggled( bool ) ), 141 connect( &mediaPlayerState, SIGNAL( loopingToggled( bool ) ),
@@ -735,128 +733,154 @@ void PlayListWidget::readListFromFile( const QString &filename ) {
735 } else { 733 } else {
736 lnk.setFile( s); 734 lnk.setFile( s);
737 } 735 }
738 } 736 }
739 d->selectedFiles->addToSelection( lnk ); 737 d->selectedFiles->addToSelection( lnk );
740 } 738 }
741 Config config( "OpiePlayer" ); 739 Config config( "OpiePlayer" );
742 config.setGroup( "PlayList" ); 740 config.setGroup( "PlayList" );
743 741
744 config.writeEntry("CurrentPlaylist",filename); 742 config.writeEntry("CurrentPlaylist",filename);
745 config.write(); 743 config.write();
746 currentPlayList=filename; 744 currentPlayList=filename;
747 745
748 m3uList->close(); 746 m3uList->close();
749 delete m3uList; 747 delete m3uList;
750 748
751 d->selectedFiles->setSelectedItem( s); 749 d->selectedFiles->setSelectedItem( s);
752 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); 750 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName());
753 751
754} 752}
755 753
756// writes current playlist to current m3u file */ 754// writes current playlist to current m3u file */
757 void PlayListWidget::writeCurrentM3u() { 755 void PlayListWidget::writeCurrentM3u() {
758 qDebug("writing to current m3u"); 756 qDebug("writing to current m3u");
759 Config cfg( "OpiePlayer" ); 757 Config cfg( "OpiePlayer" );
760 cfg.setGroup("PlayList"); 758 cfg.setGroup("PlayList");
761 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); 759 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default");
762 760
763 Om3u *m3uList; 761 Om3u *m3uList;
764 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); 762 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate );
765 if( d->selectedFiles->first()) { 763 if( d->selectedFiles->first()) {
766 764
767 do { 765 do {
768 // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); 766 // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file());
769 m3uList->add( d->selectedFiles->current()->file() ); 767 m3uList->add( d->selectedFiles->current()->file() );
770 } 768 }
771 while ( d->selectedFiles->next() ); 769 while ( d->selectedFiles->next() );
772 // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); 770 // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" );
773 m3uList->write(); 771 m3uList->write();
774 m3uList->close(); 772 m3uList->close();
775 } 773 }
776 delete m3uList; 774 delete m3uList;
777 775
778 } 776 }
779 777
780 /* 778 /*
781 writes current playlist to m3u file */ 779 writes current playlist to m3u file */
782void PlayListWidget::writem3u() { 780void PlayListWidget::writem3u() {
783 InputDialog *fileDlg; 781 //InputDilog *fileDlg;
784 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); 782 //fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
785 fileDlg->exec(); 783 //fileDlg->exec();
784
785 Config cfg( "OpiePlayer" );
786 cfg.setGroup("Dialog");
787 MimeTypes types;
788 QStringList audio, video, all;
789 audio << "audio/*";
790 audio << "playlist/plain";
791 audio << "audio/x-mpegurl";
792
793 video << "video/*";
794 video << "playlist/plain";
795
796 all += audio;
797 all += video;
798 types.insert("All Media Files", all );
799 types.insert("Audio", audio );
800 types.insert("Video", video );
801
802 QString str = OFileDialog::getOpenFileName( 1,
803 cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"",
804 types, 0 );
805 if(str.left(2) == "//") str=str.right(str.length()-1);
806 cfg.writeEntry("LastDirectory" ,QFileInfo(str).dirPath());
807
808
786 QString name, filename, list; 809 QString name, filename, list;
787 Om3u *m3uList; 810 Om3u *m3uList;
788 811
789 if( fileDlg->result() == 1 ) { 812 if( !str.isEmpty() ) {
790 name = fileDlg->text(); 813 name = str;
814 // name = fileDlg->text();
791// qDebug( filename ); 815// qDebug( filename );
792 if( name.find("/",0,true) != -1) {// assume they specify a file path 816 if( name.find("/",0,true) != -1) {// assume they specify a file path
793 filename = name; 817 filename = name;
794 name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); 818 name = name.right(name.length()- name.findRev("/",-1,true) - 1 );
795 } 819 }
796 else //otherwise dump it somewhere noticable 820 else //otherwise dump it somewhere noticable
797 filename = QPEApplication::documentDir() + "/" + name; 821 filename = QPEApplication::documentDir() + "/" + name;
798 822
799 if( filename.right( 3 ) != "m3u" ) //needs filename extension 823 if( filename.right( 3 ) != "m3u" ) //needs filename extension
800 filename += ".m3u"; 824 filename += ".m3u";
801 825
802 if( d->selectedFiles->first()) { //ramble through playlist view 826 if( d->selectedFiles->first()) { //ramble through playlist view
803 m3uList = new Om3u( filename, IO_ReadWrite | IO_Truncate); 827 m3uList = new Om3u( filename, IO_ReadWrite | IO_Truncate);
804 828
805 do { 829 do {
806 m3uList->add( d->selectedFiles->current()->file()); 830 m3uList->add( d->selectedFiles->current()->file());
807 } 831 }
808 while ( d->selectedFiles->next() ); 832 while ( d->selectedFiles->next() );
809 // qDebug( list ); 833 // qDebug( list );
810 m3uList->write(); 834 m3uList->write();
811 m3uList->close(); 835 m3uList->close();
812 delete m3uList; 836 delete m3uList;
813 837
814 delete fileDlg; 838 //delete fileDlg;
815 839
816 DocLnk lnk; 840 DocLnk lnk;
817 lnk.setFile( filename); 841 lnk.setFile( filename);
818 lnk.setIcon("opieplayer2/playlist2"); 842 lnk.setIcon("opieplayer2/playlist2");
819 lnk.setName( name); //sets file name 843 lnk.setName( name); //sets file name
820 844
821 // qDebug(filename); 845 // qDebug(filename);
822 Config config( "OpiePlayer" ); 846 Config config( "OpiePlayer" );
823 config.setGroup( "PlayList" ); 847 config.setGroup( "PlayList" );
824 848
825 config.writeEntry("CurrentPlaylist",filename); 849 config.writeEntry("CurrentPlaylist",filename);
826 currentPlayList=filename; 850 currentPlayList=filename;
827 851
828 if(!lnk.writeLink()) { 852 if(!lnk.writeLink()) {
829 qDebug("Writing doclink did not work"); 853 qDebug("Writing doclink did not work");
830 } 854 }
831 855
832 setCaption(tr("OpiePlayer: ") + name); 856 setCaption(tr("OpiePlayer: ") + name);
833 } 857 }
834 } 858 }
835} 859}
836 860
837void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { 861void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) {
838 switch ( e->key() ) { 862 switch ( e->key() ) {
839 ////////////////////////////// Zaurus keys 863 ////////////////////////////// Zaurus keys
840 case Key_F9: //activity 864 case Key_F9: //activity
841 // if(audioUI->isHidden()) 865 // if(audioUI->isHidden())
842 // audioUI->showMaximized(); 866 // audioUI->showMaximized();
843 break; 867 break;
844 case Key_F10: //contacts 868 case Key_F10: //contacts
845 // if( videoUI->isHidden()) 869 // if( videoUI->isHidden())
846 // videoUI->showMaximized(); 870 // videoUI->showMaximized();
847 break; 871 break;
848 case Key_F11: //menu 872 case Key_F11: //menu
849 break; 873 break;
850 case Key_F12: //home 874 case Key_F12: //home
851 // doBlank(); 875 // doBlank();
852 break; 876 break;
853 case Key_F13: //mail 877 case Key_F13: //mail
854 // doUnblank(); 878 // doUnblank();
855 break; 879 break;
856 case Key_Q: //add to playlist 880 case Key_Q: //add to playlist
857 addSelected(); 881 addSelected();
858 break; 882 break;
859 case Key_R: //remove from playlist 883 case Key_R: //remove from playlist
860 removeSelected(); 884 removeSelected();
861 break; 885 break;
862 // case Key_P: //play 886 // case Key_P: //play