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
@@ -1,371 +1,371 @@
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// 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
298unsigned int AudioDevice::channels() const 298unsigned int AudioDevice::channels() const
299{ 299{
300 return d->channels; 300 return d->channels;
301} 301}
302 302
303 303
304unsigned int AudioDevice::frequency() const 304unsigned int AudioDevice::frequency() const
305{ 305{
306 return d->frequency; 306 return d->frequency;
307} 307}
308 308
309 309
310unsigned int AudioDevice::bytesPerSample() const 310unsigned int AudioDevice::bytesPerSample() const
311{ 311{
312 return d->bytesPerSample; 312 return d->bytesPerSample;
313} 313}
314 314
315 315
316unsigned int AudioDevice::bufferSize() const 316unsigned int AudioDevice::bufferSize() const
317{ 317{
318 return d->bufferSize; 318 return d->bufferSize;
319} 319}
320 320
321unsigned int AudioDevice::canWrite() const 321unsigned int AudioDevice::canWrite() const
322{ 322{
323#ifdef Q_OS_WIN32 323#ifdef Q_OS_WIN32
324 return bufferSize(); // Any better? 324 return bufferSize(); // Any better?
325#else 325#else
326 audio_buf_info info; 326 audio_buf_info info;
327 if ( d->can_GETOSPACE && ioctl(d->handle,SNDCTL_DSP_GETOSPACE,&info) ) { 327 if ( d->can_GETOSPACE && ioctl(d->handle,SNDCTL_DSP_GETOSPACE,&info) ) {
328 d->can_GETOSPACE = FALSE; 328 d->can_GETOSPACE = FALSE;
329 fcntl( d->handle, F_SETFL, O_NONBLOCK ); 329 fcntl( d->handle, F_SETFL, O_NONBLOCK );
330 } 330 }
331 if ( d->can_GETOSPACE ) { 331 if ( d->can_GETOSPACE ) {
332 int t = info.fragments * sound_fragment_bytes; 332 int t = info.fragments * sound_fragment_bytes;
333 return QMIN(t,(int)bufferSize()); 333 return QMIN(t,(int)bufferSize());
334 } else { 334 } else {
335 if ( d->unwritten ) { 335 if ( d->unwritten ) {
336 int t = ::write( d->handle, d->unwrittenBuffer, d->unwritten ); 336 int t = ::write( d->handle, d->unwrittenBuffer, d->unwritten );
337 if ( t<0 ) t = 0; 337 if ( t<0 ) t = 0;
338 if ( (unsigned)t!=d->unwritten ) { 338 if ( (unsigned)t!=d->unwritten ) {
339 memcpy(d->unwrittenBuffer,d->unwrittenBuffer+t,d->unwritten-t); 339 memcpy(d->unwrittenBuffer,d->unwrittenBuffer+t,d->unwritten-t);
340 d->unwritten -= t; 340 d->unwritten -= t;
341 } else { 341 } else {
342 d->unwritten = 0; 342 d->unwritten = 0;
343 } 343 }
344 } 344 }
345 if ( d->unwritten ) 345 if ( d->unwritten )
346 return 0; 346 return 0;
347 else 347 else
348 return d->bufferSize; 348 return d->bufferSize;
349 } 349 }
350#endif 350#endif
351} 351}
352 352
353 353
354int AudioDevice::bytesWritten() { 354int AudioDevice::bytesWritten() {
355#ifdef Q_OS_WIN32 355#ifdef Q_OS_WIN32
356 MMTIME pmmt = { TIME_BYTES, 0 }; 356 MMTIME pmmt = { TIME_BYTES, 0 };
357 if ( ( waveOutGetPosition( (HWAVEOUT)d->handle, &pmmt, sizeof(MMTIME) ) != MMSYSERR_NOERROR ) || ( pmmt.wType != TIME_BYTES ) ) { 357 if ( ( waveOutGetPosition( (HWAVEOUT)d->handle, &pmmt, sizeof(MMTIME) ) != MMSYSERR_NOERROR ) || ( pmmt.wType != TIME_BYTES ) ) {
358 qDebug( "failed to get audio device position" ); 358 qDebug( "failed to get audio device position" );
359 return -1; 359 return -1;
360 } 360 }
361 return pmmt.u.cb; 361 return pmmt.u.cb;
362#else 362#else
363 int buffered = 0; 363 int buffered = 0;
364 if ( ioctl( d->handle, SNDCTL_DSP_GETODELAY, &buffered ) ) { 364 if ( ioctl( d->handle, SNDCTL_DSP_GETODELAY, &buffered ) ) {
365 qDebug( "failed to get audio device position" ); 365 qDebug( "failed to get audio device position" );
366 return -1; 366 return -1;
367 } 367 }
368 return buffered; 368 return buffered;
369#endif 369#endif
370} 370}
371 371
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
@@ -1,468 +1,468 @@
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// L.J.Potter added changes Fri 02-15-2002 20// L.J.Potter added changes Fri 02-15-2002
21 21
22#include <qpe/qpeapplication.h> 22#include <qpe/qpeapplication.h>
23 23
24#ifdef Q_WS_QWS 24#ifdef Q_WS_QWS
25#include <qpe/qcopenvelope_qws.h> 25#include <qpe/qcopenvelope_qws.h>
26#endif 26#endif
27#include <stdio.h> 27#include <stdio.h>
28#include <stdlib.h> 28#include <stdlib.h>
29#include <string.h> 29#include <string.h>
30#include <pthread.h> 30#include <pthread.h>
31#include <errno.h> 31#include <errno.h>
32#include <unistd.h> 32#include <unistd.h>
33#include "loopcontrol.h" 33#include "loopcontrol.h"
34#include "videowidget.h" 34#include "videowidget.h"
35#include "audiodevice.h" 35#include "audiodevice.h"
36#include "mediaplayerplugininterface.h" 36#include "mediaplayerplugininterface.h"
37#include "mediaplayerstate.h" 37#include "mediaplayerstate.h"
38 38
39 39
40extern VideoWidget *videoUI; // now only needed to tell it to play a frame 40extern VideoWidget *videoUI; // now only needed to tell it to play a frame
41extern MediaPlayerState *mediaPlayerState; 41extern MediaPlayerState *mediaPlayerState;
42 42
43 43
44//#define DecodeLoopDebug(x) qDebug x 44//#define DecodeLoopDebug(x) qDebug x
45#define DecodeLoopDebug(x) 45#define DecodeLoopDebug(x)
46 46
47 47
48static char *audioBuffer = NULL; 48static char *audioBuffer = NULL;
49static AudioDevice *audioDevice = NULL; 49static AudioDevice *audioDevice = NULL;
50static bool disabledSuspendScreenSaver = FALSE; 50static bool disabledSuspendScreenSaver = FALSE;
51static bool previousSuspendMode = FALSE; 51static bool previousSuspendMode = FALSE;
52 52
53 53
54pthread_t audio_tid; 54pthread_t audio_tid;
55pthread_attr_t audio_attr; 55pthread_attr_t audio_attr;
56bool threadOkToGo = FALSE; 56bool threadOkToGo = FALSE;
57 57
58 58
59class Mutex { 59class Mutex {
60public: 60public:
61 Mutex() { 61 Mutex() {
62 pthread_mutexattr_t attr; 62 pthread_mutexattr_t attr;
63 pthread_mutexattr_init( &attr ); 63 pthread_mutexattr_init( &attr );
64 pthread_mutex_init( &mutex, &attr ); 64 pthread_mutex_init( &mutex, &attr );
65 pthread_mutexattr_destroy( &attr ); 65 pthread_mutexattr_destroy( &attr );
66 } 66 }
67 67
68 ~Mutex() { 68 ~Mutex() {
69 pthread_mutex_destroy( &mutex ); 69 pthread_mutex_destroy( &mutex );
70 } 70 }
71 71
72 void lock() { 72 void lock() {
73 pthread_mutex_lock( &mutex ); 73 pthread_mutex_lock( &mutex );
74 } 74 }
75 75
76 void unlock() { 76 void unlock() {
77 pthread_mutex_unlock( &mutex ); 77 pthread_mutex_unlock( &mutex );
78 } 78 }
79private: 79private:
80 pthread_mutex_t mutex; 80 pthread_mutex_t mutex;
81}; 81};
82 82
83 83
84void *startAudioThread( void *ptr ) { 84void *startAudioThread( void *ptr ) {
85 LoopControl *mpegView = (LoopControl *)ptr; 85 LoopControl *mpegView = (LoopControl *)ptr;
86 while ( TRUE ) { 86 while ( TRUE ) {
87 if ( threadOkToGo && mpegView->moreAudio ) 87 if ( threadOkToGo && mpegView->moreAudio )
88 mpegView->startAudio(); 88 mpegView->startAudio();
89 else 89 else
90 usleep( 10000 ); // Semi-buzy-wait till we are playing again 90 usleep( 10000 ); // Semi-buzy-wait till we are playing again
91 } 91 }
92 return 0; 92 return 0;
93} 93}
94 94
95 95
96Mutex *audioMutex; 96Mutex *audioMutex;
97 97
98 98
99LoopControl::LoopControl( QObject *parent, const char *name ) 99LoopControl::LoopControl( QObject *parent, const char *name )
100 : QObject( parent, name ) { 100 : QObject( parent, name ) {
101 isMuted = FALSE; 101 isMuted = FALSE;
102 connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( setMute(bool) ) ); 102 connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( setMute(bool) ) );
103 103
104 audioMutex = new Mutex; 104 audioMutex = new Mutex;
105 105
106 pthread_attr_init(&audio_attr); 106 pthread_attr_init(&audio_attr);
107#define USE_REALTIME_AUDIO_THREAD 107#define USE_REALTIME_AUDIO_THREAD
108#ifdef USE_REALTIME_AUDIO_THREAD 108#ifdef USE_REALTIME_AUDIO_THREAD
109 // Attempt to set it to real-time round robin 109 // Attempt to set it to real-time round robin
110 if ( pthread_attr_setschedpolicy( &audio_attr, SCHED_RR ) == 0 ) { 110 if ( pthread_attr_setschedpolicy( &audio_attr, SCHED_RR ) == 0 ) {
111 sched_param params; 111 sched_param params;
112 params.sched_priority = 50; 112 params.sched_priority = 50;
113 pthread_attr_setschedparam(&audio_attr,&params); 113 pthread_attr_setschedparam(&audio_attr,&params);
114 } else { 114 } else {
115 qDebug( "Error setting up a realtime thread, reverting to using a normal thread." ); 115 qDebug( "Error setting up a realtime thread, reverting to using a normal thread." );
116 pthread_attr_destroy(&audio_attr); 116 pthread_attr_destroy(&audio_attr);
117 pthread_attr_init(&audio_attr); 117 pthread_attr_init(&audio_attr);
118 } 118 }
119#endif 119#endif
120 pthread_create(&audio_tid, &audio_attr, (void * (*)(void *))startAudioThread, this); 120 pthread_create(&audio_tid, &audio_attr, (void * (*)(void *))startAudioThread, this);
121} 121}
122 122
123 123
124LoopControl::~LoopControl() { 124LoopControl::~LoopControl() {
125 stop(); 125 stop();
126} 126}
127 127
128 128
129static long prev_frame = 0; 129static long prev_frame = 0;
130static int currentSample = 0; 130static int currentSample = 0;
131 131
132 132
133void LoopControl::timerEvent( QTimerEvent *te ) { 133void LoopControl::timerEvent( QTimerEvent *te ) {
134 134
135 if ( te->timerId() == videoId ) 135 if ( te->timerId() == videoId )
136 startVideo(); 136 startVideo();
137 137
138 if ( te->timerId() == sliderId ) { 138 if ( te->timerId() == sliderId ) {
139 if ( hasAudioChannel && !hasVideoChannel && moreAudio ) { 139 if ( hasAudioChannel && !hasVideoChannel && moreAudio ) {
140 mediaPlayerState->updatePosition( audioSampleCounter ); 140 mediaPlayerState->updatePosition( audioSampleCounter );
141 } else if ( hasVideoChannel && moreVideo ) { 141 } else if ( hasVideoChannel && moreVideo ) {
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 }
342 342
343 audioMutex->unlock(); 343 audioMutex->unlock();
344 344
345 } 345 }
346} 346}
347 347
348 348
349bool LoopControl::init( const QString& filename ) { 349bool LoopControl::init( const QString& filename ) {
350 stop(); 350 stop();
351 351
352 audioMutex->lock(); 352 audioMutex->lock();
353 353
354 fileName = filename; 354 fileName = filename;
355 stream = 0; // only play stream 0 for now 355 stream = 0; // only play stream 0 for now
356 current_frame = total_video_frames = total_audio_samples = 0; 356 current_frame = total_video_frames = total_audio_samples = 0;
357 357
358 qDebug( "Using the %s decoder", mediaPlayerState->curDecoder()->pluginName() ); 358 qDebug( "Using the %s decoder", mediaPlayerState->curDecoder()->pluginName() );
359 359
360 // ### Hack to use libmpeg3plugin to get the number of audio samples if we are using the libmad plugin 360 // ### Hack to use libmpeg3plugin to get the number of audio samples if we are using the libmad plugin
361 if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMadPlugin") ) { 361 if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMadPlugin") ) {
362 if ( mediaPlayerState->libMpeg3Decoder() && mediaPlayerState->libMpeg3Decoder()->open( filename ) ) { 362 if ( mediaPlayerState->libMpeg3Decoder() && mediaPlayerState->libMpeg3Decoder()->open( filename ) ) {
363 total_audio_samples = mediaPlayerState->libMpeg3Decoder()->audioSamples( 0 ); 363 total_audio_samples = mediaPlayerState->libMpeg3Decoder()->audioSamples( 0 );
364 mediaPlayerState->libMpeg3Decoder()->close(); 364 mediaPlayerState->libMpeg3Decoder()->close();
365 } 365 }
366 } 366 }
367 367
368 if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) ) { 368 if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) ) {
369 audioMutex->unlock(); 369 audioMutex->unlock();
370 return FALSE; 370 return FALSE;
371 } 371 }
372 372
373 hasAudioChannel = mediaPlayerState->curDecoder()->audioStreams() > 0; 373 hasAudioChannel = mediaPlayerState->curDecoder()->audioStreams() > 0;
374 hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0; 374 hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0;
375 375
376 if ( hasAudioChannel ) { 376 if ( hasAudioChannel ) {
377 int astream = 0; 377 int astream = 0;
378 378
379 channels = mediaPlayerState->curDecoder()->audioChannels( astream ); 379 channels = mediaPlayerState->curDecoder()->audioChannels( astream );
380 qDebug( "LC- channels = %d", channels ); 380 qDebug( "LC- channels = %d", channels );
381 381
382 if ( !total_audio_samples ) 382 if ( !total_audio_samples )
383 total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream ); 383 total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream );
384 384
385// total_audio_samples += 1000; 385// total_audio_samples += 1000;
386 386
387 mediaPlayerState->setLength( total_audio_samples ); 387 mediaPlayerState->setLength( total_audio_samples );
388 388
389 freq = mediaPlayerState->curDecoder()->audioFrequency( astream ); 389 freq = mediaPlayerState->curDecoder()->audioFrequency( astream );
390 qDebug( "LC- frequency = %d", freq ); 390 qDebug( "LC- frequency = %d", freq );
391 391
392 audioSampleCounter = 0; 392 audioSampleCounter = 0;
393 393
394 int bits_per_sample = mediaPlayerState->curDecoder()->audioBitsPerSample( astream); 394 int bits_per_sample = mediaPlayerState->curDecoder()->audioBitsPerSample( astream);
395 395
396 audioDevice = new AudioDevice( freq, channels, bits_per_sample); 396 audioDevice = new AudioDevice( freq, channels, bits_per_sample);
397 audioBuffer = new char[ audioDevice->bufferSize() ]; 397 audioBuffer = new char[ audioDevice->bufferSize() ];
398 channels = audioDevice->channels(); 398 channels = audioDevice->channels();
399 399
400 //### must check which frequency is actually used. 400 //### must check which frequency is actually used.
401 static const int size = 1; 401 static const int size = 1;
402 short int buf[size]; 402 short int buf[size];
403 long samplesRead = 0; 403 long samplesRead = 0;
404 mediaPlayerState->curDecoder()->audioReadSamples( buf, channels, size, samplesRead, stream ); 404 mediaPlayerState->curDecoder()->audioReadSamples( buf, channels, size, samplesRead, stream );
405 } 405 }
406 406
407 if ( hasVideoChannel ) { 407 if ( hasVideoChannel ) {
408 total_video_frames = mediaPlayerState->curDecoder()->videoFrames( stream ); 408 total_video_frames = mediaPlayerState->curDecoder()->videoFrames( stream );
409 409
410 mediaPlayerState->setLength( total_video_frames ); 410 mediaPlayerState->setLength( total_video_frames );
411 411
412 framerate = mediaPlayerState->curDecoder()->videoFrameRate( stream ); 412 framerate = mediaPlayerState->curDecoder()->videoFrameRate( stream );
413 DecodeLoopDebug(( "Frame rate %g total %ld", framerate, total_video_frames )); 413 DecodeLoopDebug(( "Frame rate %g total %ld", framerate, total_video_frames ));
414 414
415 if ( framerate <= 1.0 ) { 415 if ( framerate <= 1.0 ) {
416 DecodeLoopDebug(( "Crazy frame rate, resetting to sensible" )); 416 DecodeLoopDebug(( "Crazy frame rate, resetting to sensible" ));
417 framerate = 25; 417 framerate = 25;
418 } 418 }
419 419
420 if ( total_video_frames == 1 ) { 420 if ( total_video_frames == 1 ) {
421 DecodeLoopDebug(( "Cannot seek to frame" )); 421 DecodeLoopDebug(( "Cannot seek to frame" ));
422 } 422 }
423 423
424 } 424 }
425 425
426 current_frame = 0; 426 current_frame = 0;
427 prev_frame = -1; 427 prev_frame = -1;
428 428
429 connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( setPosition( long ) ) ); 429 connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( setPosition( long ) ) );
430 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( setPaused( bool ) ) ); 430 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( setPaused( bool ) ) );
431 431
432 audioMutex->unlock(); 432 audioMutex->unlock();
433 433
434 return TRUE; 434 return TRUE;
435} 435}
436 436
437 437
438void LoopControl::play() { 438void LoopControl::play() {
439 439
440#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 440#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
441 if ( !disabledSuspendScreenSaver || previousSuspendMode != hasVideoChannel ) { 441 if ( !disabledSuspendScreenSaver || previousSuspendMode != hasVideoChannel ) {
442 disabledSuspendScreenSaver = TRUE; 442 disabledSuspendScreenSaver = TRUE;
443 previousSuspendMode = hasVideoChannel; 443 previousSuspendMode = hasVideoChannel;
444 // Stop the screen from blanking and power saving state 444 // Stop the screen from blanking and power saving state
445 QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) 445 QCopEnvelope("QPE/System", "setScreenSaverMode(int)" )
446 << ( hasVideoChannel ? QPEApplication::Disable : QPEApplication::DisableSuspend ); 446 << ( hasVideoChannel ? QPEApplication::Disable : QPEApplication::DisableSuspend );
447 } 447 }
448#endif 448#endif
449 449
450 playtime.start(); 450 playtime.start();
451 startTimers(); 451 startTimers();
452} 452}
453 453
454 454
455void LoopControl::setMute( bool on ) { 455void LoopControl::setMute( bool on ) {
456 if ( on != isMuted ) { 456 if ( on != isMuted ) {
457 isMuted = on; 457 isMuted = on;
458 if ( !on ) { 458 if ( !on ) {
459 // Force an update of the position 459 // Force an update of the position
460 mediaPlayerState->setPosition( mediaPlayerState->position() + 1 ); 460 mediaPlayerState->setPosition( mediaPlayerState->position() + 1 );
461 mediaPlayerState->setPosition( mediaPlayerState->position() - 1 ); 461 mediaPlayerState->setPosition( mediaPlayerState->position() - 1 );
462 // Resume playing audio 462 // Resume playing audio
463 moreAudio = TRUE; 463 moreAudio = TRUE;
464 } 464 }
465 } 465 }
466} 466}
467 467
468 468
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,693 +1,698 @@
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 {
333 const DocLnk *lnk = d->selectedFiles->current(); 338 const DocLnk *lnk = d->selectedFiles->current();
334 if ( lnk ) { 339 if ( lnk ) {
335 QString entryName; 340 QString entryName;
336 entryName.sprintf( "File%i", noOfFiles + 1 ); 341 entryName.sprintf( "File%i", noOfFiles + 1 );
337 cfg.writeEntry( entryName, lnk->linkFile() ); 342 cfg.writeEntry( entryName, lnk->linkFile() );
338 // if this link does exist, add it so we have the file 343 // if this link does exist, add it so we have the file
339 // next time... 344 // next time...
340 if ( !QFile::exists( lnk->linkFile() ) ) { 345 if ( !QFile::exists( lnk->linkFile() ) ) {
341 // the way writing lnks doesn't really check for out 346 // the way writing lnks doesn't really check for out
342 // of disk space, but check it anyway. 347 // of disk space, but check it anyway.
343 if ( !lnk->writeLink() ) { 348 if ( !lnk->writeLink() ) {
344 QMessageBox::critical( 0, tr("Out of space"), 349 QMessageBox::critical( 0, tr("Out of space"),
345 tr( "There was a problem saving " 350 tr( "There was a problem saving "
346 "the playlist.\n" 351 "the playlist.\n"
347 "Your playlist " 352 "Your playlist "
348 "may be missing some entries\n" 353 "may be missing some entries\n"
349 "the next time you start it." ) 354 "the next time you start it." )
350 ); 355 );
351 } 356 }
352 } 357 }
353 noOfFiles++; 358 noOfFiles++;
354 } 359 }
355 } while ( d->selectedFiles->next() ); 360 } while ( d->selectedFiles->next() );
356 361
357 cfg.writeEntry("NumberOfFiles", noOfFiles ); 362 cfg.writeEntry("NumberOfFiles", noOfFiles );
358} 363}
359 364
360 365
361void PlayListWidget::addToSelection( const DocLnk& lnk ) { 366void PlayListWidget::addToSelection( const DocLnk& lnk ) {
362 d->setDocumentUsed = FALSE; 367 d->setDocumentUsed = FALSE;
363 if ( mediaPlayerState->playlist() ) 368 if ( mediaPlayerState->playlist() )
364 d->selectedFiles->addToSelection( lnk ); 369 d->selectedFiles->addToSelection( lnk );
365 else 370 else
366 mediaPlayerState->setPlaying( TRUE ); 371 mediaPlayerState->setPlaying( TRUE );
367} 372}
368 373
369 374
370void PlayListWidget::addToSelection( QListViewItem *it ,const QPoint & p, int index) { 375void PlayListWidget::addToSelection( QListViewItem *it ,const QPoint & p, int index) {
371 qDebug("add"); 376 qDebug("add");
372// d->selectedFiles->addToSelection( lnk ); 377// d->selectedFiles->addToSelection( lnk );
373 // } 378 // }
374// else 379// else
375// mediaPlayerState->setPlaying( TRUE ); 380// mediaPlayerState->setPlaying( TRUE );
376// 381//
377} 382}
378 383
379 384
380void PlayListWidget::clearList() { 385void PlayListWidget::clearList() {
381 while ( first() ) 386 while ( first() )
382 d->selectedFiles->removeSelected(); 387 d->selectedFiles->removeSelected();
383} 388}
384 389
385 390
386void PlayListWidget::addAllToList() { 391void PlayListWidget::addAllToList() {
387 DocLnkSet files; 392 DocLnkSet files;
388 Global::findDocuments(&files, "video/*;audio/*"); 393 Global::findDocuments(&files, "video/*;audio/*");
389 QListIterator<DocLnk> dit( files.children() ); 394 QListIterator<DocLnk> dit( files.children() );
390 for ( ; dit.current(); ++dit ) 395 for ( ; dit.current(); ++dit )
391 d->selectedFiles->addToSelection( **dit ); 396 d->selectedFiles->addToSelection( **dit );
392} 397}
393 398
394 399
395void PlayListWidget::addAllMusicToList() { 400void PlayListWidget::addAllMusicToList() {
396 DocLnkSet files; 401 DocLnkSet files;
397 Global::findDocuments(&files, "audio/*"); 402 Global::findDocuments(&files, "audio/*");
398 QListIterator<DocLnk> dit( files.children() ); 403 QListIterator<DocLnk> dit( files.children() );
399 for ( ; dit.current(); ++dit ) 404 for ( ; dit.current(); ++dit )
400 d->selectedFiles->addToSelection( **dit ); 405 d->selectedFiles->addToSelection( **dit );
401} 406}
402 407
403 408
404void PlayListWidget::addAllVideoToList() { 409void PlayListWidget::addAllVideoToList() {
405 DocLnkSet files; 410 DocLnkSet files;
406 Global::findDocuments(&files, "video/*"); 411 Global::findDocuments(&files, "video/*");
407 QListIterator<DocLnk> dit( files.children() ); 412 QListIterator<DocLnk> dit( files.children() );
408 for ( ; dit.current(); ++dit ) 413 for ( ; dit.current(); ++dit )
409 d->selectedFiles->addToSelection( **dit ); 414 d->selectedFiles->addToSelection( **dit );
410} 415}
411 416
412 417
413void PlayListWidget::setDocument(const QString& fileref) { 418void PlayListWidget::setDocument(const QString& fileref) {
414 if ( fileref.isNull() ) { 419 if ( fileref.isNull() ) {
415 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); 420 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) );
416 return; 421 return;
417 } 422 }
418 if ( mediaPlayerState->playlist() ) 423 if ( mediaPlayerState->playlist() )
419 addToSelection( DocLnk( fileref ) ); 424 addToSelection( DocLnk( fileref ) );
420 else { 425 else {
421 d->setDocumentUsed = TRUE; 426 d->setDocumentUsed = TRUE;
422 if ( d->current ) 427 if ( d->current )
423 delete d->current; 428 delete d->current;
424 d->current = new DocLnk( fileref ); 429 d->current = new DocLnk( fileref );
425 } 430 }
426 mediaPlayerState->setPlaying( FALSE ); 431 mediaPlayerState->setPlaying( FALSE );
427 mediaPlayerState->setPlaying( TRUE ); 432 mediaPlayerState->setPlaying( TRUE );
428} 433}
429 434
430 435
431void PlayListWidget::setActiveWindow() { 436void PlayListWidget::setActiveWindow() {
432 // When we get raised we need to ensure that it switches views 437 // When we get raised we need to ensure that it switches views
433 char origView = mediaPlayerState->view(); 438 char origView = mediaPlayerState->view();
434 mediaPlayerState->setView( 'l' ); // invalidate 439 mediaPlayerState->setView( 'l' ); // invalidate
435 mediaPlayerState->setView( origView ); // now switch back 440 mediaPlayerState->setView( origView ); // now switch back
436} 441}
437 442
438 443
439void PlayListWidget::useSelectedDocument() { 444void PlayListWidget::useSelectedDocument() {
440 d->setDocumentUsed = FALSE; 445 d->setDocumentUsed = FALSE;
441} 446}
442 447
443 448
444const DocLnk *PlayListWidget::current() { 449const DocLnk *PlayListWidget::current() {
445 if ( mediaPlayerState->playlist() ) 450 if ( mediaPlayerState->playlist() )
446 return d->selectedFiles->current(); 451 return d->selectedFiles->current();
447 else if ( d->setDocumentUsed && d->current ) { 452 else if ( d->setDocumentUsed && d->current ) {
448 return d->current; 453 return d->current;
449 } else 454 } else
450 return d->files->selected(); 455 return d->files->selected();
451} 456}
452 457
453 458
454bool PlayListWidget::prev() { 459bool PlayListWidget::prev() {
455 if ( mediaPlayerState->playlist() ) { 460 if ( mediaPlayerState->playlist() ) {
456 if ( mediaPlayerState->shuffled() ) { 461 if ( mediaPlayerState->shuffled() ) {
457 const DocLnk *cur = current(); 462 const DocLnk *cur = current();
458 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 463 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
459 for ( int i = 0; i < j; i++ ) { 464 for ( int i = 0; i < j; i++ ) {
460 if ( !d->selectedFiles->next() ) 465 if ( !d->selectedFiles->next() )
461 d->selectedFiles->first(); 466 d->selectedFiles->first();
462 } 467 }
463 if ( cur == current() ) 468 if ( cur == current() )
464 if ( !d->selectedFiles->next() ) 469 if ( !d->selectedFiles->next() )
465 d->selectedFiles->first(); 470 d->selectedFiles->first();
466 return TRUE; 471 return TRUE;
467 } else { 472 } else {
468 if ( !d->selectedFiles->prev() ) { 473 if ( !d->selectedFiles->prev() ) {
469 if ( mediaPlayerState->looping() ) { 474 if ( mediaPlayerState->looping() ) {
470 return d->selectedFiles->last(); 475 return d->selectedFiles->last();
471 } else { 476 } else {
472 return FALSE; 477 return FALSE;
473 } 478 }
474 } 479 }
475 return TRUE; 480 return TRUE;
476 } 481 }
477 } else { 482 } else {
478 return mediaPlayerState->looping(); 483 return mediaPlayerState->looping();
479 } 484 }
480} 485}
481 486
482 487
483bool PlayListWidget::next() { 488bool PlayListWidget::next() {
484 if ( mediaPlayerState->playlist() ) { 489 if ( mediaPlayerState->playlist() ) {
485 if ( mediaPlayerState->shuffled() ) { 490 if ( mediaPlayerState->shuffled() ) {
486 return prev(); 491 return prev();
487 } else { 492 } else {
488 if ( !d->selectedFiles->next() ) { 493 if ( !d->selectedFiles->next() ) {
489 if ( mediaPlayerState->looping() ) { 494 if ( mediaPlayerState->looping() ) {
490 return d->selectedFiles->first(); 495 return d->selectedFiles->first();
491 } else { 496 } else {
492 return FALSE; 497 return FALSE;
493 } 498 }
494 } 499 }
495 return TRUE; 500 return TRUE;
496 } 501 }
497 } else { 502 } else {
498 return mediaPlayerState->looping(); 503 return mediaPlayerState->looping();
499 } 504 }
500} 505}
501 506
502 507
503bool PlayListWidget::first() { 508bool PlayListWidget::first() {
504 if ( mediaPlayerState->playlist() ) 509 if ( mediaPlayerState->playlist() )
505 return d->selectedFiles->first(); 510 return d->selectedFiles->first();
506 else 511 else
507 return mediaPlayerState->looping(); 512 return mediaPlayerState->looping();
508} 513}
509 514
510 515
511bool PlayListWidget::last() { 516bool PlayListWidget::last() {
512 if ( mediaPlayerState->playlist() ) 517 if ( mediaPlayerState->playlist() )
513 return d->selectedFiles->last(); 518 return d->selectedFiles->last();
514 else 519 else
515 return mediaPlayerState->looping(); 520 return mediaPlayerState->looping();
516} 521}
517 522
518 523
519void PlayListWidget::saveList() { 524void PlayListWidget::saveList() {
520 QString filename; 525 QString filename;
521// pseudo code 526// pseudo code
522// filename = QLineEdit->getText(); 527// filename = QLineEdit->getText();
523 Config cfg( filename + ".playlist" ); 528 Config cfg( filename + ".playlist" );
524 writeConfig( cfg ); 529 writeConfig( cfg );
525} 530}
526 531
527 532
528void PlayListWidget::loadList() { 533void PlayListWidget::loadList() {
529 QString filename; 534 QString filename;
530// pseudo code 535// pseudo code
531// filename = FileSelector->openFile( "*.playlist" ); 536// filename = FileSelector->openFile( "*.playlist" );
532 Config cfg( filename + ".playlist" ); 537 Config cfg( filename + ".playlist" );
533 readConfig( cfg ); 538 readConfig( cfg );
534} 539}
535 540
536 541
537void PlayListWidget::setPlaylist( bool shown ) { 542void PlayListWidget::setPlaylist( bool shown ) {
538 if ( shown ) 543 if ( shown )
539 d->playListFrame->show(); 544 d->playListFrame->show();
540 else 545 else
541 d->playListFrame->hide(); 546 d->playListFrame->hide();
542} 547}
543 548
544 549
545void PlayListWidget::setView( char view ) { 550void PlayListWidget::setView( char view ) {
546 if ( view == 'l' ) 551 if ( view == 'l' )
547 showMaximized(); 552 showMaximized();
548 else 553 else
549 hide(); 554 hide();
550} 555}
551 556
552void PlayListWidget::addSelected() { 557void PlayListWidget::addSelected() {
553// QMessageBox::message("Note","Bozo the clown thinks\nthere's something actually here"); 558// QMessageBox::message("Note","Bozo the clown thinks\nthere's something actually here");
554 int tabPage=tabWidget->currentPageIndex(); 559 int tabPage=tabWidget->currentPageIndex();
555 switch (tabPage) { 560 switch (tabPage) {
556 case 0: //playlist 561 case 0: //playlist
557 break; 562 break;
558 case 1: { //audio 563 case 1: { //audio
559 addToSelection( audioView->selectedItem() ); 564 addToSelection( audioView->selectedItem() );
560 } 565 }
561 break; 566 break;
562 case 2: { // video 567 case 2: { // video
563 addToSelection( videoView->selectedItem() ); 568 addToSelection( videoView->selectedItem() );
564 } 569 }
565 break; 570 break;
566 }; 571 };
567} 572}
568 573
569void PlayListWidget::removeSelected() { 574void 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