-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.cpp | 1 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 108 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.h | 2 |
3 files changed, 64 insertions, 47 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index b8023ca..043d8ba 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp | |||
@@ -128,65 +128,64 @@ void MediaPlayer::prev() { | |||
128 | if ( playList.prev() ) { | 128 | if ( playList.prev() ) { |
129 | play(); | 129 | play(); |
130 | } else if ( mediaPlayerState.isLooping() ) { | 130 | } else if ( mediaPlayerState.isLooping() ) { |
131 | if ( playList.last() ) { | 131 | if ( playList.last() ) { |
132 | play(); | 132 | play(); |
133 | } | 133 | } |
134 | } else { | 134 | } else { |
135 | mediaPlayerState.setList(); | 135 | mediaPlayerState.setList(); |
136 | } | 136 | } |
137 | } | 137 | } |
138 | } | 138 | } |
139 | 139 | ||
140 | 140 | ||
141 | void MediaPlayer::next() { | 141 | void MediaPlayer::next() { |
142 | 142 | ||
143 | if(playList.currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist | 143 | if(playList.currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist |
144 | if ( playList.next() ) { | 144 | if ( playList.next() ) { |
145 | play(); | 145 | play(); |
146 | } else if ( mediaPlayerState.isLooping() ) { | 146 | } else if ( mediaPlayerState.isLooping() ) { |
147 | if ( playList.first() ) { | 147 | if ( playList.first() ) { |
148 | play(); | 148 | play(); |
149 | } | 149 | } |
150 | } else { | 150 | } else { |
151 | mediaPlayerState.setList(); | 151 | mediaPlayerState.setList(); |
152 | } | 152 | } |
153 | } else { //if playing from file list, let's just stop | 153 | } else { //if playing from file list, let's just stop |
154 | odebug << "<<<<<<<<<<<<<<<<<stop for filelists" << oendl; | 154 | odebug << "<<<<<<<<<<<<<<<<<stop for filelists" << oendl; |
155 | mediaPlayerState.setPlaying(false); | 155 | mediaPlayerState.setPlaying(false); |
156 | mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); | 156 | mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); |
157 | if(l) mediaPlayerState.setLooping(l); | 157 | if(l) mediaPlayerState.setLooping(l); |
158 | if(r) mediaPlayerState.setShuffled(r); | 158 | if(r) mediaPlayerState.setShuffled(r); |
159 | } | 159 | } |
160 | qApp->processEvents(); | ||
161 | } | 160 | } |
162 | 161 | ||
163 | 162 | ||
164 | void MediaPlayer::startDecreasingVolume() { | 163 | void MediaPlayer::startDecreasingVolume() { |
165 | volumeDirection = -1; | 164 | volumeDirection = -1; |
166 | startTimer( 100 ); | 165 | startTimer( 100 ); |
167 | volControl->decVol(2); | 166 | volControl->decVol(2); |
168 | } | 167 | } |
169 | 168 | ||
170 | 169 | ||
171 | void MediaPlayer::startIncreasingVolume() { | 170 | void MediaPlayer::startIncreasingVolume() { |
172 | volumeDirection = +1; | 171 | volumeDirection = +1; |
173 | startTimer( 100 ); | 172 | startTimer( 100 ); |
174 | volControl->incVol(2); | 173 | volControl->incVol(2); |
175 | } | 174 | } |
176 | 175 | ||
177 | 176 | ||
178 | bool drawnOnScreenDisplay = FALSE; | 177 | bool drawnOnScreenDisplay = FALSE; |
179 | unsigned int onScreenDisplayVolume = 0; | 178 | unsigned int onScreenDisplayVolume = 0; |
180 | const int yoff = 110; | 179 | const int yoff = 110; |
181 | 180 | ||
182 | void MediaPlayer::stopChangingVolume() { | 181 | void MediaPlayer::stopChangingVolume() { |
183 | killTimers(); | 182 | killTimers(); |
184 | // Get rid of the on-screen display stuff | 183 | // Get rid of the on-screen display stuff |
185 | drawnOnScreenDisplay = FALSE; | 184 | drawnOnScreenDisplay = FALSE; |
186 | onScreenDisplayVolume = 0; | 185 | onScreenDisplayVolume = 0; |
187 | int w=0; | 186 | int w=0; |
188 | int h=0; | 187 | int h=0; |
189 | if( !xineControl()->hasVideo() ) { | 188 | if( !xineControl()->hasVideo() ) { |
190 | w = audioUI()->width(); | 189 | w = audioUI()->width(); |
191 | h = audioUI()->height(); | 190 | h = audioUI()->height(); |
192 | audioUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); | 191 | audioUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); |
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 37b998f..dc2c496 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -56,64 +56,66 @@ PlayListWidget::PlayListWidget(QWidget* parent, const char* name, WFlags fl ) | |||
56 | { | 56 | { |
57 | Global::statusMessage( tr( "Loading of Skin started" ) ); | 57 | Global::statusMessage( tr( "Loading of Skin started" ) ); |
58 | mediaPlayerState = new MediaPlayerState(0, "mediaPlayerState" ); | 58 | mediaPlayerState = new MediaPlayerState(0, "mediaPlayerState" ); |
59 | m_mp = new MediaPlayer(*this, *mediaPlayerState, 0, "mediaPlayer"); | 59 | m_mp = new MediaPlayer(*this, *mediaPlayerState, 0, "mediaPlayer"); |
60 | 60 | ||
61 | 61 | ||
62 | 62 | ||
63 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), | 63 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), |
64 | "opieplayer2/add_to_playlist", | 64 | "opieplayer2/add_to_playlist", |
65 | this , SLOT(addSelected() ) ); | 65 | this , SLOT(addSelected() ) ); |
66 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), | 66 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), |
67 | "opieplayer2/remove_from_playlist", | 67 | "opieplayer2/remove_from_playlist", |
68 | this , SLOT(removeSelected() ) ); | 68 | this , SLOT(removeSelected() ) ); |
69 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", | 69 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", |
70 | this , SLOT( btnPlay(bool) ), TRUE ); | 70 | this , SLOT( btnPlay(bool) ), TRUE ); |
71 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", | 71 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", |
72 | mediaPlayerState, SLOT( setShuffled(bool) ), TRUE ); | 72 | mediaPlayerState, SLOT( setShuffled(bool) ), TRUE ); |
73 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", | 73 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", |
74 | mediaPlayerState, SLOT( setLooping(bool) ), TRUE ); | 74 | mediaPlayerState, SLOT( setLooping(bool) ), TRUE ); |
75 | 75 | ||
76 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 76 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
77 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), | 77 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), |
78 | this, SLOT( addAllMusicToList() ) ); | 78 | this, SLOT( addAllMusicToList() ) ); |
79 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), | 79 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), |
80 | this, SLOT( addAllVideoToList() ) ); | 80 | this, SLOT( addAllVideoToList() ) ); |
81 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), | 81 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), |
82 | this, SLOT( addAllToList() ) ); | 82 | this, SLOT( addAllToList() ) ); |
83 | pmPlayList->insertSeparator(-1); | 83 | pmPlayList->insertSeparator(-1); |
84 | (void)new MenuItem( pmPlayList, tr( "Add File" ), | 84 | (void)new MenuItem( pmPlayList, tr( "Add File" ), |
85 | this,SLOT( openFile() ) ); | 85 | this,SLOT( openFile() ) ); |
86 | (void)new MenuItem( pmPlayList, tr("Add URL"), | 86 | (void)new MenuItem( pmPlayList, tr("Add URL"), |
87 | this,SLOT( openURL() ) ); | 87 | this,SLOT( openURL() ) ); |
88 | (void)new MenuItem( pmPlayList, tr( "Add Directory"), | ||
89 | this, SLOT(openDirectory())); | ||
88 | pmPlayList->insertSeparator(-1); | 90 | pmPlayList->insertSeparator(-1); |
89 | (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), | 91 | (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), |
90 | this, SLOT(writem3u() ) ); | 92 | this, SLOT(writem3u() ) ); |
91 | pmPlayList->insertSeparator(-1); | 93 | pmPlayList->insertSeparator(-1); |
92 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), | 94 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), |
93 | audioView, SLOT( scanFiles() ) ); | 95 | audioView, SLOT( scanFiles() ) ); |
94 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), | 96 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), |
95 | videoView, SLOT( scanFiles() ) ); | 97 | videoView, SLOT( scanFiles() ) ); |
96 | 98 | ||
97 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), | 99 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), |
98 | mediaPlayerState, SLOT( toggleFullscreen() ) ); | 100 | mediaPlayerState, SLOT( toggleFullscreen() ) ); |
99 | 101 | ||
100 | Config cfg( "OpiePlayer" ); | 102 | Config cfg( "OpiePlayer" ); |
101 | bool b= cfg.readBoolEntry("FullScreen", 0); | 103 | bool b= cfg.readBoolEntry("FullScreen", 0); |
102 | mediaPlayerState->setFullscreen( b ); | 104 | mediaPlayerState->setFullscreen( b ); |
103 | pmView->setItemChecked( -16, b ); | 105 | pmView->setItemChecked( -16, b ); |
104 | 106 | ||
105 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", | 107 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", |
106 | d->selectedFiles, SLOT(moveSelectedUp() ) ); | 108 | d->selectedFiles, SLOT(moveSelectedUp() ) ); |
107 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", | 109 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", |
108 | d->selectedFiles, SLOT(removeSelected() ) ); | 110 | d->selectedFiles, SLOT(removeSelected() ) ); |
109 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", | 111 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", |
110 | d->selectedFiles, SLOT(moveSelectedDown() ) ); | 112 | d->selectedFiles, SLOT(moveSelectedDown() ) ); |
111 | QVBox *stretch2 = new QVBox( vbox1 ); | 113 | QVBox *stretch2 = new QVBox( vbox1 ); |
112 | 114 | ||
113 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), | 115 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), |
114 | SLOT( deletePlaylist() ) ); | 116 | SLOT( deletePlaylist() ) ); |
115 | connect( pmView, SIGNAL( activated(int) ), | 117 | connect( pmView, SIGNAL( activated(int) ), |
116 | this, SLOT( pmViewActivated(int) ) ); | 118 | this, SLOT( pmViewActivated(int) ) ); |
117 | connect( skinsMenu, SIGNAL( activated(int) ) , | 119 | connect( skinsMenu, SIGNAL( activated(int) ) , |
118 | this, SLOT( skinsMenuActivated(int) ) ); | 120 | this, SLOT( skinsMenuActivated(int) ) ); |
119 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), | 121 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), |
@@ -633,114 +635,135 @@ void PlayListWidget::openURL() { | |||
633 | } else if(filename.left(4) == "http"){ | 635 | } else if(filename.left(4) == "http"){ |
634 | m3uFile=filename; | 636 | m3uFile=filename; |
635 | m3uFile = m3uFile.right( m3uFile.length() - 7); | 637 | m3uFile = m3uFile.right( m3uFile.length() - 7); |
636 | } else{ | 638 | } else{ |
637 | m3uFile=filename; | 639 | m3uFile=filename; |
638 | } | 640 | } |
639 | 641 | ||
640 | lnk.setName( filename ); //sets name | 642 | lnk.setName( filename ); //sets name |
641 | lnk.setFile( filename ); //sets file name | 643 | lnk.setFile( filename ); //sets file name |
642 | 644 | ||
643 | // lnk.setIcon("opieplayer2/musicfile"); | 645 | // lnk.setIcon("opieplayer2/musicfile"); |
644 | 646 | ||
645 | d->selectedFiles->addToSelection( lnk ); | 647 | d->selectedFiles->addToSelection( lnk ); |
646 | writeCurrentM3u(); | 648 | writeCurrentM3u(); |
647 | d->selectedFiles->setSelectedItem( lnk.name()); | 649 | d->selectedFiles->setSelectedItem( lnk.name()); |
648 | } | 650 | } |
649 | else if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { | 651 | else if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { |
650 | readListFromFile( filename ); | 652 | readListFromFile( filename ); |
651 | } else { | 653 | } else { |
652 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 654 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
653 | lnk.setFile( filename ); //sets file name | 655 | lnk.setFile( filename ); //sets file name |
654 | d->selectedFiles->addToSelection( lnk); | 656 | d->selectedFiles->addToSelection( lnk); |
655 | writeCurrentM3u(); | 657 | writeCurrentM3u(); |
656 | d->selectedFiles->setSelectedItem( lnk.name()); | 658 | d->selectedFiles->setSelectedItem( lnk.name()); |
657 | } | 659 | } |
658 | } | 660 | } |
659 | 661 | ||
660 | 662 | ||
661 | delete fileDlg; | 663 | delete fileDlg; |
662 | } | 664 | } |
663 | 665 | ||
664 | 666 | ||
665 | void PlayListWidget::openFile() { | 667 | static MimeTypes fileSelectorMimeTypes() { |
666 | |||
667 | QString filename, name; | ||
668 | |||
669 | Config cfg( "OpiePlayer" ); | ||
670 | cfg.setGroup("Dialog"); | ||
671 | MimeTypes types; | 668 | MimeTypes types; |
672 | QStringList audio, video, all; | 669 | QStringList audio, video, all; |
673 | audio << "audio/*"; | 670 | audio << "audio/*"; |
674 | audio << "playlist/plain"; | 671 | audio << "playlist/plain"; |
675 | audio << "audio/x-ogg"; | 672 | audio << "audio/x-ogg"; |
676 | audio << "audio/x-mpegurl"; | 673 | audio << "audio/x-mpegurl"; |
677 | 674 | ||
678 | video << "video/*"; | 675 | video << "video/*"; |
679 | video << "playlist/plain"; | 676 | video << "playlist/plain"; |
680 | 677 | ||
681 | all += audio; | 678 | all += audio; |
682 | all += video; | 679 | all += video; |
683 | types.insert("All Media Files", all ); | 680 | types.insert("All Media Files", all ); |
684 | types.insert("Audio", audio ); | 681 | types.insert("Audio", audio ); |
685 | types.insert("Video", video ); | 682 | types.insert("Video", video ); |
686 | 683 | ||
687 | QString str = OFileDialog::getOpenFileName( 1, | 684 | return types; |
688 | cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", | 685 | } |
689 | types, 0 ); | 686 | |
687 | void PlayListWidget::openFile() { | ||
688 | |||
689 | QString filename, name; | ||
690 | |||
691 | Config cfg( "OpiePlayer" ); | ||
692 | cfg.setGroup("Dialog"); | ||
693 | MimeTypes types = fileSelectorMimeTypes(); | ||
694 | |||
695 | |||
696 | QString str = OFileDialog::getOpenFileName( 1, QString::null, | ||
697 | QString::null, types, 0, | ||
698 | tr("Add File to Playlist") ); | ||
699 | |||
700 | if( str.isEmpty() ) | ||
701 | return; | ||
702 | |||
703 | if(str.left(2) == "//") str=str.right(str.length()-1); | ||
704 | |||
690 | 705 | ||
691 | if(str.left(2) == "//") { | 706 | if( str.right( 3) == "m3u" || str.right(3) == "pls" ) { |
692 | str=str.right(str.length()-1); | 707 | readListFromFile( str ); |
708 | } else { | ||
709 | QFileInfo info( str ); | ||
710 | DocLnk lnk = addFileToPlaylist( str, info.baseName() ); | ||
711 | d->selectedFiles->setSelectedItem( lnk.name() ); | ||
693 | } | 712 | } |
694 | cfg.writeEntry( "LastDirectory" ,QFileInfo( str ).dirPath() ); | 713 | } |
695 | 714 | ||
696 | if( !str.isEmpty() ) { | 715 | void PlayListWidget::openDirectory() { |
716 | QString str = OFileDialog::getDirectory( OFileSelector::DirectorySelector, | ||
717 | QString::null, 0, | ||
718 | tr( "Add Files from Directory")); | ||
697 | 719 | ||
698 | odebug << "Selected filename is " + str << oendl; | 720 | if(str.isEmpty() ) |
699 | filename = str; | 721 | return; |
700 | DocLnk lnk; | 722 | |
723 | if(str.left(2) == "//") str=str.right(str.length()-1); | ||
724 | QDir dir( str ); | ||
725 | QStringList lst = dir.entryList(QDir::Files|QDir::Readable); | ||
701 | 726 | ||
702 | if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { | 727 | for ( QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { |
728 | QString filename = str + "/" + *it; | ||
729 | |||
730 | if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) | ||
703 | readListFromFile( filename ); | 731 | readListFromFile( filename ); |
704 | } else { | 732 | else { |
705 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 733 | addFileToPlaylist( filename, QFileInfo(*it).baseName() ); |
706 | lnk.setFile( filename ); //sets file name | ||
707 | d->selectedFiles->addToSelection( lnk ); | ||
708 | writeCurrentM3u(); | ||
709 | d->selectedFiles->setSelectedItem( lnk.name() ); | ||
710 | } | 734 | } |
711 | } | 735 | } |
712 | } | 736 | } |
713 | 737 | ||
714 | |||
715 | void PlayListWidget::readListFromFile( const QString &filename ) { | 738 | void PlayListWidget::readListFromFile( const QString &filename ) { |
716 | odebug << "read list filename " + filename << oendl; | 739 | odebug << "read list filename " + filename << oendl; |
717 | QFileInfo fi(filename); | 740 | QFileInfo fi(filename); |
718 | Om3u *m3uList; | 741 | Om3u *m3uList; |
719 | QString s, name; | 742 | QString s, name; |
720 | m3uList = new Om3u( filename, IO_ReadOnly ); | 743 | m3uList = new Om3u( filename, IO_ReadOnly ); |
721 | if(fi.extension(false).find("m3u",0,false) != -1 ) | 744 | if(fi.extension(false).find("m3u",0,false) != -1 ) |
722 | m3uList->readM3u(); | 745 | m3uList->readM3u(); |
723 | else if(fi.extension(false).find("pls",0,false) != -1 ) | 746 | else if(fi.extension(false).find("pls",0,false) != -1 ) |
724 | m3uList->readPls(); | 747 | m3uList->readPls(); |
725 | 748 | ||
726 | DocLnk lnk; | 749 | DocLnk lnk; |
727 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 750 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
728 | s = *it; | 751 | s = *it; |
729 | // odebug << s << oendl; | 752 | // odebug << s << oendl; |
730 | if(s.left(4)=="http") { | 753 | if(s.left(4)=="http") { |
731 | lnk.setName( s ); //sets file name | 754 | lnk.setName( s ); //sets file name |
732 | lnk.setIcon("opieplayer2/musicfile"); | 755 | lnk.setIcon("opieplayer2/musicfile"); |
733 | lnk.setFile( s ); //sets file name | 756 | lnk.setFile( s ); //sets file name |
734 | 757 | ||
735 | } else { //is file | 758 | } else { //is file |
736 | lnk.setName( QFileInfo(s).baseName()); | 759 | lnk.setName( QFileInfo(s).baseName()); |
737 | if(s.left(1) != "/") { | 760 | if(s.left(1) != "/") { |
738 | 761 | ||
739 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 762 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
740 | } else { | 763 | } else { |
741 | lnk.setFile( s); | 764 | lnk.setFile( s); |
742 | } | 765 | } |
743 | } | 766 | } |
744 | d->selectedFiles->addToSelection( lnk ); | 767 | d->selectedFiles->addToSelection( lnk ); |
745 | } | 768 | } |
746 | Config config( "OpiePlayer" ); | 769 | Config config( "OpiePlayer" ); |
@@ -756,91 +779,74 @@ void PlayListWidget::readListFromFile( const QString &filename ) { | |||
756 | d->selectedFiles->setSelectedItem( s); | 779 | d->selectedFiles->setSelectedItem( s); |
757 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); | 780 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); |
758 | 781 | ||
759 | } | 782 | } |
760 | 783 | ||
761 | // writes current playlist to current m3u file */ | 784 | // writes current playlist to current m3u file */ |
762 | void PlayListWidget::writeCurrentM3u() { | 785 | void PlayListWidget::writeCurrentM3u() { |
763 | odebug << "writing to current m3u" << oendl; | 786 | odebug << "writing to current m3u" << oendl; |
764 | Config cfg( "OpiePlayer" ); | 787 | Config cfg( "OpiePlayer" ); |
765 | cfg.setGroup("PlayList"); | 788 | cfg.setGroup("PlayList"); |
766 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); | 789 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); |
767 | 790 | ||
768 | Om3u *m3uList; | 791 | Om3u *m3uList; |
769 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 792 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
770 | if( d->selectedFiles->first()) { | 793 | if( d->selectedFiles->first()) { |
771 | 794 | ||
772 | do { | 795 | do { |
773 | // odebug << "add writeCurrentM3u " +d->selectedFiles->current()->file() << oendl; | 796 | // odebug << "add writeCurrentM3u " +d->selectedFiles->current()->file() << oendl; |
774 | m3uList->add( d->selectedFiles->current()->file() ); | 797 | m3uList->add( d->selectedFiles->current()->file() ); |
775 | } | 798 | } |
776 | while ( d->selectedFiles->next() ); | 799 | while ( d->selectedFiles->next() ); |
777 | // odebug << "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" << oendl; | 800 | // odebug << "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" << oendl; |
778 | m3uList->write(); | 801 | m3uList->write(); |
779 | m3uList->close(); | 802 | m3uList->close(); |
780 | } | 803 | } |
781 | delete m3uList; | 804 | delete m3uList; |
782 | 805 | ||
783 | } | 806 | } |
784 | 807 | ||
785 | /* | 808 | /* |
786 | writes current playlist to m3u file */ | 809 | writes current playlist to m3u file */ |
787 | void PlayListWidget::writem3u() { | 810 | void PlayListWidget::writem3u() { |
788 | //InputDilog *fileDlg; | ||
789 | //fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | ||
790 | //fileDlg->exec(); | ||
791 | 811 | ||
792 | Config cfg( "OpiePlayer" ); | 812 | Config cfg( "OpiePlayer" ); |
793 | cfg.setGroup("Dialog"); | 813 | cfg.setGroup("Dialog"); |
794 | MimeTypes types; | 814 | MimeTypes types = fileSelectorMimeTypes(); |
795 | QStringList audio, video, all; | ||
796 | audio << "audio/*"; | ||
797 | audio << "playlist/plain"; | ||
798 | audio << "audio/x-mpegurl"; | ||
799 | 815 | ||
800 | video << "video/*"; | 816 | QString str = OFileDialog::getOpenFileName( 1, QString::null, |
801 | video << "playlist/plain"; | 817 | QString::null, types, 0, |
818 | tr( "Save Playlist" )); | ||
802 | 819 | ||
803 | all += audio; | ||
804 | all += video; | ||
805 | types.insert("All Media Files", all ); | ||
806 | types.insert("Audio", audio ); | ||
807 | types.insert("Video", video ); | ||
808 | |||
809 | QString str = OFileDialog::getOpenFileName( 1, | ||
810 | cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", | ||
811 | types, 0 ); | ||
812 | if(str.left(2) == "//") str=str.right(str.length()-1); | 820 | if(str.left(2) == "//") str=str.right(str.length()-1); |
813 | cfg.writeEntry("LastDirectory" ,QFileInfo(str).dirPath()); | ||
814 | |||
815 | 821 | ||
816 | QString name, filename, list; | 822 | QString name, filename, list; |
817 | Om3u *m3uList; | 823 | Om3u *m3uList; |
818 | 824 | ||
819 | if( !str.isEmpty() ) { | 825 | if( !str.isEmpty() ) { |
820 | name = str; | 826 | name = str; |
821 | // name = fileDlg->text(); | 827 | // name = fileDlg->text(); |
822 | // odebug << filename << oendl; | 828 | // odebug << filename << oendl; |
823 | if( name.find("/",0,true) != -1) {// assume they specify a file path | 829 | if( name.find("/",0,true) != -1) {// assume they specify a file path |
824 | filename = name; | 830 | filename = name; |
825 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); | 831 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); |
826 | } | 832 | } |
827 | else //otherwise dump it somewhere noticable | 833 | else //otherwise dump it somewhere noticable |
828 | filename = QPEApplication::documentDir() + "/" + name; | 834 | filename = QPEApplication::documentDir() + "/" + name; |
829 | 835 | ||
830 | if( filename.right( 3 ) != "m3u" ) //needs filename extension | 836 | if( filename.right( 3 ) != "m3u" ) //needs filename extension |
831 | filename += ".m3u"; | 837 | filename += ".m3u"; |
832 | 838 | ||
833 | if( d->selectedFiles->first()) { //ramble through playlist view | 839 | if( d->selectedFiles->first()) { //ramble through playlist view |
834 | m3uList = new Om3u( filename, IO_ReadWrite | IO_Truncate); | 840 | m3uList = new Om3u( filename, IO_ReadWrite | IO_Truncate); |
835 | 841 | ||
836 | do { | 842 | do { |
837 | m3uList->add( d->selectedFiles->current()->file()); | 843 | m3uList->add( d->selectedFiles->current()->file()); |
838 | } | 844 | } |
839 | while ( d->selectedFiles->next() ); | 845 | while ( d->selectedFiles->next() ); |
840 | // odebug << list << oendl; | 846 | // odebug << list << oendl; |
841 | m3uList->write(); | 847 | m3uList->write(); |
842 | m3uList->close(); | 848 | m3uList->close(); |
843 | delete m3uList; | 849 | delete m3uList; |
844 | 850 | ||
845 | //delete fileDlg; | 851 | //delete fileDlg; |
846 | 852 | ||
@@ -978,73 +984,83 @@ void PlayListWidget::skinsMenuActivated( int item ) { | |||
978 | } | 984 | } |
979 | 985 | ||
980 | emit skinSelected(); | 986 | emit skinSelected(); |
981 | } | 987 | } |
982 | 988 | ||
983 | PlayListWidget::TabType PlayListWidget::currentTab() const | 989 | PlayListWidget::TabType PlayListWidget::currentTab() const |
984 | { | 990 | { |
985 | static const TabType indexToTabType[ TabTypeCount ] = | 991 | static const TabType indexToTabType[ TabTypeCount ] = |
986 | { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; | 992 | { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; |
987 | 993 | ||
988 | int index = tabWidget->currentPageIndex(); | 994 | int index = tabWidget->currentPageIndex(); |
989 | assert( index < TabTypeCount && index >= 0 ); | 995 | assert( index < TabTypeCount && index >= 0 ); |
990 | 996 | ||
991 | return indexToTabType[ index ]; | 997 | return indexToTabType[ index ]; |
992 | } | 998 | } |
993 | 999 | ||
994 | PlayListWidget::Entry PlayListWidget::currentEntry() const | 1000 | PlayListWidget::Entry PlayListWidget::currentEntry() const |
995 | { | 1001 | { |
996 | if ( currentTab() == CurrentPlayList ) { | 1002 | if ( currentTab() == CurrentPlayList ) { |
997 | const DocLnk *lnk = current(); | 1003 | const DocLnk *lnk = current(); |
998 | return Entry( lnk->name(), lnk->file() ); | 1004 | return Entry( lnk->name(), lnk->file() ); |
999 | } | 1005 | } |
1000 | 1006 | ||
1001 | return Entry( currentFileListPathName() ); | 1007 | return Entry( currentFileListPathName() ); |
1002 | } | 1008 | } |
1003 | 1009 | ||
1004 | QString PlayListWidget::currentFileListPathName() const { | 1010 | QString PlayListWidget::currentFileListPathName() const { |
1005 | return currentFileListView->currentItem()->text( 3 ); | 1011 | return currentFileListView->currentItem()->text( 3 ); |
1006 | } | 1012 | } |
1007 | 1013 | ||
1008 | 1014 | ||
1009 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { | 1015 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { |
1010 | odebug << "qcop message "+msg << oendl; | ||
1011 | QDataStream stream ( data, IO_ReadOnly ); | 1016 | QDataStream stream ( data, IO_ReadOnly ); |
1012 | if ( msg == "play()" ) { //plays current selection | 1017 | if ( msg == "play()" ) { //plays current selection |
1013 | btnPlay( true); | 1018 | btnPlay( true); |
1014 | } else if ( msg == "stop()" ) { | 1019 | } else if ( msg == "stop()" ) { |
1015 | mediaPlayerState->setPlaying( false); | 1020 | mediaPlayerState->setPlaying( false); |
1016 | } else if ( msg == "togglePause()" ) { | 1021 | } else if ( msg == "togglePause()" ) { |
1017 | mediaPlayerState->togglePaused(); | 1022 | mediaPlayerState->togglePaused(); |
1018 | } else if ( msg == "next()" ) { //select next in list | 1023 | } else if ( msg == "next()" ) { //select next in list |
1019 | mediaPlayerState->setNext(); | 1024 | mediaPlayerState->setNext(); |
1020 | } else if ( msg == "prev()" ) { //select previous in list | 1025 | } else if ( msg == "prev()" ) { //select previous in list |
1021 | mediaPlayerState->setPrev(); | 1026 | mediaPlayerState->setPrev(); |
1022 | } else if ( msg == "toggleLooping()" ) { //loop or not loop | 1027 | } else if ( msg == "toggleLooping()" ) { //loop or not loop |
1023 | mediaPlayerState->toggleLooping(); | 1028 | mediaPlayerState->toggleLooping(); |
1024 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled | 1029 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled |
1025 | mediaPlayerState->toggleShuffled(); | 1030 | mediaPlayerState->toggleShuffled(); |
1026 | } else if ( msg == "volUp()" ) { //volume more | 1031 | } else if ( msg == "volUp()" ) { //volume more |
1027 | // emit moreClicked(); | 1032 | // emit moreClicked(); |
1028 | // emit moreReleased(); | 1033 | // emit moreReleased(); |
1029 | } else if ( msg == "volDown()" ) { //volume less | 1034 | } else if ( msg == "volDown()" ) { //volume less |
1030 | // emit lessClicked(); | 1035 | // emit lessClicked(); |
1031 | // emit lessReleased(); | 1036 | // emit lessReleased(); |
1032 | } else if ( msg == "play(QString)" ) { //play this now | 1037 | } else if ( msg == "play(QString)" ) { //play this now |
1033 | QString file; | 1038 | QString file; |
1034 | stream >> file; | 1039 | stream >> file; |
1035 | setDocument( (const QString &) file); | 1040 | setDocument( (const QString &) file); |
1036 | } else if ( msg == "add(QString)" ) { //add to playlist | 1041 | } else if ( msg == "add(QString)" ) { //add to playlist |
1037 | QString file; | 1042 | QString file; |
1038 | stream >> file; | 1043 | stream >> file; |
1039 | QFileInfo fileInfo(file); | 1044 | QFileInfo fileInfo(file); |
1040 | DocLnk lnk; | 1045 | DocLnk lnk; |
1041 | lnk.setName( fileInfo.baseName() ); //sets name | 1046 | lnk.setName( fileInfo.baseName() ); //sets name |
1042 | lnk.setFile( file ); //sets file name | 1047 | lnk.setFile( file ); //sets file name |
1043 | addToSelection( lnk ); | 1048 | addToSelection( lnk ); |
1044 | } else if ( msg == "rem(QString)" ) { //remove from playlist | 1049 | } else if ( msg == "rem(QString)" ) { //remove from playlist |
1045 | QString file; | 1050 | QString file; |
1046 | stream >> file; | 1051 | stream >> file; |
1047 | 1052 | ||
1048 | } | 1053 | } |
1049 | 1054 | ||
1050 | } | 1055 | } |
1056 | |||
1057 | DocLnk PlayListWidget::addFileToPlaylist( const QString& file, | ||
1058 | const QString& name ) { | ||
1059 | DocLnk lnk; | ||
1060 | lnk.setName( name ); //sets name | ||
1061 | lnk.setFile( file ); //sets file name | ||
1062 | d->selectedFiles->addToSelection( lnk ); | ||
1063 | writeCurrentM3u(); | ||
1064 | |||
1065 | return lnk; | ||
1066 | } | ||
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h index 29f3e8d..1f5ba92 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.h +++ b/noncore/multimedia/opieplayer2/playlistwidget.h | |||
@@ -81,63 +81,65 @@ public: | |||
81 | public slots: | 81 | public slots: |
82 | bool first(); | 82 | bool first(); |
83 | bool last(); | 83 | bool last(); |
84 | bool next(); | 84 | bool next(); |
85 | bool prev(); | 85 | bool prev(); |
86 | void writeDefaultPlaylist( ); | 86 | void writeDefaultPlaylist( ); |
87 | QString currentFileListPathName() const; | 87 | QString currentFileListPathName() const; |
88 | protected: | 88 | protected: |
89 | QCopChannel * channel; | 89 | QCopChannel * channel; |
90 | void keyReleaseEvent( QKeyEvent *e); | 90 | void keyReleaseEvent( QKeyEvent *e); |
91 | 91 | ||
92 | signals: | 92 | signals: |
93 | void skinSelected(); | 93 | void skinSelected(); |
94 | 94 | ||
95 | private: | 95 | private: |
96 | int defaultSkinIndex; | 96 | int defaultSkinIndex; |
97 | /* void readm3u(const QString &); */ | 97 | /* void readm3u(const QString &); */ |
98 | /* void readPls(const QString &); */ | 98 | /* void readPls(const QString &); */ |
99 | void readListFromFile(const QString &); | 99 | void readListFromFile(const QString &); |
100 | void initializeStates(); | 100 | void initializeStates(); |
101 | 101 | ||
102 | bool inFileListMode() const; | 102 | bool inFileListMode() const; |
103 | 103 | ||
104 | private slots: | 104 | private slots: |
105 | void qcopReceive(const QCString&, const QByteArray&); | 105 | void qcopReceive(const QCString&, const QByteArray&); |
106 | void populateSkinsMenu(); | 106 | void populateSkinsMenu(); |
107 | void skinsMenuActivated(int); | 107 | void skinsMenuActivated(int); |
108 | void pmViewActivated(int); | 108 | void pmViewActivated(int); |
109 | void writem3u(); | 109 | void writem3u(); |
110 | void writeCurrentM3u(); | 110 | void writeCurrentM3u(); |
111 | void openFile(); | 111 | void openFile(); |
112 | void openURL(); | 112 | void openURL(); |
113 | void openDirectory(); | ||
113 | void setDocument( const QString& fileref ); | 114 | void setDocument( const QString& fileref ); |
114 | void addToSelection( const DocLnk& ); // Add a media file to the playlist | 115 | void addToSelection( const DocLnk& ); // Add a media file to the playlist |
115 | void addToSelection( QListViewItem* ); // Add a media file to the playlist | 116 | void addToSelection( QListViewItem* ); // Add a media file to the playlist |
116 | void clearList(); | 117 | void clearList(); |
117 | void addAllToList(); | 118 | void addAllToList(); |
118 | void addAllMusicToList(); | 119 | void addAllMusicToList(); |
119 | void addAllVideoToList(); | 120 | void addAllVideoToList(); |
120 | void saveList(); // Save the playlist | 121 | void saveList(); // Save the playlist |
121 | void loadList( const DocLnk &); // Load a playlist | 122 | void loadList( const DocLnk &); // Load a playlist |
122 | void playIt( QListViewItem *); | 123 | void playIt( QListViewItem *); |
123 | void btnPlay(bool); | 124 | void btnPlay(bool); |
124 | void deletePlaylist(); | 125 | void deletePlaylist(); |
125 | void addSelected(); | 126 | void addSelected(); |
126 | void removeSelected(); | 127 | void removeSelected(); |
127 | void tabChanged(QWidget*); | 128 | void tabChanged(QWidget*); |
128 | void viewPressed( int, QListViewItem *, const QPoint&, int); | 129 | void viewPressed( int, QListViewItem *, const QPoint&, int); |
129 | void playlistViewPressed( int, QListViewItem *, const QPoint&, int); | 130 | void playlistViewPressed( int, QListViewItem *, const QPoint&, int); |
130 | void playSelected(); | 131 | void playSelected(); |
131 | 132 | ||
132 | private: | 133 | private: |
134 | DocLnk addFileToPlaylist(const QString& directory, const QString& name); | ||
133 | bool fromSetDocument; | 135 | bool fromSetDocument; |
134 | bool insanityBool; | 136 | bool insanityBool; |
135 | QString setDocFileRef, currentPlayList; | 137 | QString setDocFileRef, currentPlayList; |
136 | int selected; | 138 | int selected; |
137 | QListView *currentFileListView; | 139 | QListView *currentFileListView; |
138 | 140 | ||
139 | MediaPlayer *m_mp; | 141 | MediaPlayer *m_mp; |
140 | }; | 142 | }; |
141 | 143 | ||
142 | #endif // PLAY_LIST_WIDGET_H | 144 | #endif // PLAY_LIST_WIDGET_H |
143 | 145 | ||