summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-11-10 16:52:56 (UTC)
committer llornkcor <llornkcor>2002-11-10 16:52:56 (UTC)
commit81e63be3c1e21da2a2f97df1fc38417e7ca814e1 (patch) (unidiff)
tree66b526df2913150cc67d0d2d8e4283c791ae891f
parent5a8660a4089fa2160da47e2a4d63baea431b48b1 (diff)
downloadopie-81e63be3c1e21da2a2f97df1fc38417e7ca814e1.zip
opie-81e63be3c1e21da2a2f97df1fc38417e7ca814e1.tar.gz
opie-81e63be3c1e21da2a2f97df1fc38417e7ca814e1.tar.bz2
fix file add slowdown, and make fileselector remember last directory
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/inputDialog.cpp15
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp30
2 files changed, 29 insertions, 16 deletions
diff --git a/noncore/multimedia/opieplayer2/inputDialog.cpp b/noncore/multimedia/opieplayer2/inputDialog.cpp
index 62240b2..2c4be1b 100644
--- a/noncore/multimedia/opieplayer2/inputDialog.cpp
+++ b/noncore/multimedia/opieplayer2/inputDialog.cpp
@@ -1,22 +1,24 @@
1#include "inputDialog.h" 1#include "inputDialog.h"
2 2
3#include <qpe/resource.h> 3#include <qpe/resource.h>
4 4#include <qpe/qpeapplication.h>
5#include <qpe/config.h>
5#include <opie/ofiledialog.h> 6#include <opie/ofiledialog.h>
6 7
8#include <qfileinfo.h>
7#include <qlineedit.h> 9#include <qlineedit.h>
8#include <qlayout.h> 10#include <qlayout.h>
9#include <qvariant.h> 11#include <qvariant.h>
10#include <qpushbutton.h> 12#include <qpushbutton.h>
11#include <qwhatsthis.h> 13#include <qwhatsthis.h>
12 14
13InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) 15InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
14 : QDialog( parent, name, modal, fl ) { 16 : QDialog( parent, name, modal, fl ) {
15 if ( !name ) { 17 if ( !name ) {
16 setName( "InputDialog" ); 18 setName( "InputDialog" );
17 } 19 }
18 resize( 234, 115); 20 resize( 234, 115);
19 setMaximumSize( QSize( 240, 40)); 21 setMaximumSize( QSize( 240, 40));
20 setCaption( tr( name ) ); 22 setCaption( tr( name ) );
21 23
22 QPushButton *browserButton; 24 QPushButton *browserButton;
@@ -27,36 +29,41 @@ InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags
27 LineEdit1->setGeometry( QRect( 4, 10, 190, 22 ) ); 29 LineEdit1->setGeometry( QRect( 4, 10, 190, 22 ) );
28 LineEdit1->setFocus(); 30 LineEdit1->setFocus();
29} 31}
30/* 32/*
31 * return the current text(input) 33 * return the current text(input)
32 */ 34 */
33QString InputDialog::text() const { 35QString InputDialog::text() const {
34 return LineEdit1->text(); 36 return LineEdit1->text();
35} 37}
36/* 38/*
37 * Destroys the object and frees any allocated resources 39 * Destroys the object and frees any allocated resources
38 */ 40 */
39InputDialog::~InputDialog() { 41InputDialog::~InputDialog() {
40} 42}
41 43
42void InputDialog::browse() { 44void InputDialog::browse() {
43 45 Config cfg( "OpiePlayer" );
44 MimeTypes types; 46 cfg.setGroup("Dialog");
47 MimeTypes types;
45 QStringList audio, video, all; 48 QStringList audio, video, all;
46 audio << "audio/*"; 49 audio << "audio/*";
47 audio << "playlist/plain"; 50 audio << "playlist/plain";
48 audio << "audio/x-mpegurl"; 51 audio << "audio/x-mpegurl";
49 52
50 video << "video/*"; 53 video << "video/*";
51 video << "playlist/plain"; 54 video << "playlist/plain";
52 55
53 all += audio; 56 all += audio;
54 all += video; 57 all += video;
55 types.insert("All Media Files", all ); 58 types.insert("All Media Files", all );
56 types.insert("Audio", audio ); 59 types.insert("Audio", audio );
57 types.insert("Video", video ); 60 types.insert("Video", video );
58 61
59 QString str = OFileDialog::getOpenFileName( 1,"/","", types, 0 ); 62 QString str = OFileDialog::getOpenFileName( 1,
63 cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"",
64 types, 0 );
65 if(str.left(2) == "//") str=str.right(str.length()-1);
60 LineEdit1->setText(str); 66 LineEdit1->setText(str);
67 cfg.writeEntry("LastDirectory" ,QFileInfo(str).dirPath());
61} 68}
62 69
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index b15f95e..0825eed 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -144,35 +144,35 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
144 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), 144 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ),
145 d->tbShuffle, SLOT( setOn( bool ) ) ); 145 d->tbShuffle, SLOT( setOn( bool ) ) );
146 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), 146 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ),
147 this, SLOT( setPlaylist( bool ) ) ); 147 this, SLOT( setPlaylist( bool ) ) );
148 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), 148 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ),
149 this, SLOT( playIt( QListViewItem *) ) ); 149 this, SLOT( playIt( QListViewItem *) ) );
150 connect ( gammaSlider, SIGNAL( valueChanged( int ) ), 150 connect ( gammaSlider, SIGNAL( valueChanged( int ) ),
151 mediaPlayerState, SLOT( setVideoGamma( int ) ) ); 151 mediaPlayerState, SLOT( setVideoGamma( int ) ) );
152 152
153 // see which skins are installed 153 // see which skins are installed
154 videoScan=FALSE; 154 videoScan=FALSE;
155 audioScan=FALSE; 155 audioScan=FALSE;
156 populateSkinsMenu(); 156 populateSkinsMenu();
157 initializeStates(); 157 initializeStates();
158 158
159 cfg.setGroup("PlayList"); 159 cfg.setGroup("PlayList");
160 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "" ); 160 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default");
161 loadList(DocLnk( currentPlaylist ) ); 161 loadList(DocLnk( currentPlaylist ) );
162 setCaption( tr( "OpiePlayer: " ) + currentPlaylist ); 162
163} 163}
164 164
165 165
166PlayListWidget::~PlayListWidget() { 166PlayListWidget::~PlayListWidget() {
167 if ( d->current ) { 167 if ( d->current ) {
168 delete d->current; 168 delete d->current;
169 } 169 }
170 delete d; 170 delete d;
171} 171}
172 172
173 173
174void PlayListWidget::initializeStates() { 174void PlayListWidget::initializeStates() {
175 d->tbPlay->setOn( mediaPlayerState->playing() ); 175 d->tbPlay->setOn( mediaPlayerState->playing() );
176 d->tbLoop->setOn( mediaPlayerState->looping() ); 176 d->tbLoop->setOn( mediaPlayerState->looping() );
177 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 177 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
178 setPlaylist( true ); 178 setPlaylist( true );
@@ -727,43 +727,47 @@ void PlayListWidget::openFile() {
727 727
728 if(filename.left(4) == "http") { 728 if(filename.left(4) == "http") {
729 QString m3uFile, m3uFilePath; 729 QString m3uFile, m3uFilePath;
730 if(filename.find(":",8,TRUE) != -1) { //found a port 730 if(filename.find(":",8,TRUE) != -1) { //found a port
731 m3uFile = filename.left( filename.find( ":",8,TRUE)); 731 m3uFile = filename.left( filename.find( ":",8,TRUE));
732 m3uFile = m3uFile.right( 7); 732 m3uFile = m3uFile.right( 7);
733 } else if(filename.left(4) == "http"){ 733 } else if(filename.left(4) == "http"){
734 m3uFile=filename; 734 m3uFile=filename;
735 m3uFile = m3uFile.right( m3uFile.length() - 7); 735 m3uFile = m3uFile.right( m3uFile.length() - 7);
736 } else{ 736 } else{
737 m3uFile=filename; 737 m3uFile=filename;
738 } 738 }
739 739
740// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); 740// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile);
741 lnk.setName( filename ); //sets name 741 lnk.setName( filename ); //sets name
742 lnk.setFile( filename ); //sets file name 742 lnk.setFile( filename ); //sets file name
743 lnk.setIcon("opieplayer2/musicfile"); 743
744// lnk.setIcon("opieplayer2/musicfile");
745
744 d->selectedFiles->addToSelection( lnk ); 746 d->selectedFiles->addToSelection( lnk );
745 writeCurrentM3u(); 747 writeCurrentM3u();
746 } 748 }
747 else if( filename.right( 3) == "m3u" ) { 749 else if( filename.right( 3) == "m3u" ) {
748 readm3u( filename ); 750 readm3u( filename );
749 751
750 } else if( filename.right(3) == "pls" ) { 752 } else if( filename.right(3) == "pls" ) {
751 readPls( filename ); 753 readPls( filename );
752 } else { 754 } else {
753 d->selectedFiles->addToSelection( DocLnk(filename) ); 755 lnk.setName( QFileInfo(filename).baseName() ); //sets name
756 lnk.setFile( filename ); //sets file name
757 d->selectedFiles->addToSelection( lnk);
754 writeCurrentM3u(); 758 writeCurrentM3u();
755 } 759 }
756 } 760 }
757 761
758 if( fileDlg ) { 762 if( fileDlg ) {
759 delete fileDlg; 763 delete fileDlg;
760 } 764 }
761} 765}
762 766
763/* 767/*
764reads m3u and shows files/urls to playlist widget */ 768reads m3u and shows files/urls to playlist widget */
765void PlayListWidget::readm3u( const QString &filename ) { 769void PlayListWidget::readm3u( const QString &filename ) {
766 qDebug( "read m3u filename " + filename ); 770 qDebug( "read m3u filename " + filename );
767 771
768 Om3u *m3uList; 772 Om3u *m3uList;
769 QString s, name; 773 QString s, name;
@@ -775,37 +779,39 @@ void PlayListWidget::readm3u( const QString &filename ) {
775// qDebug("reading "+ s); 779// qDebug("reading "+ s);
776 if(s.left(4)=="http") { 780 if(s.left(4)=="http") {
777 lnk.setName( s ); //sets file name 781 lnk.setName( s ); //sets file name
778 lnk.setIcon("opieplayer2/musicfile"); 782 lnk.setIcon("opieplayer2/musicfile");
779// if(s.right(4) != '.' || s.right(5) != '.') 783// if(s.right(4) != '.' || s.right(5) != '.')
780// lnk.setFile( s+"/"); //if url with no extension 784// lnk.setFile( s+"/"); //if url with no extension
781// else 785// else
782 lnk.setFile( s ); //sets file name 786 lnk.setFile( s ); //sets file name
783 787
784 } else { 788 } else {
785 // if( QFileInfo( s ).exists() ) { 789 // if( QFileInfo( s ).exists() ) {
786 lnk.setName( QFileInfo(s).baseName()); 790 lnk.setName( QFileInfo(s).baseName());
787 // if(s.right(4) == '.') {//if regular file 791 // if(s.right(4) == '.') {//if regular file
788 if(s.left(1) != "/") { 792 if(s.left(1) != "/") {
789 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); 793 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s);
790 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); 794 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s);
791 lnk.setIcon("SoundPlayer"); 795// lnk.setIcon(MimeType(s).pixmap() );
796// lnk.setIcon("SoundPlayer");
792 } else { 797 } else {
793 // qDebug("set link2 "+s); 798 // qDebug("set link2 "+s);
794 lnk.setFile( s); 799 lnk.setFile( s);
795 lnk.setIcon("SoundPlayer"); 800// lnk.setIcon(MimeType(s).pixmap() );
801// lnk.setIcon("SoundPlayer");
796 } 802 }
797 } 803 }
798 d->selectedFiles->addToSelection( lnk ); 804 d->selectedFiles->addToSelection( lnk );
799 } 805 }
800 Config config( "OpiePlayer" ); 806 Config config( "OpiePlayer" );
801 config.setGroup( "PlayList" ); 807 config.setGroup( "PlayList" );
802 808
803 config.writeEntry("CurrentPlaylist",filename); 809 config.writeEntry("CurrentPlaylist",filename);
804 config.write(); 810 config.write();
805 currentPlayList=filename; 811 currentPlayList=filename;
806 812
807// m3uList->write(); 813// m3uList->write();
808 m3uList->close(); 814 m3uList->close();
809 if(m3uList) delete m3uList; 815 if(m3uList) delete m3uList;
810 816
811 d->selectedFiles->setSelectedItem( s); 817 d->selectedFiles->setSelectedItem( s);
@@ -829,61 +835,61 @@ void PlayListWidget::readPls( const QString &filename ) {
829 DocLnk lnk( s ); 835 DocLnk lnk( s );
830 QFileInfo f( s ); 836 QFileInfo f( s );
831 QString name = f.baseName(); 837 QString name = f.baseName();
832 838
833 if( name.left( 4 ) == "http" ) { 839 if( name.left( 4 ) == "http" ) {
834 name = s.right( s.length() - 7); 840 name = s.right( s.length() - 7);
835 } else { 841 } else {
836 name = s; 842 name = s;
837 } 843 }
838 844
839 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); 845 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
840 846
841 lnk.setName( name ); 847 lnk.setName( name );
842 if( s.at( s.length() - 4) == '.') {// if this is probably a file 848 if( s.at( s.length() - 4) == '.') {// if this is probably a file
843 lnk.setFile( s ); 849 lnk.setFile( s );
844 } else { //if its a url 850 } else { //if its a url
845 if( name.right( 1 ).find( '/' ) == -1) { 851// if( name.right( 1 ).find( '/' ) == -1) {
846 s += "/"; 852// s += "/";
847 } 853// }
848 lnk.setFile( s ); 854 lnk.setFile( s );
849 } 855 }
850 lnk.setType( "audio/x-mpegurl" ); 856 lnk.setType( "audio/x-mpegurl" );
851 857
852 lnk.writeLink(); 858 lnk.writeLink();
853 d->selectedFiles->addToSelection( lnk ); 859 d->selectedFiles->addToSelection( lnk );
854 } 860 }
855 861
856 m3uList->close(); 862 m3uList->close();
857 if(m3uList) delete m3uList; 863 if(m3uList) delete m3uList;
858} 864}
859 865
860/* 866/*
861 writes current playlist to current m3u file */ 867 writes current playlist to current m3u file */
862void PlayListWidget::writeCurrentM3u() { 868void PlayListWidget::writeCurrentM3u() {
863 qDebug("writing to current m3u"); 869 qDebug("writing to current m3u");
864 Config cfg( "OpiePlayer" ); 870 Config cfg( "OpiePlayer" );
865 cfg.setGroup("PlayList"); 871 cfg.setGroup("PlayList");
866 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); 872 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default");
867 873
868 if( d->selectedFiles->first()) {
869 Om3u *m3uList; 874 Om3u *m3uList;
870 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); 875 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate );
876 if( d->selectedFiles->first()) {
871 877
872 do { 878 do {
873 qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); 879 qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file());
874 m3uList->add( d->selectedFiles->current()->file() ); 880 m3uList->add( d->selectedFiles->current()->file() );
875 } 881 }
876 while ( d->selectedFiles->next() ); 882 while ( d->selectedFiles->next() );
877 qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); 883 qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" );
878 m3uList->write(); 884 m3uList->write();
879 m3uList->close(); 885 m3uList->close();
880 886
881 if(m3uList) delete m3uList; 887 if(m3uList) delete m3uList;
882 } 888 }
883} 889}
884 890
885 /* 891 /*
886 writes current playlist to m3u file */ 892 writes current playlist to m3u file */
887void PlayListWidget::writem3u() { 893void PlayListWidget::writem3u() {
888 InputDialog *fileDlg; 894 InputDialog *fileDlg;
889 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); 895 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
@@ -906,33 +912,33 @@ void PlayListWidget::writem3u() {
906 if( d->selectedFiles->first()) { 912 if( d->selectedFiles->first()) {
907 m3uList = new Om3u(filename, IO_ReadWrite); 913 m3uList = new Om3u(filename, IO_ReadWrite);
908 914
909 do { 915 do {
910 m3uList->add( d->selectedFiles->current()->file()); 916 m3uList->add( d->selectedFiles->current()->file());
911 } 917 }
912 while ( d->selectedFiles->next() ); 918 while ( d->selectedFiles->next() );
913 // qDebug( list ); 919 // qDebug( list );
914 m3uList->write(); 920 m3uList->write();
915 m3uList->close(); 921 m3uList->close();
916 if(m3uList) delete m3uList; 922 if(m3uList) delete m3uList;
917 923
918 if(fileDlg) delete fileDlg; 924 if(fileDlg) delete fileDlg;
919 925
920 DocLnk lnk; 926 DocLnk lnk;
921 lnk.setFile( filename); 927 lnk.setFile( filename);
922 lnk.setIcon("opieplayer2/playlist2"); 928// lnk.setIcon("opieplayer2/playlist2");
923 lnk.setName( name); //sets file name 929 lnk.setName( name); //sets file name
924 930
925 // qDebug(filename); 931 // qDebug(filename);
926 Config config( "OpiePlayer" ); 932 Config config( "OpiePlayer" );
927 config.setGroup( "PlayList" ); 933 config.setGroup( "PlayList" );
928 934
929 config.writeEntry("CurrentPlaylist",filename); 935 config.writeEntry("CurrentPlaylist",filename);
930 currentPlayList=filename; 936 currentPlayList=filename;
931 937
932 if(!lnk.writeLink()) { 938 if(!lnk.writeLink()) {
933 qDebug("Writing doclink did not work"); 939 qDebug("Writing doclink did not work");
934 } 940 }
935 941
936 setCaption(tr("OpiePlayer: ") + name); 942 setCaption(tr("OpiePlayer: ") + name);
937 } 943 }
938 } 944 }