6 files changed, 68 insertions, 6 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index 8a3d3e0..5e91561 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp @@ -352,24 +352,25 @@ void MediaPlayer::recreateAudioAndVideoWidgets() delete audioUI; delete 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() ) ); connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); xineControl = new XineControl( videoUI, videoUI->vidWidget(), mediaPlayerState ); + mediaPlayerState.setBackendInitialized(); } void MediaPlayer::reloadSkins() { audioUI->loadSkin(); videoUI->loadSkin(); } diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp index 40fa1a4..d54d870 100644 --- a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp @@ -40,64 +40,77 @@ #include <qobject.h> #include <qdir.h> #include "mediaplayerstate.h" #include <assert.h> //#define MediaPlayerDebug(x) qDebug x #define MediaPlayerDebug(x) MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) : QObject( parent, name ) { Config cfg( "OpiePlayer" ); readConfig( cfg ); streaming = false; seekable = true; + backendInitialized = false; } MediaPlayerState::~MediaPlayerState() { } void MediaPlayerState::readConfig( Config& cfg ) { cfg.setGroup("Options"); fullscreen = cfg.readBoolEntry( "FullScreen" ); scaled = cfg.readBoolEntry( "Scaling" ); looping = cfg.readBoolEntry( "Looping" ); shuffled = cfg.readBoolEntry( "Shuffle" ); videoGamma = cfg.readNumEntry( "VideoGamma" ); playing = FALSE; streaming = FALSE; paused = FALSE; curPosition = 0; curLength = 0; m_displayType = MediaSelection; } void MediaPlayerState::writeConfig( Config& cfg ) const { cfg.setGroup( "Options" ); cfg.writeEntry( "FullScreen", fullscreen ); cfg.writeEntry( "Scaling", scaled ); cfg.writeEntry( "Looping", looping ); cfg.writeEntry( "Shuffle", shuffled ); cfg.writeEntry( "VideoGamma", videoGamma ); } +bool MediaPlayerState::isInitialized() const +{ + return backendInitialized; // for now, more to come (skin stuff) +} + +void MediaPlayerState::setBackendInitialized() +{ + assert( backendInitialized == false ); + backendInitialized = true; + emit initialized(); +} + MediaPlayerState::DisplayType MediaPlayerState::displayType() const { return m_displayType; } // slots void MediaPlayerState::setIsStreaming( bool b ) { streaming = b; } void MediaPlayerState::setIsSeekable( bool b ) { seekable = b; emit isSeekableToggled(b); } diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.h b/noncore/multimedia/opieplayer2/mediaplayerstate.h index c887bb8..6fe6d76 100644 --- a/noncore/multimedia/opieplayer2/mediaplayerstate.h +++ b/noncore/multimedia/opieplayer2/mediaplayerstate.h @@ -48,32 +48,33 @@ class MediaPlayerState : public QObject { Q_OBJECT public: enum DisplayType { Audio, Video, MediaSelection }; MediaPlayerState( QObject *parent, const char *name ); ~MediaPlayerState(); bool isStreaming() const { return streaming; } bool isSeekable() const { return seekable; } bool isFullscreen() const { return fullscreen; } bool isScaled() const { return scaled; } bool isLooping() const { return looping; } bool isShuffled() const { return shuffled; } bool isPaused() const { return paused; } bool isPlaying() const { return playing; } bool isStopped() const { return stopped; } + bool isInitialized() const; long position() const { return curPosition; } long length() const { return curLength; } DisplayType displayType() const; public slots: void setIsStreaming( bool b ); void setIsSeekable( bool b ); void setFullscreen( bool b ); void setScaled( bool b ); void setLooping( bool b ); void setShuffled( bool b ); void setPaused( bool b ); void setPlaying( bool b ); void setStopped( bool b ); void setPosition( long p ); void updatePosition( long p ); @@ -84,58 +85,62 @@ public slots: void setPrev(); void setNext(); void setList(); void setVideo(); void setAudio(); void toggleFullscreen(); void toggleScaled(); void toggleLooping(); void toggleShuffled(); void togglePaused(); void togglePlaying(); void toggleBlank(); void writeConfig( Config& cfg ) const; + void setBackendInitialized(); signals: void fullscreenToggled( bool ); void scaledToggled( bool ); void loopingToggled( bool ); void shuffledToggled( bool ); void pausedToggled( bool ); void playingToggled( bool ); void stopToggled( bool ); void positionChanged( long ); // When the slider is moved void positionUpdated( long ); // When the media file progresses void lengthChanged( long ); void displayTypeChanged( MediaPlayerState::DisplayType type ); void isSeekableToggled( bool ); void blankToggled( bool ); void videoGammaChanged( int ); void prev(); void next(); + void initialized(); + private: bool streaming : 1; bool seekable : 1; bool fullscreen: 1; bool scaled : 1; bool blanked : 1; bool looping : 1; bool shuffled : 1; bool usePlaylist : 1; bool paused : 1; bool playing : 1; bool stopped : 1; + bool backendInitialized : 1; long curPosition; long curLength; DisplayType m_displayType; int videoGamma; void readConfig( Config& cfg ); }; #endif // MEDIA_PLAYER_STATE_H diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index cba7b6d..8e4f56d 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp @@ -52,33 +52,33 @@ #include "playlistfileview.h" //only needed for the random play #include <stdlib.h> #include <assert.h> PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) : PlayListWidgetGui( mediaPlayerState, parent, name ) , currentFileListView( 0 ) { d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer2/add_to_playlist", this , SLOT(addSelected() ) ); d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer2/remove_from_playlist", this , SLOT(removeSelected() ) ); - d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", + d->tbPlay = new PlayButton( mediaPlayerState, bar, tr( "Play" ), "opieplayer2/play", this , SLOT( btnPlay( bool) ), TRUE ); d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", &mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", &mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); (void)new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); (void)new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); pmPlayList->insertSeparator(-1); // (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), // this, SLOT( saveList() ) ); @@ -138,32 +138,34 @@ PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* par connect( &mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); connect( &mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); connect ( gammaSlider, SIGNAL( valueChanged( int ) ), &mediaPlayerState, SLOT( setVideoGamma( int ) ) ); // see which skins are installed populateSkinsMenu(); initializeStates(); cfg.setGroup("PlayList"); QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); loadList(DocLnk( currentPlaylist ) ); + + tabWidget->showPage( playListTab ); } PlayListWidget::~PlayListWidget() { delete d; } void PlayListWidget::initializeStates() { d->tbPlay->setOn( mediaPlayerState.isPlaying() ); d->tbLoop->setOn( mediaPlayerState.isLooping() ); d->tbShuffle->setOn( mediaPlayerState.isShuffled() ); d->playListFrame->show(); } void PlayListWidget::writeDefaultPlaylist() { diff --git a/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp b/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp index 5886458..23b7a70 100644 --- a/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp @@ -108,42 +108,41 @@ PlayListWidgetGui::PlayListWidgetGui( MediaPlayerState &_mediaPlayerState, QWidg gammaLCD = new QLCDNumber( 3, gammaMenu ); gammaLCD-> setFrameShape ( QFrame::NoFrame ); gammaLCD-> setSegmentStyle ( QLCDNumber::Flat ); gammaMenu->insertItem( gammaSlider ); gammaMenu->insertItem( gammaLCD ); connect( gammaSlider, SIGNAL( valueChanged( int ) ), gammaLCD, SLOT( display( int ) ) ); vbox5 = new QVBox( this ); QVBox *vbox4 = new QVBox( vbox5 ); QHBox *hbox6 = new QHBox( vbox4 ); tabWidget = new QTabWidget( hbox6, "tabWidget" ); - QWidget *pTab; - pTab = new QWidget( tabWidget, "pTab" ); - tabWidget->insertTab( pTab, "Playlist"); + playListTab = new QWidget( tabWidget, "PlayListTab" ); + tabWidget->insertTab( playListTab, "Playlist"); - QGridLayout *Playout = new QGridLayout( pTab ); + QGridLayout *Playout = new QGridLayout( playListTab ); Playout->setSpacing( 2); Playout->setMargin( 2); // Add the playlist area - QVBox *vbox3 = new QVBox( pTab ); + QVBox *vbox3 = new QVBox( playListTab ); d->playListFrame = vbox3; QHBox *hbox2 = new QHBox( vbox3 ); d->selectedFiles = new PlayListSelection( hbox2 ); vbox1 = new QVBox( hbox2 ); QPEApplication::setStylusOperation( d->selectedFiles->viewport(), QPEApplication::RightOnHold ); QVBox *stretch1 = new QVBox( vbox1 ); // add stretch Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 ); QWidget *aTab; aTab = new QWidget( tabWidget, "aTab" ); QGridLayout *Alayout = new QGridLayout( aTab ); Alayout->setSpacing( 2 ); @@ -191,16 +190,39 @@ PlayListWidgetGui::~PlayListWidgetGui() { void PlayListWidgetGui::setView( char view ) { if ( view == 'l' ) showMaximized(); else hide(); } void PlayListWidgetGui::setActiveWindow() { // qDebug("SETTING active window"); // When we get raised we need to ensure that it switches views MediaPlayerState::DisplayType origDisplayType = mediaPlayerState.displayType(); mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); // invalidate mediaPlayerState.setDisplayType( origDisplayType ); // now switch back } +PlayButton::PlayButton( MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name, + const QString &icon, QObject *handler, const QString &slot, bool t ) + : ToolButton( parent, name, icon, handler, slot, t ), mediaPlayerState( _mediaPlayerState ), + m_lastEnableStatus( true ) +{ + connect( &mediaPlayerState, SIGNAL( initialized() ), + this, SLOT( checkInitializationStatus() ) ); +} + +void PlayButton::setEnabled( bool enable ) +{ + m_lastEnableStatus = enable; + + enable &= mediaPlayerState.isInitialized(); + + ToolButton::setEnabled( enable ); +} + +void PlayButton::checkInitializationStatus() +{ + setEnabled( m_lastEnableStatus ); +} + diff --git a/noncore/multimedia/opieplayer2/playlistwidgetgui.h b/noncore/multimedia/opieplayer2/playlistwidgetgui.h index 0d8af43..1aa8ac8 100644 --- a/noncore/multimedia/opieplayer2/playlistwidgetgui.h +++ b/noncore/multimedia/opieplayer2/playlistwidgetgui.h @@ -57,45 +57,63 @@ class QPEToolBar; class QListViewItem; class QListView; class QPoint; class QAction; class QLabel; class PlayListWidgetPrivate { public: QToolButton *tbPlay, *tbFull, *tbLoop, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; QFrame *playListFrame; PlayListSelection *selectedFiles; bool setDocumentUsed; }; class ToolButton : public QToolButton { + Q_OBJECT public: ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) : QToolButton( parent, name ) { setTextLabel( name ); setPixmap( Resource::loadPixmap( icon ) ); setAutoRaise( TRUE ); setFocusPolicy( QWidget::NoFocus ); setToggleButton( t ); connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); QPEMenuToolFocusManager::manager()->addWidget( this ); } }; +class PlayButton : public ToolButton +{ + Q_OBJECT +public: + PlayButton( MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name, + const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ); + +protected: + virtual void setEnabled( bool enable ); + +private slots: + void checkInitializationStatus(); + +private: + MediaPlayerState &mediaPlayerState; + bool m_lastEnableStatus : 1; +}; class MenuItem : public QAction { public: MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) : QAction( text, QString::null, 0, 0 ) { connect( this, SIGNAL( activated() ), handler, slot ); addTo( parent ); } }; class PlayListWidgetGui : public QMainWindow { Q_OBJECT public: PlayListWidgetGui( MediaPlayerState &_mediaPlayerState, QWidget* parent=0, const char* name=0 ); ~PlayListWidgetGui(); @@ -109,24 +127,25 @@ protected: QPopupMenu *gammaMenu; QSlider *gammaSlider; QLCDNumber *gammaLCD; bool fromSetDocument; bool insanityBool; QString setDocFileRef; // retrieve the current playlist entry (media file link) QPushButton *tbDeletePlaylist; int selected; QPopupMenu *pmPlayList; FileSelector* playLists; QPopupMenu *skinsMenu; PlayListWidgetPrivate *d; // Private implementation data QVBox *vbox1; QVBox *vbox5; QPEToolBar *bar; + QWidget *playListTab; void setActiveWindow(); // need to handle this to show the right view void setView( char ); MediaPlayerState &mediaPlayerState; }; #endif |