author | zecke <zecke> | 2004-09-24 16:03:38 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-09-24 16:03:38 (UTC) |
commit | 0b9478d52735eb62a4ead580344b989ecf03d356 (patch) (unidiff) | |
tree | 1f95262623d3513dc6a061a62be65f891d023217 | |
parent | 2911cb18af1fad00bc3557cffe2d2d2ec3a9d346 (diff) | |
download | opie-0b9478d52735eb62a4ead580344b989ecf03d356.zip opie-0b9478d52735eb62a4ead580344b989ecf03d356.tar.gz opie-0b9478d52735eb62a4ead580344b989ecf03d356.tar.bz2 |
-remove qApp->processEvents when starting playing
Revamp Adding Files and Add Directory
-Remove custom code to save the last Directory Used
-Share MimeType creating code
-Add Method to add a File to the Playlist and use it
for AddFile and Add Directory
-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 | |||
@@ -96,129 +96,128 @@ void MediaPlayer::setPlaying( bool play ) { | |||
96 | } | 96 | } |
97 | r = mediaPlayerState.isShuffled(); | 97 | r = mediaPlayerState.isShuffled(); |
98 | mediaPlayerState.setShuffled( false ); | 98 | mediaPlayerState.setShuffled( false ); |
99 | } | 99 | } |
100 | 100 | ||
101 | PlayListWidget::Entry playListEntry = playList.currentEntry(); | 101 | PlayListWidget::Entry playListEntry = playList.currentEntry(); |
102 | fileName = playListEntry.name; | 102 | fileName = playListEntry.name; |
103 | xineControl()->play( playListEntry.file ); | 103 | xineControl()->play( playListEntry.file ); |
104 | 104 | ||
105 | long seconds = mediaPlayerState.length(); | 105 | long seconds = mediaPlayerState.length(); |
106 | time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); | 106 | time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); |
107 | 107 | ||
108 | if( fileName.left(4) == "http" ) { | 108 | if( fileName.left(4) == "http" ) { |
109 | fileName = QFileInfo( fileName ).baseName(); | 109 | fileName = QFileInfo( fileName ).baseName(); |
110 | if ( xineControl()->getMetaInfo().isEmpty() ) { | 110 | if ( xineControl()->getMetaInfo().isEmpty() ) { |
111 | tickerText = tr( " File: " ) + fileName; | 111 | tickerText = tr( " File: " ) + fileName; |
112 | } else { | 112 | } else { |
113 | tickerText = xineControl()->getMetaInfo(); | 113 | tickerText = xineControl()->getMetaInfo(); |
114 | } | 114 | } |
115 | } else { | 115 | } else { |
116 | if ( xineControl()->getMetaInfo().isEmpty() ) { | 116 | if ( xineControl()->getMetaInfo().isEmpty() ) { |
117 | tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " "; | 117 | tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " "; |
118 | } else { | 118 | } else { |
119 | tickerText = xineControl()->getMetaInfo() + " Length: " + time + " "; | 119 | tickerText = xineControl()->getMetaInfo() + " Length: " + time + " "; |
120 | } | 120 | } |
121 | } | 121 | } |
122 | audioUI()->setTickerText( tickerText ); | 122 | audioUI()->setTickerText( tickerText ); |
123 | } | 123 | } |
124 | 124 | ||
125 | 125 | ||
126 | void MediaPlayer::prev() { | 126 | void MediaPlayer::prev() { |
127 | if( playList.currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist | 127 | if( playList.currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist |
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 ); |
193 | } else { | 192 | } else { |
194 | w = videoUI()->width(); | 193 | w = videoUI()->width(); |
195 | h = videoUI()->height(); | 194 | h = videoUI()->height(); |
196 | videoUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); | 195 | videoUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); |
197 | } | 196 | } |
198 | } | 197 | } |
199 | 198 | ||
200 | 199 | ||
201 | void MediaPlayer::timerEvent( QTimerEvent * ) { | 200 | void MediaPlayer::timerEvent( QTimerEvent * ) { |
202 | if ( volumeDirection == +1 ) { | 201 | if ( volumeDirection == +1 ) { |
203 | volControl->incVol( 2 ); | 202 | volControl->incVol( 2 ); |
204 | } else if ( volumeDirection == -1 ) { | 203 | } else if ( volumeDirection == -1 ) { |
205 | volControl->decVol( 2 ); | 204 | volControl->decVol( 2 ); |
206 | } | 205 | } |
207 | 206 | ||
208 | 207 | ||
209 | // TODO FIXME | 208 | // TODO FIXME |
210 | // huh?? | 209 | // huh?? |
211 | unsigned int v= 0; | 210 | unsigned int v= 0; |
212 | v = volControl->volume(); | 211 | v = volControl->volume(); |
213 | v = v / 10; | 212 | v = v / 10; |
214 | 213 | ||
215 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { | 214 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { |
216 | return; | 215 | return; |
217 | } | 216 | } |
218 | 217 | ||
219 | int w=0; int h=0; | 218 | int w=0; int h=0; |
220 | if( !xineControl()->hasVideo() ) { | 219 | if( !xineControl()->hasVideo() ) { |
221 | w = audioUI()->width(); | 220 | w = audioUI()->width(); |
222 | h = audioUI()->height(); | 221 | h = audioUI()->height(); |
223 | 222 | ||
224 | if ( drawnOnScreenDisplay ) { | 223 | if ( drawnOnScreenDisplay ) { |
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 | |||
@@ -24,128 +24,130 @@ | |||
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = General Public License along with | 26 | -_. . . )=. = General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #include "playlistselection.h" | 34 | #include "playlistselection.h" |
35 | #include "playlistwidget.h" | 35 | #include "playlistwidget.h" |
36 | #include "mediaplayer.h" | 36 | #include "mediaplayer.h" |
37 | #include "inputDialog.h" | 37 | #include "inputDialog.h" |
38 | #include "om3u.h" | 38 | #include "om3u.h" |
39 | #include "playlistfileview.h" | 39 | #include "playlistfileview.h" |
40 | 40 | ||
41 | /* OPIE */ | 41 | /* OPIE */ |
42 | #include <opie2/odebug.h> | 42 | #include <opie2/odebug.h> |
43 | #include <opie2/ofiledialog.h> | 43 | #include <opie2/ofiledialog.h> |
44 | using namespace Opie::Core; | 44 | using namespace Opie::Core; |
45 | using namespace Opie::Ui; | 45 | using namespace Opie::Ui; |
46 | 46 | ||
47 | /* QT */ | 47 | /* QT */ |
48 | #include <qmessagebox.h> | 48 | #include <qmessagebox.h> |
49 | #include <qtoolbar.h> | 49 | #include <qtoolbar.h> |
50 | 50 | ||
51 | /* STD */ | 51 | /* STD */ |
52 | #include <assert.h> | 52 | #include <assert.h> |
53 | 53 | ||
54 | PlayListWidget::PlayListWidget(QWidget* parent, const char* name, WFlags fl ) | 54 | PlayListWidget::PlayListWidget(QWidget* parent, const char* name, WFlags fl ) |
55 | : PlayListWidgetGui( parent, "playList" ) , currentFileListView( 0 ) | 55 | : PlayListWidgetGui( parent, "playList" ) , currentFileListView( 0 ) |
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) ), |
120 | this,SLOT( playlistViewPressed(int,QListViewItem*,const QPoint&,int) ) ); | 122 | this,SLOT( playlistViewPressed(int,QListViewItem*,const QPoint&,int) ) ); |
121 | connect( audioView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), | 123 | connect( audioView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), |
122 | this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) ); | 124 | this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) ); |
123 | connect( audioView, SIGNAL( returnPressed(QListViewItem*) ), | 125 | connect( audioView, SIGNAL( returnPressed(QListViewItem*) ), |
124 | this,SLOT( playIt(QListViewItem*) ) ); | 126 | this,SLOT( playIt(QListViewItem*) ) ); |
125 | connect( audioView, SIGNAL( doubleClicked(QListViewItem*) ), | 127 | connect( audioView, SIGNAL( doubleClicked(QListViewItem*) ), |
126 | this, SLOT( addToSelection(QListViewItem*) ) ); | 128 | this, SLOT( addToSelection(QListViewItem*) ) ); |
127 | connect( videoView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), | 129 | connect( videoView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), |
128 | this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) ); | 130 | this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) ); |
129 | connect( videoView, SIGNAL( returnPressed(QListViewItem*) ), | 131 | connect( videoView, SIGNAL( returnPressed(QListViewItem*) ), |
130 | this,SLOT( playIt(QListViewItem*) ) ); | 132 | this,SLOT( playIt(QListViewItem*) ) ); |
131 | connect( videoView, SIGNAL( doubleClicked(QListViewItem*) ), | 133 | connect( videoView, SIGNAL( doubleClicked(QListViewItem*) ), |
132 | this, SLOT( addToSelection(QListViewItem*) ) ); | 134 | this, SLOT( addToSelection(QListViewItem*) ) ); |
133 | connect( playLists, SIGNAL( fileSelected(const DocLnk&) ), | 135 | connect( playLists, SIGNAL( fileSelected(const DocLnk&) ), |
134 | this, SLOT( loadList(const DocLnk&) ) ); | 136 | this, SLOT( loadList(const DocLnk&) ) ); |
135 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), | 137 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), |
136 | this, SLOT( tabChanged(QWidget*) ) ); | 138 | this, SLOT( tabChanged(QWidget*) ) ); |
137 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), | 139 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), |
138 | d->tbPlay, SLOT( setOn(bool) ) ); | 140 | d->tbPlay, SLOT( setOn(bool) ) ); |
139 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), | 141 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), |
140 | d->tbLoop, SLOT( setOn(bool) ) ); | 142 | d->tbLoop, SLOT( setOn(bool) ) ); |
141 | connect( mediaPlayerState, SIGNAL( shuffledToggled(bool) ), | 143 | connect( mediaPlayerState, SIGNAL( shuffledToggled(bool) ), |
142 | d->tbShuffle, SLOT( setOn(bool) ) ); | 144 | d->tbShuffle, SLOT( setOn(bool) ) ); |
143 | connect( d->selectedFiles, SIGNAL( doubleClicked(QListViewItem*) ), | 145 | connect( d->selectedFiles, SIGNAL( doubleClicked(QListViewItem*) ), |
144 | this, SLOT( playIt(QListViewItem*) ) ); | 146 | this, SLOT( playIt(QListViewItem*) ) ); |
145 | connect ( gammaSlider, SIGNAL( valueChanged(int) ), | 147 | connect ( gammaSlider, SIGNAL( valueChanged(int) ), |
146 | mediaPlayerState, SLOT( setVideoGamma(int) ) ); | 148 | mediaPlayerState, SLOT( setVideoGamma(int) ) ); |
147 | 149 | ||
148 | connect( this, SIGNAL(skinSelected() ), | 150 | connect( this, SIGNAL(skinSelected() ), |
149 | m_mp, SLOT( reloadSkins() ) ); | 151 | m_mp, SLOT( reloadSkins() ) ); |
150 | 152 | ||
151 | // see which skins are installed | 153 | // see which skins are installed |
@@ -601,278 +603,282 @@ void PlayListWidget::deletePlaylist() { | |||
601 | 603 | ||
602 | 604 | ||
603 | void PlayListWidget::playSelected() { | 605 | void PlayListWidget::playSelected() { |
604 | btnPlay( TRUE); | 606 | btnPlay( TRUE); |
605 | } | 607 | } |
606 | 608 | ||
607 | bool PlayListWidget::inFileListMode() const | 609 | bool PlayListWidget::inFileListMode() const |
608 | { | 610 | { |
609 | TabType tab = currentTab(); | 611 | TabType tab = currentTab(); |
610 | return tab == AudioFiles || tab == VideoFiles; | 612 | return tab == AudioFiles || tab == VideoFiles; |
611 | } | 613 | } |
612 | 614 | ||
613 | void PlayListWidget::openURL() { | 615 | void PlayListWidget::openURL() { |
614 | // http://66.28.164.33:2080 | 616 | // http://66.28.164.33:2080 |
615 | // http://somafm.com/star0242.m3u | 617 | // http://somafm.com/star0242.m3u |
616 | QString filename, name; | 618 | QString filename, name; |
617 | InputDialog *fileDlg; | 619 | InputDialog *fileDlg; |
618 | fileDlg = new InputDialog(this,tr("Add URL"),TRUE, 0); | 620 | fileDlg = new InputDialog(this,tr("Add URL"),TRUE, 0); |
619 | fileDlg->exec(); | 621 | fileDlg->exec(); |
620 | if( fileDlg->result() == 1 ) { | 622 | if( fileDlg->result() == 1 ) { |
621 | filename = fileDlg->text(); | 623 | filename = fileDlg->text(); |
622 | odebug << "Selected filename is " + filename << oendl; | 624 | odebug << "Selected filename is " + filename << oendl; |
623 | // Om3u *m3uList; | 625 | // Om3u *m3uList; |
624 | DocLnk lnk; | 626 | DocLnk lnk; |
625 | Config cfg( "OpiePlayer" ); | 627 | Config cfg( "OpiePlayer" ); |
626 | cfg.setGroup("PlayList"); | 628 | cfg.setGroup("PlayList"); |
627 | 629 | ||
628 | if(filename.left(4) == "http") { | 630 | if(filename.left(4) == "http") { |
629 | QString m3uFile, m3uFilePath; | 631 | QString m3uFile, m3uFilePath; |
630 | if(filename.find(":",8,TRUE) != -1) { //found a port | 632 | if(filename.find(":",8,TRUE) != -1) { //found a port |
631 | m3uFile = filename.left( filename.find( ":",8,TRUE)); | 633 | m3uFile = filename.left( filename.find( ":",8,TRUE)); |
632 | m3uFile = m3uFile.right( 7); | 634 | m3uFile = m3uFile.right( 7); |
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" ); |
747 | config.setGroup( "PlayList" ); | 770 | config.setGroup( "PlayList" ); |
748 | 771 | ||
749 | config.writeEntry("CurrentPlaylist",filename); | 772 | config.writeEntry("CurrentPlaylist",filename); |
750 | config.write(); | 773 | config.write(); |
751 | currentPlayList=filename; | 774 | currentPlayList=filename; |
752 | 775 | ||
753 | m3uList->close(); | 776 | m3uList->close(); |
754 | delete m3uList; | 777 | delete m3uList; |
755 | 778 | ||
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 | ||
847 | DocLnk lnk; | 853 | DocLnk lnk; |
848 | lnk.setFile( filename); | 854 | lnk.setFile( filename); |
849 | lnk.setIcon("opieplayer2/playlist2"); | 855 | lnk.setIcon("opieplayer2/playlist2"); |
850 | lnk.setName( name); //sets file name | 856 | lnk.setName( name); //sets file name |
851 | 857 | ||
852 | // odebug << filename << oendl; | 858 | // odebug << filename << oendl; |
853 | Config config( "OpiePlayer" ); | 859 | Config config( "OpiePlayer" ); |
854 | config.setGroup( "PlayList" ); | 860 | config.setGroup( "PlayList" ); |
855 | 861 | ||
856 | config.writeEntry("CurrentPlaylist",filename); | 862 | config.writeEntry("CurrentPlaylist",filename); |
857 | currentPlayList=filename; | 863 | currentPlayList=filename; |
858 | 864 | ||
859 | if(!lnk.writeLink()) { | 865 | if(!lnk.writeLink()) { |
860 | odebug << "Writing doclink did not work" << oendl; | 866 | odebug << "Writing doclink did not work" << oendl; |
861 | } | 867 | } |
862 | 868 | ||
863 | setCaption(tr("OpiePlayer: ") + name); | 869 | setCaption(tr("OpiePlayer: ") + name); |
864 | } | 870 | } |
865 | } | 871 | } |
866 | } | 872 | } |
867 | 873 | ||
868 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { | 874 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { |
869 | switch ( e->key() ) { | 875 | switch ( e->key() ) { |
870 | ////////////////////////////// Zaurus keys | 876 | ////////////////////////////// Zaurus keys |
871 | case Key_F9: //activity | 877 | case Key_F9: //activity |
872 | // if(audioUI->isHidden()) | 878 | // if(audioUI->isHidden()) |
873 | // audioUI->showMaximized(); | 879 | // audioUI->showMaximized(); |
874 | break; | 880 | break; |
875 | case Key_F10: //contacts | 881 | case Key_F10: //contacts |
876 | // if( videoUI->isHidden()) | 882 | // if( videoUI->isHidden()) |
877 | // videoUI->showMaximized(); | 883 | // videoUI->showMaximized(); |
878 | break; | 884 | break; |
@@ -946,105 +952,115 @@ void PlayListWidget::populateSkinsMenu() { | |||
946 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); | 952 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); |
947 | skinsDir.setFilter( QDir::Dirs ); | 953 | skinsDir.setFilter( QDir::Dirs ); |
948 | skinsDir.setSorting(QDir::Name ); | 954 | skinsDir.setSorting(QDir::Name ); |
949 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); | 955 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); |
950 | QFileInfoListIterator it( *skinslist ); | 956 | QFileInfoListIterator it( *skinslist ); |
951 | QFileInfo *fi; | 957 | QFileInfo *fi; |
952 | while ( ( fi = it.current() ) ) { | 958 | while ( ( fi = it.current() ) ) { |
953 | skinName = fi->fileName(); | 959 | skinName = fi->fileName(); |
954 | // odebug << fi->fileName() << oendl; | 960 | // odebug << fi->fileName() << oendl; |
955 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { | 961 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { |
956 | item = skinsMenu->insertItem( fi->fileName() ) ; | 962 | item = skinsMenu->insertItem( fi->fileName() ) ; |
957 | } | 963 | } |
958 | if( skinName == "default" ) { | 964 | if( skinName == "default" ) { |
959 | defaultSkinIndex = item; | 965 | defaultSkinIndex = item; |
960 | } | 966 | } |
961 | if( skinName == skin ) { | 967 | if( skinName == skin ) { |
962 | skinsMenu->setItemChecked( item, TRUE ); | 968 | skinsMenu->setItemChecked( item, TRUE ); |
963 | } | 969 | } |
964 | ++it; | 970 | ++it; |
965 | } | 971 | } |
966 | } | 972 | } |
967 | 973 | ||
968 | void PlayListWidget::skinsMenuActivated( int item ) { | 974 | void PlayListWidget::skinsMenuActivated( int item ) { |
969 | for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { | 975 | for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { |
970 | skinsMenu->setItemChecked( i, FALSE ); | 976 | skinsMenu->setItemChecked( i, FALSE ); |
971 | } | 977 | } |
972 | skinsMenu->setItemChecked( item, TRUE ); | 978 | skinsMenu->setItemChecked( item, TRUE ); |
973 | 979 | ||
974 | { | 980 | { |
975 | Config cfg( "OpiePlayer" ); | 981 | Config cfg( "OpiePlayer" ); |
976 | cfg.setGroup("Options"); | 982 | cfg.setGroup("Options"); |
977 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); | 983 | cfg.writeEntry("Skin", skinsMenu->text( 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 | |||
@@ -49,95 +49,97 @@ class QAction; | |||
49 | class QLabel; | 49 | class QLabel; |
50 | class MediaPlayerState; | 50 | class MediaPlayerState; |
51 | class MediaPlayer; | 51 | class MediaPlayer; |
52 | 52 | ||
53 | class PlayListWidget : public PlayListWidgetGui { | 53 | class PlayListWidget : public PlayListWidgetGui { |
54 | Q_OBJECT | 54 | Q_OBJECT |
55 | public: | 55 | public: |
56 | enum TabType { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; | 56 | enum TabType { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; |
57 | enum { TabTypeCount = 4 }; | 57 | enum { TabTypeCount = 4 }; |
58 | 58 | ||
59 | struct Entry | 59 | struct Entry |
60 | { | 60 | { |
61 | Entry( const QString &_name, const QString &_fileName ) | 61 | Entry( const QString &_name, const QString &_fileName ) |
62 | : name( _name ), file( _fileName ) {} | 62 | : name( _name ), file( _fileName ) {} |
63 | Entry( const QString &_fileName ) | 63 | Entry( const QString &_fileName ) |
64 | : name( _fileName ), file( _fileName ) {} | 64 | : name( _fileName ), file( _fileName ) {} |
65 | 65 | ||
66 | QString name; | 66 | QString name; |
67 | QString file; | 67 | QString file; |
68 | }; | 68 | }; |
69 | 69 | ||
70 | static QString appName() { return QString::fromLatin1("opieplayer2"); } | 70 | static QString appName() { return QString::fromLatin1("opieplayer2"); } |
71 | PlayListWidget( QWidget* parent=0, const char* name=0, WFlags = 0 ); | 71 | PlayListWidget( QWidget* parent=0, const char* name=0, WFlags = 0 ); |
72 | ~PlayListWidget(); | 72 | ~PlayListWidget(); |
73 | 73 | ||
74 | // retrieve the current playlist entry (media file link) | 74 | // retrieve the current playlist entry (media file link) |
75 | const DocLnk *current() const; | 75 | const DocLnk *current() const; |
76 | void useSelectedDocument(); | 76 | void useSelectedDocument(); |
77 | TabType currentTab() const; | 77 | TabType currentTab() const; |
78 | 78 | ||
79 | Entry currentEntry() const; | 79 | Entry currentEntry() const; |
80 | 80 | ||
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 | ||