summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer2
authorsimon <simon>2002-12-11 01:09:30 (UTC)
committer simon <simon>2002-12-11 01:09:30 (UTC)
commit7e71955ef58a502d6a6dd2384c3f55bd852d649a (patch) (unidiff)
tree99096f2de6d579ddfa461495cddd07f40859e4d4 /noncore/multimedia/opieplayer2
parent212b7605f9e86d2161e11f65498c37acd1863300 (diff)
downloadopie-7e71955ef58a502d6a6dd2384c3f55bd852d649a.zip
opie-7e71955ef58a502d6a6dd2384c3f55bd852d649a.tar.gz
opie-7e71955ef58a502d6a6dd2384c3f55bd852d649a.tar.bz2
- centralize more of the skin loading code, so it can be factored out later
more easily
Diffstat (limited to 'noncore/multimedia/opieplayer2') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp13
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.cpp23
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.h3
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp11
4 files changed, 28 insertions, 22 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 0b7cc45..bb686f1 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -147,108 +147,97 @@ void AudioWidget::resizeEvent( QResizeEvent * ) {
147 QPixmap pixUp = combineImageWithBackground( buttonUpImage, backgroundPixmap, p ); 147 QPixmap pixUp = combineImageWithBackground( buttonUpImage, backgroundPixmap, p );
148 QPixmap pixDn = combineImageWithBackground( buttonDownImage, backgroundPixmap, p ); 148 QPixmap pixDn = combineImageWithBackground( buttonDownImage, backgroundPixmap, p );
149 149
150 for ( uint i = 0; i < buttons.size(); i++ ) { 150 for ( uint i = 0; i < buttons.size(); i++ ) {
151 if ( !buttons[i].mask.isNull() ) { 151 if ( !buttons[i].mask.isNull() ) {
152 buttons[i].pixUp = maskPixToMask( pixUp, buttons[i].mask ); 152 buttons[i].pixUp = maskPixToMask( pixUp, buttons[i].mask );
153 buttons[i].pixDown = maskPixToMask( pixDn, buttons[i].mask ); 153 buttons[i].pixDown = maskPixToMask( pixDn, buttons[i].mask );
154 } 154 }
155 } 155 }
156} 156}
157 157
158void AudioWidget::sliderPressed() { 158void AudioWidget::sliderPressed() {
159 audioSliderBeingMoved = TRUE; 159 audioSliderBeingMoved = TRUE;
160} 160}
161 161
162 162
163void AudioWidget::sliderReleased() { 163void AudioWidget::sliderReleased() {
164 audioSliderBeingMoved = FALSE; 164 audioSliderBeingMoved = FALSE;
165 if ( slider.width() == 0 ) 165 if ( slider.width() == 0 )
166 return; 166 return;
167 long val = long((double)slider.value() * mediaPlayerState.length() / slider.width()); 167 long val = long((double)slider.value() * mediaPlayerState.length() / slider.width());
168 mediaPlayerState.setPosition( val ); 168 mediaPlayerState.setPosition( val );
169} 169}
170 170
171void AudioWidget::setPosition( long i ) { 171void AudioWidget::setPosition( long i ) {
172 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); 172 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i);
173 updateSlider( i, mediaPlayerState.length() ); 173 updateSlider( i, mediaPlayerState.length() );
174} 174}
175 175
176 176
177void AudioWidget::setLength( long max ) { 177void AudioWidget::setLength( long max ) {
178 updateSlider( mediaPlayerState.position(), max ); 178 updateSlider( mediaPlayerState.position(), max );
179} 179}
180 180
181 181
182void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { 182void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) {
183 if ( mediaType == MediaPlayerState::Audio ) { 183 if ( mediaType == MediaPlayerState::Audio ) {
184 // startTimer( 150 ); 184 // startTimer( 150 );
185 showMaximized(); 185 showMaximized();
186 return; 186 return;
187 } 187 }
188 188
189 killTimers(); 189 killTimers();
190 hide(); 190 hide();
191} 191}
192 192
193void AudioWidget::loadSkin() 193void AudioWidget::loadSkin()
194{ 194{
195 Config cfg("OpiePlayer"); 195 loadDefaultSkin( skinInfo, buttonCount );
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 buttonUpImage = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) );
204 buttonDownImage = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) );
205
206 setupButtons( skinInfo, buttonCount, QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_", buttonUpImage.size() );
207 196
208 setBackgroundPixmap( backgroundPixmap ); 197 setBackgroundPixmap( backgroundPixmap );
209 198
210 songInfo.setFocusPolicy( QWidget::NoFocus ); 199 songInfo.setFocusPolicy( QWidget::NoFocus );
211// changeTextColor( &songInfo ); 200// changeTextColor( &songInfo );
212// songInfo.setBackgroundColor( QColor( 167, 212, 167 )); 201// songInfo.setBackgroundColor( QColor( 167, 212, 167 ));
213// songInfo.setFrameStyle( QFrame::NoFrame); 202// songInfo.setFrameStyle( QFrame::NoFrame);
214 songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); 203 songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken );
215// songInfo.setForegroundColor(Qt::white); 204// songInfo.setForegroundColor(Qt::white);
216 205
217 slider.setFixedHeight( 20 ); 206 slider.setFixedHeight( 20 );
218 slider.setMinValue( 0 ); 207 slider.setMinValue( 0 );
219 slider.setMaxValue( 1 ); 208 slider.setMaxValue( 1 );
220 slider.setFocusPolicy( QWidget::NoFocus ); 209 slider.setFocusPolicy( QWidget::NoFocus );
221 slider.setBackgroundPixmap( backgroundPixmap ); 210 slider.setBackgroundPixmap( backgroundPixmap );
222 211
223// Config cofg("qpe"); 212// Config cofg("qpe");
224// cofg.setGroup("Appearance"); 213// cofg.setGroup("Appearance");
225// QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); 214// QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) );
226 215
227 time.setFocusPolicy( QWidget::NoFocus ); 216 time.setFocusPolicy( QWidget::NoFocus );
228 time.setAlignment( Qt::AlignCenter ); 217 time.setAlignment( Qt::AlignCenter );
229 218
230// time.setFrame(FALSE); 219// time.setFrame(FALSE);
231// changeTextColor( &time ); 220// changeTextColor( &time );
232 221
233 resizeEvent( 0 ); 222 resizeEvent( 0 );
234} 223}
235 224
236void AudioWidget::setSeekable( bool isSeekable ) { 225void AudioWidget::setSeekable( bool isSeekable ) {
237 226
238 if ( !isSeekable ) { 227 if ( !isSeekable ) {
239 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); 228 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>");
240 if( !slider.isHidden()) { 229 if( !slider.isHidden()) {
241 slider.hide(); 230 slider.hide();
242 } 231 }
243 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 232 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
244 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 233 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
245 disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 234 disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
246 disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 235 disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
247 } else { 236 } else {
248 // this stops the slider from being moved, thus 237 // this stops the slider from being moved, thus
249 // does not stop stream when it reaches the end 238 // does not stop stream when it reaches the end
250 slider.show(); 239 slider.show();
251 qDebug( " CONNECT SET POSTION " ); 240 qDebug( " CONNECT SET POSTION " );
252 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 241 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
253 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 242 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
254 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 243 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp
index d60dc0d..c9d7db8 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.cpp
+++ b/noncore/multimedia/opieplayer2/mediawidget.cpp
@@ -1,135 +1,158 @@
1/* 1/*
2 Copyright (C) 2002 Simon Hausmann <hausmann@kde.org> 2 Copyright (C) 2002 Simon Hausmann <hausmann@kde.org>
3 (C) 2002 Max Reiss <harlekin@handhelds.org> 3 (C) 2002 Max Reiss <harlekin@handhelds.org>
4 (C) 2002 L. Potter <ljp@llornkcor.com> 4 (C) 2002 L. Potter <ljp@llornkcor.com>
5 (C) 2002 Holger Freyther <zecke@handhelds.org> 5 (C) 2002 Holger Freyther <zecke@handhelds.org>
6 6
7 This library is free software; you can redistribute it and/or 7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public 8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
11 11
12 This library is distributed in the hope that it will be useful, 12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details. 15 Library General Public License for more details.
16 16
17 You should have received a copy of the GNU Library General Public License 17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to 18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. 20 Boston, MA 02111-1307, USA.
21*/ 21*/
22 22
23 23
24#include "mediawidget.h" 24#include "mediawidget.h"
25#include "playlistwidget.h" 25#include "playlistwidget.h"
26 26
27#include <qpe/config.h>
28#include <qpe/qpeapplication.h>
29
27MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name ) 30MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name )
28 : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) 31 : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ), playList( _playList )
29{ 32{
30 connect( &mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ), 33 connect( &mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ),
31 this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) ); 34 this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) );
32 connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ), 35 connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ),
33 this, SLOT( setLength( long ) ) ); 36 this, SLOT( setLength( long ) ) );
34 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), 37 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ),
35 this, SLOT( setPlaying( bool ) ) ); 38 this, SLOT( setPlaying( bool ) ) );
36} 39}
37 40
38MediaWidget::~MediaWidget() 41MediaWidget::~MediaWidget()
39{ 42{
40} 43}
41 44
42void MediaWidget::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount, 45void MediaWidget::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount,
43 const QString &imagePrefix, const QSize &buttonAreaSize ) 46 const QString &imagePrefix, const QSize &buttonAreaSize )
44{ 47{
45 buttonMask = QImage( buttonAreaSize, 8, 255 ); 48 buttonMask = QImage( buttonAreaSize, 8, 255 );
46 buttonMask.fill( 0 ); 49 buttonMask.fill( 0 );
47 50
48 buttons.clear(); 51 buttons.clear();
49 buttons.reserve( buttonCount ); 52 buttons.reserve( buttonCount );
50 53
51 for ( uint i = 0; i < buttonCount; ++i ) { 54 for ( uint i = 0; i < buttonCount; ++i ) {
52 Button button = setupButton( skinInfo[ i ], imagePrefix ); 55 Button button = setupButton( skinInfo[ i ], imagePrefix );
53 buttons.push_back( button ); 56 buttons.push_back( button );
54 } 57 }
55} 58}
56 59
57MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const QString &imagePrefix ) 60MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const QString &imagePrefix )
58{ 61{
59 Button button; 62 Button button;
60 button.command = buttonInfo.command; 63 button.command = buttonInfo.command;
61 button.type = buttonInfo.type; 64 button.type = buttonInfo.type;
62 65
63 QString fileName = imagePrefix + buttonInfo.fileName + ".png"; 66 QString fileName = imagePrefix + buttonInfo.fileName + ".png";
64 67
65 button.mask = setupButtonMask( button.command, fileName ); 68 button.mask = setupButtonMask( button.command, fileName );
66 69
67 return button; 70 return button;
68} 71}
69 72
70QBitmap MediaWidget::setupButtonMask( const Command &command, const QString &fileName ) 73QBitmap MediaWidget::setupButtonMask( const Command &command, const QString &fileName )
71{ 74{
72 QBitmap mask( fileName ); 75 QBitmap mask( fileName );
73 if ( mask.isNull() ) 76 if ( mask.isNull() )
74 return mask; 77 return mask;
75 78
76 QImage imgMask = mask.convertToImage(); 79 QImage imgMask = mask.convertToImage();
77 uchar **dest = buttonMask.jumpTable(); 80 uchar **dest = buttonMask.jumpTable();
78 for ( int y = 0; y < buttonMask.height(); y++ ) { 81 for ( int y = 0; y < buttonMask.height(); y++ ) {
79 uchar *line = dest[y]; 82 uchar *line = dest[y];
80 for ( int x = 0; x < buttonMask.width(); x++ ) 83 for ( int x = 0; x < buttonMask.width(); x++ )
81 if ( !qRed( imgMask.pixel( x, y ) ) ) 84 if ( !qRed( imgMask.pixel( x, y ) ) )
82 line[x] = command + 1; 85 line[x] = command + 1;
83 } 86 }
84 87
85 return mask; 88 return mask;
86} 89}
87 90
91void MediaWidget::loadDefaultSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const QString &fileNameInfix )
92{
93 Config cfg( "OpiePlayer" );
94 cfg.setGroup( "Options" );
95 QString skin = cfg.readEntry( "Skin","default" );
96
97 loadSkin( skinInfo, buttonCount, skin, fileNameInfix );
98}
99
100void MediaWidget::loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const QString &name, const QString &fileNameInfix )
101{
102 QString skinPath = "opieplayer2/skins/" + name;
103 backgroundPixmap = QPixmap( Resource::loadPixmap( QString( "%1/background" ).arg( skinPath ) ) );
104 buttonUpImage = QImage( Resource::loadImage( QString( "%1/skin%2_up" ).arg( skinPath ).arg( fileNameInfix ) ) );
105 buttonDownImage = QImage( Resource::loadImage( QString( "%1/skin%2_down" ).arg( skinPath ).arg( fileNameInfix ) ) );
106
107 setupButtons( skinInfo, buttonCount,
108 QPEApplication::qpeDir() + "/pics/" + skinPath + QString::fromLatin1( "/skin%1_mask_" ).arg( fileNameInfix ), buttonUpImage.size() );
109}
110
88void MediaWidget::closeEvent( QCloseEvent * ) 111void MediaWidget::closeEvent( QCloseEvent * )
89{ 112{
90 mediaPlayerState.setList(); 113 mediaPlayerState.setList();
91} 114}
92 115
93void MediaWidget::paintEvent( QPaintEvent *pe ) 116void MediaWidget::paintEvent( QPaintEvent *pe )
94{ 117{
95 QPainter p( this ); 118 QPainter p( this );
96 119
97 if ( mediaPlayerState.isFullscreen() ) { 120 if ( mediaPlayerState.isFullscreen() ) {
98 // Clear the background 121 // Clear the background
99 p.setBrush( QBrush( Qt::black ) ); 122 p.setBrush( QBrush( Qt::black ) );
100 return; 123 return;
101 } 124 }
102 125
103 if ( !pe->erased() ) { 126 if ( !pe->erased() ) {
104 // Combine with background and double buffer 127 // Combine with background and double buffer
105 QPixmap pix( pe->rect().size() ); 128 QPixmap pix( pe->rect().size() );
106 QPainter p( &pix ); 129 QPainter p( &pix );
107 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 130 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
108 p.drawTiledPixmap( pe->rect(), backgroundPixmap, pe->rect().topLeft() ); 131 p.drawTiledPixmap( pe->rect(), backgroundPixmap, pe->rect().topLeft() );
109 paintAllButtons( p ); 132 paintAllButtons( p );
110 QPainter p2( this ); 133 QPainter p2( this );
111 p2.drawPixmap( pe->rect().topLeft(), pix ); 134 p2.drawPixmap( pe->rect().topLeft(), pix );
112 } else { 135 } else {
113 QPainter p( this ); 136 QPainter p( this );
114 paintAllButtons( p ); 137 paintAllButtons( p );
115 } 138 }
116} 139}
117 140
118MediaWidget::Button *MediaWidget::buttonAt( const QPoint &position ) 141MediaWidget::Button *MediaWidget::buttonAt( const QPoint &position )
119{ 142{
120 if ( position.x() <= 0 || position.y() <= 0 || 143 if ( position.x() <= 0 || position.y() <= 0 ||
121 position.x() >= buttonMask.width() || 144 position.x() >= buttonMask.width() ||
122 position.y() >= buttonMask.height() ) 145 position.y() >= buttonMask.height() )
123 return 0; 146 return 0;
124 147
125 int pixelIdx = buttonMask.pixelIndex( position.x(), position.y() ); 148 int pixelIdx = buttonMask.pixelIndex( position.x(), position.y() );
126 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) 149 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it )
127 if ( it->command + 1 == pixelIdx ) 150 if ( it->command + 1 == pixelIdx )
128 return &( *it ); 151 return &( *it );
129 152
130 return 0; 153 return 0;
131} 154}
132 155
133void MediaWidget::mousePressEvent( QMouseEvent *event ) 156void MediaWidget::mousePressEvent( QMouseEvent *event )
134{ 157{
135 Button *button = buttonAt( event->pos() - upperLeftOfButtonMask ); 158 Button *button = buttonAt( event->pos() - upperLeftOfButtonMask );
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h
index 754228e..52b9fcb 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.h
+++ b/noncore/multimedia/opieplayer2/mediawidget.h
@@ -59,88 +59,91 @@ public:
59 ButtonType type; // this should be part of the bitfield but gcc2 is too buggy to support this :-( 59 ButtonType type; // this should be part of the bitfield but gcc2 is too buggy to support this :-(
60 bool isDown : 1; 60 bool isDown : 1;
61 61
62 QBitmap mask; 62 QBitmap mask;
63 QPixmap pixUp; 63 QPixmap pixUp;
64 QPixmap pixDown; 64 QPixmap pixDown;
65 }; 65 };
66#if defined( _CC_GNU_ ) 66#if defined( _CC_GNU_ )
67 // use that allocator to avoid the default allocator that on gcc2 requires libstdc++ because 67 // use that allocator to avoid the default allocator that on gcc2 requires libstdc++ because
68 // in the BAD_ALLOC macro it uses std::cerr and friends :-( 68 // in the BAD_ALLOC macro it uses std::cerr and friends :-(
69 typedef std::vector<Button, std::__allocator<Button, simpleAndStupidAllocator> > ButtonVector; 69 typedef std::vector<Button, std::__allocator<Button, simpleAndStupidAllocator> > ButtonVector;
70#else 70#else
71 typedef std::vector<Button> ButtonVector; 71 typedef std::vector<Button> ButtonVector;
72#endif 72#endif
73 73
74 struct SkinButtonInfo 74 struct SkinButtonInfo
75 { 75 {
76 Command command; 76 Command command;
77 const char *fileName; 77 const char *fileName;
78 ButtonType type; 78 ButtonType type;
79 }; 79 };
80 80
81 MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 ); 81 MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 );
82 virtual ~MediaWidget(); 82 virtual ~MediaWidget();
83 83
84public slots: 84public slots:
85 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0; 85 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0;
86 virtual void setLength( long length ) = 0; 86 virtual void setLength( long length ) = 0;
87 virtual void setPlaying( bool playing ) = 0; 87 virtual void setPlaying( bool playing ) = 0;
88 88
89 virtual void loadSkin() = 0; 89 virtual void loadSkin() = 0;
90 90
91signals: 91signals:
92 void moreReleased(); 92 void moreReleased();
93 void lessReleased(); 93 void lessReleased();
94 void forwardReleased(); 94 void forwardReleased();
95 void backReleased(); 95 void backReleased();
96 void forwardClicked(); 96 void forwardClicked();
97 void backClicked(); 97 void backClicked();
98 void moreClicked(); 98 void moreClicked();
99 void lessClicked(); 99 void lessClicked();
100 100
101protected: 101protected:
102 void setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount, 102 void setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount,
103 const QString &imagePrefix, const QSize &buttonAreaSize ); 103 const QString &imagePrefix, const QSize &buttonAreaSize );
104 Button setupButton( const SkinButtonInfo &buttonInfo, const QString &imagePrefix ); 104 Button setupButton( const SkinButtonInfo &buttonInfo, const QString &imagePrefix );
105 QBitmap setupButtonMask( const Command &command, const QString &fileName ); 105 QBitmap setupButtonMask( const Command &command, const QString &fileName );
106 106
107 void loadDefaultSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const QString &fileNameInfix = QString::null );
108 void loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const QString &name, const QString &fileNameInfix );
109
107 virtual void closeEvent( QCloseEvent * ); 110 virtual void closeEvent( QCloseEvent * );
108 111
109 virtual void paintEvent( QPaintEvent *pe ); 112 virtual void paintEvent( QPaintEvent *pe );
110 113
111 Button *buttonAt( const QPoint &position ); 114 Button *buttonAt( const QPoint &position );
112 115
113 virtual void mousePressEvent( QMouseEvent *event ); 116 virtual void mousePressEvent( QMouseEvent *event );
114 virtual void mouseReleaseEvent( QMouseEvent *event ); 117 virtual void mouseReleaseEvent( QMouseEvent *event );
115 118
116 virtual void makeVisible(); 119 virtual void makeVisible();
117 120
118 void handleCommand( Command command, bool buttonDown ); 121 void handleCommand( Command command, bool buttonDown );
119 122
120 bool isOverButton( const QPoint &position, int buttonId ) const; 123 bool isOverButton( const QPoint &position, int buttonId ) const;
121 124
122 void paintAllButtons( QPainter &p ); 125 void paintAllButtons( QPainter &p );
123 void paintButton( const Button &button ); 126 void paintButton( const Button &button );
124 void paintButton( QPainter &p, const Button &button ); 127 void paintButton( QPainter &p, const Button &button );
125 128
126 void setToggleButton( Button &button, bool down ); 129 void setToggleButton( Button &button, bool down );
127 void setToggleButton( Command command, bool down ); 130 void setToggleButton( Command command, bool down );
128 void toggleButton( Button &button ); 131 void toggleButton( Button &button );
129 132
130 MediaPlayerState &mediaPlayerState; 133 MediaPlayerState &mediaPlayerState;
131 PlayListWidget &playList; 134 PlayListWidget &playList;
132 135
133 ButtonVector buttons; 136 ButtonVector buttons;
134 137
135 QImage buttonMask; 138 QImage buttonMask;
136 139
137 QPoint upperLeftOfButtonMask; 140 QPoint upperLeftOfButtonMask;
138 141
139 QPixmap backgroundPixmap; 142 QPixmap backgroundPixmap;
140 QImage buttonUpImage; 143 QImage buttonUpImage;
141 QImage buttonDownImage; 144 QImage buttonDownImage;
142}; 145};
143 146
144#endif // MEDIAWIDGET_H 147#endif // MEDIAWIDGET_H
145/* vim: et sw=4 ts=4 148/* vim: et sw=4 ts=4
146 */ 149 */
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index 0047ac0..bc47717 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -140,106 +140,97 @@ void VideoWidget::resizeEvent( QResizeEvent * ) {
140 140
141 if ( !button.mask.isNull() ) { 141 if ( !button.mask.isNull() ) {
142 button.pixUp = maskVPixToMask( *pixUp, button.mask ); 142 button.pixUp = maskVPixToMask( *pixUp, button.mask );
143 button.pixDown = maskVPixToMask( *pixDn, button.mask ); 143 button.pixDown = maskVPixToMask( *pixDn, button.mask );
144 } 144 }
145 } 145 }
146 146
147 delete pixUp; 147 delete pixUp;
148 delete pixDn; 148 delete pixDn;
149} 149}
150 150
151void VideoWidget::sliderPressed() { 151void VideoWidget::sliderPressed() {
152 videoSliderBeingMoved = TRUE; 152 videoSliderBeingMoved = TRUE;
153} 153}
154 154
155void VideoWidget::sliderReleased() { 155void VideoWidget::sliderReleased() {
156 videoSliderBeingMoved = FALSE; 156 videoSliderBeingMoved = FALSE;
157 if ( slider->width() == 0 ) { 157 if ( slider->width() == 0 ) {
158 return; 158 return;
159 } 159 }
160 long val = long((double)slider->value() * mediaPlayerState.length() / slider->width()); 160 long val = long((double)slider->value() * mediaPlayerState.length() / slider->width());
161 mediaPlayerState.setPosition( val ); 161 mediaPlayerState.setPosition( val );
162} 162}
163 163
164void VideoWidget::setPosition( long i ) { 164void VideoWidget::setPosition( long i ) {
165 updateSlider( i, mediaPlayerState.length() ); 165 updateSlider( i, mediaPlayerState.length() );
166} 166}
167 167
168 168
169void VideoWidget::setLength( long max ) { 169void VideoWidget::setLength( long max ) {
170 updateSlider( mediaPlayerState.position(), max ); 170 updateSlider( mediaPlayerState.position(), max );
171} 171}
172 172
173void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) 173void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType )
174{ 174{
175 if ( displayType == MediaPlayerState::Video ) { 175 if ( displayType == MediaPlayerState::Video ) {
176 makeVisible(); 176 makeVisible();
177 return; 177 return;
178 } 178 }
179 179
180 // 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
181 scaledWidth = 0; 181 scaledWidth = 0;
182 scaledHeight = 0; 182 scaledHeight = 0;
183 hide(); 183 hide();
184} 184}
185 185
186void VideoWidget::loadSkin() 186void VideoWidget::loadSkin()
187{ 187{
188 Config cfg("OpiePlayer"); 188 loadDefaultSkin( skinInfo, buttonCount, "V" );
189 cfg.setGroup("Options");
190 QString skin = cfg.readEntry("Skin","default");
191
192 QString skinPath = "opieplayer2/skins/" + skin;
193 backgroundPixmap = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
194 buttonUpImage = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) );
195 buttonDownImage = QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) );
196
197 setupButtons( skinInfo, buttonCount, QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_", buttonUpImage.size() );
198 189
199 setBackgroundPixmap( backgroundPixmap ); 190 setBackgroundPixmap( backgroundPixmap );
200 191
201 delete slider; 192 delete slider;
202 slider = new QSlider( Qt::Horizontal, this ); 193 slider = new QSlider( Qt::Horizontal, this );
203 slider->setMinValue( 0 ); 194 slider->setMinValue( 0 );
204 slider->setMaxValue( 1 ); 195 slider->setMaxValue( 1 );
205 slider->setBackgroundPixmap( backgroundPixmap ); 196 slider->setBackgroundPixmap( backgroundPixmap );
206 //slider->setFocusPolicy( QWidget::NoFocus ); 197 //slider->setFocusPolicy( QWidget::NoFocus );
207 198
208 resizeEvent( 0 ); 199 resizeEvent( 0 );
209} 200}
210 201
211void VideoWidget::updateSlider( long i, long max ) { 202void VideoWidget::updateSlider( long i, long max ) {
212 // Will flicker too much if we don't do this 203 // Will flicker too much if we don't do this
213 if ( max == 0 ) { 204 if ( max == 0 ) {
214 return; 205 return;
215 } 206 }
216 int width = slider->width(); 207 int width = slider->width();
217 int val = int((double)i * width / max); 208 int val = int((double)i * width / max);
218 if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { 209 if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) {
219 if ( slider->value() != val ) { 210 if ( slider->value() != val ) {
220 slider->setValue( val ); 211 slider->setValue( val );
221 } 212 }
222 if ( slider->maxValue() != width ) { 213 if ( slider->maxValue() != width ) {
223 slider->setMaxValue( width ); 214 slider->setMaxValue( width );
224 } 215 }
225 } 216 }
226} 217}
227 218
228void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 219void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
229 if ( mediaPlayerState.isFullscreen() ) { 220 if ( mediaPlayerState.isFullscreen() ) {
230 mediaPlayerState.setFullscreen( FALSE ); 221 mediaPlayerState.setFullscreen( FALSE );
231 makeVisible(); 222 makeVisible();
232 } 223 }
233 MediaWidget::mouseReleaseEvent( event ); 224 MediaWidget::mouseReleaseEvent( event );
234} 225}
235 226
236void VideoWidget::backToNormal() { 227void VideoWidget::backToNormal() {
237 mediaPlayerState.setFullscreen( FALSE ); 228 mediaPlayerState.setFullscreen( FALSE );
238 makeVisible(); 229 makeVisible();
239} 230}
240 231
241void VideoWidget::makeVisible() { 232void VideoWidget::makeVisible() {
242 if ( mediaPlayerState.isFullscreen() ) { 233 if ( mediaPlayerState.isFullscreen() ) {
243 setBackgroundMode( QWidget::NoBackground ); 234 setBackgroundMode( QWidget::NoBackground );
244 showFullScreen(); 235 showFullScreen();
245 resize( qApp->desktop()->size() ); 236 resize( qApp->desktop()->size() );