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 @@ -83,71 +83,32 @@ void changeTextColor( QWidget * w) { AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ), 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 ) ) ); connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); // Intialise state setLength( mediaPlayerState.length() ); setPosition( mediaPlayerState.position() ); setLooping( mediaPlayerState.isFullscreen() ); // setPaused( mediaPlayerState->paused() ); setPlaying( mediaPlayerState.isPlaying() ); - } AudioWidget::~AudioWidget() { // mediaPlayerState->setPlaying(false); } namespace { @@ -224,16 +185,58 @@ void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { showMaximized(); return; } 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 ) { qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); if( !slider.isHidden()) { slider.hide(); } 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 @@ -63,16 +63,18 @@ public slots: void setPosition( long ); void setSeekable( bool ); 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: void doBlank(); void doUnblank(); void resizeEvent( QResizeEvent *re ); void timerEvent( QTimerEvent *event ); 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 @@ -7,16 +7,16 @@ int main(int argc, char **argv) { QPEApplication a(argc,argv); MediaPlayerState st( 0, "mediaPlayerState" ); 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 @@ -362,8 +362,14 @@ void MediaPlayer::recreateAudioAndVideoWidgets() 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 ); } +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 @@ -50,16 +50,17 @@ class VideoWidget; class MediaPlayer : public QObject { Q_OBJECT public: MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ); ~MediaPlayer(); public slots: void recreateAudioAndVideoWidgets(); + void reloadSkins(); private slots: void setPlaying( bool ); void pauseCheck( bool ); void play(); void next(); void prev(); void startIncreasingVolume(); 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 @@ -40,16 +40,19 @@ MediaWidget::~MediaWidget() } void MediaWidget::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount, const QString &imagePrefix, const QSize &buttonAreaSize ) { 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 ); } } MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const QString &imagePrefix ) { 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 @@ -67,16 +67,18 @@ public: MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 ); virtual ~MediaWidget(); 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(); void backReleased(); void forwardClicked(); void backClicked(); void moreClicked(); 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 @@ -74,42 +74,24 @@ const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] ); } VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) : 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() ); setPlaying( mediaPlayerState.isPlaying() ); } @@ -196,16 +178,41 @@ void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) } // Effectively blank the view next time we show it so it looks nicer scaledWidth = 0; 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; } int width = slider->width(); int val = int((double)i * width / max); if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { 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 @@ -61,16 +61,18 @@ public slots: void backToNormal(); void setPosition( long ); 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 ); void videoResized ( const QSize &s ); protected: |