summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/audiodevice.cpp15
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp10
2 files changed, 18 insertions, 7 deletions
diff --git a/core/multimedia/opieplayer/audiodevice.cpp b/core/multimedia/opieplayer/audiodevice.cpp
index faadd72..8f04d0d 100644
--- a/core/multimedia/opieplayer/audiodevice.cpp
+++ b/core/multimedia/opieplayer/audiodevice.cpp
@@ -1,309 +1,320 @@
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 <qmessagebox.h>
28
27#include "audiodevice.h" 29#include "audiodevice.h"
28 30
31
32#include <errno.h>
33
29#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) 34#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
30#include "qpe/qcopenvelope_qws.h" 35#include "qpe/qcopenvelope_qws.h"
31#endif 36#endif
32 37
33// #ifdef Q_WS_WIN 38// #ifdef Q_WS_WIN
34// #include <windows.h> 39// #include <windows.h>
35// #include <mmsystem.h> 40// #include <mmsystem.h>
36// #include <mmreg.h> 41// #include <mmreg.h>
37// #endif 42// #endif
38#if defined(Q_WS_X11) || defined(Q_WS_QWS) 43#if defined(Q_WS_X11) || defined(Q_WS_QWS)
39#include <fcntl.h> 44#include <fcntl.h>
40#include <sys/ioctl.h> 45#include <sys/ioctl.h>
41#include <sys/soundcard.h> 46#include <sys/soundcard.h>
42#include <sys/stat.h> 47#include <sys/stat.h>
43#include <sys/time.h> 48#include <sys/time.h>
44#include <sys/types.h> 49#include <sys/types.h>
45#include <unistd.h> 50#include <unistd.h>
46#endif 51#endif
47 52
48// #if defined(Q_OS_WIN32) 53// #if defined(Q_OS_WIN32)
49// static const int expectedBytesPerMilliSecond = 2 * 2 * 44000 / 1000; 54// static const int expectedBytesPerMilliSecond = 2 * 2 * 44000 / 1000;
50// static const int timerResolutionMilliSeconds = 30; 55// static const int timerResolutionMilliSeconds = 30;
51// static const int sound_fragment_bytes = timerResolutionMilliSeconds * expectedBytesPerMilliSecond; 56// static const int sound_fragment_bytes = timerResolutionMilliSeconds * expectedBytesPerMilliSecond;
52// #else 57// #else
53# if defined(QT_QWS_IPAQ) 58# if defined(QT_QWS_IPAQ)
54static const int sound_fragment_shift = 14; 59static const int sound_fragment_shift = 14;
55# else 60# else
56static const int sound_fragment_shift = 16; 61static const int sound_fragment_shift = 16;
57# endif 62# endif
58static const int sound_fragment_bytes = (1<<sound_fragment_shift); 63static const int sound_fragment_bytes = (1<<sound_fragment_shift);
59//#endif 64//#endif
60 65
61 66
62class AudioDevicePrivate { 67class AudioDevicePrivate {
63public: 68public:
64 int handle; 69 int handle;
65 unsigned int frequency; 70 unsigned int frequency;
66 unsigned int channels; 71 unsigned int channels;
67 unsigned int bytesPerSample; 72 unsigned int bytesPerSample;
68 unsigned int bufferSize; 73 unsigned int bufferSize;
69//#ifndef Q_OS_WIN32 74//#ifndef Q_OS_WIN32
70 bool can_GETOSPACE; 75 bool can_GETOSPACE;
71 char* unwrittenBuffer; 76 char* unwrittenBuffer;
72 unsigned int unwritten; 77 unsigned int unwritten;
73//#endif 78//#endif
74 79
75 static int dspFd; 80 static int dspFd;
76 static bool muted; 81 static bool muted;
77 static unsigned int leftVolume; 82 static unsigned int leftVolume;
78 static unsigned int rightVolume; 83 static unsigned int rightVolume;
79}; 84};
80 85
81 86
82#ifdef Q_WS_QWS 87#ifdef Q_WS_QWS
83// This is for keeping the device open in-between playing files when 88// This is for keeping the device open in-between playing files when
84// the device makes clicks and it starts to drive you insane! :) 89// the device makes clicks and it starts to drive you insane! :)
85// Best to have the device not open when not using it though 90// Best to have the device not open when not using it though
86//#define KEEP_DEVICE_OPEN 91//#define KEEP_DEVICE_OPEN
87#endif 92#endif
88 93
89 94
90int AudioDevicePrivate::dspFd = 0; 95int AudioDevicePrivate::dspFd = 0;
91bool AudioDevicePrivate::muted = FALSE; 96bool AudioDevicePrivate::muted = FALSE;
92unsigned int AudioDevicePrivate::leftVolume = 0; 97unsigned int AudioDevicePrivate::leftVolume = 0;
93unsigned int AudioDevicePrivate::rightVolume = 0; 98unsigned int AudioDevicePrivate::rightVolume = 0;
94 99
95 100
96void AudioDevice::getVolume( unsigned int& leftVolume, unsigned int& rightVolume, bool &muted ) { 101void AudioDevice::getVolume( unsigned int& leftVolume, unsigned int& rightVolume, bool &muted ) {
97 muted = AudioDevicePrivate::muted; 102 muted = AudioDevicePrivate::muted;
98 unsigned int volume; 103 unsigned int volume;
99// #ifdef Q_OS_WIN32 104// #ifdef Q_OS_WIN32
100// HWAVEOUT handle; 105// HWAVEOUT handle;
101// WAVEFORMATEX formatData; 106// WAVEFORMATEX formatData;
102// formatData.cbSize = sizeof(WAVEFORMATEX); 107// formatData.cbSize = sizeof(WAVEFORMATEX);
103// formatData.wFormatTag = WAVE_FORMAT_PCM; 108// formatData.wFormatTag = WAVE_FORMAT_PCM;
104// formatData.nAvgBytesPerSec = 4 * 44000; 109// formatData.nAvgBytesPerSec = 4 * 44000;
105// formatData.nBlockAlign = 4; 110// formatData.nBlockAlign = 4;
106// formatData.nChannels = 2; 111// formatData.nChannels = 2;
107// formatData.nSamplesPerSec = 44000; 112// formatData.nSamplesPerSec = 44000;
108// formatData.wBitsPerSample = 16; 113// formatData.wBitsPerSample = 16;
109// waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL); 114// waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL);
110// if ( waveOutGetVolume( handle, (LPDWORD)&volume ) ) 115// if ( waveOutGetVolume( handle, (LPDWORD)&volume ) )
111// // qDebug( "get volume of audio device failed" ); 116// // qDebug( "get volume of audio device failed" );
112// waveOutClose( handle ); 117// waveOutClose( handle );
113// leftVolume = volume & 0xFFFF; 118// leftVolume = volume & 0xFFFF;
114// rightVolume = volume >> 16; 119// rightVolume = volume >> 16;
115// #else 120// #else
116 int mixerHandle = open( "/dev/mixer", O_RDWR ); 121 int mixerHandle = open( "/dev/mixer", O_RDWR );
117 if ( mixerHandle >= 0 ) { 122 if ( mixerHandle >= 0 ) {
118 if(ioctl( mixerHandle, MIXER_READ(0), &volume )==-1) 123 if(ioctl( mixerHandle, MIXER_READ(0), &volume )==-1)
119 perror("ioctl(\"MIXER_READ\")"); 124 perror("ioctl(\"MIXER_READ\")");
120 close( mixerHandle ); 125 close( mixerHandle );
121 } else 126 } else
122 perror("open(\"/dev/mixer\")"); 127 perror("open(\"/dev/mixer\")");
123 leftVolume = ((volume & 0x00FF) << 16) / 101; 128 leftVolume = ((volume & 0x00FF) << 16) / 101;
124 rightVolume = ((volume & 0xFF00) << 8) / 101; 129 rightVolume = ((volume & 0xFF00) << 8) / 101;
125//#endif 130//#endif
126} 131}
127 132
128 133
129void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, bool muted ) { 134void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, bool muted ) {
130 AudioDevicePrivate::muted = muted; 135 AudioDevicePrivate::muted = muted;
131 if ( muted ) { 136 if ( muted ) {
132 AudioDevicePrivate::leftVolume = leftVolume; 137 AudioDevicePrivate::leftVolume = leftVolume;
133 AudioDevicePrivate::rightVolume = rightVolume; 138 AudioDevicePrivate::rightVolume = rightVolume;
134 leftVolume = 0; 139 leftVolume = 0;
135 rightVolume = 0; 140 rightVolume = 0;
136 } else { 141 } else {
137 leftVolume = ( (int) leftVolume < 0 ) ? 0 : (( leftVolume > 0xFFFF ) ? 0xFFFF : leftVolume ); 142 leftVolume = ( (int) leftVolume < 0 ) ? 0 : (( leftVolume > 0xFFFF ) ? 0xFFFF : leftVolume );
138 rightVolume = ( (int)rightVolume < 0 ) ? 0 : (( rightVolume > 0xFFFF ) ? 0xFFFF : rightVolume ); 143 rightVolume = ( (int)rightVolume < 0 ) ? 0 : (( rightVolume > 0xFFFF ) ? 0xFFFF : rightVolume );
139 } 144 }
140// #ifdef Q_OS_WIN32 145// #ifdef Q_OS_WIN32
141// HWAVEOUT handle; 146// HWAVEOUT handle;
142// WAVEFORMATEX formatData; 147// WAVEFORMATEX formatData;
143// formatData.cbSize = sizeof(WAVEFORMATEX); 148// formatData.cbSize = sizeof(WAVEFORMATEX);
144// formatData.wFormatTag = WAVE_FORMAT_PCM; 149// formatData.wFormatTag = WAVE_FORMAT_PCM;
145// formatData.nAvgBytesPerSec = 4 * 44000; 150// formatData.nAvgBytesPerSec = 4 * 44000;
146// formatData.nBlockAlign = 4; 151// formatData.nBlockAlign = 4;
147// formatData.nChannels = 2; 152// formatData.nChannels = 2;
148// formatData.nSamplesPerSec = 44000; 153// formatData.nSamplesPerSec = 44000;
149// formatData.wBitsPerSample = 16; 154// formatData.wBitsPerSample = 16;
150// waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL); 155// waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL);
151// unsigned int volume = (rightVolume << 16) | leftVolume; 156// unsigned int volume = (rightVolume << 16) | leftVolume;
152// if ( waveOutSetVolume( handle, volume ) ) 157// if ( waveOutSetVolume( handle, volume ) )
153// // qDebug( "set volume of audio device failed" ); 158// // qDebug( "set volume of audio device failed" );
154// waveOutClose( handle ); 159// waveOutClose( handle );
155// #else 160// #else
156 // Volume can be from 0 to 100 which is 101 distinct values 161 // Volume can be from 0 to 100 which is 101 distinct values
157 unsigned int rV = (rightVolume * 101) >> 16; 162 unsigned int rV = (rightVolume * 101) >> 16;
158 163
159# if 0 164# if 0
160 unsigned int lV = (leftVolume * 101) >> 16; 165 unsigned int lV = (leftVolume * 101) >> 16;
161 unsigned int volume = ((rV << 8) & 0xFF00) | (lV & 0x00FF); 166 unsigned int volume = ((rV << 8) & 0xFF00) | (lV & 0x00FF);
162 int mixerHandle = 0; 167 int mixerHandle = 0;
163 if ( ( mixerHandle = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 168 if ( ( mixerHandle = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
164 if(ioctl( mixerHandle, MIXER_WRITE(0), &volume ) ==-1) 169 if(ioctl( mixerHandle, MIXER_WRITE(0), &volume ) ==-1)
165 perror("ioctl(\"MIXER_WRITE\")"); 170 perror("ioctl(\"MIXER_WRITE\")");
166 close( mixerHandle ); 171 close( mixerHandle );
167 } else 172 } else
168 perror("open(\"/dev/mixer\")"); 173 perror("open(\"/dev/mixer\")");
169 174
170# else 175# else
171 // This is the way this has to be done now I guess, doesn't allow for 176 // This is the way this has to be done now I guess, doesn't allow for
172 // independant right and left channel setting, or setting for different outputs 177 // independant right and left channel setting, or setting for different outputs
173 Config cfg("qpe"); // qtopia is "Sound" 178 Config cfg("qpe"); // qtopia is "Sound"
174 cfg.setGroup("Volume"); // qtopia is "Settings" 179 cfg.setGroup("Volume"); // qtopia is "Settings"
175 cfg.writeEntry("VolumePercent",(int)rV); //qtopia is Volume 180 cfg.writeEntry("VolumePercent",(int)rV); //qtopia is Volume
176# endif 181# endif
177 182
178//#endif 183//#endif
179// qDebug( "setting volume to: 0x%x", volume ); 184// qDebug( "setting volume to: 0x%x", volume );
180#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) 185#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
181 // Send notification that the volume has changed 186 // Send notification that the volume has changed
182 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted; 187 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted;
183#endif 188#endif
184} 189}
185 190
186 191
187 192
188 193
189AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) { 194AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) {
190 qDebug("creating new audio device"); 195 qDebug("creating new audio device");
191 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; 196 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE;
192 d = new AudioDevicePrivate; 197 d = new AudioDevicePrivate;
193 d->frequency = f; 198 d->frequency = f;
194 d->channels = chs; 199 d->channels = chs;
195 d->bytesPerSample = bps; 200 d->bytesPerSample = bps;
196 qDebug("%d",bps); 201 qDebug("%d",bps);
197 int format=0; 202 int format=0;
198 if( bps == 8) format = AFMT_U8; 203 if( bps == 8) format = AFMT_U8;
199 else if( bps <= 0) format = AFMT_S16_LE; 204 else if( bps <= 0) format = AFMT_S16_LE;
200 else format = AFMT_S16_LE; 205 else format = AFMT_S16_LE;
201 qDebug("AD- freq %d, channels %d, b/sample %d, bitrate %d",f,chs,bps,format); 206 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) ) ); 207 connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) );
203 208
204 int fragments = 0x10000 * 8 + sound_fragment_shift; 209 int fragments = 0x10000 * 8 + sound_fragment_shift;
205 int capabilities = 0; 210 int capabilities = 0;
206 211
207 212
208#ifdef KEEP_DEVICE_OPEN 213#ifdef KEEP_DEVICE_OPEN
209 if ( AudioDevicePrivate::dspFd == 0 ) { 214 if ( AudioDevicePrivate::dspFd == 0 ) {
210#endif 215#endif
211 if ( ( d->handle = ::open( "/dev/dsp", O_WRONLY ) ) < 0 ) { 216 if ( ( d->handle = ::open( "/dev/dsp", O_WRONLY ) ) < 0 ) {
212 perror("open(\"/dev/dsp\") sending to /dev/null instead"); 217
213 d->handle = ::open( "/dev/null", O_WRONLY ); 218// perror("open(\"/dev/dsp\") sending to /dev/null instead");
219 perror("open(\"/dev/dsp\")");
220 QString errorMsg=tr("Somethin's wrong with\nyour sound device.\nopen(\"/dev/dsp\")\n")+(QString)strerror(errno)+tr("\n\nClosing player now.");
221 QMessageBox::critical(0, "Vmemo", errorMsg, tr("Abort"));
222 exit(-1); //harsh?
223// d->handle = ::open( "/dev/null", O_WRONLY );
224 // WTF?!?!
214 } 225 }
215#ifdef KEEP_DEVICE_OPEN 226#ifdef KEEP_DEVICE_OPEN
216 AudioDevicePrivate::dspFd = d->handle; 227 AudioDevicePrivate::dspFd = d->handle;
217 } else { 228 } else {
218 d->handle = AudioDevicePrivate::dspFd; 229 d->handle = AudioDevicePrivate::dspFd;
219 } 230 }
220#endif 231#endif
221 232
222 if(ioctl( d->handle, SNDCTL_DSP_GETCAPS, &capabilities )==-1) 233 if(ioctl( d->handle, SNDCTL_DSP_GETCAPS, &capabilities )==-1)
223 perror("ioctl(\"SNDCTL_DSP_GETCAPS\")"); 234 perror("ioctl(\"SNDCTL_DSP_GETCAPS\")");
224 if(ioctl( d->handle, SNDCTL_DSP_SETFRAGMENT, &fragments )==-1) 235 if(ioctl( d->handle, SNDCTL_DSP_SETFRAGMENT, &fragments )==-1)
225 perror("ioctl(\"SNDCTL_DSP_SETFRAGMENT\")"); 236 perror("ioctl(\"SNDCTL_DSP_SETFRAGMENT\")");
226 if(ioctl( d->handle, SNDCTL_DSP_SETFMT, & format )==-1) 237 if(ioctl( d->handle, SNDCTL_DSP_SETFMT, & format )==-1)
227 perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); 238 perror("ioctl(\"SNDCTL_DSP_SETFMT\")");
228 qDebug("freq %d", d->frequency); 239 qDebug("freq %d", d->frequency);
229 if(ioctl( d->handle, SNDCTL_DSP_SPEED, &d->frequency )==-1) 240 if(ioctl( d->handle, SNDCTL_DSP_SPEED, &d->frequency )==-1)
230 perror("ioctl(\"SNDCTL_DSP_SPEED\")"); 241 perror("ioctl(\"SNDCTL_DSP_SPEED\")");
231 qDebug("channels %d",d->channels); 242 qDebug("channels %d",d->channels);
232 if ( ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels ) == -1 ) { 243 if ( ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels ) == -1 ) {
233 d->channels = ( d->channels == 1 ) ? 2 : d->channels; 244 d->channels = ( d->channels == 1 ) ? 2 : d->channels;
234 if(ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels )==-1) 245 if(ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels )==-1)
235 perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); 246 perror("ioctl(\"SNDCTL_DSP_CHANNELS\")");
236 } 247 }
237 248
238 d->bufferSize = sound_fragment_bytes; 249 d->bufferSize = sound_fragment_bytes;
239 d->unwrittenBuffer = new char[d->bufferSize]; 250 d->unwrittenBuffer = new char[d->bufferSize];
240 d->unwritten = 0; 251 d->unwritten = 0;
241 d->can_GETOSPACE = TRUE; // until we find otherwise 252 d->can_GETOSPACE = TRUE; // until we find otherwise
242 253
243 //if ( chs != d->channels ) qDebug( "Wanted %d, got %d channels", chs, d->channels ); 254 //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 ); 255 //if ( f != d->frequency ) qDebug( "wanted %dHz, got %dHz", f, d->frequency );
245 //if ( capabilities & DSP_CAP_BATCH ) qDebug( "Sound card has local buffer" ); 256 //if ( capabilities & DSP_CAP_BATCH ) qDebug( "Sound card has local buffer" );
246 //if ( capabilities & DSP_CAP_REALTIME )qDebug( "Sound card has realtime sync" ); 257 //if ( capabilities & DSP_CAP_REALTIME )qDebug( "Sound card has realtime sync" );
247 //if ( capabilities & DSP_CAP_TRIGGER ) qDebug( "Sound card has precise trigger" ); 258 //if ( capabilities & DSP_CAP_TRIGGER ) qDebug( "Sound card has precise trigger" );
248 //if ( capabilities & DSP_CAP_MMAP ) qDebug( "Sound card can mmap" ); 259 //if ( capabilities & DSP_CAP_MMAP ) qDebug( "Sound card can mmap" );
249 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; 260 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE;
250 261
251} 262}
252 263
253 264
254AudioDevice::~AudioDevice() { 265AudioDevice::~AudioDevice() {
255 qDebug("destryo audiodevice"); 266 qDebug("destryo audiodevice");
256 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; 267 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE;
257 268
258// #ifdef Q_OS_WIN32 269// #ifdef Q_OS_WIN32
259// waveOutClose( (HWAVEOUT)d->handle ); 270// waveOutClose( (HWAVEOUT)d->handle );
260// #else 271// #else
261# ifndef KEEP_DEVICE_OPEN 272# ifndef KEEP_DEVICE_OPEN
262 close( d->handle ); // Now it should be safe to shut the handle 273 close( d->handle ); // Now it should be safe to shut the handle
263# endif 274# endif
264 delete d->unwrittenBuffer; 275 delete d->unwrittenBuffer;
265 delete d; 276 delete d;
266//#endif 277//#endif
267 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; 278 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE;
268 279
269} 280}
270 281
271 282
272void AudioDevice::volumeChanged( bool muted ) 283void AudioDevice::volumeChanged( bool muted )
273{ 284{
274 AudioDevicePrivate::muted = muted; 285 AudioDevicePrivate::muted = muted;
275} 286}
276 287
277 288
278void AudioDevice::write( char *buffer, unsigned int length ) 289void AudioDevice::write( char *buffer, unsigned int length )
279{ 290{
280// #ifdef Q_OS_WIN32 291// #ifdef Q_OS_WIN32
281// // returns immediately and (to be implemented) emits completedIO() when finished writing 292// // returns immediately and (to be implemented) emits completedIO() when finished writing
282// WAVEHDR *lpWaveHdr = (WAVEHDR *)malloc( sizeof(WAVEHDR) ); 293// WAVEHDR *lpWaveHdr = (WAVEHDR *)malloc( sizeof(WAVEHDR) );
283// // maybe the buffer should be copied so that this fool proof, but its a performance hit 294// // maybe the buffer should be copied so that this fool proof, but its a performance hit
284// lpWaveHdr->lpData = buffer; 295// lpWaveHdr->lpData = buffer;
285// lpWaveHdr->dwBufferLength = length; 296// lpWaveHdr->dwBufferLength = length;
286// lpWaveHdr->dwFlags = 0L; 297// lpWaveHdr->dwFlags = 0L;
287// lpWaveHdr->dwLoops = 0L; 298// lpWaveHdr->dwLoops = 0L;
288// waveOutPrepareHeader( (HWAVEOUT)d->handle, lpWaveHdr, sizeof(WAVEHDR) ); 299// waveOutPrepareHeader( (HWAVEOUT)d->handle, lpWaveHdr, sizeof(WAVEHDR) );
289// // waveOutWrite returns immediately. the data is sent in the background. 300// // waveOutWrite returns immediately. the data is sent in the background.
290// if ( waveOutWrite( (HWAVEOUT)d->handle, lpWaveHdr, sizeof(WAVEHDR) ) ) 301// if ( waveOutWrite( (HWAVEOUT)d->handle, lpWaveHdr, sizeof(WAVEHDR) ) )
291// qDebug( "failed to write block to audio device" ); 302// qDebug( "failed to write block to audio device" );
292// // emit completedIO(); 303// // emit completedIO();
293// #else 304// #else
294 int t = ::write( d->handle, buffer, length ); 305 int t = ::write( d->handle, buffer, length );
295 if ( t<0 ) t = 0; 306 if ( t<0 ) t = 0;
296 if ( t != (int)length) { 307 if ( t != (int)length) {
297 qDebug("Ahhh!! memcpys 1"); 308 qDebug("Ahhh!! memcpys 1");
298 memcpy(d->unwrittenBuffer,buffer+t,length-t); 309 memcpy(d->unwrittenBuffer,buffer+t,length-t);
299 d->unwritten = length-t; 310 d->unwritten = length-t;
300 } 311 }
301//#endif 312//#endif
302} 313}
303 314
304 315
305unsigned int AudioDevice::channels() const 316unsigned int AudioDevice::channels() const
306{ 317{
307 return d->channels; 318 return d->channels;
308} 319}
309 320
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index ae25fe3..0332237 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -324,205 +324,205 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
324 324
325 setCentralWidget( vbox5 ); 325 setCentralWidget( vbox5 );
326 326
327 Config cfg( "OpiePlayer" ); 327 Config cfg( "OpiePlayer" );
328 readConfig( cfg ); 328 readConfig( cfg );
329 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 329 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
330// qDebug("currentList is "+currentPlaylist); 330// qDebug("currentList is "+currentPlaylist);
331 loadList(DocLnk( currentPlaylist)); 331 loadList(DocLnk( currentPlaylist));
332 setCaption(tr("OpiePlayer: ")+ currentPlaylist ); 332 setCaption(tr("OpiePlayer: ")+ currentPlaylist );
333 333
334 initializeStates(); 334 initializeStates();
335} 335}
336 336
337 337
338PlayListWidget::~PlayListWidget() { 338PlayListWidget::~PlayListWidget() {
339 Config cfg( "OpiePlayer" ); 339 Config cfg( "OpiePlayer" );
340 writeConfig( cfg ); 340 writeConfig( cfg );
341 341
342 342
343 if ( d->current ) 343 if ( d->current )
344 delete d->current; 344 delete d->current;
345 delete d; 345 delete d;
346} 346}
347 347
348 348
349void PlayListWidget::initializeStates() { 349void PlayListWidget::initializeStates() {
350 350
351 d->tbPlay->setOn( mediaPlayerState->playing() ); 351 d->tbPlay->setOn( mediaPlayerState->playing() );
352 d->tbLoop->setOn( mediaPlayerState->looping() ); 352 d->tbLoop->setOn( mediaPlayerState->looping() );
353 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 353 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
354// d->tbFull->setOn( mediaPlayerState->fullscreen() ); 354// d->tbFull->setOn( mediaPlayerState->fullscreen() );
355// d->tbScale->setOn( mediaPlayerState->scaled() ); 355// d->tbScale->setOn( mediaPlayerState->scaled() );
356// d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); 356// d->tbScale->setEnabled( mediaPlayerState->fullscreen() );
357// setPlaylist( mediaPlayerState->playlist() ); 357// setPlaylist( mediaPlayerState->playlist() );
358 setPlaylist( true); 358 setPlaylist( true);
359// d->selectedFiles->first(); 359// d->selectedFiles->first();
360 360
361} 361}
362 362
363 363
364void PlayListWidget::readConfig( Config& cfg ) { 364void PlayListWidget::readConfig( Config& cfg ) {
365 cfg.setGroup("PlayList"); 365 cfg.setGroup("PlayList");
366 QString currentString = cfg.readEntry("current", "" ); 366 QString currentString = cfg.readEntry("current", "" );
367 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 367 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
368 for ( int i = 0; i < noOfFiles; i++ ) { 368 for ( int i = 0; i < noOfFiles; i++ ) {
369 QString entryName; 369 QString entryName;
370 entryName.sprintf( "File%i", i + 1 ); 370 entryName.sprintf( "File%i", i + 1 );
371 QString linkFile = cfg.readEntry( entryName ); 371 QString linkFile = cfg.readEntry( entryName );
372 DocLnk lnk( linkFile ); 372 DocLnk lnk( linkFile );
373 if ( lnk.isValid() ) { 373 if ( lnk.isValid() ) {
374 d->selectedFiles->addToSelection( lnk ); 374 d->selectedFiles->addToSelection( lnk );
375 } 375 }
376 } 376 }
377 d->selectedFiles->setSelectedItem( currentString); 377 d->selectedFiles->setSelectedItem( currentString);
378// d->selectedFiles->setSelectedItem( (const QString &)currentString); 378// d->selectedFiles->setSelectedItem( (const QString &)currentString);
379} 379}
380 380
381 381
382void PlayListWidget::writeConfig( Config& cfg ) const { 382void PlayListWidget::writeConfig( Config& cfg ) const {
383 383
384 d->selectedFiles->writeCurrent( cfg); 384 d->selectedFiles->writeCurrent( cfg);
385 cfg.setGroup("PlayList"); 385 cfg.setGroup("PlayList");
386 int noOfFiles = 0; 386 int noOfFiles = 0;
387 d->selectedFiles->first(); 387 d->selectedFiles->first();
388 do { 388 do {
389 const DocLnk *lnk = d->selectedFiles->current(); 389 const DocLnk *lnk = d->selectedFiles->current();
390 if ( lnk ) { 390 if ( lnk ) {
391 QString entryName; 391 QString entryName;
392 entryName.sprintf( "File%i", noOfFiles + 1 ); 392 entryName.sprintf( "File%i", noOfFiles + 1 );
393// qDebug(entryName); 393// qDebug(entryName);
394 cfg.writeEntry( entryName, lnk->linkFile() ); 394 cfg.writeEntry( entryName, lnk->linkFile() );
395 // if this link does exist, add it so we have the file 395 // if this link does exist, add it so we have the file
396 // next time... 396 // next time...
397 if ( !QFile::exists( lnk->linkFile() ) ) { 397 if ( !QFile::exists( lnk->linkFile() ) ) {
398 // the way writing lnks doesn't really check for out 398 // the way writing lnks doesn't really check for out
399 // of disk space, but check it anyway. 399 // of disk space, but check it anyway.
400 if ( !lnk->writeLink() ) { 400 if ( !lnk->writeLink() ) {
401 QMessageBox::critical( 0, tr("Out of space"), 401 QMessageBox::critical( 0, tr("Out of space"),
402 tr( "There was a problem saving " 402 tr( "There was a problem saving "
403 "the playlist.\n" 403 "the playlist.\n"
404 "Your playlist " 404 "Your playlist "
405 "may be missing some entries\n" 405 "may be missing some entries\n"
406 "the next time you start it." ) 406 "the next time you start it." )
407 ); 407 );
408 } 408 }
409 } 409 }
410 noOfFiles++; 410 noOfFiles++;
411 } 411 }
412 } 412 }
413 while ( d->selectedFiles->next() ); 413 while ( d->selectedFiles->next() );
414 cfg.writeEntry("NumberOfFiles", noOfFiles ); 414 cfg.writeEntry("NumberOfFiles", noOfFiles );
415} 415}
416 416
417 417
418void PlayListWidget::addToSelection( const DocLnk& lnk ) { 418void PlayListWidget::addToSelection( const DocLnk& lnk ) {
419// qDebug("add"); 419// qDebug("add");
420 if( lnk.file().find(" ",0,TRUE) != -1 || lnk.file().find("%20",0,TRUE) != -1) { 420// if( lnk.file().find(" ",0,TRUE) != -1 || lnk.file().find("%20",0,TRUE) != -1) {
421 QMessageBox::message("Note","You are trying to play\na malformed url."); 421// QMessageBox::message("Note","You are trying to play\na malformed url.");
422 422
423 } else { 423// } else {
424 424
425 d->setDocumentUsed = FALSE; 425 d->setDocumentUsed = FALSE;
426 if ( mediaPlayerState->playlist() ) { 426 if ( mediaPlayerState->playlist() ) {
427 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) 427 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" )
428 d->selectedFiles->addToSelection( lnk ); 428 d->selectedFiles->addToSelection( lnk );
429 } 429 }
430 else 430 else
431 mediaPlayerState->setPlaying( TRUE ); 431 mediaPlayerState->setPlaying( TRUE );
432 } 432// }
433} 433}
434 434
435 435
436void PlayListWidget::clearList() { 436void PlayListWidget::clearList() {
437 while ( first() ) 437 while ( first() )
438 d->selectedFiles->removeSelected(); 438 d->selectedFiles->removeSelected();
439} 439}
440 440
441 441
442void PlayListWidget::addAllToList() { 442void PlayListWidget::addAllToList() {
443 DocLnkSet filesAll; 443 DocLnkSet filesAll;
444 Global::findDocuments(&filesAll, "video/*;audio/*"); 444 Global::findDocuments(&filesAll, "video/*;audio/*");
445 QListIterator<DocLnk> Adit( filesAll.children() ); 445 QListIterator<DocLnk> Adit( filesAll.children() );
446 for ( ; Adit.current(); ++Adit ) 446 for ( ; Adit.current(); ++Adit )
447 if(QFileInfo(Adit.current()->file()).exists()) 447 if(QFileInfo(Adit.current()->file()).exists())
448 d->selectedFiles->addToSelection( **Adit ); 448 d->selectedFiles->addToSelection( **Adit );
449} 449}
450 450
451 451
452void PlayListWidget::addAllMusicToList() { 452void PlayListWidget::addAllMusicToList() {
453 QListIterator<DocLnk> dit( files.children() ); 453 QListIterator<DocLnk> dit( files.children() );
454 for ( ; dit.current(); ++dit ) 454 for ( ; dit.current(); ++dit )
455 if(QFileInfo(dit.current()->file()).exists()) 455 if(QFileInfo(dit.current()->file()).exists())
456 d->selectedFiles->addToSelection( **dit ); 456 d->selectedFiles->addToSelection( **dit );
457} 457}
458 458
459 459
460void PlayListWidget::addAllVideoToList() { 460void PlayListWidget::addAllVideoToList() {
461 QListIterator<DocLnk> dit( vFiles.children() ); 461 QListIterator<DocLnk> dit( vFiles.children() );
462 for ( ; dit.current(); ++dit ) 462 for ( ; dit.current(); ++dit )
463 if(QFileInfo( dit.current()->file()).exists()) 463 if(QFileInfo( dit.current()->file()).exists())
464 d->selectedFiles->addToSelection( **dit ); 464 d->selectedFiles->addToSelection( **dit );
465} 465}
466 466
467 467
468void PlayListWidget::setDocument(const QString& fileref) { 468void PlayListWidget::setDocument(const QString& fileref) {
469 qDebug(fileref); 469 qDebug(fileref);
470 fromSetDocument = TRUE; 470 fromSetDocument = TRUE;
471 if ( fileref.isNull() ) { 471 if ( fileref.isNull() ) {
472 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); 472 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) );
473 return; 473 return;
474 } 474 }
475// qDebug("setDocument "+fileref); 475// qDebug("setDocument "+fileref);
476 if(fileref.find("m3u",0,TRUE) != -1) { //is m3u 476 if(fileref.find("m3u",0,TRUE) != -1) { //is m3u
477 readm3u( fileref); 477 readm3u( fileref);
478 } 478 }
479 else if(fileref.find("pls",0,TRUE) != -1) { //is pls 479 else if(fileref.find("pls",0,TRUE) != -1) { //is pls
480 readPls( fileref); 480 readPls( fileref);
481 } 481 }
482 else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist 482 else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist
483 clearList(); 483 clearList();
484 loadList(DocLnk(fileref)); 484 loadList(DocLnk(fileref));
485 d->selectedFiles->first(); 485 d->selectedFiles->first();
486 } else { 486 } else {
487 clearList(); 487 clearList();
488 addToSelection( DocLnk( fileref ) ); 488 addToSelection( DocLnk( fileref ) );
489 d->setDocumentUsed = TRUE; 489 d->setDocumentUsed = TRUE;
490 mediaPlayerState->setPlaying( FALSE ); 490 mediaPlayerState->setPlaying( FALSE );
491 qApp->processEvents(); 491 qApp->processEvents();
492 mediaPlayerState->setPlaying( TRUE ); 492 mediaPlayerState->setPlaying( TRUE );
493 qApp->processEvents(); 493 qApp->processEvents();
494 setCaption(tr("OpiePlayer")); 494 setCaption(tr("OpiePlayer"));
495 } 495 }
496} 496}
497 497
498 498
499void PlayListWidget::setActiveWindow() { 499void PlayListWidget::setActiveWindow() {
500 // When we get raised we need to ensure that it switches views 500 // When we get raised we need to ensure that it switches views
501 char origView = mediaPlayerState->view(); 501 char origView = mediaPlayerState->view();
502 mediaPlayerState->setView( 'l' ); // invalidate 502 mediaPlayerState->setView( 'l' ); // invalidate
503 mediaPlayerState->setView( origView ); // now switch back 503 mediaPlayerState->setView( origView ); // now switch back
504} 504}
505 505
506 506
507void PlayListWidget::useSelectedDocument() { 507void PlayListWidget::useSelectedDocument() {
508 d->setDocumentUsed = FALSE; 508 d->setDocumentUsed = FALSE;
509} 509}
510 510
511 511
512const DocLnk *PlayListWidget::current() { // this is fugly 512const DocLnk *PlayListWidget::current() { // this is fugly
513 513
514// if( fromSetDocument) { 514// if( fromSetDocument) {
515// qDebug("from setDoc"); 515// qDebug("from setDoc");
516// DocLnkSet files; 516// DocLnkSet files;
517// Global::findDocuments(&files, "video/*;audio/*"); 517// Global::findDocuments(&files, "video/*;audio/*");
518// QListIterator<DocLnk> dit( files.children() ); 518// QListIterator<DocLnk> dit( files.children() );
519// for ( ; dit.current(); ++dit ) { 519// for ( ; dit.current(); ++dit ) {
520// if(dit.current()->linkFile() == setDocFileRef) { 520// if(dit.current()->linkFile() == setDocFileRef) {
521// qDebug(setDocFileRef); 521// qDebug(setDocFileRef);
522// return dit; 522// return dit;
523// } 523// }
524// } 524// }
525// } else 525// } else
526 526
527 527
528 switch (tabWidget->currentPageIndex()) { 528 switch (tabWidget->currentPageIndex()) {
@@ -762,193 +762,193 @@ void PlayListWidget::addSelected() {
762 }; 762 };
763} 763}
764 764
765void PlayListWidget::removeSelected() { 765void PlayListWidget::removeSelected() {
766 d->selectedFiles->removeSelected( ); 766 d->selectedFiles->removeSelected( );
767} 767}
768 768
769void PlayListWidget::playIt( QListViewItem *it) { 769void PlayListWidget::playIt( QListViewItem *it) {
770// d->setDocumentUsed = FALSE; 770// d->setDocumentUsed = FALSE;
771// mediaPlayerState->curPosition =0; 771// mediaPlayerState->curPosition =0;
772 qDebug("playIt"); 772 qDebug("playIt");
773 mediaPlayerState->setPlaying(FALSE); 773 mediaPlayerState->setPlaying(FALSE);
774 mediaPlayerState->setPlaying(TRUE); 774 mediaPlayerState->setPlaying(TRUE);
775 d->selectedFiles->unSelect(); 775 d->selectedFiles->unSelect();
776} 776}
777 777
778void PlayListWidget::addToSelection( QListViewItem *it) { 778void PlayListWidget::addToSelection( QListViewItem *it) {
779 d->setDocumentUsed = FALSE; 779 d->setDocumentUsed = FALSE;
780 780
781 if(it) { 781 if(it) {
782 switch (tabWidget->currentPageIndex()) { 782 switch (tabWidget->currentPageIndex()) {
783 case 1: { 783 case 1: {
784 QListIterator<DocLnk> dit( files.children() ); 784 QListIterator<DocLnk> dit( files.children() );
785 for ( ; dit.current(); ++dit ) { 785 for ( ; dit.current(); ++dit ) {
786 if( dit.current()->name() == it->text(0)) { 786 if( dit.current()->name() == it->text(0)) {
787 d->selectedFiles->addToSelection( **dit ); 787 d->selectedFiles->addToSelection( **dit );
788 } 788 }
789 } 789 }
790 } 790 }
791 break; 791 break;
792 case 2: { 792 case 2: {
793 QListIterator<DocLnk> dit( vFiles.children() ); 793 QListIterator<DocLnk> dit( vFiles.children() );
794 for ( ; dit.current(); ++dit ) { 794 for ( ; dit.current(); ++dit ) {
795 if( dit.current()->name() == it->text(0)) { 795 if( dit.current()->name() == it->text(0)) {
796 d->selectedFiles->addToSelection( **dit ); 796 d->selectedFiles->addToSelection( **dit );
797 } 797 }
798 } 798 }
799 } 799 }
800 break; 800 break;
801 case 0: 801 case 0:
802 break; 802 break;
803 }; 803 };
804 tabWidget->setCurrentPage(0); 804 tabWidget->setCurrentPage(0);
805 } 805 }
806} 806}
807 807
808void PlayListWidget::tabChanged(QWidget *widg) { 808void PlayListWidget::tabChanged(QWidget *widg) {
809 809
810 switch ( tabWidget->currentPageIndex()) { 810 switch ( tabWidget->currentPageIndex()) {
811 case 0: 811 case 0:
812 { 812 {
813 if( !tbDeletePlaylist->isHidden()) 813 if( !tbDeletePlaylist->isHidden())
814 tbDeletePlaylist->hide(); 814 tbDeletePlaylist->hide();
815 d->tbRemoveFromList->setEnabled(TRUE); 815 d->tbRemoveFromList->setEnabled(TRUE);
816 d->tbAddToList->setEnabled(FALSE); 816 d->tbAddToList->setEnabled(FALSE);
817 } 817 }
818 break; 818 break;
819 case 1: 819 case 1:
820 { 820 {
821 audioView->clear(); 821 audioView->clear();
822 populateAudioView(); 822 populateAudioView();
823 823
824 if( !tbDeletePlaylist->isHidden()) 824 if( !tbDeletePlaylist->isHidden())
825 tbDeletePlaylist->hide(); 825 tbDeletePlaylist->hide();
826 d->tbRemoveFromList->setEnabled(FALSE); 826 d->tbRemoveFromList->setEnabled(FALSE);
827 d->tbAddToList->setEnabled(TRUE); 827 d->tbAddToList->setEnabled(TRUE);
828 } 828 }
829 break; 829 break;
830 case 2: 830 case 2:
831 { 831 {
832 videoView->clear(); 832 videoView->clear();
833 populateVideoView(); 833 populateVideoView();
834 if( !tbDeletePlaylist->isHidden()) 834 if( !tbDeletePlaylist->isHidden())
835 tbDeletePlaylist->hide(); 835 tbDeletePlaylist->hide();
836 d->tbRemoveFromList->setEnabled(FALSE); 836 d->tbRemoveFromList->setEnabled(FALSE);
837 d->tbAddToList->setEnabled(TRUE); 837 d->tbAddToList->setEnabled(TRUE);
838 } 838 }
839 break; 839 break;
840 case 3: 840 case 3:
841 { 841 {
842 if( tbDeletePlaylist->isHidden()) 842 if( tbDeletePlaylist->isHidden())
843 tbDeletePlaylist->show(); 843 tbDeletePlaylist->show();
844 playLists->reread(); 844 playLists->reread();
845 } 845 }
846 break; 846 break;
847 }; 847 };
848} 848}
849 849
850void PlayListWidget::btnPlay(bool b) { 850void PlayListWidget::btnPlay(bool b) {
851 851
852// mediaPlayerState->setPlaying(b); 852// mediaPlayerState->setPlaying(b);
853 switch ( tabWidget->currentPageIndex()) { 853 switch ( tabWidget->currentPageIndex()) {
854 case 0: 854 case 0:
855 { 855 {
856// if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 856// if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1
857// if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { 857// if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) {
858 QMessageBox::message("Note","You are trying to play\na malformed url."); 858// QMessageBox::message("Note","You are trying to play\na malformed url.");
859// } else { 859// } else {
860 mediaPlayerState->setPlaying(b); 860 mediaPlayerState->setPlaying(b);
861// } 861// }
862 } 862 }
863 break; 863 break;
864 case 1: 864 case 1:
865 { 865 {
866 addToSelection( audioView->currentItem() ); 866 addToSelection( audioView->currentItem() );
867 mediaPlayerState->setPlaying(b); 867 mediaPlayerState->setPlaying(b);
868 d->selectedFiles->removeSelected( ); 868 d->selectedFiles->removeSelected( );
869 tabWidget->setCurrentPage(1); 869 tabWidget->setCurrentPage(1);
870 d->selectedFiles->unSelect(); 870 d->selectedFiles->unSelect();
871 insanityBool=FALSE; 871 insanityBool=FALSE;
872 }// audioView->clearSelection(); 872 }// audioView->clearSelection();
873 break; 873 break;
874 case 2: 874 case 2:
875 { 875 {
876 addToSelection( videoView->currentItem() ); 876 addToSelection( videoView->currentItem() );
877 mediaPlayerState->setPlaying(b); 877 mediaPlayerState->setPlaying(b);
878 qApp->processEvents(); 878 qApp->processEvents();
879 d->selectedFiles->removeSelected( ); 879 d->selectedFiles->removeSelected( );
880 tabWidget->setCurrentPage(2); 880 tabWidget->setCurrentPage(2);
881 d->selectedFiles->unSelect(); 881 d->selectedFiles->unSelect();
882 insanityBool=FALSE; 882 insanityBool=FALSE;
883 }// videoView->clearSelection(); 883 }// videoView->clearSelection();
884 break; 884 break;
885 }; 885 };
886 886
887} 887}
888 888
889void PlayListWidget::deletePlaylist() { 889void PlayListWidget::deletePlaylist() {
890 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 890 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
891 (tr("You really want to delete\nthis playlist?")), 891 (tr("You really want to delete\nthis playlist?")),
892 (tr("Yes")), (tr("No")), 0 )){ 892 (tr("Yes")), (tr("No")), 0 )){
893 case 0: // Yes clicked, 893 case 0: // Yes clicked,
894 QFile().remove(playLists->selected()->file()); 894 QFile().remove(playLists->selected()->file());
895 QFile().remove(playLists->selected()->linkFile()); 895 QFile().remove(playLists->selected()->linkFile());
896 playLists->reread(); 896 playLists->reread();
897 break; 897 break;
898 case 1: // Cancel 898 case 1: // Cancel
899 break; 899 break;
900 }; 900 };
901} 901}
902 902
903void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) 903void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i)
904{ 904{
905 switch (mouse) { 905 switch (mouse) {
906 case 1: 906 case 1:
907 break; 907 break;
908 case 2:{ 908 case 2:{
909 909
910 QPopupMenu m; 910 QPopupMenu m;
911 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 911 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
912 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 912 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
913 m.insertSeparator(); 913 m.insertSeparator();
914 if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) 914 if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() )
915 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 915 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
916 916
917 m.exec( QCursor::pos() ); 917 m.exec( QCursor::pos() );
918 } 918 }
919 break; 919 break;
920 }; 920 };
921} 921}
922 922
923void PlayListWidget::playSelected() 923void PlayListWidget::playSelected()
924{ 924{
925 btnPlay( TRUE); 925 btnPlay( TRUE);
926// d->selectedFiles->unSelect(); 926// d->selectedFiles->unSelect();
927} 927}
928 928
929void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) 929void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i)
930{ 930{
931 switch (mouse) { 931 switch (mouse) {
932 case 1: 932 case 1:
933 933
934 break; 934 break;
935 case 2:{ 935 case 2:{
936 QPopupMenu m; 936 QPopupMenu m;
937 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 937 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
938 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 938 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
939// m.insertSeparator(); 939// m.insertSeparator();
940// m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 940// m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
941 m.exec( QCursor::pos() ); 941 m.exec( QCursor::pos() );
942 } 942 }
943 break; 943 break;
944 }; 944 };
945 945
946} 946}
947 947
948void PlayListWidget::listDelete() { 948void PlayListWidget::listDelete() {
949 Config cfg( "OpiePlayer" ); 949 Config cfg( "OpiePlayer" );
950 cfg.setGroup("PlayList"); 950 cfg.setGroup("PlayList");
951 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 951 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
952 QString file; 952 QString file;
953 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 953 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
954 switch ( tabWidget->currentPageIndex()) { 954 switch ( tabWidget->currentPageIndex()) {