summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer
Unidiff
Diffstat (limited to 'core/multimedia/opieplayer') (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/loopcontrol.cpp4
-rw-r--r--core/multimedia/opieplayer/loopcontrol_threaded.cpp4
-rw-r--r--core/multimedia/opieplayer/mediaplayer.cpp4
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp48
4 files changed, 30 insertions, 30 deletions
diff --git a/core/multimedia/opieplayer/loopcontrol.cpp b/core/multimedia/opieplayer/loopcontrol.cpp
index 82242a3..4ed5921 100644
--- a/core/multimedia/opieplayer/loopcontrol.cpp
+++ b/core/multimedia/opieplayer/loopcontrol.cpp
@@ -396,90 +396,90 @@ bool LoopControl::init( const QString& filename ) {
396 // qDebug("total samples %d", total_audio_samples); 396 // qDebug("total samples %d", total_audio_samples);
397 mediaPlayerState->setLength( total_audio_samples ); 397 mediaPlayerState->setLength( total_audio_samples );
398 398
399 freq = mediaPlayerState->curDecoder()->audioFrequency( astream ); 399 freq = mediaPlayerState->curDecoder()->audioFrequency( astream );
400 // qDebug( "LC- frequency = %d", freq ); 400 // qDebug( "LC- frequency = %d", freq );
401 401
402 audioSampleCounter = 0; 402 audioSampleCounter = 0;
403 int bits_per_sample; 403 int bits_per_sample;
404 if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibWavPlugin") ) { 404 if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibWavPlugin") ) {
405 bits_per_sample =(int) mediaPlayerState->curDecoder()->getTime(); 405 bits_per_sample =(int) mediaPlayerState->curDecoder()->getTime();
406 // qDebug("using stupid hack"); 406 // qDebug("using stupid hack");
407 } else { 407 } else {
408 bits_per_sample=0; 408 bits_per_sample=0;
409 } 409 }
410 410
411 audioDevice = new AudioDevice( freq, channels, bits_per_sample); 411 audioDevice = new AudioDevice( freq, channels, bits_per_sample);
412 audioBuffer = new char[ audioDevice->bufferSize() ]; 412 audioBuffer = new char[ audioDevice->bufferSize() ];
413 channels = audioDevice->channels(); 413 channels = audioDevice->channels();
414 414
415 //### must check which frequency is actually used. 415 //### must check which frequency is actually used.
416 static const int size = 1; 416 static const int size = 1;
417 short int buf[size]; 417 short int buf[size];
418 long samplesRead = 0; 418 long samplesRead = 0;
419 mediaPlayerState->curDecoder()->audioReadSamples( buf, channels, size, samplesRead, stream ); 419 mediaPlayerState->curDecoder()->audioReadSamples( buf, channels, size, samplesRead, stream );
420 } 420 }
421 421
422 if ( hasVideoChannel ) { 422 if ( hasVideoChannel ) {
423 total_video_frames = mediaPlayerState->curDecoder()->videoFrames( stream ); 423 total_video_frames = mediaPlayerState->curDecoder()->videoFrames( stream );
424 424
425 mediaPlayerState->setLength( total_video_frames ); 425 mediaPlayerState->setLength( total_video_frames );
426 426
427 framerate = mediaPlayerState->curDecoder()->videoFrameRate( stream ); 427 framerate = mediaPlayerState->curDecoder()->videoFrameRate( stream );
428 DecodeLoopDebug(( "Frame rate %g total %ld", framerate, total_video_frames )); 428 DecodeLoopDebug(( "Frame rate %g total %ld", framerate, total_video_frames ));
429 429
430 if ( framerate <= 1.0 ) { 430 if ( framerate <= 1.0 ) {
431 DecodeLoopDebug(( "Crazy frame rate, resetting to sensible" )); 431 DecodeLoopDebug(( "Crazy frame rate, resetting to sensible" ));
432 framerate = 25; 432 framerate = 25;
433 } 433 }
434 434
435 if ( total_video_frames == 1 ) { 435 if ( total_video_frames == 1 ) {
436 DecodeLoopDebug(( "Cannot seek to frame" )); 436 DecodeLoopDebug(( "Cannot seek to frame" ));
437 } 437 }
438 438
439 } 439 }
440 440
441 current_frame = 0; 441 current_frame = 0;
442 prev_frame = -1; 442 prev_frame = -1;
443 443
444 connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( setPosition( long ) ) ); 444 connect( mediaPlayerState, SIGNAL( positionChanged(long) ), this, SLOT( setPosition(long) ) );
445 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( setPaused( bool ) ) ); 445 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
446 446
447 audioMutex->unlock(); 447 audioMutex->unlock();
448 448
449 return TRUE; 449 return TRUE;
450} 450}
451 451
452 452
453void LoopControl::play() { 453void LoopControl::play() {
454 // qDebug("LC- play"); 454 // qDebug("LC- play");
455 mediaPlayerState->setPosition( 0); //uglyhack 455 mediaPlayerState->setPosition( 0); //uglyhack
456 456
457#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 457#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
458 if ( !disabledSuspendScreenSaver || previousSuspendMode != hasVideoChannel ) { 458 if ( !disabledSuspendScreenSaver || previousSuspendMode != hasVideoChannel ) {
459 disabledSuspendScreenSaver = TRUE; 459 disabledSuspendScreenSaver = TRUE;
460 previousSuspendMode = hasVideoChannel; 460 previousSuspendMode = hasVideoChannel;
461 // Stop the screen from blanking and power saving state 461 // Stop the screen from blanking and power saving state
462 QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) 462 QCopEnvelope("QPE/System", "setScreenSaverMode(int)" )
463 << ( hasVideoChannel ? QPEApplication::Disable : QPEApplication::DisableSuspend ); 463 << ( hasVideoChannel ? QPEApplication::Disable : QPEApplication::DisableSuspend );
464 } 464 }
465#endif 465#endif
466 466
467 playtime.start(); 467 playtime.start();
468 startTimers(); 468 startTimers();
469} 469}
470 470
471 471
472void LoopControl::setMute( bool on ) { 472void LoopControl::setMute( bool on ) {
473 if ( on != isMuted ) { 473 if ( on != isMuted ) {
474 isMuted = on; 474 isMuted = on;
475 if ( !on ) { 475 if ( !on ) {
476 // Force an update of the position 476 // Force an update of the position
477 mediaPlayerState->setPosition( mediaPlayerState->position() + 1 ); 477 mediaPlayerState->setPosition( mediaPlayerState->position() + 1 );
478 mediaPlayerState->setPosition( mediaPlayerState->position() - 1 ); 478 mediaPlayerState->setPosition( mediaPlayerState->position() - 1 );
479 // Resume playing audio 479 // Resume playing audio
480 moreAudio = TRUE; 480 moreAudio = TRUE;
481 } 481 }
482 } 482 }
483} 483}
484 484
485 485
diff --git a/core/multimedia/opieplayer/loopcontrol_threaded.cpp b/core/multimedia/opieplayer/loopcontrol_threaded.cpp
index 3796549..0a1fc17 100644
--- a/core/multimedia/opieplayer/loopcontrol_threaded.cpp
+++ b/core/multimedia/opieplayer/loopcontrol_threaded.cpp
@@ -536,89 +536,89 @@ bool LoopControl::init( const QString& filename ) {
536 536
537 if ( !total_audio_samples ) 537 if ( !total_audio_samples )
538 total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream ); 538 total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream );
539 539
540 mediaPlayerState->setLength( total_audio_samples ); 540 mediaPlayerState->setLength( total_audio_samples );
541 541
542 freq = mediaPlayerState->curDecoder()->audioFrequency( astream ); 542 freq = mediaPlayerState->curDecoder()->audioFrequency( astream );
543 DecodeLoopDebug(( "frequency = %d\n", freq )); 543 DecodeLoopDebug(( "frequency = %d\n", freq ));
544 544
545 audioSampleCounter = 0; 545 audioSampleCounter = 0;
546 546
547 static const int bytes_per_sample = 2; //16 bit 547 static const int bytes_per_sample = 2; //16 bit
548 548
549 audioDevice = new AudioDevice( freq, channels, bytes_per_sample ); 549 audioDevice = new AudioDevice( freq, channels, bytes_per_sample );
550 audioBuffer = new char[ audioDevice->bufferSize() ]; 550 audioBuffer = new char[ audioDevice->bufferSize() ];
551 channels = audioDevice->channels(); 551 channels = audioDevice->channels();
552 552
553 //### must check which frequency is actually used. 553 //### must check which frequency is actually used.
554 static const int size = 1; 554 static const int size = 1;
555 short int buf[size]; 555 short int buf[size];
556 long samplesRead = 0; 556 long samplesRead = 0;
557 mediaPlayerState->curDecoder()->audioReadSamples( buf, channels, size, samplesRead, stream ); 557 mediaPlayerState->curDecoder()->audioReadSamples( buf, channels, size, samplesRead, stream );
558 } 558 }
559 559
560 if ( hasVideoChannel ) { 560 if ( hasVideoChannel ) {
561 total_video_frames = mediaPlayerState->curDecoder()->videoFrames( stream ); 561 total_video_frames = mediaPlayerState->curDecoder()->videoFrames( stream );
562 562
563 mediaPlayerState->setLength( total_video_frames ); 563 mediaPlayerState->setLength( total_video_frames );
564 564
565 framerate = mediaPlayerState->curDecoder()->videoFrameRate( stream ); 565 framerate = mediaPlayerState->curDecoder()->videoFrameRate( stream );
566 DecodeLoopDebug(( "Frame rate %g total %ld", framerate, total_video_frames )); 566 DecodeLoopDebug(( "Frame rate %g total %ld", framerate, total_video_frames ));
567 567
568 if ( framerate <= 1.0 ) { 568 if ( framerate <= 1.0 ) {
569 DecodeLoopDebug(( "Crazy frame rate, resetting to sensible" )); 569 DecodeLoopDebug(( "Crazy frame rate, resetting to sensible" ));
570 framerate = 25; 570 framerate = 25;
571 } 571 }
572 572
573 if ( total_video_frames == 1 ) { 573 if ( total_video_frames == 1 ) {
574 DecodeLoopDebug(( "Cannot seek to frame" )); 574 DecodeLoopDebug(( "Cannot seek to frame" ));
575 } 575 }
576 576
577 } 577 }
578 578
579 videoMutex->lock(); 579 videoMutex->lock();
580 current_frame = 0; 580 current_frame = 0;
581 prev_frame = -1; 581 prev_frame = -1;
582 videoMutex->unlock(); 582 videoMutex->unlock();
583 583
584 connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( setPosition( long ) ) ); 584 connect( mediaPlayerState, SIGNAL( positionChanged(long) ), this, SLOT( setPosition(long) ) );
585 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( setPaused( bool ) ) ); 585 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
586 586
587 //setBackgroundColor( black ); 587 //setBackgroundColor( black );
588 return TRUE; 588 return TRUE;
589} 589}
590 590
591 591
592void LoopControl::play() { 592void LoopControl::play() {
593 593
594#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 594#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
595 if ( !disabledSuspendScreenSaver ) { 595 if ( !disabledSuspendScreenSaver ) {
596 disabledSuspendScreenSaver = TRUE; 596 disabledSuspendScreenSaver = TRUE;
597 // Stop the screen from blanking and power saving state 597 // Stop the screen from blanking and power saving state
598 QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) 598 QCopEnvelope("QPE/System", "setScreenSaverMode(int)" )
599 << ( hasVideoChannel ? QPEApplication::Disable : QPEApplication::DisableSuspend ); 599 << ( hasVideoChannel ? QPEApplication::Disable : QPEApplication::DisableSuspend );
600 } 600 }
601#endif 601#endif
602 602
603 //begin = clock(); 603 //begin = clock();
604 playtime.start(); 604 playtime.start();
605 startTimers(); 605 startTimers();
606 //updateGeometry(); 606 //updateGeometry();
607} 607}
608 608
609 609
610void LoopControl::setMute( bool on ) { 610void LoopControl::setMute( bool on ) {
611 if ( isMuted != on ) { 611 if ( isMuted != on ) {
612 isMuted = on; 612 isMuted = on;
613 if ( isMuted ) { 613 if ( isMuted ) {
614 } else { 614 } else {
615 int frame = current_frame; // mediaPlayerState->curDecoder()->videoGetFrame( stream ); 615 int frame = current_frame; // mediaPlayerState->curDecoder()->videoGetFrame( stream );
616 playtime.restart(); 616 playtime.restart();
617 playtime = playtime.addMSecs( -frame * 1000 / framerate ); 617 playtime = playtime.addMSecs( -frame * 1000 / framerate );
618 //begin = clock() - (double)frame * CLOCKS_PER_SEC / framerate; 618 //begin = clock() - (double)frame * CLOCKS_PER_SEC / framerate;
619 mediaPlayerState->curDecoder()->audioSetSample( frame*freq/framerate, stream ); 619 mediaPlayerState->curDecoder()->audioSetSample( frame*freq/framerate, stream );
620 } 620 }
621 } 621 }
622} 622}
623 623
624 624
diff --git a/core/multimedia/opieplayer/mediaplayer.cpp b/core/multimedia/opieplayer/mediaplayer.cpp
index b77708c..6c743ec 100644
--- a/core/multimedia/opieplayer/mediaplayer.cpp
+++ b/core/multimedia/opieplayer/mediaplayer.cpp
@@ -1,94 +1,94 @@
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 21
22#include <qmessagebox.h> 22#include <qmessagebox.h>
23 23
24#include "mediaplayer.h" 24#include "mediaplayer.h"
25#include "playlistwidget.h" 25#include "playlistwidget.h"
26#include "audiowidget.h" 26#include "audiowidget.h"
27#include "loopcontrol.h" 27#include "loopcontrol.h"
28#include "audiodevice.h" 28#include "audiodevice.h"
29 29
30#include "mediaplayerstate.h" 30#include "mediaplayerstate.h"
31 31
32 32
33extern AudioWidget *audioUI; 33extern AudioWidget *audioUI;
34extern PlayListWidget *playList; 34extern PlayListWidget *playList;
35extern LoopControl *loopControl; 35extern LoopControl *loopControl;
36extern MediaPlayerState *mediaPlayerState; 36extern MediaPlayerState *mediaPlayerState;
37 37
38 38
39MediaPlayer::MediaPlayer( QObject *parent, const char *name ) 39MediaPlayer::MediaPlayer( QObject *parent, const char *name )
40 : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { 40 : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) {
41 41
42// QPEApplication::grabKeyboard(); 42// QPEApplication::grabKeyboard();
43 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 43 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
44 44
45 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); 45 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
46 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); 46 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pauseCheck(bool) ) );
47 connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); 47 connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) );
48 connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); 48 connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) );
49 49
50 connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); 50 connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
51 connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); 51 connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
52 connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); 52 connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
53 connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); 53 connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
54} 54}
55 55
56 56
57MediaPlayer::~MediaPlayer() { 57MediaPlayer::~MediaPlayer() {
58 58
59} 59}
60 60
61 61
62void MediaPlayer::pauseCheck( bool b ) { 62void MediaPlayer::pauseCheck( bool b ) {
63 // Only pause if playing 63 // Only pause if playing
64 if ( b && !mediaPlayerState->playing() ) 64 if ( b && !mediaPlayerState->playing() )
65 mediaPlayerState->setPaused( FALSE ); 65 mediaPlayerState->setPaused( FALSE );
66} 66}
67 67
68 68
69void MediaPlayer::play() { 69void MediaPlayer::play() {
70 mediaPlayerState->setPlaying( FALSE ); 70 mediaPlayerState->setPlaying( FALSE );
71 mediaPlayerState->setPlaying( TRUE ); 71 mediaPlayerState->setPlaying( TRUE );
72} 72}
73 73
74 74
75void MediaPlayer::setPlaying( bool play ) { 75void MediaPlayer::setPlaying( bool play ) {
76 // qDebug("MediaPlayer setPlaying %d", play); 76 // qDebug("MediaPlayer setPlaying %d", play);
77 if ( !play ) { 77 if ( !play ) {
78 mediaPlayerState->setPaused( FALSE ); 78 mediaPlayerState->setPaused( FALSE );
79 loopControl->stop( FALSE ); 79 loopControl->stop( FALSE );
80 return; 80 return;
81 } 81 }
82 82
83 if ( mediaPlayerState->paused() ) { 83 if ( mediaPlayerState->paused() ) {
84 mediaPlayerState->setPaused( FALSE ); 84 mediaPlayerState->setPaused( FALSE );
85 return; 85 return;
86 } 86 }
87 // qDebug("about to ctrash"); 87 // qDebug("about to ctrash");
88 const DocLnk *playListCurrent = playList->current(); 88 const DocLnk *playListCurrent = playList->current();
89 89
90 if ( playListCurrent != NULL ) { 90 if ( playListCurrent != NULL ) {
91 loopControl->stop( TRUE ); 91 loopControl->stop( TRUE );
92 currentFile = playListCurrent; 92 currentFile = playListCurrent;
93 } 93 }
94 if ( currentFile == NULL ) { 94 if ( currentFile == NULL ) {
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index a359843..efb5df3 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -74,163 +74,163 @@ class PlayListWidgetPrivate {
74public: 74public:
75 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; 75 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove;
76 QFrame *playListFrame; 76 QFrame *playListFrame;
77 FileSelector *files; 77 FileSelector *files;
78 PlayListSelection *selectedFiles; 78 PlayListSelection *selectedFiles;
79 bool setDocumentUsed; 79 bool setDocumentUsed;
80 DocLnk *current; 80 DocLnk *current;
81}; 81};
82 82
83 83
84class ToolButton : public QToolButton { 84class ToolButton : public QToolButton {
85public: 85public:
86 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 )
87 : QToolButton( parent, name ) { 87 : QToolButton( parent, name ) {
88 setTextLabel( name ); 88 setTextLabel( name );
89 setPixmap( Resource::loadPixmap( icon ) ); 89 setPixmap( Resource::loadPixmap( icon ) );
90 setAutoRaise( TRUE ); 90 setAutoRaise( TRUE );
91 setFocusPolicy( QWidget::NoFocus ); 91 setFocusPolicy( QWidget::NoFocus );
92 setToggleButton( t ); 92 setToggleButton( t );
93 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); 93 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
94 QPEMenuToolFocusManager::manager()->addWidget( this ); 94 QPEMenuToolFocusManager::manager()->addWidget( this );
95 } 95 }
96}; 96};
97 97
98 98
99class MenuItem : public QAction { 99class MenuItem : public QAction {
100public: 100public:
101 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) 101 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot )
102 : QAction( text, QString::null, 0, 0 ) { 102 : QAction( text, QString::null, 0, 0 ) {
103 connect( this, SIGNAL( activated() ), handler, slot ); 103 connect( this, SIGNAL( activated() ), handler, slot );
104 addTo( parent ); 104 addTo( parent );
105 } 105 }
106}; 106};
107 107
108 108
109PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 109PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
110 : QMainWindow( parent, name, fl ) { 110 : QMainWindow( parent, name, fl ) {
111 111
112 d = new PlayListWidgetPrivate; 112 d = new PlayListWidgetPrivate;
113 d->setDocumentUsed = FALSE; 113 d->setDocumentUsed = FALSE;
114 d->current = NULL; 114 d->current = NULL;
115 fromSetDocument = FALSE; 115 fromSetDocument = FALSE;
116 insanityBool=FALSE; 116 insanityBool=FALSE;
117 audioScan = FALSE; 117 audioScan = FALSE;
118 videoScan = FALSE; 118 videoScan = FALSE;
119// menuTimer = new QTimer( this ,"menu timer"), 119// menuTimer = new QTimer( this ,"menu timer"),
120// connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); 120// connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) );
121 channel = new QCopChannel( "QPE/Application/opieplayer", this ); 121 channel = new QCopChannel( "QPE/Application/opieplayer", this );
122 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 122 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
123 this, SLOT( qcopReceive(const QCString&, const QByteArray&)) ); 123 this, SLOT( qcopReceive(const QCString&,const QByteArray&)) );
124 124
125 setBackgroundMode( PaletteButton ); 125 setBackgroundMode( PaletteButton );
126 126
127 setCaption( tr("OpiePlayer") ); 127 setCaption( tr("OpiePlayer") );
128 setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); 128 setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) );
129 129
130 setToolBarsMovable( FALSE ); 130 setToolBarsMovable( FALSE );
131 131
132 // Create Toolbar 132 // Create Toolbar
133 QToolBar *toolbar = new QToolBar( this ); 133 QToolBar *toolbar = new QToolBar( this );
134 toolbar->setHorizontalStretchable( TRUE ); 134 toolbar->setHorizontalStretchable( TRUE );
135 135
136 // Create Menubar 136 // Create Menubar
137 QMenuBar *menu = new QMenuBar( toolbar ); 137 QMenuBar *menu = new QMenuBar( toolbar );
138 menu->setMargin( 0 ); 138 menu->setMargin( 0 );
139 139
140 QToolBar *bar = new QToolBar( this ); 140 QToolBar *bar = new QToolBar( this );
141 bar->setLabel( tr( "Play Operations" ) ); 141 bar->setLabel( tr( "Play Operations" ) );
142// 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",
143// this , SLOT( addSelected()) ); 143// this , SLOT( addSelected()) );
144 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); 144 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close");
145 tbDeletePlaylist->setFlat(TRUE); 145 tbDeletePlaylist->setFlat(TRUE);
146 146
147 tbDeletePlaylist->setFixedSize(20,20); 147 tbDeletePlaylist->setFixedSize(20,20);
148 148
149 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",
150 this , SLOT(addSelected()) ); 150 this , SLOT(addSelected()) );
151 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",
152 this , SLOT(removeSelected()) ); 152 this , SLOT(removeSelected()) );
153// 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 );
154 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", 154 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play",
155 this , SLOT( btnPlay(bool) ), TRUE ); 155 this , SLOT( btnPlay(bool) ), TRUE );
156 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", 156 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle",
157 mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); 157 mediaPlayerState, SLOT(setShuffled(bool)), TRUE );
158 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", 158 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop",
159 mediaPlayerState, SLOT(setLooping(bool)), TRUE ); 159 mediaPlayerState, SLOT(setLooping(bool)), TRUE );
160 tbDeletePlaylist->hide(); 160 tbDeletePlaylist->hide();
161 161
162 QPopupMenu *pmPlayList = new QPopupMenu( this ); 162 QPopupMenu *pmPlayList = new QPopupMenu( this );
163 menu->insertItem( tr( "File" ), pmPlayList ); 163 menu->insertItem( tr( "File" ), pmPlayList );
164 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 164 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
165 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); 165 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) );
166 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); 166 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) );
167 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); 167 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) );
168 pmPlayList->insertSeparator(-1); 168 pmPlayList->insertSeparator(-1);
169 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); 169 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) );
170 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); 170 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) );
171 pmPlayList->insertSeparator(-1); 171 pmPlayList->insertSeparator(-1);
172 new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); 172 new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) );
173 new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); 173 new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) );
174 174
175 QPopupMenu *pmView = new QPopupMenu( this ); 175 QPopupMenu *pmView = new QPopupMenu( this );
176 menu->insertItem( tr( "View" ), pmView ); 176 menu->insertItem( tr( "View" ), pmView );
177 177
178 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);
179 fullScreenButton->addTo(pmView); 179 fullScreenButton->addTo(pmView);
180 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);
181 scaleButton->addTo(pmView); 181 scaleButton->addTo(pmView);
182 182
183 183
184 skinsMenu = new QPopupMenu( this ); 184 skinsMenu = new QPopupMenu( this );
185 menu->insertItem( tr( "Skins" ), skinsMenu ); 185 menu->insertItem( tr( "Skins" ), skinsMenu );
186 skinsMenu->isCheckable(); 186 skinsMenu->isCheckable();
187 connect( skinsMenu, SIGNAL( activated( int ) ) , 187 connect( skinsMenu, SIGNAL( activated(int) ) ,
188 this, SLOT( skinsMenuActivated( int ) ) ); 188 this, SLOT( skinsMenuActivated(int) ) );
189 populateSkinsMenu(); 189 populateSkinsMenu();
190 190
191 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); 191 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton );
192 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); 192 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton );
193 193
194 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); 194 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton );
195 195
196 tabWidget = new QTabWidget( hbox6, "tabWidget" ); 196 tabWidget = new QTabWidget( hbox6, "tabWidget" );
197// tabWidget->setTabShape(QTabWidget::Triangular); 197// tabWidget->setTabShape(QTabWidget::Triangular);
198 198
199 QWidget *pTab; 199 QWidget *pTab;
200 pTab = new QWidget( tabWidget, "pTab" ); 200 pTab = new QWidget( tabWidget, "pTab" );
201// playlistView = new QListView( pTab, "playlistview" ); 201// playlistView = new QListView( pTab, "playlistview" );
202// playlistView->setMinimumSize(236,260); 202// playlistView->setMinimumSize(236,260);
203 tabWidget->insertTab( pTab,"Playlist"); 203 tabWidget->insertTab( pTab,"Playlist");
204 204
205 205
206 // Add the playlist area 206 // Add the playlist area
207 207
208 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); 208 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton );
209 d->playListFrame = vbox3; 209 d->playListFrame = vbox3;
210 210
211 QGridLayout *layoutF = new QGridLayout( pTab ); 211 QGridLayout *layoutF = new QGridLayout( pTab );
212 layoutF->setSpacing( 2); 212 layoutF->setSpacing( 2);
213 layoutF->setMargin( 2); 213 layoutF->setMargin( 2);
214 layoutF->addMultiCellWidget( d->playListFrame , 0, 0, 0, 1 ); 214 layoutF->addMultiCellWidget( d->playListFrame , 0, 0, 0, 1 );
215 215
216 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); 216 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton );
217 217
218 d->selectedFiles = new PlayListSelection( hbox2); 218 d->selectedFiles = new PlayListSelection( hbox2);
219 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); 219 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton );
220 220
221 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); 221 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold);
222 222
223 223
224 224
225 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch 225 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch
226 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()) );
227 new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); 227 new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) );
228 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()) );
229 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch 229 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch
230 230
231 QWidget *aTab; 231 QWidget *aTab;
232 aTab = new QWidget( tabWidget, "aTab" ); 232 aTab = new QWidget( tabWidget, "aTab" );
233 audioView = new QListView( aTab, "Audioview" ); 233 audioView = new QListView( aTab, "Audioview" );
234 234
235 QGridLayout *layoutA = new QGridLayout( aTab ); 235 QGridLayout *layoutA = new QGridLayout( aTab );
236 layoutA->setSpacing( 2); 236 layoutA->setSpacing( 2);
@@ -251,128 +251,128 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
251 audioView->setSorting( 3, TRUE ); 251 audioView->setSorting( 3, TRUE );
252 252
253 tabWidget->insertTab(aTab,tr("Audio")); 253 tabWidget->insertTab(aTab,tr("Audio"));
254 254
255 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); 255 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold);
256 256
257// audioView 257// audioView
258// populateAudioView(); 258// populateAudioView();
259// videowidget 259// videowidget
260 260
261 QWidget *vTab; 261 QWidget *vTab;
262 vTab = new QWidget( tabWidget, "vTab" ); 262 vTab = new QWidget( tabWidget, "vTab" );
263 videoView = new QListView( vTab, "Videoview" ); 263 videoView = new QListView( vTab, "Videoview" );
264 264
265 QGridLayout *layoutV = new QGridLayout( vTab ); 265 QGridLayout *layoutV = new QGridLayout( vTab );
266 layoutV->setSpacing( 2); 266 layoutV->setSpacing( 2);
267 layoutV->setMargin( 2); 267 layoutV->setMargin( 2);
268 layoutV->addMultiCellWidget( videoView, 0, 0, 0, 1 ); 268 layoutV->addMultiCellWidget( videoView, 0, 0, 0, 1 );
269 269
270 videoView->addColumn(tr("Title"),-1); 270 videoView->addColumn(tr("Title"),-1);
271 videoView->addColumn(tr("Size"),-1); 271 videoView->addColumn(tr("Size"),-1);
272 videoView->addColumn(tr("Media"),-1); 272 videoView->addColumn(tr("Media"),-1);
273 videoView->addColumn(tr( "Path" ), -1 ); 273 videoView->addColumn(tr( "Path" ), -1 );
274 videoView->setColumnAlignment(1, Qt::AlignRight); 274 videoView->setColumnAlignment(1, Qt::AlignRight);
275 videoView->setColumnAlignment(2, Qt::AlignRight); 275 videoView->setColumnAlignment(2, Qt::AlignRight);
276 videoView->setAllColumnsShowFocus(TRUE); 276 videoView->setAllColumnsShowFocus(TRUE);
277 videoView->setMultiSelection( TRUE ); 277 videoView->setMultiSelection( TRUE );
278 videoView->setSelectionMode( QListView::Extended); 278 videoView->setSelectionMode( QListView::Extended);
279 279
280 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); 280 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold);
281 281
282 tabWidget->insertTab( vTab,tr("Video")); 282 tabWidget->insertTab( vTab,tr("Video"));
283 283
284 QWidget *LTab; 284 QWidget *LTab;
285 LTab = new QWidget( tabWidget, "LTab" ); 285 LTab = new QWidget( tabWidget, "LTab" );
286 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);
287 287
288 QGridLayout *layoutL = new QGridLayout( LTab ); 288 QGridLayout *layoutL = new QGridLayout( LTab );
289 layoutL->setSpacing( 2); 289 layoutL->setSpacing( 2);
290 layoutL->setMargin( 2); 290 layoutL->setMargin( 2);
291 layoutL->addMultiCellWidget( playLists, 0, 0, 0, 1 ); 291 layoutL->addMultiCellWidget( playLists, 0, 0, 0, 1 );
292 292
293 tabWidget->insertTab(LTab,tr("Lists")); 293 tabWidget->insertTab(LTab,tr("Lists"));
294 294
295 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); 295 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist()));
296 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); 296 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) );
297 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); 297 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) );
298 298
299 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 299 connect( d->selectedFiles, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)),
300 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); 300 this,SLOT( playlistViewPressed(int,QListViewItem*,const QPoint&,int)) );
301 301
302 302
303///audioView 303///audioView
304 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 304 connect( audioView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)),
305 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 305 this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int)) );
306 306
307 connect( audioView, SIGNAL( returnPressed( QListViewItem *)), 307 connect( audioView, SIGNAL( returnPressed(QListViewItem*)),
308 this,SLOT( playIt( QListViewItem *)) ); 308 this,SLOT( playIt(QListViewItem*)) );
309 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 309 connect( audioView, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( addToSelection(QListViewItem*) ) );
310 310
311 311
312//videoView 312//videoView
313 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 313 connect( videoView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)),
314 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 314 this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int)) );
315 connect( videoView, SIGNAL( returnPressed( QListViewItem *)), 315 connect( videoView, SIGNAL( returnPressed(QListViewItem*)),
316 this,SLOT( playIt( QListViewItem *)) ); 316 this,SLOT( playIt(QListViewItem*)) );
317 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 317 connect( videoView, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( addToSelection(QListViewItem*) ) );
318 318
319//playlists 319//playlists
320 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); 320 connect( playLists, SIGNAL( fileSelected(const DocLnk&) ), this, SLOT( loadList(const DocLnk&) ) );
321 321
322 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); 322 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*)));
323 323
324 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); 324 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), d->tbPlay, SLOT( setOn(bool) ) );
325 325
326 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); 326 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), d->tbLoop, SLOT( setOn(bool) ) );
327 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); 327 connect( mediaPlayerState, SIGNAL( shuffledToggled(bool) ), d->tbShuffle, SLOT( setOn(bool) ) );
328 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); 328 connect( mediaPlayerState, SIGNAL( playlistToggled(bool) ), this, SLOT( setPlaylist(bool) ) );
329 329
330 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); 330 connect( d->selectedFiles, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( playIt(QListViewItem*) ) );
331 331
332 setCentralWidget( vbox5 ); 332 setCentralWidget( vbox5 );
333 333
334 Config cfg( "OpiePlayer" ); 334 Config cfg( "OpiePlayer" );
335 readConfig( cfg ); 335 readConfig( cfg );
336 336
337 currentPlayList = cfg.readEntry("CurrentPlaylist","default"); 337 currentPlayList = cfg.readEntry("CurrentPlaylist","default");
338 loadList(DocLnk( currentPlayList)); 338 loadList(DocLnk( currentPlayList));
339 setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlayList))); 339 setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlayList)));
340 340
341 initializeStates(); 341 initializeStates();
342} 342}
343 343
344 344
345PlayListWidget::~PlayListWidget() { 345PlayListWidget::~PlayListWidget() {
346 Config cfg( "OpiePlayer" ); 346 Config cfg( "OpiePlayer" );
347 writeConfig( cfg ); 347 writeConfig( cfg );
348 348
349 if ( d->current ) 349 if ( d->current )
350 delete d->current; 350 delete d->current;
351 if(d) delete d; 351 if(d) delete d;
352} 352}
353 353
354 354
355void PlayListWidget::initializeStates() { 355void PlayListWidget::initializeStates() {
356 356
357 d->tbPlay->setOn( mediaPlayerState->playing() ); 357 d->tbPlay->setOn( mediaPlayerState->playing() );
358 d->tbLoop->setOn( mediaPlayerState->looping() ); 358 d->tbLoop->setOn( mediaPlayerState->looping() );
359 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 359 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
360 setPlaylist( true); 360 setPlaylist( true);
361} 361}
362 362
363 363
364void PlayListWidget::readConfig( Config& cfg ) { 364void PlayListWidget::readConfig( Config& cfg ) {
365 cfg.setGroup("PlayList"); 365 cfg.setGroup("PlayList");
366 QString currentString = cfg.readEntry("current", "" ); 366 QString currentString = cfg.readEntry("current", "" );
367 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 367 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
368 for ( int i = 0; i < noOfFiles; i++ ) { 368 for ( int i = 0; i < noOfFiles; i++ ) {
369 QString entryName; 369 QString entryName;
370 entryName.sprintf( "File%i", i + 1 ); 370 entryName.sprintf( "File%i", i + 1 );
371 QString linkFile = cfg.readEntry( entryName ); 371 QString linkFile = cfg.readEntry( entryName );
372 DocLnk lnk( linkFile ); 372 DocLnk lnk( linkFile );
373 if ( lnk.isValid() ) { 373 if ( lnk.isValid() ) {
374 d->selectedFiles->addToSelection( lnk ); 374 d->selectedFiles->addToSelection( lnk );
375 } 375 }
376 } 376 }
377 d->selectedFiles->setSelectedItem( currentString); 377 d->selectedFiles->setSelectedItem( currentString);
378} 378}
@@ -895,97 +895,97 @@ void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoi
895 case 1: 895 case 1:
896 896
897 break; 897 break;
898 case 2:{ 898 case 2:{
899 QPopupMenu m; 899 QPopupMenu m;
900 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 900 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
901 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 901 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
902 // m.insertSeparator(); 902 // m.insertSeparator();
903 // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 903 // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
904 m.exec( QCursor::pos() ); 904 m.exec( QCursor::pos() );
905 } 905 }
906 break; 906 break;
907 }; 907 };
908 908
909} 909}
910 910
911void PlayListWidget::listDelete() { 911void PlayListWidget::listDelete() {
912 Config cfg( "OpiePlayer" ); 912 Config cfg( "OpiePlayer" );
913 cfg.setGroup("PlayList"); 913 cfg.setGroup("PlayList");
914 currentPlayList = cfg.readEntry("CurrentPlaylist",""); 914 currentPlayList = cfg.readEntry("CurrentPlaylist","");
915 QString file; 915 QString file;
916 // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 916 // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
917 switch ( tabWidget->currentPageIndex()) { 917 switch ( tabWidget->currentPageIndex()) {
918 case 0: 918 case 0:
919 break; 919 break;
920 case 1: 920 case 1:
921 { 921 {
922 file = audioView->currentItem()->text(0); 922 file = audioView->currentItem()->text(0);
923 QListIterator<DocLnk> Pdit( files.children() ); 923 QListIterator<DocLnk> Pdit( files.children() );
924 for ( ; Pdit.current(); ++Pdit ) { 924 for ( ; Pdit.current(); ++Pdit ) {
925 if( Pdit.current()->name() == file) { 925 if( Pdit.current()->name() == file) {
926 LnkProperties prop( Pdit.current() ); 926 LnkProperties prop( Pdit.current() );
927 QPEApplication::execDialog( &prop ); 927 QPEApplication::execDialog( &prop );
928 } 928 }
929 } 929 }
930 populateAudioView(); 930 populateAudioView();
931 } 931 }
932 break; 932 break;
933 case 2: 933 case 2:
934 { 934 {
935 // file = videoView->selectedItem()->text(0); 935 // file = videoView->selectedItem()->text(0);
936 // for ( int i = 0; i < noOfFiles; i++ ) { 936 // for ( int i = 0; i < noOfFiles; i++ ) {
937 // QString entryName; 937 // QString entryName;
938 // entryName.sprintf( "File%i", i + 1 ); 938 // entryName.sprintf( "File%i", i + 1 );
939 // QString linkFile = cfg.readEntry( entryName ); 939 // QString linkFile = cfg.readEntry( entryName );
940 // AppLnk lnk( AppLnk(linkFile)); 940 // AppLnk lnk( AppLnk(linkFile));
941 // if( lnk.name() == file ) { 941 // if( lnk.name() == file ) {
942 // LnkProperties prop( &lnk); 942 // LnkProperties prop( &lnk);
943 // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); 943 // // connect(&prop, SIGNAL(select(const AppLnk*)), this, SLOT(externalSelected(const AppLnk*)));
944 // prop.showMaximized(); 944 // prop.showMaximized();
945 // prop.exec(); 945 // prop.exec();
946 // } 946 // }
947 // } 947 // }
948 } 948 }
949 break; 949 break;
950 }; 950 };
951} 951}
952 952
953void PlayListWidget::scanForAudio() { 953void PlayListWidget::scanForAudio() {
954 // qDebug("scan for audio"); 954 // qDebug("scan for audio");
955 files.detachChildren(); 955 files.detachChildren();
956 QListIterator<DocLnk> sdit( files.children() ); 956 QListIterator<DocLnk> sdit( files.children() );
957 for ( ; sdit.current(); ++sdit ) { 957 for ( ; sdit.current(); ++sdit ) {
958 delete sdit.current(); 958 delete sdit.current();
959 } 959 }
960 Global::findDocuments( &files, audioMimes); 960 Global::findDocuments( &files, audioMimes);
961 audioScan = true; 961 audioScan = true;
962} 962}
963void PlayListWidget::scanForVideo() { 963void PlayListWidget::scanForVideo() {
964 // qDebug("scan for video"); 964 // qDebug("scan for video");
965 vFiles.detachChildren(); 965 vFiles.detachChildren();
966 QListIterator<DocLnk> sdit( vFiles.children() ); 966 QListIterator<DocLnk> sdit( vFiles.children() );
967 for ( ; sdit.current(); ++sdit ) { 967 for ( ; sdit.current(); ++sdit ) {
968 delete sdit.current(); 968 delete sdit.current();
969 } 969 }
970 Global::findDocuments(&vFiles, "video/*"); 970 Global::findDocuments(&vFiles, "video/*");
971 videoScan = true; 971 videoScan = true;
972} 972}
973 973
974void PlayListWidget::populateAudioView() { 974void PlayListWidget::populateAudioView() {
975 975
976 audioView->clear(); 976 audioView->clear();
977 StorageInfo storageInfo; 977 StorageInfo storageInfo;
978 const QList<FileSystem> &fs = storageInfo.fileSystems(); 978 const QList<FileSystem> &fs = storageInfo.fileSystems();
979 if(!audioScan) scanForAudio(); 979 if(!audioScan) scanForAudio();
980 980
981 QListIterator<DocLnk> dit( files.children() ); 981 QListIterator<DocLnk> dit( files.children() );
982 QListIterator<FileSystem> it ( fs ); 982 QListIterator<FileSystem> it ( fs );
983 983
984 QString storage; 984 QString storage;
985 for ( ; dit.current(); ++dit ) { 985 for ( ; dit.current(); ++dit ) {
986 for( ; it.current(); ++it ){ 986 for( ; it.current(); ++it ){
987 const QString name = (*it)->name(); 987 const QString name = (*it)->name();
988 const QString path = (*it)->path(); 988 const QString path = (*it)->path();
989 if(dit.current()->file().find(path) != -1 ) storage=name; 989 if(dit.current()->file().find(path) != -1 ) storage=name;
990 } 990 }
991 991