author | simon <simon> | 2002-12-11 00:03:47 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-11 00:03:47 (UTC) |
commit | e9d1213578b83f8380c4681186246a2b32ae6375 (patch) (side-by-side diff) | |
tree | 8d18cd8172ff45c85c8438cf5f16d630a7bb5aeb /noncore/multimedia | |
parent | 7f4bd526d59aacbf750e9ee58337b6cf640ba28b (diff) | |
download | opie-e9d1213578b83f8380c4681186246a2b32ae6375.zip opie-e9d1213578b83f8380c4681186246a2b32ae6375.tar.gz opie-e9d1213578b83f8380c4681186246a2b32ae6375.tar.bz2 |
- added initialize states to MediaPlayerState
- the play button is now of type PlayButton, inheritting from ToolButton
and checking the media player initialization state in setEnabled
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 @@ -364,8 +364,9 @@ void MediaPlayer::recreateAudioAndVideoWidgets() 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() { 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 @@ -52,8 +52,9 @@ MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) Config cfg( "OpiePlayer" ); readConfig( cfg ); streaming = false; seekable = true; + backendInitialized = false; } MediaPlayerState::~MediaPlayerState() { @@ -84,8 +85,20 @@ void MediaPlayerState::writeConfig( Config& cfg ) const { 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; } 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 @@ -60,8 +60,9 @@ public: 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; @@ -96,8 +97,9 @@ public slots: void togglePlaying(); void toggleBlank(); void writeConfig( Config& cfg ) const; + void setBackendInitialized(); signals: void fullscreenToggled( bool ); void scaledToggled( bool ); @@ -115,8 +117,10 @@ signals: void videoGammaChanged( int ); void prev(); void next(); + void initialized(); + private: bool streaming : 1; bool seekable : 1; bool fullscreen: 1; @@ -127,8 +131,9 @@ private: bool usePlaylist : 1; bool paused : 1; bool playing : 1; bool stopped : 1; + bool backendInitialized : 1; long curPosition; long curLength; DisplayType m_displayType; int videoGamma; 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 @@ -64,9 +64,9 @@ PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* par 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", @@ -150,8 +150,10 @@ PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* par cfg.setGroup("PlayList"); QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); loadList(DocLnk( currentPlaylist ) ); + + tabWidget->showPage( playListTab ); } PlayListWidget::~PlayListWidget() { 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 @@ -120,18 +120,17 @@ PlayListWidgetGui::PlayListWidgetGui( MediaPlayerState &_mediaPlayerState, QWidg 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 ); @@ -203,4 +202,27 @@ void PlayListWidgetGui::setActiveWindow() { 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 @@ -69,8 +69,9 @@ public: }; 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 ); @@ -82,8 +83,25 @@ public: 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: @@ -121,8 +139,9 @@ protected: 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; |