From 22e232bdb4bae5e28013a4d14bfda3c068827557 Mon Sep 17 00:00:00 2001 From: simon Date: Mon, 02 Dec 2002 23:31:57 +0000 Subject: - yay, last singleton gone. global playList variable is no more :) --- diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index f6e6086..b573c45 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp @@ -87,9 +87,9 @@ static void changeTextColor( QWidget *w ) { static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); -AudioWidget::AudioWidget( MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : +AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : - MediaWidget( mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { + MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { setCaption( tr("OpiePlayer") ); diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h index f092699..52a358c 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.h +++ b/noncore/multimedia/opieplayer2/audiowidget.h @@ -52,7 +52,7 @@ class QPixmap; class AudioWidget : public MediaWidget { Q_OBJECT public: - AudioWidget( MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); + AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); ~AudioWidget(); void setTickerText( const QString &text ) { songInfo.setText( text ); } public slots: diff --git a/noncore/multimedia/opieplayer2/main.cpp b/noncore/multimedia/opieplayer2/main.cpp index 7fc7b94..ffc7cb6 100644 --- a/noncore/multimedia/opieplayer2/main.cpp +++ b/noncore/multimedia/opieplayer2/main.cpp @@ -4,16 +4,13 @@ #include "playlistwidget.h" #include "mediaplayer.h" -PlayListWidget *playList; - int main(int argc, char **argv) { QPEApplication a(argc,argv); MediaPlayerState st( 0, "mediaPlayerState" ); PlayListWidget pl( st, 0, "playList" ); - playList = &pl; pl.showMaximized(); - MediaPlayer mp( st, 0, "mediaPlayer" ); + MediaPlayer mp( pl, st, 0, "mediaPlayer" ); QObject::connect( &pl, SIGNAL( skinSelected() ), &mp, SLOT( recreateAudioAndVideoWidgets() ) ); diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index a9c74c4..8acc488 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp @@ -24,14 +24,12 @@ #include -extern VideoWidget *videoUI; -extern PlayListWidget *playList; #define FBIOBLANK 0x4611 -MediaPlayer::MediaPlayer( MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) - : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ) { +MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) + : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) { audioUI = 0; videoUI = 0; @@ -39,7 +37,7 @@ MediaPlayer::MediaPlayer( MediaPlayerState &_mediaPlayerState, QObject *parent, recreateAudioAndVideoWidgets(); fd=-1;fl=-1; - playList->setCaption( tr( "OpiePlayer: Initializating" ) ); + playList.setCaption( tr( "OpiePlayer: Initializating" ) ); qApp->processEvents(); // QPEApplication::grabKeyboard(); // EVIL @@ -57,7 +55,7 @@ MediaPlayer::MediaPlayer( MediaPlayerState &_mediaPlayerState, QObject *parent, Config cfg( "OpiePlayer" ); cfg.setGroup("PlayList"); QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); - playList->setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() ); + playList.setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() ); } MediaPlayer::~MediaPlayer() { @@ -87,7 +85,7 @@ void MediaPlayer::setPlaying( bool play ) { } QString tickerText, time, fileName; - if ( playList->currentTab() != PlayListWidget::CurrentPlayList ) { + if ( playList.currentTab() != PlayListWidget::CurrentPlayList ) { //if playing in file list.. play in a different way // random and looping settings enabled causes problems here, // since there is no selected file in the playlist, but a selected file in the file list, @@ -100,7 +98,7 @@ void MediaPlayer::setPlaying( bool play ) { mediaPlayerState.setShuffled( false ); } - PlayListWidget::Entry playListEntry = playList->currentEntry(); + PlayListWidget::Entry playListEntry = playList.currentEntry(); fileName = playListEntry.name; xineControl->play( playListEntry.file ); @@ -126,11 +124,11 @@ void MediaPlayer::setPlaying( bool play ) { void MediaPlayer::prev() { - if( playList->currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist - if ( playList->prev() ) { + if( playList.currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist + if ( playList.prev() ) { play(); } else if ( mediaPlayerState.isLooping() ) { - if ( playList->last() ) { + if ( playList.last() ) { play(); } } else { @@ -142,11 +140,11 @@ void MediaPlayer::prev() { void MediaPlayer::next() { - if(playList->currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist - if ( playList->next() ) { + if(playList.currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist + if ( playList.next() ) { play(); } else if ( mediaPlayerState.isLooping() ) { - if ( playList->first() ) { + if ( playList.first() ) { play(); } } else { @@ -339,7 +337,7 @@ void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { void MediaPlayer::cleanUp() {// this happens on closing Config cfg( "OpiePlayer" ); mediaPlayerState.writeConfig( cfg ); - playList->writeDefaultPlaylist( ); + playList.writeDefaultPlaylist( ); // QPEApplication::grabKeyboard(); // QPEApplication::ungrabKeyboard(); @@ -350,8 +348,8 @@ void MediaPlayer::recreateAudioAndVideoWidgets() delete xineControl; delete audioUI; delete videoUI; - audioUI = new AudioWidget( mediaPlayerState, 0, "audioUI" ); - videoUI = new VideoWidget( mediaPlayerState, 0, "videoUI" ); + audioUI = new AudioWidget( playList, mediaPlayerState, 0, "audioUI" ); + videoUI = new VideoWidget( playList, mediaPlayerState, 0, "videoUI" ); connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); diff --git a/noncore/multimedia/opieplayer2/mediaplayer.h b/noncore/multimedia/opieplayer2/mediaplayer.h index 0d6f722..dc306c4 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.h +++ b/noncore/multimedia/opieplayer2/mediaplayer.h @@ -39,6 +39,8 @@ #include "xinecontrol.h" +#include "playlistwidget.h" + class DocLnk; class VolumeControl; class MediaPlayerState; @@ -48,7 +50,7 @@ class VideoWidget; class MediaPlayer : public QObject { Q_OBJECT public: - MediaPlayer( MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ); + MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ); ~MediaPlayer(); public slots: @@ -77,6 +79,7 @@ private: XineControl *xineControl; VolumeControl *volControl; MediaPlayerState &mediaPlayerState; + PlayListWidget &playList; AudioWidget *audioUI; VideoWidget *videoUI; }; diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp index 2992fd6..ed5bc5a 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.cpp +++ b/noncore/multimedia/opieplayer2/mediawidget.cpp @@ -21,10 +21,8 @@ #include "mediawidget.h" #include "playlistwidget.h" -extern PlayListWidget *playList; - -MediaWidget::MediaWidget( MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name ) - : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ) +MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name ) + : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) { connect( &mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ), this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) ); @@ -48,8 +46,8 @@ void MediaWidget::handleCommand( Command command, bool buttonDown ) switch ( command ) { case Play: mediaPlayerState.togglePaused(); case Stop: mediaPlayerState.setPlaying(FALSE); return; - case Next: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; - case Previous: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; + case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; + case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; case Loop: mediaPlayerState.setLooping( buttonDown ); return; case VolumeUp: emit moreReleased(); return; case VolumeDown: emit lessReleased(); return; diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h index e3f09ce..2d92d65 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.h +++ b/noncore/multimedia/opieplayer2/mediawidget.h @@ -23,6 +23,7 @@ #include #include "mediaplayerstate.h" +#include "playlistwidget.h" class MediaWidget : public QWidget { @@ -30,7 +31,7 @@ class MediaWidget : public QWidget public: enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back }; - MediaWidget( MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 ); + MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 ); virtual ~MediaWidget(); public slots: @@ -50,6 +51,7 @@ protected: void handleCommand( Command command, bool buttonDown ); MediaPlayerState &mediaPlayerState; + PlayListWidget &playList; }; #endif // MEDIAWIDGET_H diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index c0039b1..b7305fe 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp @@ -53,7 +53,6 @@ #endif -extern PlayListWidget *playList; static const int xo = 2; // movable x offset @@ -81,10 +80,9 @@ const char *skinV_mask_file_names[7] = { static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton)); -VideoWidget::VideoWidget(MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : -MediaWidget( mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ) { - - +VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) + : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ) +{ setCaption( tr("OpiePlayer - Video") ); videoFrame = new XineVideoWidget ( this, "Video frame" ); @@ -332,8 +330,8 @@ void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { } case VideoStop: mediaPlayerState.setPlaying( FALSE ); return; - case VideoNext: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; - case VideoPrevious: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; + case VideoNext: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; + case VideoPrevious: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; case VideoVolUp: emit moreReleased(); return; case VideoVolDown: emit lessReleased(); return; case VideoFullscreen: mediaPlayerState.setFullscreen( TRUE ); makeVisible(); return; diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h index ae0e687..f996803 100644 --- a/noncore/multimedia/opieplayer2/videowidget.h +++ b/noncore/multimedia/opieplayer2/videowidget.h @@ -58,7 +58,7 @@ enum VideoButtons { class VideoWidget : public MediaWidget { Q_OBJECT public: - VideoWidget( MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); + VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); ~VideoWidget(); -- cgit v0.9.0.2