summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-11 00:03:47 (UTC)
committer simon <simon>2002-12-11 00:03:47 (UTC)
commite9d1213578b83f8380c4681186246a2b32ae6375 (patch) (side-by-side diff)
tree8d18cd8172ff45c85c8438cf5f16d630a7bb5aeb
parent7f4bd526d59aacbf750e9ee58337b6cf640ba28b (diff)
downloadopie-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
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp1
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayerstate.cpp13
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayerstate.h5
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp4
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidgetgui.cpp32
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidgetgui.h19
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
@@ -366,4 +366,5 @@ void MediaPlayer::recreateAudioAndVideoWidgets()
xineControl = new XineControl( videoUI, videoUI->vidWidget(), mediaPlayerState );
+ mediaPlayerState.setBackendInitialized();
}
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
@@ -54,4 +54,5 @@ MediaPlayerState::MediaPlayerState( QObject *parent, const char *name )
streaming = false;
seekable = true;
+ backendInitialized = false;
}
@@ -86,4 +87,16 @@ void MediaPlayerState::writeConfig( Config& cfg ) const {
}
+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
{
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
@@ -62,4 +62,5 @@ public:
bool isPlaying() const { return playing; }
bool isStopped() const { return stopped; }
+ bool isInitialized() const;
long position() const { return curPosition; }
long length() const { return curLength; }
@@ -98,4 +99,5 @@ public slots:
void writeConfig( Config& cfg ) const;
+ void setBackendInitialized();
signals:
@@ -117,4 +119,6 @@ signals:
void next();
+ void initialized();
+
private:
bool streaming : 1;
@@ -129,4 +133,5 @@ private:
bool playing : 1;
bool stopped : 1;
+ bool backendInitialized : 1;
long curPosition;
long curLength;
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
@@ -66,5 +66,5 @@ PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* par
"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",
@@ -152,4 +152,6 @@ PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* par
QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default");
loadList(DocLnk( currentPlaylist ) );
+
+ tabWidget->showPage( playListTab );
}
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
@@ -122,14 +122,13 @@ PlayListWidgetGui::PlayListWidgetGui( MediaPlayerState &_mediaPlayerState, QWidg
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;
@@ -205,2 +204,25 @@ void PlayListWidgetGui::setActiveWindow() {
}
+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
@@ -71,4 +71,5 @@ 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 )
@@ -84,4 +85,21 @@ public:
};
+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 {
@@ -123,4 +141,5 @@ protected:
QVBox *vbox5;
QPEToolBar *bar;
+ QWidget *playListTab;
void setActiveWindow(); // need to handle this to show the right view
void setView( char );