summaryrefslogtreecommitdiff
path: root/core
authorllornkcor <llornkcor>2002-03-18 01:50:17 (UTC)
committer llornkcor <llornkcor>2002-03-18 01:50:17 (UTC)
commitc09cb25eb6bbf31bed0d4a415802469cfd1efedf (patch) (unidiff)
tree86ced0fa482bd5fb244629f2baa1b1a4f25c9189 /core
parent848182342d81b4e6ab4ce6b75bdaa0b109828af3 (diff)
downloadopie-c09cb25eb6bbf31bed0d4a415802469cfd1efedf.zip
opie-c09cb25eb6bbf31bed0d4a415802469cfd1efedf.tar.gz
opie-c09cb25eb6bbf31bed0d4a415802469cfd1efedf.tar.bz2
added stuff and fixed stuff that I dont remember- plays w/o going to playlist among other things
Diffstat (limited to 'core') (more/less context) (show whitespace changes)
-rw-r--r--core/multimedia/opieplayer/audiodevice.cpp2
-rw-r--r--core/multimedia/opieplayer/audiowidget.cpp62
-rw-r--r--core/multimedia/opieplayer/audiowidget.h1
-rw-r--r--core/multimedia/opieplayer/loopcontrol.cpp13
-rw-r--r--core/multimedia/opieplayer/playlistselection.cpp9
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp180
-rw-r--r--core/multimedia/opieplayer/playlistwidget.h7
-rw-r--r--core/multimedia/opieplayer/videowidget.cpp50
-rw-r--r--core/multimedia/opieplayer/videowidget.h1
9 files changed, 234 insertions, 91 deletions
diff --git a/core/multimedia/opieplayer/audiodevice.cpp b/core/multimedia/opieplayer/audiodevice.cpp
index 5fef792..2087c7f 100644
--- a/core/multimedia/opieplayer/audiodevice.cpp
+++ b/core/multimedia/opieplayer/audiodevice.cpp
@@ -188,29 +188,27 @@ void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume,
188 188
189AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) { 189AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) {
190 qDebug("creating new audio device"); 190 qDebug("creating new audio device");
191 d = new AudioDevicePrivate; 191 d = new AudioDevicePrivate;
192 d->frequency = f; 192 d->frequency = f;
193 d->channels = chs; 193 d->channels = chs;
194 d->bytesPerSample = bps; 194 d->bytesPerSample = bps;
195 qDebug("%d",bps); 195 qDebug("%d",bps);
196 int format=0; 196 int format=0;
197 if( bps == 8) format = AFMT_U8; 197 if( bps == 8) format = AFMT_U8;
198 else if( bps <= 0) format = AFMT_S16_LE; 198 else if( bps <= 0) format = AFMT_S16_LE;
199 else format = AFMT_S16_LE; 199 else format = AFMT_S16_LE;
200
201 qDebug("AD- freq %d, channels %d, b/sample %d, bitrate %d",f,chs,bps,format); 200 qDebug("AD- freq %d, channels %d, b/sample %d, bitrate %d",f,chs,bps,format);
202 connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) ); 201 connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) );
203 202
204
205 int fragments = 0x10000 * 8 + sound_fragment_shift; 203 int fragments = 0x10000 * 8 + sound_fragment_shift;
206 int capabilities = 0; 204 int capabilities = 0;
207 205
208#ifdef KEEP_DEVICE_OPEN 206#ifdef KEEP_DEVICE_OPEN
209 if ( AudioDevicePrivate::dspFd == 0 ) { 207 if ( AudioDevicePrivate::dspFd == 0 ) {
210#endif 208#endif
211 if ( ( d->handle = ::open( "/dev/dsp", O_WRONLY ) ) < 0 ) { 209 if ( ( d->handle = ::open( "/dev/dsp", O_WRONLY ) ) < 0 ) {
212 perror("open(\"/dev/dsp\") sending to /dev/null instead"); 210 perror("open(\"/dev/dsp\") sending to /dev/null instead");
213 d->handle = ::open( "/dev/null", O_WRONLY ); 211 d->handle = ::open( "/dev/null", O_WRONLY );
214 } 212 }
215#ifdef KEEP_DEVICE_OPEN 213#ifdef KEEP_DEVICE_OPEN
216 AudioDevicePrivate::dspFd = d->handle; 214 AudioDevicePrivate::dspFd = d->handle;
diff --git a/core/multimedia/opieplayer/audiowidget.cpp b/core/multimedia/opieplayer/audiowidget.cpp
index 582660c..3901446 100644
--- a/core/multimedia/opieplayer/audiowidget.cpp
+++ b/core/multimedia/opieplayer/audiowidget.cpp
@@ -8,30 +8,33 @@
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>
21#include <qpe/resource.h>
22
20#include <qwidget.h> 23#include <qwidget.h>
21#include <qpixmap.h> 24#include <qpixmap.h>
22#include <qbutton.h> 25#include <qbutton.h>
23#include <qpainter.h> 26#include <qpainter.h>
24#include <qframe.h> 27#include <qframe.h>
25#include <qpe/resource.h> 28
26#include "audiowidget.h" 29#include "audiowidget.h"
27#include "mediaplayerstate.h" 30#include "mediaplayerstate.h"
28 31
29extern MediaPlayerState *mediaPlayerState; 32extern MediaPlayerState *mediaPlayerState;
30 33
31 34
32static const int xo = -2; // movable x offset 35static const int xo = -2; // movable x offset
33static const int yo = 22; // movable y offset 36static const int yo = 22; // movable y offset
34 37
35 38
36struct MediaButton { 39struct MediaButton {
37 int xPos, yPos; 40 int xPos, yPos;
@@ -51,24 +54,25 @@ MediaButton audioButtons[] = {
51 { 3*30+xo, 6*30-5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume down 54 { 3*30+xo, 6*30-5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume down
52 { 5*30+xo, 1*30+yo, 0, TRUE, FALSE, FALSE, FALSE }, // repeat/loop 55 { 5*30+xo, 1*30+yo, 0, TRUE, FALSE, FALSE, FALSE }, // repeat/loop
53 { 1*30+xo, 1*30+yo, 0, FALSE, FALSE, FALSE, FALSE } // playlist 56 { 1*30+xo, 1*30+yo, 0, FALSE, FALSE, FALSE, FALSE } // playlist
54}; 57};
55 58
56 59
57static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); 60static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton));
58 61
59 62
60AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : 63AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
61 QWidget( parent, name, f ) 64 QWidget( parent, name, f )
62{ 65{
66// QPEApplication::grabKeyboard();
63 setCaption( tr("OpiePlayer") ); 67 setCaption( tr("OpiePlayer") );
64 setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); 68 setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) );
65 pixmaps[0] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButtonsAll" ) ); 69 pixmaps[0] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButtonsAll" ) );
66 pixmaps[1] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButtonsBig" ) ); 70 pixmaps[1] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButtonsBig" ) );
67 pixmaps[2] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaControls" ) ); 71 pixmaps[2] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaControls" ) );
68 pixmaps[3] = new QPixmap( Resource::loadPixmap( "mpegplayer/animatedButton" ) ); 72 pixmaps[3] = new QPixmap( Resource::loadPixmap( "mpegplayer/animatedButton" ) );
69 73
70 songInfo = new Ticker( this ); 74 songInfo = new Ticker( this );
71 songInfo->setFocusPolicy( QWidget::NoFocus ); 75 songInfo->setFocusPolicy( QWidget::NoFocus );
72 songInfo->setGeometry( QRect( 7, 3, 220, 20 ) ); 76 songInfo->setGeometry( QRect( 7, 3, 220, 20 ) );
73 77
74 slider = new QSlider( Qt::Horizontal, this ); 78 slider = new QSlider( Qt::Horizontal, this );
@@ -207,24 +211,25 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
207 // The test to see if the mouse click is inside the circular button or not 211 // The test to see if the mouse click is inside the circular button or not
208 // (compared with the radius squared to avoid a square-root of our distance) 212 // (compared with the radius squared to avoid a square-root of our distance)
209 int radius = 32 + 13 * size; 213 int radius = 32 + 13 * size;
210 QPoint center = QPoint( x + radius, y + radius ); 214 QPoint center = QPoint( x + radius, y + radius );
211 QPoint dXY = center - event->pos(); 215 QPoint dXY = center - event->pos();
212 int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); 216 int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y();
213 bool isOnButton = dist <= (radius * radius); 217 bool isOnButton = dist <= (radius * radius);
214// QRect r( x, y, 64 + 22*size, 64 + 22*size ); 218// QRect r( x, y, 64 + 22*size, 64 + 22*size );
215// bool isOnButton = r.contains( event->pos() ); // Rectangular Button code 219// bool isOnButton = r.contains( event->pos() ); // Rectangular Button code
216 if ( isOnButton && !audioButtons[i].isHeld ) { 220 if ( isOnButton && !audioButtons[i].isHeld ) {
217 audioButtons[i].isHeld = TRUE; 221 audioButtons[i].isHeld = TRUE;
218 toggleButton(i); 222 toggleButton(i);
223 qDebug("button toggled %d",i);
219 switch (i) { 224 switch (i) {
220 case AudioVolumeUp: emit moreClicked(); return; 225 case AudioVolumeUp: emit moreClicked(); return;
221 case AudioVolumeDown: emit lessClicked(); return; 226 case AudioVolumeDown: emit lessClicked(); return;
222 } 227 }
223 } else if ( !isOnButton && audioButtons[i].isHeld ) { 228 } else if ( !isOnButton && audioButtons[i].isHeld ) {
224 audioButtons[i].isHeld = FALSE; 229 audioButtons[i].isHeld = FALSE;
225 toggleButton(i); 230 toggleButton(i);
226 } 231 }
227 } else { 232 } else {
228 if ( audioButtons[i].isHeld ) { 233 if ( audioButtons[i].isHeld ) {
229 audioButtons[i].isHeld = FALSE; 234 audioButtons[i].isHeld = FALSE;
230 if ( !audioButtons[i].isToggle ) 235 if ( !audioButtons[i].isToggle )
@@ -265,12 +270,67 @@ void AudioWidget::showEvent( QShowEvent* ) {
265void AudioWidget::closeEvent( QCloseEvent* ) { 270void AudioWidget::closeEvent( QCloseEvent* ) {
266 mediaPlayerState->setList(); 271 mediaPlayerState->setList();
267} 272}
268 273
269 274
270void AudioWidget::paintEvent( QPaintEvent * ) { 275void AudioWidget::paintEvent( QPaintEvent * ) {
271 QPainter p( this ); 276 QPainter p( this );
272 for ( int i = 0; i < numButtons; i++ ) 277 for ( int i = 0; i < numButtons; i++ )
273 paintButton( &p, i ); 278 paintButton( &p, i );
274} 279}
275 280
276 281
282void AudioWidget::keyReleaseEvent( QKeyEvent *e)
283{
284 switch ( e->key() ) {
285////////////////////////////// Zaurus keys
286 case Key_Home:
287 break;
288 case Key_F9: //activity
289 break;
290 case Key_F10: //contacts
291 break;
292 case Key_F11: //menu
293 break;
294 case Key_F12: //home
295 break;
296 case Key_F13: //mail
297 break;
298 case Key_Space: {
299 if(mediaPlayerState->playing()) {
300// toggleButton(1);
301 mediaPlayerState->setPlaying(FALSE);
302// toggleButton(1);
303 } else {
304// toggleButton(0);
305 mediaPlayerState->setPlaying(TRUE);
306// toggleButton(0);
307 }
308 }
309 break;
310 case Key_Down:
311 toggleButton(6);
312 emit lessClicked();
313 emit lessReleased();
314 toggleButton(6);
315 break;
316 case Key_Up:
317 toggleButton(5);
318 emit moreClicked();
319 emit moreReleased();
320 toggleButton(5);
321 break;
322 case Key_Right:
323// toggleButton(3);
324 mediaPlayerState->setNext();
325// toggleButton(3);
326 break;
327 case Key_Left:
328// toggleButton(4);
329 mediaPlayerState->setPrev();
330// toggleButton(4);
331 break;
332 case Key_Escape:
333 break;
334
335 };
336}
diff --git a/core/multimedia/opieplayer/audiowidget.h b/core/multimedia/opieplayer/audiowidget.h
index 53e84b3..a2850aa 100644
--- a/core/multimedia/opieplayer/audiowidget.h
+++ b/core/multimedia/opieplayer/audiowidget.h
@@ -119,24 +119,25 @@ signals:
119 void moreReleased(); 119 void moreReleased();
120 void lessReleased(); 120 void lessReleased();
121 void sliderMoved(long); 121 void sliderMoved(long);
122 122
123protected: 123protected:
124 void paintEvent( QPaintEvent *pe ); 124 void paintEvent( QPaintEvent *pe );
125 void showEvent( QShowEvent *se ); 125 void showEvent( QShowEvent *se );
126 void mouseMoveEvent( QMouseEvent *event ); 126 void mouseMoveEvent( QMouseEvent *event );
127 void mousePressEvent( QMouseEvent *event ); 127 void mousePressEvent( QMouseEvent *event );
128 void mouseReleaseEvent( QMouseEvent *event ); 128 void mouseReleaseEvent( QMouseEvent *event );
129 void timerEvent( QTimerEvent *event ); 129 void timerEvent( QTimerEvent *event );
130 void closeEvent( QCloseEvent *event ); 130 void closeEvent( QCloseEvent *event );
131 void keyReleaseEvent( QKeyEvent *e);
131 132
132private: 133private:
133 void toggleButton( int ); 134 void toggleButton( int );
134 void setToggleButton( int, bool ); 135 void setToggleButton( int, bool );
135 void paintButton( QPainter *p, int i ); 136 void paintButton( QPainter *p, int i );
136 QPixmap *pixmaps[4]; 137 QPixmap *pixmaps[4];
137 Ticker *songInfo; 138 Ticker *songInfo;
138 QSlider *slider; 139 QSlider *slider;
139}; 140};
140 141
141 142
142#endif // AUDIO_WIDGET_H 143#endif // AUDIO_WIDGET_H
diff --git a/core/multimedia/opieplayer/loopcontrol.cpp b/core/multimedia/opieplayer/loopcontrol.cpp
index cb8de8a..4b2827e 100644
--- a/core/multimedia/opieplayer/loopcontrol.cpp
+++ b/core/multimedia/opieplayer/loopcontrol.cpp
@@ -212,45 +212,44 @@ void LoopControl::startVideo() {
212 212
213 moreVideo = FALSE; 213 moreVideo = FALSE;
214 killTimer( videoId ); 214 killTimer( videoId );
215 215
216 } 216 }
217 217
218 } 218 }
219} 219}
220 220
221 221
222void LoopControl::startAudio() { 222void LoopControl::startAudio() {
223 223
224//qDebug("start audio");
225 audioMutex->lock(); 224 audioMutex->lock();
226 if ( moreAudio ) { 225 if ( moreAudio ) {
227 226
228 if ( !isMuted && mediaPlayerState->curDecoder() ) { 227 if ( !isMuted && mediaPlayerState->curDecoder() ) {
229 228
230 currentSample = audioSampleCounter + 1; 229 currentSample = audioSampleCounter + 1;
231 230
232 if ( currentSample != audioSampleCounter + 1 ) 231 if ( currentSample != audioSampleCounter + 1 )
233 qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter); 232 qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter);
234 233
235 long samplesRead = 0; 234 long samplesRead = 0;
236 bool readOk=mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, 1024, samplesRead, stream ); 235 bool readOk=mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, 1024, samplesRead, stream );
237 long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000; 236 long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000;
238 long sampleWaitTime = currentSample - sampleWeShouldBeAt; 237 long sampleWaitTime = currentSample - sampleWeShouldBeAt;
239 238
240// if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 20000 ) ) { 239// if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 20000 ) ) {
241// usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) ); 240// usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) );
242// } 241// }
243// else if ( sampleWaitTime <= -5000 ) { 242// else if ( sampleWaitTime <= -5000 ) {
244// qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt ); 243// // qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt );
245// //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream ); 244// //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream );
246// currentSample = sampleWeShouldBeAt; 245// currentSample = sampleWeShouldBeAt;
247// } 246// }
248 247
249 audioDevice->write( audioBuffer, samplesRead * 2 * channels ); 248 audioDevice->write( audioBuffer, samplesRead * 2 * channels );
250 audioSampleCounter = currentSample + samplesRead - 1; 249 audioSampleCounter = currentSample + samplesRead - 1;
251 250
252 moreAudio = readOk && (audioSampleCounter <= total_audio_samples); 251 moreAudio = readOk && (audioSampleCounter <= total_audio_samples);
253 252
254 } else { 253 } else {
255 254
256 moreAudio = FALSE; 255 moreAudio = FALSE;
@@ -370,43 +369,45 @@ bool LoopControl::init( const QString& filename ) {
370 if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) ) { 369 if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) ) {
371 audioMutex->unlock(); 370 audioMutex->unlock();
372 return FALSE; 371 return FALSE;
373 } 372 }
374 373
375 hasAudioChannel = mediaPlayerState->curDecoder()->audioStreams() > 0; 374 hasAudioChannel = mediaPlayerState->curDecoder()->audioStreams() > 0;
376 hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0; 375 hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0;
377 376
378 if ( hasAudioChannel ) { 377 if ( hasAudioChannel ) {
379 int astream = 0; 378 int astream = 0;
380 379
381 channels = mediaPlayerState->curDecoder()->audioChannels( astream ); 380 channels = mediaPlayerState->curDecoder()->audioChannels( astream );
382 qDebug( "LC- channels = %d", channels ); 381// qDebug( "LC- channels = %d", channels );
383 382
384 if ( !total_audio_samples ) 383 if ( !total_audio_samples )
385 total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream ); 384 total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream );
386 385
387// total_audio_samples += 1000; 386// total_audio_samples += 1000;
388 387
389 mediaPlayerState->setLength( total_audio_samples ); 388 mediaPlayerState->setLength( total_audio_samples );
390 389
391 freq = mediaPlayerState->curDecoder()->audioFrequency( astream ); 390 freq = mediaPlayerState->curDecoder()->audioFrequency( astream );
392 qDebug( "LC- frequency = %d", freq ); 391// qDebug( "LC- frequency = %d", freq );
393 392
394 audioSampleCounter = 0; 393 audioSampleCounter = 0;
395 int bits_per_sample; 394 int bits_per_sample;
396 if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibWavPlugin") ) { 395 if ( mediaPlayerState->curDecoder()->pluginName() == QString("WavPlugin") ) {
397 bits_per_sample =(int) mediaPlayerState->curDecoder()->getTime(); 396 bits_per_sample =(int) mediaPlayerState->curDecoder()->getTime();
398 qDebug("using stupid hack"); 397// qDebug("using stupid hack");
399 } else { 398 } else {
400 bits_per_sample=0; 399 bits_per_sample=0;
400// freq=44100;
401 channels=2;
401 } 402 }
402 403
403 audioDevice = new AudioDevice( freq, channels, bits_per_sample); 404 audioDevice = new AudioDevice( freq, channels, bits_per_sample);
404 audioBuffer = new char[ audioDevice->bufferSize() ]; 405 audioBuffer = new char[ audioDevice->bufferSize() ];
405 channels = audioDevice->channels(); 406 channels = audioDevice->channels();
406 407
407 //### must check which frequency is actually used. 408 //### must check which frequency is actually used.
408 static const int size = 1; 409 static const int size = 1;
409 short int buf[size]; 410 short int buf[size];
410 long samplesRead = 0; 411 long samplesRead = 0;
411 mediaPlayerState->curDecoder()->audioReadSamples( buf, channels, size, samplesRead, stream ); 412 mediaPlayerState->curDecoder()->audioReadSamples( buf, channels, size, samplesRead, stream );
412 } 413 }
diff --git a/core/multimedia/opieplayer/playlistselection.cpp b/core/multimedia/opieplayer/playlistselection.cpp
index 4019d12..47fc731 100644
--- a/core/multimedia/opieplayer/playlistselection.cpp
+++ b/core/multimedia/opieplayer/playlistselection.cpp
@@ -46,46 +46,45 @@ private:
46 const DocLnk *fl; 46 const DocLnk *fl;
47}; 47};
48 48
49 49
50PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) 50PlayListSelection::PlayListSelection( QWidget *parent, const char *name )
51 : QListView( parent, name ) 51 : QListView( parent, name )
52{ 52{
53 qDebug("starting playlistselector"); 53 qDebug("starting playlistselector");
54// #ifdef USE_PLAYLIST_BACKGROUND 54// #ifdef USE_PLAYLIST_BACKGROUND
55// setStaticBackground( TRUE ); 55// setStaticBackground( TRUE );
56// setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/background" ) ); 56// setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/background" ) );
57 57
58// setBackgroundPixmap( Resource::loadPixmap( "opielogo" ) ); 58 setBackgroundPixmap( Resource::loadPixmap( "opielogo" ) );
59// #endif 59// #endif
60// addColumn("Title",236); 60// addColumn("Title",236);
61// setAllColumnsShowFocus( TRUE ); 61// setAllColumnsShowFocus( TRUE );
62 addColumn( tr( "Playlist Selection" ) ); 62 addColumn( tr( "Playlist Selection" ) );
63 header()->hide(); 63 header()->hide();
64 setSorting( -1, FALSE ); 64 setSorting( -1, FALSE );
65} 65}
66 66
67 67
68PlayListSelection::~PlayListSelection() { 68PlayListSelection::~PlayListSelection() {
69} 69}
70 70
71 71
72// #ifdef USE_PLAYLIST_BACKGROUND 72// #ifdef USE_PLAYLIST_BACKGROUND
73void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) { 73void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) {
74// qDebug("drawBackground"); 74// qDebug("drawBackground");
75 p->fillRect( r, QBrush( white ) ); 75 p->fillRect( r, QBrush( white ) );
76// QImage logo = Resource::loadImage( "mpegplayer/background" ); 76 QImage logo = Resource::loadImage( "opielogo" );
77// // QImage logo = Resource::loadImage( "opielogo" ); 77 if ( !logo.isNull() )
78// if ( !logo.isNull() ) 78 p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo );
79// p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo );
80} 79}
81// #endif 80// #endif
82 81
83 82
84void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { 83void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) {
85 if ( event->state() == QMouseEvent::LeftButton ) { 84 if ( event->state() == QMouseEvent::LeftButton ) {
86 QListViewItem *currentItem = selectedItem(); 85 QListViewItem *currentItem = selectedItem();
87 QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); 86 QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) );
88 if ( currentItem && currentItem->itemAbove() == itemUnder ) 87 if ( currentItem && currentItem->itemAbove() == itemUnder )
89 moveSelectedUp(); 88 moveSelectedUp();
90 else if ( currentItem && currentItem->itemBelow() == itemUnder ) 89 else if ( currentItem && currentItem->itemBelow() == itemUnder )
91 moveSelectedDown(); 90 moveSelectedDown();
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index 9969526..524747e 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -96,24 +96,25 @@ public:
96 connect( this, SIGNAL( activated() ), handler, slot ); 96 connect( this, SIGNAL( activated() ), handler, slot );
97 addTo( parent ); 97 addTo( parent );
98 } 98 }
99}; 99};
100 100
101 101
102PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 102PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
103 : QMainWindow( parent, name, fl ) { 103 : QMainWindow( parent, name, fl ) {
104 104
105 d = new PlayListWidgetPrivate; 105 d = new PlayListWidgetPrivate;
106 d->setDocumentUsed = FALSE; 106 d->setDocumentUsed = FALSE;
107 d->current = NULL; 107 d->current = NULL;
108 fromSetDocument = FALSE;
108// menuTimer = new QTimer( this ,"menu timer"), 109// menuTimer = new QTimer( this ,"menu timer"),
109// connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); 110// connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) );
110 111
111 setBackgroundMode( PaletteButton ); 112 setBackgroundMode( PaletteButton );
112 113
113 setCaption( tr("OpiePlayer") ); 114 setCaption( tr("OpiePlayer") );
114 setIcon( Resource::loadPixmap( "MPEGPlayer" ) ); 115 setIcon( Resource::loadPixmap( "MPEGPlayer" ) );
115 116
116 setToolBarsMovable( FALSE ); 117 setToolBarsMovable( FALSE );
117 118
118 // Create Toolbar 119 // Create Toolbar
119 QPEToolBar *toolbar = new QPEToolBar( this ); 120 QPEToolBar *toolbar = new QPEToolBar( this );
@@ -165,55 +166,68 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
165 scaleButton->addTo(pmView); 166 scaleButton->addTo(pmView);
166 167
167 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); 168 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton );
168 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); 169 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton );
169 170
170 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); 171 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton );
171 172
172 tabWidget = new QTabWidget( hbox6, "tabWidget" ); 173 tabWidget = new QTabWidget( hbox6, "tabWidget" );
173 tabWidget->setTabShape(QTabWidget::Triangular); 174 tabWidget->setTabShape(QTabWidget::Triangular);
174 175
175 QWidget *pTab; 176 QWidget *pTab;
176 pTab = new QWidget( tabWidget, "pTab" ); 177 pTab = new QWidget( tabWidget, "pTab" );
177 playlistView = new QListView( pTab, "Videoview" ); 178// playlistView = new QListView( pTab, "playlistview" );
178 playlistView->setMinimumSize(236,260); 179// playlistView->setMinimumSize(236,260);
179 tabWidget->insertTab( pTab,"Playlist"); 180 tabWidget->insertTab( pTab,"Playlist");
180 181
182
181 // Add the playlist area 183 // Add the playlist area
182 184
183 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); 185 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton );
184 d->playListFrame = vbox3; 186 d->playListFrame = vbox3;
185 d->playListFrame ->setMinimumSize(235,260); 187 d->playListFrame ->setMinimumSize(235,260);
186 188
187 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); 189 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton );
188 190
189 d->selectedFiles = new PlayListSelection( hbox2); 191 d->selectedFiles = new PlayListSelection( hbox2);
190 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); 192 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton );
191 193
194 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold);
195 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
196 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) );
197
198
192 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch 199 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch
193 new ToolButton( vbox1, tr( "Move Up" ), "mpegplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); 200 new ToolButton( vbox1, tr( "Move Up" ), "mpegplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) );
194 new ToolButton( vbox1, tr( "Remove" ), "mpegplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); 201 new ToolButton( vbox1, tr( "Remove" ), "mpegplayer/cut", d->selectedFiles, SLOT(removeSelected()) );
195 new ToolButton( vbox1, tr( "Move Down" ), "mpegplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); 202 new ToolButton( vbox1, tr( "Move Down" ), "mpegplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) );
196 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch 203 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch
197 204
198 QWidget *aTab; 205 QWidget *aTab;
199 aTab = new QWidget( tabWidget, "aTab" ); 206 aTab = new QWidget( tabWidget, "aTab" );
200 audioView = new QListView( aTab, "Audioview" ); 207 audioView = new QListView( aTab, "Audioview" );
201 audioView->setMinimumSize(233,260); 208 audioView->setMinimumSize(233,260);
202 audioView->addColumn( "Title",150); 209 audioView->addColumn( "Title",150);
203 audioView->addColumn("Size", 45); 210 audioView->addColumn("Size", 45);
204 audioView->addColumn("Media",35); 211 audioView->addColumn("Media",35);
205 audioView->setColumnAlignment(1, Qt::AlignRight); 212 audioView->setColumnAlignment(1, Qt::AlignRight);
206 audioView->setColumnAlignment(2, Qt::AlignRight); 213 audioView->setColumnAlignment(2, Qt::AlignRight);
214 audioView->setAllColumnsShowFocus(TRUE);
207 tabWidget->insertTab(aTab,"Audio"); 215 tabWidget->insertTab(aTab,"Audio");
216
217 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold);
218 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
219 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
220
221
208// audioView 222// audioView
209 Global::findDocuments(&files, "audio/*"); 223 Global::findDocuments(&files, "audio/*");
210 QListIterator<DocLnk> dit( files.children() ); 224 QListIterator<DocLnk> dit( files.children() );
211 QString storage; 225 QString storage;
212 for ( ; dit.current(); ++dit ) { 226 for ( ; dit.current(); ++dit ) {
213 QListViewItem * newItem; 227 QListViewItem * newItem;
214 if(dit.current()->file().find("/mnt/cf") != -1 ) storage="CF"; 228 if(dit.current()->file().find("/mnt/cf") != -1 ) storage="CF";
215 else if(dit.current()->file().find("/mnt/hda") != -1 ) storage="CF"; 229 else if(dit.current()->file().find("/mnt/hda") != -1 ) storage="CF";
216 else if(dit.current()->file().find("/mnt/card") != -1 ) storage="SD"; 230 else if(dit.current()->file().find("/mnt/card") != -1 ) storage="SD";
217 else storage="RAM"; 231 else storage="RAM";
218 if ( QFile( dit.current()->file()).exists() ) { 232 if ( QFile( dit.current()->file()).exists() ) {
219 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); 233 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage);
@@ -223,24 +237,28 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
223// videowidget 237// videowidget
224 238
225 QWidget *vTab; 239 QWidget *vTab;
226 vTab = new QWidget( tabWidget, "vTab" ); 240 vTab = new QWidget( tabWidget, "vTab" );
227 videoView = new QListView( vTab, "Videoview" ); 241 videoView = new QListView( vTab, "Videoview" );
228 videoView->setMinimumSize(233,260); 242 videoView->setMinimumSize(233,260);
229 243
230 videoView->addColumn("Title",150); 244 videoView->addColumn("Title",150);
231 videoView->addColumn("Size",45); 245 videoView->addColumn("Size",45);
232 videoView->addColumn("Media",35); 246 videoView->addColumn("Media",35);
233 videoView->setColumnAlignment(1, Qt::AlignRight); 247 videoView->setColumnAlignment(1, Qt::AlignRight);
234 videoView->setColumnAlignment(2, Qt::AlignRight); 248 videoView->setColumnAlignment(2, Qt::AlignRight);
249 videoView->setAllColumnsShowFocus(TRUE);
250 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold);
251 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
252 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
235 253
236 tabWidget->insertTab( vTab,"Video"); 254 tabWidget->insertTab( vTab,"Video");
237 255
238 Global::findDocuments(&vFiles, "video/*"); 256 Global::findDocuments(&vFiles, "video/*");
239 QListIterator<DocLnk> Vdit( vFiles.children() ); 257 QListIterator<DocLnk> Vdit( vFiles.children() );
240 for ( ; Vdit.current(); ++Vdit ) { 258 for ( ; Vdit.current(); ++Vdit ) {
241 if( Vdit.current()->file().find("/mnt/cf") != -1 ) storage="CF"; 259 if( Vdit.current()->file().find("/mnt/cf") != -1 ) storage="CF";
242 else if( Vdit.current()->file().find("/mnt/hda") != -1 ) storage="CF"; 260 else if( Vdit.current()->file().find("/mnt/hda") != -1 ) storage="CF";
243 else if( Vdit.current()->file().find("/mnt/card") != -1 ) storage="SD"; 261 else if( Vdit.current()->file().find("/mnt/card") != -1 ) storage="SD";
244 else storage="RAM"; 262 else storage="RAM";
245 QListViewItem * newItem; 263 QListViewItem * newItem;
246 if ( QFile( Vdit.current()->file()).exists() ) { 264 if ( QFile( Vdit.current()->file()).exists() ) {
@@ -252,26 +270,24 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
252//playlists list 270//playlists list
253 QWidget *LTab; 271 QWidget *LTab;
254 LTab = new QWidget( tabWidget, "LTab" ); 272 LTab = new QWidget( tabWidget, "LTab" );
255 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy 273 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy
256 playLists->setMinimumSize(233,260);; 274 playLists->setMinimumSize(233,260);;
257 tabWidget->insertTab(LTab,"Lists"); 275 tabWidget->insertTab(LTab,"Lists");
258 276
259 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); 277 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) );
260// connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); 278// connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) );
261 279
262 280
263// add the library area 281// add the library area
264 QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold );
265
266 282
267// connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), 283// connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)),
268// this, SLOT( fauxPlay( QListViewItem *) ) ); 284// this, SLOT( fauxPlay( QListViewItem *) ) );
269// connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), 285// connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)),
270// this, SLOT( fauxPlay( QListViewItem *)) ); 286// this, SLOT( fauxPlay( QListViewItem *)) );
271 287
272// connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); 288// connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) );
273// connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); 289// connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) );
274 290
275 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 291 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
276 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 292 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
277 293
@@ -410,73 +426,108 @@ void PlayListWidget::addAllMusicToList() {
410 426
411 427
412void PlayListWidget::addAllVideoToList() { 428void PlayListWidget::addAllVideoToList() {
413 DocLnkSet files; 429 DocLnkSet files;
414 Global::findDocuments(&files, "video/*"); 430 Global::findDocuments(&files, "video/*");
415 QListIterator<DocLnk> dit( files.children() ); 431 QListIterator<DocLnk> dit( files.children() );
416 for ( ; dit.current(); ++dit ) 432 for ( ; dit.current(); ++dit )
417 d->selectedFiles->addToSelection( **dit ); 433 d->selectedFiles->addToSelection( **dit );
418} 434}
419 435
420 436
421void PlayListWidget::setDocument(const QString& fileref) { 437void PlayListWidget::setDocument(const QString& fileref) {
438 fromSetDocument = TRUE;
422 if ( fileref.isNull() ) { 439 if ( fileref.isNull() ) {
423 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); 440 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) );
424 return; 441 return;
425 } 442 }
426// qDebug("setDocument"); 443// qDebug("setDocument "+fileref);
427 if(fileref.find("playlist",0,TRUE) == -1) { 444 if(fileref.find("playlist",0,TRUE) == -1) {
445 clearList();
428 addToSelection( DocLnk( fileref ) ); 446 addToSelection( DocLnk( fileref ) );
429 d->setDocumentUsed = TRUE; 447 d->setDocumentUsed = TRUE;
430 qApp->processEvents();
431 mediaPlayerState->setPlaying( FALSE ); 448 mediaPlayerState->setPlaying( FALSE );
432 qApp->processEvents(); 449 qApp->processEvents();
433 mediaPlayerState->setPlaying( TRUE ); 450 mediaPlayerState->setPlaying( TRUE );
434 d->selectedFiles->removeSelected( ); 451 qApp->processEvents();
435 } else { 452 setCaption("OpiePlayer");
453
454 } else { //is playlist
455 clearList();
436 loadList(DocLnk(fileref)); 456 loadList(DocLnk(fileref));
437 d->selectedFiles->first(); 457 d->selectedFiles->first();
438// mediaPlayerState->setPlaying( TRUE );
439// mediaPlayerState->setPlaying( FALSE );
440
441 } 458 }
442} 459}
443 460
444 461
445void PlayListWidget::setActiveWindow() { 462void PlayListWidget::setActiveWindow() {
446 // When we get raised we need to ensure that it switches views 463 // When we get raised we need to ensure that it switches views
447 char origView = mediaPlayerState->view(); 464 char origView = mediaPlayerState->view();
448 mediaPlayerState->setView( 'l' ); // invalidate 465 mediaPlayerState->setView( 'l' ); // invalidate
449 mediaPlayerState->setView( origView ); // now switch back 466 mediaPlayerState->setView( origView ); // now switch back
450} 467}
451 468
452 469
453void PlayListWidget::useSelectedDocument() { 470void PlayListWidget::useSelectedDocument() {
454 d->setDocumentUsed = FALSE; 471 d->setDocumentUsed = FALSE;
455} 472}
456 473
457 474
458const DocLnk *PlayListWidget::current() { 475const DocLnk *PlayListWidget::current() { // this is fugly
459 476
460// qDebug("in Playlist widget ::current"); 477// if( fromSetDocument) {
478// qDebug("from setDoc");
479// DocLnkSet files;
480// Global::findDocuments(&files, "video/*;audio/*");
481// QListIterator<DocLnk> dit( files.children() );
482// for ( ; dit.current(); ++dit ) {
483// if(dit.current()->linkFile() == setDocFileRef) {
484// qDebug(setDocFileRef);
485// return dit;
486// }
487// }
488// } else
489 switch (tabWidget->currentPageIndex()) {
490 case 0: //playlist
491 {
461 if ( mediaPlayerState->playlist() ) { 492 if ( mediaPlayerState->playlist() ) {
462 return d->selectedFiles->current(); 493 return d->selectedFiles->current();
463 } 494 }
464 else if ( d->setDocumentUsed && d->current ) { 495 else if ( d->setDocumentUsed && d->current ) {
465 return d->current; 496 return d->current;
466 } else { 497 } else {
467 return d->files->selected(); 498 return d->files->selected();
468 } 499 }
469} 500}
470 501 break;
502 case 1: { //audio
503 Global::findDocuments(&files, "audio/*");
504 QListIterator<DocLnk> dit( files.children() );
505 for ( ; dit.current(); ++dit ) {
506 if( dit.current()->name() == audioView->currentItem()->text(0))
507 return dit;
508 }
509 }
510 break;
511 case 2: { // video
512 Global::findDocuments(&vFiles, "video/*");
513 QListIterator<DocLnk> Vdit( vFiles.children() );
514 for ( ; Vdit.current(); ++Vdit ) {
515 if( Vdit.current()->name() == videoView->currentItem()->text(0))
516 return Vdit;
517 }
518 }
519 break;
520 };
521}
471 522
472bool PlayListWidget::prev() { 523bool PlayListWidget::prev() {
473 if ( mediaPlayerState->playlist() ) { 524 if ( mediaPlayerState->playlist() ) {
474 if ( mediaPlayerState->shuffled() ) { 525 if ( mediaPlayerState->shuffled() ) {
475 const DocLnk *cur = current(); 526 const DocLnk *cur = current();
476 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 527 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
477 for ( int i = 0; i < j; i++ ) { 528 for ( int i = 0; i < j; i++ ) {
478 if ( !d->selectedFiles->next() ) 529 if ( !d->selectedFiles->next() )
479 d->selectedFiles->first(); 530 d->selectedFiles->first();
480 } 531 }
481 if ( cur == current() ) 532 if ( cur == current() )
482 if ( !d->selectedFiles->next() ) 533 if ( !d->selectedFiles->next() )
@@ -560,53 +611,49 @@ void PlayListWidget::saveList() {
560 lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D 611 lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D
561 lnk.setIcon("mpegplayer/playlist2"); 612 lnk.setIcon("mpegplayer/playlist2");
562 lnk.setName( filename); //sets file name 613 lnk.setName( filename); //sets file name
563 if(!lnk.writeLink()) 614 if(!lnk.writeLink())
564 qDebug("Writing doclink did not work"); 615 qDebug("Writing doclink did not work");
565 } 616 }
566 Config config( "MediaPlayer" ); 617 Config config( "MediaPlayer" );
567 config.writeEntry("CurrentPlaylist",filename); 618 config.writeEntry("CurrentPlaylist",filename);
568 setCaption("OpiePlayer: "+filename); 619 setCaption("OpiePlayer: "+filename);
569 d->selectedFiles->first(); 620 d->selectedFiles->first();
570 if(fileDlg) 621 if(fileDlg)
571 delete fileDlg; 622 delete fileDlg;
572
573} 623}
574 624
575
576void PlayListWidget::loadList( const DocLnk & lnk) { 625void PlayListWidget::loadList( const DocLnk & lnk) {
577 QString name= lnk.name(); 626 QString name= lnk.name();
578// qDebug("currentList is "+name); 627// qDebug("currentList is "+name);
579 if( name.length()>1) { 628 if( name.length()>1) {
580 setCaption("OpiePlayer: "+name); 629 setCaption("OpiePlayer: "+name);
581// qDebug("load list "+ name+".playlist"); 630// qDebug("load list "+ name+".playlist");
582 clearList(); 631 clearList();
583 Config cfg( name+".playlist"); 632 Config cfg( name+".playlist");
584 readConfig(cfg); 633 readConfig(cfg);
585 tabWidget->setCurrentPage(0); 634 tabWidget->setCurrentPage(0);
586 Config config( "MediaPlayer" ); 635 Config config( "MediaPlayer" );
587 config.writeEntry("CurrentPlaylist", name); 636 config.writeEntry("CurrentPlaylist", name);
588 d->selectedFiles->first(); 637 d->selectedFiles->first();
589 } 638 }
590} 639}
591 640
592
593void PlayListWidget::setPlaylist( bool shown ) { 641void PlayListWidget::setPlaylist( bool shown ) {
594 if ( shown ) 642 if ( shown )
595 d->playListFrame->show(); 643 d->playListFrame->show();
596 else 644 else
597 d->playListFrame->hide(); 645 d->playListFrame->hide();
598} 646}
599 647
600
601void PlayListWidget::setView( char view ) { 648void PlayListWidget::setView( char view ) {
602 if ( view == 'l' ) 649 if ( view == 'l' )
603 showMaximized(); 650 showMaximized();
604 else 651 else
605 hide(); 652 hide();
606} 653}
607 654
608void PlayListWidget::addSelected() { 655void PlayListWidget::addSelected() {
609 656
610 switch (tabWidget->currentPageIndex()) { 657 switch (tabWidget->currentPageIndex()) {
611 case 0: //playlist 658 case 0: //playlist
612 break; 659 break;
@@ -695,90 +742,73 @@ void PlayListWidget::tabChanged(QWidget *widg) {
695 } 742 }
696 break; 743 break;
697 case 3: 744 case 3:
698 { 745 {
699 if( tbDeletePlaylist->isHidden()) 746 if( tbDeletePlaylist->isHidden())
700 tbDeletePlaylist->show(); 747 tbDeletePlaylist->show();
701 playLists->reread(); 748 playLists->reread();
702 } 749 }
703 break; 750 break;
704 }; 751 };
705} 752}
706 753
707/*
708 list is right clicked*/
709void PlayListWidget::fauxPlay(QListViewItem *it) {
710 754
711 switch (tabWidget->currentPageIndex()) { 755/*
712 case 0: //playlist 756 play button is pressed*/
713 break; 757void PlayListWidget::btnPlay(bool b) {
714 case 1: { //audio 758 mediaPlayerState->setPlaying(b);
715 QListIterator<DocLnk> dit( files.children() );
716 for ( ; dit.current(); ++dit ) {
717// qDebug(dit.current()->name());
718 if( dit.current()->name() == it->text(0)) {
719 d->selectedFiles->addToSelection( **dit );
720 }
721 }
722 } 759 }
760
761void PlayListWidget::deletePlaylist() {
762 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
763 (tr("You really want to delete\nthis playlist?")),
764 (tr("Yes")), (tr("No")), 0 )){
765 case 0: // Yes clicked,
766 QFile().remove(playLists->selected()->file());
767 QFile().remove(playLists->selected()->linkFile());
768 playLists->reread();
723 break; 769 break;
724 case 2: { // video 770 case 1: // Cancel
725 QListIterator<DocLnk> dit( vFiles.children() );
726 for ( ; dit.current(); ++dit ) {
727// qDebug(dit.current()->name());
728 if( dit.current()->name() == it->text(0)) {
729 d->selectedFiles->addToSelection( **dit );
730 }
731 }
732 }
733 break; 771 break;
734 }; 772 };
735 mediaPlayerState->setPlaying( TRUE ); 773
736// tabWidget->setCurrentPage(0);
737 d->selectedFiles->removeSelected();
738} 774}
739 775
740/* 776void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i)
741 play button is pressed*/
742void PlayListWidget::btnPlay(bool b) { // this is fugly
743 switch ( tabWidget->currentPageIndex()) {
744 case 0:
745 { 777 {
746 mediaPlayerState->setPlaying(b); 778 switch (mouse) {
747 }
748 break;
749 case 1: 779 case 1:
750 {
751 addToSelection( audioView->selectedItem() );
752 mediaPlayerState->setPlaying(b);
753 qApp->processEvents();
754 d->selectedFiles->removeSelected( );
755 tabWidget->setCurrentPage(1);
756 }
757 break; 780 break;
758 case 2: 781 case 2:{
759 { 782 QPopupMenu m;
760 addToSelection( videoView->selectedItem() ); 783 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
761 mediaPlayerState->setPlaying(b); 784 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
762 qApp->processEvents(); 785// m.insertSeparator();
763 d->selectedFiles->removeSelected( ); 786// m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
764 tabWidget->setCurrentPage(2); 787 m.exec( QCursor::pos() );
765 } 788 }
766 break; 789 break;
767 }; 790 };
768 791
769} 792}
770 793
771void PlayListWidget::deletePlaylist() { 794void PlayListWidget::playSelected()
772 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 795{
773 (tr("You really want to delete\nthis playlist?")), 796 btnPlay( TRUE);
774 (tr("Yes")), (tr("No")), 0 )){ 797}
775 case 0: // Yes clicked, 798
776 QFile().remove(playLists->selected()->file()); 799void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i)
777 QFile().remove(playLists->selected()->linkFile()); 800{
778 playLists->reread(); 801 switch (mouse) {
802 case 1:
779 break; 803 break;
780 case 1: // Cancel 804 case 2:{
805 QPopupMenu m;
806 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
807 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
808// m.insertSeparator();
809 m.exec( QCursor::pos() );
810 }
781 break; 811 break;
782 }; 812 };
783 813
784} 814}
diff --git a/core/multimedia/opieplayer/playlistwidget.h b/core/multimedia/opieplayer/playlistwidget.h
index e72551b..effc600 100644
--- a/core/multimedia/opieplayer/playlistwidget.h
+++ b/core/multimedia/opieplayer/playlistwidget.h
@@ -39,54 +39,59 @@ class QLabel;
39 39
40class PlayListWidget : public QMainWindow { 40class PlayListWidget : public QMainWindow {
41 Q_OBJECT 41 Q_OBJECT
42public: 42public:
43 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); 43 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 );
44 ~PlayListWidget(); 44 ~PlayListWidget();
45 QTabWidget * tabWidget; 45 QTabWidget * tabWidget;
46 QAction *fullScreenButton, *scaleButton; 46 QAction *fullScreenButton, *scaleButton;
47 DocLnkSet files; 47 DocLnkSet files;
48 DocLnkSet vFiles; 48 DocLnkSet vFiles;
49 QListView *audioView, *videoView, *playlistView; 49 QListView *audioView, *videoView, *playlistView;
50 QLabel *libString; 50 QLabel *libString;
51 bool fromSetDocument;
52 QString setDocFileRef;
51 // retrieve the current playlist entry (media file link) 53 // retrieve the current playlist entry (media file link)
52 const DocLnk *current(); 54 const DocLnk *current();
53 void useSelectedDocument(); 55 void useSelectedDocument();
54/* QTimer * menuTimer; */ 56/* QTimer * menuTimer; */
55 FileSelector* playLists; 57 FileSelector* playLists;
56 QPushButton *tbDeletePlaylist; 58 QPushButton *tbDeletePlaylist;
57public slots: 59public slots:
58 void setDocument( const QString& fileref ); 60 void setDocument( const QString& fileref );
59 void addToSelection( const DocLnk& ); // Add a media file to the playlist 61 void addToSelection( const DocLnk& ); // Add a media file to the playlist
60 void addToSelection( QListViewItem* ); // Add a media file to the playlist 62 void addToSelection( QListViewItem* ); // Add a media file to the playlist
61 void setActiveWindow(); // need to handle this to show the right view 63 void setActiveWindow(); // need to handle this to show the right view
62 void setPlaylist( bool ); // Show/Hide the playlist 64 void setPlaylist( bool ); // Show/Hide the playlist
63 void setView( char ); 65 void setView( char );
64 void clearList(); 66 void clearList();
65 void addAllToList(); 67 void addAllToList();
66 void addAllMusicToList(); 68 void addAllMusicToList();
67 void addAllVideoToList(); 69 void addAllVideoToList();
68 void saveList(); // Save the playlist 70 void saveList(); // Save the playlist
69 void loadList( const DocLnk &); // Load a playlist 71 void loadList( const DocLnk &); // Load a playlist
70 void playIt( QListViewItem *); 72 void playIt( QListViewItem *);
71 void fauxPlay(QListViewItem *); 73
72 void btnPlay(bool); 74 void btnPlay(bool);
73 void deletePlaylist(); 75 void deletePlaylist();
74 bool first(); 76 bool first();
75 bool last(); 77 bool last();
76 bool next(); 78 bool next();
77 bool prev(); 79 bool prev();
78 void addSelected(); 80 void addSelected();
79 void removeSelected(); 81 void removeSelected();
80 void tabChanged(QWidget*); 82 void tabChanged(QWidget*);
83 void viewPressed( int, QListViewItem *, const QPoint&, int);
84 void playlistViewPressed( int, QListViewItem *, const QPoint&, int);
85 void playSelected();
81/* void setFullScreen(); */ 86/* void setFullScreen(); */
82/* void setScaled(); */ 87/* void setScaled(); */
83protected: 88protected:
84/* void contentsMousePressEvent( QMouseEvent * e ); */ 89/* void contentsMousePressEvent( QMouseEvent * e ); */
85/* void contentsMouseReleaseEvent( QMouseEvent * e ); */ 90/* void contentsMouseReleaseEvent( QMouseEvent * e ); */
86 91
87private: 92private:
88 void initializeStates(); 93 void initializeStates();
89 void readConfig( Config& cfg ); 94 void readConfig( Config& cfg );
90 void writeConfig( Config& cfg ) const; 95 void writeConfig( Config& cfg ) const;
91 PlayListWidgetPrivate *d; // Private implementation data 96 PlayListWidgetPrivate *d; // Private implementation data
92 97
diff --git a/core/multimedia/opieplayer/videowidget.cpp b/core/multimedia/opieplayer/videowidget.cpp
index be838c4..bb5f9e8 100644
--- a/core/multimedia/opieplayer/videowidget.cpp
+++ b/core/multimedia/opieplayer/videowidget.cpp
@@ -218,25 +218,25 @@ void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
218} 218}
219 219
220 220
221void VideoWidget::mousePressEvent( QMouseEvent *event ) { 221void VideoWidget::mousePressEvent( QMouseEvent *event ) {
222 mouseMoveEvent( event ); 222 mouseMoveEvent( event );
223} 223}
224 224
225 225
226void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 226void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
227 if ( mediaPlayerState->fullscreen() ) { 227 if ( mediaPlayerState->fullscreen() ) {
228 mediaPlayerState->setFullscreen( FALSE ); 228 mediaPlayerState->setFullscreen( FALSE );
229 makeVisible(); 229 makeVisible();
230 } else { 230
231 mouseMoveEvent( event ); 231 mouseMoveEvent( event );
232 } 232 }
233} 233}
234 234
235 235
236void VideoWidget::makeVisible() { 236void VideoWidget::makeVisible() {
237 if ( mediaPlayerState->fullscreen() ) { 237 if ( mediaPlayerState->fullscreen() ) {
238 setBackgroundMode( QWidget::NoBackground ); 238 setBackgroundMode( QWidget::NoBackground );
239 showFullScreen(); 239 showFullScreen();
240 resize( qApp->desktop()->size() ); 240 resize( qApp->desktop()->size() );
241 slider->hide(); 241 slider->hide();
242 } else { 242 } else {
@@ -412,12 +412,60 @@ bool VideoWidget::playVideo() {
412 scaledHeight = h; 412 scaledHeight = h;
413 413
414 if ( result ) { 414 if ( result ) {
415 p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight ); 415 p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight );
416 } 416 }
417 417
418 } 418 }
419 419
420 return result; 420 return result;
421} 421}
422 422
423 423
424
425void VideoWidget::keyReleaseEvent( QKeyEvent *e)
426{
427 switch ( e->key() ) {
428////////////////////////////// Zaurus keys
429 case Key_Home:
430 break;
431 case Key_F9: //activity
432 break;
433 case Key_F10: //contacts
434 break;
435 case Key_F11: //menu
436 break;
437 case Key_F12: //home
438 break;
439 case Key_F13: //mail
440 break;
441 case Key_Space: {
442 if(mediaPlayerState->playing()) {
443 mediaPlayerState->setPlaying(FALSE);
444 } else {
445 mediaPlayerState->setPlaying(TRUE);
446 }
447 }
448 break;
449 case Key_Down:
450// toggleButton(6);
451// emit lessClicked();
452// emit lessReleased();
453// toggleButton(6);
454 break;
455 case Key_Up:
456// toggleButton(5);
457// emit moreClicked();
458// emit moreReleased();
459// toggleButton(5);
460 break;
461 case Key_Right:
462 mediaPlayerState->setNext();
463 break;
464 case Key_Left:
465 mediaPlayerState->setPrev();
466 break;
467 case Key_Escape:
468 break;
469
470 };
471}
diff --git a/core/multimedia/opieplayer/videowidget.h b/core/multimedia/opieplayer/videowidget.h
index cf13743..fe56ca1 100644
--- a/core/multimedia/opieplayer/videowidget.h
+++ b/core/multimedia/opieplayer/videowidget.h
@@ -58,24 +58,25 @@ public slots:
58 void setLength( long ); 58 void setLength( long );
59 void setView( char ); 59 void setView( char );
60 60
61signals: 61signals:
62 void sliderMoved( long ); 62 void sliderMoved( long );
63 63
64protected: 64protected:
65 void paintEvent( QPaintEvent *pe ); 65 void paintEvent( QPaintEvent *pe );
66 void mouseMoveEvent( QMouseEvent *event ); 66 void mouseMoveEvent( QMouseEvent *event );
67 void mousePressEvent( QMouseEvent *event ); 67 void mousePressEvent( QMouseEvent *event );
68 void mouseReleaseEvent( QMouseEvent *event ); 68 void mouseReleaseEvent( QMouseEvent *event );
69 void closeEvent( QCloseEvent *event ); 69 void closeEvent( QCloseEvent *event );
70 void keyReleaseEvent( QKeyEvent *e);
70 71
71private: 72private:
72 void paintButton( QPainter *p, int i ); 73 void paintButton( QPainter *p, int i );
73 void toggleButton( int ); 74 void toggleButton( int );
74 void setToggleButton( int, bool ); 75 void setToggleButton( int, bool );
75 76
76 QSlider *slider; 77 QSlider *slider;
77 QPixmap *pixmaps[3]; 78 QPixmap *pixmaps[3];
78 QImage *currentFrame; 79 QImage *currentFrame;
79 intscaledWidth; 80 intscaledWidth;
80 int scaledHeight; 81 int scaledHeight;
81}; 82};