author | llornkcor <llornkcor> | 2002-08-22 01:35:24 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-08-22 01:35:24 (UTC) |
commit | ee90b966cfc262770ef5a45c2bad0af6766245a2 (patch) (unidiff) | |
tree | 3b80601759e3a2418b1b805229e4ea074fd7708f | |
parent | dbf4e3458811379488842f5d83650c7e4c6831aa (diff) | |
download | opie-ee90b966cfc262770ef5a45c2bad0af6766245a2.zip opie-ee90b966cfc262770ef5a45c2bad0af6766245a2.tar.gz opie-ee90b966cfc262770ef5a45c2bad0af6766245a2.tar.bz2 |
should scan for file at startup
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.cpp | 1 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 11 |
2 files changed, 8 insertions, 4 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index 603d426..bf2acc8 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp | |||
@@ -58,245 +58,246 @@ MediaPlayer::MediaPlayer( QObject *parent, const char *name ) | |||
58 | connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); | 58 | connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); |
59 | connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); | 59 | connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); |
60 | 60 | ||
61 | volControl = new VolumeControl; | 61 | volControl = new VolumeControl; |
62 | xineControl = new XineControl(); | 62 | xineControl = new XineControl(); |
63 | playList->setCaption(tr("OpiePlayer")); | 63 | playList->setCaption(tr("OpiePlayer")); |
64 | } | 64 | } |
65 | 65 | ||
66 | MediaPlayer::~MediaPlayer() { | 66 | MediaPlayer::~MediaPlayer() { |
67 | delete xineControl; | 67 | delete xineControl; |
68 | delete volControl; | 68 | delete volControl; |
69 | } | 69 | } |
70 | 70 | ||
71 | void MediaPlayer::pauseCheck( bool b ) { | 71 | void MediaPlayer::pauseCheck( bool b ) { |
72 | if ( b && !mediaPlayerState->playing() ) { | 72 | if ( b && !mediaPlayerState->playing() ) { |
73 | mediaPlayerState->setPaused( FALSE ); | 73 | mediaPlayerState->setPaused( FALSE ); |
74 | } | 74 | } |
75 | } | 75 | } |
76 | 76 | ||
77 | void MediaPlayer::play() { | 77 | void MediaPlayer::play() { |
78 | mediaPlayerState->setPlaying( FALSE ); | 78 | mediaPlayerState->setPlaying( FALSE ); |
79 | mediaPlayerState->setPlaying( TRUE ); | 79 | mediaPlayerState->setPlaying( TRUE ); |
80 | } | 80 | } |
81 | 81 | ||
82 | void MediaPlayer::setPlaying( bool play ) { | 82 | void MediaPlayer::setPlaying( bool play ) { |
83 | if ( !play ) { | 83 | if ( !play ) { |
84 | return; | 84 | return; |
85 | } | 85 | } |
86 | 86 | ||
87 | if ( mediaPlayerState->paused() ) { | 87 | if ( mediaPlayerState->paused() ) { |
88 | mediaPlayerState->setPaused( FALSE ); | 88 | mediaPlayerState->setPaused( FALSE ); |
89 | return; | 89 | return; |
90 | } | 90 | } |
91 | 91 | ||
92 | const DocLnk *playListCurrent = playList->current(); | 92 | const DocLnk *playListCurrent = playList->current(); |
93 | if ( playListCurrent != NULL ) { | 93 | if ( playListCurrent != NULL ) { |
94 | currentFile = playListCurrent; | 94 | currentFile = playListCurrent; |
95 | } | 95 | } |
96 | 96 | ||
97 | xineControl->play( currentFile->file() ); | 97 | xineControl->play( currentFile->file() ); |
98 | 98 | ||
99 | long seconds = mediaPlayerState->length();// | 99 | long seconds = mediaPlayerState->length();// |
100 | QString time; time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); | 100 | QString time; time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); |
101 | qDebug(time); | 101 | qDebug(time); |
102 | 102 | ||
103 | QString tickerText; | 103 | QString tickerText; |
104 | if( currentFile->file().left(4) == "http" ) | 104 | if( currentFile->file().left(4) == "http" ) |
105 | tickerText= tr( " File: " ) + currentFile->name(); | 105 | tickerText= tr( " File: " ) + currentFile->name(); |
106 | else | 106 | else |
107 | tickerText = tr( " File: " ) + currentFile->name() + tr(", Length: ") + time; | 107 | tickerText = tr( " File: " ) + currentFile->name() + tr(", Length: ") + time; |
108 | 108 | ||
109 | audioUI->setTickerText( currentFile->file( ) ); | 109 | audioUI->setTickerText( currentFile->file( ) ); |
110 | 110 | ||
111 | } | 111 | } |
112 | 112 | ||
113 | 113 | ||
114 | void MediaPlayer::prev() { | 114 | void MediaPlayer::prev() { |
115 | if ( playList->prev() ) { | 115 | if ( playList->prev() ) { |
116 | play(); | 116 | play(); |
117 | } else if ( mediaPlayerState->looping() ) { | 117 | } else if ( mediaPlayerState->looping() ) { |
118 | if ( playList->last() ) { | 118 | if ( playList->last() ) { |
119 | play(); | 119 | play(); |
120 | } | 120 | } |
121 | } else { | 121 | } else { |
122 | mediaPlayerState->setList(); | 122 | mediaPlayerState->setList(); |
123 | } | 123 | } |
124 | } | 124 | } |
125 | 125 | ||
126 | 126 | ||
127 | void MediaPlayer::next() { | 127 | void MediaPlayer::next() { |
128 | if ( playList->next() ) { | 128 | if ( playList->next() ) { |
129 | play(); | 129 | play(); |
130 | } else if ( mediaPlayerState->looping() ) { | 130 | } else if ( mediaPlayerState->looping() ) { |
131 | if ( playList->first() ) { | 131 | if ( playList->first() ) { |
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 | void MediaPlayer::startDecreasingVolume() { | 140 | void MediaPlayer::startDecreasingVolume() { |
141 | volumeDirection = -1; | 141 | volumeDirection = -1; |
142 | startTimer( 100 ); | 142 | startTimer( 100 ); |
143 | volControl->decVol(2); | 143 | volControl->decVol(2); |
144 | } | 144 | } |
145 | 145 | ||
146 | 146 | ||
147 | void MediaPlayer::startIncreasingVolume() { | 147 | void MediaPlayer::startIncreasingVolume() { |
148 | volumeDirection = +1; | 148 | volumeDirection = +1; |
149 | startTimer( 100 ); | 149 | startTimer( 100 ); |
150 | volControl->incVol(2); | 150 | volControl->incVol(2); |
151 | } | 151 | } |
152 | 152 | ||
153 | 153 | ||
154 | bool drawnOnScreenDisplay = FALSE; | 154 | bool drawnOnScreenDisplay = FALSE; |
155 | unsigned int onScreenDisplayVolume = 0; | 155 | unsigned int onScreenDisplayVolume = 0; |
156 | const int yoff = 110; | 156 | const int yoff = 110; |
157 | 157 | ||
158 | void MediaPlayer::stopChangingVolume() { | 158 | void MediaPlayer::stopChangingVolume() { |
159 | killTimers(); | 159 | killTimers(); |
160 | // Get rid of the on-screen display stuff | 160 | // Get rid of the on-screen display stuff |
161 | drawnOnScreenDisplay = FALSE; | 161 | drawnOnScreenDisplay = FALSE; |
162 | onScreenDisplayVolume = 0; | 162 | onScreenDisplayVolume = 0; |
163 | int w=0; | 163 | int w=0; |
164 | int h=0; | 164 | int h=0; |
165 | if( !xineControl->hasVideo()) { | 165 | if( !xineControl->hasVideo()) { |
166 | w = audioUI->width(); | 166 | w = audioUI->width(); |
167 | h = audioUI->height(); | 167 | h = audioUI->height(); |
168 | audioUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE ); | 168 | audioUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE ); |
169 | } else { | 169 | } else { |
170 | w = videoUI->width(); | 170 | w = videoUI->width(); |
171 | h = videoUI->height(); | 171 | h = videoUI->height(); |
172 | videoUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE ); | 172 | videoUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE ); |
173 | } | 173 | } |
174 | } | 174 | } |
175 | 175 | ||
176 | 176 | ||
177 | void MediaPlayer::timerEvent( QTimerEvent * ) { | 177 | void MediaPlayer::timerEvent( QTimerEvent * ) { |
178 | if ( volumeDirection == +1 ) { | 178 | if ( volumeDirection == +1 ) { |
179 | volControl->incVol(2); | 179 | volControl->incVol(2); |
180 | } else if ( volumeDirection == -1 ) { | 180 | } else if ( volumeDirection == -1 ) { |
181 | volControl->decVol(2); | 181 | volControl->decVol(2); |
182 | } | 182 | } |
183 | 183 | ||
184 | 184 | ||
185 | // TODO FIXME | 185 | // TODO FIXME |
186 | // huh?? | ||
186 | unsigned int v= 0; | 187 | unsigned int v= 0; |
187 | v = volControl->volume(); | 188 | v = volControl->volume(); |
188 | v = v / 10; | 189 | v = v / 10; |
189 | 190 | ||
190 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { | 191 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { |
191 | return; | 192 | return; |
192 | } | 193 | } |
193 | 194 | ||
194 | int w=0; int h=0; | 195 | int w=0; int h=0; |
195 | if( !xineControl->hasVideo()) { | 196 | if( !xineControl->hasVideo()) { |
196 | w = audioUI->width(); | 197 | w = audioUI->width(); |
197 | h = audioUI->height(); | 198 | h = audioUI->height(); |
198 | 199 | ||
199 | if ( drawnOnScreenDisplay ) { | 200 | if ( drawnOnScreenDisplay ) { |
200 | if ( onScreenDisplayVolume > v ) { | 201 | if ( onScreenDisplayVolume > v ) { |
201 | audioUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE ); | 202 | audioUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE ); |
202 | } | 203 | } |
203 | } | 204 | } |
204 | drawnOnScreenDisplay = TRUE; | 205 | drawnOnScreenDisplay = TRUE; |
205 | onScreenDisplayVolume = v; | 206 | onScreenDisplayVolume = v; |
206 | QPainter p( audioUI ); | 207 | QPainter p( audioUI ); |
207 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); | 208 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); |
208 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); | 209 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); |
209 | 210 | ||
210 | QFont f; | 211 | QFont f; |
211 | f.setPixelSize( 20 ); | 212 | f.setPixelSize( 20 ); |
212 | f.setBold( TRUE ); | 213 | f.setBold( TRUE ); |
213 | p.setFont( f ); | 214 | p.setFont( f ); |
214 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); | 215 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); |
215 | 216 | ||
216 | for ( unsigned int i = 0; i < 10; i++ ) { | 217 | for ( unsigned int i = 0; i < 10; i++ ) { |
217 | if ( v > i ) { | 218 | if ( v > i ) { |
218 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); | 219 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); |
219 | } else { | 220 | } else { |
220 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); | 221 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); |
221 | } | 222 | } |
222 | } | 223 | } |
223 | } else { | 224 | } else { |
224 | w = videoUI->width(); | 225 | w = videoUI->width(); |
225 | h = videoUI->height(); | 226 | h = videoUI->height(); |
226 | 227 | ||
227 | if ( drawnOnScreenDisplay ) { | 228 | if ( drawnOnScreenDisplay ) { |
228 | if ( onScreenDisplayVolume > v ) { | 229 | if ( onScreenDisplayVolume > v ) { |
229 | videoUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE ); | 230 | videoUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE ); |
230 | } | 231 | } |
231 | } | 232 | } |
232 | drawnOnScreenDisplay = TRUE; | 233 | drawnOnScreenDisplay = TRUE; |
233 | onScreenDisplayVolume = v; | 234 | onScreenDisplayVolume = v; |
234 | QPainter p( videoUI ); | 235 | QPainter p( videoUI ); |
235 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); | 236 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); |
236 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); | 237 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); |
237 | 238 | ||
238 | QFont f; | 239 | QFont f; |
239 | f.setPixelSize( 20 ); | 240 | f.setPixelSize( 20 ); |
240 | f.setBold( TRUE ); | 241 | f.setBold( TRUE ); |
241 | p.setFont( f ); | 242 | p.setFont( f ); |
242 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); | 243 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); |
243 | 244 | ||
244 | for ( unsigned int i = 0; i < 10; i++ ) { | 245 | for ( unsigned int i = 0; i < 10; i++ ) { |
245 | if ( v > i ) { | 246 | if ( v > i ) { |
246 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); | 247 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); |
247 | } else { | 248 | } else { |
248 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); | 249 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); |
249 | } | 250 | } |
250 | } | 251 | } |
251 | } | 252 | } |
252 | } | 253 | } |
253 | 254 | ||
254 | 255 | ||
255 | void MediaPlayer::blank( bool b ) { | 256 | void MediaPlayer::blank( bool b ) { |
256 | fd=open("/dev/fb0",O_RDWR); | 257 | fd=open("/dev/fb0",O_RDWR); |
257 | if (fd != -1) { | 258 | if (fd != -1) { |
258 | if ( b ) { | 259 | if ( b ) { |
259 | qDebug("do blanking"); | 260 | qDebug("do blanking"); |
260 | ioctl( fd, FBIOBLANK, 3 ); | 261 | ioctl( fd, FBIOBLANK, 3 ); |
261 | isBlanked = TRUE; | 262 | isBlanked = TRUE; |
262 | } else { | 263 | } else { |
263 | qDebug("do unblanking"); | 264 | qDebug("do unblanking"); |
264 | ioctl( fd, FBIOBLANK, 0); | 265 | ioctl( fd, FBIOBLANK, 0); |
265 | isBlanked = FALSE; | 266 | isBlanked = FALSE; |
266 | } | 267 | } |
267 | close( fd ); | 268 | close( fd ); |
268 | } else { | 269 | } else { |
269 | qDebug("<< /dev/fb0 could not be opened >>"); | 270 | qDebug("<< /dev/fb0 could not be opened >>"); |
270 | } | 271 | } |
271 | } | 272 | } |
272 | 273 | ||
273 | void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { | 274 | void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { |
274 | switch ( e->key() ) { | 275 | switch ( e->key() ) { |
275 | ////////////////////////////// Zaurus keys | 276 | ////////////////////////////// Zaurus keys |
276 | case Key_Home: | 277 | case Key_Home: |
277 | break; | 278 | break; |
278 | case Key_F9: //activity | 279 | case Key_F9: //activity |
279 | break; | 280 | break; |
280 | case Key_F10: //contacts | 281 | case Key_F10: //contacts |
281 | break; | 282 | break; |
282 | case Key_F11: //menu | 283 | case Key_F11: //menu |
283 | break; | 284 | break; |
284 | case Key_F12: //home | 285 | case Key_F12: //home |
285 | qDebug("Blank here"); | 286 | qDebug("Blank here"); |
286 | // mediaPlayerState->toggleBlank(); | 287 | // mediaPlayerState->toggleBlank(); |
287 | break; | 288 | break; |
288 | case Key_F13: //mail | 289 | case Key_F13: //mail |
289 | qDebug("Blank here"); | 290 | qDebug("Blank here"); |
290 | // mediaPlayerState->toggleBlank(); | 291 | // mediaPlayerState->toggleBlank(); |
291 | break; | 292 | break; |
292 | } | 293 | } |
293 | } | 294 | } |
294 | 295 | ||
295 | void MediaPlayer::cleanUp() {// this happens on closing | 296 | void MediaPlayer::cleanUp() {// this happens on closing |
296 | Config cfg( "OpiePlayer" ); | 297 | Config cfg( "OpiePlayer" ); |
297 | mediaPlayerState->writeConfig( cfg ); | 298 | mediaPlayerState->writeConfig( cfg ); |
298 | playList->writeConfig( cfg ); | 299 | playList->writeConfig( cfg ); |
299 | 300 | ||
300 | // QPEApplication::grabKeyboard(); | 301 | // QPEApplication::grabKeyboard(); |
301 | // QPEApplication::ungrabKeyboard(); | 302 | // QPEApplication::ungrabKeyboard(); |
302 | } | 303 | } |
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 6c7f6ba..603a7a3 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -1,264 +1,265 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library 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 <qpe/qpetoolbar.h> | 34 | #include <qpe/qpetoolbar.h> |
35 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
36 | #include <qpe/storage.h> | 36 | #include <qpe/storage.h> |
37 | #include <qpe/mimetype.h> | 37 | #include <qpe/mimetype.h> |
38 | #include <qpe/global.h> | 38 | #include <qpe/global.h> |
39 | #include <qpe/resource.h> | 39 | #include <qpe/resource.h> |
40 | 40 | ||
41 | #include <qdir.h> | 41 | #include <qdir.h> |
42 | #include <qmessagebox.h> | 42 | #include <qmessagebox.h> |
43 | #include <qregexp.h> | 43 | #include <qregexp.h> |
44 | #include <qtextstream.h> | 44 | #include <qtextstream.h> |
45 | 45 | ||
46 | #include "playlistselection.h" | 46 | #include "playlistselection.h" |
47 | #include "playlistwidget.h" | 47 | #include "playlistwidget.h" |
48 | #include "mediaplayerstate.h" | 48 | #include "mediaplayerstate.h" |
49 | #include "inputDialog.h" | 49 | #include "inputDialog.h" |
50 | 50 | ||
51 | //only needed for the random play | 51 | //only needed for the random play |
52 | #include <stdlib.h> | 52 | #include <stdlib.h> |
53 | 53 | ||
54 | #include "audiowidget.h" | 54 | #include "audiowidget.h" |
55 | #include "videowidget.h" | 55 | #include "videowidget.h" |
56 | 56 | ||
57 | extern MediaPlayerState *mediaPlayerState; | 57 | extern MediaPlayerState *mediaPlayerState; |
58 | 58 | ||
59 | 59 | ||
60 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | 60 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) |
61 | : PlayListWidgetGui( parent, name, fl ) { | 61 | : PlayListWidgetGui( parent, name, fl ) { |
62 | 62 | ||
63 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer2/add_to_playlist", | 63 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer2/add_to_playlist", |
64 | this , SLOT(addSelected() ) ); | 64 | this , SLOT(addSelected() ) ); |
65 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer2/remove_from_playlist", | 65 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer2/remove_from_playlist", |
66 | this , SLOT(removeSelected() ) ); | 66 | this , SLOT(removeSelected() ) ); |
67 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", | 67 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", |
68 | this , SLOT( btnPlay( bool) ), TRUE ); | 68 | this , SLOT( btnPlay( bool) ), TRUE ); |
69 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", | 69 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", |
70 | mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); | 70 | mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); |
71 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", | 71 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", |
72 | mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); | 72 | mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); |
73 | 73 | ||
74 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 74 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
75 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); | 75 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); |
76 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); | 76 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); |
77 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); | 77 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); |
78 | pmPlayList->insertSeparator(-1); | 78 | pmPlayList->insertSeparator(-1); |
79 | (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); | 79 | (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); |
80 | (void)new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) ); | 80 | (void)new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) ); |
81 | pmPlayList->insertSeparator(-1); | 81 | pmPlayList->insertSeparator(-1); |
82 | (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); | 82 | (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); |
83 | pmPlayList->insertSeparator(-1); | 83 | pmPlayList->insertSeparator(-1); |
84 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); | 84 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); |
85 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); | 85 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); |
86 | 86 | ||
87 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), mediaPlayerState, SLOT( toggleFullscreen() ) ); | 87 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), mediaPlayerState, SLOT( toggleFullscreen() ) ); |
88 | 88 | ||
89 | Config cfg( "OpiePlayer" ); | 89 | Config cfg( "OpiePlayer" ); |
90 | bool b= cfg.readBoolEntry("FullScreen", 0); | 90 | bool b= cfg.readBoolEntry("FullScreen", 0); |
91 | mediaPlayerState->setFullscreen( b ); | 91 | mediaPlayerState->setFullscreen( b ); |
92 | pmView->setItemChecked( -16, b ); | 92 | pmView->setItemChecked( -16, b ); |
93 | 93 | ||
94 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", d->selectedFiles, SLOT(moveSelectedUp() ) ); | 94 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", d->selectedFiles, SLOT(moveSelectedUp() ) ); |
95 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", d->selectedFiles, SLOT(removeSelected() ) ); | 95 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", d->selectedFiles, SLOT(removeSelected() ) ); |
96 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", d->selectedFiles, SLOT(moveSelectedDown() ) ); | 96 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", d->selectedFiles, SLOT(moveSelectedDown() ) ); |
97 | QVBox *stretch2 = new QVBox( vbox1 ); | 97 | QVBox *stretch2 = new QVBox( vbox1 ); |
98 | 98 | ||
99 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), SLOT( deletePlaylist() ) ); | 99 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), SLOT( deletePlaylist() ) ); |
100 | connect( pmView, SIGNAL( activated( int ) ), this, SLOT( pmViewActivated( int ) ) ); | 100 | connect( pmView, SIGNAL( activated( int ) ), this, SLOT( pmViewActivated( int ) ) ); |
101 | connect( skinsMenu, SIGNAL( activated( int ) ) , this, SLOT( skinsMenuActivated( int ) ) ); | 101 | connect( skinsMenu, SIGNAL( activated( int ) ) , this, SLOT( skinsMenuActivated( int ) ) ); |
102 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), | 102 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), |
103 | this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); | 103 | this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); |
104 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), | 104 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), |
105 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); | 105 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); |
106 | connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), | 106 | connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), |
107 | this,SLOT( playIt( QListViewItem *) ) ); | 107 | this,SLOT( playIt( QListViewItem *) ) ); |
108 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 108 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
109 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), | 109 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), |
110 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); | 110 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); |
111 | connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), | 111 | connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), |
112 | this,SLOT( playIt( QListViewItem *) ) ); | 112 | this,SLOT( playIt( QListViewItem *) ) ); |
113 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 113 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
114 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); | 114 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); |
115 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), this, SLOT( tabChanged( QWidget* ) ) ); | 115 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), this, SLOT( tabChanged( QWidget* ) ) ); |
116 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | 116 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); |
117 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); | 117 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); |
118 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | 118 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); |
119 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); | 119 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); |
120 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | 120 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); |
121 | 121 | ||
122 | readConfig( cfg ); | 122 | readConfig( cfg ); |
123 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "" ); | 123 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "" ); |
124 | loadList(DocLnk( currentPlaylist ) ); | 124 | loadList(DocLnk( currentPlaylist ) ); |
125 | setCaption( tr( "OpiePlayer: " ) + currentPlaylist ); | 125 | setCaption( tr( "OpiePlayer: " ) + currentPlaylist ); |
126 | 126 | ||
127 | // see which skins are installed | 127 | // see which skins are installed |
128 | videoScan=FALSE; | ||
129 | audioScan=FALSE; | ||
128 | populateSkinsMenu(); | 130 | populateSkinsMenu(); |
129 | initializeStates(); | 131 | initializeStates(); |
130 | } | 132 | } |
131 | 133 | ||
132 | 134 | ||
133 | PlayListWidget::~PlayListWidget() { | 135 | PlayListWidget::~PlayListWidget() { |
134 | /* fixing symptoms and not sources is entirely stupid - zecke */ | 136 | // WTF?!@?! |
135 | // Config cfg( "OpiePlayer" ); | 137 | |
136 | // writeConfig( cfg ); | ||
137 | if ( d->current ) { | 138 | if ( d->current ) { |
138 | delete d->current; | 139 | delete d->current; |
139 | } | 140 | } |
140 | delete d; | 141 | delete d; |
141 | } | 142 | } |
142 | 143 | ||
143 | 144 | ||
144 | void PlayListWidget::initializeStates() { | 145 | void PlayListWidget::initializeStates() { |
145 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 146 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
146 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 147 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
147 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 148 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
148 | setPlaylist( true ); | 149 | setPlaylist( true ); |
149 | } | 150 | } |
150 | 151 | ||
151 | 152 | ||
152 | void PlayListWidget::readConfig( Config& cfg ) { | 153 | void PlayListWidget::readConfig( Config& cfg ) { |
153 | cfg.setGroup( "PlayList" ); | 154 | cfg.setGroup( "PlayList" ); |
154 | QString currentString = cfg.readEntry( "current", "" ); | 155 | QString currentString = cfg.readEntry( "current", "" ); |
155 | int noOfFiles = cfg.readNumEntry( "NumberOfFiles", 0 ); | 156 | int noOfFiles = cfg.readNumEntry( "NumberOfFiles", 0 ); |
156 | for ( int i = 0; i < noOfFiles; i++ ) { | 157 | for ( int i = 0; i < noOfFiles; i++ ) { |
157 | QString entryName; | 158 | QString entryName; |
158 | entryName.sprintf( "File%i", i + 1 ); | 159 | entryName.sprintf( "File%i", i + 1 ); |
159 | QString linkFile = cfg.readEntry( entryName ); | 160 | QString linkFile = cfg.readEntry( entryName ); |
160 | if( QFileInfo( linkFile ).exists() ) { | 161 | if( QFileInfo( linkFile ).exists() ) { |
161 | DocLnk lnk( linkFile ); | 162 | DocLnk lnk( linkFile ); |
162 | if ( QFileInfo( lnk.file() ).exists() || linkFile.find( "http" , 0, TRUE) != -1) { | 163 | if ( QFileInfo( lnk.file() ).exists() || linkFile.find( "http" , 0, TRUE) != -1) { |
163 | d->selectedFiles->addToSelection( lnk ); | 164 | d->selectedFiles->addToSelection( lnk ); |
164 | } | 165 | } |
165 | } | 166 | } |
166 | } | 167 | } |
167 | d->selectedFiles->setSelectedItem( currentString ); | 168 | d->selectedFiles->setSelectedItem( currentString ); |
168 | } | 169 | } |
169 | 170 | ||
170 | 171 | ||
171 | void PlayListWidget::writeConfig( Config& cfg ) const { | 172 | void PlayListWidget::writeConfig( Config& cfg ) const { |
172 | d->selectedFiles->writeCurrent( cfg ); | 173 | d->selectedFiles->writeCurrent( cfg ); |
173 | cfg.setGroup( "PlayList" ); | 174 | cfg.setGroup( "PlayList" ); |
174 | int noOfFiles = 0; | 175 | int noOfFiles = 0; |
175 | d->selectedFiles->first(); | 176 | d->selectedFiles->first(); |
176 | do { | 177 | do { |
177 | const DocLnk *lnk = d->selectedFiles->current(); | 178 | const DocLnk *lnk = d->selectedFiles->current(); |
178 | if ( lnk ) { | 179 | if ( lnk ) { |
179 | QString entryName; | 180 | QString entryName; |
180 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 181 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
181 | cfg.writeEntry( entryName, lnk->linkFile() ); | 182 | cfg.writeEntry( entryName, lnk->linkFile() ); |
182 | // if this link does exist, add it so we have the file | 183 | // if this link does exist, add it so we have the file |
183 | // next time... | 184 | // next time... |
184 | if ( !QFile::exists( lnk->linkFile() ) ) { | 185 | if ( !QFile::exists( lnk->linkFile() ) ) { |
185 | // the way writing lnks doesn't really check for out | 186 | // the way writing lnks doesn't really check for out |
186 | // of disk space, but check it anyway. | 187 | // of disk space, but check it anyway. |
187 | if ( !lnk->writeLink() ) { | 188 | if ( !lnk->writeLink() ) { |
188 | QMessageBox::critical( 0, tr("Out of space"), | 189 | QMessageBox::critical( 0, tr("Out of space"), |
189 | tr( "There was a problem saving " | 190 | tr( "There was a problem saving " |
190 | "the playlist.\n" | 191 | "the playlist.\n" |
191 | "Your playlist " | 192 | "Your playlist " |
192 | "may be missing some entries\n" | 193 | "may be missing some entries\n" |
193 | "the next time you start it." ) | 194 | "the next time you start it." ) |
194 | ); | 195 | ); |
195 | } | 196 | } |
196 | } | 197 | } |
197 | noOfFiles++; | 198 | noOfFiles++; |
198 | } | 199 | } |
199 | } | 200 | } |
200 | while ( d->selectedFiles->next() ); | 201 | while ( d->selectedFiles->next() ); |
201 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 202 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
202 | } | 203 | } |
203 | 204 | ||
204 | 205 | ||
205 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 206 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
206 | d->setDocumentUsed = FALSE; | 207 | d->setDocumentUsed = FALSE; |
207 | if ( mediaPlayerState->playlist() ) { | 208 | if ( mediaPlayerState->playlist() ) { |
208 | if( QFileInfo( lnk.file() ).exists() || lnk.file().left(4) == "http" ) | 209 | if( QFileInfo( lnk.file() ).exists() || lnk.file().left(4) == "http" ) |
209 | d->selectedFiles->addToSelection( lnk ); | 210 | d->selectedFiles->addToSelection( lnk ); |
210 | } | 211 | } |
211 | else | 212 | else |
212 | mediaPlayerState->setPlaying( TRUE ); | 213 | mediaPlayerState->setPlaying( TRUE ); |
213 | } | 214 | } |
214 | 215 | ||
215 | 216 | ||
216 | void PlayListWidget::clearList() { | 217 | void PlayListWidget::clearList() { |
217 | while ( first() ) { | 218 | while ( first() ) { |
218 | d->selectedFiles->removeSelected(); | 219 | d->selectedFiles->removeSelected(); |
219 | } | 220 | } |
220 | } | 221 | } |
221 | 222 | ||
222 | 223 | ||
223 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { | 224 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { |
224 | switch (mouse) { | 225 | switch (mouse) { |
225 | case 1: | 226 | case 1: |
226 | break; | 227 | break; |
227 | case 2: | 228 | case 2: |
228 | { | 229 | { |
229 | QPopupMenu m; | 230 | QPopupMenu m; |
230 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 231 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
231 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 232 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
232 | m.exec( QCursor::pos() ); | 233 | m.exec( QCursor::pos() ); |
233 | } | 234 | } |
234 | break; | 235 | break; |
235 | } | 236 | } |
236 | } | 237 | } |
237 | 238 | ||
238 | 239 | ||
239 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 240 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
240 | switch (mouse) { | 241 | switch (mouse) { |
241 | case 1: | 242 | case 1: |
242 | break; | 243 | break; |
243 | case 2: | 244 | case 2: |
244 | { | 245 | { |
245 | QPopupMenu m; | 246 | QPopupMenu m; |
246 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 247 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
247 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 248 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
248 | m.exec( QCursor::pos() ); | 249 | m.exec( QCursor::pos() ); |
249 | } | 250 | } |
250 | break; | 251 | break; |
251 | } | 252 | } |
252 | } | 253 | } |
253 | 254 | ||
254 | 255 | ||
255 | void PlayListWidget::addAllToList() { | 256 | void PlayListWidget::addAllToList() { |
256 | DocLnkSet filesAll; | 257 | DocLnkSet filesAll; |
257 | Global::findDocuments(&filesAll, "video/*;audio/*"); | 258 | Global::findDocuments(&filesAll, "video/*;audio/*"); |
258 | QListIterator<DocLnk> Adit( filesAll.children() ); | 259 | QListIterator<DocLnk> Adit( filesAll.children() ); |
259 | for ( ; Adit.current(); ++Adit ) { | 260 | for ( ; Adit.current(); ++Adit ) { |
260 | if( QFileInfo( Adit.current()->file() ).exists() ) { | 261 | if( QFileInfo( Adit.current()->file() ).exists() ) { |
261 | d->selectedFiles->addToSelection( **Adit ); | 262 | d->selectedFiles->addToSelection( **Adit ); |
262 | } | 263 | } |
263 | } | 264 | } |
264 | } | 265 | } |
@@ -659,399 +660,401 @@ void PlayListWidget::btnPlay(bool b) { | |||
659 | d->selectedFiles->unSelect(); | 660 | d->selectedFiles->unSelect(); |
660 | insanityBool=FALSE; | 661 | insanityBool=FALSE; |
661 | }// videoView->clearSelection(); | 662 | }// videoView->clearSelection(); |
662 | break; | 663 | break; |
663 | }; | 664 | }; |
664 | 665 | ||
665 | } | 666 | } |
666 | 667 | ||
667 | void PlayListWidget::deletePlaylist() { | 668 | void PlayListWidget::deletePlaylist() { |
668 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 669 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
669 | (tr("You really want to delete\nthis playlist?")), | 670 | (tr("You really want to delete\nthis playlist?")), |
670 | (tr("Yes")), (tr("No")), 0 )){ | 671 | (tr("Yes")), (tr("No")), 0 )){ |
671 | case 0: // Yes clicked, | 672 | case 0: // Yes clicked, |
672 | QFile().remove(playLists->selected()->file()); | 673 | QFile().remove(playLists->selected()->file()); |
673 | QFile().remove(playLists->selected()->linkFile()); | 674 | QFile().remove(playLists->selected()->linkFile()); |
674 | playLists->reread(); | 675 | playLists->reread(); |
675 | break; | 676 | break; |
676 | case 1: // Cancel | 677 | case 1: // Cancel |
677 | break; | 678 | break; |
678 | }; | 679 | }; |
679 | } | 680 | } |
680 | 681 | ||
681 | 682 | ||
682 | void PlayListWidget::playSelected() { | 683 | void PlayListWidget::playSelected() { |
683 | btnPlay( TRUE); | 684 | btnPlay( TRUE); |
684 | } | 685 | } |
685 | 686 | ||
686 | 687 | ||
687 | void PlayListWidget::scanForAudio() { | 688 | void PlayListWidget::scanForAudio() { |
688 | // qDebug("scan for audio"); | 689 | // qDebug("scan for audio"); |
689 | files.detachChildren(); | 690 | files.detachChildren(); |
690 | QListIterator<DocLnk> sdit( files.children() ); | 691 | QListIterator<DocLnk> sdit( files.children() ); |
691 | for ( ; sdit.current(); ++sdit ) { | 692 | for ( ; sdit.current(); ++sdit ) { |
692 | delete sdit.current(); | 693 | delete sdit.current(); |
693 | } | 694 | } |
694 | Global::findDocuments(&files, "audio/*"); | 695 | Global::findDocuments(&files, "audio/*"); |
695 | audioScan = TRUE; | 696 | audioScan = TRUE; |
696 | } | 697 | } |
697 | 698 | ||
698 | void PlayListWidget::scanForVideo() { | 699 | void PlayListWidget::scanForVideo() { |
699 | // qDebug("scan for video"); | 700 | // qDebug("scan for video"); |
700 | vFiles.detachChildren(); | 701 | vFiles.detachChildren(); |
701 | QListIterator<DocLnk> sdit( vFiles.children() ); | 702 | QListIterator<DocLnk> sdit( vFiles.children() ); |
702 | for ( ; sdit.current(); ++sdit ) { | 703 | for ( ; sdit.current(); ++sdit ) { |
703 | delete sdit.current(); | 704 | delete sdit.current(); |
704 | } | 705 | } |
705 | Global::findDocuments(&vFiles, "video/*"); | 706 | Global::findDocuments(&vFiles, "video/*"); |
706 | videoScan = TRUE; | 707 | videoScan = TRUE; |
707 | } | 708 | } |
708 | 709 | ||
709 | void PlayListWidget::populateAudioView() { | 710 | void PlayListWidget::populateAudioView() { |
710 | audioView->clear(); | 711 | audioView->clear(); |
711 | StorageInfo storageInfo; | 712 | StorageInfo storageInfo; |
712 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 713 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
713 | if(!audioScan) { | 714 | if(!audioScan) { |
714 | scanForAudio(); | 715 | scanForAudio(); |
715 | } | 716 | } |
716 | 717 | ||
717 | QListIterator<DocLnk> dit( files.children() ); | 718 | QListIterator<DocLnk> dit( files.children() ); |
718 | QListIterator<FileSystem> it ( fs ); | 719 | QListIterator<FileSystem> it ( fs ); |
719 | 720 | ||
720 | QString storage; | 721 | QString storage; |
721 | for ( ; dit.current(); ++dit ) { | 722 | for ( ; dit.current(); ++dit ) { |
722 | for( ; it.current(); ++it ){ | 723 | for( ; it.current(); ++it ){ |
723 | const QString name = (*it)->name(); | 724 | const QString name = (*it)->name(); |
724 | const QString path = (*it)->path(); | 725 | const QString path = (*it)->path(); |
725 | if(dit.current()->file().find(path) != -1 ) { | 726 | if(dit.current()->file().find(path) != -1 ) { |
726 | storage = name; | 727 | storage = name; |
727 | } | 728 | } |
728 | } | 729 | } |
729 | 730 | ||
730 | QListViewItem * newItem; | 731 | QListViewItem * newItem; |
731 | if ( QFile( dit.current()->file()).exists() ) { | 732 | if ( QFile( dit.current()->file()).exists() ) { |
732 | // qDebug(dit.current()->name()); | 733 | // qDebug(dit.current()->name()); |
733 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 734 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
734 | QString::number( QFile( dit.current()->file()).size() ), storage); | 735 | QString::number( QFile( dit.current()->file()).size() ), storage); |
735 | newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); | 736 | newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); |
736 | } | 737 | } |
737 | } | 738 | } |
738 | } | 739 | } |
739 | 740 | ||
740 | 741 | ||
741 | void PlayListWidget::populateVideoView() { | 742 | void PlayListWidget::populateVideoView() { |
742 | videoView->clear(); | 743 | videoView->clear(); |
743 | StorageInfo storageInfo; | 744 | StorageInfo storageInfo; |
744 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 745 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
745 | 746 | ||
746 | if(!videoScan ) { | 747 | if(!videoScan ) { |
747 | scanForVideo(); | 748 | scanForVideo(); |
748 | } | 749 | } |
749 | 750 | ||
750 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 751 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
751 | QListIterator<FileSystem> it ( fs ); | 752 | QListIterator<FileSystem> it ( fs ); |
752 | videoView->clear(); | 753 | videoView->clear(); |
753 | QString storage; | 754 | QString storage; |
754 | for ( ; Vdit.current(); ++Vdit ) { | 755 | for ( ; Vdit.current(); ++Vdit ) { |
755 | for( ; it.current(); ++it ) { | 756 | for( ; it.current(); ++it ) { |
756 | const QString name = (*it)->name(); | 757 | const QString name = (*it)->name(); |
757 | const QString path = (*it)->path(); | 758 | const QString path = (*it)->path(); |
758 | if( Vdit.current()->file().find(path) != -1 ) { | 759 | if( Vdit.current()->file().find(path) != -1 ) { |
759 | storage=name; | 760 | storage=name; |
760 | } | 761 | } |
761 | } | 762 | } |
762 | 763 | ||
763 | QListViewItem * newItem; | 764 | QListViewItem * newItem; |
764 | if ( QFile( Vdit.current()->file() ).exists() ) { | 765 | if ( QFile( Vdit.current()->file() ).exists() ) { |
765 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 766 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
766 | QString::number( QFile( Vdit.current()->file() ).size() ), storage ); | 767 | QString::number( QFile( Vdit.current()->file() ).size() ), storage ); |
767 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); | 768 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); |
768 | } | 769 | } |
769 | } | 770 | } |
770 | } | 771 | } |
771 | 772 | ||
772 | 773 | ||
773 | void PlayListWidget::openFile() { | 774 | void PlayListWidget::openFile() { |
774 | QString filename, name; | 775 | QString filename, name; |
775 | InputDialog *fileDlg; | 776 | InputDialog *fileDlg; |
776 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 777 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
777 | fileDlg->exec(); | 778 | fileDlg->exec(); |
778 | if( fileDlg->result() == 1 ) { | 779 | if( fileDlg->result() == 1 ) { |
779 | filename = fileDlg->text(); | 780 | filename = fileDlg->text(); |
780 | 781 | ||
781 | qDebug( "Selected filename is " + filename ); | 782 | qDebug( "Selected filename is " + filename ); |
782 | if( filename.right( 3 ) == "m3u" ) { | 783 | if( filename.right( 3 ) == "m3u" ) { |
783 | readm3u( filename ); | 784 | readm3u( filename ); |
784 | } else if( filename.right(3) == "pls" ) { | 785 | } else if( filename.right(3) == "pls" ) { |
785 | readPls( filename ); | 786 | readPls( filename ); |
786 | } else { | 787 | } else { |
787 | /* FIXME ....... AUDIO/X-MPEGURL is bad*/ | 788 | // this doesnt need fixing |
788 | DocLnk lnk; | 789 | DocLnk lnk; |
789 | lnk.setName( filename ); //sets file name | 790 | lnk.setName( filename ); //sets file name |
790 | lnk.setFile( filename ); //sets File property | 791 | lnk.setFile( filename ); //sets File property |
791 | //qWarning( "Mimetype: " + MimeType( QFile::encodeName(filename) ).id() ); | 792 | //qWarning( "Mimetype: " + MimeType( QFile::encodeName(filename) ).id() ); |
792 | lnk.setType( MimeType( QFile::encodeName(filename) ).id() ); | 793 | lnk.setType( MimeType( QFile::encodeName(filename) ).id() ); |
793 | lnk.setExec( "opieplayer" ); | 794 | lnk.setExec( "opieplayer" ); |
794 | lnk.setIcon( "opieplayer2/MPEGPlayer" ); | 795 | lnk.setIcon( "opieplayer2/MPEGPlayer" ); |
795 | 796 | ||
796 | if( !lnk.writeLink() ) { | 797 | if( !lnk.writeLink() ) { |
797 | qDebug( "Writing doclink did not work" ); | 798 | qDebug( "Writing doclink did not work" ); |
798 | } | 799 | } |
799 | d->selectedFiles->addToSelection( lnk ); | 800 | d->selectedFiles->addToSelection( lnk ); |
800 | } | 801 | } |
801 | } | 802 | } |
802 | if( fileDlg ) { | 803 | if( fileDlg ) { |
803 | delete fileDlg; | 804 | delete fileDlg; |
804 | } | 805 | } |
805 | } | 806 | } |
806 | 807 | ||
807 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { | 808 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { |
808 | switch ( e->key() ) { | 809 | switch ( e->key() ) { |
809 | ////////////////////////////// Zaurus keys | 810 | ////////////////////////////// Zaurus keys |
810 | case Key_F9: //activity | 811 | case Key_F9: //activity |
811 | // if(audioUI->isHidden()) | 812 | // if(audioUI->isHidden()) |
812 | // audioUI->showMaximized(); | 813 | // audioUI->showMaximized(); |
813 | break; | 814 | break; |
814 | case Key_F10: //contacts | 815 | case Key_F10: //contacts |
815 | // if( videoUI->isHidden()) | 816 | // if( videoUI->isHidden()) |
816 | // videoUI->showMaximized(); | 817 | // videoUI->showMaximized(); |
817 | break; | 818 | break; |
818 | case Key_F11: //menu | 819 | case Key_F11: //menu |
819 | break; | 820 | break; |
820 | case Key_F12: //home | 821 | case Key_F12: //home |
821 | // doBlank(); | 822 | // doBlank(); |
822 | break; | 823 | break; |
823 | case Key_F13: //mail | 824 | case Key_F13: //mail |
824 | // doUnblank(); | 825 | // doUnblank(); |
825 | break; | 826 | break; |
826 | case Key_Q: //add to playlist | 827 | case Key_Q: //add to playlist |
827 | addSelected(); | 828 | addSelected(); |
828 | break; | 829 | break; |
829 | case Key_R: //remove from playlist | 830 | case Key_R: //remove from playlist |
830 | removeSelected(); | 831 | removeSelected(); |
831 | break; | 832 | break; |
832 | // case Key_P: //play | 833 | // case Key_P: //play |
833 | // qDebug("Play"); | 834 | // qDebug("Play"); |
834 | // playSelected(); | 835 | // playSelected(); |
835 | // break; | 836 | // break; |
836 | case Key_Space: | 837 | case Key_Space: |
837 | // playSelected(); puh | 838 | // playSelected(); puh |
838 | break; | 839 | break; |
839 | case Key_1: | 840 | case Key_1: |
840 | tabWidget->setCurrentPage( 0 ); | 841 | tabWidget->setCurrentPage( 0 ); |
841 | break; | 842 | break; |
842 | case Key_2: | 843 | case Key_2: |
843 | tabWidget->setCurrentPage( 1 ); | 844 | tabWidget->setCurrentPage( 1 ); |
844 | break; | 845 | break; |
845 | case Key_3: | 846 | case Key_3: |
846 | tabWidget->setCurrentPage( 2 ); | 847 | tabWidget->setCurrentPage( 2 ); |
847 | break; | 848 | break; |
848 | case Key_4: | 849 | case Key_4: |
849 | tabWidget->setCurrentPage( 3 ); | 850 | tabWidget->setCurrentPage( 3 ); |
850 | break; | 851 | break; |
851 | case Key_Down: | 852 | case Key_Down: |
852 | if ( !d->selectedFiles->next() ) | 853 | if ( !d->selectedFiles->next() ) |
853 | d->selectedFiles->first(); | 854 | d->selectedFiles->first(); |
854 | 855 | ||
855 | break; | 856 | break; |
856 | case Key_Up: | 857 | case Key_Up: |
857 | if ( !d->selectedFiles->prev() ) | 858 | if ( !d->selectedFiles->prev() ) |
858 | // d->selectedFiles->last(); | 859 | // d->selectedFiles->last(); |
859 | 860 | ||
860 | break; | 861 | break; |
861 | 862 | ||
862 | } | 863 | } |
863 | } | 864 | } |
864 | 865 | ||
865 | void PlayListWidget::readm3u( const QString &filename ) { | 866 | void PlayListWidget::readm3u( const QString &filename ) { |
866 | qDebug( "m3u filename is " + filename ); | 867 | qDebug( "m3u filename is " + filename ); |
867 | QFile f( filename ); | 868 | QFile f( filename ); |
868 | 869 | ||
869 | if( f.open( IO_ReadOnly ) ) { | 870 | if( f.open( IO_ReadOnly ) ) { |
870 | QTextStream t(&f); | 871 | QTextStream t(&f); |
871 | QString s;//, first, second; | 872 | QString s;//, first, second; |
872 | int i=0; | 873 | int i=0; |
873 | while ( !t.atEnd() ) { | 874 | while ( !t.atEnd() ) { |
874 | s=t.readLine(); | 875 | s=t.readLine(); |
875 | 876 | ||
876 | if( s.find( "#", 0, TRUE) == -1 ) { | 877 | if( s.find( "#", 0, TRUE) == -1 ) { |
877 | if( s.find( " ", 0, TRUE) == -1 ) { // not sure if this is neede since cf uses vfat | 878 | if( s.find( " ", 0, TRUE) == -1 ) { // not sure if this is neede since cf uses vfat |
878 | if( s.left(2) == "E:" || s.left(2) == "P:" ) { | 879 | if( s.left(2) == "E:" || s.left(2) == "P:" ) { |
879 | s = s.right( s.length() -2 ); | 880 | s = s.right( s.length() -2 ); |
880 | DocLnk lnk( s ); | 881 | DocLnk lnk( s ); |
881 | QFileInfo f( s ); | 882 | QFileInfo f( s ); |
882 | QString name = f.baseName(); | 883 | QString name = f.baseName(); |
883 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); | 884 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); |
884 | lnk.setName( name ); | 885 | lnk.setName( name ); |
885 | s=s.replace( QRegExp( "\\" ), "/" ); | 886 | s=s.replace( QRegExp( "\\" ), "/" ); |
886 | lnk.setFile( s ); | 887 | lnk.setFile( s ); |
887 | lnk.writeLink(); | 888 | lnk.writeLink(); |
888 | qDebug( "add " + name); | 889 | qDebug( "add " + name); |
889 | d->selectedFiles->addToSelection( lnk ); | 890 | d->selectedFiles->addToSelection( lnk ); |
890 | } else { // is url | 891 | } else { // is url |
891 | s.replace( QRegExp( "%20" )," " ); | 892 | s.replace( QRegExp( "%20" )," " ); |
892 | DocLnk lnk( s ); | 893 | DocLnk lnk( s ); |
893 | QString name; | 894 | QString name; |
894 | if( name.left( 4 ) == "http" ) { | 895 | if( name.left( 4 ) == "http" ) { |
895 | name = s.right( s.length() - 7 ); | 896 | name = s.right( s.length() - 7 ); |
896 | } else { | 897 | } else { |
897 | name = s; | 898 | name = s; |
898 | } | 899 | } |
899 | lnk.setName( name ); | 900 | lnk.setName( name ); |
900 | if( s.at( s.length() - 4) == '.' ) { | 901 | if( s.at( s.length() - 4) == '.' ) { |
901 | lnk.setFile( s ); | 902 | lnk.setFile( s ); |
902 | } else { | 903 | } else { |
903 | lnk.setFile( s + "/" ); | 904 | lnk.setFile( s + "/" ); |
904 | } | 905 | } |
905 | lnk.setType( "audio/x-mpegurl" ); | 906 | lnk.setType( "audio/x-mpegurl" ); |
906 | lnk.writeLink(); | 907 | lnk.writeLink(); |
907 | d->selectedFiles->addToSelection( lnk ); | 908 | d->selectedFiles->addToSelection( lnk ); |
908 | } | 909 | } |
909 | i++; | 910 | i++; |
910 | } | 911 | } |
911 | } | 912 | } |
912 | } | 913 | } |
913 | } | 914 | } |
914 | f.close(); | 915 | f.close(); |
915 | } | 916 | } |
916 | 917 | ||
917 | void PlayListWidget::writem3u() { | 918 | void PlayListWidget::writem3u() { |
918 | InputDialog *fileDlg; | 919 | InputDialog *fileDlg; |
919 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 920 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
920 | fileDlg->exec(); | 921 | fileDlg->exec(); |
921 | QString filename, list; | 922 | QString filename, list; |
922 | if( fileDlg->result() == 1 ) { | 923 | if( fileDlg->result() == 1 ) { |
923 | filename = fileDlg->text(); | 924 | filename = fileDlg->text(); |
924 | qDebug( filename ); | 925 | qDebug( filename ); |
925 | int noOfFiles = 0; | 926 | int noOfFiles = 0; |
926 | d->selectedFiles->first(); | 927 | d->selectedFiles->first(); |
927 | do { | 928 | do { |
928 | // we dont check for existance because of url's | 929 | // we dont check for existance because of url's |
929 | // qDebug(d->selectedFiles->current()->file()); | 930 | // qDebug(d->selectedFiles->current()->file()); |
930 | 931 | ||
931 | // so maybe we should do some net checking to ,-) | 932 | // so maybe we should do some net checking to ,-) |
933 | // no, cause it takes to long... | ||
934 | |||
932 | list += d->selectedFiles->current()->file() + "\n"; | 935 | list += d->selectedFiles->current()->file() + "\n"; |
933 | noOfFiles++; | 936 | noOfFiles++; |
934 | } | 937 | } |
935 | while ( d->selectedFiles->next() ); | 938 | while ( d->selectedFiles->next() ); |
936 | qDebug( list ); | 939 | qDebug( list ); |
937 | if( filename.left( 1) != "/" ) { | 940 | if( filename.left( 1) != "/" ) { |
938 | filename=QPEApplication::documentDir() + "/" + filename; | 941 | filename=QPEApplication::documentDir() + "/" + filename; |
939 | } | 942 | } |
940 | if( filename.right( 3 ) != "m3u" ) { | 943 | if( filename.right( 3 ) != "m3u" ) { |
941 | filename=filename+".m3u"; | 944 | filename=filename+".m3u"; |
942 | } | 945 | } |
943 | QFile f( filename ); | 946 | QFile f( filename ); |
944 | f.open( IO_WriteOnly ); | 947 | f.open( IO_WriteOnly ); |
945 | f.writeBlock( list, list.length() ); | 948 | f.writeBlock( list, list.length() ); |
946 | f.close(); | 949 | f.close(); |
947 | } | 950 | } |
948 | if( fileDlg ) { | 951 | if( fileDlg ) { |
949 | delete fileDlg; | 952 | delete fileDlg; |
950 | } | 953 | } |
951 | } | 954 | } |
952 | 955 | ||
953 | void PlayListWidget::readPls( const QString &filename ) { | 956 | void PlayListWidget::readPls( const QString &filename ) { |
954 | 957 | ||
955 | qDebug( "pls filename is " + filename ); | 958 | qDebug( "pls filename is " + filename ); |
956 | QFile f( filename ); | 959 | QFile f( filename ); |
957 | 960 | ||
958 | if( f.open( IO_ReadOnly ) ) { | 961 | if( f.open( IO_ReadOnly ) ) { |
959 | QTextStream t( &f ); | 962 | QTextStream t( &f ); |
960 | QString s;//, first, second; | 963 | QString s;//, first, second; |
961 | int i = 0; | 964 | int i = 0; |
962 | while ( !t.atEnd() ) { | 965 | while ( !t.atEnd() ) { |
963 | s = t.readLine(); | 966 | s = t.readLine(); |
964 | if( s.left(4) == "File" ) { | 967 | if( s.left(4) == "File" ) { |
965 | s = s.right( s.length() - 6 ); | 968 | s = s.right( s.length() - 6 ); |
966 | s.replace( QRegExp( "%20" )," "); | 969 | s.replace( QRegExp( "%20" )," "); |
967 | qDebug( "adding " + s + " to playlist" ); | 970 | qDebug( "adding " + s + " to playlist" ); |
968 | // numberofentries=2 | 971 | // numberofentries=2 |
969 | // File1=http | 972 | // File1=http |
970 | // Title | 973 | // Title |
971 | // Length | 974 | // Length |
972 | // Version | 975 | // Version |
973 | // File2=http | 976 | // File2=http |
974 | s = s.replace( QRegExp( "\\" ), "/" ); | 977 | s = s.replace( QRegExp( "\\" ), "/" ); |
975 | DocLnk lnk( s ); | 978 | DocLnk lnk( s ); |
976 | QFileInfo f( s ); | 979 | QFileInfo f( s ); |
977 | QString name = f.baseName(); | 980 | QString name = f.baseName(); |
978 | if( name.left( 4 ) == "http" ) { | 981 | if( name.left( 4 ) == "http" ) { |
979 | name = s.right( s.length() - 7); | 982 | name = s.right( s.length() - 7); |
980 | } else { | 983 | } else { |
981 | name = s; | 984 | name = s; |
982 | } | 985 | } |
983 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 986 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
984 | lnk.setName( name ); | 987 | lnk.setName( name ); |
985 | if( s.at( s.length() - 4) == '.') // if this is probably a file | 988 | if( s.at( s.length() - 4) == '.') // if this is probably a file |
986 | lnk.setFile( s ); | 989 | lnk.setFile( s ); |
987 | else { //if its a url | 990 | else { //if its a url |
988 | if( name.right( 1 ).find( '/' ) == -1) { | 991 | if( name.right( 1 ).find( '/' ) == -1) { |
989 | s += "/"; | 992 | s += "/"; |
990 | } | 993 | } |
991 | lnk.setFile( s ); | 994 | lnk.setFile( s ); |
992 | } | 995 | } |
993 | lnk.setType( "audio/x-mpegurl" ); | 996 | lnk.setType( "audio/x-mpegurl" ); |
994 | 997 | ||
995 | //qDebug("DocLnk add "+name); | 998 | //qDebug("DocLnk add "+name); |
996 | d->selectedFiles->addToSelection( lnk ); | 999 | d->selectedFiles->addToSelection( lnk ); |
997 | } | 1000 | } |
998 | } | 1001 | } |
999 | i++; | 1002 | i++; |
1000 | } | 1003 | } |
1001 | } | 1004 | } |
1002 | 1005 | ||
1003 | void PlayListWidget::pmViewActivated(int index) { | 1006 | void PlayListWidget::pmViewActivated(int index) { |
1004 | // qDebug("%d", index); | 1007 | // qDebug("%d", index); |
1005 | switch(index) { | 1008 | switch(index) { |
1006 | case -16: | 1009 | case -16: |
1007 | { | 1010 | { |
1008 | mediaPlayerState->toggleFullscreen(); | 1011 | mediaPlayerState->toggleFullscreen(); |
1009 | bool b=mediaPlayerState->fullscreen(); | 1012 | bool b=mediaPlayerState->fullscreen(); |
1010 | pmView->setItemChecked( index, b); | 1013 | pmView->setItemChecked( index, b); |
1011 | Config cfg( "OpiePlayer" ); | 1014 | Config cfg( "OpiePlayer" ); |
1012 | cfg.writeEntry( "FullScreen", b ); | 1015 | cfg.writeEntry( "FullScreen", b ); |
1013 | } | 1016 | } |
1014 | break; | 1017 | break; |
1015 | }; | 1018 | }; |
1016 | } | 1019 | } |
1017 | 1020 | ||
1018 | void PlayListWidget::populateSkinsMenu() { | 1021 | void PlayListWidget::populateSkinsMenu() { |
1019 | int item = 0; | 1022 | int item = 0; |
1020 | defaultSkinIndex = 0; | 1023 | defaultSkinIndex = 0; |
1021 | QString skinName; | 1024 | QString skinName; |
1022 | Config cfg( "OpiePlayer" ); | 1025 | Config cfg( "OpiePlayer" ); |
1023 | cfg.setGroup("Options" ); | 1026 | cfg.setGroup("Options" ); |
1024 | QString skin = cfg.readEntry( "Skin", "default" ); | 1027 | QString skin = cfg.readEntry( "Skin", "default" ); |
1025 | 1028 | ||
1026 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); | 1029 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); |
1027 | skinsDir.setFilter( QDir::Dirs ); | 1030 | skinsDir.setFilter( QDir::Dirs ); |
1028 | skinsDir.setSorting(QDir::Name ); | 1031 | skinsDir.setSorting(QDir::Name ); |
1029 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); | 1032 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); |
1030 | QFileInfoListIterator it( *skinslist ); | 1033 | QFileInfoListIterator it( *skinslist ); |
1031 | QFileInfo *fi; | 1034 | QFileInfo *fi; |
1032 | while ( ( fi = it.current() ) ) { | 1035 | while ( ( fi = it.current() ) ) { |
1033 | skinName = fi->fileName(); | 1036 | skinName = fi->fileName(); |
1034 | qDebug( fi->fileName() ); | 1037 | qDebug( fi->fileName() ); |
1035 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { | 1038 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { |
1036 | item = skinsMenu->insertItem( fi->fileName() ) ; | 1039 | item = skinsMenu->insertItem( fi->fileName() ) ; |
1037 | } | 1040 | } |
1038 | if( skinName == "default" ) { | 1041 | if( skinName == "default" ) { |
1039 | defaultSkinIndex = item; | 1042 | defaultSkinIndex = item; |
1040 | } | 1043 | } |
1041 | if( skinName == skin ) { | 1044 | if( skinName == skin ) { |
1042 | skinsMenu->setItemChecked( item, TRUE ); | 1045 | skinsMenu->setItemChecked( item, TRUE ); |
1043 | } | 1046 | } |
1044 | ++it; | 1047 | ++it; |
1045 | } | 1048 | } |
1046 | } | 1049 | } |
1047 | 1050 | ||
1048 | void PlayListWidget::skinsMenuActivated( int item ) { | 1051 | void PlayListWidget::skinsMenuActivated( int item ) { |
1049 | for( uint i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { | 1052 | for( uint i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { |
1050 | skinsMenu->setItemChecked( i, FALSE ); | 1053 | skinsMenu->setItemChecked( i, FALSE ); |
1051 | } | 1054 | } |
1052 | skinsMenu->setItemChecked( item, TRUE ); | 1055 | skinsMenu->setItemChecked( item, TRUE ); |
1053 | 1056 | ||
1054 | Config cfg( "OpiePlayer" ); | 1057 | Config cfg( "OpiePlayer" ); |
1055 | cfg.setGroup("Options"); | 1058 | cfg.setGroup("Options"); |
1056 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); | 1059 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); |
1057 | } | 1060 | } |