author | simon <simon> | 2002-12-09 21:43:32 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-09 21:43:32 (UTC) |
commit | 40ff6884f079a55fcf219b2d032c7be4da385bc1 (patch) (side-by-side diff) | |
tree | fd13c702652ee0f22201eb6145b10e67f9580aeb | |
parent | a9015ff25ddec67983f78f2a75346f21b7d062c5 (diff) | |
download | opie-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)
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 83 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.h | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/main.cpp | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.cpp | 6 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.h | 1 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.cpp | 3 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.h | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 47 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.h | 2 |
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 @@ -87,47 +87,9 @@ AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlaye audioSliderBeingMoved( false ) { 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 ) ) ); @@ -141,9 +103,8 @@ AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlaye setPosition( mediaPlayerState.position() ); setLooping( mediaPlayerState.isFullscreen() ); // setPaused( mediaPlayerState->paused() ); setPlaying( mediaPlayerState.isPlaying() ); - } AudioWidget::~AudioWidget() { @@ -228,8 +189,50 @@ void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { killTimers(); 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 ) { if ( !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 @@ -67,8 +67,10 @@ public: virtual void setLength( long ); virtual void setPlaying( bool b) { setToggleButton( Play, b ); } virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); + virtual void loadSkin(); + signals: void sliderMoved(long); protected: 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 @@ -11,9 +11,9 @@ int main(int argc, char **argv) { PlayListWidget pl( st, 0, "playList" ); pl.showMaximized(); MediaPlayer mp( pl, st, 0, "mediaPlayer" ); QObject::connect( &pl, SIGNAL( skinSelected() ), - &mp, SLOT( recreateAudioAndVideoWidgets() ) ); + &mp, SLOT( reloadSkins() ) ); a.showMainDocumentWidget(&pl); return a.exec(); 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 @@ -366,4 +366,10 @@ 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 @@ -54,8 +54,9 @@ public: ~MediaPlayer(); public slots: void recreateAudioAndVideoWidgets(); + void reloadSkins(); private slots: void setPlaying( bool ); void pauseCheck( 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 @@ -44,8 +44,11 @@ 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 @@ -71,8 +71,10 @@ public slots: virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0; virtual void setLength( long length ) = 0; virtual void setPlaying( bool playing ) = 0; + virtual void loadSkin() = 0; + signals: void moreReleased(); void lessReleased(); void forwardReleased(); 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 @@ -78,34 +78,16 @@ VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlaye : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ), videoSliderBeingMoved( false ) { 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() ); setFullscreen( mediaPlayerState.isFullscreen() ); @@ -200,8 +182,33 @@ void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) scaledHeight = 0; 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 ) { return; 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 @@ -65,8 +65,10 @@ public: virtual void setPlaying( bool b); virtual void setLength( long ); virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); + virtual void loadSkin(); + signals: void moreClicked(); void lessClicked(); void sliderMoved( long ); |