summaryrefslogtreecommitdiff
path: root/noncore
authorsimon <simon>2002-12-09 21:43:32 (UTC)
committer simon <simon>2002-12-09 21:43:32 (UTC)
commit40ff6884f079a55fcf219b2d032c7be4da385bc1 (patch) (unidiff)
treefd13c702652ee0f22201eb6145b10e67f9580aeb /noncore
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') (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
@@ -79,79 +79,40 @@ void changeTextColor( QWidget * w) {
79 w->setPalette( p ); 79 w->setPalette( p );
80} 80}
81 81
82} 82}
83 83
84AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : 84AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) :
85 85
86 MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ), 86 MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ),
87 audioSliderBeingMoved( false ) 87 audioSliderBeingMoved( false )
88{ 88{
89 setCaption( tr("OpiePlayer") ); 89 setCaption( tr("OpiePlayer") );
90 90
91 Config cfg("OpiePlayer"); 91 loadSkin();
92 cfg.setGroup("Options");
93 skin = cfg.readEntry("Skin","default");
94 //skin = "scaleTest";
95 // color of background, frame, degree of transparency
96
97 QString skinPath = "opieplayer2/skins/" + skin;
98 backgroundPixmap = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
99 imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) );
100 imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) );
101
102 setupButtons( skinInfo, buttonCount, QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_", imgUp.size() );
103
104 setBackgroundPixmap( backgroundPixmap );
105
106 songInfo.setFocusPolicy( QWidget::NoFocus );
107// changeTextColor( &songInfo );
108// songInfo.setBackgroundColor( QColor( 167, 212, 167 ));
109// songInfo.setFrameStyle( QFrame::NoFrame);
110 songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken );
111// songInfo.setForegroundColor(Qt::white);
112
113 slider.setFixedHeight( 20 );
114 slider.setMinValue( 0 );
115 slider.setMaxValue( 1 );
116 slider.setFocusPolicy( QWidget::NoFocus );
117 slider.setBackgroundPixmap( backgroundPixmap );
118
119// Config cofg("qpe");
120// cofg.setGroup("Appearance");
121// QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) );
122
123 time.setFocusPolicy( QWidget::NoFocus );
124 time.setAlignment( Qt::AlignCenter );
125
126// time.setFrame(FALSE);
127// changeTextColor( &time );
128
129 resizeEvent( NULL );
130 92
131 connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); 93 connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
132 connect( &mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) ); 94 connect( &mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) );
133 95
134 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); 96 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) );
135 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); 97 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) );
136 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); 98 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) );
137 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); 99 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) );
138 100
139 // Intialise state 101 // Intialise state
140 setLength( mediaPlayerState.length() ); 102 setLength( mediaPlayerState.length() );
141 setPosition( mediaPlayerState.position() ); 103 setPosition( mediaPlayerState.position() );
142 setLooping( mediaPlayerState.isFullscreen() ); 104 setLooping( mediaPlayerState.isFullscreen() );
143 // setPaused( mediaPlayerState->paused() ); 105 // setPaused( mediaPlayerState->paused() );
144 setPlaying( mediaPlayerState.isPlaying() ); 106 setPlaying( mediaPlayerState.isPlaying() );
145
146} 107}
147 108
148AudioWidget::~AudioWidget() { 109AudioWidget::~AudioWidget() {
149 110
150// mediaPlayerState->setPlaying(false); 111// mediaPlayerState->setPlaying(false);
151} 112}
152 113
153namespace { 114namespace {
154 115
155QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 116QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
156 QPixmap pix( img.width(), img.height() ); 117 QPixmap pix( img.width(), img.height() );
157 QPainter p( &pix ); 118 QPainter p( &pix );
@@ -220,24 +181,66 @@ void AudioWidget::setLength( long max ) {
220 181
221void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { 182void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) {
222 if ( mediaType == MediaPlayerState::Audio ) { 183 if ( mediaType == MediaPlayerState::Audio ) {
223 // startTimer( 150 ); 184 // startTimer( 150 );
224 showMaximized(); 185 showMaximized();
225 return; 186 return;
226 } 187 }
227 188
228 killTimers(); 189 killTimers();
229 hide(); 190 hide();
230} 191}
231 192
193void AudioWidget::loadSkin()
194{
195 Config cfg("OpiePlayer");
196 cfg.setGroup("Options");
197 skin = cfg.readEntry("Skin","default");
198 //skin = "scaleTest";
199 // color of background, frame, degree of transparency
200
201 QString skinPath = "opieplayer2/skins/" + skin;
202 backgroundPixmap = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
203 imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) );
204 imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) );
205
206 setupButtons( skinInfo, buttonCount, QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_", imgUp.size() );
207
208 setBackgroundPixmap( backgroundPixmap );
209
210 songInfo.setFocusPolicy( QWidget::NoFocus );
211// changeTextColor( &songInfo );
212// songInfo.setBackgroundColor( QColor( 167, 212, 167 ));
213// songInfo.setFrameStyle( QFrame::NoFrame);
214 songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken );
215// songInfo.setForegroundColor(Qt::white);
216
217 slider.setFixedHeight( 20 );
218 slider.setMinValue( 0 );
219 slider.setMaxValue( 1 );
220 slider.setFocusPolicy( QWidget::NoFocus );
221 slider.setBackgroundPixmap( backgroundPixmap );
222
223// Config cofg("qpe");
224// cofg.setGroup("Appearance");
225// QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) );
226
227 time.setFocusPolicy( QWidget::NoFocus );
228 time.setAlignment( Qt::AlignCenter );
229
230// time.setFrame(FALSE);
231// changeTextColor( &time );
232
233 resizeEvent( 0 );
234}
232 235
233void AudioWidget::setSeekable( bool isSeekable ) { 236void AudioWidget::setSeekable( bool isSeekable ) {
234 237
235 if ( !isSeekable ) { 238 if ( !isSeekable ) {
236 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); 239 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>");
237 if( !slider.isHidden()) { 240 if( !slider.isHidden()) {
238 slider.hide(); 241 slider.hide();
239 } 242 }
240 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 243 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
241 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 244 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
242 disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 245 disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
243 disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 246 disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
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
@@ -59,24 +59,26 @@ public slots:
59 void updateSlider( long, long ); 59 void updateSlider( long, long );
60 void sliderPressed( ); 60 void sliderPressed( );
61 void sliderReleased( ); 61 void sliderReleased( );
62 void setLooping( bool b) { setToggleButton( Loop, b ); } 62 void setLooping( bool b) { setToggleButton( Loop, b ); }
63 void setPosition( long ); 63 void setPosition( long );
64 void setSeekable( bool ); 64 void setSeekable( bool );
65 65
66public: 66public:
67 virtual void setLength( long ); 67 virtual void setLength( long );
68 virtual void setPlaying( bool b) { setToggleButton( Play, b ); } 68 virtual void setPlaying( bool b) { setToggleButton( Play, b ); }
69 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); 69 virtual void setDisplayType( MediaPlayerState::DisplayType displayType );
70 70
71 virtual void loadSkin();
72
71signals: 73signals:
72 void sliderMoved(long); 74 void sliderMoved(long);
73 75
74protected: 76protected:
75 void doBlank(); 77 void doBlank();
76 void doUnblank(); 78 void doUnblank();
77 void resizeEvent( QResizeEvent *re ); 79 void resizeEvent( QResizeEvent *re );
78 void timerEvent( QTimerEvent *event ); 80 void timerEvent( QTimerEvent *event );
79 void keyReleaseEvent( QKeyEvent *e); 81 void keyReleaseEvent( QKeyEvent *e);
80private slots: 82private slots:
81 void skipFor(); 83 void skipFor();
82 void skipBack(); 84 void skipBack();
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
@@ -3,20 +3,20 @@
3#include "mediaplayerstate.h" 3#include "mediaplayerstate.h"
4#include "playlistwidget.h" 4#include "playlistwidget.h"
5#include "mediaplayer.h" 5#include "mediaplayer.h"
6 6
7int main(int argc, char **argv) { 7int main(int argc, char **argv) {
8 QPEApplication a(argc,argv); 8 QPEApplication a(argc,argv);
9 9
10 MediaPlayerState st( 0, "mediaPlayerState" ); 10 MediaPlayerState st( 0, "mediaPlayerState" );
11 PlayListWidget pl( st, 0, "playList" ); 11 PlayListWidget pl( st, 0, "playList" );
12 pl.showMaximized(); 12 pl.showMaximized();
13 MediaPlayer mp( pl, st, 0, "mediaPlayer" ); 13 MediaPlayer mp( pl, st, 0, "mediaPlayer" );
14 QObject::connect( &pl, SIGNAL( skinSelected() ), 14 QObject::connect( &pl, SIGNAL( skinSelected() ),
15 &mp, SLOT( recreateAudioAndVideoWidgets() ) ); 15 &mp, SLOT( reloadSkins() ) );
16 16
17 a.showMainDocumentWidget(&pl); 17 a.showMainDocumentWidget(&pl);
18 18
19 return a.exec(); 19 return a.exec();
20} 20}
21 21
22 22
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
@@ -358,12 +358,18 @@ void MediaPlayer::recreateAudioAndVideoWidgets()
358 connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); 358 connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
359 connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); 359 connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
360 connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); 360 connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
361 361
362 connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); 362 connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
363 connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); 363 connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
364 connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); 364 connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
365 connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); 365 connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
366 366
367 xineControl = new XineControl( videoUI, videoUI->vidWidget(), mediaPlayerState ); 367 xineControl = new XineControl( videoUI, videoUI->vidWidget(), mediaPlayerState );
368} 368}
369 369
370void MediaPlayer::reloadSkins()
371{
372 audioUI->loadSkin();
373 videoUI->loadSkin();
374}
375
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
@@ -46,24 +46,25 @@ class VolumeControl;
46class MediaPlayerState; 46class MediaPlayerState;
47class AudioWidget; 47class AudioWidget;
48class VideoWidget; 48class VideoWidget;
49 49
50class MediaPlayer : public QObject { 50class MediaPlayer : public QObject {
51 Q_OBJECT 51 Q_OBJECT
52public: 52public:
53 MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ); 53 MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name );
54 ~MediaPlayer(); 54 ~MediaPlayer();
55 55
56public slots: 56public slots:
57 void recreateAudioAndVideoWidgets(); 57 void recreateAudioAndVideoWidgets();
58 void reloadSkins();
58 59
59private slots: 60private slots:
60 void setPlaying( bool ); 61 void setPlaying( bool );
61 void pauseCheck( bool ); 62 void pauseCheck( bool );
62 void play(); 63 void play();
63 void next(); 64 void next();
64 void prev(); 65 void prev();
65 void startIncreasingVolume(); 66 void startIncreasingVolume();
66 void startDecreasingVolume(); 67 void startDecreasingVolume();
67 void stopChangingVolume(); 68 void stopChangingVolume();
68 void cleanUp(); 69 void cleanUp();
69 void blank( bool ); 70 void blank( 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
@@ -36,24 +36,27 @@ MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPla
36} 36}
37 37
38MediaWidget::~MediaWidget() 38MediaWidget::~MediaWidget()
39{ 39{
40} 40}
41 41
42void MediaWidget::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount, 42void MediaWidget::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount,
43 const QString &imagePrefix, const QSize &buttonAreaSize ) 43 const QString &imagePrefix, const QSize &buttonAreaSize )
44{ 44{
45 buttonMask = QImage( buttonAreaSize, 8, 255 ); 45 buttonMask = QImage( buttonAreaSize, 8, 255 );
46 buttonMask.fill( 0 ); 46 buttonMask.fill( 0 );
47 47
48 buttons.clear();
49 buttons.reserve( buttonCount );
50
48 for ( uint i = 0; i < buttonCount; ++i ) { 51 for ( uint i = 0; i < buttonCount; ++i ) {
49 Button button = setupButton( skinInfo[ i ], imagePrefix ); 52 Button button = setupButton( skinInfo[ i ], imagePrefix );
50 buttons.push_back( button ); 53 buttons.push_back( button );
51 } 54 }
52} 55}
53 56
54MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const QString &imagePrefix ) 57MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const QString &imagePrefix )
55{ 58{
56 Button button; 59 Button button;
57 button.command = buttonInfo.command; 60 button.command = buttonInfo.command;
58 button.type = buttonInfo.type; 61 button.type = buttonInfo.type;
59 62
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
@@ -63,24 +63,26 @@ public:
63 63
64 typedef std::vector<QBitmap> MaskVector; 64 typedef std::vector<QBitmap> MaskVector;
65 typedef std::vector<QPixmap> PixmapVector; 65 typedef std::vector<QPixmap> PixmapVector;
66 66
67 MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 ); 67 MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 );
68 virtual ~MediaWidget(); 68 virtual ~MediaWidget();
69 69
70public slots: 70public slots:
71 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0; 71 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0;
72 virtual void setLength( long length ) = 0; 72 virtual void setLength( long length ) = 0;
73 virtual void setPlaying( bool playing ) = 0; 73 virtual void setPlaying( bool playing ) = 0;
74 74
75 virtual void loadSkin() = 0;
76
75signals: 77signals:
76 void moreReleased(); 78 void moreReleased();
77 void lessReleased(); 79 void lessReleased();
78 void forwardReleased(); 80 void forwardReleased();
79 void backReleased(); 81 void backReleased();
80 void forwardClicked(); 82 void forwardClicked();
81 void backClicked(); 83 void backClicked();
82 void moreClicked(); 84 void moreClicked();
83 void lessClicked(); 85 void lessClicked();
84 86
85protected: 87protected:
86 void setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount, 88 void setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount,
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
@@ -70,50 +70,32 @@ const MediaWidget::SkinButtonInfo skinInfo[] =
70 { MediaWidget::FullScreen, "full", MediaWidget::ToggleButton } 70 { MediaWidget::FullScreen, "full", MediaWidget::ToggleButton }
71}; 71};
72 72
73const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] ); 73const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] );
74 74
75} 75}
76 76
77VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) 77VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name )
78 : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ), videoSliderBeingMoved( false ) 78 : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ), videoSliderBeingMoved( false )
79{ 79{
80 setCaption( tr("OpiePlayer - Video") ); 80 setCaption( tr("OpiePlayer - Video") );
81 81
82
83 videoFrame = new XineVideoWidget ( this, "Video frame" ); 82 videoFrame = new XineVideoWidget ( this, "Video frame" );
84 83
85 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); 84 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & )));
86 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); 85 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) );
87 86
88 Config cfg("OpiePlayer"); 87 slider = 0;
89 cfg.setGroup("Options");
90 skin = cfg.readEntry("Skin","default");
91 88
92 QString skinPath = "opieplayer2/skins/" + skin; 89 loadSkin();
93 backgroundPixmap = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
94 imgUp = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) );
95 imgDn = QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) );
96
97 setupButtons( skinInfo, buttonCount, QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_", imgUp.size() );
98
99 setBackgroundPixmap( backgroundPixmap );
100
101 slider = new QSlider( Qt::Horizontal, this );
102 slider->setMinValue( 0 );
103 slider->setMaxValue( 1 );
104 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
105 //slider->setFocusPolicy( QWidget::NoFocus );
106
107 resizeEvent( NULL );
108 90
109 setLength( mediaPlayerState.length() ); 91 setLength( mediaPlayerState.length() );
110 setPosition( mediaPlayerState.position() ); 92 setPosition( mediaPlayerState.position() );
111 setFullscreen( mediaPlayerState.isFullscreen() ); 93 setFullscreen( mediaPlayerState.isFullscreen() );
112 setPlaying( mediaPlayerState.isPlaying() ); 94 setPlaying( mediaPlayerState.isPlaying() );
113} 95}
114 96
115 97
116VideoWidget::~VideoWidget() 98VideoWidget::~VideoWidget()
117{ 99{
118} 100}
119 101
@@ -192,24 +174,49 @@ void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType )
192{ 174{
193 if ( displayType == MediaPlayerState::Video ) { 175 if ( displayType == MediaPlayerState::Video ) {
194 makeVisible(); 176 makeVisible();
195 return; 177 return;
196 } 178 }
197 179
198 // Effectively blank the view next time we show it so it looks nicer 180 // Effectively blank the view next time we show it so it looks nicer
199 scaledWidth = 0; 181 scaledWidth = 0;
200 scaledHeight = 0; 182 scaledHeight = 0;
201 hide(); 183 hide();
202} 184}
203 185
186void VideoWidget::loadSkin()
187{
188 Config cfg("OpiePlayer");
189 cfg.setGroup("Options");
190 skin = cfg.readEntry("Skin","default");
191
192 QString skinPath = "opieplayer2/skins/" + skin;
193 backgroundPixmap = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
194 imgUp = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) );
195 imgDn = QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) );
196
197 setupButtons( skinInfo, buttonCount, QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_", imgUp.size() );
198
199 setBackgroundPixmap( backgroundPixmap );
200
201 delete slider;
202 slider = new QSlider( Qt::Horizontal, this );
203 slider->setMinValue( 0 );
204 slider->setMaxValue( 1 );
205 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
206 //slider->setFocusPolicy( QWidget::NoFocus );
207
208 resizeEvent( 0 );
209}
210
204void VideoWidget::updateSlider( long i, long max ) { 211void VideoWidget::updateSlider( long i, long max ) {
205 // Will flicker too much if we don't do this 212 // Will flicker too much if we don't do this
206 if ( max == 0 ) { 213 if ( max == 0 ) {
207 return; 214 return;
208 } 215 }
209 int width = slider->width(); 216 int width = slider->width();
210 int val = int((double)i * width / max); 217 int val = int((double)i * width / max);
211 if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { 218 if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) {
212 if ( slider->value() != val ) { 219 if ( slider->value() != val ) {
213 slider->setValue( val ); 220 slider->setValue( val );
214 } 221 }
215 if ( slider->maxValue() != width ) { 222 if ( slider->maxValue() != width ) {
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
@@ -57,24 +57,26 @@ public slots:
57 void sliderPressed( ); 57 void sliderPressed( );
58 void sliderReleased( ); 58 void sliderReleased( );
59 void setFullscreen( bool b ); 59 void setFullscreen( bool b );
60 virtual void makeVisible(); 60 virtual void makeVisible();
61 void backToNormal(); 61 void backToNormal();
62 void setPosition( long ); 62 void setPosition( long );
63 63
64public: 64public:
65 virtual void setPlaying( bool b); 65 virtual void setPlaying( bool b);
66 virtual void setLength( long ); 66 virtual void setLength( long );
67 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); 67 virtual void setDisplayType( MediaPlayerState::DisplayType displayType );
68 68
69 virtual void loadSkin();
70
69signals: 71signals:
70 void moreClicked(); 72 void moreClicked();
71 void lessClicked(); 73 void lessClicked();
72 void sliderMoved( long ); 74 void sliderMoved( long );
73 void videoResized ( const QSize &s ); 75 void videoResized ( const QSize &s );
74 76
75protected: 77protected:
76 78
77 void resizeEvent( QResizeEvent * ); 79 void resizeEvent( QResizeEvent * );
78 void mouseReleaseEvent( QMouseEvent *event ); 80 void mouseReleaseEvent( QMouseEvent *event );
79 void keyReleaseEvent( QKeyEvent *e); 81 void keyReleaseEvent( QKeyEvent *e);
80 82