summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-02-25 00:26:33 (UTC)
committer llornkcor <llornkcor>2002-02-25 00:26:33 (UTC)
commitc0446b55fc32b7fdea9f58db06e40da703f5e8ff (patch) (unidiff)
treeb84cbcdf9d2687bb3e8672981a6e62577c98becb
parent146ed85c70bf6a288294e91baceb9af9ec5b8611 (diff)
downloadopie-c0446b55fc32b7fdea9f58db06e40da703f5e8ff.zip
opie-c0446b55fc32b7fdea9f58db06e40da703f5e8ff.tar.gz
opie-c0446b55fc32b7fdea9f58db06e40da703f5e8ff.tar.bz2
*** empty log message ***
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/audiodevice.cpp8
-rw-r--r--core/multimedia/opieplayer/loopcontrol.cpp16
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp47
-rw-r--r--core/multimedia/opieplayer/playlistwidget.h12
4 files changed, 44 insertions, 39 deletions
diff --git a/core/multimedia/opieplayer/audiodevice.cpp b/core/multimedia/opieplayer/audiodevice.cpp
index 59136af..11fd9e8 100644
--- a/core/multimedia/opieplayer/audiodevice.cpp
+++ b/core/multimedia/opieplayer/audiodevice.cpp
@@ -16,282 +16,282 @@
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20// L.J.Potter added better error code Fri 02-15-2002 14:37:47 20// L.J.Potter added better error code Fri 02-15-2002 14:37:47
21 21
22 22
23#include <stdlib.h> 23#include <stdlib.h>
24#include <stdio.h> 24#include <stdio.h>
25#include <qpe/qpeapplication.h> 25#include <qpe/qpeapplication.h>
26#include <qpe/config.h> 26#include <qpe/config.h>
27#include "audiodevice.h" 27#include "audiodevice.h"
28 28
29#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) 29#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
30#include "qpe/qcopenvelope_qws.h" 30#include "qpe/qcopenvelope_qws.h"
31#endif 31#endif
32 32
33#ifdef Q_WS_WIN 33#ifdef Q_WS_WIN
34#include <windows.h> 34#include <windows.h>
35#include <mmsystem.h> 35#include <mmsystem.h>
36#include <mmreg.h> 36#include <mmreg.h>
37#endif 37#endif
38 38
39#if defined(Q_WS_X11) || defined(Q_WS_QWS) 39#if defined(Q_WS_X11) || defined(Q_WS_QWS)
40#include <fcntl.h> 40#include <fcntl.h>
41#include <sys/ioctl.h> 41#include <sys/ioctl.h>
42#include <sys/soundcard.h> 42#include <sys/soundcard.h>
43#include <sys/stat.h> 43#include <sys/stat.h>
44#include <sys/time.h> 44#include <sys/time.h>
45#include <sys/types.h> 45#include <sys/types.h>
46#include <unistd.h> 46#include <unistd.h>
47#endif 47#endif
48 48
49#if defined(Q_OS_WIN32) 49#if defined(Q_OS_WIN32)
50static const int expectedBytesPerMilliSecond = 2 * 2 * 44000 / 1000; 50static const int expectedBytesPerMilliSecond = 2 * 2 * 44000 / 1000;
51static const int timerResolutionMilliSeconds = 30; 51static const int timerResolutionMilliSeconds = 30;
52static const int sound_fragment_bytes = timerResolutionMilliSeconds * expectedBytesPerMilliSecond; 52static const int sound_fragment_bytes = timerResolutionMilliSeconds * expectedBytesPerMilliSecond;
53#else 53#else
54# if defined(QT_QWS_IPAQ) 54# if defined(QT_QWS_IPAQ)
55static const int sound_fragment_shift = 14; 55static const int sound_fragment_shift = 14;
56# else 56# else
57static const int sound_fragment_shift = 16; 57static const int sound_fragment_shift = 16;
58# endif 58# endif
59static const int sound_fragment_bytes = (1<<sound_fragment_shift); 59static const int sound_fragment_bytes = (1<<sound_fragment_shift);
60#endif 60#endif
61 61
62 62
63class AudioDevicePrivate { 63class AudioDevicePrivate {
64public: 64public:
65 int handle; 65 int handle;
66 unsigned int frequency; 66 unsigned int frequency;
67 unsigned int channels; 67 unsigned int channels;
68 unsigned int bytesPerSample; 68 unsigned int bytesPerSample;
69 unsigned int bufferSize; 69 unsigned int bufferSize;
70#ifndef Q_OS_WIN32 70#ifndef Q_OS_WIN32
71 bool can_GETOSPACE; 71 bool can_GETOSPACE;
72 char* unwrittenBuffer; 72 char* unwrittenBuffer;
73 unsigned int unwritten; 73 unsigned int unwritten;
74#endif 74#endif
75 75
76 static int dspFd; 76 static int dspFd;
77 static bool muted; 77 static bool muted;
78 static unsigned int leftVolume; 78 static unsigned int leftVolume;
79 static unsigned int rightVolume; 79 static unsigned int rightVolume;
80}; 80};
81 81
82 82
83#ifdef Q_WS_QWS 83#ifdef Q_WS_QWS
84// This is for keeping the device open in-between playing files when 84// This is for keeping the device open in-between playing files when
85// the device makes clicks and it starts to drive you insane! :) 85// the device makes clicks and it starts to drive you insane! :)
86// Best to have the device not open when not using it though 86// Best to have the device not open when not using it though
87//#define KEEP_DEVICE_OPEN 87//#define KEEP_DEVICE_OPEN
88#endif 88#endif
89 89
90 90
91int AudioDevicePrivate::dspFd = 0; 91int AudioDevicePrivate::dspFd = 0;
92bool AudioDevicePrivate::muted = FALSE; 92bool AudioDevicePrivate::muted = FALSE;
93unsigned int AudioDevicePrivate::leftVolume = 0; 93unsigned int AudioDevicePrivate::leftVolume = 0;
94unsigned int AudioDevicePrivate::rightVolume = 0; 94unsigned int AudioDevicePrivate::rightVolume = 0;
95 95
96 96
97void AudioDevice::getVolume( unsigned int& leftVolume, unsigned int& rightVolume, bool &muted ) { 97void AudioDevice::getVolume( unsigned int& leftVolume, unsigned int& rightVolume, bool &muted ) {
98 muted = AudioDevicePrivate::muted; 98 muted = AudioDevicePrivate::muted;
99 unsigned int volume; 99 unsigned int volume;
100#ifdef Q_OS_WIN32 100#ifdef Q_OS_WIN32
101 HWAVEOUT handle; 101 HWAVEOUT handle;
102 WAVEFORMATEX formatData; 102 WAVEFORMATEX formatData;
103 formatData.cbSize = sizeof(WAVEFORMATEX); 103 formatData.cbSize = sizeof(WAVEFORMATEX);
104 formatData.wFormatTag = WAVE_FORMAT_PCM; 104 formatData.wFormatTag = WAVE_FORMAT_PCM;
105 formatData.nAvgBytesPerSec = 4 * 44000; 105 formatData.nAvgBytesPerSec = 4 * 44000;
106 formatData.nBlockAlign = 4; 106 formatData.nBlockAlign = 4;
107 formatData.nChannels = 2; 107 formatData.nChannels = 2;
108 formatData.nSamplesPerSec = 44000; 108 formatData.nSamplesPerSec = 44000;
109 formatData.wBitsPerSample = 16; 109 formatData.wBitsPerSample = 16;
110 waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL); 110 waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL);
111 if ( waveOutGetVolume( handle, (LPDWORD)&volume ) ) 111 if ( waveOutGetVolume( handle, (LPDWORD)&volume ) )
112 qDebug( "get volume of audio device failed" ); 112// qDebug( "get volume of audio device failed" );
113 waveOutClose( handle ); 113 waveOutClose( handle );
114 leftVolume = volume & 0xFFFF; 114 leftVolume = volume & 0xFFFF;
115 rightVolume = volume >> 16; 115 rightVolume = volume >> 16;
116#else 116#else
117 int mixerHandle = open( "/dev/mixer", O_RDWR ); 117 int mixerHandle = open( "/dev/mixer", O_RDWR );
118 if ( mixerHandle >= 0 ) { 118 if ( mixerHandle >= 0 ) {
119 if(ioctl( mixerHandle, MIXER_READ(0), &volume )==-1) 119 if(ioctl( mixerHandle, MIXER_READ(0), &volume )==-1)
120 perror("ioctl(\"MIXER_READ\")"); 120 perror("ioctl(\"MIXER_READ\")");
121 close( mixerHandle ); 121 close( mixerHandle );
122 } else 122 } else
123 perror("open(\"/dev/mixer\")"); 123 perror("open(\"/dev/mixer\")");
124 leftVolume = ((volume & 0x00FF) << 16) / 101; 124 leftVolume = ((volume & 0x00FF) << 16) / 101;
125 rightVolume = ((volume & 0xFF00) << 8) / 101; 125 rightVolume = ((volume & 0xFF00) << 8) / 101;
126#endif 126#endif
127} 127}
128 128
129 129
130void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, bool muted ) { 130void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, bool muted ) {
131 AudioDevicePrivate::muted = muted; 131 AudioDevicePrivate::muted = muted;
132 if ( muted ) { 132 if ( muted ) {
133 AudioDevicePrivate::leftVolume = leftVolume; 133 AudioDevicePrivate::leftVolume = leftVolume;
134 AudioDevicePrivate::rightVolume = rightVolume; 134 AudioDevicePrivate::rightVolume = rightVolume;
135 leftVolume = 0; 135 leftVolume = 0;
136 rightVolume = 0; 136 rightVolume = 0;
137 } else { 137 } else {
138 leftVolume = ( (int) leftVolume < 0 ) ? 0 : (( leftVolume > 0xFFFF ) ? 0xFFFF : leftVolume ); 138 leftVolume = ( (int) leftVolume < 0 ) ? 0 : (( leftVolume > 0xFFFF ) ? 0xFFFF : leftVolume );
139 rightVolume = ( (int)rightVolume < 0 ) ? 0 : (( rightVolume > 0xFFFF ) ? 0xFFFF : rightVolume ); 139 rightVolume = ( (int)rightVolume < 0 ) ? 0 : (( rightVolume > 0xFFFF ) ? 0xFFFF : rightVolume );
140 } 140 }
141#ifdef Q_OS_WIN32 141#ifdef Q_OS_WIN32
142 HWAVEOUT handle; 142 HWAVEOUT handle;
143 WAVEFORMATEX formatData; 143 WAVEFORMATEX formatData;
144 formatData.cbSize = sizeof(WAVEFORMATEX); 144 formatData.cbSize = sizeof(WAVEFORMATEX);
145 formatData.wFormatTag = WAVE_FORMAT_PCM; 145 formatData.wFormatTag = WAVE_FORMAT_PCM;
146 formatData.nAvgBytesPerSec = 4 * 44000; 146 formatData.nAvgBytesPerSec = 4 * 44000;
147 formatData.nBlockAlign = 4; 147 formatData.nBlockAlign = 4;
148 formatData.nChannels = 2; 148 formatData.nChannels = 2;
149 formatData.nSamplesPerSec = 44000; 149 formatData.nSamplesPerSec = 44000;
150 formatData.wBitsPerSample = 16; 150 formatData.wBitsPerSample = 16;
151 waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL); 151 waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL);
152 unsigned int volume = (rightVolume << 16) | leftVolume; 152 unsigned int volume = (rightVolume << 16) | leftVolume;
153 if ( waveOutSetVolume( handle, volume ) ) 153 if ( waveOutSetVolume( handle, volume ) )
154 qDebug( "set volume of audio device failed" ); 154// qDebug( "set volume of audio device failed" );
155 waveOutClose( handle ); 155 waveOutClose( handle );
156#else 156#else
157 // Volume can be from 0 to 100 which is 101 distinct values 157 // Volume can be from 0 to 100 which is 101 distinct values
158 unsigned int rV = (rightVolume * 101) >> 16; 158 unsigned int rV = (rightVolume * 101) >> 16;
159 159
160# if 0 160# if 0
161 unsigned int lV = (leftVolume * 101) >> 16; 161 unsigned int lV = (leftVolume * 101) >> 16;
162 unsigned int volume = ((rV << 8) & 0xFF00) | (lV & 0x00FF); 162 unsigned int volume = ((rV << 8) & 0xFF00) | (lV & 0x00FF);
163 int mixerHandle = 0; 163 int mixerHandle = 0;
164 if ( ( mixerHandle = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 164 if ( ( mixerHandle = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
165 if(ioctl( mixerHandle, MIXER_WRITE(0), &volume ) ==-1) 165 if(ioctl( mixerHandle, MIXER_WRITE(0), &volume ) ==-1)
166 perror("ioctl(\"MIXER_WRITE\")"); 166 perror("ioctl(\"MIXER_WRITE\")");
167 close( mixerHandle ); 167 close( mixerHandle );
168 } else 168 } else
169 perror("open(\"/dev/mixer\")"); 169 perror("open(\"/dev/mixer\")");
170 170
171# else 171# else
172 // This is the way this has to be done now I guess, doesn't allow for 172 // This is the way this has to be done now I guess, doesn't allow for
173 // independant right and left channel setting, or setting for different outputs 173 // independant right and left channel setting, or setting for different outputs
174 Config cfg("Sound"); 174 Config cfg("Sound");
175 cfg.setGroup("System"); 175 cfg.setGroup("System");
176 cfg.writeEntry("Volume",(int)rV); 176 cfg.writeEntry("Volume",(int)rV);
177# endif 177# endif
178 178
179#endif 179#endif
180// qDebug( "setting volume to: 0x%x", volume ); 180// qDebug( "setting volume to: 0x%x", volume );
181#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) 181#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
182 // Send notification that the volume has changed 182 // Send notification that the volume has changed
183 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted; 183 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted;
184#endif 184#endif
185} 185}
186 186
187 187
188 188
189 189
190AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) { 190AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) {
191 d = new AudioDevicePrivate; 191 d = new AudioDevicePrivate;
192 d->frequency = f; 192 d->frequency = f;
193 d->channels = chs; 193 d->channels = chs;
194 d->bytesPerSample = bps; 194 d->bytesPerSample = bps;
195 qDebug("%d",bps); 195// qDebug("%d",bps);
196 int format=0; 196 int format=0;
197 if( bps == 8) format = AFMT_U8; 197 if( bps == 8) format = AFMT_U8;
198 else if( bps <= 0) format = AFMT_S16_LE; 198 else if( bps <= 0) format = AFMT_S16_LE;
199 else format = AFMT_S16_LE; 199 else format = AFMT_S16_LE;
200 200
201 qDebug("AD- freq %d, channels %d, b/sample %d, bitrate %d",f,chs,bps,format); 201// qDebug("AD- freq %d, channels %d, b/sample %d, bitrate %d",f,chs,bps,format);
202 connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) ); 202 connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) );
203 203
204 204
205 int fragments = 0x10000 * 8 + sound_fragment_shift; 205 int fragments = 0x10000 * 8 + sound_fragment_shift;
206 int capabilities = 0; 206 int capabilities = 0;
207 207
208#ifdef KEEP_DEVICE_OPEN 208#ifdef KEEP_DEVICE_OPEN
209 if ( AudioDevicePrivate::dspFd == 0 ) { 209 if ( AudioDevicePrivate::dspFd == 0 ) {
210#endif 210#endif
211 if ( ( d->handle = ::open( "/dev/dsp", O_WRONLY ) ) < 0 ) { 211 if ( ( d->handle = ::open( "/dev/dsp", O_WRONLY ) ) < 0 ) {
212 perror("open(\"/dev/dsp\") sending to /dev/null instead"); 212 perror("open(\"/dev/dsp\") sending to /dev/null instead");
213 d->handle = ::open( "/dev/null", O_WRONLY ); 213 d->handle = ::open( "/dev/null", O_WRONLY );
214 } 214 }
215#ifdef KEEP_DEVICE_OPEN 215#ifdef KEEP_DEVICE_OPEN
216 AudioDevicePrivate::dspFd = d->handle; 216 AudioDevicePrivate::dspFd = d->handle;
217 } else { 217 } else {
218 d->handle = AudioDevicePrivate::dspFd; 218 d->handle = AudioDevicePrivate::dspFd;
219 } 219 }
220#endif 220#endif
221 221
222 if(ioctl( d->handle, SNDCTL_DSP_GETCAPS, &capabilities )==-1) 222 if(ioctl( d->handle, SNDCTL_DSP_GETCAPS, &capabilities )==-1)
223 perror("ioctl(\"SNDCTL_DSP_GETCAPS\")"); 223 perror("ioctl(\"SNDCTL_DSP_GETCAPS\")");
224 if(ioctl( d->handle, SNDCTL_DSP_SETFRAGMENT, &fragments )==-1) 224 if(ioctl( d->handle, SNDCTL_DSP_SETFRAGMENT, &fragments )==-1)
225 perror("ioctl(\"SNDCTL_DSP_SETFRAGMENT\")"); 225 perror("ioctl(\"SNDCTL_DSP_SETFRAGMENT\")");
226 if(ioctl( d->handle, SNDCTL_DSP_SETFMT, & format )==-1) 226 if(ioctl( d->handle, SNDCTL_DSP_SETFMT, & format )==-1)
227 perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); 227 perror("ioctl(\"SNDCTL_DSP_SETFMT\")");
228 qDebug("freq %d", d->frequency); 228 qDebug("freq %d", d->frequency);
229 if(ioctl( d->handle, SNDCTL_DSP_SPEED, &d->frequency )==-1) 229 if(ioctl( d->handle, SNDCTL_DSP_SPEED, &d->frequency )==-1)
230 perror("ioctl(\"SNDCTL_DSP_SPEED\")"); 230 perror("ioctl(\"SNDCTL_DSP_SPEED\")");
231 qDebug("channels %d",d->channels); 231 qDebug("channels %d",d->channels);
232 if ( ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels ) == -1 ) { 232 if ( ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels ) == -1 ) {
233 d->channels = ( d->channels == 1 ) ? 2 : d->channels; 233 d->channels = ( d->channels == 1 ) ? 2 : d->channels;
234 if(ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels )==-1) 234 if(ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels )==-1)
235 perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); 235 perror("ioctl(\"SNDCTL_DSP_CHANNELS\")");
236 } 236 }
237 237
238 d->bufferSize = sound_fragment_bytes; 238 d->bufferSize = sound_fragment_bytes;
239 d->unwrittenBuffer = new char[d->bufferSize]; 239 d->unwrittenBuffer = new char[d->bufferSize];
240 d->unwritten = 0; 240 d->unwritten = 0;
241 d->can_GETOSPACE = TRUE; // until we find otherwise 241 d->can_GETOSPACE = TRUE; // until we find otherwise
242 242
243 //if ( chs != d->channels ) qDebug( "Wanted %d, got %d channels", chs, d->channels ); 243 //if ( chs != d->channels ) qDebug( "Wanted %d, got %d channels", chs, d->channels );
244 //if ( f != d->frequency ) qDebug( "wanted %dHz, got %dHz", f, d->frequency ); 244 //if ( f != d->frequency ) qDebug( "wanted %dHz, got %dHz", f, d->frequency );
245 //if ( capabilities & DSP_CAP_BATCH ) qDebug( "Sound card has local buffer" ); 245 //if ( capabilities & DSP_CAP_BATCH ) qDebug( "Sound card has local buffer" );
246 //if ( capabilities & DSP_CAP_REALTIME )qDebug( "Sound card has realtime sync" ); 246 //if ( capabilities & DSP_CAP_REALTIME )qDebug( "Sound card has realtime sync" );
247 //if ( capabilities & DSP_CAP_TRIGGER ) qDebug( "Sound card has precise trigger" ); 247 //if ( capabilities & DSP_CAP_TRIGGER ) qDebug( "Sound card has precise trigger" );
248 //if ( capabilities & DSP_CAP_MMAP ) qDebug( "Sound card can mmap" ); 248 //if ( capabilities & DSP_CAP_MMAP ) qDebug( "Sound card can mmap" );
249} 249}
250 250
251 251
252AudioDevice::~AudioDevice() { 252AudioDevice::~AudioDevice() {
253#ifdef Q_OS_WIN32 253#ifdef Q_OS_WIN32
254 waveOutClose( (HWAVEOUT)d->handle ); 254 waveOutClose( (HWAVEOUT)d->handle );
255#else 255#else
256# ifndef KEEP_DEVICE_OPEN 256# ifndef KEEP_DEVICE_OPEN
257 close( d->handle ); // Now it should be safe to shut the handle 257 close( d->handle ); // Now it should be safe to shut the handle
258# endif 258# endif
259 delete d->unwrittenBuffer; 259 delete d->unwrittenBuffer;
260 delete d; 260 delete d;
261#endif 261#endif
262} 262}
263 263
264 264
265void AudioDevice::volumeChanged( bool muted ) 265void AudioDevice::volumeChanged( bool muted )
266{ 266{
267 AudioDevicePrivate::muted = muted; 267 AudioDevicePrivate::muted = muted;
268} 268}
269 269
270 270
271void AudioDevice::write( char *buffer, unsigned int length ) 271void AudioDevice::write( char *buffer, unsigned int length )
272{ 272{
273#ifdef Q_OS_WIN32 273#ifdef Q_OS_WIN32
274 // returns immediately and (to be implemented) emits completedIO() when finished writing 274 // returns immediately and (to be implemented) emits completedIO() when finished writing
275 WAVEHDR *lpWaveHdr = (WAVEHDR *)malloc( sizeof(WAVEHDR) ); 275 WAVEHDR *lpWaveHdr = (WAVEHDR *)malloc( sizeof(WAVEHDR) );
276 // maybe the buffer should be copied so that this fool proof, but its a performance hit 276 // maybe the buffer should be copied so that this fool proof, but its a performance hit
277 lpWaveHdr->lpData = buffer; 277 lpWaveHdr->lpData = buffer;
278 lpWaveHdr->dwBufferLength = length; 278 lpWaveHdr->dwBufferLength = length;
279 lpWaveHdr->dwFlags = 0L; 279 lpWaveHdr->dwFlags = 0L;
280 lpWaveHdr->dwLoops = 0L; 280 lpWaveHdr->dwLoops = 0L;
281 waveOutPrepareHeader( (HWAVEOUT)d->handle, lpWaveHdr, sizeof(WAVEHDR) ); 281 waveOutPrepareHeader( (HWAVEOUT)d->handle, lpWaveHdr, sizeof(WAVEHDR) );
282 // waveOutWrite returns immediately. the data is sent in the background. 282 // waveOutWrite returns immediately. the data is sent in the background.
283 if ( waveOutWrite( (HWAVEOUT)d->handle, lpWaveHdr, sizeof(WAVEHDR) ) ) 283 if ( waveOutWrite( (HWAVEOUT)d->handle, lpWaveHdr, sizeof(WAVEHDR) ) )
284 qDebug( "failed to write block to audio device" ); 284 qDebug( "failed to write block to audio device" );
285 // emit completedIO(); 285 // emit completedIO();
286#else 286#else
287 int t = ::write( d->handle, buffer, length ); 287 int t = ::write( d->handle, buffer, length );
288 if ( t<0 ) t = 0; 288 if ( t<0 ) t = 0;
289 if ( t != (int)length) { 289 if ( t != (int)length) {
290 qDebug("Ahhh!! memcpys 1"); 290 qDebug("Ahhh!! memcpys 1");
291 memcpy(d->unwrittenBuffer,buffer+t,length-t); 291 memcpy(d->unwrittenBuffer,buffer+t,length-t);
292 d->unwritten = length-t; 292 d->unwritten = length-t;
293 } 293 }
294#endif 294#endif
295} 295}
296 296
297 297
diff --git a/core/multimedia/opieplayer/loopcontrol.cpp b/core/multimedia/opieplayer/loopcontrol.cpp
index 859a67a..1ae0059 100644
--- a/core/multimedia/opieplayer/loopcontrol.cpp
+++ b/core/multimedia/opieplayer/loopcontrol.cpp
@@ -142,200 +142,200 @@ void LoopControl::timerEvent( QTimerEvent *te ) {
142 mediaPlayerState->updatePosition( current_frame ); 142 mediaPlayerState->updatePosition( current_frame );
143 } 143 }
144 } 144 }
145 145
146 if ( !moreVideo && !moreAudio ) { 146 if ( !moreVideo && !moreAudio ) {
147 mediaPlayerState->setPlaying( FALSE ); 147 mediaPlayerState->setPlaying( FALSE );
148 mediaPlayerState->setNext(); 148 mediaPlayerState->setNext();
149 } 149 }
150} 150}
151 151
152 152
153void LoopControl::setPosition( long pos ) { 153void LoopControl::setPosition( long pos ) {
154 audioMutex->lock(); 154 audioMutex->lock();
155 155
156 if ( hasVideoChannel && hasAudioChannel ) { 156 if ( hasVideoChannel && hasAudioChannel ) {
157 playtime.restart(); 157 playtime.restart();
158 playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) ); 158 playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) );
159 current_frame = pos + 1; 159 current_frame = pos + 1;
160 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); 160 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream );
161 prev_frame = current_frame - 1; 161 prev_frame = current_frame - 1;
162 currentSample = (int)( (double)current_frame * freq / framerate ); 162 currentSample = (int)( (double)current_frame * freq / framerate );
163 mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream ); 163 mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream );
164 audioSampleCounter = currentSample - 1; 164 audioSampleCounter = currentSample - 1;
165 } else if ( hasVideoChannel ) { 165 } else if ( hasVideoChannel ) {
166 playtime.restart(); 166 playtime.restart();
167 playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) ); 167 playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) );
168 current_frame = pos + 1; 168 current_frame = pos + 1;
169 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); 169 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream );
170 prev_frame = current_frame - 1; 170 prev_frame = current_frame - 1;
171 } else if ( hasAudioChannel ) { 171 } else if ( hasAudioChannel ) {
172 playtime.restart(); 172 playtime.restart();
173 playtime = playtime.addMSecs( long((double)-pos * 1000.0 / freq) ); 173 playtime = playtime.addMSecs( long((double)-pos * 1000.0 / freq) );
174 currentSample = pos + 1; 174 currentSample = pos + 1;
175 mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream ); 175 mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream );
176 audioSampleCounter = currentSample - 1; 176 audioSampleCounter = currentSample - 1;
177 } 177 }
178 178
179 audioMutex->unlock(); 179 audioMutex->unlock();
180} 180}
181 181
182 182
183void LoopControl::startVideo() { 183void LoopControl::startVideo() {
184 184
185 if ( moreVideo ) { 185 if ( moreVideo ) {
186 186
187 if ( mediaPlayerState->curDecoder() ) { 187 if ( mediaPlayerState->curDecoder() ) {
188 188
189 if ( hasAudioChannel && !isMuted ) { 189 if ( hasAudioChannel && !isMuted ) {
190 190
191 current_frame = long( playtime.elapsed() * framerate / 1000 ); 191 current_frame = long( playtime.elapsed() * framerate / 1000 );
192 192
193 if ( prev_frame != -1 && current_frame <= prev_frame ) 193 if ( prev_frame != -1 && current_frame <= prev_frame )
194 return; 194 return;
195 195
196 } else { 196 } else {
197 // Don't skip 197 // Don't skip
198 current_frame++; 198 current_frame++;
199 } 199 }
200 200
201 if ( prev_frame == -1 || current_frame > prev_frame ) { 201 if ( prev_frame == -1 || current_frame > prev_frame ) {
202 if ( current_frame > prev_frame + 1 ) { 202 if ( current_frame > prev_frame + 1 ) {
203 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); 203 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream );
204 } 204 }
205 moreVideo = videoUI->playVideo(); 205 moreVideo = videoUI->playVideo();
206 prev_frame = current_frame; 206 prev_frame = current_frame;
207 } 207 }
208 208
209 } else { 209 } else {
210 210
211 moreVideo = FALSE; 211 moreVideo = FALSE;
212 killTimer( videoId ); 212 killTimer( videoId );
213 213
214 } 214 }
215 215
216 } 216 }
217} 217}
218 218
219 219
220void LoopControl::startAudio() { 220void LoopControl::startAudio() {
221 221
222 audioMutex->lock(); 222 audioMutex->lock();
223 223
224 if ( moreAudio ) { 224 if ( moreAudio ) {
225 225
226 if ( !isMuted && mediaPlayerState->curDecoder() ) { 226 if ( !isMuted && mediaPlayerState->curDecoder() ) {
227 227
228 currentSample = audioSampleCounter + 1; 228 currentSample = audioSampleCounter + 1;
229 229
230 if ( currentSample != audioSampleCounter + 1 ) 230 if ( currentSample != audioSampleCounter + 1 )
231 qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter); 231 qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter);
232 232
233 long samplesRead = 0; 233 long samplesRead = 0;
234 bool readOk=mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, 1024, samplesRead, stream ); 234 bool readOk=mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, 1024, samplesRead, stream );
235 long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000; 235 long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000;
236 long sampleWaitTime = currentSample - sampleWeShouldBeAt; 236 long sampleWaitTime = currentSample - sampleWeShouldBeAt;
237 237
238// if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 5000 ) ) { 238 if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 20000 ) ) {
239// usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) ); 239 usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) );
240// } 240 }
241// else if ( sampleWaitTime <= -5000 ) { 241 else if ( sampleWaitTime <= -5000 ) {
242// qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt ); 242 qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt );
243// //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream ); 243 //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream );
244// currentSample = sampleWeShouldBeAt; 244 currentSample = sampleWeShouldBeAt;
245// } 245 }
246 246
247 audioDevice->write( audioBuffer, samplesRead * 2 * channels ); 247 audioDevice->write( audioBuffer, samplesRead * 2 * channels );
248 audioSampleCounter = currentSample + samplesRead - 1; 248 audioSampleCounter = currentSample + samplesRead - 1;
249 249
250 moreAudio = readOk && (audioSampleCounter <= total_audio_samples); 250 moreAudio = readOk && (audioSampleCounter <= total_audio_samples);
251 251
252 } else { 252 } else {
253 253
254 moreAudio = FALSE; 254 moreAudio = FALSE;
255 255
256 } 256 }
257 257
258 } 258 }
259 259
260 audioMutex->unlock(); 260 audioMutex->unlock();
261} 261}
262 262
263 263
264void LoopControl::killTimers() { 264void LoopControl::killTimers() {
265 265
266 audioMutex->lock(); 266 audioMutex->lock();
267 267
268 if ( hasVideoChannel ) 268 if ( hasVideoChannel )
269 killTimer( videoId ); 269 killTimer( videoId );
270 killTimer( sliderId ); 270 killTimer( sliderId );
271 threadOkToGo = FALSE; 271 threadOkToGo = FALSE;
272 272
273 audioMutex->unlock(); 273 audioMutex->unlock();
274} 274}
275 275
276 276
277void LoopControl::startTimers() { 277void LoopControl::startTimers() {
278 278
279 audioMutex->lock(); 279 audioMutex->lock();
280 280
281 moreVideo = FALSE; 281 moreVideo = FALSE;
282 moreAudio = FALSE; 282 moreAudio = FALSE;
283 283
284 if ( hasVideoChannel ) { 284 if ( hasVideoChannel ) {
285 moreVideo = TRUE; 285 moreVideo = TRUE;
286 int mSecsBetweenFrames = (int)(100 / framerate); // 10% of the real value 286 int mSecsBetweenFrames = (int)(100 / framerate); // 10% of the real value
287 videoId = startTimer( mSecsBetweenFrames ); 287 videoId = startTimer( mSecsBetweenFrames );
288 } 288 }
289 289
290 if ( hasAudioChannel ) { 290 if ( hasAudioChannel ) {
291 moreAudio = TRUE; 291 moreAudio = TRUE;
292 threadOkToGo = TRUE; 292 threadOkToGo = TRUE;
293 } 293 }
294 294
295 sliderId = startTimer( 300 ); // update slider every 1/3 second 295 sliderId = startTimer( 300 ); // update slider every 1/3 second
296 296
297 audioMutex->unlock(); 297 audioMutex->unlock();
298} 298}
299 299
300 300
301void LoopControl::setPaused( bool pause ) { 301void LoopControl::setPaused( bool pause ) {
302 302
303 if ( !mediaPlayerState->curDecoder() || !mediaPlayerState->curDecoder()->isOpen() ) 303 if ( !mediaPlayerState->curDecoder() || !mediaPlayerState->curDecoder()->isOpen() )
304 return; 304 return;
305 305
306 if ( pause ) { 306 if ( pause ) {
307 killTimers(); 307 killTimers();
308 } else { 308 } else {
309 // Force an update of the position 309 // Force an update of the position
310 mediaPlayerState->setPosition( mediaPlayerState->position() + 1 ); 310 mediaPlayerState->setPosition( mediaPlayerState->position() + 1 );
311 mediaPlayerState->setPosition( mediaPlayerState->position() - 1 ); 311 mediaPlayerState->setPosition( mediaPlayerState->position() - 1 );
312 // Just like we never stopped 312 // Just like we never stopped
313 startTimers(); 313 startTimers();
314 } 314 }
315} 315}
316 316
317 317
318void LoopControl::stop( bool willPlayAgainShortly ) { 318void LoopControl::stop( bool willPlayAgainShortly ) {
319 319
320#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 320#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
321 if ( !willPlayAgainShortly && disabledSuspendScreenSaver ) { 321 if ( !willPlayAgainShortly && disabledSuspendScreenSaver ) {
322 disabledSuspendScreenSaver = FALSE; 322 disabledSuspendScreenSaver = FALSE;
323 // Re-enable the suspend mode 323 // Re-enable the suspend mode
324 QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 324 QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
325 } 325 }
326#endif 326#endif
327 327
328 if ( mediaPlayerState->curDecoder() && mediaPlayerState->curDecoder()->isOpen() ) { 328 if ( mediaPlayerState->curDecoder() && mediaPlayerState->curDecoder()->isOpen() ) {
329 329
330 killTimers(); 330 killTimers();
331 331
332 audioMutex->lock(); 332 audioMutex->lock();
333 333
334 mediaPlayerState->curDecoder()->close(); 334 mediaPlayerState->curDecoder()->close();
335 335
336 if ( audioDevice ) { 336 if ( audioDevice ) {
337 delete audioDevice; 337 delete audioDevice;
338 delete audioBuffer; 338 delete audioBuffer;
339 audioDevice = 0; 339 audioDevice = 0;
340 audioBuffer = 0; 340 audioBuffer = 0;
341 } 341 }
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index 4e1543e..269aed8 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -1,332 +1,337 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include <qpe/qpemenubar.h> 20#include <qpe/qpemenubar.h>
21#include <qpe/qpetoolbar.h> 21#include <qpe/qpetoolbar.h>
22#include <qpe/fileselector.h> 22#include <qpe/fileselector.h>
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24 24
25#include <qpe/applnk.h> 25#include <qpe/applnk.h>
26#include <qpe/config.h> 26#include <qpe/config.h>
27#include <qpe/global.h> 27#include <qpe/global.h>
28#include <qpe/resource.h> 28#include <qpe/resource.h>
29#include <qaction.h> 29#include <qaction.h>
30#include <qimage.h> 30#include <qimage.h>
31#include <qfile.h> 31#include <qfile.h>
32#include <qlayout.h> 32#include <qlayout.h>
33#include <qlabel.h> 33#include <qlabel.h>
34#include <qlist.h> 34#include <qlist.h>
35#include <qlistbox.h> 35#include <qlistbox.h>
36#include <qmainwindow.h> 36#include <qmainwindow.h>
37#include <qmessagebox.h> 37#include <qmessagebox.h>
38#include <qtoolbutton.h> 38#include <qtoolbutton.h>
39#include <qtabwidget.h> 39#include <qtabwidget.h>
40#include <qlistview.h> 40#include <qlistview.h>
41#include <qpoint.h> 41#include <qpoint.h>
42#include <qtimer.h> 42//#include <qtimer.h>
43 43
44#include "playlistselection.h" 44#include "playlistselection.h"
45#include "playlistwidget.h" 45#include "playlistwidget.h"
46#include "mediaplayerstate.h" 46#include "mediaplayerstate.h"
47 47
48#include <stdlib.h> 48#include <stdlib.h>
49 49
50#define BUTTONS_ON_TOOLBAR 50#define BUTTONS_ON_TOOLBAR
51#define SIDE_BUTTONS 51#define SIDE_BUTTONS
52#define CAN_SAVE_LOAD_PLAYLISTS 52#define CAN_SAVE_LOAD_PLAYLISTS
53 53
54extern MediaPlayerState *mediaPlayerState; 54extern MediaPlayerState *mediaPlayerState;
55 55
56// class myFileSelector { 56// class myFileSelector {
57 57
58// }; 58// };
59class PlayListWidgetPrivate { 59class PlayListWidgetPrivate {
60public: 60public:
61 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; 61 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove;
62 QFrame *playListFrame; 62 QFrame *playListFrame;
63 FileSelector *files; 63 FileSelector *files;
64 PlayListSelection *selectedFiles; 64 PlayListSelection *selectedFiles;
65 bool setDocumentUsed; 65 bool setDocumentUsed;
66 DocLnk *current; 66 DocLnk *current;
67}; 67};
68 68
69 69
70class ToolButton : public QToolButton { 70class ToolButton : public QToolButton {
71public: 71public:
72 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) 72 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE )
73 : QToolButton( parent, name ) { 73 : QToolButton( parent, name ) {
74 setTextLabel( name ); 74 setTextLabel( name );
75 setPixmap( Resource::loadPixmap( icon ) ); 75 setPixmap( Resource::loadPixmap( icon ) );
76 setAutoRaise( TRUE ); 76 setAutoRaise( TRUE );
77 setFocusPolicy( QWidget::NoFocus ); 77 setFocusPolicy( QWidget::NoFocus );
78 setToggleButton( t ); 78 setToggleButton( t );
79 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); 79 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
80 QPEMenuToolFocusManager::manager()->addWidget( this ); 80 QPEMenuToolFocusManager::manager()->addWidget( this );
81 } 81 }
82}; 82};
83 83
84 84
85class MenuItem : public QAction { 85class MenuItem : public QAction {
86public: 86public:
87 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) 87 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot )
88 : QAction( text, QString::null, 0, 0 ) { 88 : QAction( text, QString::null, 0, 0 ) {
89 connect( this, SIGNAL( activated() ), handler, slot ); 89 connect( this, SIGNAL( activated() ), handler, slot );
90 addTo( parent ); 90 addTo( parent );
91 } 91 }
92}; 92};
93 93
94 94
95PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 95PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
96 : QMainWindow( parent, name, fl ) { 96 : QMainWindow( parent, name, fl ) {
97 97
98 d = new PlayListWidgetPrivate; 98 d = new PlayListWidgetPrivate;
99 d->setDocumentUsed = FALSE; 99 d->setDocumentUsed = FALSE;
100 d->current = NULL; 100 d->current = NULL;
101 menuTimer = new QTimer( this ,"menu timer"), 101// menuTimer = new QTimer( this ,"menu timer"),
102 connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); 102// connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) );
103 103
104 setBackgroundMode( PaletteButton ); 104 setBackgroundMode( PaletteButton );
105 105
106 setCaption( tr("OpiePlayer") ); 106 setCaption( tr("OpiePlayer") );
107 setIcon( Resource::loadPixmap( "MPEGPlayer" ) ); 107 setIcon( Resource::loadPixmap( "MPEGPlayer" ) );
108 108
109 setToolBarsMovable( FALSE ); 109 setToolBarsMovable( FALSE );
110 110
111 // Create Toolbar 111 // Create Toolbar
112 QPEToolBar *toolbar = new QPEToolBar( this ); 112 QPEToolBar *toolbar = new QPEToolBar( this );
113 toolbar->setHorizontalStretchable( TRUE ); 113 toolbar->setHorizontalStretchable( TRUE );
114 114
115 // Create Menubar 115 // Create Menubar
116 QPEMenuBar *menu = new QPEMenuBar( toolbar ); 116 QPEMenuBar *menu = new QPEMenuBar( toolbar );
117 menu->setMargin( 0 ); 117 menu->setMargin( 0 );
118 118
119 QPEToolBar *bar = new QPEToolBar( this ); 119 QPEToolBar *bar = new QPEToolBar( this );
120 bar->setLabel( tr( "Play Operations" ) ); 120 bar->setLabel( tr( "Play Operations" ) );
121 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "mpegplayer/add_to_playlist", 121 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "mpegplayer/add_to_playlist",
122 this , SLOT(addSelected()) ); 122 this , SLOT(addSelected()) );
123 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "mpegplayer/remove_from_playlist", 123 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "mpegplayer/remove_from_playlist",
124 this , SLOT(removeSelected()) ); 124 this , SLOT(removeSelected()) );
125 d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", 125 d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play",
126 mediaPlayerState, SLOT(setPlaying(bool)), TRUE ); 126 mediaPlayerState, SLOT(setPlaying(bool)), TRUE );
127 127
128 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ), "mpegplayer/shuffle", 128 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ), "mpegplayer/shuffle",
129 mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); 129 mediaPlayerState, SLOT(setShuffled(bool)), TRUE );
130 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "mpegplayer/loop", 130 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "mpegplayer/loop",
131 mediaPlayerState, SLOT(setLooping(bool)), TRUE ); 131 mediaPlayerState, SLOT(setLooping(bool)), TRUE );
132 132
133// d->tbFull = new ToolButton( bar, tr( "Fullscreen" ), "fullscreen", mediaPlayerState, SLOT(setFullscreen(bool)), TRUE ); 133// d->tbFull = new ToolButton( bar, tr( "Fullscreen" ), "fullscreen", mediaPlayerState, SLOT(setFullscreen(bool)), TRUE );
134// d->tbScale = new ToolButton( bar, tr( "Scale" ), "mpegplayer/scale", mediaPlayerState, SLOT(setScaled(bool)), TRUE ); 134// d->tbScale = new ToolButton( bar, tr( "Scale" ), "mpegplayer/scale", mediaPlayerState, SLOT(setScaled(bool)), TRUE );
135 135
136 QPopupMenu *pmPlayList = new QPopupMenu( this ); 136 QPopupMenu *pmPlayList = new QPopupMenu( this );
137 menu->insertItem( tr( "File" ), pmPlayList ); 137 menu->insertItem( tr( "File" ), pmPlayList );
138 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 138 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
139 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); 139 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) );
140 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); 140 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) );
141 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); 141 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) );
142 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); 142 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) );
143 new MenuItem( pmPlayList, tr( "Load PlayList" ), this, SLOT( loadList() ) ); 143 new MenuItem( pmPlayList, tr( "Load PlayList" ), this, SLOT( loadList() ) );
144 144
145 QPopupMenu *pmView = new QPopupMenu( this ); 145 QPopupMenu *pmView = new QPopupMenu( this );
146 menu->insertItem( tr( "View" ), pmView ); 146 menu->insertItem( tr( "View" ), pmView );
147 147
148 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); 148 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0);
149 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); 149 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) );
150 fullScreenButton->addTo(pmView); 150 fullScreenButton->addTo(pmView);
151 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("mpegplayer/scale"), QString::null, 0, this, 0); 151 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("mpegplayer/scale"), QString::null, 0, this, 0);
152 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); 152 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) );
153 scaleButton->addTo(pmView); 153 scaleButton->addTo(pmView);
154 154
155 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); 155 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton );
156 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); 156 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton );
157// vbox4->setMargin(4); 157// vbox4->setMargin(4);
158// libString = new QLabel( tr(" Media Library"), vbox4 ); 158// libString = new QLabel( tr(" Media Library"), vbox4 );
159// libString->setBackgroundMode( QButton::PaletteButton ); 159// libString->setBackgroundMode( QButton::PaletteButton );
160// libString->setFont( QFont( "Helvetica", 8, QFont::Bold ) ); 160// libString->setFont( QFont( "Helvetica", 8, QFont::Bold ) );
161 161
162 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); 162 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton );
163 163
164 tabWidget = new QTabWidget( hbox6, "tabWidget" ); 164 tabWidget = new QTabWidget( hbox6, "tabWidget" );
165 tabWidget->setTabShape(QTabWidget::Triangular); 165 tabWidget->setTabShape(QTabWidget::Triangular);
166 166
167 167
168 QWidget *pTab; 168 QWidget *pTab;
169 pTab = new QWidget( tabWidget, "pTab" ); 169 pTab = new QWidget( tabWidget, "pTab" );
170 playlistView = new QListView( pTab, "Videoview" ); 170 playlistView = new QListView( pTab, "Videoview" );
171 playlistView->setMinimumSize(236,260); 171 playlistView->setMinimumSize(236,260);
172 tabWidget->insertTab( pTab,"Playlist"); 172 tabWidget->insertTab( pTab,"Playlist");
173 173
174 // Add the playlist area 174 // Add the playlist area
175 175
176 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); 176 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton );
177 d->playListFrame = vbox3; 177 d->playListFrame = vbox3;
178 d->playListFrame ->setMinimumSize(235,260); 178 d->playListFrame ->setMinimumSize(235,260);
179 179
180 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); 180 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton );
181 d->selectedFiles = new PlayListSelection( hbox2); 181 d->selectedFiles = new PlayListSelection( hbox2);
182 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); 182 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton );
183 183
184 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch 184 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch
185 new ToolButton( vbox1, tr( "Move Up" ), "mpegplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); 185 new ToolButton( vbox1, tr( "Move Up" ), "mpegplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) );
186 new ToolButton( vbox1, tr( "Remove" ), "mpegplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); 186 new ToolButton( vbox1, tr( "Remove" ), "mpegplayer/cut", d->selectedFiles, SLOT(removeSelected()) );
187 new ToolButton( vbox1, tr( "Move Down" ), "mpegplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); 187 new ToolButton( vbox1, tr( "Move Down" ), "mpegplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) );
188 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch 188 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch
189 189
190 QWidget *aTab; 190 QWidget *aTab;
191 aTab = new QWidget( tabWidget, "aTab" ); 191 aTab = new QWidget( tabWidget, "aTab" );
192 audioView = new QListView( aTab, "Audioview" ); 192 audioView = new QListView( aTab, "Audioview" );
193 audioView->setMinimumSize(233,260); 193 audioView->setMinimumSize(233,260);
194 audioView->addColumn( "Title",150); 194 audioView->addColumn( "Title",150);
195 audioView->addColumn("Size", 45); 195 audioView->addColumn("Size", 45);
196 audioView->addColumn("Media",35); 196 audioView->addColumn("Media",35);
197 audioView->setColumnAlignment(1, Qt::AlignRight); 197 audioView->setColumnAlignment(1, Qt::AlignRight);
198 audioView->setColumnAlignment(2, Qt::AlignRight); 198 audioView->setColumnAlignment(2, Qt::AlignRight);
199 tabWidget->insertTab(aTab,"Audio"); 199 tabWidget->insertTab(aTab,"Audio");
200// audioView 200// audioView
201 Global::findDocuments(&files, "audio/*"); 201 Global::findDocuments(&files, "audio/*");
202 QListIterator<DocLnk> dit( files.children() ); 202 QListIterator<DocLnk> dit( files.children() );
203 QString storage; 203 QString storage;
204 for ( ; dit.current(); ++dit ) { 204 for ( ; dit.current(); ++dit ) {
205 QListViewItem * newItem; 205 QListViewItem * newItem;
206 if(dit.current()->file().find("/mnt/cf") != -1 ) storage="CF"; 206 if(dit.current()->file().find("/mnt/cf") != -1 ) storage="CF";
207 else if(dit.current()->file().find("/mnt/hda") != -1 ) storage="CF";
207 else if(dit.current()->file().find("/mnt/card") != -1 ) storage="SD"; 208 else if(dit.current()->file().find("/mnt/card") != -1 ) storage="SD";
208 else storage="RAM"; 209 else storage="RAM";
209 210 if ( QFile( dit.current()->file()).exists() ) {
210 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); 211 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage);
211 newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/musicfile" )); 212 newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/musicfile" ));
213 }
212 } 214 }
213// videowidget 215// videowidget
214 216
215 QWidget *vTab; 217 QWidget *vTab;
216 vTab = new QWidget( tabWidget, "vTab" ); 218 vTab = new QWidget( tabWidget, "vTab" );
217 videoView = new QListView( vTab, "Videoview" ); 219 videoView = new QListView( vTab, "Videoview" );
218 videoView->setMinimumSize(233,260); 220 videoView->setMinimumSize(233,260);
219 221
220 videoView->addColumn("Title",150); 222 videoView->addColumn("Title",150);
221 videoView->addColumn("Size",45); 223 videoView->addColumn("Size",45);
222 videoView->addColumn("Media",35); 224 videoView->addColumn("Media",35);
223 videoView->setColumnAlignment(1, Qt::AlignRight); 225 videoView->setColumnAlignment(1, Qt::AlignRight);
224 videoView->setColumnAlignment(2, Qt::AlignRight); 226 videoView->setColumnAlignment(2, Qt::AlignRight);
225 227
226 tabWidget->insertTab( vTab,"Video"); 228 tabWidget->insertTab( vTab,"Video");
227 229
228 Global::findDocuments(&vFiles, "video/*"); 230 Global::findDocuments(&vFiles, "video/*");
229 QListIterator<DocLnk> Vdit( vFiles.children() ); 231 QListIterator<DocLnk> Vdit( vFiles.children() );
230 for ( ; Vdit.current(); ++Vdit ) { 232 for ( ; Vdit.current(); ++Vdit ) {
231 if( Vdit.current()->file().find("/mnt/cf") != -1 ) storage="CF"; 233 if( Vdit.current()->file().find("/mnt/cf") != -1 ) storage="CF";
234 else if( Vdit.current()->file().find("/mnt/hda") != -1 ) storage="CF";
232 else if( Vdit.current()->file().find("/mnt/card") != -1 ) storage="SD"; 235 else if( Vdit.current()->file().find("/mnt/card") != -1 ) storage="SD";
233 else storage="RAM"; 236 else storage="RAM";
234 QListViewItem * newItem; 237 QListViewItem * newItem;
238 if ( QFile( Vdit.current()->file()).exists() ) {
235 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); 239 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage);
236 newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" )); 240 newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" ));
241 }
237 } 242 }
238 243
239 244
240// d->tbPlay = new ToolButton( vbox1, tr( "Play" ), "mpegplayer/play", mediaPlayerState, SLOT(setPlaying(bool)), TRUE ); 245// d->tbPlay = new ToolButton( vbox1, tr( "Play" ), "mpegplayer/play", mediaPlayerState, SLOT(setPlaying(bool)), TRUE );
241// d->tbShuffle = new ToolButton( vbox1, tr( "Randomize" ), "mpegplayer/shuffle", mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); 246// d->tbShuffle = new ToolButton( vbox1, tr( "Randomize" ), "mpegplayer/shuffle", mediaPlayerState, SLOT(setShuffled(bool)), TRUE );
242 247
243 // add the library area 248 // add the library area
244 249
245// d->files->setBackgroundMode( PaletteButton ); 250// d->files->setBackgroundMode( PaletteButton );
246// QVBox *vbox7 = new QVBox( hbox6 ); vbox7->setBackgroundMode( PaletteButton ); 251// QVBox *vbox7 = new QVBox( hbox6 ); vbox7->setBackgroundMode( PaletteButton );
247 252
248// #ifdef SIDE_BUTTONS 253// #ifdef SIDE_BUTTONS
249// QVBox *stretch3 = new QVBox( vbox1 ); stretch3->setBackgroundMode( PaletteButton ); // add stretch 254// QVBox *stretch3 = new QVBox( vbox1 ); stretch3->setBackgroundMode( PaletteButton ); // add stretch
250// #endif 255// #endif
251 QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); 256 QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold );
252 257
253// connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); 258// connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
254// connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); 259// connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
255 260
256 connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 261 connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
257 connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 262 connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
258 263
259 connect( audioView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint&, int ) ), 264 connect( audioView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint&, int ) ),
260 this, SLOT( addToSelection( QListViewItem *, const QPoint&, int )) ); 265 this, SLOT( addToSelection( QListViewItem *, const QPoint&, int )) );
261 connect( videoView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint&, int ) ), 266 connect( videoView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint&, int ) ),
262 this, SLOT( addToSelection( QListViewItem *, const QPoint&, int )) ); 267 this, SLOT( addToSelection( QListViewItem *, const QPoint&, int )) );
263 268
264 connect( playlistView, SIGNAL( pressed( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); 269 connect( playlistView, SIGNAL( pressed( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
265 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); 270 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*)));
266 // connect( d->files, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); 271 // connect( d->files, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) );
267 // connect( d->files, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); 272 // connect( d->files, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) );
268 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); 273 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) );
269 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); 274 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) );
270 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); 275 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) );
271 276
272// connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), fullScreenButton, SLOT( setOn( bool ) ) ); 277// connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), fullScreenButton, SLOT( setOn( bool ) ) );
273// connect( mediaPlayerState, SIGNAL( scaledToggled( bool ) ), scaleButton, SLOT( setEnabled( bool ) ) ); 278// connect( mediaPlayerState, SIGNAL( scaledToggled( bool ) ), scaleButton, SLOT( setEnabled( bool ) ) );
274// connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), fullScreenButton, SLOT( setEnabled( bool ) ) ); 279// connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), fullScreenButton, SLOT( setEnabled( bool ) ) );
275 280
276 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); 281 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) );
277 282
278 setCentralWidget( vbox5 ); 283 setCentralWidget( vbox5 );
279 284
280 Config cfg( "MediaPlayer" ); 285 Config cfg( "MediaPlayer" );
281 readConfig( cfg ); 286 readConfig( cfg );
282 287
283 initializeStates(); 288 initializeStates();
284} 289}
285 290
286 291
287PlayListWidget::~PlayListWidget() { 292PlayListWidget::~PlayListWidget() {
288 Config cfg( "MediaPlayer" ); 293 Config cfg( "MediaPlayer" );
289 writeConfig( cfg ); 294 writeConfig( cfg );
290 295
291 if ( d->current ) 296 if ( d->current )
292 delete d->current; 297 delete d->current;
293 delete d; 298 delete d;
294} 299}
295 300
296 301
297void PlayListWidget::initializeStates() { 302void PlayListWidget::initializeStates() {
298 303
299 d->tbPlay->setOn( mediaPlayerState->playing() ); 304 d->tbPlay->setOn( mediaPlayerState->playing() );
300 d->tbLoop->setOn( mediaPlayerState->looping() ); 305 d->tbLoop->setOn( mediaPlayerState->looping() );
301 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 306 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
302// d->tbFull->setOn( mediaPlayerState->fullscreen() ); 307// d->tbFull->setOn( mediaPlayerState->fullscreen() );
303// d->tbScale->setOn( mediaPlayerState->scaled() ); 308// d->tbScale->setOn( mediaPlayerState->scaled() );
304// d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); 309// d->tbScale->setEnabled( mediaPlayerState->fullscreen() );
305// setPlaylist( mediaPlayerState->playlist() ); 310// setPlaylist( mediaPlayerState->playlist() );
306} 311}
307 312
308 313
309void PlayListWidget::readConfig( Config& cfg ) { 314void PlayListWidget::readConfig( Config& cfg ) {
310 cfg.setGroup("PlayList"); 315 cfg.setGroup("PlayList");
311 316
312 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 317 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
313 318
314 for ( int i = 0; i < noOfFiles; i++ ) { 319 for ( int i = 0; i < noOfFiles; i++ ) {
315 QString entryName; 320 QString entryName;
316 entryName.sprintf( "File%i", i + 1 ); 321 entryName.sprintf( "File%i", i + 1 );
317 QString linkFile = cfg.readEntry( entryName ); 322 QString linkFile = cfg.readEntry( entryName );
318 DocLnk lnk( linkFile ); 323 DocLnk lnk( linkFile );
319 if ( lnk.isValid() ) 324 if ( lnk.isValid() )
320 d->selectedFiles->addToSelection( lnk ); 325 d->selectedFiles->addToSelection( lnk );
321 326
322 } 327 }
323} 328}
324 329
325 330
326void PlayListWidget::writeConfig( Config& cfg ) const { 331void PlayListWidget::writeConfig( Config& cfg ) const {
327 cfg.setGroup("PlayList"); 332 cfg.setGroup("PlayList");
328 333
329 int noOfFiles = 0; 334 int noOfFiles = 0;
330 335
331 d->selectedFiles->first(); 336 d->selectedFiles->first();
332 do { 337 do {
@@ -570,124 +575,124 @@ void PlayListWidget::removeSelected() {
570 d->selectedFiles->removeSelected( ); 575 d->selectedFiles->removeSelected( );
571} 576}
572 577
573 578
574void PlayListWidget::playIt( QListViewItem *it) { 579void PlayListWidget::playIt( QListViewItem *it) {
575 d->setDocumentUsed = FALSE; 580 d->setDocumentUsed = FALSE;
576 581
577 if(it) { 582 if(it) {
578 qDebug("playit"); 583 qDebug("playit");
579 int tabPage=tabWidget->currentPageIndex(); 584 int tabPage=tabWidget->currentPageIndex();
580 switch (tabPage) { 585 switch (tabPage) {
581 case 1: { 586 case 1: {
582 DocLnkSet files; 587 DocLnkSet files;
583 QListIterator<DocLnk> dit( files.children() ); 588 QListIterator<DocLnk> dit( files.children() );
584 for ( ; dit.current(); ++dit ) { 589 for ( ; dit.current(); ++dit ) {
585 if( dit.current()->name() == it->text(0)) { 590 if( dit.current()->name() == it->text(0)) {
586 setDocument( dit.current()->name()); 591 setDocument( dit.current()->name());
587 } 592 }
588 } 593 }
589 } 594 }
590 break; 595 break;
591 case 2: { 596 case 2: {
592 DocLnkSet vFiles; 597 DocLnkSet vFiles;
593 QListIterator<DocLnk> dit( vFiles.children() ); 598 QListIterator<DocLnk> dit( vFiles.children() );
594 for ( ; dit.current(); ++dit ) { 599 for ( ; dit.current(); ++dit ) {
595 qDebug(dit.current()->name()); 600 qDebug(dit.current()->name());
596 if( dit.current()->name() == it->text(0)) { 601 if( dit.current()->name() == it->text(0)) {
597 qDebug(it->text(0)); 602 qDebug(it->text(0));
598 setDocument( dit.current()->name()); 603 setDocument( dit.current()->name());
599 } 604 }
600 } 605 }
601 } 606 }
602 break; 607 break;
603 }; 608 };
604 } 609 }
605} 610}
606 611
607void PlayListWidget::addToSelection( QListViewItem *it) { 612void PlayListWidget::addToSelection( QListViewItem *it) {
608 d->setDocumentUsed = FALSE; 613 d->setDocumentUsed = FALSE;
609 614
610 if(it) { 615 if(it) {
611 qDebug("add to selection"); 616 qDebug("add to selection");
612 int tabPage=tabWidget->currentPageIndex(); 617 int tabPage=tabWidget->currentPageIndex();
613 switch (tabPage) { 618 switch (tabPage) {
614 case 1: { 619 case 1: {
615 QListIterator<DocLnk> dit( files.children() ); 620 QListIterator<DocLnk> dit( files.children() );
616 for ( ; dit.current(); ++dit ) { 621 for ( ; dit.current(); ++dit ) {
617 if( dit.current()->name() == it->text(0)) { 622 if( dit.current()->name() == it->text(0)) {
618 d->selectedFiles->addToSelection( **dit ); 623 d->selectedFiles->addToSelection( **dit );
619 } 624 }
620 } 625 }
621 } 626 }
622 break; 627 break;
623 case 2: { 628 case 2: {
624 QListIterator<DocLnk> dit( vFiles.children() ); 629 QListIterator<DocLnk> dit( vFiles.children() );
625 for ( ; dit.current(); ++dit ) { 630 for ( ; dit.current(); ++dit ) {
626 qDebug(dit.current()->name()); 631 qDebug(dit.current()->name());
627 if( dit.current()->name() == it->text(0)) { 632 if( dit.current()->name() == it->text(0)) {
628 d->selectedFiles->addToSelection( **dit ); 633 d->selectedFiles->addToSelection( **dit );
629 } 634 }
630 } 635 }
631 } 636 }
632 break; 637 break;
633 case 0: 638 case 0:
634 break; 639 break;
635 }; 640 };
636 tabWidget->setCurrentPage(0); 641 tabWidget->setCurrentPage(0);
637// mediaPlayerState->setPlaying( TRUE ); 642// mediaPlayerState->setPlaying( TRUE );
638 } 643 }
639} 644}
640 645
641void PlayListWidget::tabChanged(QWidget *widg) { 646void PlayListWidget::tabChanged(QWidget *widg) {
642 647
643 int tabPage=tabWidget->currentPageIndex(); 648 int tabPage=tabWidget->currentPageIndex();
644 switch (tabPage) { 649 switch (tabPage) {
645 case 0: 650 case 0:
646 { 651 {
647 d->tbRemoveFromList->setEnabled(TRUE); 652 d->tbRemoveFromList->setEnabled(TRUE);
648 d->tbAddToList->setEnabled(FALSE); 653 d->tbAddToList->setEnabled(FALSE);
649 } 654 }
650 break; 655 break;
651 case 1: 656 case 1:
652 { 657 {
653 d->tbRemoveFromList->setEnabled(FALSE); 658 d->tbRemoveFromList->setEnabled(FALSE);
654 d->tbAddToList->setEnabled(TRUE); 659 d->tbAddToList->setEnabled(TRUE);
655 } 660 }
656 break; 661 break;
657 case 2: 662 case 2:
658 { 663 {
659 d->tbRemoveFromList->setEnabled(FALSE); 664 d->tbRemoveFromList->setEnabled(FALSE);
660 d->tbAddToList->setEnabled(TRUE); 665 d->tbAddToList->setEnabled(TRUE);
661 } 666 }
662 break; 667 break;
663 }; 668 };
664} 669}
665 670
666void PlayListWidget::cancelMenuTimer() { 671// void PlayListWidget::cancelMenuTimer() {
667 if( menuTimer->isActive() ) 672// if( menuTimer->isActive() )
668 menuTimer->stop(); 673// menuTimer->stop();
669} 674// }
670 675
671void PlayListWidget::showFileMenu() { 676// void PlayListWidget::showFileMenu() {
672 677
673} 678// }
674 679
675void PlayListWidget::contentsMousePressEvent( QMouseEvent * e ) 680// void PlayListWidget::contentsMousePressEvent( QMouseEvent * e )
676{ 681// {
677// QListView::contentsMousePressEvent( e ); 682// // QListView::contentsMousePressEvent( e );
678 menuTimer->start( 750, TRUE ); 683// menuTimer->start( 750, TRUE );
679} 684// }
680 685
681 686
682void PlayListWidget::contentsMouseReleaseEvent( QMouseEvent * e ) 687// void PlayListWidget::contentsMouseReleaseEvent( QMouseEvent * e )
683{ 688// {
684// QListView::contentsMouseReleaseEvent( e ); 689// // QListView::contentsMouseReleaseEvent( e );
685 menuTimer->stop(); 690// menuTimer->stop();
686} 691// }
687// void PlayListWidget::setFullScreen() { 692// // void PlayListWidget::setFullScreen() {
688// mediaPlayerState->toggleFullscreen( ); 693// mediaPlayerState->toggleFullscreen( );
689// } 694// }
690 695
691// void PlayListWidget::setScaled() { 696// void PlayListWidget::setScaled() {
692// mediaPlayerState->toggleScaled(); 697// mediaPlayerState->toggleScaled();
693// } 698// }
diff --git a/core/multimedia/opieplayer/playlistwidget.h b/core/multimedia/opieplayer/playlistwidget.h
index 3a52dd5..6fe2211 100644
--- a/core/multimedia/opieplayer/playlistwidget.h
+++ b/core/multimedia/opieplayer/playlistwidget.h
@@ -1,97 +1,97 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef PLAY_LIST_WIDGET_H 20#ifndef PLAY_LIST_WIDGET_H
21#define PLAY_LIST_WIDGET_H 21#define PLAY_LIST_WIDGET_H
22 22
23 23
24#include <qmainwindow.h> 24#include <qmainwindow.h>
25#include <qpe/applnk.h> 25#include <qpe/applnk.h>
26#include <qtabwidget.h> 26#include <qtabwidget.h>
27#include <qtimer.h> 27/* #include <qtimer.h> */
28 28
29 29
30class PlayListWidgetPrivate; 30class PlayListWidgetPrivate;
31class Config; 31class Config;
32class QListViewItem; 32class QListViewItem;
33class QListView; 33class QListView;
34class QPoint; 34class QPoint;
35class QAction; 35class QAction;
36class QLabel; 36class QLabel;
37 37
38class PlayListWidget : public QMainWindow { 38class PlayListWidget : public QMainWindow {
39 Q_OBJECT 39 Q_OBJECT
40public: 40public:
41 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); 41 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 );
42 ~PlayListWidget(); 42 ~PlayListWidget();
43 QTabWidget * tabWidget; 43 QTabWidget * tabWidget;
44 QAction *fullScreenButton, *scaleButton; 44 QAction *fullScreenButton, *scaleButton;
45 DocLnkSet files; 45 DocLnkSet files;
46 DocLnkSet vFiles; 46 DocLnkSet vFiles;
47 QListView *audioView, *videoView, *playlistView; 47 QListView *audioView, *videoView, *playlistView;
48 QLabel *libString; 48 QLabel *libString;
49 // retrieve the current playlist entry (media file link) 49 // retrieve the current playlist entry (media file link)
50 const DocLnk *current(); 50 const DocLnk *current();
51 void useSelectedDocument(); 51 void useSelectedDocument();
52 QTimer * menuTimer; 52/* QTimer * menuTimer; */
53 53
54public slots: 54public slots:
55 void setDocument( const QString& fileref ); 55 void setDocument( const QString& fileref );
56 void addToSelection( const DocLnk& ); // Add a media file to the playlist 56 void addToSelection( const DocLnk& ); // Add a media file to the playlist
57 void addToSelection( QListViewItem* ); // Add a media file to the playlist 57 void addToSelection( QListViewItem* ); // Add a media file to the playlist
58 void addToSelection( QListViewItem*, const QPoint&,int ); // Add a media file to the playlist 58 void addToSelection( QListViewItem*, const QPoint&,int ); // Add a media file to the playlist
59 void setActiveWindow(); // need to handle this to show the right view 59 void setActiveWindow(); // need to handle this to show the right view
60 void setPlaylist( bool ); // Show/Hide the playlist 60 void setPlaylist( bool ); // Show/Hide the playlist
61 void setView( char ); 61 void setView( char );
62 void clearList(); 62 void clearList();
63 void addAllToList(); 63 void addAllToList();
64 void addAllMusicToList(); 64 void addAllMusicToList();
65 void addAllVideoToList(); 65 void addAllVideoToList();
66 void saveList(); // Save the playlist 66 void saveList(); // Save the playlist
67 void loadList(); // Load a playlist 67 void loadList(); // Load a playlist
68 void playIt( QListViewItem *); 68 void playIt( QListViewItem *);
69 bool first(); 69 bool first();
70 bool last(); 70 bool last();
71 bool next(); 71 bool next();
72 bool prev(); 72 bool prev();
73 void addSelected(); 73 void addSelected();
74 void removeSelected(); 74 void removeSelected();
75 void tabChanged(QWidget*); 75 void tabChanged(QWidget*);
76/* void setFullScreen(); */ 76/* void setFullScreen(); */
77/* void setScaled(); */ 77/* void setScaled(); */
78protected: 78protected:
79 void contentsMousePressEvent( QMouseEvent * e ); 79/* void contentsMousePressEvent( QMouseEvent * e ); */
80 void contentsMouseReleaseEvent( QMouseEvent * e ); 80/* void contentsMouseReleaseEvent( QMouseEvent * e ); */
81 81
82private: 82private:
83 void initializeStates(); 83 void initializeStates();
84 void readConfig( Config& cfg ); 84 void readConfig( Config& cfg );
85 void writeConfig( Config& cfg ) const; 85 void writeConfig( Config& cfg ) const;
86 PlayListWidgetPrivate *d; // Private implementation data 86 PlayListWidgetPrivate *d; // Private implementation data
87 87
88protected slots: 88protected slots:
89 void cancelMenuTimer(); 89/* void cancelMenuTimer(); */
90 void showFileMenu(); 90/* void showFileMenu(); */
91 91
92 92
93}; 93};
94 94
95 95
96#endif // PLAY_LIST_WIDGET_H 96#endif // PLAY_LIST_WIDGET_H
97 97