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 @@ -360,16 +360,17 @@ void MediaPlayer::recreateAudioAndVideoWidgets() 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 @@ -48,16 +48,17 @@ 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 ) { @@ -80,16 +81,28 @@ 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; 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 @@ -56,16 +56,17 @@ public: 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 ); @@ -92,16 +93,17 @@ public slots: 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 ); @@ -111,28 +113,31 @@ signals: 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 ); }; 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 @@ -60,17 +60,17 @@ PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* par { 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" ), @@ -146,16 +146,18 @@ PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* par // 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; } 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 @@ -116,26 +116,25 @@ PlayListWidgetGui::PlayListWidgetGui( MediaPlayerState &_mediaPlayerState, QWidg 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 @@ -199,8 +198,31 @@ void PlayListWidgetGui::setView( char view ) { 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 @@ -65,29 +65,47 @@ 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 ); @@ -117,16 +135,17 @@ protected: 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 |