Diffstat (limited to 'noncore/multimedia/opieplayer2/audiowidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index 40e20e1..a718826 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp | |||
@@ -144,50 +144,50 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : | |||
144 | imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); | 144 | imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); |
145 | imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); | 145 | imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); |
146 | 146 | ||
147 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); | 147 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); |
148 | imgButtonMask->fill( 0 ); | 148 | imgButtonMask->fill( 0 ); |
149 | 149 | ||
150 | for ( int i = 0; i < 10; i++ ) { | 150 | for ( int i = 0; i < 10; i++ ) { |
151 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png" ); | 151 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png" ); |
152 | masks[i] = new QBitmap( filename ); | 152 | masks[i] = new QBitmap( filename ); |
153 | 153 | ||
154 | if ( !masks[i]->isNull() ) { | 154 | if ( !masks[i]->isNull() ) { |
155 | QImage imgMask = masks[i]->convertToImage(); | 155 | QImage imgMask = masks[i]->convertToImage(); |
156 | uchar **dest = imgButtonMask->jumpTable(); | 156 | uchar **dest = imgButtonMask->jumpTable(); |
157 | for ( int y = 0; y < imgUp->height(); y++ ) { | 157 | for ( int y = 0; y < imgUp->height(); y++ ) { |
158 | uchar *line = dest[y]; | 158 | uchar *line = dest[y]; |
159 | for ( int x = 0; x < imgUp->width(); x++ ) | 159 | for ( int x = 0; x < imgUp->width(); x++ ) |
160 | if ( !qRed( imgMask.pixel( x, y ) ) ) | 160 | if ( !qRed( imgMask.pixel( x, y ) ) ) |
161 | line[x] = i + 1; | 161 | line[x] = i + 1; |
162 | } | 162 | } |
163 | } | 163 | } |
164 | 164 | ||
165 | } | 165 | } |
166 | 166 | ||
167 | for ( int i = 0; i < 10; i++ ) { | 167 | for ( int i = 0; i < 10; i++ ) { |
168 | buttonPixUp[i] = NULL; | 168 | buttonPixUp[i] = 0l; |
169 | buttonPixDown[i] = NULL; | 169 | buttonPixDown[i] = 0l; |
170 | } | 170 | } |
171 | 171 | ||
172 | setBackgroundPixmap( *pixBg ); | 172 | setBackgroundPixmap( *pixBg ); |
173 | 173 | ||
174 | songInfo.setFocusPolicy( QWidget::NoFocus ); | 174 | songInfo.setFocusPolicy( QWidget::NoFocus ); |
175 | changeTextColor( &songInfo ); | 175 | changeTextColor( &songInfo ); |
176 | 176 | ||
177 | slider.setFixedHeight( 20 ); | 177 | slider.setFixedHeight( 20 ); |
178 | slider.setMinValue( 0 ); | 178 | slider.setMinValue( 0 ); |
179 | slider.setMaxValue( 1 ); | 179 | slider.setMaxValue( 1 ); |
180 | slider.setFocusPolicy( QWidget::NoFocus ); | 180 | slider.setFocusPolicy( QWidget::NoFocus ); |
181 | slider.setBackgroundPixmap( *pixBg ); | 181 | slider.setBackgroundPixmap( *pixBg ); |
182 | 182 | ||
183 | time.setFocusPolicy( QWidget::NoFocus ); | 183 | time.setFocusPolicy( QWidget::NoFocus ); |
184 | time.setAlignment( Qt::AlignCenter ); | 184 | time.setAlignment( Qt::AlignCenter ); |
185 | time.setFrame(FALSE); | 185 | time.setFrame(FALSE); |
186 | changeTextColor( &time ); | 186 | changeTextColor( &time ); |
187 | 187 | ||
188 | resizeEvent( NULL ); | 188 | resizeEvent( NULL ); |
189 | 189 | ||
190 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 190 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
191 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 191 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
192 | 192 | ||
193 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); | 193 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); |
@@ -206,64 +206,66 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : | |||
206 | // Intialise state | 206 | // Intialise state |
207 | setLength( mediaPlayerState->length() ); | 207 | setLength( mediaPlayerState->length() ); |
208 | setPosition( mediaPlayerState->position() ); | 208 | setPosition( mediaPlayerState->position() ); |
209 | setLooping( mediaPlayerState->fullscreen() ); | 209 | setLooping( mediaPlayerState->fullscreen() ); |
210 | // setPaused( mediaPlayerState->paused() ); | 210 | // setPaused( mediaPlayerState->paused() ); |
211 | setPlaying( mediaPlayerState->playing() ); | 211 | setPlaying( mediaPlayerState->playing() ); |
212 | 212 | ||
213 | } | 213 | } |
214 | 214 | ||
215 | AudioWidget::~AudioWidget() { | 215 | AudioWidget::~AudioWidget() { |
216 | 216 | ||
217 | for ( int i = 0; i < 10; i++ ) { | 217 | for ( int i = 0; i < 10; i++ ) { |
218 | delete buttonPixUp[i]; | 218 | delete buttonPixUp[i]; |
219 | delete buttonPixDown[i]; | 219 | delete buttonPixDown[i]; |
220 | } | 220 | } |
221 | delete pixBg; | 221 | delete pixBg; |
222 | delete imgUp; | 222 | delete imgUp; |
223 | delete imgDn; | 223 | delete imgDn; |
224 | delete imgButtonMask; | 224 | delete imgButtonMask; |
225 | for ( int i = 0; i < 10; i++ ) { | 225 | for ( int i = 0; i < 10; i++ ) { |
226 | delete masks[i]; | 226 | delete masks[i]; |
227 | } | 227 | } |
228 | } | 228 | } |
229 | 229 | ||
230 | namespace { | ||
231 | |||
230 | QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | 232 | QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { |
231 | QPixmap pix( img.width(), img.height() ); | 233 | QPixmap pix( img.width(), img.height() ); |
232 | QPainter p( &pix ); | 234 | QPainter p( &pix ); |
233 | p.drawTiledPixmap( pix.rect(), bg, offset ); | 235 | p.drawTiledPixmap( pix.rect(), bg, offset ); |
234 | p.drawImage( 0, 0, img ); | 236 | p.drawImage( 0, 0, img ); |
235 | return new QPixmap( pix ); | 237 | return new QPixmap( pix ); |
236 | } | 238 | } |
237 | 239 | ||
238 | 240 | ||
239 | QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) { | 241 | QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) { |
240 | QPixmap *pixmap = new QPixmap( pix ); | 242 | QPixmap *pixmap = new QPixmap( pix ); |
241 | pixmap->setMask( mask ); | 243 | pixmap->setMask( mask ); |
242 | return pixmap; | 244 | return pixmap; |
243 | } | 245 | } |
244 | 246 | ||
245 | 247 | }; | |
246 | 248 | ||
247 | void AudioWidget::resizeEvent( QResizeEvent * ) { | 249 | void AudioWidget::resizeEvent( QResizeEvent * ) { |
248 | int h = height(); | 250 | int h = height(); |
249 | int w = width(); | 251 | int w = width(); |
250 | 252 | ||
251 | songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) ); | 253 | songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) ); |
252 | slider.setFixedWidth( w - 110 ); | 254 | slider.setFixedWidth( w - 110 ); |
253 | slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); | 255 | slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); |
254 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); | 256 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); |
255 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); | 257 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); |
256 | 258 | ||
257 | xoff = ( w - imgUp->width() ) / 2; | 259 | xoff = ( w - imgUp->width() ) / 2; |
258 | yoff = (( h - imgUp->height() ) / 2) - 10; | 260 | yoff = (( h - imgUp->height() ) / 2) - 10; |
259 | QPoint p( xoff, yoff ); | 261 | QPoint p( xoff, yoff ); |
260 | 262 | ||
261 | QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p ); | 263 | QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p ); |
262 | QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p ); | 264 | QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p ); |
263 | 265 | ||
264 | for ( int i = 0; i < 10; i++ ) { | 266 | for ( int i = 0; i < 10; i++ ) { |
265 | if ( !masks[i]->isNull() ) { | 267 | if ( !masks[i]->isNull() ) { |
266 | delete buttonPixUp[i]; | 268 | delete buttonPixUp[i]; |
267 | delete buttonPixDown[i]; | 269 | delete buttonPixDown[i]; |
268 | buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] ); | 270 | buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] ); |
269 | buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] ); | 271 | buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] ); |