summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer2
authorsimon <simon>2002-12-09 21:43:32 (UTC)
committer simon <simon>2002-12-09 21:43:32 (UTC)
commit40ff6884f079a55fcf219b2d032c7be4da385bc1 (patch) (side-by-side diff)
treefd13c702652ee0f22201eb6145b10e67f9580aeb /noncore/multimedia/opieplayer2
parenta9015ff25ddec67983f78f2a75346f21b7d062c5 (diff)
downloadopie-40ff6884f079a55fcf219b2d032c7be4da385bc1.zip
opie-40ff6884f079a55fcf219b2d032c7be4da385bc1.tar.gz
opie-40ff6884f079a55fcf219b2d032c7be4da385bc1.tar.bz2
- hah, the improved design pays off :) switching skins at run-time now
only reloads the pixmaps and no more requires a restart or re-creation of the audio/video widgets and the xine control (which involved slow xine initialization)
Diffstat (limited to 'noncore/multimedia/opieplayer2') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp83
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.h2
-rw-r--r--noncore/multimedia/opieplayer2/main.cpp2
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp6
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.h1
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.cpp3
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.h2
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp47
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.h2
9 files changed, 87 insertions, 61 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index fd18dbb..0516089 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -88,45 +88,7 @@ AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlaye
{
setCaption( tr("OpiePlayer") );
- Config cfg("OpiePlayer");
- cfg.setGroup("Options");
- skin = cfg.readEntry("Skin","default");
- //skin = "scaleTest";
- // color of background, frame, degree of transparency
-
- QString skinPath = "opieplayer2/skins/" + skin;
- backgroundPixmap = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
- imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) );
- imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) );
-
- setupButtons( skinInfo, buttonCount, QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_", imgUp.size() );
-
- setBackgroundPixmap( backgroundPixmap );
-
- songInfo.setFocusPolicy( QWidget::NoFocus );
-// changeTextColor( &songInfo );
-// songInfo.setBackgroundColor( QColor( 167, 212, 167 ));
-// songInfo.setFrameStyle( QFrame::NoFrame);
- songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken );
-// songInfo.setForegroundColor(Qt::white);
-
- slider.setFixedHeight( 20 );
- slider.setMinValue( 0 );
- slider.setMaxValue( 1 );
- slider.setFocusPolicy( QWidget::NoFocus );
- slider.setBackgroundPixmap( backgroundPixmap );
-
-// Config cofg("qpe");
-// cofg.setGroup("Appearance");
-// QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) );
-
- time.setFocusPolicy( QWidget::NoFocus );
- time.setAlignment( Qt::AlignCenter );
-
-// time.setFrame(FALSE);
-// changeTextColor( &time );
-
- resizeEvent( NULL );
+ loadSkin();
connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
connect( &mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) );
@@ -142,7 +104,6 @@ AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlaye
setLooping( mediaPlayerState.isFullscreen() );
// setPaused( mediaPlayerState->paused() );
setPlaying( mediaPlayerState.isPlaying() );
-
}
AudioWidget::~AudioWidget() {
@@ -229,6 +190,48 @@ void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) {
hide();
}
+void AudioWidget::loadSkin()
+{
+ Config cfg("OpiePlayer");
+ cfg.setGroup("Options");
+ skin = cfg.readEntry("Skin","default");
+ //skin = "scaleTest";
+ // color of background, frame, degree of transparency
+
+ QString skinPath = "opieplayer2/skins/" + skin;
+ backgroundPixmap = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
+ imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) );
+ imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) );
+
+ setupButtons( skinInfo, buttonCount, QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_", imgUp.size() );
+
+ setBackgroundPixmap( backgroundPixmap );
+
+ songInfo.setFocusPolicy( QWidget::NoFocus );
+// changeTextColor( &songInfo );
+// songInfo.setBackgroundColor( QColor( 167, 212, 167 ));
+// songInfo.setFrameStyle( QFrame::NoFrame);
+ songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken );
+// songInfo.setForegroundColor(Qt::white);
+
+ slider.setFixedHeight( 20 );
+ slider.setMinValue( 0 );
+ slider.setMaxValue( 1 );
+ slider.setFocusPolicy( QWidget::NoFocus );
+ slider.setBackgroundPixmap( backgroundPixmap );
+
+// Config cofg("qpe");
+// cofg.setGroup("Appearance");
+// QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) );
+
+ time.setFocusPolicy( QWidget::NoFocus );
+ time.setAlignment( Qt::AlignCenter );
+
+// time.setFrame(FALSE);
+// changeTextColor( &time );
+
+ resizeEvent( 0 );
+}
void AudioWidget::setSeekable( bool isSeekable ) {
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h
index 53982a1..61556c6 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.h
+++ b/noncore/multimedia/opieplayer2/audiowidget.h
@@ -68,6 +68,8 @@ public:
virtual void setPlaying( bool b) { setToggleButton( Play, b ); }
virtual void setDisplayType( MediaPlayerState::DisplayType displayType );
+ virtual void loadSkin();
+
signals:
void sliderMoved(long);
diff --git a/noncore/multimedia/opieplayer2/main.cpp b/noncore/multimedia/opieplayer2/main.cpp
index ffc7cb6..f87cee8 100644
--- a/noncore/multimedia/opieplayer2/main.cpp
+++ b/noncore/multimedia/opieplayer2/main.cpp
@@ -12,7 +12,7 @@ int main(int argc, char **argv) {
pl.showMaximized();
MediaPlayer mp( pl, st, 0, "mediaPlayer" );
QObject::connect( &pl, SIGNAL( skinSelected() ),
- &mp, SLOT( recreateAudioAndVideoWidgets() ) );
+ &mp, SLOT( reloadSkins() ) );
a.showMainDocumentWidget(&pl);
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp
index e1bfc2d..8a3d3e0 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp
@@ -367,3 +367,9 @@ void MediaPlayer::recreateAudioAndVideoWidgets()
xineControl = new XineControl( videoUI, videoUI->vidWidget(), mediaPlayerState );
}
+void MediaPlayer::reloadSkins()
+{
+ audioUI->loadSkin();
+ videoUI->loadSkin();
+}
+
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.h b/noncore/multimedia/opieplayer2/mediaplayer.h
index dc306c4..6b316f6 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.h
+++ b/noncore/multimedia/opieplayer2/mediaplayer.h
@@ -55,6 +55,7 @@ public:
public slots:
void recreateAudioAndVideoWidgets();
+ void reloadSkins();
private slots:
void setPlaying( bool );
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp
index db16b44..d60dc0d 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.cpp
+++ b/noncore/multimedia/opieplayer2/mediawidget.cpp
@@ -45,6 +45,9 @@ void MediaWidget::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount
buttonMask = QImage( buttonAreaSize, 8, 255 );
buttonMask.fill( 0 );
+ buttons.clear();
+ buttons.reserve( buttonCount );
+
for ( uint i = 0; i < buttonCount; ++i ) {
Button button = setupButton( skinInfo[ i ], imagePrefix );
buttons.push_back( button );
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h
index 148948a..8c781e9 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.h
+++ b/noncore/multimedia/opieplayer2/mediawidget.h
@@ -72,6 +72,8 @@ public slots:
virtual void setLength( long length ) = 0;
virtual void setPlaying( bool playing ) = 0;
+ virtual void loadSkin() = 0;
+
signals:
void moreReleased();
void lessReleased();
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index d1efaad..a03d43e 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -79,32 +79,14 @@ VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlaye
{
setCaption( tr("OpiePlayer - Video") );
-
videoFrame = new XineVideoWidget ( this, "Video frame" );
connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & )));
connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) );
- Config cfg("OpiePlayer");
- cfg.setGroup("Options");
- skin = cfg.readEntry("Skin","default");
+ slider = 0;
- QString skinPath = "opieplayer2/skins/" + skin;
- backgroundPixmap = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
- imgUp = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) );
- imgDn = QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) );
-
- setupButtons( skinInfo, buttonCount, QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_", imgUp.size() );
-
- setBackgroundPixmap( backgroundPixmap );
-
- slider = new QSlider( Qt::Horizontal, this );
- slider->setMinValue( 0 );
- slider->setMaxValue( 1 );
- slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
- //slider->setFocusPolicy( QWidget::NoFocus );
-
- resizeEvent( NULL );
+ loadSkin();
setLength( mediaPlayerState.length() );
setPosition( mediaPlayerState.position() );
@@ -201,6 +183,31 @@ void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType )
hide();
}
+void VideoWidget::loadSkin()
+{
+ Config cfg("OpiePlayer");
+ cfg.setGroup("Options");
+ skin = cfg.readEntry("Skin","default");
+
+ QString skinPath = "opieplayer2/skins/" + skin;
+ backgroundPixmap = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
+ imgUp = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) );
+ imgDn = QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) );
+
+ setupButtons( skinInfo, buttonCount, QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_", imgUp.size() );
+
+ setBackgroundPixmap( backgroundPixmap );
+
+ delete slider;
+ slider = new QSlider( Qt::Horizontal, this );
+ slider->setMinValue( 0 );
+ slider->setMaxValue( 1 );
+ slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
+ //slider->setFocusPolicy( QWidget::NoFocus );
+
+ resizeEvent( 0 );
+}
+
void VideoWidget::updateSlider( long i, long max ) {
// Will flicker too much if we don't do this
if ( max == 0 ) {
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h
index 21a4e9e..87be371 100644
--- a/noncore/multimedia/opieplayer2/videowidget.h
+++ b/noncore/multimedia/opieplayer2/videowidget.h
@@ -66,6 +66,8 @@ public:
virtual void setLength( long );
virtual void setDisplayType( MediaPlayerState::DisplayType displayType );
+ virtual void loadSkin();
+
signals:
void moreClicked();
void lessClicked();