summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-09 13:42:19 (UTC)
committer simon <simon>2002-12-09 13:42:19 (UTC)
commit374d7ba11f669449900c7e93f7929d724eb85f26 (patch) (unidiff)
tree1372975b6953972e5ce622da5e967fd452be7f14
parentd0d993b584bba77905955466897a50cea758103c (diff)
downloadopie-374d7ba11f669449900c7e93f7929d724eb85f26.zip
opie-374d7ba11f669449900c7e93f7929d724eb85f26.tar.gz
opie-374d7ba11f669449900c7e93f7929d724eb85f26.tar.bz2
- another hardcoded number removed :)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 2081b4f..8659971 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -124,193 +124,193 @@ AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlaye
124 for ( int x = 0; x < imgUp.width(); x++ ) 124 for ( int x = 0; x < imgUp.width(); x++ )
125 if ( !qRed( imgMask.pixel( x, y ) ) ) 125 if ( !qRed( imgMask.pixel( x, y ) ) )
126 line[x] = i + 1; 126 line[x] = i + 1;
127 } 127 }
128 } 128 }
129 129
130 } 130 }
131 131
132 buttonPixUp.resize( masks.size(), QPixmap() ); 132 buttonPixUp.resize( masks.size(), QPixmap() );
133 buttonPixDown.resize( masks.size(), QPixmap() ); 133 buttonPixDown.resize( masks.size(), QPixmap() );
134 134
135 setBackgroundPixmap( pixBg ); 135 setBackgroundPixmap( pixBg );
136 136
137 songInfo.setFocusPolicy( QWidget::NoFocus ); 137 songInfo.setFocusPolicy( QWidget::NoFocus );
138// changeTextColor( &songInfo ); 138// changeTextColor( &songInfo );
139// songInfo.setBackgroundColor( QColor( 167, 212, 167 )); 139// songInfo.setBackgroundColor( QColor( 167, 212, 167 ));
140// songInfo.setFrameStyle( QFrame::NoFrame); 140// songInfo.setFrameStyle( QFrame::NoFrame);
141 songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); 141 songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken );
142// songInfo.setForegroundColor(Qt::white); 142// songInfo.setForegroundColor(Qt::white);
143 143
144 slider.setFixedHeight( 20 ); 144 slider.setFixedHeight( 20 );
145 slider.setMinValue( 0 ); 145 slider.setMinValue( 0 );
146 slider.setMaxValue( 1 ); 146 slider.setMaxValue( 1 );
147 slider.setFocusPolicy( QWidget::NoFocus ); 147 slider.setFocusPolicy( QWidget::NoFocus );
148 slider.setBackgroundPixmap( pixBg ); 148 slider.setBackgroundPixmap( pixBg );
149 149
150// Config cofg("qpe"); 150// Config cofg("qpe");
151// cofg.setGroup("Appearance"); 151// cofg.setGroup("Appearance");
152// QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); 152// QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) );
153 153
154 time.setFocusPolicy( QWidget::NoFocus ); 154 time.setFocusPolicy( QWidget::NoFocus );
155 time.setAlignment( Qt::AlignCenter ); 155 time.setAlignment( Qt::AlignCenter );
156 156
157// time.setFrame(FALSE); 157// time.setFrame(FALSE);
158// changeTextColor( &time ); 158// changeTextColor( &time );
159 159
160 resizeEvent( NULL ); 160 resizeEvent( NULL );
161 161
162 connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); 162 connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
163 connect( &mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) ); 163 connect( &mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) );
164 164
165 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); 165 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) );
166 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); 166 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) );
167 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); 167 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) );
168 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); 168 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) );
169 169
170 // Intialise state 170 // Intialise state
171 setLength( mediaPlayerState.length() ); 171 setLength( mediaPlayerState.length() );
172 setPosition( mediaPlayerState.position() ); 172 setPosition( mediaPlayerState.position() );
173 setLooping( mediaPlayerState.isFullscreen() ); 173 setLooping( mediaPlayerState.isFullscreen() );
174 // setPaused( mediaPlayerState->paused() ); 174 // setPaused( mediaPlayerState->paused() );
175 setPlaying( mediaPlayerState.isPlaying() ); 175 setPlaying( mediaPlayerState.isPlaying() );
176 176
177} 177}
178 178
179AudioWidget::~AudioWidget() { 179AudioWidget::~AudioWidget() {
180 180
181// mediaPlayerState->setPlaying(false); 181// mediaPlayerState->setPlaying(false);
182} 182}
183 183
184namespace { 184namespace {
185 185
186QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 186QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
187 QPixmap pix( img.width(), img.height() ); 187 QPixmap pix( img.width(), img.height() );
188 QPainter p( &pix ); 188 QPainter p( &pix );
189 p.drawTiledPixmap( pix.rect(), bg, offset ); 189 p.drawTiledPixmap( pix.rect(), bg, offset );
190 p.drawImage( 0, 0, img ); 190 p.drawImage( 0, 0, img );
191 return pix; 191 return pix;
192} 192}
193 193
194 194
195QPixmap maskPixToMask( QPixmap pix, QBitmap mask ) { 195QPixmap maskPixToMask( QPixmap pix, QBitmap mask ) {
196 QPixmap pixmap( pix ); 196 QPixmap pixmap( pix );
197 pixmap.setMask( mask ); 197 pixmap.setMask( mask );
198 return pixmap; 198 return pixmap;
199} 199}
200 200
201}; 201};
202 202
203void AudioWidget::resizeEvent( QResizeEvent * ) { 203void AudioWidget::resizeEvent( QResizeEvent * ) {
204 int h = height(); 204 int h = height();
205 int w = width(); 205 int w = width();
206 206
207 songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); 207 songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) );
208 slider.setFixedWidth( w - 110 ); 208 slider.setFixedWidth( w - 110 );
209 slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); 209 slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
210 slider.setBackgroundOrigin( QWidget::ParentOrigin ); 210 slider.setBackgroundOrigin( QWidget::ParentOrigin );
211 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); 211 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) );
212 212
213 upperLeftOfButtonMask.rx() = ( w - imgUp.width() ) / 2; 213 upperLeftOfButtonMask.rx() = ( w - imgUp.width() ) / 2;
214 upperLeftOfButtonMask.ry() = (( h - imgUp.height() ) / 2) - 10; 214 upperLeftOfButtonMask.ry() = (( h - imgUp.height() ) / 2) - 10;
215 QPoint p = upperLeftOfButtonMask; 215 QPoint p = upperLeftOfButtonMask;
216 216
217 QPixmap pixUp = combineImageWithBackground( imgUp, pixBg, p ); 217 QPixmap pixUp = combineImageWithBackground( imgUp, pixBg, p );
218 QPixmap pixDn = combineImageWithBackground( imgDn, pixBg, p ); 218 QPixmap pixDn = combineImageWithBackground( imgDn, pixBg, p );
219 219
220 for ( int i = 0; i < 10; i++ ) { 220 for ( uint i = 0; i < masks.size(); i++ ) {
221 if ( !masks[i].isNull() ) { 221 if ( !masks[i].isNull() ) {
222 buttonPixUp[i] = maskPixToMask( pixUp, masks[i] ); 222 buttonPixUp[i] = maskPixToMask( pixUp, masks[i] );
223 buttonPixDown[i] = maskPixToMask( pixDn, masks[i] ); 223 buttonPixDown[i] = maskPixToMask( pixDn, masks[i] );
224 } 224 }
225 } 225 }
226} 226}
227 227
228void AudioWidget::sliderPressed() { 228void AudioWidget::sliderPressed() {
229 audioSliderBeingMoved = TRUE; 229 audioSliderBeingMoved = TRUE;
230} 230}
231 231
232 232
233void AudioWidget::sliderReleased() { 233void AudioWidget::sliderReleased() {
234 audioSliderBeingMoved = FALSE; 234 audioSliderBeingMoved = FALSE;
235 if ( slider.width() == 0 ) 235 if ( slider.width() == 0 )
236 return; 236 return;
237 long val = long((double)slider.value() * mediaPlayerState.length() / slider.width()); 237 long val = long((double)slider.value() * mediaPlayerState.length() / slider.width());
238 mediaPlayerState.setPosition( val ); 238 mediaPlayerState.setPosition( val );
239} 239}
240 240
241void AudioWidget::setPosition( long i ) { 241void AudioWidget::setPosition( long i ) {
242 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); 242 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i);
243 updateSlider( i, mediaPlayerState.length() ); 243 updateSlider( i, mediaPlayerState.length() );
244} 244}
245 245
246 246
247void AudioWidget::setLength( long max ) { 247void AudioWidget::setLength( long max ) {
248 updateSlider( mediaPlayerState.position(), max ); 248 updateSlider( mediaPlayerState.position(), max );
249} 249}
250 250
251 251
252void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { 252void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) {
253 if ( mediaType == MediaPlayerState::Audio ) { 253 if ( mediaType == MediaPlayerState::Audio ) {
254 // startTimer( 150 ); 254 // startTimer( 150 );
255 showMaximized(); 255 showMaximized();
256 return; 256 return;
257 } 257 }
258 258
259 killTimers(); 259 killTimers();
260 hide(); 260 hide();
261} 261}
262 262
263 263
264void AudioWidget::setSeekable( bool isSeekable ) { 264void AudioWidget::setSeekable( bool isSeekable ) {
265 265
266 if ( !isSeekable ) { 266 if ( !isSeekable ) {
267 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); 267 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>");
268 if( !slider.isHidden()) { 268 if( !slider.isHidden()) {
269 slider.hide(); 269 slider.hide();
270 } 270 }
271 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 271 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
272 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 272 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
273 disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 273 disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
274 disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 274 disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
275 } else { 275 } else {
276 // this stops the slider from being moved, thus 276 // this stops the slider from being moved, thus
277 // does not stop stream when it reaches the end 277 // does not stop stream when it reaches the end
278 slider.show(); 278 slider.show();
279 qDebug( " CONNECT SET POSTION " ); 279 qDebug( " CONNECT SET POSTION " );
280 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 280 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
281 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 281 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
282 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 282 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
283 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 283 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
284 } 284 }
285} 285}
286 286
287 287
288static QString timeAsString( long length ) { 288static QString timeAsString( long length ) {
289 int minutes = length / 60; 289 int minutes = length / 60;
290 int seconds = length % 60; 290 int seconds = length % 60;
291 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); 291 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 );
292} 292}
293 293
294void AudioWidget::updateSlider( long i, long max ) { 294void AudioWidget::updateSlider( long i, long max ) {
295 295
296 time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); 296 time.setText( timeAsString( i ) + " / " + timeAsString( max ) );
297// qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; 297// qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ;
298 298
299 if ( max == 0 ) { 299 if ( max == 0 ) {
300 return; 300 return;
301 } 301 }
302 // Will flicker too much if we don't do this 302 // Will flicker too much if we don't do this
303 // Scale to something reasonable 303 // Scale to something reasonable
304 int width = slider.width(); 304 int width = slider.width();
305 int val = int((double)i * width / max); 305 int val = int((double)i * width / max);
306 if ( !audioSliderBeingMoved ) { 306 if ( !audioSliderBeingMoved ) {
307 if ( slider.value() != val ) { 307 if ( slider.value() != val ) {
308 slider.setValue( val ); 308 slider.setValue( val );
309 } 309 }
310 310
311 if ( slider.maxValue() != width ) { 311 if ( slider.maxValue() != width ) {
312 slider.setMaxValue( width ); 312 slider.setMaxValue( width );
313 } 313 }
314 } 314 }
315} 315}
316 316