author | llornkcor <llornkcor> | 2002-08-20 11:58:03 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-08-20 11:58:03 (UTC) |
commit | dfd3bcb3dd20cc72487c527d135e076a0ff78b25 (patch) (unidiff) | |
tree | 0e26510735ca9c2b65e39e03ab56c77372de8d6a | |
parent | b00ba7b9cdf02a4512f70694e2262ce6e3ebcb98 (diff) | |
download | opie-dfd3bcb3dd20cc72487c527d135e076a0ff78b25.zip opie-dfd3bcb3dd20cc72487c527d135e076a0ff78b25.tar.gz opie-dfd3bcb3dd20cc72487c527d135e076a0ff78b25.tar.bz2 |
move configwrite to a better place not in deconstructor
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.cpp | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 3 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.h | 2 |
3 files changed, 3 insertions, 4 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index 6a48b82..0526c2a 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp | |||
@@ -1,299 +1,301 @@ | |||
1 | #include <qpe/qpeapplication.h> | 1 | #include <qpe/qpeapplication.h> |
2 | #include <qpe/qlibrary.h> | 2 | #include <qpe/qlibrary.h> |
3 | #include <qpe/resource.h> | 3 | #include <qpe/resource.h> |
4 | #include <qpe/config.h> | 4 | #include <qpe/config.h> |
5 | #include <qpe/qcopenvelope_qws.h> | 5 | #include <qpe/qcopenvelope_qws.h> |
6 | 6 | ||
7 | #include <qmainwindow.h> | 7 | #include <qmainwindow.h> |
8 | #include <qmessagebox.h> | 8 | #include <qmessagebox.h> |
9 | #include <qwidgetstack.h> | 9 | #include <qwidgetstack.h> |
10 | #include <qfile.h> | 10 | #include <qfile.h> |
11 | 11 | ||
12 | #include "mediaplayer.h" | 12 | #include "mediaplayer.h" |
13 | #include "playlistwidget.h" | 13 | #include "playlistwidget.h" |
14 | #include "audiowidget.h" | 14 | #include "audiowidget.h" |
15 | #include "videowidget.h" | 15 | #include "videowidget.h" |
16 | #include "volumecontrol.h" | 16 | #include "volumecontrol.h" |
17 | 17 | ||
18 | #include "mediaplayerstate.h" | 18 | #include "mediaplayerstate.h" |
19 | 19 | ||
20 | // for setBacklight() | 20 | // for setBacklight() |
21 | #include <linux/fb.h> | 21 | #include <linux/fb.h> |
22 | #include <sys/file.h> | 22 | #include <sys/file.h> |
23 | #include <sys/ioctl.h> | 23 | #include <sys/ioctl.h> |
24 | 24 | ||
25 | 25 | ||
26 | extern AudioWidget *audioUI; | 26 | extern AudioWidget *audioUI; |
27 | extern VideoWidget *videoUI; | 27 | extern VideoWidget *videoUI; |
28 | extern PlayListWidget *playList; | 28 | extern PlayListWidget *playList; |
29 | extern MediaPlayerState *mediaPlayerState; | 29 | extern MediaPlayerState *mediaPlayerState; |
30 | 30 | ||
31 | 31 | ||
32 | #define FBIOBLANK 0x4611 | 32 | #define FBIOBLANK 0x4611 |
33 | 33 | ||
34 | MediaPlayer::MediaPlayer( QObject *parent, const char *name ) | 34 | MediaPlayer::MediaPlayer( QObject *parent, const char *name ) |
35 | : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { | 35 | : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { |
36 | 36 | ||
37 | playList->setCaption(tr("OpiePlayer: Initializating")); | 37 | playList->setCaption(tr("OpiePlayer: Initializating")); |
38 | 38 | ||
39 | qApp->processEvents(); | 39 | qApp->processEvents(); |
40 | // QPEApplication::grabKeyboard(); // EVIL | 40 | // QPEApplication::grabKeyboard(); // EVIL |
41 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 41 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
42 | 42 | ||
43 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); | 43 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); |
44 | 44 | ||
45 | connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); | 45 | connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); |
46 | 46 | ||
47 | connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); | 47 | connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); |
48 | connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); | 48 | connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); |
49 | connect( mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) ); | 49 | connect( mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) ); |
50 | 50 | ||
51 | connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); | 51 | connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); |
52 | connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); | 52 | connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); |
53 | connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); | 53 | connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); |
54 | connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); | 54 | connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); |
55 | 55 | ||
56 | connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); | 56 | connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); |
57 | connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); | 57 | connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); |
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 | unsigned int v= 0; | 186 | unsigned int v= 0; |
187 | v = volControl->volume(); | 187 | v = volControl->volume(); |
188 | v = v / 10; | 188 | v = v / 10; |
189 | 189 | ||
190 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { | 190 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { |
191 | return; | 191 | return; |
192 | } | 192 | } |
193 | 193 | ||
194 | int w=0; int h=0; | 194 | int w=0; int h=0; |
195 | if( !xineControl->hasVideo()) { | 195 | if( !xineControl->hasVideo()) { |
196 | w = audioUI->width(); | 196 | w = audioUI->width(); |
197 | h = audioUI->height(); | 197 | h = audioUI->height(); |
198 | 198 | ||
199 | if ( drawnOnScreenDisplay ) { | 199 | if ( drawnOnScreenDisplay ) { |
200 | if ( onScreenDisplayVolume > v ) { | 200 | if ( onScreenDisplayVolume > v ) { |
201 | audioUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE ); | 201 | audioUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE ); |
202 | } | 202 | } |
203 | } | 203 | } |
204 | drawnOnScreenDisplay = TRUE; | 204 | drawnOnScreenDisplay = TRUE; |
205 | onScreenDisplayVolume = v; | 205 | onScreenDisplayVolume = v; |
206 | QPainter p( audioUI ); | 206 | QPainter p( audioUI ); |
207 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); | 207 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); |
208 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); | 208 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); |
209 | 209 | ||
210 | QFont f; | 210 | QFont f; |
211 | f.setPixelSize( 20 ); | 211 | f.setPixelSize( 20 ); |
212 | f.setBold( TRUE ); | 212 | f.setBold( TRUE ); |
213 | p.setFont( f ); | 213 | p.setFont( f ); |
214 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); | 214 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); |
215 | 215 | ||
216 | for ( unsigned int i = 0; i < 10; i++ ) { | 216 | for ( unsigned int i = 0; i < 10; i++ ) { |
217 | if ( v > i ) { | 217 | if ( v > i ) { |
218 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); | 218 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); |
219 | } else { | 219 | } else { |
220 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); | 220 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); |
221 | } | 221 | } |
222 | } | 222 | } |
223 | } else { | 223 | } else { |
224 | w = videoUI->width(); | 224 | w = videoUI->width(); |
225 | h = videoUI->height(); | 225 | h = videoUI->height(); |
226 | 226 | ||
227 | if ( drawnOnScreenDisplay ) { | 227 | if ( drawnOnScreenDisplay ) { |
228 | if ( onScreenDisplayVolume > v ) { | 228 | if ( onScreenDisplayVolume > v ) { |
229 | videoUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE ); | 229 | videoUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE ); |
230 | } | 230 | } |
231 | } | 231 | } |
232 | drawnOnScreenDisplay = TRUE; | 232 | drawnOnScreenDisplay = TRUE; |
233 | onScreenDisplayVolume = v; | 233 | onScreenDisplayVolume = v; |
234 | QPainter p( videoUI ); | 234 | QPainter p( videoUI ); |
235 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); | 235 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); |
236 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); | 236 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); |
237 | 237 | ||
238 | QFont f; | 238 | QFont f; |
239 | f.setPixelSize( 20 ); | 239 | f.setPixelSize( 20 ); |
240 | f.setBold( TRUE ); | 240 | f.setBold( TRUE ); |
241 | p.setFont( f ); | 241 | p.setFont( f ); |
242 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); | 242 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); |
243 | 243 | ||
244 | for ( unsigned int i = 0; i < 10; i++ ) { | 244 | for ( unsigned int i = 0; i < 10; i++ ) { |
245 | if ( v > i ) { | 245 | if ( v > i ) { |
246 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); | 246 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); |
247 | } else { | 247 | } else { |
248 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); | 248 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); |
249 | } | 249 | } |
250 | } | 250 | } |
251 | } | 251 | } |
252 | } | 252 | } |
253 | 253 | ||
254 | 254 | ||
255 | void MediaPlayer::blank( bool b ) { | 255 | void MediaPlayer::blank( bool b ) { |
256 | fd=open("/dev/fb0",O_RDWR); | 256 | fd=open("/dev/fb0",O_RDWR); |
257 | if (fd != -1) { | 257 | if (fd != -1) { |
258 | if ( b ) { | 258 | if ( b ) { |
259 | qDebug("do blanking"); | 259 | qDebug("do blanking"); |
260 | ioctl( fd, FBIOBLANK, 3 ); | 260 | ioctl( fd, FBIOBLANK, 3 ); |
261 | isBlanked = TRUE; | 261 | isBlanked = TRUE; |
262 | } else { | 262 | } else { |
263 | qDebug("do unblanking"); | 263 | qDebug("do unblanking"); |
264 | ioctl( fd, FBIOBLANK, 0); | 264 | ioctl( fd, FBIOBLANK, 0); |
265 | isBlanked = FALSE; | 265 | isBlanked = FALSE; |
266 | } | 266 | } |
267 | close( fd ); | 267 | close( fd ); |
268 | } else { | 268 | } else { |
269 | qDebug("<< /dev/fb0 could not be opened >>"); | 269 | qDebug("<< /dev/fb0 could not be opened >>"); |
270 | } | 270 | } |
271 | } | 271 | } |
272 | 272 | ||
273 | void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { | 273 | void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { |
274 | switch ( e->key() ) { | 274 | switch ( e->key() ) { |
275 | ////////////////////////////// Zaurus keys | 275 | ////////////////////////////// Zaurus keys |
276 | case Key_Home: | 276 | case Key_Home: |
277 | break; | 277 | break; |
278 | case Key_F9: //activity | 278 | case Key_F9: //activity |
279 | break; | 279 | break; |
280 | case Key_F10: //contacts | 280 | case Key_F10: //contacts |
281 | break; | 281 | break; |
282 | case Key_F11: //menu | 282 | case Key_F11: //menu |
283 | break; | 283 | break; |
284 | case Key_F12: //home | 284 | case Key_F12: //home |
285 | qDebug("Blank here"); | 285 | qDebug("Blank here"); |
286 | // mediaPlayerState->toggleBlank(); | 286 | // mediaPlayerState->toggleBlank(); |
287 | break; | 287 | break; |
288 | case Key_F13: //mail | 288 | case Key_F13: //mail |
289 | qDebug("Blank here"); | 289 | qDebug("Blank here"); |
290 | // mediaPlayerState->toggleBlank(); | 290 | // mediaPlayerState->toggleBlank(); |
291 | break; | 291 | break; |
292 | } | 292 | } |
293 | } | 293 | } |
294 | 294 | ||
295 | void MediaPlayer::cleanUp() {// this happens on closing | 295 | void MediaPlayer::cleanUp() {// this happens on closing |
296 | Config cfg( "OpiePlayer" ); | ||
297 | playList->writeConfig( cfg ); | ||
296 | 298 | ||
297 | // QPEApplication::grabKeyboard(); | 299 | // QPEApplication::grabKeyboard(); |
298 | // QPEApplication::ungrabKeyboard(); | 300 | // QPEApplication::ungrabKeyboard(); |
299 | } | 301 | } |
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 404e1fe..bc9b166 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -1,1250 +1,1247 @@ | |||
1 | 1 | ||
2 | #define QTOPIA_INTERNAL_FSLP | 2 | #define QTOPIA_INTERNAL_FSLP |
3 | #include <qpe/qpemenubar.h> | 3 | #include <qpe/qpemenubar.h> |
4 | #include <qpe/qpetoolbar.h> | 4 | #include <qpe/qpetoolbar.h> |
5 | #include <qpe/fileselector.h> | 5 | #include <qpe/fileselector.h> |
6 | #include <qpe/qpeapplication.h> | 6 | #include <qpe/qpeapplication.h> |
7 | #include <qpe/lnkproperties.h> | 7 | #include <qpe/lnkproperties.h> |
8 | #include <qpe/storage.h> | 8 | #include <qpe/storage.h> |
9 | 9 | ||
10 | #include <qpe/applnk.h> | 10 | #include <qpe/applnk.h> |
11 | #include <qpopupmenu.h> | 11 | #include <qpopupmenu.h> |
12 | #include <qpe/config.h> | 12 | #include <qpe/config.h> |
13 | #include <qpe/global.h> | 13 | #include <qpe/global.h> |
14 | #include <qpe/resource.h> | 14 | #include <qpe/resource.h> |
15 | #include <qaction.h> | 15 | #include <qaction.h> |
16 | #include <qcursor.h> | 16 | #include <qcursor.h> |
17 | #include <qimage.h> | 17 | #include <qimage.h> |
18 | #include <qfile.h> | 18 | #include <qfile.h> |
19 | #include <qdir.h> | 19 | #include <qdir.h> |
20 | #include <qlayout.h> | 20 | #include <qlayout.h> |
21 | #include <qlabel.h> | 21 | #include <qlabel.h> |
22 | #include <qlist.h> | 22 | #include <qlist.h> |
23 | #include <qlistbox.h> | 23 | #include <qlistbox.h> |
24 | #include <qmainwindow.h> | 24 | #include <qmainwindow.h> |
25 | #include <qmessagebox.h> | 25 | #include <qmessagebox.h> |
26 | #include <qtoolbutton.h> | 26 | #include <qtoolbutton.h> |
27 | #include <qtabwidget.h> | 27 | #include <qtabwidget.h> |
28 | #include <qlistview.h> | 28 | #include <qlistview.h> |
29 | #include <qpoint.h> | 29 | #include <qpoint.h> |
30 | #include <qlineedit.h> | 30 | #include <qlineedit.h> |
31 | #include <qpushbutton.h> | 31 | #include <qpushbutton.h> |
32 | #include <qregexp.h> | 32 | #include <qregexp.h> |
33 | #include <qtextstream.h> | 33 | #include <qtextstream.h> |
34 | 34 | ||
35 | 35 | ||
36 | #include "playlistselection.h" | 36 | #include "playlistselection.h" |
37 | #include "playlistwidget.h" | 37 | #include "playlistwidget.h" |
38 | #include "mediaplayerstate.h" | 38 | #include "mediaplayerstate.h" |
39 | 39 | ||
40 | #include "inputDialog.h" | 40 | #include "inputDialog.h" |
41 | 41 | ||
42 | #include <stdlib.h> | 42 | #include <stdlib.h> |
43 | #include "audiowidget.h" | 43 | #include "audiowidget.h" |
44 | #include "videowidget.h" | 44 | #include "videowidget.h" |
45 | 45 | ||
46 | #define BUTTONS_ON_TOOLBAR | 46 | #define BUTTONS_ON_TOOLBAR |
47 | #define SIDE_BUTTONS | 47 | #define SIDE_BUTTONS |
48 | #define CAN_SAVE_LOAD_PLAYLISTS | 48 | #define CAN_SAVE_LOAD_PLAYLISTS |
49 | 49 | ||
50 | extern MediaPlayerState *mediaPlayerState; | 50 | extern MediaPlayerState *mediaPlayerState; |
51 | 51 | ||
52 | 52 | ||
53 | class PlayListWidgetPrivate { | 53 | class PlayListWidgetPrivate { |
54 | public: | 54 | public: |
55 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; | 55 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; |
56 | QFrame *playListFrame; | 56 | QFrame *playListFrame; |
57 | FileSelector *files; | 57 | FileSelector *files; |
58 | PlayListSelection *selectedFiles; | 58 | PlayListSelection *selectedFiles; |
59 | bool setDocumentUsed; | 59 | bool setDocumentUsed; |
60 | DocLnk *current; | 60 | DocLnk *current; |
61 | }; | 61 | }; |
62 | 62 | ||
63 | 63 | ||
64 | class ToolButton : public QToolButton { | 64 | class ToolButton : public QToolButton { |
65 | public: | 65 | public: |
66 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) | 66 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) |
67 | : QToolButton( parent, name ) { | 67 | : QToolButton( parent, name ) { |
68 | setTextLabel( name ); | 68 | setTextLabel( name ); |
69 | setPixmap( Resource::loadPixmap( icon ) ); | 69 | setPixmap( Resource::loadPixmap( icon ) ); |
70 | setAutoRaise( TRUE ); | 70 | setAutoRaise( TRUE ); |
71 | setFocusPolicy( QWidget::NoFocus ); | 71 | setFocusPolicy( QWidget::NoFocus ); |
72 | setToggleButton( t ); | 72 | setToggleButton( t ); |
73 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); | 73 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); |
74 | QPEMenuToolFocusManager::manager()->addWidget( this ); | 74 | QPEMenuToolFocusManager::manager()->addWidget( this ); |
75 | } | 75 | } |
76 | }; | 76 | }; |
77 | 77 | ||
78 | 78 | ||
79 | class MenuItem : public QAction { | 79 | class MenuItem : public QAction { |
80 | public: | 80 | public: |
81 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) | 81 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) |
82 | : QAction( text, QString::null, 0, 0 ) { | 82 | : QAction( text, QString::null, 0, 0 ) { |
83 | connect( this, SIGNAL( activated() ), handler, slot ); | 83 | connect( this, SIGNAL( activated() ), handler, slot ); |
84 | addTo( parent ); | 84 | addTo( parent ); |
85 | } | 85 | } |
86 | }; | 86 | }; |
87 | 87 | ||
88 | 88 | ||
89 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | 89 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) |
90 | : QMainWindow( parent, name, fl ) { | 90 | : QMainWindow( parent, name, fl ) { |
91 | 91 | ||
92 | d = new PlayListWidgetPrivate; | 92 | d = new PlayListWidgetPrivate; |
93 | d->setDocumentUsed = FALSE; | 93 | d->setDocumentUsed = FALSE; |
94 | d->current = NULL; | 94 | d->current = NULL; |
95 | fromSetDocument = FALSE; | 95 | fromSetDocument = FALSE; |
96 | insanityBool=FALSE; | 96 | insanityBool=FALSE; |
97 | audioScan = FALSE; | 97 | audioScan = FALSE; |
98 | videoScan = FALSE; | 98 | videoScan = FALSE; |
99 | 99 | ||
100 | setBackgroundMode( PaletteButton ); | 100 | setBackgroundMode( PaletteButton ); |
101 | 101 | ||
102 | // setCaption( tr("OpiePlayer") ); | 102 | // setCaption( tr("OpiePlayer") ); |
103 | // setIcon( Resource::loadPixmap( "opieplayer2/MPEGPlayer" ) ); | 103 | // setIcon( Resource::loadPixmap( "opieplayer2/MPEGPlayer" ) ); |
104 | 104 | ||
105 | setToolBarsMovable( FALSE ); | 105 | setToolBarsMovable( FALSE ); |
106 | 106 | ||
107 | // Create Toolbar | 107 | // Create Toolbar |
108 | QPEToolBar *toolbar = new QPEToolBar( this ); | 108 | QPEToolBar *toolbar = new QPEToolBar( this ); |
109 | toolbar->setHorizontalStretchable( TRUE ); | 109 | toolbar->setHorizontalStretchable( TRUE ); |
110 | 110 | ||
111 | // Create Menubar | 111 | // Create Menubar |
112 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); | 112 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); |
113 | menu->setMargin( 0 ); | 113 | menu->setMargin( 0 ); |
114 | 114 | ||
115 | QPEToolBar *bar = new QPEToolBar( this ); | 115 | QPEToolBar *bar = new QPEToolBar( this ); |
116 | bar->setLabel( tr( "Play Operations" ) ); | 116 | bar->setLabel( tr( "Play Operations" ) ); |
117 | 117 | ||
118 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); | 118 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); |
119 | tbDeletePlaylist->setFlat(TRUE); | 119 | tbDeletePlaylist->setFlat(TRUE); |
120 | tbDeletePlaylist->setFixedSize(20,20); | 120 | tbDeletePlaylist->setFixedSize(20,20); |
121 | 121 | ||
122 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer2/add_to_playlist", | 122 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer2/add_to_playlist", |
123 | this , SLOT(addSelected()) ); | 123 | this , SLOT(addSelected()) ); |
124 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer2/remove_from_playlist", | 124 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer2/remove_from_playlist", |
125 | this , SLOT(removeSelected()) ); | 125 | this , SLOT(removeSelected()) ); |
126 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", | 126 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", |
127 | this , SLOT( btnPlay(bool) ), TRUE ); | 127 | this , SLOT( btnPlay(bool) ), TRUE ); |
128 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", | 128 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", |
129 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); | 129 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); |
130 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer2/loop", | 130 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer2/loop", |
131 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); | 131 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); |
132 | tbDeletePlaylist->hide(); | 132 | tbDeletePlaylist->hide(); |
133 | 133 | ||
134 | QPopupMenu *pmPlayList = new QPopupMenu( this ); | 134 | QPopupMenu *pmPlayList = new QPopupMenu( this ); |
135 | menu->insertItem( tr( "File" ), pmPlayList ); | 135 | menu->insertItem( tr( "File" ), pmPlayList ); |
136 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 136 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
137 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); | 137 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); |
138 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); | 138 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); |
139 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); | 139 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); |
140 | pmPlayList->insertSeparator(-1); | 140 | pmPlayList->insertSeparator(-1); |
141 | (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); | 141 | (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); |
142 | (void)new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) ); | 142 | (void)new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) ); |
143 | pmPlayList->insertSeparator(-1); | 143 | pmPlayList->insertSeparator(-1); |
144 | (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); | 144 | (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); |
145 | pmPlayList->insertSeparator(-1); | 145 | pmPlayList->insertSeparator(-1); |
146 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); | 146 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); |
147 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); | 147 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); |
148 | 148 | ||
149 | pmView = new QPopupMenu( this ); | 149 | pmView = new QPopupMenu( this ); |
150 | menu->insertItem( tr( "View" ), pmView ); | 150 | menu->insertItem( tr( "View" ), pmView ); |
151 | pmView->isCheckable(); | 151 | pmView->isCheckable(); |
152 | 152 | ||
153 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), mediaPlayerState, SLOT( toggleFullscreen() ) ); | 153 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), mediaPlayerState, SLOT( toggleFullscreen() ) ); |
154 | 154 | ||
155 | Config cfg( "OpiePlayer" ); | 155 | Config cfg( "OpiePlayer" ); |
156 | bool b= cfg.readBoolEntry("FullScreen", 0); | 156 | bool b= cfg.readBoolEntry("FullScreen", 0); |
157 | mediaPlayerState->setFullscreen( b ); | 157 | mediaPlayerState->setFullscreen( b ); |
158 | pmView->setItemChecked( -16, b ); | 158 | pmView->setItemChecked( -16, b ); |
159 | 159 | ||
160 | // pmView->insertItem( Resource::loadPixmap("opieplayer/scale") , tr( "Scale"), mediaPlayerState, SLOT(toggleScaled() ) ); | 160 | // pmView->insertItem( Resource::loadPixmap("opieplayer/scale") , tr( "Scale"), mediaPlayerState, SLOT(toggleScaled() ) ); |
161 | 161 | ||
162 | pmView->insertSeparator(-1); | 162 | pmView->insertSeparator(-1); |
163 | 163 | ||
164 | skinsMenu = new QPopupMenu( this ); | 164 | skinsMenu = new QPopupMenu( this ); |
165 | pmView->insertItem( tr( "Skins" ), skinsMenu ); | 165 | pmView->insertItem( tr( "Skins" ), skinsMenu ); |
166 | skinsMenu->isCheckable(); | 166 | skinsMenu->isCheckable(); |
167 | populateSkinsMenu(); | 167 | populateSkinsMenu(); |
168 | 168 | ||
169 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); | 169 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); |
170 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); | 170 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); |
171 | 171 | ||
172 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); | 172 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); |
173 | 173 | ||
174 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | 174 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); |
175 | // tabWidget->setTabShape(QTabWidget::Triangular); | 175 | // tabWidget->setTabShape(QTabWidget::Triangular); |
176 | 176 | ||
177 | QWidget *pTab; | 177 | QWidget *pTab; |
178 | pTab = new QWidget( tabWidget, "pTab" ); | 178 | pTab = new QWidget( tabWidget, "pTab" ); |
179 | tabWidget->insertTab( pTab,"Playlist"); | 179 | tabWidget->insertTab( pTab,"Playlist"); |
180 | 180 | ||
181 | 181 | ||
182 | QGridLayout *Playout = new QGridLayout( pTab ); | 182 | QGridLayout *Playout = new QGridLayout( pTab ); |
183 | Playout->setSpacing( 2); | 183 | Playout->setSpacing( 2); |
184 | Playout->setMargin( 2); | 184 | Playout->setMargin( 2); |
185 | 185 | ||
186 | // Add the playlist area | 186 | // Add the playlist area |
187 | 187 | ||
188 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); | 188 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); |
189 | d->playListFrame = vbox3; | 189 | d->playListFrame = vbox3; |
190 | 190 | ||
191 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); | 191 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); |
192 | 192 | ||
193 | d->selectedFiles = new PlayListSelection( hbox2); | 193 | d->selectedFiles = new PlayListSelection( hbox2); |
194 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); | 194 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); |
195 | 195 | ||
196 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); | 196 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); |
197 | 197 | ||
198 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch | 198 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch |
199 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", d->selectedFiles, SLOT(moveSelectedUp()) ); | 199 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", d->selectedFiles, SLOT(moveSelectedUp()) ); |
200 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", d->selectedFiles, SLOT(removeSelected()) ); | 200 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", d->selectedFiles, SLOT(removeSelected()) ); |
201 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", d->selectedFiles, SLOT(moveSelectedDown()) ); | 201 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", d->selectedFiles, SLOT(moveSelectedDown()) ); |
202 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch | 202 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch |
203 | 203 | ||
204 | 204 | ||
205 | Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 ); | 205 | Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 ); |
206 | 206 | ||
207 | QWidget *aTab; | 207 | QWidget *aTab; |
208 | aTab = new QWidget( tabWidget, "aTab" ); | 208 | aTab = new QWidget( tabWidget, "aTab" ); |
209 | 209 | ||
210 | QGridLayout *Alayout = new QGridLayout( aTab ); | 210 | QGridLayout *Alayout = new QGridLayout( aTab ); |
211 | Alayout->setSpacing( 2); | 211 | Alayout->setSpacing( 2); |
212 | Alayout->setMargin( 2); | 212 | Alayout->setMargin( 2); |
213 | 213 | ||
214 | audioView = new QListView( aTab, "Audioview" ); | 214 | audioView = new QListView( aTab, "Audioview" ); |
215 | audioView->addColumn( tr("Title"),140); | 215 | audioView->addColumn( tr("Title"),140); |
216 | audioView->addColumn(tr("Size"), -1); | 216 | audioView->addColumn(tr("Size"), -1); |
217 | audioView->addColumn(tr("Media"),-1); | 217 | audioView->addColumn(tr("Media"),-1); |
218 | audioView->setColumnAlignment(1, Qt::AlignRight); | 218 | audioView->setColumnAlignment(1, Qt::AlignRight); |
219 | audioView->setColumnAlignment(2, Qt::AlignRight); | 219 | audioView->setColumnAlignment(2, Qt::AlignRight); |
220 | audioView->setAllColumnsShowFocus(TRUE); | 220 | audioView->setAllColumnsShowFocus(TRUE); |
221 | audioView->setSorting(0,TRUE); | 221 | audioView->setSorting(0,TRUE); |
222 | 222 | ||
223 | audioView->setMultiSelection( TRUE ); | 223 | audioView->setMultiSelection( TRUE ); |
224 | audioView->setSelectionMode( QListView::Extended); | 224 | audioView->setSelectionMode( QListView::Extended); |
225 | 225 | ||
226 | Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 ); | 226 | Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 ); |
227 | 227 | ||
228 | tabWidget->insertTab(aTab,tr("Audio")); | 228 | tabWidget->insertTab(aTab,tr("Audio")); |
229 | 229 | ||
230 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); | 230 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); |
231 | 231 | ||
232 | QWidget *vTab; | 232 | QWidget *vTab; |
233 | vTab = new QWidget( tabWidget, "vTab" ); | 233 | vTab = new QWidget( tabWidget, "vTab" ); |
234 | 234 | ||
235 | QGridLayout *Vlayout = new QGridLayout( vTab ); | 235 | QGridLayout *Vlayout = new QGridLayout( vTab ); |
236 | Vlayout->setSpacing( 2); | 236 | Vlayout->setSpacing( 2); |
237 | Vlayout->setMargin( 2); | 237 | Vlayout->setMargin( 2); |
238 | 238 | ||
239 | videoView = new QListView( vTab, "Videoview" ); | 239 | videoView = new QListView( vTab, "Videoview" ); |
240 | 240 | ||
241 | videoView->addColumn(tr("Title"),140); | 241 | videoView->addColumn(tr("Title"),140); |
242 | videoView->addColumn(tr("Size"),-1); | 242 | videoView->addColumn(tr("Size"),-1); |
243 | videoView->addColumn(tr("Media"),-1); | 243 | videoView->addColumn(tr("Media"),-1); |
244 | videoView->setColumnAlignment(1, Qt::AlignRight); | 244 | videoView->setColumnAlignment(1, Qt::AlignRight); |
245 | videoView->setColumnAlignment(2, Qt::AlignRight); | 245 | videoView->setColumnAlignment(2, Qt::AlignRight); |
246 | videoView->setAllColumnsShowFocus(TRUE); | 246 | videoView->setAllColumnsShowFocus(TRUE); |
247 | videoView->setSorting(0,TRUE); | 247 | videoView->setSorting(0,TRUE); |
248 | 248 | ||
249 | videoView->setMultiSelection( TRUE ); | 249 | videoView->setMultiSelection( TRUE ); |
250 | videoView->setSelectionMode( QListView::Extended); | 250 | videoView->setSelectionMode( QListView::Extended); |
251 | 251 | ||
252 | Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 ); | 252 | Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 ); |
253 | 253 | ||
254 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); | 254 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); |
255 | 255 | ||
256 | tabWidget->insertTab( vTab,tr("Video")); | 256 | tabWidget->insertTab( vTab,tr("Video")); |
257 | 257 | ||
258 | //playlists list | 258 | //playlists list |
259 | QWidget *LTab; | 259 | QWidget *LTab; |
260 | LTab = new QWidget( tabWidget, "LTab" ); | 260 | LTab = new QWidget( tabWidget, "LTab" ); |
261 | QGridLayout *Llayout = new QGridLayout( LTab ); | 261 | QGridLayout *Llayout = new QGridLayout( LTab ); |
262 | Llayout->setSpacing( 2); | 262 | Llayout->setSpacing( 2); |
263 | Llayout->setMargin( 2); | 263 | Llayout->setMargin( 2); |
264 | 264 | ||
265 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy | 265 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy |
266 | Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 ); | 266 | Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 ); |
267 | 267 | ||
268 | tabWidget->insertTab(LTab,tr("Lists")); | 268 | tabWidget->insertTab(LTab,tr("Lists")); |
269 | 269 | ||
270 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); | 270 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); |
271 | 271 | ||
272 | connect( pmView, SIGNAL( activated(int)), this, SLOT( pmViewActivated(int) ) ); | 272 | connect( pmView, SIGNAL( activated(int)), this, SLOT( pmViewActivated(int) ) ); |
273 | 273 | ||
274 | connect( skinsMenu, SIGNAL( activated(int)), this, SLOT(skinsMenuActivated(int) ) ); | 274 | connect( skinsMenu, SIGNAL( activated(int)), this, SLOT(skinsMenuActivated(int) ) ); |
275 | 275 | ||
276 | // connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled() ) ); | 276 | // connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled() ) ); |
277 | 277 | ||
278 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 278 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
279 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); | 279 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); |
280 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 280 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
281 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 281 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
282 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), | 282 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), |
283 | this,SLOT( playIt( QListViewItem *)) ); | 283 | this,SLOT( playIt( QListViewItem *)) ); |
284 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 284 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
285 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 285 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
286 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 286 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
287 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), | 287 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), |
288 | this,SLOT( playIt( QListViewItem *)) ); | 288 | this,SLOT( playIt( QListViewItem *)) ); |
289 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 289 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
290 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); | 290 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); |
291 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); | 291 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); |
292 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | 292 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); |
293 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); | 293 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); |
294 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | 294 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); |
295 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); | 295 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); |
296 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | 296 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); |
297 | 297 | ||
298 | setCentralWidget( vbox5 ); | 298 | setCentralWidget( vbox5 ); |
299 | 299 | ||
300 | readConfig( cfg ); | 300 | readConfig( cfg ); |
301 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 301 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
302 | loadList(DocLnk( currentPlaylist)); | 302 | loadList(DocLnk( currentPlaylist)); |
303 | setCaption(tr("OpiePlayer: ")+ currentPlaylist ); | 303 | setCaption(tr("OpiePlayer: ")+ currentPlaylist ); |
304 | 304 | ||
305 | initializeStates(); | 305 | initializeStates(); |
306 | } | 306 | } |
307 | 307 | ||
308 | 308 | ||
309 | PlayListWidget::~PlayListWidget() { | 309 | PlayListWidget::~PlayListWidget() { |
310 | Config cfg( "OpiePlayer" ); | ||
311 | writeConfig( cfg ); | ||
312 | |||
313 | if ( d->current ) { | 310 | if ( d->current ) { |
314 | delete d->current; | 311 | delete d->current; |
315 | } | 312 | } |
316 | delete d; | 313 | delete d; |
317 | } | 314 | } |
318 | 315 | ||
319 | 316 | ||
320 | void PlayListWidget::initializeStates() { | 317 | void PlayListWidget::initializeStates() { |
321 | 318 | ||
322 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 319 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
323 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 320 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
324 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 321 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
325 | setPlaylist( true); | 322 | setPlaylist( true); |
326 | } | 323 | } |
327 | 324 | ||
328 | 325 | ||
329 | void PlayListWidget::readConfig( Config& cfg ) { | 326 | void PlayListWidget::readConfig( Config& cfg ) { |
330 | cfg.setGroup("PlayList"); | 327 | cfg.setGroup("PlayList"); |
331 | QString currentString = cfg.readEntry("current", "" ); | 328 | QString currentString = cfg.readEntry("current", "" ); |
332 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 329 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
333 | for ( int i = 0; i < noOfFiles; i++ ) { | 330 | for ( int i = 0; i < noOfFiles; i++ ) { |
334 | QString entryName; | 331 | QString entryName; |
335 | entryName.sprintf( "File%i", i + 1 ); | 332 | entryName.sprintf( "File%i", i + 1 ); |
336 | QString linkFile = cfg.readEntry( entryName ); | 333 | QString linkFile = cfg.readEntry( entryName ); |
337 | if(QFileInfo( linkFile).exists() ) { | 334 | if(QFileInfo( linkFile).exists() ) { |
338 | DocLnk lnk( linkFile ); | 335 | DocLnk lnk( linkFile ); |
339 | if ( QFileInfo( lnk.file()).exists() || linkFile.find("http",0,TRUE) != -1) { | 336 | if ( QFileInfo( lnk.file()).exists() || linkFile.find("http",0,TRUE) != -1) { |
340 | d->selectedFiles->addToSelection( lnk ); | 337 | d->selectedFiles->addToSelection( lnk ); |
341 | } | 338 | } |
342 | } | 339 | } |
343 | } | 340 | } |
344 | d->selectedFiles->setSelectedItem( currentString); | 341 | d->selectedFiles->setSelectedItem( currentString); |
345 | } | 342 | } |
346 | 343 | ||
347 | 344 | ||
348 | void PlayListWidget::writeConfig( Config& cfg ) const { | 345 | void PlayListWidget::writeConfig( Config& cfg ) const { |
349 | 346 | ||
350 | d->selectedFiles->writeCurrent( cfg); | 347 | d->selectedFiles->writeCurrent( cfg); |
351 | cfg.setGroup("PlayList"); | 348 | cfg.setGroup("PlayList"); |
352 | int noOfFiles = 0; | 349 | int noOfFiles = 0; |
353 | d->selectedFiles->first(); | 350 | d->selectedFiles->first(); |
354 | do { | 351 | do { |
355 | const DocLnk *lnk = d->selectedFiles->current(); | 352 | const DocLnk *lnk = d->selectedFiles->current(); |
356 | if ( lnk ) { | 353 | if ( lnk ) { |
357 | QString entryName; | 354 | QString entryName; |
358 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 355 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
359 | cfg.writeEntry( entryName, lnk->linkFile() ); | 356 | cfg.writeEntry( entryName, lnk->linkFile() ); |
360 | // if this link does exist, add it so we have the file | 357 | // if this link does exist, add it so we have the file |
361 | // next time... | 358 | // next time... |
362 | if ( !QFile::exists( lnk->linkFile() ) ) { | 359 | if ( !QFile::exists( lnk->linkFile() ) ) { |
363 | // the way writing lnks doesn't really check for out | 360 | // the way writing lnks doesn't really check for out |
364 | // of disk space, but check it anyway. | 361 | // of disk space, but check it anyway. |
365 | if ( !lnk->writeLink() ) { | 362 | if ( !lnk->writeLink() ) { |
366 | QMessageBox::critical( 0, tr("Out of space"), | 363 | QMessageBox::critical( 0, tr("Out of space"), |
367 | tr( "There was a problem saving " | 364 | tr( "There was a problem saving " |
368 | "the playlist.\n" | 365 | "the playlist.\n" |
369 | "Your playlist " | 366 | "Your playlist " |
370 | "may be missing some entries\n" | 367 | "may be missing some entries\n" |
371 | "the next time you start it." ) | 368 | "the next time you start it." ) |
372 | ); | 369 | ); |
373 | } | 370 | } |
374 | } | 371 | } |
375 | noOfFiles++; | 372 | noOfFiles++; |
376 | } | 373 | } |
377 | } | 374 | } |
378 | while ( d->selectedFiles->next() ); | 375 | while ( d->selectedFiles->next() ); |
379 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 376 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
380 | } | 377 | } |
381 | 378 | ||
382 | 379 | ||
383 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 380 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
384 | d->setDocumentUsed = FALSE; | 381 | d->setDocumentUsed = FALSE; |
385 | if ( mediaPlayerState->playlist() ) { | 382 | if ( mediaPlayerState->playlist() ) { |
386 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) | 383 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) |
387 | d->selectedFiles->addToSelection( lnk ); | 384 | d->selectedFiles->addToSelection( lnk ); |
388 | } | 385 | } |
389 | else | 386 | else |
390 | mediaPlayerState->setPlaying( TRUE ); | 387 | mediaPlayerState->setPlaying( TRUE ); |
391 | } | 388 | } |
392 | 389 | ||
393 | 390 | ||
394 | void PlayListWidget::clearList() { | 391 | void PlayListWidget::clearList() { |
395 | while ( first() ) { | 392 | while ( first() ) { |
396 | d->selectedFiles->removeSelected(); | 393 | d->selectedFiles->removeSelected(); |
397 | } | 394 | } |
398 | } | 395 | } |
399 | 396 | ||
400 | 397 | ||
401 | void PlayListWidget::addAllToList() { | 398 | void PlayListWidget::addAllToList() { |
402 | DocLnkSet filesAll; | 399 | DocLnkSet filesAll; |
403 | Global::findDocuments(&filesAll, "video/*;audio/*"); | 400 | Global::findDocuments(&filesAll, "video/*;audio/*"); |
404 | QListIterator<DocLnk> Adit( filesAll.children() ); | 401 | QListIterator<DocLnk> Adit( filesAll.children() ); |
405 | for ( ; Adit.current(); ++Adit ) { | 402 | for ( ; Adit.current(); ++Adit ) { |
406 | if(QFileInfo(Adit.current()->file()).exists()) { | 403 | if(QFileInfo(Adit.current()->file()).exists()) { |
407 | d->selectedFiles->addToSelection( **Adit ); | 404 | d->selectedFiles->addToSelection( **Adit ); |
408 | } | 405 | } |
409 | } | 406 | } |
410 | } | 407 | } |
411 | 408 | ||
412 | 409 | ||
413 | void PlayListWidget::addAllMusicToList() { | 410 | void PlayListWidget::addAllMusicToList() { |
414 | QListIterator<DocLnk> dit( files.children() ); | 411 | QListIterator<DocLnk> dit( files.children() ); |
415 | for ( ; dit.current(); ++dit ) { | 412 | for ( ; dit.current(); ++dit ) { |
416 | if(QFileInfo(dit.current()->file()).exists()) { | 413 | if(QFileInfo(dit.current()->file()).exists()) { |
417 | d->selectedFiles->addToSelection( **dit ); | 414 | d->selectedFiles->addToSelection( **dit ); |
418 | } | 415 | } |
419 | } | 416 | } |
420 | } | 417 | } |
421 | 418 | ||
422 | 419 | ||
423 | void PlayListWidget::addAllVideoToList() { | 420 | void PlayListWidget::addAllVideoToList() { |
424 | QListIterator<DocLnk> dit( vFiles.children() ); | 421 | QListIterator<DocLnk> dit( vFiles.children() ); |
425 | for ( ; dit.current(); ++dit ) | 422 | for ( ; dit.current(); ++dit ) |
426 | if(QFileInfo( dit.current()->file()).exists()) | 423 | if(QFileInfo( dit.current()->file()).exists()) |
427 | d->selectedFiles->addToSelection( **dit ); | 424 | d->selectedFiles->addToSelection( **dit ); |
428 | } | 425 | } |
429 | 426 | ||
430 | 427 | ||
431 | void PlayListWidget::setDocument(const QString& fileref) { | 428 | void PlayListWidget::setDocument(const QString& fileref) { |
432 | qDebug(fileref); | 429 | qDebug(fileref); |
433 | fromSetDocument = TRUE; | 430 | fromSetDocument = TRUE; |
434 | if ( fileref.isNull() ) { | 431 | if ( fileref.isNull() ) { |
435 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); | 432 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); |
436 | return; | 433 | return; |
437 | } | 434 | } |
438 | 435 | ||
439 | if(fileref.find("m3u",0,TRUE) != -1) { //is m3u | 436 | if(fileref.find("m3u",0,TRUE) != -1) { //is m3u |
440 | readm3u( fileref); | 437 | readm3u( fileref); |
441 | } else if(fileref.find("pls",0,TRUE) != -1) { //is pls | 438 | } else if(fileref.find("pls",0,TRUE) != -1) { //is pls |
442 | readPls( fileref); | 439 | readPls( fileref); |
443 | } else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist | 440 | } else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist |
444 | clearList(); | 441 | clearList(); |
445 | loadList(DocLnk(fileref)); | 442 | loadList(DocLnk(fileref)); |
446 | d->selectedFiles->first(); | 443 | d->selectedFiles->first(); |
447 | } else { | 444 | } else { |
448 | clearList(); | 445 | clearList(); |
449 | addToSelection( DocLnk( fileref ) ); | 446 | addToSelection( DocLnk( fileref ) ); |
450 | d->setDocumentUsed = TRUE; | 447 | d->setDocumentUsed = TRUE; |
451 | mediaPlayerState->setPlaying( FALSE ); | 448 | mediaPlayerState->setPlaying( FALSE ); |
452 | qApp->processEvents(); | 449 | qApp->processEvents(); |
453 | mediaPlayerState->setPlaying( TRUE ); | 450 | mediaPlayerState->setPlaying( TRUE ); |
454 | qApp->processEvents(); | 451 | qApp->processEvents(); |
455 | setCaption(tr("OpiePlayer")); | 452 | setCaption(tr("OpiePlayer")); |
456 | } | 453 | } |
457 | } | 454 | } |
458 | 455 | ||
459 | 456 | ||
460 | void PlayListWidget::setActiveWindow() { | 457 | void PlayListWidget::setActiveWindow() { |
461 | // qDebug("SETTING active window"); | 458 | // qDebug("SETTING active window"); |
462 | // When we get raised we need to ensure that it switches views | 459 | // When we get raised we need to ensure that it switches views |
463 | char origView = mediaPlayerState->view(); | 460 | char origView = mediaPlayerState->view(); |
464 | mediaPlayerState->setView( 'l' ); // invalidate | 461 | mediaPlayerState->setView( 'l' ); // invalidate |
465 | mediaPlayerState->setView( origView ); // now switch back | 462 | mediaPlayerState->setView( origView ); // now switch back |
466 | } | 463 | } |
467 | 464 | ||
468 | 465 | ||
469 | void PlayListWidget::useSelectedDocument() { | 466 | void PlayListWidget::useSelectedDocument() { |
470 | d->setDocumentUsed = FALSE; | 467 | d->setDocumentUsed = FALSE; |
471 | } | 468 | } |
472 | 469 | ||
473 | 470 | ||
474 | const DocLnk *PlayListWidget::current() { // this is fugly | 471 | const DocLnk *PlayListWidget::current() { // this is fugly |
475 | 472 | ||
476 | switch (tabWidget->currentPageIndex()) { | 473 | switch (tabWidget->currentPageIndex()) { |
477 | case 0: //playlist | 474 | case 0: //playlist |
478 | { | 475 | { |
479 | // qDebug("playlist"); | 476 | // qDebug("playlist"); |
480 | if ( mediaPlayerState->playlist() ) { | 477 | if ( mediaPlayerState->playlist() ) { |
481 | return d->selectedFiles->current(); | 478 | return d->selectedFiles->current(); |
482 | } else if ( d->setDocumentUsed && d->current ) { | 479 | } else if ( d->setDocumentUsed && d->current ) { |
483 | return d->current; | 480 | return d->current; |
484 | } else { | 481 | } else { |
485 | return d->files->selected(); | 482 | return d->files->selected(); |
486 | } | 483 | } |
487 | } | 484 | } |
488 | break; | 485 | break; |
489 | case 1://audio | 486 | case 1://audio |
490 | { | 487 | { |
491 | // qDebug("audioView"); | 488 | // qDebug("audioView"); |
492 | QListIterator<DocLnk> dit( files.children() ); | 489 | QListIterator<DocLnk> dit( files.children() ); |
493 | for ( ; dit.current(); ++dit ) { | 490 | for ( ; dit.current(); ++dit ) { |
494 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { | 491 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { |
495 | insanityBool=TRUE; | 492 | insanityBool=TRUE; |
496 | return dit; | 493 | return dit; |
497 | } | 494 | } |
498 | } | 495 | } |
499 | } | 496 | } |
500 | break; | 497 | break; |
501 | case 2: // video | 498 | case 2: // video |
502 | { | 499 | { |
503 | // qDebug("videoView"); | 500 | // qDebug("videoView"); |
504 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 501 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
505 | for ( ; Vdit.current(); ++Vdit ) { | 502 | for ( ; Vdit.current(); ++Vdit ) { |
506 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { | 503 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { |
507 | insanityBool=TRUE; | 504 | insanityBool=TRUE; |
508 | return Vdit; | 505 | return Vdit; |
509 | } | 506 | } |
510 | } | 507 | } |
511 | } | 508 | } |
512 | break; | 509 | break; |
513 | }; | 510 | }; |
514 | return 0; | 511 | return 0; |
515 | } | 512 | } |
516 | 513 | ||
517 | bool PlayListWidget::prev() { | 514 | bool PlayListWidget::prev() { |
518 | if ( mediaPlayerState->playlist() ) { | 515 | if ( mediaPlayerState->playlist() ) { |
519 | if ( mediaPlayerState->shuffled() ) { | 516 | if ( mediaPlayerState->shuffled() ) { |
520 | const DocLnk *cur = current(); | 517 | const DocLnk *cur = current(); |
521 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 518 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
522 | for ( int i = 0; i < j; i++ ) { | 519 | for ( int i = 0; i < j; i++ ) { |
523 | if ( !d->selectedFiles->next() ) | 520 | if ( !d->selectedFiles->next() ) |
524 | d->selectedFiles->first(); | 521 | d->selectedFiles->first(); |
525 | } | 522 | } |
526 | if ( cur == current() ) | 523 | if ( cur == current() ) |
527 | if ( !d->selectedFiles->next() ) | 524 | if ( !d->selectedFiles->next() ) |
528 | d->selectedFiles->first(); | 525 | d->selectedFiles->first(); |
529 | return TRUE; | 526 | return TRUE; |
530 | } else { | 527 | } else { |
531 | if ( !d->selectedFiles->prev() ) { | 528 | if ( !d->selectedFiles->prev() ) { |
532 | if ( mediaPlayerState->looping() ) { | 529 | if ( mediaPlayerState->looping() ) { |
533 | return d->selectedFiles->last(); | 530 | return d->selectedFiles->last(); |
534 | } else { | 531 | } else { |
535 | return FALSE; | 532 | return FALSE; |
536 | } | 533 | } |
537 | } | 534 | } |
538 | return TRUE; | 535 | return TRUE; |
539 | } | 536 | } |
540 | } else { | 537 | } else { |
541 | return mediaPlayerState->looping(); | 538 | return mediaPlayerState->looping(); |
542 | } | 539 | } |
543 | } | 540 | } |
544 | 541 | ||
545 | 542 | ||
546 | bool PlayListWidget::next() { | 543 | bool PlayListWidget::next() { |
547 | if ( mediaPlayerState->playlist() ) { | 544 | if ( mediaPlayerState->playlist() ) { |
548 | if ( mediaPlayerState->shuffled() ) { | 545 | if ( mediaPlayerState->shuffled() ) { |
549 | return prev(); | 546 | return prev(); |
550 | } else { | 547 | } else { |
551 | if ( !d->selectedFiles->next() ) { | 548 | if ( !d->selectedFiles->next() ) { |
552 | if ( mediaPlayerState->looping() ) { | 549 | if ( mediaPlayerState->looping() ) { |
553 | return d->selectedFiles->first(); | 550 | return d->selectedFiles->first(); |
554 | } else { | 551 | } else { |
555 | return FALSE; | 552 | return FALSE; |
556 | } | 553 | } |
557 | } | 554 | } |
558 | return TRUE; | 555 | return TRUE; |
559 | } | 556 | } |
560 | } else { | 557 | } else { |
561 | return mediaPlayerState->looping(); | 558 | return mediaPlayerState->looping(); |
562 | } | 559 | } |
563 | } | 560 | } |
564 | 561 | ||
565 | 562 | ||
566 | bool PlayListWidget::first() { | 563 | bool PlayListWidget::first() { |
567 | if ( mediaPlayerState->playlist() ) | 564 | if ( mediaPlayerState->playlist() ) |
568 | return d->selectedFiles->first(); | 565 | return d->selectedFiles->first(); |
569 | else | 566 | else |
570 | return mediaPlayerState->looping(); | 567 | return mediaPlayerState->looping(); |
571 | } | 568 | } |
572 | 569 | ||
573 | 570 | ||
574 | bool PlayListWidget::last() { | 571 | bool PlayListWidget::last() { |
575 | if ( mediaPlayerState->playlist() ) | 572 | if ( mediaPlayerState->playlist() ) |
576 | return d->selectedFiles->last(); | 573 | return d->selectedFiles->last(); |
577 | else | 574 | else |
578 | return mediaPlayerState->looping(); | 575 | return mediaPlayerState->looping(); |
579 | } | 576 | } |
580 | 577 | ||
581 | 578 | ||
582 | void PlayListWidget::saveList() { | 579 | void PlayListWidget::saveList() { |
583 | 580 | ||
584 | QString filename; | 581 | QString filename; |
585 | InputDialog *fileDlg = 0l; | 582 | InputDialog *fileDlg = 0l; |
586 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); | 583 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); |
587 | fileDlg->exec(); | 584 | fileDlg->exec(); |
588 | if( fileDlg->result() == 1 ) { | 585 | if( fileDlg->result() == 1 ) { |
589 | if ( d->current ) | 586 | if ( d->current ) |
590 | delete d->current; | 587 | delete d->current; |
591 | filename = fileDlg->text();//+".playlist"; | 588 | filename = fileDlg->text();//+".playlist"; |
592 | // qDebug("saving playlist "+filename+".playlist"); | 589 | // qDebug("saving playlist "+filename+".playlist"); |
593 | Config cfg( filename +".playlist"); | 590 | Config cfg( filename +".playlist"); |
594 | writeConfig( cfg ); | 591 | writeConfig( cfg ); |
595 | 592 | ||
596 | DocLnk lnk; | 593 | DocLnk lnk; |
597 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property | 594 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property |
598 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D | 595 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D |
599 | lnk.setIcon("opieplayer2/playlist2"); | 596 | lnk.setIcon("opieplayer2/playlist2"); |
600 | lnk.setName( filename); //sets file name | 597 | lnk.setName( filename); //sets file name |
601 | // qDebug(filename); | 598 | // qDebug(filename); |
602 | if(!lnk.writeLink()) { | 599 | if(!lnk.writeLink()) { |
603 | qDebug("Writing doclink did not work"); | 600 | qDebug("Writing doclink did not work"); |
604 | } | 601 | } |
605 | } | 602 | } |
606 | Config config( "OpiePlayer" ); | 603 | Config config( "OpiePlayer" ); |
607 | config.writeEntry("CurrentPlaylist",filename); | 604 | config.writeEntry("CurrentPlaylist",filename); |
608 | setCaption(tr("OpiePlayer: ")+filename); | 605 | setCaption(tr("OpiePlayer: ")+filename); |
609 | d->selectedFiles->first(); | 606 | d->selectedFiles->first(); |
610 | if(fileDlg) { | 607 | if(fileDlg) { |
611 | delete fileDlg; | 608 | delete fileDlg; |
612 | } | 609 | } |
613 | } | 610 | } |
614 | 611 | ||
615 | void PlayListWidget::loadList( const DocLnk & lnk) { | 612 | void PlayListWidget::loadList( const DocLnk & lnk) { |
616 | QString name= lnk.name(); | 613 | QString name= lnk.name(); |
617 | // qDebug("currentList is "+name); | 614 | // qDebug("currentList is "+name); |
618 | if( name.length()>1) { | 615 | if( name.length()>1) { |
619 | setCaption("OpiePlayer: "+name); | 616 | setCaption("OpiePlayer: "+name); |
620 | // qDebug("load list "+ name+".playlist"); | 617 | // qDebug("load list "+ name+".playlist"); |
621 | clearList(); | 618 | clearList(); |
622 | Config cfg( name+".playlist"); | 619 | Config cfg( name+".playlist"); |
623 | readConfig(cfg); | 620 | readConfig(cfg); |
624 | 621 | ||
625 | tabWidget->setCurrentPage(0); | 622 | tabWidget->setCurrentPage(0); |
626 | 623 | ||
627 | Config config( "OpiePlayer" ); | 624 | Config config( "OpiePlayer" ); |
628 | config.writeEntry("CurrentPlaylist", name); | 625 | config.writeEntry("CurrentPlaylist", name); |
629 | // d->selectedFiles->first(); | 626 | // d->selectedFiles->first(); |
630 | } | 627 | } |
631 | 628 | ||
632 | } | 629 | } |
633 | 630 | ||
634 | void PlayListWidget::setPlaylist( bool shown ) { | 631 | void PlayListWidget::setPlaylist( bool shown ) { |
635 | if ( shown ) { | 632 | if ( shown ) { |
636 | d->playListFrame->show(); | 633 | d->playListFrame->show(); |
637 | } else { | 634 | } else { |
638 | d->playListFrame->hide(); | 635 | d->playListFrame->hide(); |
639 | } | 636 | } |
640 | } | 637 | } |
641 | 638 | ||
642 | void PlayListWidget::setView( char view ) { | 639 | void PlayListWidget::setView( char view ) { |
643 | if ( view == 'l' ) | 640 | if ( view == 'l' ) |
644 | showMaximized(); | 641 | showMaximized(); |
645 | else | 642 | else |
646 | hide(); | 643 | hide(); |
647 | } | 644 | } |
648 | 645 | ||
649 | void PlayListWidget::addSelected() { | 646 | void PlayListWidget::addSelected() { |
650 | 647 | ||
651 | Config cfg( "OpiePlayer" ); | 648 | Config cfg( "OpiePlayer" ); |
652 | cfg.setGroup("PlayList"); | 649 | cfg.setGroup("PlayList"); |
653 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 650 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
654 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 651 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
655 | 652 | ||
656 | switch (tabWidget->currentPageIndex()) { | 653 | switch (tabWidget->currentPageIndex()) { |
657 | case 0: //playlist | 654 | case 0: //playlist |
658 | break; | 655 | break; |
659 | case 1: { //audio | 656 | case 1: { //audio |
660 | QListViewItemIterator it( audioView ); | 657 | QListViewItemIterator it( audioView ); |
661 | // iterate through all items of the listview | 658 | // iterate through all items of the listview |
662 | for ( ; it.current(); ++it ) { | 659 | for ( ; it.current(); ++it ) { |
663 | if ( it.current()->isSelected() ) { | 660 | if ( it.current()->isSelected() ) { |
664 | QListIterator<DocLnk> dit( files.children() ); | 661 | QListIterator<DocLnk> dit( files.children() ); |
665 | for ( ; dit.current(); ++dit ) { | 662 | for ( ; dit.current(); ++dit ) { |
666 | if( dit.current()->name() == it.current()->text(0) ) { | 663 | if( dit.current()->name() == it.current()->text(0) ) { |
667 | if(QFileInfo( dit.current()->file()).exists()) | 664 | if(QFileInfo( dit.current()->file()).exists()) |
668 | d->selectedFiles->addToSelection( **dit ); | 665 | d->selectedFiles->addToSelection( **dit ); |
669 | } | 666 | } |
670 | } | 667 | } |
671 | audioView->setSelected( it.current(),FALSE); | 668 | audioView->setSelected( it.current(),FALSE); |
672 | } | 669 | } |
673 | } | 670 | } |
674 | tabWidget->setCurrentPage(0); | 671 | tabWidget->setCurrentPage(0); |
675 | } | 672 | } |
676 | break; | 673 | break; |
677 | case 2: { // video | 674 | case 2: { // video |
678 | QListViewItemIterator it( videoView ); | 675 | QListViewItemIterator it( videoView ); |
679 | // iterate through all items of the listview | 676 | // iterate through all items of the listview |
680 | for ( ; it.current(); ++it ) { | 677 | for ( ; it.current(); ++it ) { |
681 | if ( it.current()->isSelected() ) { | 678 | if ( it.current()->isSelected() ) { |
682 | QListIterator<DocLnk> dit( vFiles.children() ); | 679 | QListIterator<DocLnk> dit( vFiles.children() ); |
683 | for ( ; dit.current(); ++dit ) { | 680 | for ( ; dit.current(); ++dit ) { |
684 | if( dit.current()->name() == it.current()->text(0) ) { | 681 | if( dit.current()->name() == it.current()->text(0) ) { |
685 | if(QFileInfo( dit.current()->file()).exists()) | 682 | if(QFileInfo( dit.current()->file()).exists()) |
686 | d->selectedFiles->addToSelection( **dit ); | 683 | d->selectedFiles->addToSelection( **dit ); |
687 | } | 684 | } |
688 | } | 685 | } |
689 | videoView->setSelected( it.current(),FALSE); | 686 | videoView->setSelected( it.current(),FALSE); |
690 | } | 687 | } |
691 | } | 688 | } |
692 | tabWidget->setCurrentPage(0); | 689 | tabWidget->setCurrentPage(0); |
693 | } | 690 | } |
694 | break; | 691 | break; |
695 | }; | 692 | }; |
696 | } | 693 | } |
697 | 694 | ||
698 | void PlayListWidget::removeSelected() { | 695 | void PlayListWidget::removeSelected() { |
699 | d->selectedFiles->removeSelected( ); | 696 | d->selectedFiles->removeSelected( ); |
700 | } | 697 | } |
701 | 698 | ||
702 | void PlayListWidget::playIt( QListViewItem *it) { | 699 | void PlayListWidget::playIt( QListViewItem *it) { |
703 | if(!it) return; | 700 | if(!it) return; |
704 | mediaPlayerState->setPlaying(FALSE); | 701 | mediaPlayerState->setPlaying(FALSE); |
705 | mediaPlayerState->setPlaying(TRUE); | 702 | mediaPlayerState->setPlaying(TRUE); |
706 | d->selectedFiles->unSelect(); | 703 | d->selectedFiles->unSelect(); |
707 | } | 704 | } |
708 | 705 | ||
709 | void PlayListWidget::addToSelection( QListViewItem *it) { | 706 | void PlayListWidget::addToSelection( QListViewItem *it) { |
710 | d->setDocumentUsed = FALSE; | 707 | d->setDocumentUsed = FALSE; |
711 | 708 | ||
712 | if(it) { | 709 | if(it) { |
713 | switch (tabWidget->currentPageIndex()) { | 710 | switch (tabWidget->currentPageIndex()) { |
714 | case 1: { | 711 | case 1: { |
715 | QListIterator<DocLnk> dit( files.children() ); | 712 | QListIterator<DocLnk> dit( files.children() ); |
716 | for ( ; dit.current(); ++dit ) { | 713 | for ( ; dit.current(); ++dit ) { |
717 | if( dit.current()->name() == it->text(0)) { | 714 | if( dit.current()->name() == it->text(0)) { |
718 | if(QFileInfo( dit.current()->file()).exists()) | 715 | if(QFileInfo( dit.current()->file()).exists()) |
719 | d->selectedFiles->addToSelection( **dit ); | 716 | d->selectedFiles->addToSelection( **dit ); |
720 | } | 717 | } |
721 | } | 718 | } |
722 | } | 719 | } |
723 | break; | 720 | break; |
724 | case 2: { | 721 | case 2: { |
725 | QListIterator<DocLnk> dit( vFiles.children() ); | 722 | QListIterator<DocLnk> dit( vFiles.children() ); |
726 | for ( ; dit.current(); ++dit ) { | 723 | for ( ; dit.current(); ++dit ) { |
727 | if( dit.current()->name() == it->text(0)) { | 724 | if( dit.current()->name() == it->text(0)) { |
728 | if(QFileInfo( dit.current()->file()).exists()) | 725 | if(QFileInfo( dit.current()->file()).exists()) |
729 | d->selectedFiles->addToSelection( **dit ); | 726 | d->selectedFiles->addToSelection( **dit ); |
730 | } | 727 | } |
731 | } | 728 | } |
732 | } | 729 | } |
733 | break; | 730 | break; |
734 | case 0: | 731 | case 0: |
735 | break; | 732 | break; |
736 | }; | 733 | }; |
737 | tabWidget->setCurrentPage(0); | 734 | tabWidget->setCurrentPage(0); |
738 | } | 735 | } |
739 | } | 736 | } |
740 | 737 | ||
741 | void PlayListWidget::tabChanged(QWidget *) { | 738 | void PlayListWidget::tabChanged(QWidget *) { |
742 | 739 | ||
743 | switch ( tabWidget->currentPageIndex()) { | 740 | switch ( tabWidget->currentPageIndex()) { |
744 | case 0: | 741 | case 0: |
745 | { | 742 | { |
746 | if( !tbDeletePlaylist->isHidden()) | 743 | if( !tbDeletePlaylist->isHidden()) |
747 | tbDeletePlaylist->hide(); | 744 | tbDeletePlaylist->hide(); |
748 | d->tbRemoveFromList->setEnabled(TRUE); | 745 | d->tbRemoveFromList->setEnabled(TRUE); |
749 | d->tbAddToList->setEnabled(FALSE); | 746 | d->tbAddToList->setEnabled(FALSE); |
750 | } | 747 | } |
751 | break; | 748 | break; |
752 | case 1: | 749 | case 1: |
753 | { | 750 | { |
754 | audioView->clear(); | 751 | audioView->clear(); |
755 | populateAudioView(); | 752 | populateAudioView(); |
756 | 753 | ||
757 | if( !tbDeletePlaylist->isHidden()) | 754 | if( !tbDeletePlaylist->isHidden()) |
758 | tbDeletePlaylist->hide(); | 755 | tbDeletePlaylist->hide(); |
759 | d->tbRemoveFromList->setEnabled(FALSE); | 756 | d->tbRemoveFromList->setEnabled(FALSE); |
760 | d->tbAddToList->setEnabled(TRUE); | 757 | d->tbAddToList->setEnabled(TRUE); |
761 | } | 758 | } |
762 | break; | 759 | break; |
763 | case 2: | 760 | case 2: |
764 | { | 761 | { |
765 | videoView->clear(); | 762 | videoView->clear(); |
766 | populateVideoView(); | 763 | populateVideoView(); |
767 | if( !tbDeletePlaylist->isHidden()) | 764 | if( !tbDeletePlaylist->isHidden()) |
768 | tbDeletePlaylist->hide(); | 765 | tbDeletePlaylist->hide(); |
769 | d->tbRemoveFromList->setEnabled(FALSE); | 766 | d->tbRemoveFromList->setEnabled(FALSE); |
770 | d->tbAddToList->setEnabled(TRUE); | 767 | d->tbAddToList->setEnabled(TRUE); |
771 | } | 768 | } |
772 | break; | 769 | break; |
773 | case 3: | 770 | case 3: |
774 | { | 771 | { |
775 | if( tbDeletePlaylist->isHidden()) | 772 | if( tbDeletePlaylist->isHidden()) |
776 | tbDeletePlaylist->show(); | 773 | tbDeletePlaylist->show(); |
777 | playLists->reread(); | 774 | playLists->reread(); |
778 | } | 775 | } |
779 | break; | 776 | break; |
780 | }; | 777 | }; |
781 | } | 778 | } |
782 | 779 | ||
783 | void PlayListWidget::btnPlay(bool b) { | 780 | void PlayListWidget::btnPlay(bool b) { |
784 | 781 | ||
785 | // mediaPlayerState->setPlaying(b); | 782 | // mediaPlayerState->setPlaying(b); |
786 | switch ( tabWidget->currentPageIndex()) { | 783 | switch ( tabWidget->currentPageIndex()) { |
787 | case 0: | 784 | case 0: |
788 | { | 785 | { |
789 | mediaPlayerState->setPlaying(b); | 786 | mediaPlayerState->setPlaying(b); |
790 | } | 787 | } |
791 | break; | 788 | break; |
792 | case 1: | 789 | case 1: |
793 | { | 790 | { |
794 | addToSelection( audioView->currentItem() ); | 791 | addToSelection( audioView->currentItem() ); |
795 | mediaPlayerState->setPlaying(b); | 792 | mediaPlayerState->setPlaying(b); |
796 | d->selectedFiles->removeSelected( ); | 793 | d->selectedFiles->removeSelected( ); |
797 | tabWidget->setCurrentPage(1); | 794 | tabWidget->setCurrentPage(1); |
798 | d->selectedFiles->unSelect(); | 795 | d->selectedFiles->unSelect(); |
799 | insanityBool=FALSE; | 796 | insanityBool=FALSE; |
800 | }// audioView->clearSelection(); | 797 | }// audioView->clearSelection(); |
801 | break; | 798 | break; |
802 | case 2: | 799 | case 2: |
803 | { | 800 | { |
804 | addToSelection( videoView->currentItem() ); | 801 | addToSelection( videoView->currentItem() ); |
805 | mediaPlayerState->setPlaying(b); | 802 | mediaPlayerState->setPlaying(b); |
806 | qApp->processEvents(); | 803 | qApp->processEvents(); |
807 | d->selectedFiles->removeSelected( ); | 804 | d->selectedFiles->removeSelected( ); |
808 | tabWidget->setCurrentPage(2); | 805 | tabWidget->setCurrentPage(2); |
809 | d->selectedFiles->unSelect(); | 806 | d->selectedFiles->unSelect(); |
810 | insanityBool=FALSE; | 807 | insanityBool=FALSE; |
811 | }// videoView->clearSelection(); | 808 | }// videoView->clearSelection(); |
812 | break; | 809 | break; |
813 | }; | 810 | }; |
814 | 811 | ||
815 | } | 812 | } |
816 | 813 | ||
817 | void PlayListWidget::deletePlaylist() { | 814 | void PlayListWidget::deletePlaylist() { |
818 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 815 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
819 | (tr("You really want to delete\nthis playlist?")), | 816 | (tr("You really want to delete\nthis playlist?")), |
820 | (tr("Yes")), (tr("No")), 0 )){ | 817 | (tr("Yes")), (tr("No")), 0 )){ |
821 | case 0: // Yes clicked, | 818 | case 0: // Yes clicked, |
822 | QFile().remove(playLists->selected()->file()); | 819 | QFile().remove(playLists->selected()->file()); |
823 | QFile().remove(playLists->selected()->linkFile()); | 820 | QFile().remove(playLists->selected()->linkFile()); |
824 | playLists->reread(); | 821 | playLists->reread(); |
825 | break; | 822 | break; |
826 | case 1: // Cancel | 823 | case 1: // Cancel |
827 | break; | 824 | break; |
828 | }; | 825 | }; |
829 | } | 826 | } |
830 | 827 | ||
831 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { | 828 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { |
832 | switch (mouse) { | 829 | switch (mouse) { |
833 | case 1: | 830 | case 1: |
834 | break; | 831 | break; |
835 | case 2:{ | 832 | case 2:{ |
836 | QPopupMenu m; | 833 | QPopupMenu m; |
837 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 834 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
838 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 835 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
839 | m.exec( QCursor::pos() ); | 836 | m.exec( QCursor::pos() ); |
840 | } | 837 | } |
841 | break; | 838 | break; |
842 | }; | 839 | }; |
843 | } | 840 | } |
844 | 841 | ||
845 | void PlayListWidget::playSelected() { | 842 | void PlayListWidget::playSelected() { |
846 | btnPlay( TRUE); | 843 | btnPlay( TRUE); |
847 | } | 844 | } |
848 | 845 | ||
849 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 846 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
850 | switch (mouse) { | 847 | switch (mouse) { |
851 | case 1: | 848 | case 1: |
852 | 849 | ||
853 | break; | 850 | break; |
854 | case 2: | 851 | case 2: |
855 | { | 852 | { |
856 | QPopupMenu m; | 853 | QPopupMenu m; |
857 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 854 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
858 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 855 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
859 | m.exec( QCursor::pos() ); | 856 | m.exec( QCursor::pos() ); |
860 | } | 857 | } |
861 | break; | 858 | break; |
862 | }; | 859 | }; |
863 | } | 860 | } |
864 | 861 | ||
865 | 862 | ||
866 | void PlayListWidget::scanForAudio() { | 863 | void PlayListWidget::scanForAudio() { |
867 | // qDebug("scan for audio"); | 864 | // qDebug("scan for audio"); |
868 | files.detachChildren(); | 865 | files.detachChildren(); |
869 | QListIterator<DocLnk> sdit( files.children() ); | 866 | QListIterator<DocLnk> sdit( files.children() ); |
870 | for ( ; sdit.current(); ++sdit ) { | 867 | for ( ; sdit.current(); ++sdit ) { |
871 | delete sdit.current(); | 868 | delete sdit.current(); |
872 | } | 869 | } |
873 | Global::findDocuments(&files, "audio/*"); | 870 | Global::findDocuments(&files, "audio/*"); |
874 | audioScan = TRUE; | 871 | audioScan = TRUE; |
875 | } | 872 | } |
876 | 873 | ||
877 | void PlayListWidget::scanForVideo() { | 874 | void PlayListWidget::scanForVideo() { |
878 | // qDebug("scan for video"); | 875 | // qDebug("scan for video"); |
879 | vFiles.detachChildren(); | 876 | vFiles.detachChildren(); |
880 | QListIterator<DocLnk> sdit( vFiles.children() ); | 877 | QListIterator<DocLnk> sdit( vFiles.children() ); |
881 | for ( ; sdit.current(); ++sdit ) { | 878 | for ( ; sdit.current(); ++sdit ) { |
882 | delete sdit.current(); | 879 | delete sdit.current(); |
883 | } | 880 | } |
884 | Global::findDocuments(&vFiles, "video/*"); | 881 | Global::findDocuments(&vFiles, "video/*"); |
885 | videoScan = TRUE; | 882 | videoScan = TRUE; |
886 | } | 883 | } |
887 | 884 | ||
888 | void PlayListWidget::populateAudioView() { | 885 | void PlayListWidget::populateAudioView() { |
889 | 886 | ||
890 | audioView->clear(); | 887 | audioView->clear(); |
891 | StorageInfo storageInfo; | 888 | StorageInfo storageInfo; |
892 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 889 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
893 | if(!audioScan) scanForAudio(); | 890 | if(!audioScan) scanForAudio(); |
894 | 891 | ||
895 | QListIterator<DocLnk> dit( files.children() ); | 892 | QListIterator<DocLnk> dit( files.children() ); |
896 | QListIterator<FileSystem> it ( fs ); | 893 | QListIterator<FileSystem> it ( fs ); |
897 | 894 | ||
898 | QString storage; | 895 | QString storage; |
899 | for ( ; dit.current(); ++dit ) { | 896 | for ( ; dit.current(); ++dit ) { |
900 | for( ; it.current(); ++it ){ | 897 | for( ; it.current(); ++it ){ |
901 | const QString name = (*it)->name(); | 898 | const QString name = (*it)->name(); |
902 | const QString path = (*it)->path(); | 899 | const QString path = (*it)->path(); |
903 | if(dit.current()->file().find(path) != -1 ) storage=name; | 900 | if(dit.current()->file().find(path) != -1 ) storage=name; |
904 | } | 901 | } |
905 | 902 | ||
906 | QListViewItem * newItem; | 903 | QListViewItem * newItem; |
907 | if ( QFile( dit.current()->file()).exists() ) { | 904 | if ( QFile( dit.current()->file()).exists() ) { |
908 | // qDebug(dit.current()->name()); | 905 | // qDebug(dit.current()->name()); |
909 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 906 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
910 | QString::number( QFile( dit.current()->file()).size() ), storage); | 907 | QString::number( QFile( dit.current()->file()).size() ), storage); |
911 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/musicfile" )); | 908 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/musicfile" )); |
912 | } | 909 | } |
913 | } | 910 | } |
914 | 911 | ||
915 | } | 912 | } |
916 | 913 | ||
917 | void PlayListWidget::populateVideoView() { | 914 | void PlayListWidget::populateVideoView() { |
918 | videoView->clear(); | 915 | videoView->clear(); |
919 | StorageInfo storageInfo; | 916 | StorageInfo storageInfo; |
920 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 917 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
921 | 918 | ||
922 | if(!videoScan ) scanForVideo(); | 919 | if(!videoScan ) scanForVideo(); |
923 | 920 | ||
924 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 921 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
925 | QListIterator<FileSystem> it ( fs ); | 922 | QListIterator<FileSystem> it ( fs ); |
926 | videoView->clear(); | 923 | videoView->clear(); |
927 | QString storage; | 924 | QString storage; |
928 | for ( ; Vdit.current(); ++Vdit ) { | 925 | for ( ; Vdit.current(); ++Vdit ) { |
929 | for( ; it.current(); ++it ){ | 926 | for( ; it.current(); ++it ){ |
930 | const QString name = (*it)->name(); | 927 | const QString name = (*it)->name(); |
931 | const QString path = (*it)->path(); | 928 | const QString path = (*it)->path(); |
932 | if( Vdit.current()->file().find(path) != -1 ) storage=name; | 929 | if( Vdit.current()->file().find(path) != -1 ) storage=name; |
933 | } | 930 | } |
934 | 931 | ||
935 | QListViewItem * newItem; | 932 | QListViewItem * newItem; |
936 | if ( QFile( Vdit.current()->file()).exists() ) { | 933 | if ( QFile( Vdit.current()->file()).exists() ) { |
937 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 934 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
938 | QString::number( QFile( Vdit.current()->file()).size() ), storage); | 935 | QString::number( QFile( Vdit.current()->file()).size() ), storage); |
939 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" )); | 936 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" )); |
940 | } | 937 | } |
941 | } | 938 | } |
942 | } | 939 | } |
943 | 940 | ||
944 | void PlayListWidget::openFile() { | 941 | void PlayListWidget::openFile() { |
945 | QString filename, name; | 942 | QString filename, name; |
946 | InputDialog *fileDlg; | 943 | InputDialog *fileDlg; |
947 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 944 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
948 | fileDlg->exec(); | 945 | fileDlg->exec(); |
949 | if( fileDlg->result() == 1 ) { | 946 | if( fileDlg->result() == 1 ) { |
950 | filename = fileDlg->text(); | 947 | filename = fileDlg->text(); |
951 | 948 | ||
952 | qDebug("Selected filename is "+filename); | 949 | qDebug("Selected filename is "+filename); |
953 | if(filename.right(3) == "m3u") { | 950 | if(filename.right(3) == "m3u") { |
954 | readm3u( filename ); | 951 | readm3u( filename ); |
955 | } else if(filename.right(3) == "pls") { | 952 | } else if(filename.right(3) == "pls") { |
956 | readPls( filename ); | 953 | readPls( filename ); |
957 | } else { | 954 | } else { |
958 | DocLnk lnk; | 955 | DocLnk lnk; |
959 | 956 | ||
960 | lnk.setName(filename); //sets file name | 957 | lnk.setName(filename); //sets file name |
961 | lnk.setFile(filename); //sets File property | 958 | lnk.setFile(filename); //sets File property |
962 | lnk.setType("audio/x-mpegurl"); | 959 | lnk.setType("audio/x-mpegurl"); |
963 | lnk.setExec("opieplayer"); | 960 | lnk.setExec("opieplayer"); |
964 | lnk.setIcon("opieplayer2/MPEGPlayer"); | 961 | lnk.setIcon("opieplayer2/MPEGPlayer"); |
965 | 962 | ||
966 | if(!lnk.writeLink()) { | 963 | if(!lnk.writeLink()) { |
967 | qDebug("Writing doclink did not work"); | 964 | qDebug("Writing doclink did not work"); |
968 | } | 965 | } |
969 | d->selectedFiles->addToSelection( lnk); | 966 | d->selectedFiles->addToSelection( lnk); |
970 | } | 967 | } |
971 | } | 968 | } |
972 | if(fileDlg) { | 969 | if(fileDlg) { |
973 | delete fileDlg; | 970 | delete fileDlg; |
974 | } | 971 | } |
975 | } | 972 | } |
976 | 973 | ||
977 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) | 974 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) |
978 | { | 975 | { |
979 | switch ( e->key() ) { | 976 | switch ( e->key() ) { |
980 | ////////////////////////////// Zaurus keys | 977 | ////////////////////////////// Zaurus keys |
981 | case Key_F9: //activity | 978 | case Key_F9: //activity |
982 | // if(audioUI->isHidden()) | 979 | // if(audioUI->isHidden()) |
983 | // audioUI->showMaximized(); | 980 | // audioUI->showMaximized(); |
984 | break; | 981 | break; |
985 | case Key_F10: //contacts | 982 | case Key_F10: //contacts |
986 | // if( videoUI->isHidden()) | 983 | // if( videoUI->isHidden()) |
987 | // videoUI->showMaximized(); | 984 | // videoUI->showMaximized(); |
988 | break; | 985 | break; |
989 | case Key_F11: //menu | 986 | case Key_F11: //menu |
990 | break; | 987 | break; |
991 | case Key_F12: //home | 988 | case Key_F12: //home |
992 | // doBlank(); | 989 | // doBlank(); |
993 | break; | 990 | break; |
994 | case Key_F13: //mail | 991 | case Key_F13: //mail |
995 | // doUnblank(); | 992 | // doUnblank(); |
996 | break; | 993 | break; |
997 | case Key_Q: //add to playlist | 994 | case Key_Q: //add to playlist |
998 | addSelected(); | 995 | addSelected(); |
999 | break; | 996 | break; |
1000 | case Key_R: //remove from playlist | 997 | case Key_R: //remove from playlist |
1001 | removeSelected(); | 998 | removeSelected(); |
1002 | break; | 999 | break; |
1003 | // case Key_P: //play | 1000 | // case Key_P: //play |
1004 | // qDebug("Play"); | 1001 | // qDebug("Play"); |
1005 | // playSelected(); | 1002 | // playSelected(); |
1006 | // break; | 1003 | // break; |
1007 | case Key_Space: | 1004 | case Key_Space: |
1008 | // playSelected(); puh | 1005 | // playSelected(); puh |
1009 | break; | 1006 | break; |
1010 | case Key_1: | 1007 | case Key_1: |
1011 | tabWidget->setCurrentPage(0); | 1008 | tabWidget->setCurrentPage(0); |
1012 | break; | 1009 | break; |
1013 | case Key_2: | 1010 | case Key_2: |
1014 | tabWidget->setCurrentPage(1); | 1011 | tabWidget->setCurrentPage(1); |
1015 | break; | 1012 | break; |
1016 | case Key_3: | 1013 | case Key_3: |
1017 | tabWidget->setCurrentPage(2); | 1014 | tabWidget->setCurrentPage(2); |
1018 | break; | 1015 | break; |
1019 | case Key_4: | 1016 | case Key_4: |
1020 | tabWidget->setCurrentPage(3); | 1017 | tabWidget->setCurrentPage(3); |
1021 | break; | 1018 | break; |
1022 | case Key_Down: | 1019 | case Key_Down: |
1023 | if ( !d->selectedFiles->next() ) | 1020 | if ( !d->selectedFiles->next() ) |
1024 | d->selectedFiles->first(); | 1021 | d->selectedFiles->first(); |
1025 | 1022 | ||
1026 | break; | 1023 | break; |
1027 | case Key_Up: | 1024 | case Key_Up: |
1028 | if ( !d->selectedFiles->prev() ) | 1025 | if ( !d->selectedFiles->prev() ) |
1029 | // d->selectedFiles->last(); | 1026 | // d->selectedFiles->last(); |
1030 | 1027 | ||
1031 | break; | 1028 | break; |
1032 | 1029 | ||
1033 | } | 1030 | } |
1034 | } | 1031 | } |
1035 | 1032 | ||
1036 | void PlayListWidget::keyPressEvent( QKeyEvent *) | 1033 | void PlayListWidget::keyPressEvent( QKeyEvent *) |
1037 | { | 1034 | { |
1038 | // qDebug("Key press"); | 1035 | // qDebug("Key press"); |
1039 | // switch ( e->key() ) { | 1036 | // switch ( e->key() ) { |
1040 | // ////////////////////////////// Zaurus keys | 1037 | // ////////////////////////////// Zaurus keys |
1041 | // case Key_A: //add to playlist | 1038 | // case Key_A: //add to playlist |
1042 | // qDebug("Add"); | 1039 | // qDebug("Add"); |
1043 | // addSelected(); | 1040 | // addSelected(); |
1044 | // break; | 1041 | // break; |
1045 | // case Key_R: //remove from playlist | 1042 | // case Key_R: //remove from playlist |
1046 | // removeSelected(); | 1043 | // removeSelected(); |
1047 | // break; | 1044 | // break; |
1048 | // case Key_P: //play | 1045 | // case Key_P: //play |
1049 | // qDebug("Play"); | 1046 | // qDebug("Play"); |
1050 | // playSelected(); | 1047 | // playSelected(); |
1051 | // break; | 1048 | // break; |
1052 | // case Key_Space: | 1049 | // case Key_Space: |
1053 | // qDebug("Play"); | 1050 | // qDebug("Play"); |
1054 | // playSelected(); | 1051 | // playSelected(); |
1055 | // break; | 1052 | // break; |
1056 | // } | 1053 | // } |
1057 | } | 1054 | } |
1058 | 1055 | ||
1059 | 1056 | ||
1060 | 1057 | ||
1061 | void PlayListWidget::readm3u(const QString &filename) { | 1058 | void PlayListWidget::readm3u(const QString &filename) { |
1062 | 1059 | ||
1063 | qDebug("m3u filename is "+filename); | 1060 | qDebug("m3u filename is "+filename); |
1064 | QFile f(filename); | 1061 | QFile f(filename); |
1065 | 1062 | ||
1066 | if(f.open(IO_ReadOnly)) { | 1063 | if(f.open(IO_ReadOnly)) { |
1067 | QTextStream t(&f); | 1064 | QTextStream t(&f); |
1068 | QString s;//, first, second; | 1065 | QString s;//, first, second; |
1069 | int i=0; | 1066 | int i=0; |
1070 | while ( !t.atEnd()) { | 1067 | while ( !t.atEnd()) { |
1071 | s=t.readLine(); | 1068 | s=t.readLine(); |
1072 | 1069 | ||
1073 | if(s.find("#",0,TRUE) == -1) { | 1070 | if(s.find("#",0,TRUE) == -1) { |
1074 | if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat | 1071 | if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat |
1075 | if(s.left(2) == "E:" || s.left(2) == "P:") { | 1072 | if(s.left(2) == "E:" || s.left(2) == "P:") { |
1076 | s=s.right(s.length()-2); | 1073 | s=s.right(s.length()-2); |
1077 | // if(QFile(s).exists()) { | 1074 | // if(QFile(s).exists()) { |
1078 | DocLnk lnk( s ); | 1075 | DocLnk lnk( s ); |
1079 | QFileInfo f(s); | 1076 | QFileInfo f(s); |
1080 | QString name = f.baseName(); | 1077 | QString name = f.baseName(); |
1081 | name = name.right( name.length()-name.findRev( "\\",-1,TRUE ) -1 ); | 1078 | name = name.right( name.length()-name.findRev( "\\",-1,TRUE ) -1 ); |
1082 | lnk.setName( name ); | 1079 | lnk.setName( name ); |
1083 | s=s.replace( QRegExp("\\"),"/"); | 1080 | s=s.replace( QRegExp("\\"),"/"); |
1084 | lnk.setFile( s ); | 1081 | lnk.setFile( s ); |
1085 | lnk.writeLink(); | 1082 | lnk.writeLink(); |
1086 | qDebug("add "+name); | 1083 | qDebug("add "+name); |
1087 | d->selectedFiles->addToSelection( lnk); | 1084 | d->selectedFiles->addToSelection( lnk); |
1088 | // } | 1085 | // } |
1089 | } else { // is url | 1086 | } else { // is url |
1090 | s.replace(QRegExp("%20")," "); | 1087 | s.replace(QRegExp("%20")," "); |
1091 | DocLnk lnk( s ); | 1088 | DocLnk lnk( s ); |
1092 | QString name; | 1089 | QString name; |
1093 | if(name.left(4)=="http") { | 1090 | if(name.left(4)=="http") { |
1094 | name = s.right( s.length() - 7); | 1091 | name = s.right( s.length() - 7); |
1095 | } else { | 1092 | } else { |
1096 | name = s; | 1093 | name = s; |
1097 | } | 1094 | } |
1098 | lnk.setName(name); | 1095 | lnk.setName(name); |
1099 | if(s.at(s.length()-4) == '.') { | 1096 | if(s.at(s.length()-4) == '.') { |
1100 | lnk.setFile( s); | 1097 | lnk.setFile( s); |
1101 | } else { | 1098 | } else { |
1102 | lnk.setFile( s+"/"); | 1099 | lnk.setFile( s+"/"); |
1103 | } | 1100 | } |
1104 | lnk.setType("audio/x-mpegurl"); | 1101 | lnk.setType("audio/x-mpegurl"); |
1105 | lnk.writeLink(); | 1102 | lnk.writeLink(); |
1106 | d->selectedFiles->addToSelection( lnk); | 1103 | d->selectedFiles->addToSelection( lnk); |
1107 | } | 1104 | } |
1108 | i++; | 1105 | i++; |
1109 | } | 1106 | } |
1110 | } | 1107 | } |
1111 | } | 1108 | } |
1112 | } | 1109 | } |
1113 | f.close(); | 1110 | f.close(); |
1114 | } | 1111 | } |
1115 | 1112 | ||
1116 | void PlayListWidget::writem3u() { | 1113 | void PlayListWidget::writem3u() { |
1117 | 1114 | ||
1118 | InputDialog *fileDlg; | 1115 | InputDialog *fileDlg; |
1119 | fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0); | 1116 | fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0); |
1120 | fileDlg->exec(); | 1117 | fileDlg->exec(); |
1121 | QString filename,list; | 1118 | QString filename,list; |
1122 | if( fileDlg->result() == 1 ) { | 1119 | if( fileDlg->result() == 1 ) { |
1123 | filename = fileDlg->text(); | 1120 | filename = fileDlg->text(); |
1124 | qDebug(filename); | 1121 | qDebug(filename); |
1125 | int noOfFiles = 0; | 1122 | int noOfFiles = 0; |
1126 | d->selectedFiles->first(); | 1123 | d->selectedFiles->first(); |
1127 | do { | 1124 | do { |
1128 | // we dont check for existance because of url's | 1125 | // we dont check for existance because of url's |
1129 | // qDebug(d->selectedFiles->current()->file()); | 1126 | // qDebug(d->selectedFiles->current()->file()); |
1130 | list += d->selectedFiles->current()->file()+"\n"; | 1127 | list += d->selectedFiles->current()->file()+"\n"; |
1131 | noOfFiles++; | 1128 | noOfFiles++; |
1132 | } | 1129 | } |
1133 | while ( d->selectedFiles->next() ); | 1130 | while ( d->selectedFiles->next() ); |
1134 | qDebug(list); | 1131 | qDebug(list); |
1135 | if(filename.left(1) != "/") | 1132 | if(filename.left(1) != "/") |
1136 | filename=QPEApplication::documentDir()+"/"+filename; | 1133 | filename=QPEApplication::documentDir()+"/"+filename; |
1137 | if(filename.right(3) != "m3u") | 1134 | if(filename.right(3) != "m3u") |
1138 | filename=filename+".m3u"; | 1135 | filename=filename+".m3u"; |
1139 | 1136 | ||
1140 | QFile f(filename); | 1137 | QFile f(filename); |
1141 | f.open(IO_WriteOnly); | 1138 | f.open(IO_WriteOnly); |
1142 | f.writeBlock(list, list.length()); | 1139 | f.writeBlock(list, list.length()); |
1143 | f.close(); | 1140 | f.close(); |
1144 | } | 1141 | } |
1145 | if(fileDlg) delete fileDlg; | 1142 | if(fileDlg) delete fileDlg; |
1146 | } | 1143 | } |
1147 | 1144 | ||
1148 | void PlayListWidget::readPls(const QString &filename) { | 1145 | void PlayListWidget::readPls(const QString &filename) { |
1149 | 1146 | ||
1150 | qDebug("pls filename is "+filename); | 1147 | qDebug("pls filename is "+filename); |
1151 | QFile f(filename); | 1148 | QFile f(filename); |
1152 | 1149 | ||
1153 | if(f.open(IO_ReadOnly)) { | 1150 | if(f.open(IO_ReadOnly)) { |
1154 | QTextStream t(&f); | 1151 | QTextStream t(&f); |
1155 | QString s;//, first, second; | 1152 | QString s;//, first, second; |
1156 | int i=0; | 1153 | int i=0; |
1157 | while ( !t.atEnd()) { | 1154 | while ( !t.atEnd()) { |
1158 | s=t.readLine(); | 1155 | s=t.readLine(); |
1159 | if(s.left(4) == "File") { | 1156 | if(s.left(4) == "File") { |
1160 | s=s.right(s.length() - 6); | 1157 | s=s.right(s.length() - 6); |
1161 | s.replace(QRegExp("%20")," "); | 1158 | s.replace(QRegExp("%20")," "); |
1162 | qDebug("adding "+s+" to playlist"); | 1159 | qDebug("adding "+s+" to playlist"); |
1163 | // numberofentries=2 | 1160 | // numberofentries=2 |
1164 | // File1=http | 1161 | // File1=http |
1165 | // Title | 1162 | // Title |
1166 | // Length | 1163 | // Length |
1167 | // Version | 1164 | // Version |
1168 | // File2=http | 1165 | // File2=http |
1169 | s=s.replace( QRegExp("\\"),"/"); | 1166 | s=s.replace( QRegExp("\\"),"/"); |
1170 | DocLnk lnk( s ); | 1167 | DocLnk lnk( s ); |
1171 | QFileInfo f(s); | 1168 | QFileInfo f(s); |
1172 | QString name = f.baseName(); | 1169 | QString name = f.baseName(); |
1173 | if(name.left(4)=="http") | 1170 | if(name.left(4)=="http") |
1174 | name = s.right( s.length() - 7); | 1171 | name = s.right( s.length() - 7); |
1175 | else | 1172 | else |
1176 | name=s; | 1173 | name=s; |
1177 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); | 1174 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); |
1178 | lnk.setName( name); | 1175 | lnk.setName( name); |
1179 | if(s.at(s.length()-4) == '.') // if this is probably a file | 1176 | if(s.at(s.length()-4) == '.') // if this is probably a file |
1180 | lnk.setFile( s); | 1177 | lnk.setFile( s); |
1181 | else { //if its a url | 1178 | else { //if its a url |
1182 | if( name.right(1).find('/') == -1) | 1179 | if( name.right(1).find('/') == -1) |
1183 | s+="/"; | 1180 | s+="/"; |
1184 | lnk.setFile( s); | 1181 | lnk.setFile( s); |
1185 | } | 1182 | } |
1186 | lnk.setType("audio/x-mpegurl"); | 1183 | lnk.setType("audio/x-mpegurl"); |
1187 | 1184 | ||
1188 | qDebug("DocLnk add "+name); | 1185 | qDebug("DocLnk add "+name); |
1189 | d->selectedFiles->addToSelection( lnk); | 1186 | d->selectedFiles->addToSelection( lnk); |
1190 | } | 1187 | } |
1191 | } | 1188 | } |
1192 | i++; | 1189 | i++; |
1193 | } | 1190 | } |
1194 | } | 1191 | } |
1195 | 1192 | ||
1196 | void PlayListWidget::pmViewActivated(int index) { | 1193 | void PlayListWidget::pmViewActivated(int index) { |
1197 | // qDebug("%d", index); | 1194 | // qDebug("%d", index); |
1198 | switch(index) { | 1195 | switch(index) { |
1199 | case -16: | 1196 | case -16: |
1200 | { | 1197 | { |
1201 | 1198 | ||
1202 | mediaPlayerState->toggleFullscreen(); | 1199 | mediaPlayerState->toggleFullscreen(); |
1203 | bool b=mediaPlayerState->fullscreen(); | 1200 | bool b=mediaPlayerState->fullscreen(); |
1204 | pmView->setItemChecked( index,b); | 1201 | pmView->setItemChecked( index,b); |
1205 | Config cfg( "OpiePlayer" ); | 1202 | Config cfg( "OpiePlayer" ); |
1206 | cfg.writeEntry("FullScreen", b); | 1203 | cfg.writeEntry("FullScreen", b); |
1207 | 1204 | ||
1208 | } | 1205 | } |
1209 | break; | 1206 | break; |
1210 | }; | 1207 | }; |
1211 | } | 1208 | } |
1212 | 1209 | ||
1213 | void PlayListWidget::populateSkinsMenu() { | 1210 | void PlayListWidget::populateSkinsMenu() { |
1214 | int item=0; | 1211 | int item=0; |
1215 | defaultSkinIndex=0; | 1212 | defaultSkinIndex=0; |
1216 | QString skinName; | 1213 | QString skinName; |
1217 | Config cfg( "OpiePlayer" ); | 1214 | Config cfg( "OpiePlayer" ); |
1218 | cfg.setGroup("Options"); | 1215 | cfg.setGroup("Options"); |
1219 | QString skin = cfg.readEntry("Skin","default"); | 1216 | QString skin = cfg.readEntry("Skin","default"); |
1220 | 1217 | ||
1221 | QDir skinsDir(QPEApplication::qpeDir()+"/pics/opieplayer2/skins"); | 1218 | QDir skinsDir(QPEApplication::qpeDir()+"/pics/opieplayer2/skins"); |
1222 | skinsDir.setFilter( QDir::Dirs); | 1219 | skinsDir.setFilter( QDir::Dirs); |
1223 | skinsDir.setSorting(QDir::Name); | 1220 | skinsDir.setSorting(QDir::Name); |
1224 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); | 1221 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); |
1225 | QFileInfoListIterator it( *skinslist ); | 1222 | QFileInfoListIterator it( *skinslist ); |
1226 | QFileInfo *fi; | 1223 | QFileInfo *fi; |
1227 | while ( (fi=it.current()) ) { | 1224 | while ( (fi=it.current()) ) { |
1228 | skinName = fi->fileName(); | 1225 | skinName = fi->fileName(); |
1229 | qDebug( fi->fileName()); | 1226 | qDebug( fi->fileName()); |
1230 | if( skinName != "." && skinName != ".." && skinName !="CVS") | 1227 | if( skinName != "." && skinName != ".." && skinName !="CVS") |
1231 | item = skinsMenu->insertItem( fi->fileName()); | 1228 | item = skinsMenu->insertItem( fi->fileName()); |
1232 | if( skinName == "default") | 1229 | if( skinName == "default") |
1233 | defaultSkinIndex = item; | 1230 | defaultSkinIndex = item; |
1234 | if( skinName == skin) | 1231 | if( skinName == skin) |
1235 | skinsMenu->setItemChecked( item, TRUE); | 1232 | skinsMenu->setItemChecked( item, TRUE); |
1236 | 1233 | ||
1237 | ++it; | 1234 | ++it; |
1238 | } | 1235 | } |
1239 | } | 1236 | } |
1240 | 1237 | ||
1241 | void PlayListWidget::skinsMenuActivated(int item) { | 1238 | void PlayListWidget::skinsMenuActivated(int item) { |
1242 | for(int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i--) { | 1239 | for(int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i--) { |
1243 | skinsMenu->setItemChecked( i, FALSE); | 1240 | skinsMenu->setItemChecked( i, FALSE); |
1244 | } | 1241 | } |
1245 | skinsMenu->setItemChecked( item, TRUE); | 1242 | skinsMenu->setItemChecked( item, TRUE); |
1246 | 1243 | ||
1247 | Config cfg( "OpiePlayer" ); | 1244 | Config cfg( "OpiePlayer" ); |
1248 | cfg.setGroup("Options"); | 1245 | cfg.setGroup("Options"); |
1249 | cfg.writeEntry("Skin", skinsMenu->text( item)); | 1246 | cfg.writeEntry("Skin", skinsMenu->text( item)); |
1250 | } | 1247 | } |
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h index 8076707..8710a99 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.h +++ b/noncore/multimedia/opieplayer2/playlistwidget.h | |||
@@ -1,111 +1,111 @@ | |||
1 | 1 | ||
2 | #ifndef PLAY_LIST_WIDGET_H | 2 | #ifndef PLAY_LIST_WIDGET_H |
3 | #define PLAY_LIST_WIDGET_H | 3 | #define PLAY_LIST_WIDGET_H |
4 | 4 | ||
5 | #include <qmainwindow.h> | 5 | #include <qmainwindow.h> |
6 | #include <qpe/applnk.h> | 6 | #include <qpe/applnk.h> |
7 | #include <qtabwidget.h> | 7 | #include <qtabwidget.h> |
8 | #include <qpe/fileselector.h> | 8 | #include <qpe/fileselector.h> |
9 | #include <qpushbutton.h> | 9 | #include <qpushbutton.h> |
10 | #include <qpopupmenu.h> | 10 | #include <qpopupmenu.h> |
11 | 11 | ||
12 | /* #include <qtimer.h> */ | 12 | /* #include <qtimer.h> */ |
13 | 13 | ||
14 | 14 | ||
15 | class PlayListWidgetPrivate; | 15 | class PlayListWidgetPrivate; |
16 | class Config; | 16 | class Config; |
17 | class QListViewItem; | 17 | class QListViewItem; |
18 | class QListView; | 18 | class QListView; |
19 | class QPoint; | 19 | class QPoint; |
20 | class QAction; | 20 | class QAction; |
21 | class QLabel; | 21 | class QLabel; |
22 | 22 | ||
23 | class PlayListWidget : public QMainWindow { | 23 | class PlayListWidget : public QMainWindow { |
24 | Q_OBJECT | 24 | Q_OBJECT |
25 | public: | 25 | public: |
26 | PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); | 26 | PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); |
27 | ~PlayListWidget(); | 27 | ~PlayListWidget(); |
28 | QTabWidget * tabWidget; | 28 | QTabWidget * tabWidget; |
29 | // MenuItem *fullScreenButton, *scaleButton; | 29 | // MenuItem *fullScreenButton, *scaleButton; |
30 | // QAction *fullScreenButton, *scaleButton; | 30 | // QAction *fullScreenButton, *scaleButton; |
31 | DocLnkSet files; | 31 | DocLnkSet files; |
32 | DocLnkSet vFiles; | 32 | DocLnkSet vFiles; |
33 | QListView *audioView, *videoView, *playlistView; | 33 | QListView *audioView, *videoView, *playlistView; |
34 | QLabel *libString; | 34 | QLabel *libString; |
35 | QPopupMenu *pmView ; | 35 | QPopupMenu *pmView ; |
36 | bool fromSetDocument; | 36 | bool fromSetDocument; |
37 | bool insanityBool; | 37 | bool insanityBool; |
38 | QString setDocFileRef; | 38 | QString setDocFileRef; |
39 | // retrieve the current playlist entry (media file link) | 39 | // retrieve the current playlist entry (media file link) |
40 | const DocLnk *current(); | 40 | const DocLnk *current(); |
41 | void useSelectedDocument(); | 41 | void useSelectedDocument(); |
42 | /* QTimer * menuTimer; */ | 42 | /* QTimer * menuTimer; */ |
43 | FileSelector* playLists; | 43 | FileSelector* playLists; |
44 | QPushButton *tbDeletePlaylist; | 44 | QPushButton *tbDeletePlaylist; |
45 | int selected; | 45 | int selected; |
46 | public slots: | 46 | public slots: |
47 | bool first(); | 47 | bool first(); |
48 | bool last(); | 48 | bool last(); |
49 | bool next(); | 49 | bool next(); |
50 | bool prev(); | 50 | bool prev(); |
51 | void writeConfig( Config& cfg ) const; | ||
51 | /* void setFullScreen(); */ | 52 | /* void setFullScreen(); */ |
52 | /* void setScaled(); */ | 53 | /* void setScaled(); */ |
53 | protected: | 54 | protected: |
54 | /* void contentsMousePressEvent( QMouseEvent * e ); */ | 55 | /* void contentsMousePressEvent( QMouseEvent * e ); */ |
55 | /* void contentsMouseReleaseEvent( QMouseEvent * e ); */ | 56 | /* void contentsMouseReleaseEvent( QMouseEvent * e ); */ |
56 | void keyReleaseEvent( QKeyEvent *e); | 57 | void keyReleaseEvent( QKeyEvent *e); |
57 | void keyPressEvent( QKeyEvent *e); | 58 | void keyPressEvent( QKeyEvent *e); |
58 | private: | 59 | private: |
59 | int defaultSkinIndex; | 60 | int defaultSkinIndex; |
60 | QPopupMenu *skinsMenu; | 61 | QPopupMenu *skinsMenu; |
61 | bool audioScan, videoScan; | 62 | bool audioScan, videoScan; |
62 | void readm3u(const QString &); | 63 | void readm3u(const QString &); |
63 | void readPls(const QString &); | 64 | void readPls(const QString &); |
64 | 65 | ||
65 | void initializeStates(); | 66 | void initializeStates(); |
66 | void readConfig( Config& cfg ); | 67 | void readConfig( Config& cfg ); |
67 | void writeConfig( Config& cfg ) const; | ||
68 | PlayListWidgetPrivate *d; // Private implementation data | 68 | PlayListWidgetPrivate *d; // Private implementation data |
69 | void populateAudioView(); | 69 | void populateAudioView(); |
70 | void populateVideoView(); | 70 | void populateVideoView(); |
71 | private slots: | 71 | private slots: |
72 | void populateSkinsMenu(); | 72 | void populateSkinsMenu(); |
73 | void skinsMenuActivated(int); | 73 | void skinsMenuActivated(int); |
74 | void pmViewActivated(int); | 74 | void pmViewActivated(int); |
75 | void writem3u(); | 75 | void writem3u(); |
76 | void scanForAudio(); | 76 | void scanForAudio(); |
77 | void scanForVideo(); | 77 | void scanForVideo(); |
78 | void openFile(); | 78 | void openFile(); |
79 | void setDocument( const QString& fileref ); | 79 | void setDocument( const QString& fileref ); |
80 | void addToSelection( const DocLnk& ); // Add a media file to the playlist | 80 | void addToSelection( const DocLnk& ); // Add a media file to the playlist |
81 | void addToSelection( QListViewItem* ); // Add a media file to the playlist | 81 | void addToSelection( QListViewItem* ); // Add a media file to the playlist |
82 | void setActiveWindow(); // need to handle this to show the right view | 82 | void setActiveWindow(); // need to handle this to show the right view |
83 | void setPlaylist( bool ); // Show/Hide the playlist | 83 | void setPlaylist( bool ); // Show/Hide the playlist |
84 | void setView( char ); | 84 | void setView( char ); |
85 | void clearList(); | 85 | void clearList(); |
86 | void addAllToList(); | 86 | void addAllToList(); |
87 | void addAllMusicToList(); | 87 | void addAllMusicToList(); |
88 | void addAllVideoToList(); | 88 | void addAllVideoToList(); |
89 | void saveList(); // Save the playlist | 89 | void saveList(); // Save the playlist |
90 | void loadList( const DocLnk &); // Load a playlist | 90 | void loadList( const DocLnk &); // Load a playlist |
91 | void playIt( QListViewItem *); | 91 | void playIt( QListViewItem *); |
92 | 92 | ||
93 | void btnPlay(bool); | 93 | void btnPlay(bool); |
94 | void deletePlaylist(); | 94 | void deletePlaylist(); |
95 | void addSelected(); | 95 | void addSelected(); |
96 | void removeSelected(); | 96 | void removeSelected(); |
97 | void tabChanged(QWidget*); | 97 | void tabChanged(QWidget*); |
98 | void viewPressed( int, QListViewItem *, const QPoint&, int); | 98 | void viewPressed( int, QListViewItem *, const QPoint&, int); |
99 | void playlistViewPressed( int, QListViewItem *, const QPoint&, int); | 99 | void playlistViewPressed( int, QListViewItem *, const QPoint&, int); |
100 | void playSelected(); | 100 | void playSelected(); |
101 | 101 | ||
102 | protected slots: | 102 | protected slots: |
103 | /* void cancelMenuTimer(); */ | 103 | /* void cancelMenuTimer(); */ |
104 | /* void showFileMenu(); */ | 104 | /* void showFileMenu(); */ |
105 | 105 | ||
106 | 106 | ||
107 | }; | 107 | }; |
108 | 108 | ||
109 | 109 | ||
110 | #endif // PLAY_LIST_WIDGET_H | 110 | #endif // PLAY_LIST_WIDGET_H |
111 | 111 | ||