summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/audiodevice.cpp1
-rw-r--r--core/multimedia/opieplayer/audiowidget.cpp6
-rw-r--r--core/multimedia/opieplayer/mediaplayer.cpp7
-rw-r--r--core/multimedia/opieplayer/mediaplayerstate.cpp2
-rw-r--r--core/multimedia/opieplayer/modplug/load_j2b.cpp1
-rw-r--r--core/multimedia/opieplayer/om3u.cpp15
-rw-r--r--core/multimedia/opieplayer/playlistselection.cpp8
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp25
-rw-r--r--core/multimedia/opieplayer/videowidget.cpp4
-rw-r--r--core/opie-login/loginwindowimpl.cpp4
-rw-r--r--core/opie-login/main.cpp4
-rw-r--r--core/opie-login/opie-login.pro2
12 files changed, 2 insertions, 77 deletions
diff --git a/core/multimedia/opieplayer/audiodevice.cpp b/core/multimedia/opieplayer/audiodevice.cpp
index d296d27..355062b 100644
--- a/core/multimedia/opieplayer/audiodevice.cpp
+++ b/core/multimedia/opieplayer/audiodevice.cpp
@@ -1,323 +1,322 @@
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 <qpe/custom.h>
28#include <qmessagebox.h> 27#include <qmessagebox.h>
29 28
30#include "audiodevice.h" 29#include "audiodevice.h"
31 30
32 31
33#include <errno.h> 32#include <errno.h>
34 33
35#if !defined(QT_NO_COP) 34#if !defined(QT_NO_COP)
36#include <qpe/qcopenvelope_qws.h> 35#include <qpe/qcopenvelope_qws.h>
37#endif 36#endif
38 37
39#if defined(Q_WS_X11) || defined(Q_WS_QWS) 38#if defined(Q_WS_X11) || defined(Q_WS_QWS)
40#include <fcntl.h> 39#include <fcntl.h>
41#include <sys/ioctl.h> 40#include <sys/ioctl.h>
42#include <sys/soundcard.h> 41#include <sys/soundcard.h>
43#include <sys/stat.h> 42#include <sys/stat.h>
44#include <sys/time.h> 43#include <sys/time.h>
45#include <sys/types.h> 44#include <sys/types.h>
46#include <unistd.h> 45#include <unistd.h>
47#endif 46#endif
48 47
49#ifdef OPIE_SOUND_FRAGMENT_SHIFT 48#ifdef OPIE_SOUND_FRAGMENT_SHIFT
50static const int sound_fragment_shift = OPIE_SOUND_FRAGMENT_SHIFT; 49static const int sound_fragment_shift = OPIE_SOUND_FRAGMENT_SHIFT;
51#else 50#else
52static const int sound_fragment_shift = 16; 51static const int sound_fragment_shift = 16;
53#endif 52#endif
54static const int sound_fragment_bytes = (1<<sound_fragment_shift); 53static const int sound_fragment_bytes = (1<<sound_fragment_shift);
55//#endif 54//#endif
56 55
57 56
58class AudioDevicePrivate { 57class AudioDevicePrivate {
59public: 58public:
60 int handle; 59 int handle;
61 unsigned int frequency; 60 unsigned int frequency;
62 unsigned int channels; 61 unsigned int channels;
63 unsigned int bytesPerSample; 62 unsigned int bytesPerSample;
64 unsigned int bufferSize; 63 unsigned int bufferSize;
65//#ifndef Q_OS_WIN32 64//#ifndef Q_OS_WIN32
66 bool can_GETOSPACE; 65 bool can_GETOSPACE;
67 char* unwrittenBuffer; 66 char* unwrittenBuffer;
68 unsigned int unwritten; 67 unsigned int unwritten;
69//#endif 68//#endif
70 69
71 static int dspFd; 70 static int dspFd;
72 static bool muted; 71 static bool muted;
73 static unsigned int leftVolume; 72 static unsigned int leftVolume;
74 static unsigned int rightVolume; 73 static unsigned int rightVolume;
75}; 74};
76 75
77 76
78#ifdef Q_WS_QWS 77#ifdef Q_WS_QWS
79// This is for keeping the device open in-between playing files when 78// This is for keeping the device open in-between playing files when
80// the device makes clicks and it starts to drive you insane! :) 79// the device makes clicks and it starts to drive you insane! :)
81// Best to have the device not open when not using it though 80// Best to have the device not open when not using it though
82//#define KEEP_DEVICE_OPEN 81//#define KEEP_DEVICE_OPEN
83#endif 82#endif
84 83
85 84
86int AudioDevicePrivate::dspFd = 0; 85int AudioDevicePrivate::dspFd = 0;
87bool AudioDevicePrivate::muted = FALSE; 86bool AudioDevicePrivate::muted = FALSE;
88unsigned int AudioDevicePrivate::leftVolume = 0; 87unsigned int AudioDevicePrivate::leftVolume = 0;
89unsigned int AudioDevicePrivate::rightVolume = 0; 88unsigned int AudioDevicePrivate::rightVolume = 0;
90 89
91 90
92void AudioDevice::getVolume( unsigned int& leftVolume, unsigned int& rightVolume, bool &muted ) { 91void AudioDevice::getVolume( unsigned int& leftVolume, unsigned int& rightVolume, bool &muted ) {
93 muted = AudioDevicePrivate::muted; 92 muted = AudioDevicePrivate::muted;
94 unsigned int volume; 93 unsigned int volume;
95#ifdef QT_QWS_DEVFS 94#ifdef QT_QWS_DEVFS
96 int mixerHandle = open( "/dev/sound/mixer", O_RDWR ); 95 int mixerHandle = open( "/dev/sound/mixer", O_RDWR );
97#else 96#else
98 int mixerHandle = open( "/dev/mixer", O_RDWR ); 97 int mixerHandle = open( "/dev/mixer", O_RDWR );
99#endif 98#endif
100 if ( mixerHandle >= 0 ) { 99 if ( mixerHandle >= 0 ) {
101 if(ioctl( mixerHandle, MIXER_READ(0), &volume )==-1) 100 if(ioctl( mixerHandle, MIXER_READ(0), &volume )==-1)
102 perror("ioctl(\"MIXER_READ\")"); 101 perror("ioctl(\"MIXER_READ\")");
103 close( mixerHandle ); 102 close( mixerHandle );
104 } else 103 } else
105 perror("open(\"/dev/mixer\")"); 104 perror("open(\"/dev/mixer\")");
106 leftVolume = ((volume & 0x00FF) << 16) / 101; 105 leftVolume = ((volume & 0x00FF) << 16) / 101;
107 rightVolume = ((volume & 0xFF00) << 8) / 101; 106 rightVolume = ((volume & 0xFF00) << 8) / 101;
108} 107}
109 108
110 109
111void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, bool muted ) { 110void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, bool muted ) {
112 AudioDevicePrivate::muted = muted; 111 AudioDevicePrivate::muted = muted;
113 if ( muted ) { 112 if ( muted ) {
114 AudioDevicePrivate::leftVolume = leftVolume; 113 AudioDevicePrivate::leftVolume = leftVolume;
115 AudioDevicePrivate::rightVolume = rightVolume; 114 AudioDevicePrivate::rightVolume = rightVolume;
116 leftVolume = 0; 115 leftVolume = 0;
117 rightVolume = 0; 116 rightVolume = 0;
118 } else { 117 } else {
119 leftVolume = ( (int) leftVolume < 0 ) ? 0 : (( leftVolume > 0xFFFF ) ? 0xFFFF : leftVolume ); 118 leftVolume = ( (int) leftVolume < 0 ) ? 0 : (( leftVolume > 0xFFFF ) ? 0xFFFF : leftVolume );
120 rightVolume = ( (int)rightVolume < 0 ) ? 0 : (( rightVolume > 0xFFFF ) ? 0xFFFF : rightVolume ); 119 rightVolume = ( (int)rightVolume < 0 ) ? 0 : (( rightVolume > 0xFFFF ) ? 0xFFFF : rightVolume );
121 } 120 }
122 // Volume can be from 0 to 100 which is 101 distinct values 121 // Volume can be from 0 to 100 which is 101 distinct values
123 unsigned int rV = (rightVolume * 101) >> 16; 122 unsigned int rV = (rightVolume * 101) >> 16;
124 123
125# if 0 124# if 0
126 unsigned int lV = (leftVolume * 101) >> 16; 125 unsigned int lV = (leftVolume * 101) >> 16;
127 unsigned int volume = ((rV << 8) & 0xFF00) | (lV & 0x00FF); 126 unsigned int volume = ((rV << 8) & 0xFF00) | (lV & 0x00FF);
128 int mixerHandle = 0; 127 int mixerHandle = 0;
129#ifdef QT_QWS_DEVFS 128#ifdef QT_QWS_DEVFS
130 if ( ( mixerHandle = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { 129 if ( ( mixerHandle = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) {
131#else 130#else
132 if ( ( mixerHandle = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 131 if ( ( mixerHandle = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
133#endif 132#endif
134 if(ioctl( mixerHandle, MIXER_WRITE(0), &volume ) ==-1) 133 if(ioctl( mixerHandle, MIXER_WRITE(0), &volume ) ==-1)
135 perror("ioctl(\"MIXER_WRITE\")"); 134 perror("ioctl(\"MIXER_WRITE\")");
136 close( mixerHandle ); 135 close( mixerHandle );
137 } else 136 } else
138 perror("open(\"/dev/mixer\")"); 137 perror("open(\"/dev/mixer\")");
139 138
140# else 139# else
141 // This is the way this has to be done now I guess, doesn't allow for 140 // This is the way this has to be done now I guess, doesn't allow for
142 // independant right and left channel setting, or setting for different outputs 141 // independant right and left channel setting, or setting for different outputs
143 Config cfg("qpe"); // qtopia is "Sound" 142 Config cfg("qpe"); // qtopia is "Sound"
144 cfg.setGroup("Volume"); // qtopia is "Settings" 143 cfg.setGroup("Volume"); // qtopia is "Settings"
145 cfg.writeEntry("VolumePercent",(int)rV); //qtopia is Volume 144 cfg.writeEntry("VolumePercent",(int)rV); //qtopia is Volume
146# endif 145# endif
147 146
148//#endif 147//#endif
149// qDebug( "setting volume to: 0x%x", volume ); 148// qDebug( "setting volume to: 0x%x", volume );
150#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) 149#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
151 // Send notification that the volume has changed 150 // Send notification that the volume has changed
152 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted; 151 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted;
153#endif 152#endif
154} 153}
155 154
156 155
157 156
158AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) { 157AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) {
159 // qDebug("creating new audio device"); 158 // qDebug("creating new audio device");
160// QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; 159// QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE;
161 d = new AudioDevicePrivate; 160 d = new AudioDevicePrivate;
162 d->frequency = f; 161 d->frequency = f;
163 d->channels = chs; 162 d->channels = chs;
164 d->bytesPerSample = bps; 163 d->bytesPerSample = bps;
165 // qDebug("%d",bps); 164 // qDebug("%d",bps);
166 int format=0; 165 int format=0;
167 if( bps == 8) format = AFMT_U8; 166 if( bps == 8) format = AFMT_U8;
168 else if( bps <= 0) format = AFMT_S16_LE; 167 else if( bps <= 0) format = AFMT_S16_LE;
169 else format = AFMT_S16_LE; 168 else format = AFMT_S16_LE;
170 // qDebug("AD- freq %d, channels %d, b/sample %d, bitrate %d",f,chs,bps,format); 169 // qDebug("AD- freq %d, channels %d, b/sample %d, bitrate %d",f,chs,bps,format);
171 connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) ); 170 connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) );
172 171
173 int fragments = 0x10000 * 8 + sound_fragment_shift; 172 int fragments = 0x10000 * 8 + sound_fragment_shift;
174 int capabilities = 0; 173 int capabilities = 0;
175 174
176 175
177#ifdef KEEP_DEVICE_OPEN 176#ifdef KEEP_DEVICE_OPEN
178 if ( AudioDevicePrivate::dspFd == 0 ) { 177 if ( AudioDevicePrivate::dspFd == 0 ) {
179#endif 178#endif
180#ifdef QT_QWS_DEVFS 179#ifdef QT_QWS_DEVFS
181 if ( ( d->handle = ::open( "/dev/sound/dsp", O_WRONLY ) ) < 0 ) { 180 if ( ( d->handle = ::open( "/dev/sound/dsp", O_WRONLY ) ) < 0 ) {
182#else 181#else
183 if ( ( d->handle = ::open( "/dev/dsp", O_WRONLY ) ) < 0 ) { 182 if ( ( d->handle = ::open( "/dev/dsp", O_WRONLY ) ) < 0 ) {
184#endif 183#endif
185 184
186 perror("open(\"/dev/dsp\")"); 185 perror("open(\"/dev/dsp\")");
187 QString errorMsg=tr("Somethin's wrong with\nyour sound device.\nopen(\"/dev/dsp\")\n")+(QString)strerror(errno)+tr("\n\nClosing player now."); 186 QString errorMsg=tr("Somethin's wrong with\nyour sound device.\nopen(\"/dev/dsp\")\n")+(QString)strerror(errno)+tr("\n\nClosing player now.");
188 QMessageBox::critical(0, "Vmemo", errorMsg, tr("Abort")); 187 QMessageBox::critical(0, "Vmemo", errorMsg, tr("Abort"));
189 exit(-1); //harsh? 188 exit(-1); //harsh?
190 } 189 }
191#ifdef KEEP_DEVICE_OPEN 190#ifdef KEEP_DEVICE_OPEN
192 AudioDevicePrivate::dspFd = d->handle; 191 AudioDevicePrivate::dspFd = d->handle;
193 } else { 192 } else {
194 d->handle = AudioDevicePrivate::dspFd; 193 d->handle = AudioDevicePrivate::dspFd;
195 } 194 }
196#endif 195#endif
197 196
198 if(ioctl( d->handle, SNDCTL_DSP_GETCAPS, &capabilities )==-1) 197 if(ioctl( d->handle, SNDCTL_DSP_GETCAPS, &capabilities )==-1)
199 perror("ioctl(\"SNDCTL_DSP_GETCAPS\")"); 198 perror("ioctl(\"SNDCTL_DSP_GETCAPS\")");
200 if(ioctl( d->handle, SNDCTL_DSP_SETFRAGMENT, &fragments )==-1) 199 if(ioctl( d->handle, SNDCTL_DSP_SETFRAGMENT, &fragments )==-1)
201 perror("ioctl(\"SNDCTL_DSP_SETFRAGMENT\")"); 200 perror("ioctl(\"SNDCTL_DSP_SETFRAGMENT\")");
202 if(ioctl( d->handle, SNDCTL_DSP_SETFMT, & format )==-1) 201 if(ioctl( d->handle, SNDCTL_DSP_SETFMT, & format )==-1)
203 perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); 202 perror("ioctl(\"SNDCTL_DSP_SETFMT\")");
204 // qDebug("freq %d", d->frequency); 203 // qDebug("freq %d", d->frequency);
205 if(ioctl( d->handle, SNDCTL_DSP_SPEED, &d->frequency )==-1) 204 if(ioctl( d->handle, SNDCTL_DSP_SPEED, &d->frequency )==-1)
206 perror("ioctl(\"SNDCTL_DSP_SPEED\")"); 205 perror("ioctl(\"SNDCTL_DSP_SPEED\")");
207 // qDebug("channels %d",d->channels); 206 // qDebug("channels %d",d->channels);
208 if ( ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels ) == -1 ) { 207 if ( ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels ) == -1 ) {
209 d->channels = ( d->channels == 1 ) ? 2 : d->channels; 208 d->channels = ( d->channels == 1 ) ? 2 : d->channels;
210 if(ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels )==-1) 209 if(ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels )==-1)
211 perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); 210 perror("ioctl(\"SNDCTL_DSP_CHANNELS\")");
212 } 211 }
213// QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; 212// QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE;
214 213
215 d->bufferSize = sound_fragment_bytes; 214 d->bufferSize = sound_fragment_bytes;
216 d->unwrittenBuffer = new char[d->bufferSize]; 215 d->unwrittenBuffer = new char[d->bufferSize];
217 d->unwritten = 0; 216 d->unwritten = 0;
218 d->can_GETOSPACE = TRUE; // until we find otherwise 217 d->can_GETOSPACE = TRUE; // until we find otherwise
219 218
220 //if ( chs != d->channels ) qDebug( "Wanted %d, got %d channels", chs, d->channels ); 219 //if ( chs != d->channels ) qDebug( "Wanted %d, got %d channels", chs, d->channels );
221 //if ( f != d->frequency ) qDebug( "wanted %dHz, got %dHz", f, d->frequency ); 220 //if ( f != d->frequency ) qDebug( "wanted %dHz, got %dHz", f, d->frequency );
222 //if ( capabilities & DSP_CAP_BATCH ) qDebug( "Sound card has local buffer" ); 221 //if ( capabilities & DSP_CAP_BATCH ) qDebug( "Sound card has local buffer" );
223 //if ( capabilities & DSP_CAP_REALTIME )qDebug( "Sound card has realtime sync" ); 222 //if ( capabilities & DSP_CAP_REALTIME )qDebug( "Sound card has realtime sync" );
224 //if ( capabilities & DSP_CAP_TRIGGER ) qDebug( "Sound card has precise trigger" ); 223 //if ( capabilities & DSP_CAP_TRIGGER ) qDebug( "Sound card has precise trigger" );
225 //if ( capabilities & DSP_CAP_MMAP ) qDebug( "Sound card can mmap" ); 224 //if ( capabilities & DSP_CAP_MMAP ) qDebug( "Sound card can mmap" );
226 225
227} 226}
228 227
229 228
230AudioDevice::~AudioDevice() { 229AudioDevice::~AudioDevice() {
231 // qDebug("destryo audiodevice"); 230 // qDebug("destryo audiodevice");
232// QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; 231// QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE;
233 232
234# ifndef KEEP_DEVICE_OPEN 233# ifndef KEEP_DEVICE_OPEN
235 close( d->handle ); // Now it should be safe to shut the handle 234 close( d->handle ); // Now it should be safe to shut the handle
236# endif 235# endif
237 delete d->unwrittenBuffer; 236 delete d->unwrittenBuffer;
238 delete d; 237 delete d;
239// QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; 238// QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE;
240 239
241} 240}
242 241
243 242
244void AudioDevice::volumeChanged( bool muted ) 243void AudioDevice::volumeChanged( bool muted )
245{ 244{
246 AudioDevicePrivate::muted = muted; 245 AudioDevicePrivate::muted = muted;
247} 246}
248 247
249 248
250void AudioDevice::write( char *buffer, unsigned int length ) 249void AudioDevice::write( char *buffer, unsigned int length )
251{ 250{
252 int t = ::write( d->handle, buffer, length ); 251 int t = ::write( d->handle, buffer, length );
253 if ( t<0 ) t = 0; 252 if ( t<0 ) t = 0;
254 if ( t != (int)length) { 253 if ( t != (int)length) {
255 // qDebug("Ahhh!! memcpys 1"); 254 // qDebug("Ahhh!! memcpys 1");
256 memcpy(d->unwrittenBuffer,buffer+t,length-t); 255 memcpy(d->unwrittenBuffer,buffer+t,length-t);
257 d->unwritten = length-t; 256 d->unwritten = length-t;
258 } 257 }
259//#endif 258//#endif
260} 259}
261 260
262 261
263unsigned int AudioDevice::channels() const 262unsigned int AudioDevice::channels() const
264{ 263{
265 return d->channels; 264 return d->channels;
266} 265}
267 266
268 267
269unsigned int AudioDevice::frequency() const 268unsigned int AudioDevice::frequency() const
270{ 269{
271 return d->frequency; 270 return d->frequency;
272} 271}
273 272
274 273
275unsigned int AudioDevice::bytesPerSample() const 274unsigned int AudioDevice::bytesPerSample() const
276{ 275{
277 return d->bytesPerSample; 276 return d->bytesPerSample;
278} 277}
279 278
280 279
281unsigned int AudioDevice::bufferSize() const 280unsigned int AudioDevice::bufferSize() const
282{ 281{
283 return d->bufferSize; 282 return d->bufferSize;
284} 283}
285 284
286unsigned int AudioDevice::canWrite() const 285unsigned int AudioDevice::canWrite() const
287{ 286{
288 audio_buf_info info; 287 audio_buf_info info;
289 if ( d->can_GETOSPACE && ioctl(d->handle,SNDCTL_DSP_GETOSPACE,&info) ) { 288 if ( d->can_GETOSPACE && ioctl(d->handle,SNDCTL_DSP_GETOSPACE,&info) ) {
290 d->can_GETOSPACE = FALSE; 289 d->can_GETOSPACE = FALSE;
291 fcntl( d->handle, F_SETFL, O_NONBLOCK ); 290 fcntl( d->handle, F_SETFL, O_NONBLOCK );
292 } 291 }
293 if ( d->can_GETOSPACE ) { 292 if ( d->can_GETOSPACE ) {
294 int t = info.fragments * sound_fragment_bytes; 293 int t = info.fragments * sound_fragment_bytes;
295 return QMIN(t,(int)bufferSize()); 294 return QMIN(t,(int)bufferSize());
296 } else { 295 } else {
297 if ( d->unwritten ) { 296 if ( d->unwritten ) {
298 int t = ::write( d->handle, d->unwrittenBuffer, d->unwritten ); 297 int t = ::write( d->handle, d->unwrittenBuffer, d->unwritten );
299 if ( t<0 ) t = 0; 298 if ( t<0 ) t = 0;
300 if ( (unsigned)t!=d->unwritten ) { 299 if ( (unsigned)t!=d->unwritten ) {
301 memcpy(d->unwrittenBuffer,d->unwrittenBuffer+t,d->unwritten-t); 300 memcpy(d->unwrittenBuffer,d->unwrittenBuffer+t,d->unwritten-t);
302 d->unwritten -= t; 301 d->unwritten -= t;
303 } else { 302 } else {
304 d->unwritten = 0; 303 d->unwritten = 0;
305 } 304 }
306 } 305 }
307 if ( d->unwritten ) 306 if ( d->unwritten )
308 return 0; 307 return 0;
309 else 308 else
310 return d->bufferSize; 309 return d->bufferSize;
311 } 310 }
312} 311}
313 312
314 313
315int AudioDevice::bytesWritten() { 314int AudioDevice::bytesWritten() {
316 int buffered = 0; 315 int buffered = 0;
317 if ( ioctl( d->handle, SNDCTL_DSP_GETODELAY, &buffered ) ) { 316 if ( ioctl( d->handle, SNDCTL_DSP_GETODELAY, &buffered ) ) {
318 // qDebug( "failed to get audio device position" ); 317 // qDebug( "failed to get audio device position" );
319 return -1; 318 return -1;
320 } 319 }
321 return buffered; 320 return buffered;
322} 321}
323 322
diff --git a/core/multimedia/opieplayer/audiowidget.cpp b/core/multimedia/opieplayer/audiowidget.cpp
index fbc5072..8bcc567 100644
--- a/core/multimedia/opieplayer/audiowidget.cpp
+++ b/core/multimedia/opieplayer/audiowidget.cpp
@@ -1,527 +1,521 @@
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/qpeapplication.h> 20#include <qpe/qpeapplication.h>
21#include <qpe/resource.h> 21#include <qpe/resource.h>
22#include <qpe/config.h> 22#include <qpe/config.h>
23 23
24#include <qwidget.h>
25#include <qpixmap.h>
26#include <qbutton.h>
27#include <qpainter.h>
28#include <qframe.h>
29#include <qlayout.h>
30#include <qdir.h> 24#include <qdir.h>
31#include "audiowidget.h" 25#include "audiowidget.h"
32#include "mediaplayerstate.h" 26#include "mediaplayerstate.h"
33 27
34#include <stdlib.h> 28#include <stdlib.h>
35#include <stdio.h> 29#include <stdio.h>
36 30
37extern MediaPlayerState *mediaPlayerState; 31extern MediaPlayerState *mediaPlayerState;
38 32
39 33
40static const int xo = -2; // movable x offset 34static const int xo = -2; // movable x offset
41static const int yo = 22; // movable y offset 35static const int yo = 22; // movable y offset
42 36
43struct MediaButton { 37struct MediaButton {
44 bool isToggle, isHeld, isDown; 38 bool isToggle, isHeld, isDown;
45}; 39};
46 40
47//Layout information for the audioButtons (and if it is a toggle button or not) 41//Layout information for the audioButtons (and if it is a toggle button or not)
48MediaButton audioButtons[] = { 42MediaButton audioButtons[] = {
49 { TRUE, FALSE, FALSE }, // play 43 { TRUE, FALSE, FALSE }, // play
50 { FALSE, FALSE, FALSE }, // stop 44 { FALSE, FALSE, FALSE }, // stop
51 { FALSE, FALSE, FALSE }, // next 45 { FALSE, FALSE, FALSE }, // next
52 { FALSE, FALSE, FALSE }, // previous 46 { FALSE, FALSE, FALSE }, // previous
53 { FALSE, FALSE, FALSE }, // volume up 47 { FALSE, FALSE, FALSE }, // volume up
54 { FALSE, FALSE, FALSE }, // volume down 48 { FALSE, FALSE, FALSE }, // volume down
55 { TRUE, FALSE, FALSE }, // repeat/loop 49 { TRUE, FALSE, FALSE }, // repeat/loop
56 { FALSE, FALSE, FALSE }, // playlist 50 { FALSE, FALSE, FALSE }, // playlist
57 { FALSE, FALSE, FALSE }, // forward 51 { FALSE, FALSE, FALSE }, // forward
58 { FALSE, FALSE, FALSE } // back 52 { FALSE, FALSE, FALSE } // back
59}; 53};
60 54
61const char *skin_mask_file_names[10] = { 55const char *skin_mask_file_names[10] = {
62 "play", "stop", "next", "prev", "up", 56 "play", "stop", "next", "prev", "up",
63 "down", "loop", "playlist", "forward", "back" 57 "down", "loop", "playlist", "forward", "back"
64}; 58};
65 59
66static void changeTextColor( QWidget *w ) { 60static void changeTextColor( QWidget *w ) {
67 QPalette p = w->palette(); 61 QPalette p = w->palette();
68 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); 62 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) );
69 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); 63 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) );
70 w->setPalette( p ); 64 w->setPalette( p );
71} 65}
72 66
73static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); 67static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton));
74 68
75AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : 69AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
76 QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) 70 QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this )
77{ 71{
78 setCaption( tr("OpiePlayer") ); 72 setCaption( tr("OpiePlayer") );
79 // qDebug("<<<<<audioWidget"); 73 // qDebug("<<<<<audioWidget");
80 74
81 Config cfg("OpiePlayer"); 75 Config cfg("OpiePlayer");
82 cfg.setGroup("Options"); 76 cfg.setGroup("Options");
83 skin = cfg.readEntry("Skin","default"); 77 skin = cfg.readEntry("Skin","default");
84 //skin = "scaleTest"; 78 //skin = "scaleTest";
85// color of background, frame, degree of transparency 79// color of background, frame, degree of transparency
86 80
87// QString skinPath = "opieplayer/skins/" + skin; 81// QString skinPath = "opieplayer/skins/" + skin;
88 QString skinPath; 82 QString skinPath;
89 skinPath = "opieplayer2/skins/" + skin; 83 skinPath = "opieplayer2/skins/" + skin;
90 if(!QDir(QString(getenv("OPIEDIR")) +"/pics/"+skinPath).exists()) 84 if(!QDir(QString(getenv("OPIEDIR")) +"/pics/"+skinPath).exists())
91 skinPath = "opieplayer2/skins/default"; 85 skinPath = "opieplayer2/skins/default";
92 86
93 // qDebug("skin path " + skinPath); 87 // qDebug("skin path " + skinPath);
94 88
95 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 89 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
96 imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); 90 imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) );
97 imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); 91 imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) );
98 92
99 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); 93 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 );
100 imgButtonMask->fill( 0 ); 94 imgButtonMask->fill( 0 );
101 95
102 for ( int i = 0; i < 10; i++ ) { 96 for ( int i = 0; i < 10; i++ ) {
103 QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png"; 97 QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png";
104 masks[i] = new QBitmap( filename ); 98 masks[i] = new QBitmap( filename );
105 99
106 if ( !masks[i]->isNull() ) { 100 if ( !masks[i]->isNull() ) {
107 QImage imgMask = masks[i]->convertToImage(); 101 QImage imgMask = masks[i]->convertToImage();
108 uchar **dest = imgButtonMask->jumpTable(); 102 uchar **dest = imgButtonMask->jumpTable();
109 for ( int y = 0; y < imgUp->height(); y++ ) { 103 for ( int y = 0; y < imgUp->height(); y++ ) {
110 uchar *line = dest[y]; 104 uchar *line = dest[y];
111 for ( int x = 0; x < imgUp->width(); x++ ) 105 for ( int x = 0; x < imgUp->width(); x++ )
112 if ( !qRed( imgMask.pixel( x, y ) ) ) 106 if ( !qRed( imgMask.pixel( x, y ) ) )
113 line[x] = i + 1; 107 line[x] = i + 1;
114 } 108 }
115 } 109 }
116 110
117 } 111 }
118 112
119 for ( int i = 0; i < 11; i++ ) { 113 for ( int i = 0; i < 11; i++ ) {
120 buttonPixUp[i] = NULL; 114 buttonPixUp[i] = NULL;
121 buttonPixDown[i] = NULL; 115 buttonPixDown[i] = NULL;
122 } 116 }
123 117
124 QWidget *d = QApplication::desktop(); 118 QWidget *d = QApplication::desktop();
125 int width = d->width(); 119 int width = d->width();
126 int height = d->height(); 120 int height = d->height();
127 121
128 if( (width != pixBg->width() ) || (height != pixBg->height() ) ) { 122 if( (width != pixBg->width() ) || (height != pixBg->height() ) ) {
129 // qDebug("<<<<<<<< scale image >>>>>>>>>>>>"); 123 // qDebug("<<<<<<<< scale image >>>>>>>>>>>>");
130 QImage img; 124 QImage img;
131 img = pixBg->convertToImage(); 125 img = pixBg->convertToImage();
132 pixBg->convertFromImage( img.smoothScale( width, height)); 126 pixBg->convertFromImage( img.smoothScale( width, height));
133 } 127 }
134 setBackgroundPixmap( *pixBg); 128 setBackgroundPixmap( *pixBg);
135 129
136 songInfo.setFocusPolicy( QWidget::NoFocus ); 130 songInfo.setFocusPolicy( QWidget::NoFocus );
137 131
138// changeTextColor( &songInfo ); 132// changeTextColor( &songInfo );
139// songInfo.setBackgroundColor( QColor( 167, 212, 167 )); 133// songInfo.setBackgroundColor( QColor( 167, 212, 167 ));
140// songInfo.setFrameStyle( QFrame::NoFrame); 134// songInfo.setFrameStyle( QFrame::NoFrame);
141// songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); 135// songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken );
142 //NoFrame 136 //NoFrame
143// songInfo.setForegroundColor(Qt::white); 137// songInfo.setForegroundColor(Qt::white);
144 138
145 slider.setFixedHeight( 20 ); 139 slider.setFixedHeight( 20 );
146 slider.setMinValue( 0 ); 140 slider.setMinValue( 0 );
147 slider.setMaxValue( 1 ); 141 slider.setMaxValue( 1 );
148 slider.setFocusPolicy( QWidget::NoFocus ); 142 slider.setFocusPolicy( QWidget::NoFocus );
149 143
150 slider.setBackgroundPixmap( *pixBg ); 144 slider.setBackgroundPixmap( *pixBg );
151 145
152 time.setFocusPolicy( QWidget::NoFocus ); 146 time.setFocusPolicy( QWidget::NoFocus );
153 time.setAlignment( Qt::AlignCenter ); 147 time.setAlignment( Qt::AlignCenter );
154 time.setFrame(FALSE); 148 time.setFrame(FALSE);
155 changeTextColor( &time ); 149 changeTextColor( &time );
156 150
157 resizeEvent( NULL ); 151 resizeEvent( NULL );
158 152
159 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 153 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
160 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 154 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
161 155
162 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 156 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
163 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 157 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
164 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); 158 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
165// connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); 159// connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
166 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 160 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
167 161
168 // Intialise state 162 // Intialise state
169 setLength( mediaPlayerState->length() ); 163 setLength( mediaPlayerState->length() );
170 setPosition( mediaPlayerState->position() ); 164 setPosition( mediaPlayerState->position() );
171 setLooping( mediaPlayerState->fullscreen() ); 165 setLooping( mediaPlayerState->fullscreen() );
172// setPaused( mediaPlayerState->paused() ); 166// setPaused( mediaPlayerState->paused() );
173 setPlaying( mediaPlayerState->playing() ); 167 setPlaying( mediaPlayerState->playing() );
174this->setFocus(); 168this->setFocus();
175} 169}
176 170
177 171
178AudioWidget::~AudioWidget() { 172AudioWidget::~AudioWidget() {
179 // setPlaying( false); 173 // setPlaying( false);
180 174
181 for ( int i = 0; i < 10; i++ ) { 175 for ( int i = 0; i < 10; i++ ) {
182 if(buttonPixUp[i]) delete buttonPixUp[i]; 176 if(buttonPixUp[i]) delete buttonPixUp[i];
183 if(buttonPixDown[i]) delete buttonPixDown[i]; 177 if(buttonPixDown[i]) delete buttonPixDown[i];
184 } 178 }
185 if(pixBg) delete pixBg; 179 if(pixBg) delete pixBg;
186 if(imgUp) delete imgUp; 180 if(imgUp) delete imgUp;
187 if(imgDn) delete imgDn; 181 if(imgDn) delete imgDn;
188 if(imgButtonMask) delete imgButtonMask; 182 if(imgButtonMask) delete imgButtonMask;
189 for ( int i = 0; i < 10; i++ ) { 183 for ( int i = 0; i < 10; i++ ) {
190 if(masks[i]) delete masks[i]; 184 if(masks[i]) delete masks[i];
191 } 185 }
192} 186}
193 187
194 188
195QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 189QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
196 QPixmap pix( img.width(), img.height() ); 190 QPixmap pix( img.width(), img.height() );
197 QPainter p( &pix ); 191 QPainter p( &pix );
198 p.drawTiledPixmap( pix.rect(), bg, offset ); 192 p.drawTiledPixmap( pix.rect(), bg, offset );
199 p.drawImage( 0, 0, img ); 193 p.drawImage( 0, 0, img );
200 return new QPixmap( pix ); 194 return new QPixmap( pix );
201} 195}
202 196
203 197
204QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) 198QPixmap *maskPixToMask( QPixmap pix, QBitmap mask )
205{ 199{
206 QPixmap *pixmap = new QPixmap( pix ); 200 QPixmap *pixmap = new QPixmap( pix );
207 pixmap->setMask( mask ); 201 pixmap->setMask( mask );
208 return pixmap; 202 return pixmap;
209} 203}
210 204
211 205
212 206
213void AudioWidget::resizeEvent( QResizeEvent * ) { 207void AudioWidget::resizeEvent( QResizeEvent * ) {
214 int h = height(); 208 int h = height();
215 int w = width(); 209 int w = width();
216 210
217 songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) ); 211 songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) );
218 slider.setFixedWidth( w - 110 ); 212 slider.setFixedWidth( w - 110 );
219 slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); 213 slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) );
220 slider.setBackgroundOrigin( QWidget::ParentOrigin ); 214 slider.setBackgroundOrigin( QWidget::ParentOrigin );
221 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); 215 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) );
222 216
223 xoff = ( w - imgUp->width() ) / 2; 217 xoff = ( w - imgUp->width() ) / 2;
224 yoff = (( h - imgUp->height() ) / 2) - 10; 218 yoff = (( h - imgUp->height() ) / 2) - 10;
225 QPoint p( xoff, yoff ); 219 QPoint p( xoff, yoff );
226 220
227 QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p ); 221 QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p );
228 QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p ); 222 QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p );
229 223
230 for ( int i = 0; i < 10; i++ ) { 224 for ( int i = 0; i < 10; i++ ) {
231 if ( !masks[i]->isNull() ) { 225 if ( !masks[i]->isNull() ) {
232 delete buttonPixUp[i]; 226 delete buttonPixUp[i];
233 delete buttonPixDown[i]; 227 delete buttonPixDown[i];
234 buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] ); 228 buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] );
235 buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] ); 229 buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] );
236 } 230 }
237 } 231 }
238 232
239 delete pixUp; 233 delete pixUp;
240 delete pixDn; 234 delete pixDn;
241} 235}
242 236
243 237
244static bool audioSliderBeingMoved = FALSE; 238static bool audioSliderBeingMoved = FALSE;
245 239
246void AudioWidget::sliderPressed() { 240void AudioWidget::sliderPressed() {
247 audioSliderBeingMoved = TRUE; 241 audioSliderBeingMoved = TRUE;
248} 242}
249 243
250 244
251void AudioWidget::sliderReleased() { 245void AudioWidget::sliderReleased() {
252 audioSliderBeingMoved = FALSE; 246 audioSliderBeingMoved = FALSE;
253 if ( slider.width() == 0 ) 247 if ( slider.width() == 0 )
254 return; 248 return;
255 long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); 249 long val = long((double)slider.value() * mediaPlayerState->length() / slider.width());
256 mediaPlayerState->setPosition( val ); 250 mediaPlayerState->setPosition( val );
257} 251}
258 252
259 253
260void AudioWidget::setPosition( long i ) { 254void AudioWidget::setPosition( long i ) {
261// qDebug("set position %d",i); 255// qDebug("set position %d",i);
262 long length = mediaPlayerState->length(); 256 long length = mediaPlayerState->length();
263 updateSlider( i, length ); 257 updateSlider( i, length );
264} 258}
265 259
266 260
267void AudioWidget::setLength( long max ) { 261void AudioWidget::setLength( long max ) {
268 updateSlider( mediaPlayerState->position(), max ); 262 updateSlider( mediaPlayerState->position(), max );
269} 263}
270 264
271 265
272void AudioWidget::setView( char view ) { 266void AudioWidget::setView( char view ) {
273 267
274 if (mediaPlayerState->isStreaming) { 268 if (mediaPlayerState->isStreaming) {
275 if( !slider.isHidden()) slider.hide(); 269 if( !slider.isHidden()) slider.hide();
276 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 270 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
277 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 271 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
278 } else { 272 } else {
279// this stops the slider from being moved, thus 273// this stops the slider from being moved, thus
280 // does not stop stream when it reaches the end 274 // does not stop stream when it reaches the end
281 slider.show(); 275 slider.show();
282 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 276 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
283 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 277 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
284 } 278 }
285 279
286 if ( view == 'a' ) { 280 if ( view == 'a' ) {
287 startTimer( 150 ); 281 startTimer( 150 );
288// show(); 282// show();
289 QPEApplication::showWidget( this ); 283 QPEApplication::showWidget( this );
290 } else { 284 } else {
291 killTimers(); 285 killTimers();
292 hide(); 286 hide();
293 } 287 }
294 288
295} 289}
296 290
297 291
298static QString timeAsString( long length ) { 292static QString timeAsString( long length ) {
299 length /= 44100; 293 length /= 44100;
300 int minutes = length / 60; 294 int minutes = length / 60;
301 int seconds = length % 60; 295 int seconds = length % 60;
302 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); 296 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 );
303} 297}
304 298
305void AudioWidget::updateSlider( long i, long max ) { 299void AudioWidget::updateSlider( long i, long max ) {
306this->setFocus(); 300this->setFocus();
307 time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); 301 time.setText( timeAsString( i ) + " / " + timeAsString( max ) );
308 302
309 if ( max == 0 ) 303 if ( max == 0 )
310 return; 304 return;
311 // Will flicker too much if we don't do this 305 // Will flicker too much if we don't do this
312 // Scale to something reasonable 306 // Scale to something reasonable
313 int width = slider.width(); 307 int width = slider.width();
314 int val = int((double)i * width / max); 308 int val = int((double)i * width / max);
315 if ( !audioSliderBeingMoved ) { 309 if ( !audioSliderBeingMoved ) {
316 if ( slider.value() != val ) 310 if ( slider.value() != val )
317 slider.setValue( val ); 311 slider.setValue( val );
318 if ( slider.maxValue() != width ) 312 if ( slider.maxValue() != width )
319 slider.setMaxValue( width ); 313 slider.setMaxValue( width );
320 } 314 }
321} 315}
322 316
323 317
324void AudioWidget::setToggleButton( int i, bool down ) { 318void AudioWidget::setToggleButton( int i, bool down ) {
325 if ( down != audioButtons[i].isDown ) 319 if ( down != audioButtons[i].isDown )
326 toggleButton( i ); 320 toggleButton( i );
327} 321}
328 322
329 323
330void AudioWidget::toggleButton( int i ) { 324void AudioWidget::toggleButton( int i ) {
331 audioButtons[i].isDown = !audioButtons[i].isDown; 325 audioButtons[i].isDown = !audioButtons[i].isDown;
332 QPainter p(this); 326 QPainter p(this);
333 paintButton ( &p, i ); 327 paintButton ( &p, i );
334} 328}
335 329
336 330
337void AudioWidget::paintButton( QPainter *p, int i ) { 331void AudioWidget::paintButton( QPainter *p, int i ) {
338 if ( audioButtons[i].isDown ) 332 if ( audioButtons[i].isDown )
339 p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); 333 p->drawPixmap( xoff, yoff, *buttonPixDown[i] );
340 else 334 else
341 p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); 335 p->drawPixmap( xoff, yoff, *buttonPixUp[i] );
342} 336}
343 337
344 338
345void AudioWidget::timerEvent( QTimerEvent * ) { 339void AudioWidget::timerEvent( QTimerEvent * ) {
346/* 340/*
347 int x = audioButtons[AudioPlay].xPos; 341 int x = audioButtons[AudioPlay].xPos;
348 int y = audioButtons[AudioPlay].yPos; 342 int y = audioButtons[AudioPlay].yPos;
349 QPainter p( this ); 343 QPainter p( this );
350 // Optimize to only draw the little bit of the changing images which is different 344 // Optimize to only draw the little bit of the changing images which is different
351 p.drawPixmap( x + 14, y + 8, *pixmaps[3], 32 * frame, 0, 32, 32 ); 345 p.drawPixmap( x + 14, y + 8, *pixmaps[3], 32 * frame, 0, 32, 32 );
352 p.drawPixmap( x + 37, y + 37, *pixmaps[2], 18 * AudioPlay, 0, 6, 3 ); 346 p.drawPixmap( x + 37, y + 37, *pixmaps[2], 18 * AudioPlay, 0, 6, 3 );
353*/ 347*/
354/* 348/*
355 static int frame = 0; 349 static int frame = 0;
356 if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) { 350 if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) {
357 frame = frame >= 7 ? 0 : frame + 1; 351 frame = frame >= 7 ? 0 : frame + 1;
358 } 352 }
359 */ 353 */
360} 354}
361 355
362 356
363void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { 357void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
364 for ( int i = 0; i < numButtons; i++ ) { 358 for ( int i = 0; i < numButtons; i++ ) {
365 if ( event->state() == QMouseEvent::LeftButton ) { 359 if ( event->state() == QMouseEvent::LeftButton ) {
366 360
367 // The test to see if the mouse click is inside the button or not 361 // The test to see if the mouse click is inside the button or not
368 int x = event->pos().x() - xoff; 362 int x = event->pos().x() - xoff;
369 int y = event->pos().y() - yoff; 363 int y = event->pos().y() - yoff;
370 364
371 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() 365 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width()
372 && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 ); 366 && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 );
373 367
374// if ( isOnButton && i == AudioVolumeUp ) 368// if ( isOnButton && i == AudioVolumeUp )
375// qDebug("on up"); 369// qDebug("on up");
376 370
377 if ( isOnButton && !audioButtons[i].isHeld ) { 371 if ( isOnButton && !audioButtons[i].isHeld ) {
378 audioButtons[i].isHeld = TRUE; 372 audioButtons[i].isHeld = TRUE;
379 toggleButton(i); 373 toggleButton(i);
380 switch (i) { 374 switch (i) {
381 case AudioVolumeUp: 375 case AudioVolumeUp:
382 // qDebug("more clicked"); 376 // qDebug("more clicked");
383 emit moreClicked(); 377 emit moreClicked();
384 return; 378 return;
385 case AudioVolumeDown: 379 case AudioVolumeDown:
386 // qDebug("less clicked"); 380 // qDebug("less clicked");
387 emit lessClicked(); 381 emit lessClicked();
388 return; 382 return;
389 case AudioForward: 383 case AudioForward:
390 emit forwardClicked(); 384 emit forwardClicked();
391 return; 385 return;
392 case AudioBack: 386 case AudioBack:
393 emit backClicked(); 387 emit backClicked();
394 return; 388 return;
395 } 389 }
396 } else if ( !isOnButton && audioButtons[i].isHeld ) { 390 } else if ( !isOnButton && audioButtons[i].isHeld ) {
397 audioButtons[i].isHeld = FALSE; 391 audioButtons[i].isHeld = FALSE;
398 toggleButton(i); 392 toggleButton(i);
399 } 393 }
400 } else { 394 } else {
401 if ( audioButtons[i].isHeld ) { 395 if ( audioButtons[i].isHeld ) {
402 audioButtons[i].isHeld = FALSE; 396 audioButtons[i].isHeld = FALSE;
403 if ( !audioButtons[i].isToggle ) 397 if ( !audioButtons[i].isToggle )
404 setToggleButton( i, FALSE ); 398 setToggleButton( i, FALSE );
405 switch (i) { 399 switch (i) {
406 case AudioPlay: 400 case AudioPlay:
407 if( mediaPlayerState->isPaused ) { 401 if( mediaPlayerState->isPaused ) {
408 mediaPlayerState->setPaused( FALSE ); 402 mediaPlayerState->setPaused( FALSE );
409 return; 403 return;
410 } else if( !mediaPlayerState->isPaused ) { 404 } else if( !mediaPlayerState->isPaused ) {
411 mediaPlayerState->setPaused( TRUE ); 405 mediaPlayerState->setPaused( TRUE );
412 return; 406 return;
413 } 407 }
414// case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; 408// case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return;
415 case AudioStop: mediaPlayerState->setPlaying(FALSE); return; 409 case AudioStop: mediaPlayerState->setPlaying(FALSE); return;
416// case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return; 410// case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return;
417 case AudioNext: mediaPlayerState->setNext(); return; 411 case AudioNext: mediaPlayerState->setNext(); return;
418 case AudioPrevious: mediaPlayerState->setPrev(); return; 412 case AudioPrevious: mediaPlayerState->setPrev(); return;
419 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; 413 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return;
420 case AudioVolumeUp: emit moreReleased(); return; 414 case AudioVolumeUp: emit moreReleased(); return;
421 case AudioVolumeDown: emit lessReleased(); return; 415 case AudioVolumeDown: emit lessReleased(); return;
422 case AudioPlayList: mediaPlayerState->setList(); return; 416 case AudioPlayList: mediaPlayerState->setList(); return;
423 } 417 }
424 } 418 }
425 } 419 }
426 } 420 }
427} 421}
428 422
429 423
430 424
431void AudioWidget::mousePressEvent( QMouseEvent *event ) { 425void AudioWidget::mousePressEvent( QMouseEvent *event ) {
432 mouseMoveEvent( event ); 426 mouseMoveEvent( event );
433} 427}
434 428
435 429
436void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { 430void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) {
437 mouseMoveEvent( event ); 431 mouseMoveEvent( event );
438} 432}
439 433
440 434
441void AudioWidget::showEvent( QShowEvent* ) { 435void AudioWidget::showEvent( QShowEvent* ) {
442 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 436 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
443 mouseMoveEvent( &event ); 437 mouseMoveEvent( &event );
444} 438}
445 439
446 440
447void AudioWidget::closeEvent( QCloseEvent* ) { 441void AudioWidget::closeEvent( QCloseEvent* ) {
448 mediaPlayerState->setList(); 442 mediaPlayerState->setList();
449} 443}
450 444
451 445
452void AudioWidget::paintEvent( QPaintEvent * pe) { 446void AudioWidget::paintEvent( QPaintEvent * pe) {
453 if ( !pe->erased() ) { 447 if ( !pe->erased() ) {
454 // Combine with background and double buffer 448 // Combine with background and double buffer
455 QPixmap pix( pe->rect().size() ); 449 QPixmap pix( pe->rect().size() );
456 QPainter p( &pix ); 450 QPainter p( &pix );
457 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 451 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
458 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); 452 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() );
459 for ( int i = 0; i < numButtons; i++ ) 453 for ( int i = 0; i < numButtons; i++ )
460 paintButton( &p, i ); 454 paintButton( &p, i );
461 QPainter p2( this ); 455 QPainter p2( this );
462 p2.drawPixmap( pe->rect().topLeft(), pix ); 456 p2.drawPixmap( pe->rect().topLeft(), pix );
463 } else { 457 } else {
464 QPainter p( this ); 458 QPainter p( this );
465 for ( int i = 0; i < numButtons; i++ ) 459 for ( int i = 0; i < numButtons; i++ )
466 paintButton( &p, i ); 460 paintButton( &p, i );
467 } 461 }
468} 462}
469 463
470void AudioWidget::keyReleaseEvent( QKeyEvent *e) 464void AudioWidget::keyReleaseEvent( QKeyEvent *e)
471{ 465{
472 switch ( e->key() ) { 466 switch ( e->key() ) {
473////////////////////////////// Zaurus keys 467////////////////////////////// Zaurus keys
474 case Key_Home: 468 case Key_Home:
475 break; 469 break;
476 case Key_F9: //activity 470 case Key_F9: //activity
477 hide(); 471 hide();
478// qDebug("Audio F9"); 472// qDebug("Audio F9");
479 break; 473 break;
480 case Key_F10: //contacts 474 case Key_F10: //contacts
481 break; 475 break;
482 case Key_F11: //menu 476 case Key_F11: //menu
483 break; 477 break;
484 case Key_F12: //home 478 case Key_F12: //home
485 break; 479 break;
486 case Key_F13: //mail 480 case Key_F13: //mail
487 break; 481 break;
488 case Key_Space: { 482 case Key_Space: {
489 483
490 if(mediaPlayerState->playing()) { 484 if(mediaPlayerState->playing()) {
491// toggleButton(1); 485// toggleButton(1);
492 mediaPlayerState->setPlaying(FALSE); 486 mediaPlayerState->setPlaying(FALSE);
493// toggleButton(1); 487// toggleButton(1);
494 } else { 488 } else {
495// toggleButton(0); 489// toggleButton(0);
496 mediaPlayerState->setPlaying(TRUE); 490 mediaPlayerState->setPlaying(TRUE);
497// toggleButton(0); 491// toggleButton(0);
498 } 492 }
499 } 493 }
500 break; 494 break;
501 case Key_Down: //volume 495 case Key_Down: //volume
502// toggleButton(6); 496// toggleButton(6);
503 emit lessClicked(); 497 emit lessClicked();
504 emit lessReleased(); 498 emit lessReleased();
505// toggleButton(6); 499// toggleButton(6);
506 break; 500 break;
507 case Key_Up: //volume 501 case Key_Up: //volume
508// toggleButton(5); 502// toggleButton(5);
509 emit moreClicked(); 503 emit moreClicked();
510 emit moreReleased(); 504 emit moreReleased();
511// toggleButton(5); 505// toggleButton(5);
512 break; 506 break;
513 case Key_Right: //next in playlist 507 case Key_Right: //next in playlist
514// toggleButton(3); 508// toggleButton(3);
515 mediaPlayerState->setNext(); 509 mediaPlayerState->setNext();
516// toggleButton(3); 510// toggleButton(3);
517 break; 511 break;
518 case Key_Left: // previous in playlist 512 case Key_Left: // previous in playlist
519// toggleButton(4); 513// toggleButton(4);
520 mediaPlayerState->setPrev(); 514 mediaPlayerState->setPrev();
521// toggleButton(4); 515// toggleButton(4);
522 break; 516 break;
523 case Key_Escape: 517 case Key_Escape:
524 break; 518 break;
525 519
526 }; 520 };
527} 521}
diff --git a/core/multimedia/opieplayer/mediaplayer.cpp b/core/multimedia/opieplayer/mediaplayer.cpp
index 753b2e3..b77708c 100644
--- a/core/multimedia/opieplayer/mediaplayer.cpp
+++ b/core/multimedia/opieplayer/mediaplayer.cpp
@@ -1,278 +1,271 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the 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 20
21#include <qpe/qpeapplication.h>
22#include <qpe/qlibrary.h>
23#include <qpe/resource.h>
24#include <qpe/config.h>
25 21
26#include <qmainwindow.h>
27#include <qmessagebox.h> 22#include <qmessagebox.h>
28#include <qwidgetstack.h>
29#include <qfile.h>
30 23
31#include "mediaplayer.h" 24#include "mediaplayer.h"
32#include "playlistwidget.h" 25#include "playlistwidget.h"
33#include "audiowidget.h" 26#include "audiowidget.h"
34#include "loopcontrol.h" 27#include "loopcontrol.h"
35#include "audiodevice.h" 28#include "audiodevice.h"
36 29
37#include "mediaplayerstate.h" 30#include "mediaplayerstate.h"
38 31
39 32
40extern AudioWidget *audioUI; 33extern AudioWidget *audioUI;
41extern PlayListWidget *playList; 34extern PlayListWidget *playList;
42extern LoopControl *loopControl; 35extern LoopControl *loopControl;
43extern MediaPlayerState *mediaPlayerState; 36extern MediaPlayerState *mediaPlayerState;
44 37
45 38
46MediaPlayer::MediaPlayer( QObject *parent, const char *name ) 39MediaPlayer::MediaPlayer( QObject *parent, const char *name )
47 : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { 40 : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) {
48 41
49// QPEApplication::grabKeyboard(); 42// QPEApplication::grabKeyboard();
50 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 43 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
51 44
52 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); 45 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) );
53 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); 46 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) );
54 connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); 47 connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) );
55 connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); 48 connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) );
56 49
57 connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); 50 connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
58 connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); 51 connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
59 connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); 52 connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
60 connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); 53 connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
61} 54}
62 55
63 56
64MediaPlayer::~MediaPlayer() { 57MediaPlayer::~MediaPlayer() {
65 58
66} 59}
67 60
68 61
69void MediaPlayer::pauseCheck( bool b ) { 62void MediaPlayer::pauseCheck( bool b ) {
70 // Only pause if playing 63 // Only pause if playing
71 if ( b && !mediaPlayerState->playing() ) 64 if ( b && !mediaPlayerState->playing() )
72 mediaPlayerState->setPaused( FALSE ); 65 mediaPlayerState->setPaused( FALSE );
73} 66}
74 67
75 68
76void MediaPlayer::play() { 69void MediaPlayer::play() {
77 mediaPlayerState->setPlaying( FALSE ); 70 mediaPlayerState->setPlaying( FALSE );
78 mediaPlayerState->setPlaying( TRUE ); 71 mediaPlayerState->setPlaying( TRUE );
79} 72}
80 73
81 74
82void MediaPlayer::setPlaying( bool play ) { 75void MediaPlayer::setPlaying( bool play ) {
83 // qDebug("MediaPlayer setPlaying %d", play); 76 // qDebug("MediaPlayer setPlaying %d", play);
84 if ( !play ) { 77 if ( !play ) {
85 mediaPlayerState->setPaused( FALSE ); 78 mediaPlayerState->setPaused( FALSE );
86 loopControl->stop( FALSE ); 79 loopControl->stop( FALSE );
87 return; 80 return;
88 } 81 }
89 82
90 if ( mediaPlayerState->paused() ) { 83 if ( mediaPlayerState->paused() ) {
91 mediaPlayerState->setPaused( FALSE ); 84 mediaPlayerState->setPaused( FALSE );
92 return; 85 return;
93 } 86 }
94 // qDebug("about to ctrash"); 87 // qDebug("about to ctrash");
95 const DocLnk *playListCurrent = playList->current(); 88 const DocLnk *playListCurrent = playList->current();
96 89
97 if ( playListCurrent != NULL ) { 90 if ( playListCurrent != NULL ) {
98 loopControl->stop( TRUE ); 91 loopControl->stop( TRUE );
99 currentFile = playListCurrent; 92 currentFile = playListCurrent;
100 } 93 }
101 if ( currentFile == NULL ) { 94 if ( currentFile == NULL ) {
102 QMessageBox::critical( 0, tr( "No file"), tr( "Error: There is no file selected" ) ); 95 QMessageBox::critical( 0, tr( "No file"), tr( "Error: There is no file selected" ) );
103 mediaPlayerState->setPlaying( FALSE ); 96 mediaPlayerState->setPlaying( FALSE );
104 return; 97 return;
105 } 98 }
106 99
107 if ( ((currentFile->file()).left(4) != "http") && !QFile::exists( currentFile->file() ) ) { 100 if ( ((currentFile->file()).left(4) != "http") && !QFile::exists( currentFile->file() ) ) {
108 QMessageBox::critical( 0, tr( "File not found"), 101 QMessageBox::critical( 0, tr( "File not found"),
109 tr( "The following file was not found: <i>" ) 102 tr( "The following file was not found: <i>" )
110 + currentFile->file() + "</i>" ); 103 + currentFile->file() + "</i>" );
111 mediaPlayerState->setPlaying( FALSE ); 104 mediaPlayerState->setPlaying( FALSE );
112 return; 105 return;
113 } 106 }
114 107
115 if ( !mediaPlayerState->newDecoder( currentFile->file() ) ) { 108 if ( !mediaPlayerState->newDecoder( currentFile->file() ) ) {
116 QMessageBox::critical( 0, tr( "No decoder found"), 109 QMessageBox::critical( 0, tr( "No decoder found"),
117 tr( "Sorry, no appropriate decoders found for this file: <i>" ) 110 tr( "Sorry, no appropriate decoders found for this file: <i>" )
118 + currentFile->file() + "</i>" ); 111 + currentFile->file() + "</i>" );
119 mediaPlayerState->setPlaying( FALSE ); 112 mediaPlayerState->setPlaying( FALSE );
120 return; 113 return;
121 } 114 }
122 115
123 if ( !loopControl->init( currentFile->file() ) ) { 116 if ( !loopControl->init( currentFile->file() ) ) {
124 QMessageBox::critical( 0, tr( "Error opening file"), 117 QMessageBox::critical( 0, tr( "Error opening file"),
125 tr( "Sorry, an error occured trying to play the file: <i>" ) + currentFile->file() + "</i>" ); 118 tr( "Sorry, an error occured trying to play the file: <i>" ) + currentFile->file() + "</i>" );
126 mediaPlayerState->setPlaying( FALSE ); 119 mediaPlayerState->setPlaying( FALSE );
127 return; 120 return;
128 } 121 }
129 long seconds = loopControl->totalPlaytime(); 122 long seconds = loopControl->totalPlaytime();
130 QString time; time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); 123 QString time; time.sprintf("%li:%02i", seconds/60, (int)seconds%60 );
131 QString tickerText; 124 QString tickerText;
132 if( currentFile->file().left(4) == "http" ) 125 if( currentFile->file().left(4) == "http" )
133 tickerText= tr( " File: " ) + currentFile->name(); 126 tickerText= tr( " File: " ) + currentFile->name();
134 else 127 else
135 tickerText = tr( " File: " ) + currentFile->name() + tr(", Length: ") + time; 128 tickerText = tr( " File: " ) + currentFile->name() + tr(", Length: ") + time;
136 129
137 QString fileInfo = mediaPlayerState->curDecoder()->fileInfo(); 130 QString fileInfo = mediaPlayerState->curDecoder()->fileInfo();
138 if ( !fileInfo.isEmpty() ) 131 if ( !fileInfo.isEmpty() )
139 tickerText += ", " + fileInfo; 132 tickerText += ", " + fileInfo;
140 audioUI->setTickerText( tickerText + "." ); 133 audioUI->setTickerText( tickerText + "." );
141 134
142 loopControl->play(); 135 loopControl->play();
143 136
144 mediaPlayerState->setView( loopControl->hasVideo() ? 'v' : 'a' ); 137 mediaPlayerState->setView( loopControl->hasVideo() ? 'v' : 'a' );
145} 138}
146 139
147 140
148void MediaPlayer::prev() { 141void MediaPlayer::prev() {
149 if ( playList->prev() ) 142 if ( playList->prev() )
150 play(); 143 play();
151 else if ( mediaPlayerState->looping() ) { 144 else if ( mediaPlayerState->looping() ) {
152 if ( playList->last() ) 145 if ( playList->last() )
153 play(); 146 play();
154 } else 147 } else
155 mediaPlayerState->setList(); 148 mediaPlayerState->setList();
156} 149}
157 150
158 151
159void MediaPlayer::next() { 152void MediaPlayer::next() {
160 if ( playList->next() ) 153 if ( playList->next() )
161 play(); 154 play();
162 else if ( mediaPlayerState->looping() ) { 155 else if ( mediaPlayerState->looping() ) {
163 if ( playList->first() ) 156 if ( playList->first() )
164 play(); 157 play();
165 } else 158 } else
166 mediaPlayerState->setList(); 159 mediaPlayerState->setList();
167} 160}
168 161
169 162
170void MediaPlayer::startDecreasingVolume() { 163void MediaPlayer::startDecreasingVolume() {
171 volumeDirection = -1; 164 volumeDirection = -1;
172 startTimer( 100 ); 165 startTimer( 100 );
173 AudioDevice::decreaseVolume(); 166 AudioDevice::decreaseVolume();
174} 167}
175 168
176 169
177void MediaPlayer::startIncreasingVolume() { 170void MediaPlayer::startIncreasingVolume() {
178 volumeDirection = +1; 171 volumeDirection = +1;
179 startTimer( 100 ); 172 startTimer( 100 );
180 AudioDevice::increaseVolume(); 173 AudioDevice::increaseVolume();
181 174
182} 175}
183 176
184bool drawnOnScreenDisplay = FALSE; 177bool drawnOnScreenDisplay = FALSE;
185unsigned int onScreenDisplayVolume = 0; 178unsigned int onScreenDisplayVolume = 0;
186const int yoff = 110; 179const int yoff = 110;
187 180
188void MediaPlayer::stopChangingVolume() { 181void MediaPlayer::stopChangingVolume() {
189 killTimers(); 182 killTimers();
190 183
191 // Get rid of the on-screen display stuff 184 // Get rid of the on-screen display stuff
192 drawnOnScreenDisplay = FALSE; 185 drawnOnScreenDisplay = FALSE;
193 onScreenDisplayVolume = 0; 186 onScreenDisplayVolume = 0;
194 int w = audioUI->width(); 187 int w = audioUI->width();
195 int h = audioUI->height(); 188 int h = audioUI->height();
196 audioUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE ); 189 audioUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE );
197} 190}
198 191
199 192
200void MediaPlayer::timerEvent( QTimerEvent * ) { 193void MediaPlayer::timerEvent( QTimerEvent * ) {
201// qDebug("timer"); 194// qDebug("timer");
202 if ( volumeDirection == +1 ) 195 if ( volumeDirection == +1 )
203 AudioDevice::increaseVolume(); 196 AudioDevice::increaseVolume();
204 else if ( volumeDirection == -1 ) 197 else if ( volumeDirection == -1 )
205 AudioDevice::decreaseVolume(); 198 AudioDevice::decreaseVolume();
206 199
207 // Display an on-screen display volume 200 // Display an on-screen display volume
208 unsigned int l, r, v; bool m; 201 unsigned int l, r, v; bool m;
209 AudioDevice::getVolume( l, r, m ); 202 AudioDevice::getVolume( l, r, m );
210 v = ((l + r) * 11) / (2*0xFFFF); 203 v = ((l + r) * 11) / (2*0xFFFF);
211 204
212 if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { 205 if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) {
213// qDebug("returning %d, %d, %d, %d", v, l, r, m); 206// qDebug("returning %d, %d, %d, %d", v, l, r, m);
214 return; 207 return;
215 } 208 }
216 209
217 int w = audioUI->width(); 210 int w = audioUI->width();
218 int h = audioUI->height(); 211 int h = audioUI->height();
219 212
220 if ( drawnOnScreenDisplay ) { 213 if ( drawnOnScreenDisplay ) {
221 if ( onScreenDisplayVolume > v ) 214 if ( onScreenDisplayVolume > v )
222 audioUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, 215 audioUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40,
223 (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE ); 216 (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE );
224 } 217 }
225 218
226 drawnOnScreenDisplay = TRUE; 219 drawnOnScreenDisplay = TRUE;
227 onScreenDisplayVolume = v; 220 onScreenDisplayVolume = v;
228 221
229 QPainter p( audioUI ); 222 QPainter p( audioUI );
230 p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); 223 p.setPen( QColor( 0x10, 0xD0, 0x10 ) );
231 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); 224 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) );
232 225
233 QFont f; 226 QFont f;
234 f.setPixelSize( 20 ); 227 f.setPixelSize( 20 );
235 f.setBold( TRUE ); 228 f.setBold( TRUE );
236 p.setFont( f ); 229 p.setFont( f );
237 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); 230 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") );
238 231
239 for ( unsigned int i = 0; i < 10; i++ ) { 232 for ( unsigned int i = 0; i < 10; i++ ) {
240 if ( v > i ) 233 if ( v > i )
241 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); 234 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 );
242 else 235 else
243 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); 236 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 );
244 } 237 }
245} 238}
246 239
247void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { 240void MediaPlayer::keyReleaseEvent( QKeyEvent *e) {
248 switch ( e->key() ) { 241 switch ( e->key() ) {
249////////////////////////////// Zaurus keys 242////////////////////////////// Zaurus keys
250 case Key_Home: 243 case Key_Home:
251 break; 244 break;
252 case Key_F9: //activity 245 case Key_F9: //activity
253 break; 246 break;
254 case Key_F10: //contacts 247 case Key_F10: //contacts
255 break; 248 break;
256 case Key_F11: //menu 249 case Key_F11: //menu
257 break; 250 break;
258 case Key_F12: //home 251 case Key_F12: //home
259 // qDebug("Blank here"); 252 // qDebug("Blank here");
260 break; 253 break;
261 case Key_F13: //mail 254 case Key_F13: //mail
262 break; 255 break;
263 } 256 }
264} 257}
265 258
266void MediaPlayer::doBlank() { 259void MediaPlayer::doBlank() {
267 260
268} 261}
269 262
270void MediaPlayer::doUnblank() { 263void MediaPlayer::doUnblank() {
271 264
272} 265}
273 266
274void MediaPlayer::cleanUp() { 267void MediaPlayer::cleanUp() {
275// QPEApplication::grabKeyboard(); 268// QPEApplication::grabKeyboard();
276// QPEApplication::ungrabKeyboard(); 269// QPEApplication::ungrabKeyboard();
277 270
278} 271}
diff --git a/core/multimedia/opieplayer/mediaplayerstate.cpp b/core/multimedia/opieplayer/mediaplayerstate.cpp
index 6823076..5bfb87e 100644
--- a/core/multimedia/opieplayer/mediaplayerstate.cpp
+++ b/core/multimedia/opieplayer/mediaplayerstate.cpp
@@ -1,195 +1,193 @@
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/qpeapplication.h> 20#include <qpe/qpeapplication.h>
21#include <qpe/qlibrary.h> 21#include <qpe/qlibrary.h>
22#include <qpe/config.h> 22#include <qpe/config.h>
23#include <qvaluelist.h>
24#include <qobject.h>
25#include <qdir.h> 23#include <qdir.h>
26#include <qpe/mediaplayerplugininterface.h> 24#include <qpe/mediaplayerplugininterface.h>
27#include "mediaplayerstate.h" 25#include "mediaplayerstate.h"
28 26
29 27
30 28
31#ifdef QT_NO_COMPONENT 29#ifdef QT_NO_COMPONENT
32// Plugins which are compiled in when no plugin architecture available 30// Plugins which are compiled in when no plugin architecture available
33#include "libmad/libmadpluginimpl.h" 31#include "libmad/libmadpluginimpl.h"
34#include "libmpeg3/libmpeg3pluginimpl.h" 32#include "libmpeg3/libmpeg3pluginimpl.h"
35#include "wavplugin/wavpluginimpl.h" 33#include "wavplugin/wavpluginimpl.h"
36#endif 34#endif
37 35
38 36
39//#define MediaPlayerDebug(x) qDebug x 37//#define MediaPlayerDebug(x) qDebug x
40#define MediaPlayerDebug(x) 38#define MediaPlayerDebug(x)
41 39
42 40
43MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) 41MediaPlayerState::MediaPlayerState( QObject *parent, const char *name )
44 : QObject( parent, name ), decoder( NULL ), libmpeg3decoder( NULL ) { 42 : QObject( parent, name ), decoder( NULL ), libmpeg3decoder( NULL ) {
45 Config cfg( "OpiePlayer" ); 43 Config cfg( "OpiePlayer" );
46 readConfig( cfg ); 44 readConfig( cfg );
47 loadPlugins(); 45 loadPlugins();
48} 46}
49 47
50 48
51MediaPlayerState::~MediaPlayerState() { 49MediaPlayerState::~MediaPlayerState() {
52 Config cfg( "OpiePlayer" ); 50 Config cfg( "OpiePlayer" );
53 writeConfig( cfg ); 51 writeConfig( cfg );
54} 52}
55 53
56 54
57void MediaPlayerState::readConfig( Config& cfg ) { 55void MediaPlayerState::readConfig( Config& cfg ) {
58 cfg.setGroup("Options"); 56 cfg.setGroup("Options");
59 isFullscreen = cfg.readBoolEntry( "FullScreen" ); 57 isFullscreen = cfg.readBoolEntry( "FullScreen" );
60 isScaled = cfg.readBoolEntry( "Scaling" ); 58 isScaled = cfg.readBoolEntry( "Scaling" );
61 isLooping = cfg.readBoolEntry( "Looping" ); 59 isLooping = cfg.readBoolEntry( "Looping" );
62 isShuffled = cfg.readBoolEntry( "Shuffle" ); 60 isShuffled = cfg.readBoolEntry( "Shuffle" );
63 usePlaylist = cfg.readBoolEntry( "UsePlayList" ); 61 usePlaylist = cfg.readBoolEntry( "UsePlayList" );
64 usePlaylist = TRUE; 62 usePlaylist = TRUE;
65 isPlaying = FALSE; 63 isPlaying = FALSE;
66 isPaused = FALSE; 64 isPaused = FALSE;
67 curPosition = 0; 65 curPosition = 0;
68 curLength = 0; 66 curLength = 0;
69 curView = 'l'; 67 curView = 'l';
70} 68}
71 69
72 70
73void MediaPlayerState::writeConfig( Config& cfg ) const { 71void MediaPlayerState::writeConfig( Config& cfg ) const {
74 cfg.setGroup("Options"); 72 cfg.setGroup("Options");
75 cfg.writeEntry("FullScreen", isFullscreen ); 73 cfg.writeEntry("FullScreen", isFullscreen );
76 cfg.writeEntry("Scaling", isScaled ); 74 cfg.writeEntry("Scaling", isScaled );
77 cfg.writeEntry("Looping", isLooping ); 75 cfg.writeEntry("Looping", isLooping );
78 cfg.writeEntry("Shuffle", isShuffled ); 76 cfg.writeEntry("Shuffle", isShuffled );
79 cfg.writeEntry("UsePlayList", usePlaylist ); 77 cfg.writeEntry("UsePlayList", usePlaylist );
80} 78}
81 79
82 80
83struct MediaPlayerPlugin { 81struct MediaPlayerPlugin {
84#ifndef QT_NO_COMPONENT 82#ifndef QT_NO_COMPONENT
85 QLibrary *library; 83 QLibrary *library;
86#endif 84#endif
87 MediaPlayerPluginInterface *iface; 85 MediaPlayerPluginInterface *iface;
88 MediaPlayerDecoder *decoder; 86 MediaPlayerDecoder *decoder;
89 MediaPlayerEncoder *encoder; 87 MediaPlayerEncoder *encoder;
90}; 88};
91 89
92 90
93static QValueList<MediaPlayerPlugin> pluginList; 91static QValueList<MediaPlayerPlugin> pluginList;
94 92
95 93
96// Find the first decoder which supports this type of file 94// Find the first decoder which supports this type of file
97MediaPlayerDecoder *MediaPlayerState::newDecoder( const QString& file ) { 95MediaPlayerDecoder *MediaPlayerState::newDecoder( const QString& file ) {
98 MediaPlayerDecoder *tmpDecoder = NULL; 96 MediaPlayerDecoder *tmpDecoder = NULL;
99 QValueList<MediaPlayerPlugin>::Iterator it; 97 QValueList<MediaPlayerPlugin>::Iterator it;
100 for ( it = pluginList.begin(); it != pluginList.end(); ++it ) { 98 for ( it = pluginList.begin(); it != pluginList.end(); ++it ) {
101 if ( (*it).decoder->isFileSupported( file ) ) { 99 if ( (*it).decoder->isFileSupported( file ) ) {
102 tmpDecoder = (*it).decoder; 100 tmpDecoder = (*it).decoder;
103 break; 101 break;
104 } 102 }
105 } 103 }
106 if(file.left(4)=="http") 104 if(file.left(4)=="http")
107 isStreaming = TRUE; 105 isStreaming = TRUE;
108 else 106 else
109 isStreaming = FALSE; 107 isStreaming = FALSE;
110 return decoder = tmpDecoder; 108 return decoder = tmpDecoder;
111} 109}
112 110
113 111
114MediaPlayerDecoder *MediaPlayerState::curDecoder() { 112MediaPlayerDecoder *MediaPlayerState::curDecoder() {
115 return decoder; 113 return decoder;
116} 114}
117 115
118 116
119// ### hack to get true sample count 117// ### hack to get true sample count
120MediaPlayerDecoder *MediaPlayerState::libMpeg3Decoder() { 118MediaPlayerDecoder *MediaPlayerState::libMpeg3Decoder() {
121 return libmpeg3decoder; 119 return libmpeg3decoder;
122} 120}
123 121
124// ### hack to get true sample count 122// ### hack to get true sample count
125// MediaPlayerDecoder *MediaPlayerState::libWavDecoder() { 123// MediaPlayerDecoder *MediaPlayerState::libWavDecoder() {
126// return libwavdecoder; 124// return libwavdecoder;
127// } 125// }
128 126
129void MediaPlayerState::loadPlugins() { 127void MediaPlayerState::loadPlugins() {
130 // qDebug("load plugins"); 128 // qDebug("load plugins");
131#ifndef QT_NO_COMPONENT 129#ifndef QT_NO_COMPONENT
132 QValueList<MediaPlayerPlugin>::Iterator mit; 130 QValueList<MediaPlayerPlugin>::Iterator mit;
133 for ( mit = pluginList.begin(); mit != pluginList.end(); ++mit ) { 131 for ( mit = pluginList.begin(); mit != pluginList.end(); ++mit ) {
134 (*mit).iface->release(); 132 (*mit).iface->release();
135 (*mit).library->unload(); 133 (*mit).library->unload();
136 delete (*mit).library; 134 delete (*mit).library;
137 } 135 }
138 pluginList.clear(); 136 pluginList.clear();
139 137
140 QString path = QPEApplication::qpeDir() + "/plugins/codecs"; 138 QString path = QPEApplication::qpeDir() + "/plugins/codecs";
141 QDir dir( path, "lib*.so" ); 139 QDir dir( path, "lib*.so" );
142 QStringList list = dir.entryList(); 140 QStringList list = dir.entryList();
143 QStringList::Iterator it; 141 QStringList::Iterator it;
144 for ( it = list.begin(); it != list.end(); ++it ) { 142 for ( it = list.begin(); it != list.end(); ++it ) {
145 MediaPlayerPluginInterface *iface = 0; 143 MediaPlayerPluginInterface *iface = 0;
146 QLibrary *lib = new QLibrary( path + "/" + *it ); 144 QLibrary *lib = new QLibrary( path + "/" + *it );
147// qDebug( "querying: %s", QString( path + "/" + *it ).latin1() ); 145// qDebug( "querying: %s", QString( path + "/" + *it ).latin1() );
148 146
149 if ( lib->queryInterface( IID_MediaPlayerPlugin, (QUnknownInterface**)&iface ) == QS_OK ) { 147 if ( lib->queryInterface( IID_MediaPlayerPlugin, (QUnknownInterface**)&iface ) == QS_OK ) {
150 148
151// qDebug( "loading: %s", QString( path + "/" + *it ).latin1() ); 149// qDebug( "loading: %s", QString( path + "/" + *it ).latin1() );
152 150
153 MediaPlayerPlugin plugin; 151 MediaPlayerPlugin plugin;
154 plugin.library = lib; 152 plugin.library = lib;
155 plugin.iface = iface; 153 plugin.iface = iface;
156 plugin.decoder = plugin.iface->decoder(); 154 plugin.decoder = plugin.iface->decoder();
157 plugin.encoder = plugin.iface->encoder(); 155 plugin.encoder = plugin.iface->encoder();
158 pluginList.append( plugin ); 156 pluginList.append( plugin );
159 157
160 // ### hack to get true sample count 158 // ### hack to get true sample count
161 if ( plugin.decoder->pluginName() == QString("LibMpeg3Plugin") ) 159 if ( plugin.decoder->pluginName() == QString("LibMpeg3Plugin") )
162 libmpeg3decoder = plugin.decoder; 160 libmpeg3decoder = plugin.decoder;
163 161
164 } else { 162 } else {
165 delete lib; 163 delete lib;
166 } 164 }
167 } 165 }
168#else 166#else
169 pluginList.clear(); 167 pluginList.clear();
170 168
171 MediaPlayerPlugin plugin0; 169 MediaPlayerPlugin plugin0;
172 plugin0.iface = new LibMpeg3PluginImpl; 170 plugin0.iface = new LibMpeg3PluginImpl;
173 plugin0.decoder = plugin0.iface->decoder(); 171 plugin0.decoder = plugin0.iface->decoder();
174 plugin0.encoder = plugin0.iface->encoder(); 172 plugin0.encoder = plugin0.iface->encoder();
175 pluginList.append( plugin0 ); 173 pluginList.append( plugin0 );
176 174
177 MediaPlayerPlugin plugin1; 175 MediaPlayerPlugin plugin1;
178 plugin1.iface = new LibMadPluginImpl; 176 plugin1.iface = new LibMadPluginImpl;
179 plugin1.decoder = plugin1.iface->decoder(); 177 plugin1.decoder = plugin1.iface->decoder();
180 plugin1.encoder = plugin1.iface->encoder(); 178 plugin1.encoder = plugin1.iface->encoder();
181 pluginList.append( plugin1 ); 179 pluginList.append( plugin1 );
182 180
183 MediaPlayerPlugin plugin2; 181 MediaPlayerPlugin plugin2;
184 plugin2.iface = new WavPluginImpl; 182 plugin2.iface = new WavPluginImpl;
185 plugin2.decoder = plugin2.iface->decoder(); 183 plugin2.decoder = plugin2.iface->decoder();
186 plugin2.encoder = plugin2.iface->encoder(); 184 plugin2.encoder = plugin2.iface->encoder();
187 pluginList.append( plugin2 ); 185 pluginList.append( plugin2 );
188#endif 186#endif
189 187
190 if ( pluginList.count() ) 188 if ( pluginList.count() )
191 MediaPlayerDebug(( "%i decoders found", pluginList.count() )); 189 MediaPlayerDebug(( "%i decoders found", pluginList.count() ));
192 else 190 else
193 MediaPlayerDebug(( "No decoders found" )); 191 MediaPlayerDebug(( "No decoders found" ));
194} 192}
195 193
diff --git a/core/multimedia/opieplayer/modplug/load_j2b.cpp b/core/multimedia/opieplayer/modplug/load_j2b.cpp
index 4f0b85c..8b4cccd 100644
--- a/core/multimedia/opieplayer/modplug/load_j2b.cpp
+++ b/core/multimedia/opieplayer/modplug/load_j2b.cpp
@@ -1,17 +1,16 @@
1/* 1/*
2 * This program is free software; you can redistribute it and modify it 2 * This program is free software; you can redistribute it and modify it
3 * under the terms of the GNU General Public License as published by the 3 * under the terms of the GNU General Public License as published by the
4 * Free Software Foundation; either version 2 of the license or (at your 4 * Free Software Foundation; either version 2 of the license or (at your
5 * option) any later version. 5 * option) any later version.
6 * 6 *
7 * Authors: Olivier Lapicque <olivierl@jps.net> 7 * Authors: Olivier Lapicque <olivierl@jps.net>
8*/ 8*/
9 9
10 10
11/////////////////////////////////////////////////// 11///////////////////////////////////////////////////
12// 12//
13// J2B module loader 13// J2B module loader
14// 14//
15/////////////////////////////////////////////////// 15///////////////////////////////////////////////////
16#include "stdafx.h"
17 16
diff --git a/core/multimedia/opieplayer/om3u.cpp b/core/multimedia/opieplayer/om3u.cpp
index 778eb22..ae89518 100644
--- a/core/multimedia/opieplayer/om3u.cpp
+++ b/core/multimedia/opieplayer/om3u.cpp
@@ -1,175 +1,162 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 4 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
5 =. 5 =.
6 .=l. 6 .=l.
7           .>+-= 7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can 8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU General Public 10:`=1 )Y*s>-.--   : the terms of the GNU General Public
11.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_. 14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 17    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; General Public License for more 20..}^=.=       =       ; General Public License for more
21++=   -.     .`     .: details. 21++=   -.     .`     .: details.
22 :     =  ...= . :.=- 22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = General Public License along with 24  -_. . .   )=.  = General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29 29
30*/ 30*/
31 31
32#include "playlistwidget.h"
33#include "om3u.h" 32#include "om3u.h"
34 33
35#include <qpe/applnk.h> 34
36#include <qpe/qpeapplication.h>
37#include <qpe/storage.h>
38#include <qpe/mimetype.h>
39#include <qpe/global.h>
40#include <qpe/resource.h>
41
42#include <qdir.h>
43#include <qregexp.h>
44#include <qstring.h>
45#include <qtextstream.h>
46#include <qstringlist.h>
47#include <qcstring.h>
48 35
49static inline QString fullBaseName ( const QFileInfo &fi ) 36static inline QString fullBaseName ( const QFileInfo &fi )
50{ 37{
51 QString str = fi. fileName ( ); 38 QString str = fi. fileName ( );
52 return str. left ( str. findRev ( '.' )); 39 return str. left ( str. findRev ( '.' ));
53} 40}
54 41
55 42
56//extern PlayListWidget *playList; 43//extern PlayListWidget *playList;
57 44
58Om3u::Om3u( const QString &filePath, int mode) 45Om3u::Om3u( const QString &filePath, int mode)
59 : QStringList (){ 46 : QStringList (){
60//qDebug("<<<<<<<new m3u "+filePath); 47//qDebug("<<<<<<<new m3u "+filePath);
61 f.setName(filePath); 48 f.setName(filePath);
62 f.open(mode); 49 f.open(mode);
63} 50}
64 51
65Om3u::~Om3u(){} 52Om3u::~Om3u(){}
66 53
67void Om3u::readM3u() { 54void Om3u::readM3u() {
68// qDebug("<<<<<<reading m3u "+f.name()); 55// qDebug("<<<<<<reading m3u "+f.name());
69 QTextStream t(&f); 56 QTextStream t(&f);
70 t.setEncoding(QTextStream::UnicodeUTF8); 57 t.setEncoding(QTextStream::UnicodeUTF8);
71 QString s; 58 QString s;
72 while ( !t.atEnd() ) { 59 while ( !t.atEnd() ) {
73 s=t.readLine(); 60 s=t.readLine();
74 // qDebug(s); 61 // qDebug(s);
75 if( s.find( "#", 0, TRUE) == -1 ) { 62 if( s.find( "#", 0, TRUE) == -1 ) {
76 if( s.left(2) == "E:" || s.left(2) == "P:" ) { 63 if( s.left(2) == "E:" || s.left(2) == "P:" ) {
77 s = s.right( s.length() -2 ); 64 s = s.right( s.length() -2 );
78 QFileInfo f( s ); 65 QFileInfo f( s );
79 QString name = fullBaseName ( f ); 66 QString name = fullBaseName ( f );
80 name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); 67 name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 );
81 s=s.replace( QRegExp( "\\" ), "/" ); 68 s=s.replace( QRegExp( "\\" ), "/" );
82 append(s); 69 append(s);
83 // qDebug(s); 70 // qDebug(s);
84 } else { // is url 71 } else { // is url
85 s.replace( QRegExp( "%20" )," " ); 72 s.replace( QRegExp( "%20" )," " );
86 QString name; 73 QString name;
87 // if( name.left( 4 ) == "http" ) { 74 // if( name.left( 4 ) == "http" ) {
88 // name = s.right( s.length() - 7 ); 75 // name = s.right( s.length() - 7 );
89 // } else { 76 // } else {
90 name = s; 77 name = s;
91 // } 78 // }
92 append(name); 79 append(name);
93 // qDebug(name); 80 // qDebug(name);
94 } 81 }
95 } 82 }
96 } 83 }
97} 84}
98 85
99void Om3u::readPls() { //it's a pls file 86void Om3u::readPls() { //it's a pls file
100 QTextStream t( &f ); 87 QTextStream t( &f );
101 t.setEncoding(QTextStream::UnicodeUTF8); 88 t.setEncoding(QTextStream::UnicodeUTF8);
102 QString s; 89 QString s;
103 while ( !t.atEnd() ) { 90 while ( !t.atEnd() ) {
104 s = t.readLine(); 91 s = t.readLine();
105 if( s.left(4) == "File" ) { 92 if( s.left(4) == "File" ) {
106 s = s.right( s.length() - 6 ); 93 s = s.right( s.length() - 6 );
107 s.replace( QRegExp( "%20" )," "); 94 s.replace( QRegExp( "%20" )," ");
108// qDebug( "adding " + s + " to playlist" ); 95// qDebug( "adding " + s + " to playlist" );
109 // numberofentries=2 96 // numberofentries=2
110 // File1=http 97 // File1=http
111 // Title 98 // Title
112 // Length 99 // Length
113 // Version 100 // Version
114 // File2=http 101 // File2=http
115 s = s.replace( QRegExp( "\\" ), "/" ); 102 s = s.replace( QRegExp( "\\" ), "/" );
116 QFileInfo f( s ); 103 QFileInfo f( s );
117 QString name = fullBaseName ( f ); 104 QString name = fullBaseName ( f );
118 if( name.left( 4 ) == "http" ) { 105 if( name.left( 4 ) == "http" ) {
119 name = s.right( s.length() - 7); 106 name = s.right( s.length() - 7);
120 } else { 107 } else {
121 name = s; 108 name = s;
122 } 109 }
123 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); 110 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
124 if( s.at( s.length() - 4) == '.') // if this is probably a file 111 if( s.at( s.length() - 4) == '.') // if this is probably a file
125 append(s); 112 append(s);
126 else { //if its a url 113 else { //if its a url
127 if( name.right( 1 ).find( '/' ) == -1) { 114 if( name.right( 1 ).find( '/' ) == -1) {
128 s += "/"; 115 s += "/";
129 } 116 }
130 append(s); 117 append(s);
131 } 118 }
132 } 119 }
133 } 120 }
134} 121}
135 122
136void Om3u::write() { //writes list to m3u file 123void Om3u::write() { //writes list to m3u file
137 QString list; 124 QString list;
138 QTextStream t(&f); 125 QTextStream t(&f);
139 t.setEncoding(QTextStream::UnicodeUTF8); 126 t.setEncoding(QTextStream::UnicodeUTF8);
140 if(count()>0) { 127 if(count()>0) {
141 for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { 128 for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) {
142 // qDebug(*it); 129 // qDebug(*it);
143 t << *it << "\n"; 130 t << *it << "\n";
144 } 131 }
145 } 132 }
146// f.close(); 133// f.close();
147} 134}
148 135
149void Om3u::add(const QString &filePath) { //adds to m3u file 136void Om3u::add(const QString &filePath) { //adds to m3u file
150 append(filePath); 137 append(filePath);
151} 138}
152 139
153void Om3u::remove(const QString &filePath) { //removes from m3u list 140void Om3u::remove(const QString &filePath) { //removes from m3u list
154 QString list, currentFile; 141 QString list, currentFile;
155 if(count()>0) { 142 if(count()>0) {
156 for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { 143 for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) {
157 currentFile=*it; 144 currentFile=*it;
158 // qDebug(*it); 145 // qDebug(*it);
159 146
160 if( filePath != currentFile) 147 if( filePath != currentFile)
161 list += currentFile+"\n"; 148 list += currentFile+"\n";
162 } 149 }
163 f.writeBlock( list, list.length() ); 150 f.writeBlock( list, list.length() );
164 } 151 }
165} 152}
166 153
167void Om3u::deleteFile(const QString &filePath) {//deletes m3u file 154void Om3u::deleteFile(const QString &filePath) {//deletes m3u file
168 f.close(); 155 f.close();
169 f.remove(); 156 f.remove();
170 157
171} 158}
172 159
173void Om3u::close() { //closes m3u file 160void Om3u::close() { //closes m3u file
174 f.close(); 161 f.close();
175} 162}
diff --git a/core/multimedia/opieplayer/playlistselection.cpp b/core/multimedia/opieplayer/playlistselection.cpp
index 94567f2..ad831cf 100644
--- a/core/multimedia/opieplayer/playlistselection.cpp
+++ b/core/multimedia/opieplayer/playlistselection.cpp
@@ -1,216 +1,208 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the 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/applnk.h>
21#include <qpe/resource.h>
22#include <qpe/config.h>
23 20
24#include <qpainter.h>
25#include <qimage.h>
26#include <qheader.h> 21#include <qheader.h>
27#include <qlistview.h>
28#include <qlist.h>
29#include <qpixmap.h>
30 22
31#include "playlistselection.h" 23#include "playlistselection.h"
32 24
33#include <stdlib.h> 25#include <stdlib.h>
34 26
35class PlayListSelectionItem : public QListViewItem { 27class PlayListSelectionItem : public QListViewItem {
36public: 28public:
37 PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) { 29 PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) {
38 setText( 0, f->name() ); 30 setText( 0, f->name() );
39 setPixmap( 0, f->pixmap() ); 31 setPixmap( 0, f->pixmap() );
40 } 32 }
41 33
42 ~PlayListSelectionItem() { 34 ~PlayListSelectionItem() {
43 }; 35 };
44 36
45 const DocLnk *file() const { return fl; } 37 const DocLnk *file() const { return fl; }
46 38
47private: 39private:
48 const DocLnk *fl; 40 const DocLnk *fl;
49}; 41};
50 42
51 43
52PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) 44PlayListSelection::PlayListSelection( QWidget *parent, const char *name )
53 : QListView( parent, name ) 45 : QListView( parent, name )
54{ 46{
55// qDebug("starting playlistselector"); 47// qDebug("starting playlistselector");
56// #ifdef USE_PLAYLIST_BACKGROUND 48// #ifdef USE_PLAYLIST_BACKGROUND
57// setStaticBackground( TRUE ); 49// setStaticBackground( TRUE );
58// setBackgroundPixmap( Resource::loadPixmap( "opieplayer/background" ) ); 50// setBackgroundPixmap( Resource::loadPixmap( "opieplayer/background" ) );
59 51
60// setBackgroundPixmap( Resource::loadPixmap( "launcher/opielogo" ) ); 52// setBackgroundPixmap( Resource::loadPixmap( "launcher/opielogo" ) );
61// #endif 53// #endif
62// addColumn("Title",236); 54// addColumn("Title",236);
63// setAllColumnsShowFocus( TRUE ); 55// setAllColumnsShowFocus( TRUE );
64 addColumn( tr( "Playlist Selection" ) ); 56 addColumn( tr( "Playlist Selection" ) );
65 header()->hide(); 57 header()->hide();
66// setSorting( -1, FALSE ); 58// setSorting( -1, FALSE );
67 // FIXME 59 // FIXME
68} 60}
69 61
70 62
71PlayListSelection::~PlayListSelection() { 63PlayListSelection::~PlayListSelection() {
72} 64}
73 65
74 66
75// #ifdef USE_PLAYLIST_BACKGROUND 67// #ifdef USE_PLAYLIST_BACKGROUND
76void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) { 68void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) {
77// qDebug("drawBackground"); 69// qDebug("drawBackground");
78 p->fillRect( r, QBrush( white ) ); 70 p->fillRect( r, QBrush( white ) );
79// QImage logo = Resource::loadImage( "launcher/opielogo" ); 71// QImage logo = Resource::loadImage( "launcher/opielogo" );
80// if ( !logo.isNull() ) 72// if ( !logo.isNull() )
81// p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo ); 73// p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo );
82} 74}
83// #endif 75// #endif
84 76
85 77
86void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { 78void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) {
87 if ( event->state() == QMouseEvent::LeftButton ) { 79 if ( event->state() == QMouseEvent::LeftButton ) {
88 QListViewItem *currentItem = selectedItem(); 80 QListViewItem *currentItem = selectedItem();
89 QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); 81 QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) );
90 if ( currentItem && currentItem->itemAbove() == itemUnder ) 82 if ( currentItem && currentItem->itemAbove() == itemUnder )
91 moveSelectedUp(); 83 moveSelectedUp();
92 else if ( currentItem && currentItem->itemBelow() == itemUnder ) 84 else if ( currentItem && currentItem->itemBelow() == itemUnder )
93 moveSelectedDown(); 85 moveSelectedDown();
94 } 86 }
95} 87}
96 88
97 89
98const DocLnk *PlayListSelection::current() { 90const DocLnk *PlayListSelection::current() {
99 PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); 91 PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem();
100 if ( item ) 92 if ( item )
101 return item->file(); 93 return item->file();
102 return NULL; 94 return NULL;
103} 95}
104 96
105 97
106void PlayListSelection::addToSelection( const DocLnk &lnk ) { 98void PlayListSelection::addToSelection( const DocLnk &lnk ) {
107 PlayListSelectionItem *item = new PlayListSelectionItem( this, new DocLnk( lnk ) ); 99 PlayListSelectionItem *item = new PlayListSelectionItem( this, new DocLnk( lnk ) );
108 QListViewItem *current = selectedItem(); 100 QListViewItem *current = selectedItem();
109 if ( current ) 101 if ( current )
110 item->moveItem( current ); 102 item->moveItem( current );
111 setSelected( item, TRUE ); 103 setSelected( item, TRUE );
112 ensureItemVisible( item); 104 ensureItemVisible( item);
113} 105}
114 106
115 107
116void PlayListSelection::removeSelected() { 108void PlayListSelection::removeSelected() {
117 QListViewItem *item = selectedItem(); 109 QListViewItem *item = selectedItem();
118 if ( item ) 110 if ( item )
119 delete item; 111 delete item;
120 setSelected( currentItem(), TRUE ); 112 setSelected( currentItem(), TRUE );
121 ensureItemVisible( selectedItem() ); 113 ensureItemVisible( selectedItem() );
122} 114}
123 115
124 116
125void PlayListSelection::moveSelectedUp() { 117void PlayListSelection::moveSelectedUp() {
126 QListViewItem *item = selectedItem(); 118 QListViewItem *item = selectedItem();
127 if ( item && item->itemAbove() ) 119 if ( item && item->itemAbove() )
128 item->itemAbove()->moveItem( item ); 120 item->itemAbove()->moveItem( item );
129 ensureItemVisible( selectedItem() ); 121 ensureItemVisible( selectedItem() );
130} 122}
131 123
132 124
133void PlayListSelection::moveSelectedDown() { 125void PlayListSelection::moveSelectedDown() {
134 QListViewItem *item = selectedItem(); 126 QListViewItem *item = selectedItem();
135 if ( item && item->itemBelow() ) 127 if ( item && item->itemBelow() )
136 item->moveItem( item->itemBelow() ); 128 item->moveItem( item->itemBelow() );
137 ensureItemVisible( selectedItem() ); 129 ensureItemVisible( selectedItem() );
138} 130}
139 131
140 132
141bool PlayListSelection::prev() { 133bool PlayListSelection::prev() {
142 QListViewItem *item = selectedItem(); 134 QListViewItem *item = selectedItem();
143 if ( item && item->itemAbove() ) 135 if ( item && item->itemAbove() )
144 setSelected( item->itemAbove(), TRUE ); 136 setSelected( item->itemAbove(), TRUE );
145 else 137 else
146 return FALSE; 138 return FALSE;
147 ensureItemVisible( selectedItem() ); 139 ensureItemVisible( selectedItem() );
148 return TRUE; 140 return TRUE;
149} 141}
150 142
151bool PlayListSelection::next() { 143bool PlayListSelection::next() {
152 QListViewItem *item = selectedItem(); 144 QListViewItem *item = selectedItem();
153 if ( item && item->itemBelow() ) 145 if ( item && item->itemBelow() )
154 setSelected( item->itemBelow(), TRUE ); 146 setSelected( item->itemBelow(), TRUE );
155 else 147 else
156 return FALSE; 148 return FALSE;
157 ensureItemVisible( selectedItem() ); 149 ensureItemVisible( selectedItem() );
158 return TRUE; 150 return TRUE;
159} 151}
160 152
161 153
162bool PlayListSelection::first() { 154bool PlayListSelection::first() {
163 QListViewItem *item = firstChild(); 155 QListViewItem *item = firstChild();
164 if ( item ) 156 if ( item )
165 setSelected( item, TRUE ); 157 setSelected( item, TRUE );
166 else 158 else
167 return FALSE; 159 return FALSE;
168 ensureItemVisible( selectedItem() ); 160 ensureItemVisible( selectedItem() );
169 return TRUE; 161 return TRUE;
170} 162}
171 163
172 164
173bool PlayListSelection::last() { 165bool PlayListSelection::last() {
174 QListViewItem *prevItem = NULL; 166 QListViewItem *prevItem = NULL;
175 QListViewItem *item = firstChild(); 167 QListViewItem *item = firstChild();
176 while ( ( item = item->nextSibling() ) ) 168 while ( ( item = item->nextSibling() ) )
177 prevItem = item; 169 prevItem = item;
178 if ( prevItem ) 170 if ( prevItem )
179 setSelected( prevItem, TRUE ); 171 setSelected( prevItem, TRUE );
180 else 172 else
181 return FALSE; 173 return FALSE;
182 ensureItemVisible( selectedItem() ); 174 ensureItemVisible( selectedItem() );
183 return TRUE; 175 return TRUE;
184} 176}
185 177
186void PlayListSelection::unSelect() 178void PlayListSelection::unSelect()
187{ 179{
188 QListViewItem *item = selectedItem(); 180 QListViewItem *item = selectedItem();
189 setSelected( currentItem(), FALSE); 181 setSelected( currentItem(), FALSE);
190} 182}
191 183
192void PlayListSelection::writeCurrent( Config& cfg ) { 184void PlayListSelection::writeCurrent( Config& cfg ) {
193 cfg.setGroup("PlayList"); 185 cfg.setGroup("PlayList");
194 QListViewItem *item = selectedItem(); 186 QListViewItem *item = selectedItem();
195 if ( item ) 187 if ( item )
196 cfg.writeEntry("current", item->text(0) ); 188 cfg.writeEntry("current", item->text(0) );
197 // qDebug(item->text(0)); 189 // qDebug(item->text(0));
198 190
199} 191}
200 192
201void PlayListSelection::setSelectedItem(const QString &strk ) { 193void PlayListSelection::setSelectedItem(const QString &strk ) {
202 194
203 unSelect(); 195 unSelect();
204 QListViewItemIterator it( this ); 196 QListViewItemIterator it( this );
205 for ( ; it.current(); ++it ) { 197 for ( ; it.current(); ++it ) {
206// qDebug( it.current()->text(0)); 198// qDebug( it.current()->text(0));
207 if( strk == it.current()->text(0)) { 199 if( strk == it.current()->text(0)) {
208// qDebug( "We have a match "+strk); 200// qDebug( "We have a match "+strk);
209 setSelected( it.current(), TRUE); 201 setSelected( it.current(), TRUE);
210 ensureItemVisible( it.current() ); 202 ensureItemVisible( it.current() );
211 return; 203 return;
212 } 204 }
213 } 205 }
214// setSelected( item, TRUE ); 206// setSelected( item, TRUE );
215// ensureItemVisible( selectedItem() ); 207// ensureItemVisible( selectedItem() );
216} 208}
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index db99866..a359843 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -1,1482 +1,1457 @@
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// code added by L. J. Potter Sat 03-02-2002 06:17:54 20// code added by L. J. Potter Sat 03-02-2002 06:17:54
21#define QTOPIA_INTERNAL_FSLP 21#define QTOPIA_INTERNAL_FSLP
22#include <qpe/qcopenvelope_qws.h>
23 22
24#include <qmenubar.h>
25#include <qtoolbar.h> 23#include <qtoolbar.h>
26#include <qpe/qpemenubar.h> 24#include <qpe/qpemenubar.h>
27#include <qpe/fileselector.h>
28#include <qpe/qpeapplication.h>
29#include <qpe/lnkproperties.h> 25#include <qpe/lnkproperties.h>
30#include <qpe/storage.h>
31 26
32#include <qpe/applnk.h>
33#include <qpe/config.h>
34#include <qpe/global.h>
35#include <qpe/resource.h>
36#include <qaction.h> 27#include <qaction.h>
37#include <qcursor.h>
38#include <qimage.h>
39#include <qfile.h>
40#include <qdir.h>
41#include <qlayout.h> 28#include <qlayout.h>
42#include <qlabel.h>
43#include <qlist.h>
44#include <qlistbox.h>
45#include <qmainwindow.h>
46#include <qmessagebox.h> 29#include <qmessagebox.h>
47#include <qtoolbutton.h>
48#include <qtabwidget.h>
49#include <qlistview.h>
50#include <qpoint.h>
51#include <qlineedit.h>
52#include <qpushbutton.h>
53#include <qregexp.h>
54#include <qtextstream.h>
55 30
56//#include <qtimer.h> 31//#include <qtimer.h>
57 32
58#include "playlistselection.h" 33#include "playlistselection.h"
59#include "playlistwidget.h" 34#include "playlistwidget.h"
60#include "mediaplayerstate.h" 35#include "mediaplayerstate.h"
61 36
62#include "inputDialog.h" 37#include "inputDialog.h"
63 38
64#include <stdlib.h> 39#include <stdlib.h>
65#include "audiowidget.h" 40#include "audiowidget.h"
66#include "videowidget.h" 41#include "videowidget.h"
67 42
68#include <unistd.h> 43#include <unistd.h>
69#include <sys/file.h> 44#include <sys/file.h>
70#include <sys/ioctl.h> 45#include <sys/ioctl.h>
71#include <sys/soundcard.h> 46#include <sys/soundcard.h>
72 47
73// for setBacklight() 48// for setBacklight()
74#include <linux/fb.h> 49#include <linux/fb.h>
75#include <sys/types.h> 50#include <sys/types.h>
76#include <sys/stat.h> 51#include <sys/stat.h>
77#include <stdlib.h> 52#include <stdlib.h>
78 53
79#define BUTTONS_ON_TOOLBAR 54#define BUTTONS_ON_TOOLBAR
80#define SIDE_BUTTONS 55#define SIDE_BUTTONS
81#define CAN_SAVE_LOAD_PLAYLISTS 56#define CAN_SAVE_LOAD_PLAYLISTS
82 57
83extern AudioWidget *audioUI; 58extern AudioWidget *audioUI;
84extern VideoWidget *videoUI; 59extern VideoWidget *videoUI;
85extern MediaPlayerState *mediaPlayerState; 60extern MediaPlayerState *mediaPlayerState;
86 61
87static inline QString fullBaseName ( const QFileInfo &fi ) 62static inline QString fullBaseName ( const QFileInfo &fi )
88{ 63{
89 QString str = fi. fileName ( ); 64 QString str = fi. fileName ( );
90 return str. left ( str. findRev ( '.' )); 65 return str. left ( str. findRev ( '.' ));
91} 66}
92 67
93 68
94QString audioMimes ="audio/mpeg;audio/x-wav;application/ogg;audio/x-mod"; 69QString audioMimes ="audio/mpeg;audio/x-wav;application/ogg;audio/x-mod";
95// class myFileSelector { 70// class myFileSelector {
96 71
97// }; 72// };
98class PlayListWidgetPrivate { 73class PlayListWidgetPrivate {
99public: 74public:
100 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; 75 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove;
101 QFrame *playListFrame; 76 QFrame *playListFrame;
102 FileSelector *files; 77 FileSelector *files;
103 PlayListSelection *selectedFiles; 78 PlayListSelection *selectedFiles;
104 bool setDocumentUsed; 79 bool setDocumentUsed;
105 DocLnk *current; 80 DocLnk *current;
106}; 81};
107 82
108 83
109class ToolButton : public QToolButton { 84class ToolButton : public QToolButton {
110public: 85public:
111 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) 86 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE )
112 : QToolButton( parent, name ) { 87 : QToolButton( parent, name ) {
113 setTextLabel( name ); 88 setTextLabel( name );
114 setPixmap( Resource::loadPixmap( icon ) ); 89 setPixmap( Resource::loadPixmap( icon ) );
115 setAutoRaise( TRUE ); 90 setAutoRaise( TRUE );
116 setFocusPolicy( QWidget::NoFocus ); 91 setFocusPolicy( QWidget::NoFocus );
117 setToggleButton( t ); 92 setToggleButton( t );
118 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); 93 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
119 QPEMenuToolFocusManager::manager()->addWidget( this ); 94 QPEMenuToolFocusManager::manager()->addWidget( this );
120 } 95 }
121}; 96};
122 97
123 98
124class MenuItem : public QAction { 99class MenuItem : public QAction {
125public: 100public:
126 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) 101 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot )
127 : QAction( text, QString::null, 0, 0 ) { 102 : QAction( text, QString::null, 0, 0 ) {
128 connect( this, SIGNAL( activated() ), handler, slot ); 103 connect( this, SIGNAL( activated() ), handler, slot );
129 addTo( parent ); 104 addTo( parent );
130 } 105 }
131}; 106};
132 107
133 108
134PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 109PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
135 : QMainWindow( parent, name, fl ) { 110 : QMainWindow( parent, name, fl ) {
136 111
137 d = new PlayListWidgetPrivate; 112 d = new PlayListWidgetPrivate;
138 d->setDocumentUsed = FALSE; 113 d->setDocumentUsed = FALSE;
139 d->current = NULL; 114 d->current = NULL;
140 fromSetDocument = FALSE; 115 fromSetDocument = FALSE;
141 insanityBool=FALSE; 116 insanityBool=FALSE;
142 audioScan = FALSE; 117 audioScan = FALSE;
143 videoScan = FALSE; 118 videoScan = FALSE;
144// menuTimer = new QTimer( this ,"menu timer"), 119// menuTimer = new QTimer( this ,"menu timer"),
145// connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); 120// connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) );
146 channel = new QCopChannel( "QPE/Application/opieplayer", this ); 121 channel = new QCopChannel( "QPE/Application/opieplayer", this );
147 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 122 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
148 this, SLOT( qcopReceive(const QCString&, const QByteArray&)) ); 123 this, SLOT( qcopReceive(const QCString&, const QByteArray&)) );
149 124
150 setBackgroundMode( PaletteButton ); 125 setBackgroundMode( PaletteButton );
151 126
152 setCaption( tr("OpiePlayer") ); 127 setCaption( tr("OpiePlayer") );
153 setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); 128 setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) );
154 129
155 setToolBarsMovable( FALSE ); 130 setToolBarsMovable( FALSE );
156 131
157 // Create Toolbar 132 // Create Toolbar
158 QToolBar *toolbar = new QToolBar( this ); 133 QToolBar *toolbar = new QToolBar( this );
159 toolbar->setHorizontalStretchable( TRUE ); 134 toolbar->setHorizontalStretchable( TRUE );
160 135
161 // Create Menubar 136 // Create Menubar
162 QMenuBar *menu = new QMenuBar( toolbar ); 137 QMenuBar *menu = new QMenuBar( toolbar );
163 menu->setMargin( 0 ); 138 menu->setMargin( 0 );
164 139
165 QToolBar *bar = new QToolBar( this ); 140 QToolBar *bar = new QToolBar( this );
166 bar->setLabel( tr( "Play Operations" ) ); 141 bar->setLabel( tr( "Play Operations" ) );
167// d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", 142// d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list",
168// this , SLOT( addSelected()) ); 143// this , SLOT( addSelected()) );
169 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); 144 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close");
170 tbDeletePlaylist->setFlat(TRUE); 145 tbDeletePlaylist->setFlat(TRUE);
171 146
172 tbDeletePlaylist->setFixedSize(20,20); 147 tbDeletePlaylist->setFixedSize(20,20);
173 148
174 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", 149 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist",
175 this , SLOT(addSelected()) ); 150 this , SLOT(addSelected()) );
176 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", 151 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist",
177 this , SLOT(removeSelected()) ); 152 this , SLOT(removeSelected()) );
178// d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); 153// d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE );
179 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", 154 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play",
180 this , SLOT( btnPlay(bool) ), TRUE ); 155 this , SLOT( btnPlay(bool) ), TRUE );
181 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", 156 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle",
182 mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); 157 mediaPlayerState, SLOT(setShuffled(bool)), TRUE );
183 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", 158 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop",
184 mediaPlayerState, SLOT(setLooping(bool)), TRUE ); 159 mediaPlayerState, SLOT(setLooping(bool)), TRUE );
185 tbDeletePlaylist->hide(); 160 tbDeletePlaylist->hide();
186 161
187 QPopupMenu *pmPlayList = new QPopupMenu( this ); 162 QPopupMenu *pmPlayList = new QPopupMenu( this );
188 menu->insertItem( tr( "File" ), pmPlayList ); 163 menu->insertItem( tr( "File" ), pmPlayList );
189 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 164 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
190 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); 165 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) );
191 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); 166 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) );
192 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); 167 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) );
193 pmPlayList->insertSeparator(-1); 168 pmPlayList->insertSeparator(-1);
194 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); 169 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) );
195 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); 170 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) );
196 pmPlayList->insertSeparator(-1); 171 pmPlayList->insertSeparator(-1);
197 new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); 172 new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) );
198 new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); 173 new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) );
199 174
200 QPopupMenu *pmView = new QPopupMenu( this ); 175 QPopupMenu *pmView = new QPopupMenu( this );
201 menu->insertItem( tr( "View" ), pmView ); 176 menu->insertItem( tr( "View" ), pmView );
202 177
203 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); 178 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0);
204 fullScreenButton->addTo(pmView); 179 fullScreenButton->addTo(pmView);
205 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); 180 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0);
206 scaleButton->addTo(pmView); 181 scaleButton->addTo(pmView);
207 182
208 183
209 skinsMenu = new QPopupMenu( this ); 184 skinsMenu = new QPopupMenu( this );
210 menu->insertItem( tr( "Skins" ), skinsMenu ); 185 menu->insertItem( tr( "Skins" ), skinsMenu );
211 skinsMenu->isCheckable(); 186 skinsMenu->isCheckable();
212 connect( skinsMenu, SIGNAL( activated( int ) ) , 187 connect( skinsMenu, SIGNAL( activated( int ) ) ,
213 this, SLOT( skinsMenuActivated( int ) ) ); 188 this, SLOT( skinsMenuActivated( int ) ) );
214 populateSkinsMenu(); 189 populateSkinsMenu();
215 190
216 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); 191 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton );
217 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); 192 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton );
218 193
219 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); 194 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton );
220 195
221 tabWidget = new QTabWidget( hbox6, "tabWidget" ); 196 tabWidget = new QTabWidget( hbox6, "tabWidget" );
222// tabWidget->setTabShape(QTabWidget::Triangular); 197// tabWidget->setTabShape(QTabWidget::Triangular);
223 198
224 QWidget *pTab; 199 QWidget *pTab;
225 pTab = new QWidget( tabWidget, "pTab" ); 200 pTab = new QWidget( tabWidget, "pTab" );
226// playlistView = new QListView( pTab, "playlistview" ); 201// playlistView = new QListView( pTab, "playlistview" );
227// playlistView->setMinimumSize(236,260); 202// playlistView->setMinimumSize(236,260);
228 tabWidget->insertTab( pTab,"Playlist"); 203 tabWidget->insertTab( pTab,"Playlist");
229 204
230 205
231 // Add the playlist area 206 // Add the playlist area
232 207
233 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); 208 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton );
234 d->playListFrame = vbox3; 209 d->playListFrame = vbox3;
235 210
236 QGridLayout *layoutF = new QGridLayout( pTab ); 211 QGridLayout *layoutF = new QGridLayout( pTab );
237 layoutF->setSpacing( 2); 212 layoutF->setSpacing( 2);
238 layoutF->setMargin( 2); 213 layoutF->setMargin( 2);
239 layoutF->addMultiCellWidget( d->playListFrame , 0, 0, 0, 1 ); 214 layoutF->addMultiCellWidget( d->playListFrame , 0, 0, 0, 1 );
240 215
241 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); 216 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton );
242 217
243 d->selectedFiles = new PlayListSelection( hbox2); 218 d->selectedFiles = new PlayListSelection( hbox2);
244 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); 219 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton );
245 220
246 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); 221 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold);
247 222
248 223
249 224
250 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch 225 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch
251 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); 226 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) );
252 new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); 227 new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) );
253 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); 228 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) );
254 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch 229 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch
255 230
256 QWidget *aTab; 231 QWidget *aTab;
257 aTab = new QWidget( tabWidget, "aTab" ); 232 aTab = new QWidget( tabWidget, "aTab" );
258 audioView = new QListView( aTab, "Audioview" ); 233 audioView = new QListView( aTab, "Audioview" );
259 234
260 QGridLayout *layoutA = new QGridLayout( aTab ); 235 QGridLayout *layoutA = new QGridLayout( aTab );
261 layoutA->setSpacing( 2); 236 layoutA->setSpacing( 2);
262 layoutA->setMargin( 2); 237 layoutA->setMargin( 2);
263 layoutA->addMultiCellWidget( audioView, 0, 0, 0, 1 ); 238 layoutA->addMultiCellWidget( audioView, 0, 0, 0, 1 );
264 239
265 audioView->addColumn( tr("Title"),-1); 240 audioView->addColumn( tr("Title"),-1);
266 audioView->addColumn(tr("Size"), -1); 241 audioView->addColumn(tr("Size"), -1);
267 audioView->addColumn(tr("Media"),-1); 242 audioView->addColumn(tr("Media"),-1);
268 audioView->addColumn( tr( "Path" ), -1 ); 243 audioView->addColumn( tr( "Path" ), -1 );
269 244
270 audioView->setColumnAlignment(1, Qt::AlignRight); 245 audioView->setColumnAlignment(1, Qt::AlignRight);
271 audioView->setColumnAlignment(2, Qt::AlignRight); 246 audioView->setColumnAlignment(2, Qt::AlignRight);
272 audioView->setAllColumnsShowFocus(TRUE); 247 audioView->setAllColumnsShowFocus(TRUE);
273 248
274 audioView->setMultiSelection( TRUE ); 249 audioView->setMultiSelection( TRUE );
275 audioView->setSelectionMode( QListView::Extended); 250 audioView->setSelectionMode( QListView::Extended);
276 audioView->setSorting( 3, TRUE ); 251 audioView->setSorting( 3, TRUE );
277 252
278 tabWidget->insertTab(aTab,tr("Audio")); 253 tabWidget->insertTab(aTab,tr("Audio"));
279 254
280 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); 255 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold);
281 256
282// audioView 257// audioView
283// populateAudioView(); 258// populateAudioView();
284// videowidget 259// videowidget
285 260
286 QWidget *vTab; 261 QWidget *vTab;
287 vTab = new QWidget( tabWidget, "vTab" ); 262 vTab = new QWidget( tabWidget, "vTab" );
288 videoView = new QListView( vTab, "Videoview" ); 263 videoView = new QListView( vTab, "Videoview" );
289 264
290 QGridLayout *layoutV = new QGridLayout( vTab ); 265 QGridLayout *layoutV = new QGridLayout( vTab );
291 layoutV->setSpacing( 2); 266 layoutV->setSpacing( 2);
292 layoutV->setMargin( 2); 267 layoutV->setMargin( 2);
293 layoutV->addMultiCellWidget( videoView, 0, 0, 0, 1 ); 268 layoutV->addMultiCellWidget( videoView, 0, 0, 0, 1 );
294 269
295 videoView->addColumn(tr("Title"),-1); 270 videoView->addColumn(tr("Title"),-1);
296 videoView->addColumn(tr("Size"),-1); 271 videoView->addColumn(tr("Size"),-1);
297 videoView->addColumn(tr("Media"),-1); 272 videoView->addColumn(tr("Media"),-1);
298 videoView->addColumn(tr( "Path" ), -1 ); 273 videoView->addColumn(tr( "Path" ), -1 );
299 videoView->setColumnAlignment(1, Qt::AlignRight); 274 videoView->setColumnAlignment(1, Qt::AlignRight);
300 videoView->setColumnAlignment(2, Qt::AlignRight); 275 videoView->setColumnAlignment(2, Qt::AlignRight);
301 videoView->setAllColumnsShowFocus(TRUE); 276 videoView->setAllColumnsShowFocus(TRUE);
302 videoView->setMultiSelection( TRUE ); 277 videoView->setMultiSelection( TRUE );
303 videoView->setSelectionMode( QListView::Extended); 278 videoView->setSelectionMode( QListView::Extended);
304 279
305 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); 280 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold);
306 281
307 tabWidget->insertTab( vTab,tr("Video")); 282 tabWidget->insertTab( vTab,tr("Video"));
308 283
309 QWidget *LTab; 284 QWidget *LTab;
310 LTab = new QWidget( tabWidget, "LTab" ); 285 LTab = new QWidget( tabWidget, "LTab" );
311 playLists = new FileSelector( "playlist/plain;audio/x-mpegurl", LTab, "fileselector" , FALSE, FALSE); 286 playLists = new FileSelector( "playlist/plain;audio/x-mpegurl", LTab, "fileselector" , FALSE, FALSE);
312 287
313 QGridLayout *layoutL = new QGridLayout( LTab ); 288 QGridLayout *layoutL = new QGridLayout( LTab );
314 layoutL->setSpacing( 2); 289 layoutL->setSpacing( 2);
315 layoutL->setMargin( 2); 290 layoutL->setMargin( 2);
316 layoutL->addMultiCellWidget( playLists, 0, 0, 0, 1 ); 291 layoutL->addMultiCellWidget( playLists, 0, 0, 0, 1 );
317 292
318 tabWidget->insertTab(LTab,tr("Lists")); 293 tabWidget->insertTab(LTab,tr("Lists"));
319 294
320 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); 295 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist()));
321 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); 296 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) );
322 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); 297 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) );
323 298
324 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 299 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
325 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); 300 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) );
326 301
327 302
328///audioView 303///audioView
329 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 304 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
330 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 305 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
331 306
332 connect( audioView, SIGNAL( returnPressed( QListViewItem *)), 307 connect( audioView, SIGNAL( returnPressed( QListViewItem *)),
333 this,SLOT( playIt( QListViewItem *)) ); 308 this,SLOT( playIt( QListViewItem *)) );
334 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 309 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
335 310
336 311
337//videoView 312//videoView
338 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 313 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
339 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 314 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
340 connect( videoView, SIGNAL( returnPressed( QListViewItem *)), 315 connect( videoView, SIGNAL( returnPressed( QListViewItem *)),
341 this,SLOT( playIt( QListViewItem *)) ); 316 this,SLOT( playIt( QListViewItem *)) );
342 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 317 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
343 318
344//playlists 319//playlists
345 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); 320 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) );
346 321
347 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); 322 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*)));
348 323
349 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); 324 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) );
350 325
351 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); 326 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) );
352 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); 327 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) );
353 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); 328 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) );
354 329
355 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); 330 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
356 331
357 setCentralWidget( vbox5 ); 332 setCentralWidget( vbox5 );
358 333
359 Config cfg( "OpiePlayer" ); 334 Config cfg( "OpiePlayer" );
360 readConfig( cfg ); 335 readConfig( cfg );
361 336
362 currentPlayList = cfg.readEntry("CurrentPlaylist","default"); 337 currentPlayList = cfg.readEntry("CurrentPlaylist","default");
363 loadList(DocLnk( currentPlayList)); 338 loadList(DocLnk( currentPlayList));
364 setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlayList))); 339 setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlayList)));
365 340
366 initializeStates(); 341 initializeStates();
367} 342}
368 343
369 344
370PlayListWidget::~PlayListWidget() { 345PlayListWidget::~PlayListWidget() {
371 Config cfg( "OpiePlayer" ); 346 Config cfg( "OpiePlayer" );
372 writeConfig( cfg ); 347 writeConfig( cfg );
373 348
374 if ( d->current ) 349 if ( d->current )
375 delete d->current; 350 delete d->current;
376 if(d) delete d; 351 if(d) delete d;
377} 352}
378 353
379 354
380void PlayListWidget::initializeStates() { 355void PlayListWidget::initializeStates() {
381 356
382 d->tbPlay->setOn( mediaPlayerState->playing() ); 357 d->tbPlay->setOn( mediaPlayerState->playing() );
383 d->tbLoop->setOn( mediaPlayerState->looping() ); 358 d->tbLoop->setOn( mediaPlayerState->looping() );
384 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 359 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
385 setPlaylist( true); 360 setPlaylist( true);
386} 361}
387 362
388 363
389void PlayListWidget::readConfig( Config& cfg ) { 364void PlayListWidget::readConfig( Config& cfg ) {
390 cfg.setGroup("PlayList"); 365 cfg.setGroup("PlayList");
391 QString currentString = cfg.readEntry("current", "" ); 366 QString currentString = cfg.readEntry("current", "" );
392 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 367 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
393 for ( int i = 0; i < noOfFiles; i++ ) { 368 for ( int i = 0; i < noOfFiles; i++ ) {
394 QString entryName; 369 QString entryName;
395 entryName.sprintf( "File%i", i + 1 ); 370 entryName.sprintf( "File%i", i + 1 );
396 QString linkFile = cfg.readEntry( entryName ); 371 QString linkFile = cfg.readEntry( entryName );
397 DocLnk lnk( linkFile ); 372 DocLnk lnk( linkFile );
398 if ( lnk.isValid() ) { 373 if ( lnk.isValid() ) {
399 d->selectedFiles->addToSelection( lnk ); 374 d->selectedFiles->addToSelection( lnk );
400 } 375 }
401 } 376 }
402 d->selectedFiles->setSelectedItem( currentString); 377 d->selectedFiles->setSelectedItem( currentString);
403} 378}
404 379
405 380
406void PlayListWidget::writeConfig( Config& cfg ) const { 381void PlayListWidget::writeConfig( Config& cfg ) const {
407 382
408 d->selectedFiles->writeCurrent( cfg); 383 d->selectedFiles->writeCurrent( cfg);
409 cfg.setGroup("PlayList"); 384 cfg.setGroup("PlayList");
410 int noOfFiles = 0; 385 int noOfFiles = 0;
411 d->selectedFiles->first(); 386 d->selectedFiles->first();
412 do { 387 do {
413 const DocLnk *lnk = d->selectedFiles->current(); 388 const DocLnk *lnk = d->selectedFiles->current();
414 if ( lnk ) { 389 if ( lnk ) {
415 QString entryName; 390 QString entryName;
416 entryName.sprintf( "File%i", noOfFiles + 1 ); 391 entryName.sprintf( "File%i", noOfFiles + 1 );
417// qDebug(entryName); 392// qDebug(entryName);
418 cfg.writeEntry( entryName, lnk->linkFile() ); 393 cfg.writeEntry( entryName, lnk->linkFile() );
419 // if this link does exist, add it so we have the file 394 // if this link does exist, add it so we have the file
420 // next time... 395 // next time...
421 if ( !QFile::exists( lnk->linkFile() ) ) { 396 if ( !QFile::exists( lnk->linkFile() ) ) {
422 // the way writing lnks doesn't really check for out 397 // the way writing lnks doesn't really check for out
423 // of disk space, but check it anyway. 398 // of disk space, but check it anyway.
424// if ( !lnk->writeLink() ) { 399// if ( !lnk->writeLink() ) {
425// QMessageBox::critical( 0, tr("Out of space"), 400// QMessageBox::critical( 0, tr("Out of space"),
426// tr( "There was a problem saving " 401// tr( "There was a problem saving "
427// "the playlist.\n" 402// "the playlist.\n"
428// "Your playlist " 403// "Your playlist "
429// "may be missing some entries\n" 404// "may be missing some entries\n"
430// "the next time you start it." ) 405// "the next time you start it." )
431// ); 406// );
432// } 407// }
433 408
434 } 409 }
435 noOfFiles++; 410 noOfFiles++;
436 } 411 }
437 } 412 }
438 while ( d->selectedFiles->next() ); 413 while ( d->selectedFiles->next() );
439 cfg.writeEntry("NumberOfFiles", noOfFiles ); 414 cfg.writeEntry("NumberOfFiles", noOfFiles );
440} 415}
441 416
442 417
443void PlayListWidget::addToSelection( const DocLnk& lnk ) { 418void PlayListWidget::addToSelection( const DocLnk& lnk ) {
444 d->setDocumentUsed = false; 419 d->setDocumentUsed = false;
445 if ( mediaPlayerState->playlist() ) { 420 if ( mediaPlayerState->playlist() ) {
446 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) 421 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" )
447 d->selectedFiles->addToSelection( lnk ); 422 d->selectedFiles->addToSelection( lnk );
448 } 423 }
449 else 424 else
450 mediaPlayerState->setPlaying( true); 425 mediaPlayerState->setPlaying( true);
451 426
452} 427}
453 428
454 429
455void PlayListWidget::clearList() { 430void PlayListWidget::clearList() {
456 while ( first() ) 431 while ( first() )
457 d->selectedFiles->removeSelected(); 432 d->selectedFiles->removeSelected();
458 Config cfg( "OpiePlayer" ); 433 Config cfg( "OpiePlayer" );
459 cfg.setGroup("PlayList"); 434 cfg.setGroup("PlayList");
460 cfg.writeEntry("CurrentPlaylist",""); 435 cfg.writeEntry("CurrentPlaylist","");
461 currentPlayList=""; 436 currentPlayList="";
462 437
463} 438}
464 439
465 440
466void PlayListWidget::addAllToList() { 441void PlayListWidget::addAllToList() {
467 DocLnkSet filesAll; 442 DocLnkSet filesAll;
468 Global::findDocuments(&filesAll, "video/*;audio/*"); 443 Global::findDocuments(&filesAll, "video/*;audio/*");
469 QListIterator<DocLnk> Adit( filesAll.children() ); 444 QListIterator<DocLnk> Adit( filesAll.children() );
470 for ( ; Adit.current(); ++Adit ) 445 for ( ; Adit.current(); ++Adit )
471 if(QFileInfo(Adit.current()->file()).exists()) 446 if(QFileInfo(Adit.current()->file()).exists())
472 d->selectedFiles->addToSelection( **Adit ); 447 d->selectedFiles->addToSelection( **Adit );
473 tabWidget->setCurrentPage(0); 448 tabWidget->setCurrentPage(0);
474 449
475 writeCurrentM3u(); 450 writeCurrentM3u();
476 d->selectedFiles->first(); 451 d->selectedFiles->first();
477} 452}
478 453
479 454
480void PlayListWidget::addAllMusicToList() { 455void PlayListWidget::addAllMusicToList() {
481 QListIterator<DocLnk> dit( files.children() ); 456 QListIterator<DocLnk> dit( files.children() );
482 for ( ; dit.current(); ++dit ) 457 for ( ; dit.current(); ++dit )
483 if(QFileInfo(dit.current()->file()).exists()) 458 if(QFileInfo(dit.current()->file()).exists())
484 d->selectedFiles->addToSelection( **dit ); 459 d->selectedFiles->addToSelection( **dit );
485 tabWidget->setCurrentPage(0); 460 tabWidget->setCurrentPage(0);
486 461
487 writeCurrentM3u(); 462 writeCurrentM3u();
488 d->selectedFiles->first(); 463 d->selectedFiles->first();
489} 464}
490 465
491 466
492void PlayListWidget::addAllVideoToList() { 467void PlayListWidget::addAllVideoToList() {
493 QListIterator<DocLnk> dit( vFiles.children() ); 468 QListIterator<DocLnk> dit( vFiles.children() );
494 for ( ; dit.current(); ++dit ) 469 for ( ; dit.current(); ++dit )
495 if(QFileInfo( dit.current()->file()).exists()) 470 if(QFileInfo( dit.current()->file()).exists())
496 d->selectedFiles->addToSelection( **dit ); 471 d->selectedFiles->addToSelection( **dit );
497 tabWidget->setCurrentPage(0); 472 tabWidget->setCurrentPage(0);
498 473
499 writeCurrentM3u(); 474 writeCurrentM3u();
500 d->selectedFiles->first(); 475 d->selectedFiles->first();
501} 476}
502 477
503 478
504void PlayListWidget::setDocument(const QString& fileref) { 479void PlayListWidget::setDocument(const QString& fileref) {
505 fromSetDocument = true; 480 fromSetDocument = true;
506 d->setDocumentUsed = TRUE; 481 d->setDocumentUsed = TRUE;
507 setDocumentEx(fileref); 482 setDocumentEx(fileref);
508} 483}
509 484
510void PlayListWidget::setDocumentEx(const QString& fileref) { 485void PlayListWidget::setDocumentEx(const QString& fileref) {
511 qDebug("opieplayer receive "+fileref); 486 qDebug("opieplayer receive "+fileref);
512 clearList(); 487 clearList();
513 DocLnk lnk; 488 DocLnk lnk;
514 QFileInfo fileInfo(fileref); 489 QFileInfo fileInfo(fileref);
515 if ( !fileInfo.exists() ) { 490 if ( !fileInfo.exists() ) {
516 QMessageBox::critical( 0, tr( "Invalid File" ), 491 QMessageBox::critical( 0, tr( "Invalid File" ),
517 tr( "There was a problem in getting the file." ) ); 492 tr( "There was a problem in getting the file." ) );
518 return; 493 return;
519 } 494 }
520 // qDebug("<<<<<<<<<<<<<<<<<<<<<<setDocument "+fileref); 495 // qDebug("<<<<<<<<<<<<<<<<<<<<<<setDocument "+fileref);
521 QString extension = fileInfo.extension(false); 496 QString extension = fileInfo.extension(false);
522 if( extension.find( "m3u", 0, false) != -1) { //is m3u 497 if( extension.find( "m3u", 0, false) != -1) { //is m3u
523 readm3u( fileref); 498 readm3u( fileref);
524 } 499 }
525 else if( extension.find( "pls", 0, false) != -1 ) { //is pls 500 else if( extension.find( "pls", 0, false) != -1 ) { //is pls
526 readPls( fileref); 501 readPls( fileref);
527 } 502 }
528 else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist 503 else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist
529 clearList(); 504 clearList();
530 lnk.setName( fileInfo.baseName() ); //sets name 505 lnk.setName( fileInfo.baseName() ); //sets name
531 lnk.setFile( fileref ); //sets file name 506 lnk.setFile( fileref ); //sets file name
532 lnk.setIcon("Sound"); 507 lnk.setIcon("Sound");
533 //addToSelection( lnk ); 508 //addToSelection( lnk );
534 509
535 loadList( lnk); 510 loadList( lnk);
536 d->selectedFiles->first(); 511 d->selectedFiles->first();
537 } else { 512 } else {
538 if( fileref.find(".desktop",0,TRUE) != -1) { 513 if( fileref.find(".desktop",0,TRUE) != -1) {
539 lnk = DocLnk(fileref); 514 lnk = DocLnk(fileref);
540 } else { 515 } else {
541 lnk.setName( fileInfo.baseName() ); //sets name 516 lnk.setName( fileInfo.baseName() ); //sets name
542 lnk.setFile( fileref ); //sets file name 517 lnk.setFile( fileref ); //sets file name
543 lnk.setIcon("Sound"); 518 lnk.setIcon("Sound");
544 } 519 }
545 520
546 addToSelection( lnk ); 521 addToSelection( lnk );
547 // addToSelection( DocLnk( fileref ) ); 522 // addToSelection( DocLnk( fileref ) );
548 lnk.removeLinkFile(); 523 lnk.removeLinkFile();
549 // qApp->processEvents(); 524 // qApp->processEvents();
550 } 525 }
551 setCaption(tr("OpiePlayer")); 526 setCaption(tr("OpiePlayer"));
552 d->setDocumentUsed = TRUE; 527 d->setDocumentUsed = TRUE;
553 d->selectedFiles->setSelected(d->selectedFiles->firstChild(),true ); 528 d->selectedFiles->setSelected(d->selectedFiles->firstChild(),true );
554 mediaPlayerState->setPlaying( FALSE ); 529 mediaPlayerState->setPlaying( FALSE );
555 qApp->processEvents(); 530 qApp->processEvents();
556 mediaPlayerState->setPlaying( TRUE ); 531 mediaPlayerState->setPlaying( TRUE );
557 532
558} 533}
559 534
560 535
561void PlayListWidget::setActiveWindow() { 536void PlayListWidget::setActiveWindow() {
562 // qDebug("SETTING active window"); 537 // qDebug("SETTING active window");
563 // When we get raised we need to ensure that it switches views 538 // When we get raised we need to ensure that it switches views
564 char origView = mediaPlayerState->view(); 539 char origView = mediaPlayerState->view();
565 mediaPlayerState->setView( 'l' ); // invalidate 540 mediaPlayerState->setView( 'l' ); // invalidate
566 mediaPlayerState->setView( origView ); // now switch back 541 mediaPlayerState->setView( origView ); // now switch back
567} 542}
568 543
569 544
570void PlayListWidget::useSelectedDocument() { 545void PlayListWidget::useSelectedDocument() {
571 d->setDocumentUsed = FALSE; 546 d->setDocumentUsed = FALSE;
572} 547}
573 548
574 549
575const DocLnk *PlayListWidget::current() { // this is fugly 550const DocLnk *PlayListWidget::current() { // this is fugly
576 switch (tabWidget->currentPageIndex()) { 551 switch (tabWidget->currentPageIndex()) {
577 case 0: //playlist 552 case 0: //playlist
578 { 553 {
579 // qDebug("playlist"); 554 // qDebug("playlist");
580 if ( mediaPlayerState->playlist() ) { 555 if ( mediaPlayerState->playlist() ) {
581 return d->selectedFiles->current(); 556 return d->selectedFiles->current();
582 } 557 }
583 else if ( d->setDocumentUsed && d->current ) { 558 else if ( d->setDocumentUsed && d->current ) {
584 return d->current; 559 return d->current;
585 } else { 560 } else {
586 return &(d->files->selectedDocument()); 561 return &(d->files->selectedDocument());
587 } 562 }
588 } 563 }
589 break; 564 break;
590 case 1://audio 565 case 1://audio
591 { 566 {
592 // qDebug("audioView"); 567 // qDebug("audioView");
593 QListIterator<DocLnk> dit( files.children() ); 568 QListIterator<DocLnk> dit( files.children() );
594 for ( ; dit.current(); ++dit ) { 569 for ( ; dit.current(); ++dit ) {
595 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { 570 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) {
596 insanityBool=TRUE; 571 insanityBool=TRUE;
597 return dit; 572 return dit;
598 } 573 }
599 } 574 }
600 } 575 }
601 break; 576 break;
602 case 2: // video 577 case 2: // video
603 { 578 {
604 QListIterator<DocLnk> Vdit( vFiles.children() ); 579 QListIterator<DocLnk> Vdit( vFiles.children() );
605 for ( ; Vdit.current(); ++Vdit ) { 580 for ( ; Vdit.current(); ++Vdit ) {
606 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { 581 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) {
607 insanityBool=TRUE; 582 insanityBool=TRUE;
608 return Vdit; 583 return Vdit;
609 } 584 }
610 } 585 }
611 } 586 }
612 break; 587 break;
613 }; 588 };
614 return 0; 589 return 0;
615} 590}
616 591
617bool PlayListWidget::prev() { 592bool PlayListWidget::prev() {
618 if ( mediaPlayerState->playlist() ) { 593 if ( mediaPlayerState->playlist() ) {
619 if ( mediaPlayerState->shuffled() ) { 594 if ( mediaPlayerState->shuffled() ) {
620 const DocLnk *cur = current(); 595 const DocLnk *cur = current();
621 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 596 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
622 for ( int i = 0; i < j; i++ ) { 597 for ( int i = 0; i < j; i++ ) {
623 if ( !d->selectedFiles->next() ) 598 if ( !d->selectedFiles->next() )
624 d->selectedFiles->first(); 599 d->selectedFiles->first();
625 } 600 }
626 if ( cur == current() ) 601 if ( cur == current() )
627 if ( !d->selectedFiles->next() ) 602 if ( !d->selectedFiles->next() )
628 d->selectedFiles->first(); 603 d->selectedFiles->first();
629 return TRUE; 604 return TRUE;
630 } else { 605 } else {
631 if ( !d->selectedFiles->prev() ) { 606 if ( !d->selectedFiles->prev() ) {
632 if ( mediaPlayerState->looping() ) { 607 if ( mediaPlayerState->looping() ) {
633 return d->selectedFiles->last(); 608 return d->selectedFiles->last();
634 } else { 609 } else {
635 return FALSE; 610 return FALSE;
636 } 611 }
637 } 612 }
638 return TRUE; 613 return TRUE;
639 } 614 }
640 } else { 615 } else {
641 return mediaPlayerState->looping(); 616 return mediaPlayerState->looping();
642 } 617 }
643} 618}
644 619
645 620
646bool PlayListWidget::next() { 621bool PlayListWidget::next() {
647 if ( mediaPlayerState->playlist() ) { 622 if ( mediaPlayerState->playlist() ) {
648 if ( mediaPlayerState->shuffled() ) { 623 if ( mediaPlayerState->shuffled() ) {
649 return prev(); 624 return prev();
650 } else { 625 } else {
651 if ( !d->selectedFiles->next() ) { 626 if ( !d->selectedFiles->next() ) {
652 if ( mediaPlayerState->looping() ) { 627 if ( mediaPlayerState->looping() ) {
653 return d->selectedFiles->first(); 628 return d->selectedFiles->first();
654 } else { 629 } else {
655 return FALSE; 630 return FALSE;
656 } 631 }
657 } 632 }
658 return TRUE; 633 return TRUE;
659 } 634 }
660 } else { 635 } else {
661 return mediaPlayerState->looping(); 636 return mediaPlayerState->looping();
662 } 637 }
663} 638}
664 639
665 640
666bool PlayListWidget::first() { 641bool PlayListWidget::first() {
667 if ( mediaPlayerState->playlist() ) 642 if ( mediaPlayerState->playlist() )
668 return d->selectedFiles->first(); 643 return d->selectedFiles->first();
669 else 644 else
670 return mediaPlayerState->looping(); 645 return mediaPlayerState->looping();
671} 646}
672 647
673 648
674bool PlayListWidget::last() { 649bool PlayListWidget::last() {
675 if ( mediaPlayerState->playlist() ) 650 if ( mediaPlayerState->playlist() )
676 return d->selectedFiles->last(); 651 return d->selectedFiles->last();
677 else 652 else
678 return mediaPlayerState->looping(); 653 return mediaPlayerState->looping();
679} 654}
680 655
681 656
682void PlayListWidget::saveList() { 657void PlayListWidget::saveList() {
683 writem3u(); 658 writem3u();
684} 659}
685 660
686void PlayListWidget::loadList( const DocLnk & lnk) { 661void PlayListWidget::loadList( const DocLnk & lnk) {
687 QString name = lnk.name(); 662 QString name = lnk.name();
688 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); 663 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name);
689 664
690 if( name.length()>0) { 665 if( name.length()>0) {
691 setCaption("OpiePlayer: "+name); 666 setCaption("OpiePlayer: "+name);
692 // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); 667 // qDebug("<<<<<<<<<<<<load list "+ lnk.file());
693 clearList(); 668 clearList();
694 readm3u(lnk.file()); 669 readm3u(lnk.file());
695 tabWidget->setCurrentPage(0); 670 tabWidget->setCurrentPage(0);
696 } 671 }
697} 672}
698 673
699void PlayListWidget::setPlaylist( bool shown ) { 674void PlayListWidget::setPlaylist( bool shown ) {
700 if ( shown ) 675 if ( shown )
701 d->playListFrame->show(); 676 d->playListFrame->show();
702 else 677 else
703 d->playListFrame->hide(); 678 d->playListFrame->hide();
704} 679}
705 680
706void PlayListWidget::setView( char view ) { 681void PlayListWidget::setView( char view ) {
707 if ( view == 'l' ) 682 if ( view == 'l' )
708 QPEApplication::showWidget( this ); 683 QPEApplication::showWidget( this );
709 else 684 else
710 hide(); 685 hide();
711} 686}
712 687
713void PlayListWidget::addSelected() { 688void PlayListWidget::addSelected() {
714 DocLnk lnk; 689 DocLnk lnk;
715 QString filename; 690 QString filename;
716 switch (tabWidget->currentPageIndex()) { 691 switch (tabWidget->currentPageIndex()) {
717 692
718 case 0: //playlist 693 case 0: //playlist
719 return; 694 return;
720 break; 695 break;
721 case 1: { //audio 696 case 1: { //audio
722 QListViewItemIterator it( audioView ); 697 QListViewItemIterator it( audioView );
723 for ( ; it.current(); ++it ) { 698 for ( ; it.current(); ++it ) {
724 if ( it.current()->isSelected() ) { 699 if ( it.current()->isSelected() ) {
725 filename = it.current()->text(3); 700 filename = it.current()->text(3);
726 lnk.setName( QFileInfo(filename).baseName() ); //sets name 701 lnk.setName( QFileInfo(filename).baseName() ); //sets name
727 lnk.setFile( filename ); //sets file name 702 lnk.setFile( filename ); //sets file name
728 d->selectedFiles->addToSelection( lnk); 703 d->selectedFiles->addToSelection( lnk);
729 } 704 }
730 } 705 }
731 audioView->clearSelection(); 706 audioView->clearSelection();
732 // d->selectedFiles->next(); 707 // d->selectedFiles->next();
733 } 708 }
734 break; 709 break;
735 710
736 case 2: { // video 711 case 2: { // video
737 QListViewItemIterator it( videoView ); 712 QListViewItemIterator it( videoView );
738 for ( ; it.current(); ++it ) { 713 for ( ; it.current(); ++it ) {
739 if ( it.current()->isSelected() ) { 714 if ( it.current()->isSelected() ) {
740 715
741 filename = it.current()->text(3); 716 filename = it.current()->text(3);
742 lnk.setName( QFileInfo(filename).baseName() ); //sets name 717 lnk.setName( QFileInfo(filename).baseName() ); //sets name
743 lnk.setFile( filename ); //sets file name 718 lnk.setFile( filename ); //sets file name
744 d->selectedFiles->addToSelection( lnk); 719 d->selectedFiles->addToSelection( lnk);
745 } 720 }
746 } 721 }
747 videoView->clearSelection(); 722 videoView->clearSelection();
748 } 723 }
749 break; 724 break;
750 }; 725 };
751 // tabWidget->setCurrentPage(0); 726 // tabWidget->setCurrentPage(0);
752 writeCurrentM3u(); 727 writeCurrentM3u();
753 728
754} 729}
755 730
756void PlayListWidget::removeSelected() { 731void PlayListWidget::removeSelected() {
757 d->selectedFiles->removeSelected( ); 732 d->selectedFiles->removeSelected( );
758} 733}
759 734
760void PlayListWidget::playIt( QListViewItem *) { 735void PlayListWidget::playIt( QListViewItem *) {
761 // d->setDocumentUsed = FALSE; 736 // d->setDocumentUsed = FALSE;
762 // mediaPlayerState->curPosition =0; 737 // mediaPlayerState->curPosition =0;
763 // mediaPlayerState->setPlaying(FALSE); 738 // mediaPlayerState->setPlaying(FALSE);
764 mediaPlayerState->setPlaying(TRUE); 739 mediaPlayerState->setPlaying(TRUE);
765 d->selectedFiles->unSelect(); 740 d->selectedFiles->unSelect();
766} 741}
767 742
768void PlayListWidget::addToSelection( QListViewItem *it) { 743void PlayListWidget::addToSelection( QListViewItem *it) {
769 d->setDocumentUsed = FALSE; 744 d->setDocumentUsed = FALSE;
770 745
771 if(it) { 746 if(it) {
772 switch ( tabWidget->currentPageIndex()) { 747 switch ( tabWidget->currentPageIndex()) {
773 case 0: //playlist 748 case 0: //playlist
774 return; 749 return;
775 break; 750 break;
776 }; 751 };
777 // case 1: { 752 // case 1: {
778 DocLnk lnk; 753 DocLnk lnk;
779 QString filename; 754 QString filename;
780 755
781 filename=it->text(3); 756 filename=it->text(3);
782 lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name 757 lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name
783 lnk.setFile( filename ); //sets file name 758 lnk.setFile( filename ); //sets file name
784 d->selectedFiles->addToSelection( lnk); 759 d->selectedFiles->addToSelection( lnk);
785 760
786 if(tabWidget->currentPageIndex() == 0) 761 if(tabWidget->currentPageIndex() == 0)
787 writeCurrentM3u(); 762 writeCurrentM3u();
788 // tabWidget->setCurrentPage(0); 763 // tabWidget->setCurrentPage(0);
789 764
790 } 765 }
791} 766}
792 767
793void PlayListWidget::tabChanged(QWidget *) { 768void PlayListWidget::tabChanged(QWidget *) {
794 769
795 switch ( tabWidget->currentPageIndex()) { 770 switch ( tabWidget->currentPageIndex()) {
796 case 0: 771 case 0:
797 { 772 {
798 if( !tbDeletePlaylist->isHidden()) 773 if( !tbDeletePlaylist->isHidden())
799 tbDeletePlaylist->hide(); 774 tbDeletePlaylist->hide();
800 d->tbRemoveFromList->setEnabled(TRUE); 775 d->tbRemoveFromList->setEnabled(TRUE);
801 d->tbAddToList->setEnabled(FALSE); 776 d->tbAddToList->setEnabled(FALSE);
802 } 777 }
803 break; 778 break;
804 case 1: 779 case 1:
805 { 780 {
806 audioView->clear(); 781 audioView->clear();
807 populateAudioView(); 782 populateAudioView();
808 783
809 if( !tbDeletePlaylist->isHidden()) 784 if( !tbDeletePlaylist->isHidden())
810 tbDeletePlaylist->hide(); 785 tbDeletePlaylist->hide();
811 d->tbRemoveFromList->setEnabled(FALSE); 786 d->tbRemoveFromList->setEnabled(FALSE);
812 d->tbAddToList->setEnabled(TRUE); 787 d->tbAddToList->setEnabled(TRUE);
813 } 788 }
814 break; 789 break;
815 case 2: 790 case 2:
816 { 791 {
817 videoView->clear(); 792 videoView->clear();
818 populateVideoView(); 793 populateVideoView();
819 if( !tbDeletePlaylist->isHidden()) 794 if( !tbDeletePlaylist->isHidden())
820 tbDeletePlaylist->hide(); 795 tbDeletePlaylist->hide();
821 d->tbRemoveFromList->setEnabled(FALSE); 796 d->tbRemoveFromList->setEnabled(FALSE);
822 d->tbAddToList->setEnabled(TRUE); 797 d->tbAddToList->setEnabled(TRUE);
823 } 798 }
824 break; 799 break;
825 case 3: 800 case 3:
826 { 801 {
827 if( tbDeletePlaylist->isHidden()) 802 if( tbDeletePlaylist->isHidden())
828 tbDeletePlaylist->show(); 803 tbDeletePlaylist->show();
829 playLists->reread(); 804 playLists->reread();
830 } 805 }
831 break; 806 break;
832 }; 807 };
833} 808}
834 809
835void PlayListWidget::btnPlay(bool b) { 810void PlayListWidget::btnPlay(bool b) {
836 // mediaPlayerState->setPlaying(b); 811 // mediaPlayerState->setPlaying(b);
837 switch ( tabWidget->currentPageIndex()) { 812 switch ( tabWidget->currentPageIndex()) {
838 case 0: 813 case 0:
839 { 814 {
840 // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 815 // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1
841 // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { 816 // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) {
842 // QMessageBox::message("Note","You are trying to play\na malformed url."); 817 // QMessageBox::message("Note","You are trying to play\na malformed url.");
843 // } else { 818 // } else {
844 mediaPlayerState->setPlaying(b); 819 mediaPlayerState->setPlaying(b);
845 insanityBool=FALSE; 820 insanityBool=FALSE;
846 qDebug("insanity"); 821 qDebug("insanity");
847 // } 822 // }
848 } 823 }
849 break; 824 break;
850 case 1: 825 case 1:
851 { 826 {
852 // d->selectedFiles->unSelect(); 827 // d->selectedFiles->unSelect();
853 addToSelection( audioView->currentItem() ); 828 addToSelection( audioView->currentItem() );
854 mediaPlayerState->setPlaying( b); 829 mediaPlayerState->setPlaying( b);
855 d->selectedFiles->removeSelected( ); 830 d->selectedFiles->removeSelected( );
856 d->selectedFiles->unSelect(); 831 d->selectedFiles->unSelect();
857 tabWidget->setCurrentPage(1); 832 tabWidget->setCurrentPage(1);
858 insanityBool=FALSE; 833 insanityBool=FALSE;
859 }// audioView->clearSelection(); 834 }// audioView->clearSelection();
860 break; 835 break;
861 case 2: 836 case 2:
862 { 837 {
863 838
864 addToSelection( videoView->currentItem() ); 839 addToSelection( videoView->currentItem() );
865 mediaPlayerState->setPlaying( b); 840 mediaPlayerState->setPlaying( b);
866 // qApp->processEvents(); 841 // qApp->processEvents();
867 d->selectedFiles->removeSelected( ); 842 d->selectedFiles->removeSelected( );
868 d->selectedFiles->unSelect(); 843 d->selectedFiles->unSelect();
869 tabWidget->setCurrentPage(2); 844 tabWidget->setCurrentPage(2);
870 insanityBool=FALSE; 845 insanityBool=FALSE;
871 }// videoView->clearSelection(); 846 }// videoView->clearSelection();
872 break; 847 break;
873 }; 848 };
874 849
875} 850}
876 851
877void PlayListWidget::deletePlaylist() { 852void PlayListWidget::deletePlaylist() {
878 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 853 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
879 (tr("You really want to delete\nthis playlist?")), 854 (tr("You really want to delete\nthis playlist?")),
880 (tr("Yes")), (tr("No")), 0 )){ 855 (tr("Yes")), (tr("No")), 0 )){
881 case 0: // Yes clicked, 856 case 0: // Yes clicked,
882 QFile().remove(playLists->selectedDocument().file()); 857 QFile().remove(playLists->selectedDocument().file());
883 QFile().remove(playLists->selectedDocument().linkFile()); 858 QFile().remove(playLists->selectedDocument().linkFile());
884 playLists->reread(); 859 playLists->reread();
885 break; 860 break;
886 case 1: // Cancel 861 case 1: // Cancel
887 break; 862 break;
888 }; 863 };
889} 864}
890 865
891void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int ) 866void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int )
892{ 867{
893 switch (mouse) { 868 switch (mouse) {
894 case 1: 869 case 1:
895 break; 870 break;
896 case 2:{ 871 case 2:{
897 872
898 QPopupMenu m; 873 QPopupMenu m;
899 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 874 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
900 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 875 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
901 m.insertSeparator(); 876 m.insertSeparator();
902 if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) 877 if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() )
903 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 878 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
904 879
905 m.exec( QCursor::pos() ); 880 m.exec( QCursor::pos() );
906 } 881 }
907 break; 882 break;
908 }; 883 };
909} 884}
910 885
911void PlayListWidget::playSelected() 886void PlayListWidget::playSelected()
912{ 887{
913 btnPlay( true); 888 btnPlay( true);
914// d->selectedFiles->unSelect(); 889// d->selectedFiles->unSelect();
915} 890}
916 891
917void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int) 892void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int)
918{ 893{
919 switch (mouse) { 894 switch (mouse) {
920 case 1: 895 case 1:
921 896
922 break; 897 break;
923 case 2:{ 898 case 2:{
924 QPopupMenu m; 899 QPopupMenu m;
925 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 900 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
926 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 901 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
927 // m.insertSeparator(); 902 // m.insertSeparator();
928 // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 903 // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
929 m.exec( QCursor::pos() ); 904 m.exec( QCursor::pos() );
930 } 905 }
931 break; 906 break;
932 }; 907 };
933 908
934} 909}
935 910
936void PlayListWidget::listDelete() { 911void PlayListWidget::listDelete() {
937 Config cfg( "OpiePlayer" ); 912 Config cfg( "OpiePlayer" );
938 cfg.setGroup("PlayList"); 913 cfg.setGroup("PlayList");
939 currentPlayList = cfg.readEntry("CurrentPlaylist",""); 914 currentPlayList = cfg.readEntry("CurrentPlaylist","");
940 QString file; 915 QString file;
941 // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 916 // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
942 switch ( tabWidget->currentPageIndex()) { 917 switch ( tabWidget->currentPageIndex()) {
943 case 0: 918 case 0:
944 break; 919 break;
945 case 1: 920 case 1:
946 { 921 {
947 file = audioView->currentItem()->text(0); 922 file = audioView->currentItem()->text(0);
948 QListIterator<DocLnk> Pdit( files.children() ); 923 QListIterator<DocLnk> Pdit( files.children() );
949 for ( ; Pdit.current(); ++Pdit ) { 924 for ( ; Pdit.current(); ++Pdit ) {
950 if( Pdit.current()->name() == file) { 925 if( Pdit.current()->name() == file) {
951 LnkProperties prop( Pdit.current() ); 926 LnkProperties prop( Pdit.current() );
952 QPEApplication::execDialog( &prop ); 927 QPEApplication::execDialog( &prop );
953 } 928 }
954 } 929 }
955 populateAudioView(); 930 populateAudioView();
956 } 931 }
957 break; 932 break;
958 case 2: 933 case 2:
959 { 934 {
960 // file = videoView->selectedItem()->text(0); 935 // file = videoView->selectedItem()->text(0);
961 // for ( int i = 0; i < noOfFiles; i++ ) { 936 // for ( int i = 0; i < noOfFiles; i++ ) {
962 // QString entryName; 937 // QString entryName;
963 // entryName.sprintf( "File%i", i + 1 ); 938 // entryName.sprintf( "File%i", i + 1 );
964 // QString linkFile = cfg.readEntry( entryName ); 939 // QString linkFile = cfg.readEntry( entryName );
965 // AppLnk lnk( AppLnk(linkFile)); 940 // AppLnk lnk( AppLnk(linkFile));
966 // if( lnk.name() == file ) { 941 // if( lnk.name() == file ) {
967 // LnkProperties prop( &lnk); 942 // LnkProperties prop( &lnk);
968 // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); 943 // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *)));
969 // prop.showMaximized(); 944 // prop.showMaximized();
970 // prop.exec(); 945 // prop.exec();
971 // } 946 // }
972 // } 947 // }
973 } 948 }
974 break; 949 break;
975 }; 950 };
976} 951}
977 952
978void PlayListWidget::scanForAudio() { 953void PlayListWidget::scanForAudio() {
979 // qDebug("scan for audio"); 954 // qDebug("scan for audio");
980 files.detachChildren(); 955 files.detachChildren();
981 QListIterator<DocLnk> sdit( files.children() ); 956 QListIterator<DocLnk> sdit( files.children() );
982 for ( ; sdit.current(); ++sdit ) { 957 for ( ; sdit.current(); ++sdit ) {
983 delete sdit.current(); 958 delete sdit.current();
984 } 959 }
985 Global::findDocuments( &files, audioMimes); 960 Global::findDocuments( &files, audioMimes);
986 audioScan = true; 961 audioScan = true;
987} 962}
988void PlayListWidget::scanForVideo() { 963void PlayListWidget::scanForVideo() {
989 // qDebug("scan for video"); 964 // qDebug("scan for video");
990 vFiles.detachChildren(); 965 vFiles.detachChildren();
991 QListIterator<DocLnk> sdit( vFiles.children() ); 966 QListIterator<DocLnk> sdit( vFiles.children() );
992 for ( ; sdit.current(); ++sdit ) { 967 for ( ; sdit.current(); ++sdit ) {
993 delete sdit.current(); 968 delete sdit.current();
994 } 969 }
995 Global::findDocuments(&vFiles, "video/*"); 970 Global::findDocuments(&vFiles, "video/*");
996 videoScan = true; 971 videoScan = true;
997} 972}
998 973
999void PlayListWidget::populateAudioView() { 974void PlayListWidget::populateAudioView() {
1000 975
1001 audioView->clear(); 976 audioView->clear();
1002 StorageInfo storageInfo; 977 StorageInfo storageInfo;
1003 const QList<FileSystem> &fs = storageInfo.fileSystems(); 978 const QList<FileSystem> &fs = storageInfo.fileSystems();
1004 if(!audioScan) scanForAudio(); 979 if(!audioScan) scanForAudio();
1005 980
1006 QListIterator<DocLnk> dit( files.children() ); 981 QListIterator<DocLnk> dit( files.children() );
1007 QListIterator<FileSystem> it ( fs ); 982 QListIterator<FileSystem> it ( fs );
1008 983
1009 QString storage; 984 QString storage;
1010 for ( ; dit.current(); ++dit ) { 985 for ( ; dit.current(); ++dit ) {
1011 for( ; it.current(); ++it ){ 986 for( ; it.current(); ++it ){
1012 const QString name = (*it)->name(); 987 const QString name = (*it)->name();
1013 const QString path = (*it)->path(); 988 const QString path = (*it)->path();
1014 if(dit.current()->file().find(path) != -1 ) storage=name; 989 if(dit.current()->file().find(path) != -1 ) storage=name;
1015 } 990 }
1016 991
1017 QListViewItem * newItem; 992 QListViewItem * newItem;
1018 if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { 993 if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) {
1019 long size; 994 long size;
1020 if( dit.current()->file().left(4) == "http" ) 995 if( dit.current()->file().left(4) == "http" )
1021 size=0; 996 size=0;
1022 else 997 else
1023 size = QFile( dit.current()->file() ).size(); 998 size = QFile( dit.current()->file() ).size();
1024 // qDebug(dit.current()->name()); 999 // qDebug(dit.current()->name());
1025 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), 1000 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(),
1026 QString::number(size ), storage, dit.current()->file()); 1001 QString::number(size ), storage, dit.current()->file());
1027 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); 1002 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" ));
1028 } 1003 }
1029 } 1004 }
1030 1005
1031} 1006}
1032 1007
1033void PlayListWidget::populateVideoView() { 1008void PlayListWidget::populateVideoView() {
1034 videoView->clear(); 1009 videoView->clear();
1035 StorageInfo storageInfo; 1010 StorageInfo storageInfo;
1036 const QList<FileSystem> &fs = storageInfo.fileSystems(); 1011 const QList<FileSystem> &fs = storageInfo.fileSystems();
1037 1012
1038 if(!videoScan ) scanForVideo(); 1013 if(!videoScan ) scanForVideo();
1039 1014
1040 QListIterator<DocLnk> Vdit( vFiles.children() ); 1015 QListIterator<DocLnk> Vdit( vFiles.children() );
1041 QListIterator<FileSystem> it ( fs ); 1016 QListIterator<FileSystem> it ( fs );
1042 videoView->clear(); 1017 videoView->clear();
1043 QString storage; 1018 QString storage;
1044 for ( ; Vdit.current(); ++Vdit ) { 1019 for ( ; Vdit.current(); ++Vdit ) {
1045 for( ; it.current(); ++it ){ 1020 for( ; it.current(); ++it ){
1046 const QString name = (*it)->name(); 1021 const QString name = (*it)->name();
1047 const QString path = (*it)->path(); 1022 const QString path = (*it)->path();
1048 if( Vdit.current()->file().find(path) != -1 ) storage=name; 1023 if( Vdit.current()->file().find(path) != -1 ) storage=name;
1049 } 1024 }
1050 1025
1051 QListViewItem * newItem; 1026 QListViewItem * newItem;
1052 if ( QFile( Vdit.current()->file()).exists() ) { 1027 if ( QFile( Vdit.current()->file()).exists() ) {
1053 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), 1028 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
1054 QString::number( QFile( Vdit.current()->file() ).size() ), 1029 QString::number( QFile( Vdit.current()->file() ).size() ),
1055 storage, Vdit.current()->file()); 1030 storage, Vdit.current()->file());
1056 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); 1031 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" ));
1057 } 1032 }
1058 } 1033 }
1059} 1034}
1060 1035
1061void PlayListWidget::openFile() { 1036void PlayListWidget::openFile() {
1062 QString filename, name; 1037 QString filename, name;
1063 InputDialog *fileDlg; 1038 InputDialog *fileDlg;
1064 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 1039 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
1065 fileDlg->exec(); 1040 fileDlg->exec();
1066 if( fileDlg->result() == 1 ) { 1041 if( fileDlg->result() == 1 ) {
1067 filename = fileDlg->text(); 1042 filename = fileDlg->text();
1068 // qDebug( "Selected filename is " + filename ); 1043 // qDebug( "Selected filename is " + filename );
1069 DocLnk lnk; 1044 DocLnk lnk;
1070 Config cfg( "OpiePlayer" ); 1045 Config cfg( "OpiePlayer" );
1071 cfg.setGroup("PlayList"); 1046 cfg.setGroup("PlayList");
1072 1047
1073 QString m3uFile; 1048 QString m3uFile;
1074 m3uFile = filename; 1049 m3uFile = filename;
1075 if(filename.left(4) == "http") { 1050 if(filename.left(4) == "http") {
1076 if(filename.find(":",8,TRUE) != -1) { //found a port 1051 if(filename.find(":",8,TRUE) != -1) { //found a port
1077 1052
1078 m3uFile = filename; 1053 m3uFile = filename;
1079 if( m3uFile.right( 1 ).find( '/' ) == -1) { 1054 if( m3uFile.right( 1 ).find( '/' ) == -1) {
1080 m3uFile += "/"; 1055 m3uFile += "/";
1081 } 1056 }
1082 filename = m3uFile; 1057 filename = m3uFile;
1083 } 1058 }
1084 lnk.setName( m3uFile ); //sets name 1059 lnk.setName( m3uFile ); //sets name
1085 lnk.setFile( filename ); //sets file name 1060 lnk.setFile( filename ); //sets file name
1086 lnk.setIcon("opieplayer2/musicfile"); 1061 lnk.setIcon("opieplayer2/musicfile");
1087 d->selectedFiles->addToSelection( lnk ); 1062 d->selectedFiles->addToSelection( lnk );
1088 writeCurrentM3u(); 1063 writeCurrentM3u();
1089 } 1064 }
1090 else if( filename.right( 3) == "m3u" ) { 1065 else if( filename.right( 3) == "m3u" ) {
1091 readm3u( filename ); 1066 readm3u( filename );
1092 1067
1093 } else if( filename.right(3) == "pls" ) { 1068 } else if( filename.right(3) == "pls" ) {
1094 readPls( filename ); 1069 readPls( filename );
1095 } else { 1070 } else {
1096 lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name 1071 lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name
1097 lnk.setFile( filename ); //sets file name 1072 lnk.setFile( filename ); //sets file name
1098 d->selectedFiles->addToSelection( lnk); 1073 d->selectedFiles->addToSelection( lnk);
1099 lnk.removeLinkFile(); 1074 lnk.removeLinkFile();
1100 writeCurrentM3u(); 1075 writeCurrentM3u();
1101 } 1076 }
1102 } 1077 }
1103 1078
1104 if( fileDlg ) { 1079 if( fileDlg ) {
1105 delete fileDlg; 1080 delete fileDlg;
1106 } 1081 }
1107} 1082}
1108 1083
1109 1084
1110/* 1085/*
1111reads m3u and shows files/urls to playlist widget */ 1086reads m3u and shows files/urls to playlist widget */
1112void PlayListWidget::readm3u( const QString &filename ) { 1087void PlayListWidget::readm3u( const QString &filename ) {
1113 // qDebug( "read m3u filename " + filename ); 1088 // qDebug( "read m3u filename " + filename );
1114 1089
1115 Om3u *m3uList; 1090 Om3u *m3uList;
1116 QString s, name; 1091 QString s, name;
1117 m3uList = new Om3u( filename, IO_ReadOnly ); 1092 m3uList = new Om3u( filename, IO_ReadOnly );
1118 m3uList->readM3u(); 1093 m3uList->readM3u();
1119 DocLnk lnk; 1094 DocLnk lnk;
1120 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 1095 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
1121 s = *it; 1096 s = *it;
1122 // qDebug("reading "+ s); 1097 // qDebug("reading "+ s);
1123 if(s.left(4)=="http") { 1098 if(s.left(4)=="http") {
1124 lnk.setName( s ); //sets file name 1099 lnk.setName( s ); //sets file name
1125 lnk.setIcon("opieplayer2/musicfile"); 1100 lnk.setIcon("opieplayer2/musicfile");
1126 1101
1127 // if(s.right(4) != '.' || s.right(5) != '.') 1102 // if(s.right(4) != '.' || s.right(5) != '.')
1128 if(s.right(4) != '.' || s.right(5) != '.' ) 1103 if(s.right(4) != '.' || s.right(5) != '.' )
1129 if( s.right(1) != "/") 1104 if( s.right(1) != "/")
1130 lnk.setFile( s+"/"); //if url with no extension 1105 lnk.setFile( s+"/"); //if url with no extension
1131 else 1106 else
1132 lnk.setFile( s ); //sets file name 1107 lnk.setFile( s ); //sets file name
1133 1108
1134 } else { 1109 } else {
1135 // if( QFileInfo( s ).exists() ) { 1110 // if( QFileInfo( s ).exists() ) {
1136 lnk.setName( fullBaseName ( QFileInfo(s))); 1111 lnk.setName( fullBaseName ( QFileInfo(s)));
1137 // if(s.right(4) == '.') {//if regular file 1112 // if(s.right(4) == '.') {//if regular file
1138 if(s.left(1) != "/") { 1113 if(s.left(1) != "/") {
1139 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); 1114 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s);
1140 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); 1115 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s);
1141 lnk.setIcon("SoundPlayer"); 1116 lnk.setIcon("SoundPlayer");
1142 } else { 1117 } else {
1143 // qDebug("set link2 "+s); 1118 // qDebug("set link2 "+s);
1144 lnk.setFile( s); 1119 lnk.setFile( s);
1145 lnk.setIcon("SoundPlayer"); 1120 lnk.setIcon("SoundPlayer");
1146 } 1121 }
1147 } 1122 }
1148 d->selectedFiles->addToSelection( lnk ); 1123 d->selectedFiles->addToSelection( lnk );
1149 } 1124 }
1150 Config config( "OpiePlayer" ); 1125 Config config( "OpiePlayer" );
1151 config.setGroup( "PlayList" ); 1126 config.setGroup( "PlayList" );
1152 1127
1153 config.writeEntry("CurrentPlaylist",filename); 1128 config.writeEntry("CurrentPlaylist",filename);
1154 config.write(); 1129 config.write();
1155 currentPlayList=filename; 1130 currentPlayList=filename;
1156 1131
1157// m3uList->write(); 1132// m3uList->write();
1158 m3uList->close(); 1133 m3uList->close();
1159 if(m3uList) delete m3uList; 1134 if(m3uList) delete m3uList;
1160 1135
1161 d->selectedFiles->setSelectedItem( s); 1136 d->selectedFiles->setSelectedItem( s);
1162 setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(filename))); 1137 setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(filename)));
1163 1138
1164} 1139}
1165 1140
1166/* 1141/*
1167reads pls and adds files/urls to playlist */ 1142reads pls and adds files/urls to playlist */
1168void PlayListWidget::readPls( const QString &filename ) { 1143void PlayListWidget::readPls( const QString &filename ) {
1169 1144
1170 // qDebug( "pls filename is " + filename ); 1145 // qDebug( "pls filename is " + filename );
1171 Om3u *m3uList; 1146 Om3u *m3uList;
1172 QString s, name; 1147 QString s, name;
1173 m3uList = new Om3u( filename, IO_ReadOnly ); 1148 m3uList = new Om3u( filename, IO_ReadOnly );
1174 m3uList->readPls(); 1149 m3uList->readPls();
1175 1150
1176 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 1151 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
1177 s = *it; 1152 s = *it;
1178 // s.replace( QRegExp( "%20" )," " ); 1153 // s.replace( QRegExp( "%20" )," " );
1179 DocLnk lnk( s ); 1154 DocLnk lnk( s );
1180 QFileInfo f( s ); 1155 QFileInfo f( s );
1181 QString name = fullBaseName ( f); 1156 QString name = fullBaseName ( f);
1182 1157
1183 if( name.left( 4 ) == "http" ) { 1158 if( name.left( 4 ) == "http" ) {
1184 name = s.right( s.length() - 7); 1159 name = s.right( s.length() - 7);
1185 } else { 1160 } else {
1186 name = s; 1161 name = s;
1187 } 1162 }
1188 1163
1189 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); 1164 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
1190 1165
1191 lnk.setName( name ); 1166 lnk.setName( name );
1192 if( s.at( s.length() - 4) == '.') {// if this is probably a file 1167 if( s.at( s.length() - 4) == '.') {// if this is probably a file
1193 lnk.setFile( s ); 1168 lnk.setFile( s );
1194 } else { //if its a url 1169 } else { //if its a url
1195 if( name.right( 1 ).find( '/' ) == -1) { 1170 if( name.right( 1 ).find( '/' ) == -1) {
1196 s += "/"; 1171 s += "/";
1197 } 1172 }
1198 lnk.setFile( s ); 1173 lnk.setFile( s );
1199 } 1174 }
1200 lnk.setType( "audio/x-mpegurl" ); 1175 lnk.setType( "audio/x-mpegurl" );
1201 1176
1202 lnk.writeLink(); 1177 lnk.writeLink();
1203 d->selectedFiles->addToSelection( lnk ); 1178 d->selectedFiles->addToSelection( lnk );
1204 } 1179 }
1205 1180
1206 m3uList->close(); 1181 m3uList->close();
1207 if(m3uList) delete m3uList; 1182 if(m3uList) delete m3uList;
1208} 1183}
1209 1184
1210/* 1185/*
1211 writes current playlist to current m3u file */ 1186 writes current playlist to current m3u file */
1212void PlayListWidget::writeCurrentM3u() { 1187void PlayListWidget::writeCurrentM3u() {
1213 // qDebug("writing to current m3u"); 1188 // qDebug("writing to current m3u");
1214 Config cfg( "OpiePlayer" ); 1189 Config cfg( "OpiePlayer" );
1215 cfg.setGroup("PlayList"); 1190 cfg.setGroup("PlayList");
1216 currentPlayList = cfg.readEntry("CurrentPlaylist",""); 1191 currentPlayList = cfg.readEntry("CurrentPlaylist","");
1217 Om3u *m3uList; 1192 Om3u *m3uList;
1218 m3uList = new Om3u( currentPlayList, IO_ReadWrite | IO_Truncate ); 1193 m3uList = new Om3u( currentPlayList, IO_ReadWrite | IO_Truncate );
1219 1194
1220 if( d->selectedFiles->first()) { 1195 if( d->selectedFiles->first()) {
1221 do { 1196 do {
1222 // qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); 1197 // qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file());
1223 m3uList->add( d->selectedFiles->current()->file() ); 1198 m3uList->add( d->selectedFiles->current()->file() );
1224 } 1199 }
1225 while ( d->selectedFiles->next() ); 1200 while ( d->selectedFiles->next() );
1226 // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); 1201 // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" );
1227 m3uList->write(); 1202 m3uList->write();
1228 m3uList->close(); 1203 m3uList->close();
1229 1204
1230 if(m3uList) delete m3uList; 1205 if(m3uList) delete m3uList;
1231 } 1206 }
1232} 1207}
1233 1208
1234 /* 1209 /*
1235 writes current playlist to m3u file */ 1210 writes current playlist to m3u file */
1236void PlayListWidget::writem3u() { 1211void PlayListWidget::writem3u() {
1237 InputDialog *fileDlg; 1212 InputDialog *fileDlg;
1238 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); 1213 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
1239 fileDlg->exec(); 1214 fileDlg->exec();
1240 QString name, filename, list; 1215 QString name, filename, list;
1241 Om3u *m3uList; 1216 Om3u *m3uList;
1242 1217
1243 if( fileDlg->result() == 1 ) { 1218 if( fileDlg->result() == 1 ) {
1244 name = fileDlg->text(); 1219 name = fileDlg->text();
1245 // qDebug( filename ); 1220 // qDebug( filename );
1246 if( name.find("/",0,true) != -1) {// assume they specify a file path 1221 if( name.find("/",0,true) != -1) {// assume they specify a file path
1247 filename = name; 1222 filename = name;
1248 name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); 1223 name = name.right(name.length()- name.findRev("/",-1,true) - 1 );
1249 } 1224 }
1250 else //otherwise dump it somewhere noticable 1225 else //otherwise dump it somewhere noticable
1251 filename = QPEApplication::documentDir() + "/" + name; 1226 filename = QPEApplication::documentDir() + "/" + name;
1252 1227
1253 if( filename.right( 3 ) != "m3u" ) //needs filename extension 1228 if( filename.right( 3 ) != "m3u" ) //needs filename extension
1254 filename += ".m3u"; 1229 filename += ".m3u";
1255 1230
1256 if( d->selectedFiles->first()) { 1231 if( d->selectedFiles->first()) {
1257 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); 1232 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate);
1258 1233
1259 do { 1234 do {
1260 m3uList->add( d->selectedFiles->current()->file()); 1235 m3uList->add( d->selectedFiles->current()->file());
1261 } 1236 }
1262 while ( d->selectedFiles->next() ); 1237 while ( d->selectedFiles->next() );
1263 // qDebug( list ); 1238 // qDebug( list );
1264 m3uList->write(); 1239 m3uList->write();
1265 m3uList->close(); 1240 m3uList->close();
1266 if(m3uList) delete m3uList; 1241 if(m3uList) delete m3uList;
1267 1242
1268 if(fileDlg) delete fileDlg; 1243 if(fileDlg) delete fileDlg;
1269 1244
1270 DocLnk lnk; 1245 DocLnk lnk;
1271 lnk.setFile( filename); 1246 lnk.setFile( filename);
1272 lnk.setIcon("opieplayer2/playlist2"); 1247 lnk.setIcon("opieplayer2/playlist2");
1273 lnk.setName( name); //sets file name 1248 lnk.setName( name); //sets file name
1274 1249
1275 // qDebug(filename); 1250 // qDebug(filename);
1276 Config config( "OpiePlayer" ); 1251 Config config( "OpiePlayer" );
1277 config.setGroup( "PlayList" ); 1252 config.setGroup( "PlayList" );
1278 1253
1279 config.writeEntry("CurrentPlaylist",filename); 1254 config.writeEntry("CurrentPlaylist",filename);
1280 currentPlayList=filename; 1255 currentPlayList=filename;
1281 1256
1282 if(!lnk.writeLink()) { 1257 if(!lnk.writeLink()) {
1283 // qDebug("Writing doclink did not work"); 1258 // qDebug("Writing doclink did not work");
1284 } 1259 }
1285 1260
1286 setCaption(tr("OpiePlayer: ") + name); 1261 setCaption(tr("OpiePlayer: ") + name);
1287 } 1262 }
1288 } 1263 }
1289} 1264}
1290 1265
1291 1266
1292void PlayListWidget::keyReleaseEvent( QKeyEvent *e) 1267void PlayListWidget::keyReleaseEvent( QKeyEvent *e)
1293{ 1268{
1294 switch ( e->key() ) { 1269 switch ( e->key() ) {
1295////////////////////////////// Zaurus keys 1270////////////////////////////// Zaurus keys
1296 case Key_F9: //activity 1271 case Key_F9: //activity
1297// if(audioUI->isHidden()) 1272// if(audioUI->isHidden())
1298// audioUI->showMaximized(); 1273// audioUI->showMaximized();
1299 break; 1274 break;
1300 case Key_F10: //contacts 1275 case Key_F10: //contacts
1301// if( videoUI->isHidden()) 1276// if( videoUI->isHidden())
1302// videoUI->showMaximized(); 1277// videoUI->showMaximized();
1303 break; 1278 break;
1304 case Key_F11: //menu 1279 case Key_F11: //menu
1305 break; 1280 break;
1306 case Key_F12: //home 1281 case Key_F12: //home
1307// doBlank(); 1282// doBlank();
1308 break; 1283 break;
1309 case Key_F13: //mail 1284 case Key_F13: //mail
1310// doUnblank(); 1285// doUnblank();
1311 break; 1286 break;
1312 case Key_Q: //add to playlist 1287 case Key_Q: //add to playlist
1313 addSelected(); 1288 addSelected();
1314 break; 1289 break;
1315 case Key_R: //remove from playlist 1290 case Key_R: //remove from playlist
1316 removeSelected(); 1291 removeSelected();
1317 break; 1292 break;
1318// case Key_P: //play 1293// case Key_P: //play
1319// qDebug("Play"); 1294// qDebug("Play");
1320// playSelected(); 1295// playSelected();
1321// break; 1296// break;
1322 case Key_Space: 1297 case Key_Space:
1323// playSelected(); puh 1298// playSelected(); puh
1324 break; 1299 break;
1325 case Key_1: 1300 case Key_1:
1326 tabWidget->setCurrentPage(0); 1301 tabWidget->setCurrentPage(0);
1327 break; 1302 break;
1328 case Key_2: 1303 case Key_2:
1329 tabWidget->setCurrentPage(1); 1304 tabWidget->setCurrentPage(1);
1330 break; 1305 break;
1331 case Key_3: 1306 case Key_3:
1332 tabWidget->setCurrentPage(2); 1307 tabWidget->setCurrentPage(2);
1333 break; 1308 break;
1334 case Key_4: 1309 case Key_4:
1335 tabWidget->setCurrentPage(3); 1310 tabWidget->setCurrentPage(3);
1336 break; 1311 break;
1337 case Key_Down: 1312 case Key_Down:
1338 if ( !d->selectedFiles->next() ) 1313 if ( !d->selectedFiles->next() )
1339 d->selectedFiles->first(); 1314 d->selectedFiles->first();
1340 1315
1341 break; 1316 break;
1342 case Key_Up: 1317 case Key_Up:
1343 if ( !d->selectedFiles->prev() ) 1318 if ( !d->selectedFiles->prev() )
1344 // d->selectedFiles->last(); 1319 // d->selectedFiles->last();
1345 1320
1346 break; 1321 break;
1347 1322
1348 } 1323 }
1349} 1324}
1350 1325
1351void PlayListWidget::keyPressEvent( QKeyEvent *) 1326void PlayListWidget::keyPressEvent( QKeyEvent *)
1352{ 1327{
1353// qDebug("Key press"); 1328// qDebug("Key press");
1354// switch ( e->key() ) { 1329// switch ( e->key() ) {
1355// ////////////////////////////// Zaurus keys 1330// ////////////////////////////// Zaurus keys
1356// case Key_A: //add to playlist 1331// case Key_A: //add to playlist
1357// qDebug("Add"); 1332// qDebug("Add");
1358// addSelected(); 1333// addSelected();
1359// break; 1334// break;
1360// case Key_R: //remove from playlist 1335// case Key_R: //remove from playlist
1361// removeSelected(); 1336// removeSelected();
1362// break; 1337// break;
1363// case Key_P: //play 1338// case Key_P: //play
1364// qDebug("Play"); 1339// qDebug("Play");
1365// playSelected(); 1340// playSelected();
1366// break; 1341// break;
1367// case Key_Space: 1342// case Key_Space:
1368// qDebug("Play"); 1343// qDebug("Play");
1369// playSelected(); 1344// playSelected();
1370// break; 1345// break;
1371// } 1346// }
1372} 1347}
1373 1348
1374void PlayListWidget::doBlank() { 1349void PlayListWidget::doBlank() {
1375 // qDebug("do blanking"); 1350 // qDebug("do blanking");
1376#ifdef QT_QWS_DEVFS 1351#ifdef QT_QWS_DEVFS
1377 fd=open("/dev/fb/0",O_RDWR); 1352 fd=open("/dev/fb/0",O_RDWR);
1378#else 1353#else
1379 fd=open("/dev/fb0",O_RDWR); 1354 fd=open("/dev/fb0",O_RDWR);
1380#endif 1355#endif
1381 if (fd != -1) { 1356 if (fd != -1) {
1382 ioctl(fd,FBIOBLANK,1); 1357 ioctl(fd,FBIOBLANK,1);
1383 // close(fd); 1358 // close(fd);
1384 } 1359 }
1385} 1360}
1386 1361
1387void PlayListWidget::doUnblank() { 1362void PlayListWidget::doUnblank() {
1388 // this crashes opieplayer with a segfault 1363 // this crashes opieplayer with a segfault
1389 // int fd; 1364 // int fd;
1390 // fd=open("/dev/fb0",O_RDWR); 1365 // fd=open("/dev/fb0",O_RDWR);
1391 // qDebug("do unblanking"); 1366 // qDebug("do unblanking");
1392 if (fd != -1) { 1367 if (fd != -1) {
1393 ioctl(fd,FBIOBLANK,0); 1368 ioctl(fd,FBIOBLANK,0);
1394 close(fd); 1369 close(fd);
1395 } 1370 }
1396 QCopEnvelope h("QPE/System", "setBacklight(int)"); 1371 QCopEnvelope h("QPE/System", "setBacklight(int)");
1397 h <<-3;// v[1]; // -3 Force on 1372 h <<-3;// v[1]; // -3 Force on
1398} 1373}
1399 1374
1400void PlayListWidget::populateSkinsMenu() { 1375void PlayListWidget::populateSkinsMenu() {
1401 int item = 0; 1376 int item = 0;
1402 defaultSkinIndex = 0; 1377 defaultSkinIndex = 0;
1403 QString skinName; 1378 QString skinName;
1404 Config cfg( "OpiePlayer" ); 1379 Config cfg( "OpiePlayer" );
1405 cfg.setGroup("Options" ); 1380 cfg.setGroup("Options" );
1406 QString skin = cfg.readEntry( "Skin", "default" ); 1381 QString skin = cfg.readEntry( "Skin", "default" );
1407 1382
1408 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); 1383 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" );
1409 skinsDir.setFilter( QDir::Dirs ); 1384 skinsDir.setFilter( QDir::Dirs );
1410 skinsDir.setSorting(QDir::Name ); 1385 skinsDir.setSorting(QDir::Name );
1411 const QFileInfoList *skinslist = skinsDir.entryInfoList(); 1386 const QFileInfoList *skinslist = skinsDir.entryInfoList();
1412 QFileInfoListIterator it( *skinslist ); 1387 QFileInfoListIterator it( *skinslist );
1413 QFileInfo *fi; 1388 QFileInfo *fi;
1414 while ( ( fi = it.current() ) ) { 1389 while ( ( fi = it.current() ) ) {
1415 skinName = fi->fileName(); 1390 skinName = fi->fileName();
1416 // qDebug( fi->fileName() ); 1391 // qDebug( fi->fileName() );
1417 if( skinName != "." && skinName != ".." && skinName !="CVS" ) { 1392 if( skinName != "." && skinName != ".." && skinName !="CVS" ) {
1418 item = skinsMenu->insertItem( fi->fileName() ) ; 1393 item = skinsMenu->insertItem( fi->fileName() ) ;
1419 } 1394 }
1420 if( skinName == "default" ) { 1395 if( skinName == "default" ) {
1421 defaultSkinIndex = item; 1396 defaultSkinIndex = item;
1422 } 1397 }
1423 if( skinName == skin ) { 1398 if( skinName == skin ) {
1424 skinsMenu->setItemChecked( item, TRUE ); 1399 skinsMenu->setItemChecked( item, TRUE );
1425 } 1400 }
1426 ++it; 1401 ++it;
1427 } 1402 }
1428} 1403}
1429 1404
1430void PlayListWidget::skinsMenuActivated( int item ) { 1405void PlayListWidget::skinsMenuActivated( int item ) {
1431 for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { 1406 for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) {
1432 skinsMenu->setItemChecked( i, FALSE ); 1407 skinsMenu->setItemChecked( i, FALSE );
1433 } 1408 }
1434 skinsMenu->setItemChecked( item, TRUE ); 1409 skinsMenu->setItemChecked( item, TRUE );
1435 1410
1436 Config cfg( "OpiePlayer" ); 1411 Config cfg( "OpiePlayer" );
1437 cfg.setGroup("Options"); 1412 cfg.setGroup("Options");
1438 cfg.writeEntry("Skin", skinsMenu->text( item ) ); 1413 cfg.writeEntry("Skin", skinsMenu->text( item ) );
1439} 1414}
1440 1415
1441void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { 1416void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) {
1442 // qDebug("qcop message "+msg ); 1417 // qDebug("qcop message "+msg );
1443 QDataStream stream ( data, IO_ReadOnly ); 1418 QDataStream stream ( data, IO_ReadOnly );
1444 if ( msg == "play()" ) { //plays current selection 1419 if ( msg == "play()" ) { //plays current selection
1445 btnPlay( true); 1420 btnPlay( true);
1446 } else if ( msg == "stop()" ) { 1421 } else if ( msg == "stop()" ) {
1447 mediaPlayerState->setPlaying( false); 1422 mediaPlayerState->setPlaying( false);
1448 } else if ( msg == "togglePause()" ) { 1423 } else if ( msg == "togglePause()" ) {
1449 mediaPlayerState->togglePaused(); 1424 mediaPlayerState->togglePaused();
1450 } else if ( msg == "next()" ) { //select next in lis 1425 } else if ( msg == "next()" ) { //select next in lis
1451 mediaPlayerState->setNext(); 1426 mediaPlayerState->setNext();
1452 } else if ( msg == "prev()" ) { //select previous in list 1427 } else if ( msg == "prev()" ) { //select previous in list
1453 mediaPlayerState->setPrev(); 1428 mediaPlayerState->setPrev();
1454 } else if ( msg == "toggleLooping()" ) { //loop or not loop 1429 } else if ( msg == "toggleLooping()" ) { //loop or not loop
1455 mediaPlayerState->toggleLooping(); 1430 mediaPlayerState->toggleLooping();
1456 } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled 1431 } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled
1457 mediaPlayerState->toggleShuffled(); 1432 mediaPlayerState->toggleShuffled();
1458 } else if ( msg == "volUp()" ) { //volume more 1433 } else if ( msg == "volUp()" ) { //volume more
1459 // emit moreClicked(); 1434 // emit moreClicked();
1460 // emit moreReleased(); 1435 // emit moreReleased();
1461 } else if ( msg == "volDown()" ) { //volume less 1436 } else if ( msg == "volDown()" ) { //volume less
1462 // emit lessClicked(); 1437 // emit lessClicked();
1463 // emit lessReleased(); 1438 // emit lessReleased();
1464 } else if ( msg == "play(QString)" ) { //play this now 1439 } else if ( msg == "play(QString)" ) { //play this now
1465 QString file; 1440 QString file;
1466 stream >> file; 1441 stream >> file;
1467 setDocumentEx( (const QString &) file); 1442 setDocumentEx( (const QString &) file);
1468 } else if ( msg == "add(QString)" ) { //add to playlist 1443 } else if ( msg == "add(QString)" ) { //add to playlist
1469 QString file; 1444 QString file;
1470 stream >> file; 1445 stream >> file;
1471 QFileInfo fileInfo(file); 1446 QFileInfo fileInfo(file);
1472 DocLnk lnk; 1447 DocLnk lnk;
1473 lnk.setName( fileInfo.baseName() ); //sets name 1448 lnk.setName( fileInfo.baseName() ); //sets name
1474 lnk.setFile( file ); //sets file name 1449 lnk.setFile( file ); //sets file name
1475 addToSelection( lnk ); 1450 addToSelection( lnk );
1476 } else if ( msg == "rem(QString)" ) { //remove from playlist 1451 } else if ( msg == "rem(QString)" ) { //remove from playlist
1477 QString file; 1452 QString file;
1478 stream >> file; 1453 stream >> file;
1479 } else if ( msg == "setDocument(QString)" ) { //loop or not loop 1454 } else if ( msg == "setDocument(QString)" ) { //loop or not loop
1480 QCopEnvelope h("QPE/Application/opieplayer", "raise()"); 1455 QCopEnvelope h("QPE/Application/opieplayer", "raise()");
1481 } 1456 }
1482} 1457}
diff --git a/core/multimedia/opieplayer/videowidget.cpp b/core/multimedia/opieplayer/videowidget.cpp
index 5273ad3..d002c42 100644
--- a/core/multimedia/opieplayer/videowidget.cpp
+++ b/core/multimedia/opieplayer/videowidget.cpp
@@ -1,677 +1,673 @@
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/resource.h> 20#include <qpe/resource.h>
21#include <qpe/mediaplayerplugininterface.h> 21#include <qpe/mediaplayerplugininterface.h>
22#include <qpe/config.h> 22#include <qpe/config.h>
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24 24
25#include <qdir.h> 25#include <qdir.h>
26#include <qwidget.h>
27#include <qpainter.h>
28#include <qpixmap.h>
29#include <qslider.h> 26#include <qslider.h>
30#include <qdrawutil.h>
31#include "videowidget.h" 27#include "videowidget.h"
32#include "mediaplayerstate.h" 28#include "mediaplayerstate.h"
33 29
34 30
35#ifdef Q_WS_QWS 31#ifdef Q_WS_QWS
36# define USE_DIRECT_PAINTER 32# define USE_DIRECT_PAINTER
37# include <qdirectpainter_qws.h> 33# include <qdirectpainter_qws.h>
38# include <qgfxraster_qws.h> 34# include <qgfxraster_qws.h>
39#endif 35#endif
40 36
41 37
42extern MediaPlayerState *mediaPlayerState; 38extern MediaPlayerState *mediaPlayerState;
43 39
44 40
45static const int xo = 2; // movable x offset 41static const int xo = 2; // movable x offset
46static const int yo = 0; // movable y offset 42static const int yo = 0; // movable y offset
47 43
48 44
49struct MediaButton { 45struct MediaButton {
50// int xPos, yPos; 46// int xPos, yPos;
51 bool isToggle, isHeld, isDown; 47 bool isToggle, isHeld, isDown;
52// int controlType; 48// int controlType;
53}; 49};
54 50
55 51
56// Layout information for the videoButtons (and if it is a toggle button or not) 52// Layout information for the videoButtons (and if it is a toggle button or not)
57MediaButton videoButtons[] = { 53MediaButton videoButtons[] = {
58 { FALSE, FALSE, FALSE }, // stop 54 { FALSE, FALSE, FALSE }, // stop
59 { FALSE, FALSE, FALSE }, // play 55 { FALSE, FALSE, FALSE }, // play
60 { FALSE, FALSE, FALSE }, // previous 56 { FALSE, FALSE, FALSE }, // previous
61 { FALSE, FALSE, FALSE }, // next 57 { FALSE, FALSE, FALSE }, // next
62 { FALSE, FALSE, FALSE }, // volUp 58 { FALSE, FALSE, FALSE }, // volUp
63 { FALSE, FALSE, FALSE }, // volDown 59 { FALSE, FALSE, FALSE }, // volDown
64 { TRUE, FALSE, FALSE } // fullscreen 60 { TRUE, FALSE, FALSE } // fullscreen
65}; 61};
66 62
67//static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); 63//static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton));
68 64
69const char *skinV_mask_file_names[7] = { 65const char *skinV_mask_file_names[7] = {
70 "stop","play","back","fwd","up","down","full" 66 "stop","play","back","fwd","up","down","full"
71}; 67};
72 68
73static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton)); 69static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton));
74 70
75VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : 71VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) :
76 QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) 72 QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 )
77{ 73{
78 setCaption( tr("OpiePlayer") ); 74 setCaption( tr("OpiePlayer") );
79 Config cfg("OpiePlayer"); 75 Config cfg("OpiePlayer");
80 76
81 cfg.setGroup("Options"); 77 cfg.setGroup("Options");
82 skin = cfg.readEntry("Skin","default"); 78 skin = cfg.readEntry("Skin","default");
83 79
84 QString skinPath; 80 QString skinPath;
85 skinPath = "opieplayer2/skins/" + skin; 81 skinPath = "opieplayer2/skins/" + skin;
86 if(!QDir(QString(getenv("OPIEDIR")) +"/pics/"+skinPath).exists()) 82 if(!QDir(QString(getenv("OPIEDIR")) +"/pics/"+skinPath).exists())
87 skinPath = "opieplayer2/skins/default"; 83 skinPath = "opieplayer2/skins/default";
88 84
89 // qDebug("skin path " + skinPath); 85 // qDebug("skin path " + skinPath);
90 86
91// QString skinPath = "opieplayer2/skins/" + skin; 87// QString skinPath = "opieplayer2/skins/" + skin;
92 88
93 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 89 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
94 imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); 90 imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) );
95 imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); 91 imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) );
96 92
97 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); 93 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 );
98 imgButtonMask->fill( 0 ); 94 imgButtonMask->fill( 0 );
99 95
100 for ( int i = 0; i < 7; i++ ) { 96 for ( int i = 0; i < 7; i++ ) {
101 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + 97 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath +
102 "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); 98 "/skinV_mask_" + skinV_mask_file_names[i] + ".png" );
103 // qDebug("loading "+filename); 99 // qDebug("loading "+filename);
104 masks[i] = new QBitmap( filename ); 100 masks[i] = new QBitmap( filename );
105 101
106 if ( !masks[i]->isNull() ) { 102 if ( !masks[i]->isNull() ) {
107 QImage imgMask = masks[i]->convertToImage(); 103 QImage imgMask = masks[i]->convertToImage();
108 uchar **dest = imgButtonMask->jumpTable(); 104 uchar **dest = imgButtonMask->jumpTable();
109 for ( int y = 0; y < imgUp->height(); y++ ) { 105 for ( int y = 0; y < imgUp->height(); y++ ) {
110 uchar *line = dest[y]; 106 uchar *line = dest[y];
111 for ( int x = 0; x < imgUp->width(); x++ ) { 107 for ( int x = 0; x < imgUp->width(); x++ ) {
112 if ( !qRed( imgMask.pixel( x, y ) ) ) 108 if ( !qRed( imgMask.pixel( x, y ) ) )
113 line[x] = i + 1; 109 line[x] = i + 1;
114 } 110 }
115 } 111 }
116 } 112 }
117 } 113 }
118 // qDebug("finished loading first pics"); 114 // qDebug("finished loading first pics");
119 for ( int i = 0; i < 7; i++ ) { 115 for ( int i = 0; i < 7; i++ ) {
120 buttonPixUp[i] = NULL; 116 buttonPixUp[i] = NULL;
121 buttonPixDown[i] = NULL; 117 buttonPixDown[i] = NULL;
122 } 118 }
123 119
124 120
125 QWidget *d = QApplication::desktop(); 121 QWidget *d = QApplication::desktop();
126 int width = d->width(); 122 int width = d->width();
127 int height = d->height(); 123 int height = d->height();
128 124
129 if( (width != pixBg->width() ) || (height != pixBg->height() ) ) { 125 if( (width != pixBg->width() ) || (height != pixBg->height() ) ) {
130 // qDebug("<<<<<<<< scale image >>>>>>>>>>>>"); 126 // qDebug("<<<<<<<< scale image >>>>>>>>>>>>");
131 QImage img; 127 QImage img;
132 img = pixBg->convertToImage(); 128 img = pixBg->convertToImage();
133 pixBg->convertFromImage( img.smoothScale( width, height)); 129 pixBg->convertFromImage( img.smoothScale( width, height));
134 } 130 }
135 setBackgroundPixmap( *pixBg ); 131 setBackgroundPixmap( *pixBg );
136 132
137 currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); 133 currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 );
138 134
139 slider = new QSlider( Qt::Horizontal, this ); 135 slider = new QSlider( Qt::Horizontal, this );
140 slider->setMinValue( 0 ); 136 slider->setMinValue( 0 );
141 slider->setMaxValue( 1 ); 137 slider->setMaxValue( 1 );
142 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); 138 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
143 slider->setFocusPolicy( QWidget::NoFocus ); 139 slider->setFocusPolicy( QWidget::NoFocus );
144// slider->setGeometry( QRect( 7, 250, 220, 20 ) ); 140// slider->setGeometry( QRect( 7, 250, 220, 20 ) );
145 141
146 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 142 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
147 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 143 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
148 144
149 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 145 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
150 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 146 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
151 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 147 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
152 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 148 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
153// connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); 149// connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
154 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 150 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
155 151
156 // Intialise state 152 // Intialise state
157 setLength( mediaPlayerState->length() ); 153 setLength( mediaPlayerState->length() );
158 setPosition( mediaPlayerState->position() ); 154 setPosition( mediaPlayerState->position() );
159 setFullscreen( mediaPlayerState->fullscreen() ); 155 setFullscreen( mediaPlayerState->fullscreen() );
160// setPaused( mediaPlayerState->paused() ); 156// setPaused( mediaPlayerState->paused() );
161 setPlaying( mediaPlayerState->playing() ); 157 setPlaying( mediaPlayerState->playing() );
162} 158}
163 159
164 160
165VideoWidget::~VideoWidget() { 161VideoWidget::~VideoWidget() {
166 162
167 for ( int i = 0; i < 7; i++ ) 163 for ( int i = 0; i < 7; i++ )
168 { 164 {
169 delete buttonPixUp[i]; 165 delete buttonPixUp[i];
170 delete buttonPixDown[i]; 166 delete buttonPixDown[i];
171 } 167 }
172 168
173 delete pixBg; 169 delete pixBg;
174 delete imgUp; 170 delete imgUp;
175 delete imgDn; 171 delete imgDn;
176 delete imgButtonMask; 172 delete imgButtonMask;
177 for ( int i = 0; i < 7; i++ ) 173 for ( int i = 0; i < 7; i++ )
178 { 174 {
179 delete masks[i]; 175 delete masks[i];
180 } 176 }
181 177
182// for ( int i = 0; i < 3; i++ ) 178// for ( int i = 0; i < 3; i++ )
183// delete pixmaps[i]; 179// delete pixmaps[i];
184// delete currentFrame; 180// delete currentFrame;
185} 181}
186 182
187 183
188static bool videoSliderBeingMoved = FALSE; 184static bool videoSliderBeingMoved = FALSE;
189 185
190QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 186QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
191 QPixmap pix( img.width(), img.height() ); 187 QPixmap pix( img.width(), img.height() );
192 QPainter p( &pix ); 188 QPainter p( &pix );
193 p.drawTiledPixmap( pix.rect(), bg, offset ); 189 p.drawTiledPixmap( pix.rect(), bg, offset );
194 p.drawImage( 0, 0, img ); 190 p.drawImage( 0, 0, img );
195 return new QPixmap( pix ); 191 return new QPixmap( pix );
196} 192}
197 193
198QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { 194QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) {
199 QPixmap *pixmap = new QPixmap( pix ); 195 QPixmap *pixmap = new QPixmap( pix );
200 pixmap->setMask( mask ); 196 pixmap->setMask( mask );
201 return pixmap; 197 return pixmap;
202} 198}
203 199
204void VideoWidget::resizeEvent( QResizeEvent * ) { 200void VideoWidget::resizeEvent( QResizeEvent * ) {
205 int h = height(); 201 int h = height();
206 int w = width(); 202 int w = width();
207 //int Vh = 160; 203 //int Vh = 160;
208 //int Vw = 220; 204 //int Vw = 220;
209 205
210 slider->setFixedWidth( w - 20 ); 206 slider->setFixedWidth( w - 20 );
211 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); 207 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
212 slider->setBackgroundOrigin( QWidget::ParentOrigin ); 208 slider->setBackgroundOrigin( QWidget::ParentOrigin );
213 slider->setFocusPolicy( QWidget::NoFocus ); 209 slider->setFocusPolicy( QWidget::NoFocus );
214 slider->setBackgroundPixmap( *pixBg ); 210 slider->setBackgroundPixmap( *pixBg );
215 211
216 xoff = 0;// ( imgUp->width() ) / 2; 212 xoff = 0;// ( imgUp->width() ) / 2;
217 if(w>h) 213 if(w>h)
218 yoff = 0; 214 yoff = 0;
219 else 215 else
220 yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10; 216 yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10;
221 QPoint p( xoff, yoff ); 217 QPoint p( xoff, yoff );
222 218
223 QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); 219 QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p );
224 QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); 220 QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p );
225 221
226 for ( int i = 0; i < 7; i++ ) 222 for ( int i = 0; i < 7; i++ )
227 { 223 {
228 if ( !masks[i]->isNull() ) 224 if ( !masks[i]->isNull() )
229 { 225 {
230 delete buttonPixUp[i]; 226 delete buttonPixUp[i];
231 delete buttonPixDown[i]; 227 delete buttonPixDown[i];
232 buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); 228 buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] );
233 buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); 229 buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] );
234 } 230 }
235 } 231 }
236 232
237 delete pixUp; 233 delete pixUp;
238 delete pixDn; 234 delete pixDn;
239} 235}
240 236
241 237
242void VideoWidget::sliderPressed() { 238void VideoWidget::sliderPressed() {
243 videoSliderBeingMoved = TRUE; 239 videoSliderBeingMoved = TRUE;
244} 240}
245 241
246 242
247void VideoWidget::sliderReleased() { 243void VideoWidget::sliderReleased() {
248 videoSliderBeingMoved = FALSE; 244 videoSliderBeingMoved = FALSE;
249 if ( slider->width() == 0 ) 245 if ( slider->width() == 0 )
250 return; 246 return;
251 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); 247 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width());
252 mediaPlayerState->setPosition( val ); 248 mediaPlayerState->setPosition( val );
253} 249}
254 250
255 251
256void VideoWidget::setPosition( long i ) { 252void VideoWidget::setPosition( long i ) {
257 updateSlider( i, mediaPlayerState->length() ); 253 updateSlider( i, mediaPlayerState->length() );
258} 254}
259 255
260 256
261void VideoWidget::setLength( long max ) { 257void VideoWidget::setLength( long max ) {
262 updateSlider( mediaPlayerState->position(), max ); 258 updateSlider( mediaPlayerState->position(), max );
263} 259}
264 260
265 261
266void VideoWidget::setView( char view ) { 262void VideoWidget::setView( char view ) {
267 if ( view == 'v' ) 263 if ( view == 'v' )
268 { 264 {
269 makeVisible(); 265 makeVisible();
270 } 266 }
271 else 267 else
272 { 268 {
273 // Effectively blank the view next time we show it so it looks nicer 269 // Effectively blank the view next time we show it so it looks nicer
274 scaledWidth = 0; 270 scaledWidth = 0;
275 scaledHeight = 0; 271 scaledHeight = 0;
276 hide(); 272 hide();
277 } 273 }
278} 274}
279 275
280 276
281void VideoWidget::updateSlider( long i, long max ) { 277void VideoWidget::updateSlider( long i, long max ) {
282 // Will flicker too much if we don't do this 278 // Will flicker too much if we don't do this
283 if ( max == 0 ) 279 if ( max == 0 )
284 return; 280 return;
285 int width = slider->width(); 281 int width = slider->width();
286 int val = int((double)i * width / max); 282 int val = int((double)i * width / max);
287 if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) 283 if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved )
288 { 284 {
289 if ( slider->value() != val ) 285 if ( slider->value() != val )
290 slider->setValue( val ); 286 slider->setValue( val );
291 if ( slider->maxValue() != width ) 287 if ( slider->maxValue() != width )
292 slider->setMaxValue( width ); 288 slider->setMaxValue( width );
293 } 289 }
294} 290}
295 291
296 292
297void VideoWidget::setToggleButton( int i, bool down ) { 293void VideoWidget::setToggleButton( int i, bool down ) {
298 if ( down != videoButtons[i].isDown ) 294 if ( down != videoButtons[i].isDown )
299 toggleButton( i ); 295 toggleButton( i );
300} 296}
301 297
302 298
303void VideoWidget::toggleButton( int i ) { 299void VideoWidget::toggleButton( int i ) {
304 videoButtons[i].isDown = !videoButtons[i].isDown; 300 videoButtons[i].isDown = !videoButtons[i].isDown;
305 QPainter p(this); 301 QPainter p(this);
306 paintButton ( &p, i ); 302 paintButton ( &p, i );
307} 303}
308 304
309 305
310void VideoWidget::paintButton( QPainter *p, int i ) { 306void VideoWidget::paintButton( QPainter *p, int i ) {
311 if ( videoButtons[i].isDown ) 307 if ( videoButtons[i].isDown )
312 { 308 {
313 p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); 309 p->drawPixmap( xoff, yoff, *buttonPixDown[i] );
314 } 310 }
315 else 311 else
316 { 312 {
317 p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); 313 p->drawPixmap( xoff, yoff, *buttonPixUp[i] );
318 } 314 }
319} 315}
320 316
321 317
322void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { 318void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
323 for ( int i = 0; i < numVButtons; i++ ) { 319 for ( int i = 0; i < numVButtons; i++ ) {
324 if ( event->state() == QMouseEvent::LeftButton ) { 320 if ( event->state() == QMouseEvent::LeftButton ) {
325 // The test to see if the mouse click is inside the button or not 321 // The test to see if the mouse click is inside the button or not
326 int x = event->pos().x() - xoff; 322 int x = event->pos().x() - xoff;
327 int y = event->pos().y() - yoff; 323 int y = event->pos().y() - yoff;
328 324
329 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() 325 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width()
330 && y < imgButtonMask->height() 326 && y < imgButtonMask->height()
331 && imgButtonMask->pixelIndex( x, y ) == i + 1 ); 327 && imgButtonMask->pixelIndex( x, y ) == i + 1 );
332 328
333 if ( isOnButton && !videoButtons[i].isHeld ) { 329 if ( isOnButton && !videoButtons[i].isHeld ) {
334 videoButtons[i].isHeld = TRUE; 330 videoButtons[i].isHeld = TRUE;
335 toggleButton(i); 331 toggleButton(i);
336 332
337 switch (i) { 333 switch (i) {
338 case VideoVolUp: 334 case VideoVolUp:
339 emit moreClicked(); 335 emit moreClicked();
340 return; 336 return;
341 case VideoVolDown: 337 case VideoVolDown:
342 emit lessClicked(); 338 emit lessClicked();
343 return; 339 return;
344 } 340 }
345 } else if ( !isOnButton && videoButtons[i].isHeld ) { 341 } else if ( !isOnButton && videoButtons[i].isHeld ) {
346 videoButtons[i].isHeld = FALSE; 342 videoButtons[i].isHeld = FALSE;
347 toggleButton(i); 343 toggleButton(i);
348 } 344 }
349 } else { 345 } else {
350 346
351 if ( videoButtons[i].isHeld ) { 347 if ( videoButtons[i].isHeld ) {
352 videoButtons[i].isHeld = FALSE; 348 videoButtons[i].isHeld = FALSE;
353 if ( !videoButtons[i].isToggle ) { 349 if ( !videoButtons[i].isToggle ) {
354 setToggleButton( i, FALSE ); 350 setToggleButton( i, FALSE );
355 } 351 }
356 352
357 switch(i) { 353 switch(i) {
358 354
359 case VideoPlay: { 355 case VideoPlay: {
360 // qDebug("play"); 356 // qDebug("play");
361 if( !mediaPlayerState->playing()) { 357 if( !mediaPlayerState->playing()) {
362 mediaPlayerState->setPlaying( true); 358 mediaPlayerState->setPlaying( true);
363 setToggleButton( i-1, false ); 359 setToggleButton( i-1, false );
364 setToggleButton( i, false ); 360 setToggleButton( i, false );
365 return; 361 return;
366 } 362 }
367 if( mediaPlayerState->isPaused ) { 363 if( mediaPlayerState->isPaused ) {
368 // qDebug("isPaused"); 364 // qDebug("isPaused");
369 setToggleButton( i, FALSE ); 365 setToggleButton( i, FALSE );
370 mediaPlayerState->setPaused( FALSE ); 366 mediaPlayerState->setPaused( FALSE );
371 return; 367 return;
372 } else if( !mediaPlayerState->isPaused ) { 368 } else if( !mediaPlayerState->isPaused ) {
373 // qDebug("is not paused"); 369 // qDebug("is not paused");
374 setToggleButton( i, TRUE ); 370 setToggleButton( i, TRUE );
375 mediaPlayerState->setPaused( TRUE ); 371 mediaPlayerState->setPaused( TRUE );
376 return; 372 return;
377 } else { 373 } else {
378 return; 374 return;
379 } 375 }
380 } 376 }
381 377
382 case VideoStop: mediaPlayerState->setPlaying( FALSE ); setToggleButton( i+1, true); setToggleButton( i, true ); return; 378 case VideoStop: mediaPlayerState->setPlaying( FALSE ); setToggleButton( i+1, true); setToggleButton( i, true ); return;
383 case VideoNext: mediaPlayerState->setNext(); return; 379 case VideoNext: mediaPlayerState->setNext(); return;
384 case VideoPrevious: mediaPlayerState->setPrev(); return; 380 case VideoPrevious: mediaPlayerState->setPrev(); return;
385 case VideoVolUp: emit moreReleased(); return; 381 case VideoVolUp: emit moreReleased(); return;
386 case VideoVolDown: emit lessReleased(); return; 382 case VideoVolDown: emit lessReleased(); return;
387 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; 383 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return;
388 } 384 }
389 } 385 }
390 } 386 }
391 } 387 }
392} 388}
393 389
394 390
395void VideoWidget::mousePressEvent( QMouseEvent *event ) { 391void VideoWidget::mousePressEvent( QMouseEvent *event ) {
396 mouseMoveEvent( event ); 392 mouseMoveEvent( event );
397} 393}
398 394
399 395
400void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 396void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
401 if ( mediaPlayerState->fullscreen() ) 397 if ( mediaPlayerState->fullscreen() )
402 { 398 {
403 mediaPlayerState->setFullscreen( FALSE ); 399 mediaPlayerState->setFullscreen( FALSE );
404 makeVisible(); 400 makeVisible();
405 } 401 }
406 mouseMoveEvent( event ); 402 mouseMoveEvent( event );
407// } 403// }
408} 404}
409 405
410 406
411void VideoWidget::makeVisible() { 407void VideoWidget::makeVisible() {
412 if ( mediaPlayerState->fullscreen() ) 408 if ( mediaPlayerState->fullscreen() )
413 { 409 {
414 setBackgroundMode( QWidget::NoBackground ); 410 setBackgroundMode( QWidget::NoBackground );
415 showFullScreen(); 411 showFullScreen();
416 resize( qApp->desktop()->size() ); 412 resize( qApp->desktop()->size() );
417 slider->hide(); 413 slider->hide();
418 } 414 }
419 else 415 else
420 { 416 {
421 setBackgroundPixmap( *pixBg ); 417 setBackgroundPixmap( *pixBg );
422 showNormal(); 418 showNormal();
423 QPEApplication::showWidget( this ); 419 QPEApplication::showWidget( this );
424 slider->show(); 420 slider->show();
425 } 421 }
426} 422}
427 423
428 424
429void VideoWidget::paintEvent( QPaintEvent * pe) { 425void VideoWidget::paintEvent( QPaintEvent * pe) {
430 QPainter p( this ); 426 QPainter p( this );
431 427
432 if ( mediaPlayerState->fullscreen() ) { 428 if ( mediaPlayerState->fullscreen() ) {
433 // Clear the background 429 // Clear the background
434 p.setBrush( QBrush( Qt::black ) ); 430 p.setBrush( QBrush( Qt::black ) );
435 p.drawRect( rect() ); 431 p.drawRect( rect() );
436 } else { 432 } else {
437 if ( !pe->erased() ) { 433 if ( !pe->erased() ) {
438 // Combine with background and double buffer 434 // Combine with background and double buffer
439 QPixmap pix( pe->rect().size() ); 435 QPixmap pix( pe->rect().size() );
440 QPainter p( &pix ); 436 QPainter p( &pix );
441 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 437 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
442 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); 438 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() );
443 for ( int i = 0; i < numVButtons; i++ ) { 439 for ( int i = 0; i < numVButtons; i++ ) {
444 paintButton( &p, i ); 440 paintButton( &p, i );
445 } 441 }
446 QPainter p2( this ); 442 QPainter p2( this );
447 p2.drawPixmap( pe->rect().topLeft(), pix ); 443 p2.drawPixmap( pe->rect().topLeft(), pix );
448 } else { 444 } else {
449 QPainter p( this ); 445 QPainter p( this );
450 for ( int i = 0; i < numVButtons; i++ ) 446 for ( int i = 0; i < numVButtons; i++ )
451 paintButton( &p, i ); 447 paintButton( &p, i );
452 } 448 }
453 slider->repaint( TRUE ); 449 slider->repaint( TRUE );
454 } 450 }
455} 451}
456 452
457 453
458void VideoWidget::closeEvent( QCloseEvent* ) { 454void VideoWidget::closeEvent( QCloseEvent* ) {
459 mediaPlayerState->setList(); 455 mediaPlayerState->setList();
460} 456}
461 457
462 458
463bool VideoWidget::playVideo() { 459bool VideoWidget::playVideo() {
464 bool result = FALSE; 460 bool result = FALSE;
465// qDebug("<<<<<<<<<<<<<<<< play video"); 461// qDebug("<<<<<<<<<<<<<<<< play video");
466 int stream = 0; 462 int stream = 0;
467 463
468 int sw = mediaPlayerState->curDecoder()->videoWidth( stream ); 464 int sw = mediaPlayerState->curDecoder()->videoWidth( stream );
469 int sh = mediaPlayerState->curDecoder()->videoHeight( stream ); 465 int sh = mediaPlayerState->curDecoder()->videoHeight( stream );
470 int dd = QPixmap::defaultDepth(); 466 int dd = QPixmap::defaultDepth();
471 int w = height(); 467 int w = height();
472 int h = width(); 468 int h = width();
473 469
474 ColorFormat format = (dd == 16) ? RGB565 : BGRA8888; 470 ColorFormat format = (dd == 16) ? RGB565 : BGRA8888;
475 471
476 if ( mediaPlayerState->fullscreen() ) 472 if ( mediaPlayerState->fullscreen() )
477 { 473 {
478#ifdef USE_DIRECT_PAINTER 474#ifdef USE_DIRECT_PAINTER
479 QDirectPainter p(this); 475 QDirectPainter p(this);
480 476
481 if ( ( qt_screen->transformOrientation() == 3 ) && 477 if ( ( qt_screen->transformOrientation() == 3 ) &&
482 ( ( dd == 16 ) || ( dd == 32 ) ) && ( p.numRects() == 1 ) ) 478 ( ( dd == 16 ) || ( dd == 32 ) ) && ( p.numRects() == 1 ) )
483 { 479 {
484 480
485 w = 320; 481 w = 320;
486 h = 240; 482 h = 240;
487 483
488 if ( mediaPlayerState->scaled() ) 484 if ( mediaPlayerState->scaled() )
489 { 485 {
490 // maintain aspect ratio 486 // maintain aspect ratio
491 if ( w * sh > sw * h ) 487 if ( w * sh > sw * h )
492 w = sw * h / sh; 488 w = sw * h / sh;
493 else 489 else
494 h = sh * w / sw; 490 h = sh * w / sw;
495 } 491 }
496 else 492 else
497 { 493 {
498 w = sw; 494 w = sw;
499 h = sh; 495 h = sh;
500 } 496 }
501 497
502 w--; // we can't allow libmpeg to overwrite. 498 w--; // we can't allow libmpeg to overwrite.
503 QPoint roff = qt_screen->mapToDevice( p.offset(), QSize( qt_screen->width(), qt_screen->height() ) ); 499 QPoint roff = qt_screen->mapToDevice( p.offset(), QSize( qt_screen->width(), qt_screen->height() ) );
504 500
505 int ox = roff.x() - height() + 2 + (height() - w) / 2; 501 int ox = roff.x() - height() + 2 + (height() - w) / 2;
506 int oy = roff.y() + (width() - h) / 2; 502 int oy = roff.y() + (width() - h) / 2;
507 int sx = 0, sy = 0; 503 int sx = 0, sy = 0;
508 504
509 uchar* fp = p.frameBuffer() + p.lineStep() * oy; 505 uchar* fp = p.frameBuffer() + p.lineStep() * oy;
510 fp += dd * ox / 8; 506 fp += dd * ox / 8;
511 uchar **jt = new uchar*[h]; 507 uchar **jt = new uchar*[h];
512 508
513 for ( int i = h; i; i-- ) 509 for ( int i = h; i; i-- )
514 { 510 {
515 jt[h - i] = fp; 511 jt[h - i] = fp;
516 fp += p.lineStep(); 512 fp += p.lineStep();
517 } 513 }
518 514
519 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( jt, sx, sy, sw, sh, w, h, format, 0) == 0; 515 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( jt, sx, sy, sw, sh, w, h, format, 0) == 0;
520 516
521 delete [] jt; 517 delete [] jt;
522 } 518 }
523 else 519 else
524 { 520 {
525#endif 521#endif
526 QPainter p(this); 522 QPainter p(this);
527 523
528 w = 320; 524 w = 320;
529 h = 240; 525 h = 240;
530 526
531 if ( mediaPlayerState->scaled() ) 527 if ( mediaPlayerState->scaled() )
532 { 528 {
533 // maintain aspect ratio 529 // maintain aspect ratio
534 if ( w * sh > sw * h ) 530 if ( w * sh > sw * h )
535 w = sw * h / sh; 531 w = sw * h / sh;
536 else 532 else
537 h = sh * w / sw; 533 h = sh * w / sw;
538 } 534 }
539 else 535 else
540 { 536 {
541 w = sw; 537 w = sw;
542 h = sh; 538 h = sh;
543 } 539 }
544 540
545 int bytes = ( dd == 16 ) ? 2 : 4; 541 int bytes = ( dd == 16 ) ? 2 : 4;
546 QImage tempFrame( w, h, bytes << 3 ); 542 QImage tempFrame( w, h, bytes << 3 );
547 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( tempFrame.jumpTable(), 543 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( tempFrame.jumpTable(),
548 0, 0, sw, sh, w, h, format, 0) == 0; 544 0, 0, sw, sh, w, h, format, 0) == 0;
549 545
550 if ( result && mediaPlayerState->fullscreen() ) 546 if ( result && mediaPlayerState->fullscreen() )
551 { 547 {
552 548
553 int rw = h, rh = w; 549 int rw = h, rh = w;
554 QImage rotatedFrame( rw, rh, bytes << 3 ); 550 QImage rotatedFrame( rw, rh, bytes << 3 );
555 551
556 ushort* in = (ushort*)tempFrame.bits(); 552 ushort* in = (ushort*)tempFrame.bits();
557 ushort* out = (ushort*)rotatedFrame.bits(); 553 ushort* out = (ushort*)rotatedFrame.bits();
558 int spl = rotatedFrame.bytesPerLine() / bytes; 554 int spl = rotatedFrame.bytesPerLine() / bytes;
559 555
560 for (int x=0; x<h; x++) 556 for (int x=0; x<h; x++)
561 { 557 {
562 if ( bytes == 2 ) 558 if ( bytes == 2 )
563 { 559 {
564 ushort* lout = out++ + (w - 1)*spl; 560 ushort* lout = out++ + (w - 1)*spl;
565 for (int y=0; y<w; y++) { 561 for (int y=0; y<w; y++) {
566 *lout=*in++; 562 *lout=*in++;
567 lout-=spl; 563 lout-=spl;
568 } 564 }
569 } 565 }
570 else 566 else
571 { 567 {
572 ulong* lout = ((ulong *)out)++ + (w - 1)*spl; 568 ulong* lout = ((ulong *)out)++ + (w - 1)*spl;
573 for (int y=0; y<w; y++) 569 for (int y=0; y<w; y++)
574 { 570 {
575 *lout=*((ulong*)in)++; 571 *lout=*((ulong*)in)++;
576 lout-=spl; 572 lout-=spl;
577 } 573 }
578 } 574 }
579 } 575 }
580 576
581 p.drawImage( (240 - rw) / 2, (320 - rh) / 2, rotatedFrame, 0, 0, rw, rh ); 577 p.drawImage( (240 - rw) / 2, (320 - rh) / 2, rotatedFrame, 0, 0, rw, rh );
582 } 578 }
583#ifdef USE_DIRECT_PAINTER 579#ifdef USE_DIRECT_PAINTER
584 } 580 }
585#endif 581#endif
586 } 582 }
587 else 583 else
588 { 584 {
589 585
590 w = 220; 586 w = 220;
591 h = 160; 587 h = 160;
592 588
593 // maintain aspect ratio 589 // maintain aspect ratio
594 if ( w * sh > sw * h ) 590 if ( w * sh > sw * h )
595 w = sw * h / sh; 591 w = sw * h / sh;
596 else 592 else
597 h = sh * w / sw; 593 h = sh * w / sw;
598 594
599 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( currentFrame->jumpTable(), 0, 0, sw, sh, w, h, format, 0) == 0; 595 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( currentFrame->jumpTable(), 0, 0, sw, sh, w, h, format, 0) == 0;
600 596
601 QPainter p( this ); 597 QPainter p( this );
602 int deskW = qApp->desktop()->width(); 598 int deskW = qApp->desktop()->width();
603 // Image changed size, therefore need to blank the possibly unpainted regions first 599 // Image changed size, therefore need to blank the possibly unpainted regions first
604 if ( scaledWidth != w || scaledHeight != h ) 600 if ( scaledWidth != w || scaledHeight != h )
605 { 601 {
606 p.setBrush( QBrush( Qt::black ) ); 602 p.setBrush( QBrush( Qt::black ) );
607 p.drawRect( ( deskW -scaledWidth)/2, 20, scaledWidth, 160 ); 603 p.drawRect( ( deskW -scaledWidth)/2, 20, scaledWidth, 160 );
608 } 604 }
609 605
610 scaledWidth = w; 606 scaledWidth = w;
611 scaledHeight = h; 607 scaledHeight = h;
612 608
613 if ( result ) 609 if ( result )
614 { 610 {
615 p.drawImage( (deskW - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight ); 611 p.drawImage( (deskW - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight );
616 } 612 }
617 613
618 } 614 }
619 615
620 return result; 616 return result;
621} 617}
622 618
623 619
624 620
625void VideoWidget::keyReleaseEvent( QKeyEvent *e) 621void VideoWidget::keyReleaseEvent( QKeyEvent *e)
626{ 622{
627 switch ( e->key() ) 623 switch ( e->key() )
628 { 624 {
629////////////////////////////// Zaurus keys 625////////////////////////////// Zaurus keys
630 case Key_Home: 626 case Key_Home:
631 break; 627 break;
632 case Key_F9: //activity 628 case Key_F9: //activity
633 break; 629 break;
634 case Key_F10: //contacts 630 case Key_F10: //contacts
635// hide(); 631// hide();
636 break; 632 break;
637 case Key_F11: //menu 633 case Key_F11: //menu
638 break; 634 break;
639 case Key_F12: //home 635 case Key_F12: //home
640 break; 636 break;
641 case Key_F13: //mail 637 case Key_F13: //mail
642 break; 638 break;
643 case Key_Space: 639 case Key_Space:
644 { 640 {
645 if(mediaPlayerState->playing()) 641 if(mediaPlayerState->playing())
646 { 642 {
647 mediaPlayerState->setPlaying(FALSE); 643 mediaPlayerState->setPlaying(FALSE);
648 } 644 }
649 else 645 else
650 { 646 {
651 mediaPlayerState->setPlaying(TRUE); 647 mediaPlayerState->setPlaying(TRUE);
652 } 648 }
653 } 649 }
654 break; 650 break;
655 case Key_Down: 651 case Key_Down:
656// toggleButton(6); 652// toggleButton(6);
657// emit lessClicked(); 653// emit lessClicked();
658// emit lessReleased(); 654// emit lessReleased();
659// toggleButton(6); 655// toggleButton(6);
660 break; 656 break;
661 case Key_Up: 657 case Key_Up:
662// toggleButton(5); 658// toggleButton(5);
663// emit moreClicked(); 659// emit moreClicked();
664// emit moreReleased(); 660// emit moreReleased();
665// toggleButton(5); 661// toggleButton(5);
666 break; 662 break;
667 case Key_Right: 663 case Key_Right:
668 mediaPlayerState->setNext(); 664 mediaPlayerState->setNext();
669 break; 665 break;
670 case Key_Left: 666 case Key_Left:
671 mediaPlayerState->setPrev(); 667 mediaPlayerState->setPrev();
672 break; 668 break;
673 case Key_Escape: 669 case Key_Escape:
674 break; 670 break;
675 671
676 }; 672 };
677} 673}
diff --git a/core/opie-login/loginwindowimpl.cpp b/core/opie-login/loginwindowimpl.cpp
index 330fac5..3037ba3 100644
--- a/core/opie-login/loginwindowimpl.cpp
+++ b/core/opie-login/loginwindowimpl.cpp
@@ -1,254 +1,250 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> 3             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This file is free software; you can 5 _;:,     .>    :=|. This file is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public 7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This file is distributed in the hope that 12    .i_,=:_.      -<s. This file is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
17..}^=.=       =       ; Public License for more details. 17..}^=.=       =       ; Public License for more details.
18++=   -.     .`     .: 18++=   -.     .`     .:
19 :     =  ...= . :.=- You should have received a copy of the GNU 19 :     =  ...= . :.=- You should have received a copy of the GNU
20 -.   .:....=;==+<; General Public License along with this file; 20 -.   .:....=;==+<; General Public License along with this file;
21  -_. . .   )=.  = see the file COPYING. If not, write to the 21  -_. . .   )=.  = see the file COPYING. If not, write to the
22    --        :-=` Free Software Foundation, Inc., 22    --        :-=` Free Software Foundation, Inc.,
23 59 Temple Place - Suite 330, 23 59 Temple Place - Suite 330,
24 Boston, MA 02111-1307, USA. 24 Boston, MA 02111-1307, USA.
25 25
26*/ 26*/
27#include <qpe/version.h> 27#include <qpe/version.h>
28#include <qapplication.h>
29#include <qpushbutton.h> 28#include <qpushbutton.h>
30#include <qlayout.h> 29#include <qlayout.h>
31#include <qframe.h>
32#include <qlineedit.h> 30#include <qlineedit.h>
33#include <qtimer.h> 31#include <qtimer.h>
34#include <qcombobox.h> 32#include <qcombobox.h>
35#include <qpixmap.h>
36#include <qlabel.h> 33#include <qlabel.h>
37#include <qpopupmenu.h> 34#include <qpopupmenu.h>
38#include <qmessagebox.h> 35#include <qmessagebox.h>
39#include <qimage.h>
40#if QT_VERSION < 300 36#if QT_VERSION < 300
41#include <qgfx_qws.h> 37#include <qgfx_qws.h>
42#endif 38#endif
43#include <qwindowsystem_qws.h> 39#include <qwindowsystem_qws.h>
44 40
45#include <qpe/resource.h> 41#include <qpe/resource.h>
46#include <qpe/qcopenvelope_qws.h> 42#include <qpe/qcopenvelope_qws.h>
47#include <qpe/config.h> 43#include <qpe/config.h>
48 44
49#include <opie/odevice.h> 45#include <opie/odevice.h>
50 46
51#include <stdio.h> 47#include <stdio.h>
52#include <stdlib.h> 48#include <stdlib.h>
53 49
54#include "loginwindowimpl.h" 50#include "loginwindowimpl.h"
55#include "loginapplication.h" 51#include "loginapplication.h"
56#include "inputmethods.h" 52#include "inputmethods.h"
57 53
58using namespace Opie; 54using namespace Opie;
59 55
60 56
61LoginWindowImpl::LoginWindowImpl ( ) : LoginWindow ( 0, "LOGIN-WINDOW", WStyle_Customize | WStyle_NoBorder | WDestructiveClose ) 57LoginWindowImpl::LoginWindowImpl ( ) : LoginWindow ( 0, "LOGIN-WINDOW", WStyle_Customize | WStyle_NoBorder | WDestructiveClose )
62{ 58{
63 QPopupMenu *pop = new QPopupMenu ( this ); 59 QPopupMenu *pop = new QPopupMenu ( this );
64 pop-> insertItem ( tr( "Restart" ), this, SLOT( restart ( ))); 60 pop-> insertItem ( tr( "Restart" ), this, SLOT( restart ( )));
65 pop-> insertItem ( tr( "Quit" ), this, SLOT( quit ( ))); 61 pop-> insertItem ( tr( "Quit" ), this, SLOT( quit ( )));
66 m_menu-> setPopup ( pop ); 62 m_menu-> setPopup ( pop );
67 63
68 QCopChannel *channel = new QCopChannel ( "QPE/TaskBar", this ); 64 QCopChannel *channel = new QCopChannel ( "QPE/TaskBar", this );
69 connect ( channel, SIGNAL( received ( const QCString &, const QByteArray & )), this, SLOT( receive ( const QCString &, const QByteArray & ))); 65 connect ( channel, SIGNAL( received ( const QCString &, const QByteArray & )), this, SLOT( receive ( const QCString &, const QByteArray & )));
70 66
71 QHBoxLayout *lay = new QHBoxLayout ( m_taskbar, 4, 4 ); 67 QHBoxLayout *lay = new QHBoxLayout ( m_taskbar, 4, 4 );
72 m_input = new InputMethods ( m_taskbar ); 68 m_input = new InputMethods ( m_taskbar );
73 connect ( m_input, SIGNAL( inputToggled ( bool )), this, SLOT( calcMaxWindowRect ( ))); 69 connect ( m_input, SIGNAL( inputToggled ( bool )), this, SLOT( calcMaxWindowRect ( )));
74 lay-> addWidget ( m_input ); 70 lay-> addWidget ( m_input );
75 lay-> addStretch ( 10 ); 71 lay-> addStretch ( 10 );
76 72
77 setActiveWindow ( ); 73 setActiveWindow ( );
78 m_password-> setFocus ( ); 74 m_password-> setFocus ( );
79 75
80 m_user-> insertStringList ( lApp-> allUsers ( )); 76 m_user-> insertStringList ( lApp-> allUsers ( ));
81 77
82 //there is no point in displaying the IM for a zaurus 78 //there is no point in displaying the IM for a zaurus
83 if (ODevice::inst ( )-> series ( ) != Model_Zaurus){ 79 if (ODevice::inst ( )-> series ( ) != Model_Zaurus){
84 QTimer::singleShot ( 0, this, SLOT( showIM ( ))); 80 QTimer::singleShot ( 0, this, SLOT( showIM ( )));
85 } 81 }
86 82
87 QString opiedir = ::getenv ( "OPIEDIR" ); 83 QString opiedir = ::getenv ( "OPIEDIR" );
88 QPixmap bgpix ( opiedir + "/pics/launcher/opie-background.jpg" ); 84 QPixmap bgpix ( opiedir + "/pics/launcher/opie-background.jpg" );
89 85
90 if ( !bgpix. isNull ( )) { 86 if ( !bgpix. isNull ( )) {
91 setBackgroundPixmap ( bgpix ); 87 setBackgroundPixmap ( bgpix );
92 m_caption-> setBackgroundPixmap ( bgpix); 88 m_caption-> setBackgroundPixmap ( bgpix);
93 TextLabel1-> setBackgroundPixmap ( bgpix); 89 TextLabel1-> setBackgroundPixmap ( bgpix);
94 TextLabel2-> setBackgroundPixmap ( bgpix); 90 TextLabel2-> setBackgroundPixmap ( bgpix);
95 } 91 }
96 92
97 m_caption-> setText ( tr("<center>Welcome to OPIE %1</center><center>& %2 %3</center>"). arg(QPE_VERSION). arg ( ODevice::inst ( )-> systemString ( )). arg ( ODevice::inst ( )-> systemVersionString ( ))); 93 m_caption-> setText ( tr("<center>Welcome to OPIE %1</center><center>& %2 %3</center>"). arg(QPE_VERSION). arg ( ODevice::inst ( )-> systemString ( )). arg ( ODevice::inst ( )-> systemVersionString ( )));
98 94
99 Config cfg ( "opie-login" ); 95 Config cfg ( "opie-login" );
100 cfg. setGroup ( "General" ); 96 cfg. setGroup ( "General" );
101 QString last = cfg. readEntry ( "LastLogin" ); 97 QString last = cfg. readEntry ( "LastLogin" );
102 98
103 if ( !last. isEmpty ( )) 99 if ( !last. isEmpty ( ))
104 m_user-> setEditText ( last ); 100 m_user-> setEditText ( last );
105 101
106 calcMaxWindowRect ( ); 102 calcMaxWindowRect ( );
107} 103}
108 104
109LoginWindowImpl::~LoginWindowImpl ( ) 105LoginWindowImpl::~LoginWindowImpl ( )
110{ 106{
111} 107}
112 108
113 109
114void LoginWindowImpl::receive ( const QCString &msg, const QByteArray &data ) 110void LoginWindowImpl::receive ( const QCString &msg, const QByteArray &data )
115{ 111{
116 QDataStream stream ( data, IO_ReadOnly ); 112 QDataStream stream ( data, IO_ReadOnly );
117 113
118 if ( msg == "hideInputMethod()" ) 114 if ( msg == "hideInputMethod()" )
119 m_input-> hideInputMethod ( ); 115 m_input-> hideInputMethod ( );
120 else if ( msg == "showInputMethod()" ) 116 else if ( msg == "showInputMethod()" )
121 m_input-> showInputMethod ( ); 117 m_input-> showInputMethod ( );
122 else if ( msg == "reloadInputMethods()" ) 118 else if ( msg == "reloadInputMethods()" )
123 m_input-> loadInputMethods ( ); 119 m_input-> loadInputMethods ( );
124} 120}
125 121
126void LoginWindowImpl::calcMaxWindowRect ( ) 122void LoginWindowImpl::calcMaxWindowRect ( )
127{ 123{
128#ifdef Q_WS_QWS 124#ifdef Q_WS_QWS
129 QRect wr; 125 QRect wr;
130 int displayWidth = qApp-> desktop ( )-> width ( ); 126 int displayWidth = qApp-> desktop ( )-> width ( );
131 QRect ir = m_input-> inputRect ( ); 127 QRect ir = m_input-> inputRect ( );
132 if ( ir.isValid() ) 128 if ( ir.isValid() )
133 wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 ); 129 wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 );
134 else 130 else
135 wr.setCoords( 0, 0, displayWidth-1, m_taskbar->y()-1 ); 131 wr.setCoords( 0, 0, displayWidth-1, m_taskbar->y()-1 );
136 132
137#if QT_VERSION < 300 133#if QT_VERSION < 300
138 wr = qt_screen-> mapToDevice ( wr, QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); 134 wr = qt_screen-> mapToDevice ( wr, QSize ( qt_screen-> width ( ), qt_screen-> height ( )));
139#endif 135#endif
140 136
141 QWSServer::setMaxWindowRect( wr ); 137 QWSServer::setMaxWindowRect( wr );
142#endif 138#endif
143} 139}
144 140
145 141
146void LoginWindowImpl::keyPressEvent ( QKeyEvent *e ) 142void LoginWindowImpl::keyPressEvent ( QKeyEvent *e )
147{ 143{
148 switch ( e-> key ( )) { 144 switch ( e-> key ( )) {
149 case HardKey_Suspend: suspend ( ); 145 case HardKey_Suspend: suspend ( );
150 break; 146 break;
151 case HardKey_Backlight: backlight ( ); 147 case HardKey_Backlight: backlight ( );
152 break; 148 break;
153 default: e-> ignore ( ); 149 default: e-> ignore ( );
154 break; 150 break;
155 } 151 }
156 LoginWindow::keyPressEvent ( e ); 152 LoginWindow::keyPressEvent ( e );
157} 153}
158 154
159 155
160void LoginWindowImpl::toggleEchoMode ( bool t ) 156void LoginWindowImpl::toggleEchoMode ( bool t )
161{ 157{
162 m_password-> setEchoMode ( t ? QLineEdit::Normal : QLineEdit::Password ); 158 m_password-> setEchoMode ( t ? QLineEdit::Normal : QLineEdit::Password );
163} 159}
164 160
165void LoginWindowImpl::showIM ( ) 161void LoginWindowImpl::showIM ( )
166{ 162{
167 m_input-> showInputMethod ( ); 163 m_input-> showInputMethod ( );
168} 164}
169 165
170void LoginWindowImpl::restart ( ) 166void LoginWindowImpl::restart ( )
171{ 167{
172 qApp-> quit ( ); 168 qApp-> quit ( );
173} 169}
174 170
175void LoginWindowImpl::quit ( ) 171void LoginWindowImpl::quit ( )
176{ 172{
177 lApp-> quitToConsole ( ); 173 lApp-> quitToConsole ( );
178} 174}
179 175
180void LoginWindowImpl::suspend ( ) 176void LoginWindowImpl::suspend ( )
181{ 177{
182 ODevice::inst ( )-> suspend ( ); 178 ODevice::inst ( )-> suspend ( );
183 179
184 QCopEnvelope e("QPE/System", "setBacklight(int)"); 180 QCopEnvelope e("QPE/System", "setBacklight(int)");
185 e << -3; // Force on 181 e << -3; // Force on
186} 182}
187 183
188void LoginWindowImpl::backlight ( ) 184void LoginWindowImpl::backlight ( )
189{ 185{
190 QCopEnvelope e("QPE/System", "setBacklight(int)"); 186 QCopEnvelope e("QPE/System", "setBacklight(int)");
191 e << -2; // toggle 187 e << -2; // toggle
192} 188}
193 189
194class WaitLogo : public QLabel { 190class WaitLogo : public QLabel {
195public: 191public:
196 WaitLogo ( ) : QLabel ( 0, "wait hack!", WStyle_Customize | WStyle_NoBorder | WStyle_Tool ) 192 WaitLogo ( ) : QLabel ( 0, "wait hack!", WStyle_Customize | WStyle_NoBorder | WStyle_Tool )
197 { 193 {
198 QImage img = Resource::loadImage ( "launcher/new_wait" ); 194 QImage img = Resource::loadImage ( "launcher/new_wait" );
199 QPixmap pix; 195 QPixmap pix;
200 pix. convertFromImage ( img ); 196 pix. convertFromImage ( img );
201 setPixmap ( pix ); 197 setPixmap ( pix );
202 setAlignment ( AlignCenter ); 198 setAlignment ( AlignCenter );
203 move ( 0, 0 ); 199 move ( 0, 0 );
204 resize ( qApp-> desktop ( )-> width ( ), qApp-> desktop ( )-> height ( )); 200 resize ( qApp-> desktop ( )-> width ( ), qApp-> desktop ( )-> height ( ));
205 201
206 m_visible = false; 202 m_visible = false;
207 show ( ); 203 show ( );
208 } 204 }
209 205
210 virtual void showEvent ( QShowEvent *e ) 206 virtual void showEvent ( QShowEvent *e )
211 { 207 {
212 QLabel::showEvent ( e ); 208 QLabel::showEvent ( e );
213 m_visible = true; 209 m_visible = true;
214 } 210 }
215 211
216 virtual void paintEvent ( QPaintEvent *e ) 212 virtual void paintEvent ( QPaintEvent *e )
217 { 213 {
218 QLabel::paintEvent ( e ); 214 QLabel::paintEvent ( e );
219 if ( m_visible ) 215 if ( m_visible )
220 qApp-> quit ( ); 216 qApp-> quit ( );
221 } 217 }
222 218
223private: 219private:
224 bool m_visible; 220 bool m_visible;
225}; 221};
226 222
227void LoginWindowImpl::login ( ) 223void LoginWindowImpl::login ( )
228{ 224{
229 const char *user = ::strdup ( m_user-> currentText ( ). local8Bit ( )); 225 const char *user = ::strdup ( m_user-> currentText ( ). local8Bit ( ));
230 const char *pass = ::strdup ( m_password-> text ( ). local8Bit ( )); 226 const char *pass = ::strdup ( m_password-> text ( ). local8Bit ( ));
231 227
232 if ( !user || !user [0] ) 228 if ( !user || !user [0] )
233 return; 229 return;
234 if ( !pass ) 230 if ( !pass )
235 pass = ""; 231 pass = "";
236 232
237 if ( lApp-> checkPassword ( user, pass )) { 233 if ( lApp-> checkPassword ( user, pass )) {
238 Config cfg ( "opie-login" ); 234 Config cfg ( "opie-login" );
239 cfg. setGroup ( "General" ); 235 cfg. setGroup ( "General" );
240 cfg. writeEntry ( "LastLogin", user ); 236 cfg. writeEntry ( "LastLogin", user );
241 cfg. write ( ); 237 cfg. write ( );
242 238
243 lApp-> setLoginAs ( user ); 239 lApp-> setLoginAs ( user );
244 240
245 // Draw a big wait icon, the image can be altered in later revisions 241 // Draw a big wait icon, the image can be altered in later revisions
246 m_input-> hideInputMethod ( ); 242 m_input-> hideInputMethod ( );
247 new WaitLogo ( ); 243 new WaitLogo ( );
248 // WaitLogo::showEvent() calls qApp-> quit() 244 // WaitLogo::showEvent() calls qApp-> quit()
249 } 245 }
250 else { 246 else {
251 QMessageBox::warning ( this, tr( "Wrong password" ), tr( "The given password is incorrect." )); 247 QMessageBox::warning ( this, tr( "Wrong password" ), tr( "The given password is incorrect." ));
252 m_password-> clear ( ); 248 m_password-> clear ( );
253 } 249 }
254} 250}
diff --git a/core/opie-login/main.cpp b/core/opie-login/main.cpp
index 7d2ed63..bf98735 100644
--- a/core/opie-login/main.cpp
+++ b/core/opie-login/main.cpp
@@ -1,386 +1,382 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> 3             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This file is free software; you can 5 _;:,     .>    :=|. This file is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public 7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This file is distributed in the hope that 12    .i_,=:_.      -<s. This file is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
17..}^=.=       =       ; Public License for more details. 17..}^=.=       =       ; Public License for more details.
18++=   -.     .`     .: 18++=   -.     .`     .:
19 :     =  ...= . :.=- You should have received a copy of the GNU 19 :     =  ...= . :.=- You should have received a copy of the GNU
20 -.   .:....=;==+<; General Public License along with this file; 20 -.   .:....=;==+<; General Public License along with this file;
21  -_. . .   )=.  = see the file COPYING. If not, write to the 21  -_. . .   )=.  = see the file COPYING. If not, write to the
22    --        :-=` Free Software Foundation, Inc., 22    --        :-=` Free Software Foundation, Inc.,
23 59 Temple Place - Suite 330, 23 59 Temple Place - Suite 330,
24 Boston, MA 02111-1307, USA. 24 Boston, MA 02111-1307, USA.
25 25
26*/ 26*/
27 27
28#define _GNU_SOURCE 28#define _GNU_SOURCE
29 29
30#include <sys/types.h> 30#include <sys/types.h>
31#include <time.h> 31#include <time.h>
32#include <sys/time.h> 32#include <sys/time.h>
33#include <sys/resource.h> 33#include <sys/resource.h>
34#include <unistd.h> 34#include <unistd.h>
35#include <syslog.h> 35#include <syslog.h>
36#include <sys/wait.h> 36#include <sys/wait.h>
37#include <stdio.h> 37#include <stdio.h>
38#include <stdlib.h> 38#include <stdlib.h>
39#include <signal.h> 39#include <signal.h>
40#include <getopt.h> 40#include <getopt.h>
41#include <string.h> 41#include <string.h>
42 42
43#include <qpe/qpeapplication.h>
44#include <qpe/qcopenvelope_qws.h>
45#include <qpe/qpestyle.h> 43#include <qpe/qpestyle.h>
46#include <qpe/power.h> 44#include <qpe/power.h>
47#include <qpe/config.h> 45#include <qpe/config.h>
48 46
49#include <opie/odevice.h> 47#include <opie/odevice.h>
50 48
51#include <qwindowsystem_qws.h> 49#include <qwindowsystem_qws.h>
52#include <qwsmouse_qws.h>
53#include <qmessagebox.h> 50#include <qmessagebox.h>
54#include <qlabel.h> 51#include <qlabel.h>
55#include <qtimer.h> 52#include <qtimer.h>
56#include <qfile.h> 53#include <qfile.h>
57#include <qtextstream.h>
58 54
59#include "loginapplication.h" 55#include "loginapplication.h"
60#include "loginwindowimpl.h" 56#include "loginwindowimpl.h"
61#include "calibrate.h" 57#include "calibrate.h"
62 58
63using namespace Opie; 59using namespace Opie;
64 60
65int login_main ( int argc, char **argv, pid_t ppid ); 61int login_main ( int argc, char **argv, pid_t ppid );
66void sigterm ( int sig ); 62void sigterm ( int sig );
67void sigint ( int sig ); 63void sigint ( int sig );
68void exit_closelog ( ); 64void exit_closelog ( );
69 65
70static struct option long_options [] = { 66static struct option long_options [] = {
71 { "autologin", 1, 0, 'a' }, 67 { "autologin", 1, 0, 'a' },
72 { 0, 0, 0, 0 } 68 { 0, 0, 0, 0 }
73}; 69};
74 70
75 71
76int main ( int argc, char **argv ) 72int main ( int argc, char **argv )
77{ 73{
78 int userExited = 0; 74 int userExited = 0;
79 pid_t ppid = ::getpid ( ); 75 pid_t ppid = ::getpid ( );
80 76
81 if ( ::geteuid ( ) != 0 ) { 77 if ( ::geteuid ( ) != 0 ) {
82 ::fprintf ( stderr, "%s can only be executed by root. (or chmod +s)", argv [0] ); 78 ::fprintf ( stderr, "%s can only be executed by root. (or chmod +s)", argv [0] );
83 return 1; 79 return 1;
84 } 80 }
85 if ( ::getuid ( ) != 0 ) // qt doesn't really like SUID and 81 if ( ::getuid ( ) != 0 ) // qt doesn't really like SUID and
86 ::setuid ( 0 ); // messes up things like config files 82 ::setuid ( 0 ); // messes up things like config files
87 83
88 char *autolog = 0; 84 char *autolog = 0;
89 int c; 85 int c;
90 while (( c = ::getopt_long ( argc, argv, "a:", long_options, 0 )) != -1 ) { 86 while (( c = ::getopt_long ( argc, argv, "a:", long_options, 0 )) != -1 ) {
91 switch ( c ) { 87 switch ( c ) {
92 case 'a': 88 case 'a':
93 autolog = optarg; 89 autolog = optarg;
94 break; 90 break;
95 default: 91 default:
96 ::fprintf ( stderr, "Usage: %s [-a|--autologin=<user>]\n", argv [0] ); 92 ::fprintf ( stderr, "Usage: %s [-a|--autologin=<user>]\n", argv [0] );
97 return 2; 93 return 2;
98 } 94 }
99 } 95 }
100 96
101 //struct rlimit rl; 97 //struct rlimit rl;
102 //::getrlimit ( RLIMIT_NOFILE, &rl ); 98 //::getrlimit ( RLIMIT_NOFILE, &rl );
103 99
104 //for ( unsigned int i = 0; i < rl. rlim_cur; i++ ) 100 //for ( unsigned int i = 0; i < rl. rlim_cur; i++ )
105 // ::close ( i ); 101 // ::close ( i );
106 102
107 ::setpgid ( 0, 0 ); 103 ::setpgid ( 0, 0 );
108 ::setsid ( ); 104 ::setsid ( );
109 105
110 ::signal ( SIGTERM, sigterm ); 106 ::signal ( SIGTERM, sigterm );
111 ::signal ( SIGINT, sigterm ); 107 ::signal ( SIGINT, sigterm );
112 108
113 ::openlog ( "opie-login", LOG_CONS, LOG_AUTHPRIV ); 109 ::openlog ( "opie-login", LOG_CONS, LOG_AUTHPRIV );
114 ::atexit ( exit_closelog ); 110 ::atexit ( exit_closelog );
115 111
116 while ( true ) { 112 while ( true ) {
117 pid_t child = ::fork ( ); 113 pid_t child = ::fork ( );
118 114
119 if ( child < 0 ) { 115 if ( child < 0 ) {
120 ::syslog ( LOG_ERR, "Could not fork GUI process\n" ); 116 ::syslog ( LOG_ERR, "Could not fork GUI process\n" );
121 break; 117 break;
122 } 118 }
123 else if ( child > 0 ) { 119 else if ( child > 0 ) {
124 int status = 0; 120 int status = 0;
125 time_t started = ::time ( 0 ); 121 time_t started = ::time ( 0 );
126 122
127 while ( ::waitpid ( child, &status, 0 ) < 0 ) { } 123 while ( ::waitpid ( child, &status, 0 ) < 0 ) { }
128 124
129 LoginApplication::logout ( ); 125 LoginApplication::logout ( );
130 126
131 if (( ::time ( 0 ) - started ) < 3 ) { 127 if (( ::time ( 0 ) - started ) < 3 ) {
132 if ( autolog ) { 128 if ( autolog ) {
133 ::syslog ( LOG_ERR, "Respawning too fast -- disabling auto-login\n" ); 129 ::syslog ( LOG_ERR, "Respawning too fast -- disabling auto-login\n" );
134 autolog = 0; 130 autolog = 0;
135 } 131 }
136 else { 132 else {
137 ::syslog ( LOG_ERR, "Respawning too fast -- going down\n" ); 133 ::syslog ( LOG_ERR, "Respawning too fast -- going down\n" );
138 break; 134 break;
139 } 135 }
140 } 136 }
141 int killedbysig = 0; 137 int killedbysig = 0;
142 userExited=0; 138 userExited=0;
143 if (WIFEXITED(status)!=0 ) { 139 if (WIFEXITED(status)!=0 ) {
144 if (WEXITSTATUS(status)==137) { 140 if (WEXITSTATUS(status)==137) {
145 userExited=1; 141 userExited=1;
146 } 142 }
147 } 143 }
148 144
149 if ( WIFSIGNALED( status )) { 145 if ( WIFSIGNALED( status )) {
150 switch ( WTERMSIG( status )) { 146 switch ( WTERMSIG( status )) {
151 case SIGTERM: 147 case SIGTERM:
152 case SIGINT : 148 case SIGINT :
153 case SIGKILL: 149 case SIGKILL:
154 break; 150 break;
155 151
156 default : 152 default :
157 killedbysig = WTERMSIG( status ); 153 killedbysig = WTERMSIG( status );
158 break; 154 break;
159 } 155 }
160 } 156 }
161 if ( killedbysig ) { // qpe was killed by an uncaught signal 157 if ( killedbysig ) { // qpe was killed by an uncaught signal
162 qApp = 0; 158 qApp = 0;
163 159
164 ::syslog ( LOG_ERR, "Opie was killed by a signal #%d", killedbysig ); 160 ::syslog ( LOG_ERR, "Opie was killed by a signal #%d", killedbysig );
165 161
166 QWSServer::setDesktopBackground ( QImage ( )); 162 QWSServer::setDesktopBackground ( QImage ( ));
167 QApplication *app = new QApplication ( argc, argv, QApplication::GuiServer ); 163 QApplication *app = new QApplication ( argc, argv, QApplication::GuiServer );
168 app-> setFont ( QFont ( "Helvetica", 10 )); 164 app-> setFont ( QFont ( "Helvetica", 10 ));
169 app-> setStyle ( new QPEStyle ( )); 165 app-> setStyle ( new QPEStyle ( ));
170 166
171 const char *sig = ::strsignal ( killedbysig ); 167 const char *sig = ::strsignal ( killedbysig );
172 QLabel *l = new QLabel ( 0, "sig", Qt::WStyle_Customize | Qt::WStyle_NoBorder | Qt::WStyle_Tool ); 168 QLabel *l = new QLabel ( 0, "sig", Qt::WStyle_Customize | Qt::WStyle_NoBorder | Qt::WStyle_Tool );
173 l-> setText ( LoginWindowImpl::tr( "Opie was terminated\nby an uncaught signal\n(%1)\n" ). arg ( sig )); 169 l-> setText ( LoginWindowImpl::tr( "Opie was terminated\nby an uncaught signal\n(%1)\n" ). arg ( sig ));
174 l-> setAlignment ( Qt::AlignCenter ); 170 l-> setAlignment ( Qt::AlignCenter );
175 l-> move ( 0, 0 ); 171 l-> move ( 0, 0 );
176 l-> resize ( app-> desktop ( )-> width ( ), app-> desktop ( )-> height ( )); 172 l-> resize ( app-> desktop ( )-> width ( ), app-> desktop ( )-> height ( ));
177 l-> show ( ); 173 l-> show ( );
178 QTimer::singleShot ( 3000, app, SLOT( quit ( ))); 174 QTimer::singleShot ( 3000, app, SLOT( quit ( )));
179 app-> exec ( ); 175 app-> exec ( );
180 delete app; 176 delete app;
181 qApp = 0; 177 qApp = 0;
182 } 178 }
183 } 179 }
184 else { 180 else {
185 if ( !autolog ) { 181 if ( !autolog ) {
186 QString confFile=QPEApplication::qpeDir() + "/etc/opie-login.conf"; 182 QString confFile=QPEApplication::qpeDir() + "/etc/opie-login.conf";
187 Config cfg ( confFile, Config::File ); 183 Config cfg ( confFile, Config::File );
188 cfg. setGroup ( "General" ); 184 cfg. setGroup ( "General" );
189 QString user = cfg. readEntry ( "AutoLogin" ); 185 QString user = cfg. readEntry ( "AutoLogin" );
190 186
191 if ( !user. isEmpty ( )) 187 if ( !user. isEmpty ( ))
192 autolog = ::strdup ( user. latin1 ( )); 188 autolog = ::strdup ( user. latin1 ( ));
193 } 189 }
194 190
195 if ( autolog && !userExited ) { 191 if ( autolog && !userExited ) {
196 192
197 QWSServer::setDesktopBackground( QImage() ); 193 QWSServer::setDesktopBackground( QImage() );
198 ODevice::inst ( )-> setDisplayStatus ( true ); 194 ODevice::inst ( )-> setDisplayStatus ( true );
199 ODevice::inst ( )-> setSoftSuspend ( false ); 195 ODevice::inst ( )-> setSoftSuspend ( false );
200 LoginApplication *app = new LoginApplication ( argc, argv, ppid ); 196 LoginApplication *app = new LoginApplication ( argc, argv, ppid );
201 LoginApplication::setLoginAs ( autolog ); 197 LoginApplication::setLoginAs ( autolog );
202 198
203 199
204 if ( LoginApplication::changeIdentity ( )) 200 if ( LoginApplication::changeIdentity ( ))
205 ::exit ( LoginApplication::login ( )); 201 ::exit ( LoginApplication::login ( ));
206 else 202 else
207 ::exit ( 0 ); 203 ::exit ( 0 );
208 } 204 }
209 else { 205 else {
210 ::exit ( login_main ( argc, argv, ppid )); 206 ::exit ( login_main ( argc, argv, ppid ));
211 } 207 }
212 } 208 }
213 } 209 }
214 return 0; 210 return 0;
215} 211}
216 212
217void sigterm ( int /*sig*/ ) 213void sigterm ( int /*sig*/ )
218{ 214{
219 ::exit ( 0 ); 215 ::exit ( 0 );
220} 216}
221 217
222 218
223void exit_closelog ( ) 219void exit_closelog ( )
224{ 220{
225 ::closelog ( ); 221 ::closelog ( );
226} 222}
227 223
228 224
229class LoginScreenSaver : public QWSScreenSaver 225class LoginScreenSaver : public QWSScreenSaver
230{ 226{
231public: 227public:
232 LoginScreenSaver ( ) 228 LoginScreenSaver ( )
233 { 229 {
234 m_lcd_status = true; 230 m_lcd_status = true;
235 231
236 m_backlight_bright = -1; 232 m_backlight_bright = -1;
237 m_backlight_forcedoff = false; 233 m_backlight_forcedoff = false;
238 234
239 // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) 235 // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off)
240 ODevice::inst ( )-> setDisplayStatus ( true ); 236 ODevice::inst ( )-> setDisplayStatus ( true );
241 } 237 }
242 void restore() 238 void restore()
243 { 239 {
244 if ( !m_lcd_status ) // We must have turned it off 240 if ( !m_lcd_status ) // We must have turned it off
245 ODevice::inst ( ) -> setDisplayStatus ( true ); 241 ODevice::inst ( ) -> setDisplayStatus ( true );
246 242
247 setBacklight ( -3 ); 243 setBacklight ( -3 );
248 } 244 }
249 bool save( int level ) 245 bool save( int level )
250 { 246 {
251 switch ( level ) { 247 switch ( level ) {
252 case 0: 248 case 0:
253 if ( backlight() > 1 ) 249 if ( backlight() > 1 )
254 setBacklight( 1 ); // lowest non-off 250 setBacklight( 1 ); // lowest non-off
255 return true; 251 return true;
256 break; 252 break;
257 case 1: 253 case 1:
258 setBacklight( 0 ); // off 254 setBacklight( 0 ); // off
259 return true; 255 return true;
260 break; 256 break;
261 case 2: 257 case 2:
262 // We're going to suspend the whole machine 258 // We're going to suspend the whole machine
263 if ( PowerStatusManager::readStatus().acStatus() != PowerStatus::Online ) { 259 if ( PowerStatusManager::readStatus().acStatus() != PowerStatus::Online ) {
264 QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); 260 QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE );
265 return true; 261 return true;
266 } 262 }
267 break; 263 break;
268 } 264 }
269 return false; 265 return false;
270 } 266 }
271 267
272private: 268private:
273public: 269public:
274 void setIntervals( int i1 = 30, int i2 = 20, int i3 = 60 ) 270 void setIntervals( int i1 = 30, int i2 = 20, int i3 = 60 )
275 { 271 {
276 int v [4]; 272 int v [4];
277 273
278 v [ 0 ] = QMAX( 1000 * i1, 100 ); 274 v [ 0 ] = QMAX( 1000 * i1, 100 );
279 v [ 1 ] = QMAX( 1000 * i2, 100 ); 275 v [ 1 ] = QMAX( 1000 * i2, 100 );
280 v [ 2 ] = QMAX( 1000 * i3, 100 ); 276 v [ 2 ] = QMAX( 1000 * i3, 100 );
281 v [ 3 ] = 0; 277 v [ 3 ] = 0;
282 278
283 if ( !i1 && !i2 && !i3 ) 279 if ( !i1 && !i2 && !i3 )
284 QWSServer::setScreenSaverInterval ( 0 ); 280 QWSServer::setScreenSaverInterval ( 0 );
285 else 281 else
286 QWSServer::setScreenSaverIntervals ( v ); 282 QWSServer::setScreenSaverIntervals ( v );
287 } 283 }
288 284
289 int backlight ( ) 285 int backlight ( )
290 { 286 {
291 if ( m_backlight_bright == -1 ) 287 if ( m_backlight_bright == -1 )
292 m_backlight_bright = 255; 288 m_backlight_bright = 255;
293 289
294 return m_backlight_bright; 290 return m_backlight_bright;
295 } 291 }
296 292
297 void setBacklight ( int bright ) 293 void setBacklight ( int bright )
298 { 294 {
299 if ( bright == -3 ) { 295 if ( bright == -3 ) {
300 // Forced on 296 // Forced on
301 m_backlight_forcedoff = false; 297 m_backlight_forcedoff = false;
302 bright = -1; 298 bright = -1;
303 } 299 }
304 if ( m_backlight_forcedoff && bright != -2 ) 300 if ( m_backlight_forcedoff && bright != -2 )
305 return ; 301 return ;
306 if ( bright == -2 ) { 302 if ( bright == -2 ) {
307 // Toggle between off and on 303 // Toggle between off and on
308 bright = m_backlight_bright ? 0 : -1; 304 bright = m_backlight_bright ? 0 : -1;
309 m_backlight_forcedoff = !bright; 305 m_backlight_forcedoff = !bright;
310 } 306 }
311 307
312 m_backlight_bright = bright; 308 m_backlight_bright = bright;
313 309
314 bright = backlight ( ); 310 bright = backlight ( );
315 ODevice::inst ( ) -> setDisplayBrightness ( bright ); 311 ODevice::inst ( ) -> setDisplayBrightness ( bright );
316 312
317 m_backlight_bright = bright; 313 m_backlight_bright = bright;
318 } 314 }
319 315
320private: 316private:
321 bool m_lcd_status; 317 bool m_lcd_status;
322 318
323 int m_backlight_bright; 319 int m_backlight_bright;
324 bool m_backlight_forcedoff; 320 bool m_backlight_forcedoff;
325}; 321};
326 322
327 323
328namespace Opie { extern int force_appearance; } // HACK to get around the force-style setting 324namespace Opie { extern int force_appearance; } // HACK to get around the force-style setting
329 325
330 326
331int login_main ( int argc, char **argv, pid_t ppid ) 327int login_main ( int argc, char **argv, pid_t ppid )
332{ 328{
333 QWSServer::setDesktopBackground( QImage() ); 329 QWSServer::setDesktopBackground( QImage() );
334 LoginApplication *app = new LoginApplication ( argc, argv, ppid ); 330 LoginApplication *app = new LoginApplication ( argc, argv, ppid );
335 331
336 Opie::force_appearance = 0; 332 Opie::force_appearance = 0;
337 333
338 app-> setFont ( QFont ( "Helvetica", 10 )); 334 app-> setFont ( QFont ( "Helvetica", 10 ));
339 app-> setStyle ( new QPEStyle ( )); 335 app-> setStyle ( new QPEStyle ( ));
340 336
341 ODevice::inst ( )-> setSoftSuspend ( true ); 337 ODevice::inst ( )-> setSoftSuspend ( true );
342 338
343 if ( QWSServer::mouseHandler() && 339 if ( QWSServer::mouseHandler() &&
344 QWSServer::mouseHandler() ->inherits("QCalibratedMouseHandler") ) { 340 QWSServer::mouseHandler() ->inherits("QCalibratedMouseHandler") ) {
345 if ( !QFile::exists ( "/etc/pointercal" )) { 341 if ( !QFile::exists ( "/etc/pointercal" )) {
346 // Make sure calibration widget starts on top. 342 // Make sure calibration widget starts on top.
347 Calibrate *cal = new Calibrate; 343 Calibrate *cal = new Calibrate;
348 cal-> exec ( ); 344 cal-> exec ( );
349 delete cal; 345 delete cal;
350 } 346 }
351 } 347 }
352 348
353 LoginScreenSaver *saver = new LoginScreenSaver; 349 LoginScreenSaver *saver = new LoginScreenSaver;
354 350
355 saver-> setIntervals ( ); 351 saver-> setIntervals ( );
356 QWSServer::setScreenSaver ( saver ); 352 QWSServer::setScreenSaver ( saver );
357 saver-> restore ( ); 353 saver-> restore ( );
358 354
359 355
360 LoginWindowImpl *lw = new LoginWindowImpl ( ); 356 LoginWindowImpl *lw = new LoginWindowImpl ( );
361 app-> setMainWidget ( lw ); 357 app-> setMainWidget ( lw );
362 lw-> setGeometry ( 0, 0, app-> desktop ( )-> width ( ), app-> desktop ( )-> height ( )); 358 lw-> setGeometry ( 0, 0, app-> desktop ( )-> width ( ), app-> desktop ( )-> height ( ));
363 lw-> show ( ); 359 lw-> show ( );
364 360
365 int rc = app-> exec ( ); 361 int rc = app-> exec ( );
366 362
367 ODevice::inst ( )-> setSoftSuspend ( false ); 363 ODevice::inst ( )-> setSoftSuspend ( false );
368 364
369 if ( app-> loginAs ( )) { 365 if ( app-> loginAs ( )) {
370 if ( app-> changeIdentity ( )) { 366 if ( app-> changeIdentity ( )) {
371 app-> login ( ); 367 app-> login ( );
372 368
373 // if login succeeds, it never comes back 369 // if login succeeds, it never comes back
374 370
375 QMessageBox::critical ( 0, LoginWindowImpl::tr( "Failure" ), LoginWindowImpl::tr( "Could not start Opie." )); 371 QMessageBox::critical ( 0, LoginWindowImpl::tr( "Failure" ), LoginWindowImpl::tr( "Could not start Opie." ));
376 rc = 1; 372 rc = 1;
377 } 373 }
378 else { 374 else {
379 QMessageBox::critical ( 0, LoginWindowImpl::tr( "Failure" ), LoginWindowImpl::tr( "Could not switch to new user identity" )); 375 QMessageBox::critical ( 0, LoginWindowImpl::tr( "Failure" ), LoginWindowImpl::tr( "Could not switch to new user identity" ));
380 rc = 2; 376 rc = 2;
381 } 377 }
382 378
383 } 379 }
384 return rc; 380 return rc;
385} 381}
386 382
diff --git a/core/opie-login/opie-login.pro b/core/opie-login/opie-login.pro
index f9dbe2b..0fdd8e1 100644
--- a/core/opie-login/opie-login.pro
+++ b/core/opie-login/opie-login.pro
@@ -1,28 +1,28 @@
1TEMPLATE = app 1TEMPLATE = app
2CONFIG = qt warn_on debug usepam 2CONFIG = qt warn_on debug
3 3
4HEADERS = loginwindowimpl.h \ 4HEADERS = loginwindowimpl.h \
5 loginapplication.h \ 5 loginapplication.h \
6 ../launcher/inputmethods.h \ 6 ../launcher/inputmethods.h \
7 ../apps/calibrate/calibrate.h 7 ../apps/calibrate/calibrate.h
8 8
9SOURCES = loginwindowimpl.cpp \ 9SOURCES = loginwindowimpl.cpp \
10 loginapplication.cpp \ 10 loginapplication.cpp \
11 ../launcher/inputmethods.cpp \ 11 ../launcher/inputmethods.cpp \
12 ../apps/calibrate/calibrate.cpp \ 12 ../apps/calibrate/calibrate.cpp \
13 main.cpp 13 main.cpp
14 14
15INTERFACES = loginwindow.ui 15INTERFACES = loginwindow.ui
16 16
17INCLUDEPATH += $(OPIEDIR)/include ../launcher ../apps/calibrate 17INCLUDEPATH += $(OPIEDIR)/include ../launcher ../apps/calibrate
18DEPENDPATH += $(OPIEDIR)/include ../launcher ../apps/calibrate 18DEPENDPATH += $(OPIEDIR)/include ../launcher ../apps/calibrate
19 19
20LIBS += -lqpe -lopie 20LIBS += -lqpe -lopie
21 21
22usepam:LIBS += -lpam 22usepam:LIBS += -lpam
23usepam:DEFINES += USEPAM 23usepam:DEFINES += USEPAM
24 24
25DESTDIR = $(OPIEDIR)/bin 25DESTDIR = $(OPIEDIR)/bin
26TARGET = opie-login 26TARGET = opie-login
27 27
28include ( $(OPIEDIR)/include.pro ) 28include ( $(OPIEDIR)/include.pro )