summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-08-20 12:27:14 (UTC)
committer llornkcor <llornkcor>2002-08-20 12:27:14 (UTC)
commit41fe19a4e2e808d48429c84f4b7dd6b9af797ead (patch) (unidiff)
tree3f9b0c91c34c3d81feebd43e904e74563ba2229c
parentdfd3bcb3dd20cc72487c527d135e076a0ff78b25 (diff)
downloadopie-41fe19a4e2e808d48429c84f4b7dd6b9af797ead.zip
opie-41fe19a4e2e808d48429c84f4b7dd6b9af797ead.tar.gz
opie-41fe19a4e2e808d48429c84f4b7dd6b9af797ead.tar.bz2
fix coredump on exit
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp4
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayerstate.cpp4
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp8
3 files changed, 8 insertions, 8 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp
index 0526c2a..5503705 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp
@@ -104,198 +104,198 @@ void MediaPlayer::setPlaying( bool play ) {
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
114void MediaPlayer::prev() { 114void 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
127void MediaPlayer::next() { 127void 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
140void MediaPlayer::startDecreasingVolume() { 140void 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
147void MediaPlayer::startIncreasingVolume() { 147void 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
154bool drawnOnScreenDisplay = FALSE; 154bool drawnOnScreenDisplay = FALSE;
155unsigned int onScreenDisplayVolume = 0; 155unsigned int onScreenDisplayVolume = 0;
156const int yoff = 110; 156const int yoff = 110;
157 157
158void MediaPlayer::stopChangingVolume() { 158void 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
177void MediaPlayer::timerEvent( QTimerEvent * ) { 177void 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
255void MediaPlayer::blank( bool b ) { 255void 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
273void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { 273void 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
295void MediaPlayer::cleanUp() {// this happens on closing 295void MediaPlayer::cleanUp() {// this happens on closing
296 Config cfg( "OpiePlayer" ); 296 Config cfg( "OpiePlayer" );
297 playList->writeConfig( cfg ); 297 playList->writeConfig( cfg );
298 298
299// QPEApplication::grabKeyboard(); 299// QPEApplication::grabKeyboard();
300// QPEApplication::ungrabKeyboard(); 300// QPEApplication::ungrabKeyboard();
301} 301}
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp
index eaedaa5..d984022 100644
--- a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp
@@ -1,217 +1,217 @@
1#include <qpe/qpeapplication.h> 1#include <qpe/qpeapplication.h>
2#include <qpe/qlibrary.h> 2#include <qpe/qlibrary.h>
3#include <qpe/config.h> 3#include <qpe/config.h>
4#include <qvaluelist.h> 4#include <qvaluelist.h>
5#include <qobject.h> 5#include <qobject.h>
6#include <qdir.h> 6#include <qdir.h>
7#include "mediaplayerstate.h" 7#include "mediaplayerstate.h"
8 8
9 9
10 10
11//#define MediaPlayerDebug(x) qDebug x 11//#define MediaPlayerDebug(x) qDebug x
12#define MediaPlayerDebug(x) 12#define MediaPlayerDebug(x)
13 13
14 14
15MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) 15MediaPlayerState::MediaPlayerState( QObject *parent, const char *name )
16 : QObject( parent, name ) { 16 : QObject( parent, name ) {
17 Config cfg( "OpiePlayer" ); 17 Config cfg( "OpiePlayer" );
18 readConfig( cfg ); 18 readConfig( cfg );
19 isStreaming = false; 19 isStreaming = false;
20} 20}
21 21
22 22
23MediaPlayerState::~MediaPlayerState() { 23MediaPlayerState::~MediaPlayerState() {
24 Config cfg( "OpiePlayer" ); 24// Config cfg( "OpiePlayer" );
25 writeConfig( cfg ); 25// writeConfig( cfg );
26 26
27} 27}
28 28
29 29
30void MediaPlayerState::readConfig( Config& cfg ) { 30void MediaPlayerState::readConfig( Config& cfg ) {
31 cfg.setGroup("Options"); 31 cfg.setGroup("Options");
32 isFullscreen = cfg.readBoolEntry( "FullScreen" ); 32 isFullscreen = cfg.readBoolEntry( "FullScreen" );
33 isScaled = cfg.readBoolEntry( "Scaling" ); 33 isScaled = cfg.readBoolEntry( "Scaling" );
34 isLooping = cfg.readBoolEntry( "Looping" ); 34 isLooping = cfg.readBoolEntry( "Looping" );
35 isShuffled = cfg.readBoolEntry( "Shuffle" ); 35 isShuffled = cfg.readBoolEntry( "Shuffle" );
36 usePlaylist = cfg.readBoolEntry( "UsePlayList" ); 36 usePlaylist = cfg.readBoolEntry( "UsePlayList" );
37 usePlaylist = TRUE; 37 usePlaylist = TRUE;
38 isPlaying = FALSE; 38 isPlaying = FALSE;
39 isStreaming = FALSE; 39 isStreaming = FALSE;
40 isPaused = FALSE; 40 isPaused = FALSE;
41 curPosition = 0; 41 curPosition = 0;
42 curLength = 0; 42 curLength = 0;
43 curView = 'l'; 43 curView = 'l';
44} 44}
45 45
46 46
47void MediaPlayerState::writeConfig( Config& cfg ) const { 47void MediaPlayerState::writeConfig( Config& cfg ) const {
48 cfg.setGroup("Options"); 48 cfg.setGroup("Options");
49 cfg.writeEntry("FullScreen", isFullscreen ); 49 cfg.writeEntry("FullScreen", isFullscreen );
50 cfg.writeEntry("Scaling", isScaled ); 50 cfg.writeEntry("Scaling", isScaled );
51 cfg.writeEntry("Looping", isLooping ); 51 cfg.writeEntry("Looping", isLooping );
52 cfg.writeEntry("Shuffle", isShuffled ); 52 cfg.writeEntry("Shuffle", isShuffled );
53 cfg.writeEntry("UsePlayList", usePlaylist ); 53 cfg.writeEntry("UsePlayList", usePlaylist );
54} 54}
55 55
56 56
57// public stuff 57// public stuff
58 58
59 59
60bool MediaPlayerState::streaming() { 60bool MediaPlayerState::streaming() {
61 return isStreaming; 61 return isStreaming;
62} 62}
63 63
64bool MediaPlayerState::fullscreen() { 64bool MediaPlayerState::fullscreen() {
65 return isFullscreen; 65 return isFullscreen;
66} 66}
67 67
68bool MediaPlayerState::scaled() { 68bool MediaPlayerState::scaled() {
69 return isScaled; 69 return isScaled;
70} 70}
71 71
72bool MediaPlayerState::looping() { 72bool MediaPlayerState::looping() {
73 return isLooping; 73 return isLooping;
74} 74}
75 75
76bool MediaPlayerState::shuffled() { 76bool MediaPlayerState::shuffled() {
77 return isShuffled; 77 return isShuffled;
78} 78}
79 79
80 80
81bool MediaPlayerState:: playlist() { 81bool MediaPlayerState:: playlist() {
82 return usePlaylist; 82 return usePlaylist;
83} 83}
84 84
85bool MediaPlayerState::paused() { 85bool MediaPlayerState::paused() {
86 return isPaused; 86 return isPaused;
87} 87}
88 88
89bool MediaPlayerState::playing() { 89bool MediaPlayerState::playing() {
90 return isPlaying; 90 return isPlaying;
91} 91}
92 92
93bool MediaPlayerState::stop() { 93bool MediaPlayerState::stop() {
94 return isStoped; 94 return isStoped;
95} 95}
96 96
97long MediaPlayerState::position() { 97long MediaPlayerState::position() {
98 return curPosition; 98 return curPosition;
99} 99}
100 100
101long MediaPlayerState::length() { 101long MediaPlayerState::length() {
102 return curLength; 102 return curLength;
103} 103}
104 104
105char MediaPlayerState::view() { 105char MediaPlayerState::view() {
106 return curView; 106 return curView;
107} 107}
108 108
109// slots 109// slots
110void MediaPlayerState::setIsStreaming( bool b ) { 110void MediaPlayerState::setIsStreaming( bool b ) {
111 111
112 if ( isStreaming == b ) { 112 if ( isStreaming == b ) {
113 return; 113 return;
114 } 114 }
115 isStreaming = b; 115 isStreaming = b;
116} 116}
117 117
118 118
119void MediaPlayerState::setFullscreen( bool b ) { 119void MediaPlayerState::setFullscreen( bool b ) {
120 if ( isFullscreen == b ) { 120 if ( isFullscreen == b ) {
121 return; 121 return;
122 } 122 }
123 isFullscreen = b; 123 isFullscreen = b;
124 emit fullscreenToggled(b); 124 emit fullscreenToggled(b);
125} 125}
126 126
127 127
128void MediaPlayerState::setBlanked( bool b ) { 128void MediaPlayerState::setBlanked( bool b ) {
129 if ( isBlanked == b ) { 129 if ( isBlanked == b ) {
130 return; 130 return;
131 } 131 }
132 isBlanked = b; 132 isBlanked = b;
133 emit blankToggled(b); 133 emit blankToggled(b);
134} 134}
135 135
136 136
137void MediaPlayerState::setScaled( bool b ) { 137void MediaPlayerState::setScaled( bool b ) {
138 if ( isScaled == b ) { 138 if ( isScaled == b ) {
139 return; 139 return;
140 } 140 }
141 isScaled = b; 141 isScaled = b;
142 emit scaledToggled(b); 142 emit scaledToggled(b);
143} 143}
144 144
145void MediaPlayerState::setLooping( bool b ) { 145void MediaPlayerState::setLooping( bool b ) {
146 if ( isLooping == b ) { 146 if ( isLooping == b ) {
147 return; 147 return;
148 } 148 }
149 isLooping = b; 149 isLooping = b;
150 emit loopingToggled(b); 150 emit loopingToggled(b);
151} 151}
152 152
153void MediaPlayerState::setShuffled( bool b ) { 153void MediaPlayerState::setShuffled( bool b ) {
154 if ( isShuffled == b ) { 154 if ( isShuffled == b ) {
155 return; 155 return;
156 } 156 }
157 isShuffled = b; 157 isShuffled = b;
158 emit shuffledToggled(b); 158 emit shuffledToggled(b);
159} 159}
160 160
161void MediaPlayerState::setPlaylist( bool b ) { 161void MediaPlayerState::setPlaylist( bool b ) {
162 if ( usePlaylist == b ) { 162 if ( usePlaylist == b ) {
163 return; 163 return;
164 } 164 }
165 usePlaylist = b; 165 usePlaylist = b;
166 emit playlistToggled(b); 166 emit playlistToggled(b);
167} 167}
168 168
169void MediaPlayerState::setPaused( bool b ) { 169void MediaPlayerState::setPaused( bool b ) {
170 if ( isPaused == b ) { 170 if ( isPaused == b ) {
171 isPaused = FALSE; 171 isPaused = FALSE;
172 emit pausedToggled(FALSE); 172 emit pausedToggled(FALSE);
173 return; 173 return;
174 } 174 }
175 isPaused = b; 175 isPaused = b;
176 emit pausedToggled(b); 176 emit pausedToggled(b);
177} 177}
178 178
179void MediaPlayerState::setPlaying( bool b ) { 179void MediaPlayerState::setPlaying( bool b ) {
180 if ( isPlaying == b ) { 180 if ( isPlaying == b ) {
181 return; 181 return;
182 } 182 }
183 isPlaying = b; 183 isPlaying = b;
184 isStoped = !b; 184 isStoped = !b;
185 emit playingToggled(b); 185 emit playingToggled(b);
186} 186}
187 187
188void MediaPlayerState::setStop( bool b ) { 188void MediaPlayerState::setStop( bool b ) {
189 if ( isStoped == b ) { 189 if ( isStoped == b ) {
190 return; 190 return;
191 } 191 }
192 isStoped = b; 192 isStoped = b;
193 emit stopToggled(b); 193 emit stopToggled(b);
194} 194}
195 195
196void MediaPlayerState::setPosition( long p ) { 196void MediaPlayerState::setPosition( long p ) {
197 if ( curPosition == p ) { 197 if ( curPosition == p ) {
198 return; 198 return;
199 } 199 }
200 curPosition = p; 200 curPosition = p;
201 emit positionChanged(p); 201 emit positionChanged(p);
202} 202}
203 203
204void MediaPlayerState::updatePosition( long p ){ 204void MediaPlayerState::updatePosition( long p ){
205 if ( curPosition == p ) { 205 if ( curPosition == p ) {
206 return; 206 return;
207 } 207 }
208 curPosition = p; 208 curPosition = p;
209 emit positionUpdated(p); 209 emit positionUpdated(p);
210} 210}
211 211
212void MediaPlayerState::setLength( long l ) { 212void MediaPlayerState::setLength( long l ) {
213 if ( curLength == l ) { 213 if ( curLength == l ) {
214 return; 214 return;
215 } 215 }
216 curLength = l; 216 curLength = l;
217 emit lengthChanged(l); 217 emit lengthChanged(l);
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index bc9b166..75e2979 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -118,388 +118,388 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
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
309PlayListWidget::~PlayListWidget() { 309PlayListWidget::~PlayListWidget() {
310 if ( d->current ) { 310 if ( d->current ) {
311 delete d->current; 311 delete d->current;
312 } 312 }
313 delete d; 313 delete d;
314} 314}
315 315
316 316
317void PlayListWidget::initializeStates() { 317void PlayListWidget::initializeStates() {
318 318
319 d->tbPlay->setOn( mediaPlayerState->playing() ); 319 d->tbPlay->setOn( mediaPlayerState->playing() );
320 d->tbLoop->setOn( mediaPlayerState->looping() ); 320 d->tbLoop->setOn( mediaPlayerState->looping() );
321 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 321 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
322 setPlaylist( true); 322 setPlaylist( true);
323} 323}
324 324
325 325
326void PlayListWidget::readConfig( Config& cfg ) { 326void PlayListWidget::readConfig( Config& cfg ) {
327 cfg.setGroup("PlayList"); 327 cfg.setGroup("PlayList");
328 QString currentString = cfg.readEntry("current", "" ); 328 QString currentString = cfg.readEntry("current", "" );
329 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 329 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
330 for ( int i = 0; i < noOfFiles; i++ ) { 330 for ( int i = 0; i < noOfFiles; i++ ) {
331 QString entryName; 331 QString entryName;
332 entryName.sprintf( "File%i", i + 1 ); 332 entryName.sprintf( "File%i", i + 1 );
333 QString linkFile = cfg.readEntry( entryName ); 333 QString linkFile = cfg.readEntry( entryName );
334 if(QFileInfo( linkFile).exists() ) { 334 if(QFileInfo( linkFile).exists() ) {
335 DocLnk lnk( linkFile ); 335 DocLnk lnk( linkFile );
336 if ( QFileInfo( lnk.file()).exists() || linkFile.find("http",0,TRUE) != -1) { 336 if ( QFileInfo( lnk.file()).exists() || linkFile.find("http",0,TRUE) != -1) {
337 d->selectedFiles->addToSelection( lnk ); 337 d->selectedFiles->addToSelection( lnk );
338 } 338 }
339 } 339 }
340 } 340 }
341 d->selectedFiles->setSelectedItem( currentString); 341 d->selectedFiles->setSelectedItem( currentString);
342} 342}
343 343
344 344
345void PlayListWidget::writeConfig( Config& cfg ) const { 345void PlayListWidget::writeConfig( Config& cfg ) const {
346 346
347 d->selectedFiles->writeCurrent( cfg); 347 d->selectedFiles->writeCurrent( cfg);
348 cfg.setGroup("PlayList"); 348 cfg.setGroup("PlayList");
349 int noOfFiles = 0; 349 int noOfFiles = 0;
350 d->selectedFiles->first(); 350 d->selectedFiles->first();
351 do { 351 do {
352 const DocLnk *lnk = d->selectedFiles->current(); 352 const DocLnk *lnk = d->selectedFiles->current();
353 if ( lnk ) { 353 if ( lnk ) {
354 QString entryName; 354 QString entryName;
355 entryName.sprintf( "File%i", noOfFiles + 1 ); 355 entryName.sprintf( "File%i", noOfFiles + 1 );
356 cfg.writeEntry( entryName, lnk->linkFile() ); 356 cfg.writeEntry( entryName, lnk->linkFile() );
357 // 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
358 // next time... 358 // next time...
359 if ( !QFile::exists( lnk->linkFile() ) ) { 359 if ( !QFile::exists( lnk->linkFile() ) ) {
360 // the way writing lnks doesn't really check for out 360 // the way writing lnks doesn't really check for out
361 // of disk space, but check it anyway. 361 // of disk space, but check it anyway.
362 if ( !lnk->writeLink() ) { 362 if ( !lnk->writeLink() ) {
363 QMessageBox::critical( 0, tr("Out of space"), 363 QMessageBox::critical( 0, tr("Out of space"),
364 tr( "There was a problem saving " 364 tr( "There was a problem saving "
365 "the playlist.\n" 365 "the playlist.\n"
366 "Your playlist " 366 "Your playlist "
367 "may be missing some entries\n" 367 "may be missing some entries\n"
368 "the next time you start it." ) 368 "the next time you start it." )
369 ); 369 );
370 } 370 }
371 } 371 }
372 noOfFiles++; 372 noOfFiles++;
373 } 373 }
374 } 374 }
375 while ( d->selectedFiles->next() ); 375 while ( d->selectedFiles->next() );
376 cfg.writeEntry("NumberOfFiles", noOfFiles ); 376 cfg.writeEntry("NumberOfFiles", noOfFiles );
377} 377}
378 378
379 379
380void PlayListWidget::addToSelection( const DocLnk& lnk ) { 380void PlayListWidget::addToSelection( const DocLnk& lnk ) {
381 d->setDocumentUsed = FALSE; 381 d->setDocumentUsed = FALSE;
382 if ( mediaPlayerState->playlist() ) { 382 if ( mediaPlayerState->playlist() ) {
383 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) 383 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" )
384 d->selectedFiles->addToSelection( lnk ); 384 d->selectedFiles->addToSelection( lnk );
385 } 385 }
386 else 386 else
387 mediaPlayerState->setPlaying( TRUE ); 387 mediaPlayerState->setPlaying( TRUE );
388} 388}
389 389
390 390
391void PlayListWidget::clearList() { 391void PlayListWidget::clearList() {
392 while ( first() ) { 392 while ( first() ) {
393 d->selectedFiles->removeSelected(); 393 d->selectedFiles->removeSelected();
394 } 394 }
395} 395}
396 396
397 397
398void PlayListWidget::addAllToList() { 398void PlayListWidget::addAllToList() {
399 DocLnkSet filesAll; 399 DocLnkSet filesAll;
400 Global::findDocuments(&filesAll, "video/*;audio/*"); 400 Global::findDocuments(&filesAll, "video/*;audio/*");
401 QListIterator<DocLnk> Adit( filesAll.children() ); 401 QListIterator<DocLnk> Adit( filesAll.children() );
402 for ( ; Adit.current(); ++Adit ) { 402 for ( ; Adit.current(); ++Adit ) {
403 if(QFileInfo(Adit.current()->file()).exists()) { 403 if(QFileInfo(Adit.current()->file()).exists()) {
404 d->selectedFiles->addToSelection( **Adit ); 404 d->selectedFiles->addToSelection( **Adit );
405 } 405 }
406 } 406 }
407} 407}
408 408
409 409
410void PlayListWidget::addAllMusicToList() { 410void PlayListWidget::addAllMusicToList() {
411 QListIterator<DocLnk> dit( files.children() ); 411 QListIterator<DocLnk> dit( files.children() );
412 for ( ; dit.current(); ++dit ) { 412 for ( ; dit.current(); ++dit ) {
413 if(QFileInfo(dit.current()->file()).exists()) { 413 if(QFileInfo(dit.current()->file()).exists()) {
414 d->selectedFiles->addToSelection( **dit ); 414 d->selectedFiles->addToSelection( **dit );
415 } 415 }
416 } 416 }
417} 417}
418 418
419 419
420void PlayListWidget::addAllVideoToList() { 420void PlayListWidget::addAllVideoToList() {
421 QListIterator<DocLnk> dit( vFiles.children() ); 421 QListIterator<DocLnk> dit( vFiles.children() );
422 for ( ; dit.current(); ++dit ) 422 for ( ; dit.current(); ++dit )
423 if(QFileInfo( dit.current()->file()).exists()) 423 if(QFileInfo( dit.current()->file()).exists())
424 d->selectedFiles->addToSelection( **dit ); 424 d->selectedFiles->addToSelection( **dit );
425} 425}
426 426
427 427
428void PlayListWidget::setDocument(const QString& fileref) { 428void PlayListWidget::setDocument(const QString& fileref) {
429 qDebug(fileref); 429 qDebug(fileref);
430 fromSetDocument = TRUE; 430 fromSetDocument = TRUE;
431 if ( fileref.isNull() ) { 431 if ( fileref.isNull() ) {
432 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." ) );
433 return; 433 return;
434 } 434 }
435 435
436 if(fileref.find("m3u",0,TRUE) != -1) { //is m3u 436 if(fileref.find("m3u",0,TRUE) != -1) { //is m3u
437 readm3u( fileref); 437 readm3u( fileref);
438 } else if(fileref.find("pls",0,TRUE) != -1) { //is pls 438 } else if(fileref.find("pls",0,TRUE) != -1) { //is pls
439 readPls( fileref); 439 readPls( fileref);
440 } else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist 440 } else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist
441 clearList(); 441 clearList();
442 loadList(DocLnk(fileref)); 442 loadList(DocLnk(fileref));
443 d->selectedFiles->first(); 443 d->selectedFiles->first();
444 } else { 444 } else {
445 clearList(); 445 clearList();
446 addToSelection( DocLnk( fileref ) ); 446 addToSelection( DocLnk( fileref ) );
447 d->setDocumentUsed = TRUE; 447 d->setDocumentUsed = TRUE;
448 mediaPlayerState->setPlaying( FALSE ); 448 mediaPlayerState->setPlaying( FALSE );
449 qApp->processEvents(); 449 qApp->processEvents();
450 mediaPlayerState->setPlaying( TRUE ); 450 mediaPlayerState->setPlaying( TRUE );
451 qApp->processEvents(); 451 qApp->processEvents();
452 setCaption(tr("OpiePlayer")); 452 setCaption(tr("OpiePlayer"));
453 } 453 }
454} 454}
455 455
456 456
457void PlayListWidget::setActiveWindow() { 457void PlayListWidget::setActiveWindow() {
458// qDebug("SETTING active window"); 458// qDebug("SETTING active window");
459 // 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
460 char origView = mediaPlayerState->view(); 460 char origView = mediaPlayerState->view();
461 mediaPlayerState->setView( 'l' ); // invalidate 461 mediaPlayerState->setView( 'l' ); // invalidate
462 mediaPlayerState->setView( origView ); // now switch back 462 mediaPlayerState->setView( origView ); // now switch back
463} 463}
464 464
465 465
466void PlayListWidget::useSelectedDocument() { 466void PlayListWidget::useSelectedDocument() {
467 d->setDocumentUsed = FALSE; 467 d->setDocumentUsed = FALSE;
468} 468}
469 469
470 470
471const DocLnk *PlayListWidget::current() { // this is fugly 471const DocLnk *PlayListWidget::current() { // this is fugly
472 472
473 switch (tabWidget->currentPageIndex()) { 473 switch (tabWidget->currentPageIndex()) {
474 case 0: //playlist 474 case 0: //playlist
475 { 475 {
476// qDebug("playlist"); 476// qDebug("playlist");
477 if ( mediaPlayerState->playlist() ) { 477 if ( mediaPlayerState->playlist() ) {
478 return d->selectedFiles->current(); 478 return d->selectedFiles->current();
479 } else if ( d->setDocumentUsed && d->current ) { 479 } else if ( d->setDocumentUsed && d->current ) {
480 return d->current; 480 return d->current;
481 } else { 481 } else {
482 return d->files->selected(); 482 return d->files->selected();
483 } 483 }
484 } 484 }
485 break; 485 break;
486 case 1://audio 486 case 1://audio
487 { 487 {
488// qDebug("audioView"); 488// qDebug("audioView");
489 QListIterator<DocLnk> dit( files.children() ); 489 QListIterator<DocLnk> dit( files.children() );
490 for ( ; dit.current(); ++dit ) { 490 for ( ; dit.current(); ++dit ) {
491 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { 491 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) {
492 insanityBool=TRUE; 492 insanityBool=TRUE;
493 return dit; 493 return dit;
494 } 494 }
495 } 495 }
496 } 496 }
497 break; 497 break;
498 case 2: // video 498 case 2: // video
499 { 499 {
500// qDebug("videoView"); 500// qDebug("videoView");
501 QListIterator<DocLnk> Vdit( vFiles.children() ); 501 QListIterator<DocLnk> Vdit( vFiles.children() );
502 for ( ; Vdit.current(); ++Vdit ) { 502 for ( ; Vdit.current(); ++Vdit ) {
503 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { 503 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) {
504 insanityBool=TRUE; 504 insanityBool=TRUE;
505 return Vdit; 505 return Vdit;