summaryrefslogtreecommitdiff
authorzecke <zecke>2005-05-12 21:21:14 (UTC)
committer zecke <zecke>2005-05-12 21:21:14 (UTC)
commited2d14794cee66441f06be923623694f4ad2e06b (patch) (unidiff)
tree92a30a25343f9aa97285ed4f8d95209923ab1c0d
parent9d1113376da0ba95a5b4121bd953756311ac5a97 (diff)
downloadopie-ed2d14794cee66441f06be923623694f4ad2e06b.zip
opie-ed2d14794cee66441f06be923623694f4ad2e06b.tar.gz
opie-ed2d14794cee66441f06be923623694f4ad2e06b.tar.bz2
Fix for #1657 to show the play button when we've playable files
patch courtsey Gints Polis
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 83eb83b..98326a8 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -721,96 +721,102 @@ void PlayListWidget::openFile() {
721 721
722 Config cfg( "OpiePlayer" ); 722 Config cfg( "OpiePlayer" );
723 cfg.setGroup("Dialog"); 723 cfg.setGroup("Dialog");
724 MimeTypes types = fileSelectorMimeTypes(); 724 MimeTypes types = fileSelectorMimeTypes();
725 725
726 726
727 QString str = OFileDialog::getOpenFileName( 1, QString::null, 727 QString str = OFileDialog::getOpenFileName( 1, QString::null,
728 QString::null, types, 0, 728 QString::null, types, 0,
729 tr("Add File to Playlist") ); 729 tr("Add File to Playlist") );
730 730
731 if( str.isEmpty() ) 731 if( str.isEmpty() )
732 return; 732 return;
733 733
734 if(str.left(2) == "//") str=str.right(str.length()-1); 734 if(str.left(2) == "//") str=str.right(str.length()-1);
735 735
736 736
737 if( str.right( 3) == "m3u" || str.right(3) == "pls" ) { 737 if( str.right( 3) == "m3u" || str.right(3) == "pls" ) {
738 readListFromFile( str ); 738 readListFromFile( str );
739 } else { 739 } else {
740 QFileInfo info( str ); 740 QFileInfo info( str );
741 DocLnk lnk = addFileToPlaylist( str, info.baseName() ); 741 DocLnk lnk = addFileToPlaylist( str, info.baseName() );
742 d->selectedFiles->setSelectedItem( lnk.name() ); 742 d->selectedFiles->setSelectedItem( lnk.name() );
743 } 743 }
744 744
745 setButtons(); 745 setButtons();
746} 746}
747 747
748void PlayListWidget::openDirectory() { 748void PlayListWidget::openDirectory() {
749 QString str = OFileDialog::getDirectory( OFileSelector::DirectorySelector, 749 QString str = OFileDialog::getDirectory( OFileSelector::DirectorySelector,
750 QString::null, 0, 750 QString::null, 0,
751 tr( "Add Files from Directory")); 751 tr( "Add Files from Directory"));
752 752
753 if(str.isEmpty() ) 753 if(str.isEmpty() )
754 return; 754 return;
755 755
756 if(str.left(2) == "//") str=str.right(str.length()-1); 756 if(str.left(2) == "//") str=str.right(str.length()-1);
757 QDir dir( str ); 757 QDir dir( str );
758 QStringList lst = dir.entryList(QDir::Files|QDir::Readable); 758 QStringList lst = dir.entryList(QDir::Files|QDir::Readable);
759 759
760 for ( QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { 760 for ( QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) {
761 QString filename = str + "/" + *it; 761 QString filename = str + "/" + *it;
762 762
763 if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) 763 if( filename.right( 3) == "m3u" || filename.right(3) == "pls" )
764 readListFromFile( filename ); 764 readListFromFile( filename );
765 else { 765 else {
766 addFileToPlaylist( filename, QFileInfo(*it).baseName() ); 766 addFileToPlaylist( filename, QFileInfo(*it).baseName() );
767 } 767 }
768 } 768 }
769
770 if (!d->selectedFiles->isEmpty()) {
771 d->selectedFiles->first();
772
773 setButtons();
774 }
769} 775}
770 776
771void PlayListWidget::readListFromFile( const QString &filename ) { 777void PlayListWidget::readListFromFile( const QString &filename ) {
772 odebug << "read list filename " + filename << oendl; 778 odebug << "read list filename " + filename << oendl;
773 QFileInfo fi(filename); 779 QFileInfo fi(filename);
774 Om3u *m3uList; 780 Om3u *m3uList;
775 QString s, name; 781 QString s, name;
776 m3uList = new Om3u( filename, IO_ReadOnly ); 782 m3uList = new Om3u( filename, IO_ReadOnly );
777 if(fi.extension(false).find("m3u",0,false) != -1 ) 783 if(fi.extension(false).find("m3u",0,false) != -1 )
778 m3uList->readM3u(); 784 m3uList->readM3u();
779 else if(fi.extension(false).find("pls",0,false) != -1 ) 785 else if(fi.extension(false).find("pls",0,false) != -1 )
780 m3uList->readPls(); 786 m3uList->readPls();
781 787
782 DocLnk lnk; 788 DocLnk lnk;
783 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 789 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
784 s = *it; 790 s = *it;
785 // odebug << s << oendl; 791 // odebug << s << oendl;
786 if(s.left(4)=="http") { 792 if(s.left(4)=="http") {
787 lnk.setName( s ); //sets file name 793 lnk.setName( s ); //sets file name
788 lnk.setIcon("opieplayer2/musicfile"); 794 lnk.setIcon("opieplayer2/musicfile");
789 lnk.setFile( s ); //sets file name 795 lnk.setFile( s ); //sets file name
790 796
791 } else { //is file 797 } else { //is file
792 lnk.setName( QFileInfo(s).baseName()); 798 lnk.setName( QFileInfo(s).baseName());
793 if(s.left(1) != "/") { 799 if(s.left(1) != "/") {
794 800
795 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); 801 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s);
796 } else { 802 } else {
797 lnk.setFile( s); 803 lnk.setFile( s);
798 } 804 }
799 } 805 }
800 d->selectedFiles->addToSelection( lnk ); 806 d->selectedFiles->addToSelection( lnk );
801 } 807 }
802 Config config( "OpiePlayer" ); 808 Config config( "OpiePlayer" );
803 config.setGroup( "PlayList" ); 809 config.setGroup( "PlayList" );
804 810
805 config.writeEntry("CurrentPlaylist",filename); 811 config.writeEntry("CurrentPlaylist",filename);
806 config.write(); 812 config.write();
807 currentPlayList=filename; 813 currentPlayList=filename;
808 814
809 m3uList->close(); 815 m3uList->close();
810 delete m3uList; 816 delete m3uList;
811 817
812 d->selectedFiles->setSelectedItem( s); 818 d->selectedFiles->setSelectedItem( s);
813 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); 819 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName());
814 820
815 setButtons(); 821 setButtons();
816} 822}