author | simon <simon> | 2002-12-09 18:33:53 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-09 18:33:53 (UTC) |
commit | 711d8c1af3ebdd6f88ff3e9ffa46624c9b63badd (patch) (unidiff) | |
tree | 20ad8855c3e9fcb0e0ec5a79b3d9e934236e1344 | |
parent | 29b5784bba7b19497b5984418bacee261075ccf7 (diff) | |
download | opie-711d8c1af3ebdd6f88ff3e9ffa46624c9b63badd.zip opie-711d8c1af3ebdd6f88ff3e9ffa46624c9b63badd.tar.gz opie-711d8c1af3ebdd6f88ff3e9ffa46624c9b63badd.tar.bz2 |
- another small cleanup in the mouse handling
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 10 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.h | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.cpp | 10 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.h | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 6 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.h | 1 |
6 files changed, 13 insertions, 18 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index dda039c..5986a72 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp | |||
@@ -144,258 +144,248 @@ AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlaye | |||
144 | // QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); | 144 | // QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); |
145 | 145 | ||
146 | time.setFocusPolicy( QWidget::NoFocus ); | 146 | time.setFocusPolicy( QWidget::NoFocus ); |
147 | time.setAlignment( Qt::AlignCenter ); | 147 | time.setAlignment( Qt::AlignCenter ); |
148 | 148 | ||
149 | // time.setFrame(FALSE); | 149 | // time.setFrame(FALSE); |
150 | // changeTextColor( &time ); | 150 | // changeTextColor( &time ); |
151 | 151 | ||
152 | resizeEvent( NULL ); | 152 | resizeEvent( NULL ); |
153 | 153 | ||
154 | connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); | 154 | connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); |
155 | connect( &mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) ); | 155 | connect( &mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) ); |
156 | 156 | ||
157 | connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); | 157 | connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); |
158 | connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); | 158 | connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); |
159 | connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); | 159 | connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); |
160 | connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); | 160 | connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); |
161 | 161 | ||
162 | // Intialise state | 162 | // Intialise state |
163 | setLength( mediaPlayerState.length() ); | 163 | setLength( mediaPlayerState.length() ); |
164 | setPosition( mediaPlayerState.position() ); | 164 | setPosition( mediaPlayerState.position() ); |
165 | setLooping( mediaPlayerState.isFullscreen() ); | 165 | setLooping( mediaPlayerState.isFullscreen() ); |
166 | // setPaused( mediaPlayerState->paused() ); | 166 | // setPaused( mediaPlayerState->paused() ); |
167 | setPlaying( mediaPlayerState.isPlaying() ); | 167 | setPlaying( mediaPlayerState.isPlaying() ); |
168 | 168 | ||
169 | } | 169 | } |
170 | 170 | ||
171 | AudioWidget::~AudioWidget() { | 171 | AudioWidget::~AudioWidget() { |
172 | 172 | ||
173 | // mediaPlayerState->setPlaying(false); | 173 | // mediaPlayerState->setPlaying(false); |
174 | } | 174 | } |
175 | 175 | ||
176 | namespace { | 176 | namespace { |
177 | 177 | ||
178 | QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | 178 | QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { |
179 | QPixmap pix( img.width(), img.height() ); | 179 | QPixmap pix( img.width(), img.height() ); |
180 | QPainter p( &pix ); | 180 | QPainter p( &pix ); |
181 | p.drawTiledPixmap( pix.rect(), bg, offset ); | 181 | p.drawTiledPixmap( pix.rect(), bg, offset ); |
182 | p.drawImage( 0, 0, img ); | 182 | p.drawImage( 0, 0, img ); |
183 | return pix; | 183 | return pix; |
184 | } | 184 | } |
185 | 185 | ||
186 | 186 | ||
187 | QPixmap maskPixToMask( QPixmap pix, QBitmap mask ) { | 187 | QPixmap maskPixToMask( QPixmap pix, QBitmap mask ) { |
188 | QPixmap pixmap( pix ); | 188 | QPixmap pixmap( pix ); |
189 | pixmap.setMask( mask ); | 189 | pixmap.setMask( mask ); |
190 | return pixmap; | 190 | return pixmap; |
191 | } | 191 | } |
192 | 192 | ||
193 | }; | 193 | }; |
194 | 194 | ||
195 | void AudioWidget::resizeEvent( QResizeEvent * ) { | 195 | void AudioWidget::resizeEvent( QResizeEvent * ) { |
196 | int h = height(); | 196 | int h = height(); |
197 | int w = width(); | 197 | int w = width(); |
198 | 198 | ||
199 | songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); | 199 | songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); |
200 | slider.setFixedWidth( w - 110 ); | 200 | slider.setFixedWidth( w - 110 ); |
201 | slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); | 201 | slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); |
202 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); | 202 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); |
203 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); | 203 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); |
204 | 204 | ||
205 | upperLeftOfButtonMask.rx() = ( w - imgUp.width() ) / 2; | 205 | upperLeftOfButtonMask.rx() = ( w - imgUp.width() ) / 2; |
206 | upperLeftOfButtonMask.ry() = (( h - imgUp.height() ) / 2) - 10; | 206 | upperLeftOfButtonMask.ry() = (( h - imgUp.height() ) / 2) - 10; |
207 | QPoint p = upperLeftOfButtonMask; | 207 | QPoint p = upperLeftOfButtonMask; |
208 | 208 | ||
209 | QPixmap pixUp = combineImageWithBackground( imgUp, backgroundPixmap, p ); | 209 | QPixmap pixUp = combineImageWithBackground( imgUp, backgroundPixmap, p ); |
210 | QPixmap pixDn = combineImageWithBackground( imgDn, backgroundPixmap, p ); | 210 | QPixmap pixDn = combineImageWithBackground( imgDn, backgroundPixmap, p ); |
211 | 211 | ||
212 | for ( uint i = 0; i < buttons.size(); i++ ) { | 212 | for ( uint i = 0; i < buttons.size(); i++ ) { |
213 | if ( !buttons[i].mask.isNull() ) { | 213 | if ( !buttons[i].mask.isNull() ) { |
214 | buttons[i].pixUp = maskPixToMask( pixUp, buttons[i].mask ); | 214 | buttons[i].pixUp = maskPixToMask( pixUp, buttons[i].mask ); |
215 | buttons[i].pixDown = maskPixToMask( pixDn, buttons[i].mask ); | 215 | buttons[i].pixDown = maskPixToMask( pixDn, buttons[i].mask ); |
216 | } | 216 | } |
217 | } | 217 | } |
218 | } | 218 | } |
219 | 219 | ||
220 | void AudioWidget::sliderPressed() { | 220 | void AudioWidget::sliderPressed() { |
221 | audioSliderBeingMoved = TRUE; | 221 | audioSliderBeingMoved = TRUE; |
222 | } | 222 | } |
223 | 223 | ||
224 | 224 | ||
225 | void AudioWidget::sliderReleased() { | 225 | void AudioWidget::sliderReleased() { |
226 | audioSliderBeingMoved = FALSE; | 226 | audioSliderBeingMoved = FALSE; |
227 | if ( slider.width() == 0 ) | 227 | if ( slider.width() == 0 ) |
228 | return; | 228 | return; |
229 | long val = long((double)slider.value() * mediaPlayerState.length() / slider.width()); | 229 | long val = long((double)slider.value() * mediaPlayerState.length() / slider.width()); |
230 | mediaPlayerState.setPosition( val ); | 230 | mediaPlayerState.setPosition( val ); |
231 | } | 231 | } |
232 | 232 | ||
233 | void AudioWidget::setPosition( long i ) { | 233 | void AudioWidget::setPosition( long i ) { |
234 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); | 234 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); |
235 | updateSlider( i, mediaPlayerState.length() ); | 235 | updateSlider( i, mediaPlayerState.length() ); |
236 | } | 236 | } |
237 | 237 | ||
238 | 238 | ||
239 | void AudioWidget::setLength( long max ) { | 239 | void AudioWidget::setLength( long max ) { |
240 | updateSlider( mediaPlayerState.position(), max ); | 240 | updateSlider( mediaPlayerState.position(), max ); |
241 | } | 241 | } |
242 | 242 | ||
243 | 243 | ||
244 | void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { | 244 | void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { |
245 | if ( mediaType == MediaPlayerState::Audio ) { | 245 | if ( mediaType == MediaPlayerState::Audio ) { |
246 | // startTimer( 150 ); | 246 | // startTimer( 150 ); |
247 | showMaximized(); | 247 | showMaximized(); |
248 | return; | 248 | return; |
249 | } | 249 | } |
250 | 250 | ||
251 | killTimers(); | 251 | killTimers(); |
252 | hide(); | 252 | hide(); |
253 | } | 253 | } |
254 | 254 | ||
255 | 255 | ||
256 | void AudioWidget::setSeekable( bool isSeekable ) { | 256 | void AudioWidget::setSeekable( bool isSeekable ) { |
257 | 257 | ||
258 | if ( !isSeekable ) { | 258 | if ( !isSeekable ) { |
259 | qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); | 259 | qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); |
260 | if( !slider.isHidden()) { | 260 | if( !slider.isHidden()) { |
261 | slider.hide(); | 261 | slider.hide(); |
262 | } | 262 | } |
263 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 263 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
264 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 264 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
265 | disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 265 | disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
266 | disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 266 | disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
267 | } else { | 267 | } else { |
268 | // this stops the slider from being moved, thus | 268 | // this stops the slider from being moved, thus |
269 | // does not stop stream when it reaches the end | 269 | // does not stop stream when it reaches the end |
270 | slider.show(); | 270 | slider.show(); |
271 | qDebug( " CONNECT SET POSTION " ); | 271 | qDebug( " CONNECT SET POSTION " ); |
272 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 272 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
273 | connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 273 | connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
274 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 274 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
275 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 275 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
276 | } | 276 | } |
277 | } | 277 | } |
278 | 278 | ||
279 | 279 | ||
280 | static QString timeAsString( long length ) { | 280 | static QString timeAsString( long length ) { |
281 | int minutes = length / 60; | 281 | int minutes = length / 60; |
282 | int seconds = length % 60; | 282 | int seconds = length % 60; |
283 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); | 283 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); |
284 | } | 284 | } |
285 | 285 | ||
286 | void AudioWidget::updateSlider( long i, long max ) { | 286 | void AudioWidget::updateSlider( long i, long max ) { |
287 | 287 | ||
288 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); | 288 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); |
289 | // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; | 289 | // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; |
290 | 290 | ||
291 | if ( max == 0 ) { | 291 | if ( max == 0 ) { |
292 | return; | 292 | return; |
293 | } | 293 | } |
294 | // Will flicker too much if we don't do this | 294 | // Will flicker too much if we don't do this |
295 | // Scale to something reasonable | 295 | // Scale to something reasonable |
296 | int width = slider.width(); | 296 | int width = slider.width(); |
297 | int val = int((double)i * width / max); | 297 | int val = int((double)i * width / max); |
298 | if ( !audioSliderBeingMoved ) { | 298 | if ( !audioSliderBeingMoved ) { |
299 | if ( slider.value() != val ) { | 299 | if ( slider.value() != val ) { |
300 | slider.setValue( val ); | 300 | slider.setValue( val ); |
301 | } | 301 | } |
302 | 302 | ||
303 | if ( slider.maxValue() != width ) { | 303 | if ( slider.maxValue() != width ) { |
304 | slider.setMaxValue( width ); | 304 | slider.setMaxValue( width ); |
305 | } | 305 | } |
306 | } | 306 | } |
307 | } | 307 | } |
308 | 308 | ||
309 | void AudioWidget::skipFor() { | 309 | void AudioWidget::skipFor() { |
310 | skipDirection = +1; | 310 | skipDirection = +1; |
311 | startTimer( 50 ); | 311 | startTimer( 50 ); |
312 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); | 312 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); |
313 | } | 313 | } |
314 | 314 | ||
315 | void AudioWidget::skipBack() { | 315 | void AudioWidget::skipBack() { |
316 | skipDirection = -1; | 316 | skipDirection = -1; |
317 | startTimer( 50 ); | 317 | startTimer( 50 ); |
318 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); | 318 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); |
319 | } | 319 | } |
320 | 320 | ||
321 | 321 | ||
322 | 322 | ||
323 | void AudioWidget::stopSkip() { | 323 | void AudioWidget::stopSkip() { |
324 | killTimers(); | 324 | killTimers(); |
325 | } | 325 | } |
326 | 326 | ||
327 | 327 | ||
328 | void AudioWidget::timerEvent( QTimerEvent * ) { | 328 | void AudioWidget::timerEvent( QTimerEvent * ) { |
329 | if ( skipDirection == +1 ) { | 329 | if ( skipDirection == +1 ) { |
330 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); | 330 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); |
331 | } else if ( skipDirection == -1 ) { | 331 | } else if ( skipDirection == -1 ) { |
332 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); | 332 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); |
333 | } | 333 | } |
334 | } | 334 | } |
335 | 335 | ||
336 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { | ||
337 | mouseMoveEvent( event ); | ||
338 | } | ||
339 | |||
340 | |||
341 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { | ||
342 | mouseMoveEvent( event ); | ||
343 | } | ||
344 | |||
345 | |||
346 | void AudioWidget::showEvent( QShowEvent* ) { | 336 | void AudioWidget::showEvent( QShowEvent* ) { |
347 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); | 337 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); |
348 | mouseMoveEvent( &event ); | 338 | mouseMoveEvent( &event ); |
349 | } | 339 | } |
350 | 340 | ||
351 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { | 341 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { |
352 | switch ( e->key() ) { | 342 | switch ( e->key() ) { |
353 | ////////////////////////////// Zaurus keys | 343 | ////////////////////////////// Zaurus keys |
354 | case Key_Home: | 344 | case Key_Home: |
355 | break; | 345 | break; |
356 | case Key_F9: //activity | 346 | case Key_F9: //activity |
357 | hide(); | 347 | hide(); |
358 | // qDebug("Audio F9"); | 348 | // qDebug("Audio F9"); |
359 | break; | 349 | break; |
360 | case Key_F10: //contacts | 350 | case Key_F10: //contacts |
361 | break; | 351 | break; |
362 | case Key_F11: //menu | 352 | case Key_F11: //menu |
363 | mediaPlayerState.toggleBlank(); | 353 | mediaPlayerState.toggleBlank(); |
364 | break; | 354 | break; |
365 | case Key_F12: //home | 355 | case Key_F12: //home |
366 | break; | 356 | break; |
367 | case Key_F13: //mail | 357 | case Key_F13: //mail |
368 | mediaPlayerState.toggleBlank(); | 358 | mediaPlayerState.toggleBlank(); |
369 | break; | 359 | break; |
370 | case Key_Space: { | 360 | case Key_Space: { |
371 | mediaPlayerState.togglePaused(); | 361 | mediaPlayerState.togglePaused(); |
372 | } | 362 | } |
373 | break; | 363 | break; |
374 | case Key_Down: | 364 | case Key_Down: |
375 | // toggleButton(6); | 365 | // toggleButton(6); |
376 | emit lessClicked(); | 366 | emit lessClicked(); |
377 | emit lessReleased(); | 367 | emit lessReleased(); |
378 | // toggleButton(6); | 368 | // toggleButton(6); |
379 | break; | 369 | break; |
380 | case Key_Up: | 370 | case Key_Up: |
381 | // toggleButton(5); | 371 | // toggleButton(5); |
382 | emit moreClicked(); | 372 | emit moreClicked(); |
383 | emit moreReleased(); | 373 | emit moreReleased(); |
384 | // toggleButton(5); | 374 | // toggleButton(5); |
385 | break; | 375 | break; |
386 | case Key_Right: | 376 | case Key_Right: |
387 | // toggleButton(3); | 377 | // toggleButton(3); |
388 | mediaPlayerState.setNext(); | 378 | mediaPlayerState.setNext(); |
389 | // toggleButton(3); | 379 | // toggleButton(3); |
390 | break; | 380 | break; |
391 | case Key_Left: | 381 | case Key_Left: |
392 | // toggleButton(4); | 382 | // toggleButton(4); |
393 | mediaPlayerState.setPrev(); | 383 | mediaPlayerState.setPrev(); |
394 | // toggleButton(4); | 384 | // toggleButton(4); |
395 | break; | 385 | break; |
396 | case Key_Escape: { | 386 | case Key_Escape: { |
397 | } | 387 | } |
398 | break; | 388 | break; |
399 | 389 | ||
400 | }; | 390 | }; |
401 | } | 391 | } |
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h index 690d1b3..e2e2314 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.h +++ b/noncore/multimedia/opieplayer2/audiowidget.h | |||
@@ -1,102 +1,100 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #ifndef AUDIO_WIDGET_H | 34 | #ifndef AUDIO_WIDGET_H |
35 | #define AUDIO_WIDGET_H | 35 | #define AUDIO_WIDGET_H |
36 | 36 | ||
37 | #include <qpainter.h> | 37 | #include <qpainter.h> |
38 | #include <qdrawutil.h> | 38 | #include <qdrawutil.h> |
39 | #include <qpixmap.h> | 39 | #include <qpixmap.h> |
40 | #include <qstring.h> | 40 | #include <qstring.h> |
41 | #include <qslider.h> | 41 | #include <qslider.h> |
42 | #include <qframe.h> | 42 | #include <qframe.h> |
43 | #include <qlineedit.h> | 43 | #include <qlineedit.h> |
44 | #include <qimage.h> | 44 | #include <qimage.h> |
45 | 45 | ||
46 | #include <opie/oticker.h> | 46 | #include <opie/oticker.h> |
47 | 47 | ||
48 | #include "mediawidget.h" | 48 | #include "mediawidget.h" |
49 | 49 | ||
50 | class QPixmap; | 50 | class QPixmap; |
51 | 51 | ||
52 | class AudioWidget : public MediaWidget { | 52 | class AudioWidget : public MediaWidget { |
53 | Q_OBJECT | 53 | Q_OBJECT |
54 | public: | 54 | public: |
55 | AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); | 55 | AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); |
56 | ~AudioWidget(); | 56 | ~AudioWidget(); |
57 | void setTickerText( const QString &text ) { songInfo.setText( text ); } | 57 | void setTickerText( const QString &text ) { songInfo.setText( text ); } |
58 | public slots: | 58 | 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 | ||
66 | public: | 66 | public: |
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 | signals: | 71 | signals: |
72 | void sliderMoved(long); | 72 | void sliderMoved(long); |
73 | 73 | ||
74 | protected: | 74 | protected: |
75 | void doBlank(); | 75 | void doBlank(); |
76 | void doUnblank(); | 76 | void doUnblank(); |
77 | void showEvent( QShowEvent *se ); | 77 | void showEvent( QShowEvent *se ); |
78 | void resizeEvent( QResizeEvent *re ); | 78 | void resizeEvent( QResizeEvent *re ); |
79 | void mousePressEvent( QMouseEvent *event ); | ||
80 | void mouseReleaseEvent( QMouseEvent *event ); | ||
81 | void timerEvent( QTimerEvent *event ); | 79 | void timerEvent( QTimerEvent *event ); |
82 | void keyReleaseEvent( QKeyEvent *e); | 80 | void keyReleaseEvent( QKeyEvent *e); |
83 | private slots: | 81 | private slots: |
84 | void skipFor(); | 82 | void skipFor(); |
85 | void skipBack(); | 83 | void skipBack(); |
86 | void stopSkip(); | 84 | void stopSkip(); |
87 | private: | 85 | private: |
88 | int skipDirection; | 86 | int skipDirection; |
89 | QString skin; | 87 | QString skin; |
90 | QImage imgUp; | 88 | QImage imgUp; |
91 | QImage imgDn; | 89 | QImage imgDn; |
92 | 90 | ||
93 | OTicker songInfo; | 91 | OTicker songInfo; |
94 | QSlider slider; | 92 | QSlider slider; |
95 | QLineEdit time; | 93 | QLineEdit time; |
96 | bool isStreaming : 1; | 94 | bool isStreaming : 1; |
97 | bool audioSliderBeingMoved : 1; | 95 | bool audioSliderBeingMoved : 1; |
98 | }; | 96 | }; |
99 | 97 | ||
100 | 98 | ||
101 | #endif // AUDIO_WIDGET_H | 99 | #endif // AUDIO_WIDGET_H |
102 | 100 | ||
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp index 3533d74..439ba2e 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.cpp +++ b/noncore/multimedia/opieplayer2/mediawidget.cpp | |||
@@ -1,190 +1,200 @@ | |||
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 | MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name ) | 27 | MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name ) |
28 | : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) | 28 | : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) |
29 | { | 29 | { |
30 | connect( &mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ), | 30 | connect( &mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ), |
31 | this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) ); | 31 | this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) ); |
32 | connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ), | 32 | connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ), |
33 | this, SLOT( setLength( long ) ) ); | 33 | this, SLOT( setLength( long ) ) ); |
34 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), | 34 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), |
35 | this, SLOT( setPlaying( bool ) ) ); | 35 | this, SLOT( setPlaying( bool ) ) ); |
36 | } | 36 | } |
37 | 37 | ||
38 | MediaWidget::~MediaWidget() | 38 | MediaWidget::~MediaWidget() |
39 | { | 39 | { |
40 | } | 40 | } |
41 | 41 | ||
42 | void MediaWidget::closeEvent( QCloseEvent * ) | 42 | void MediaWidget::closeEvent( QCloseEvent * ) |
43 | { | 43 | { |
44 | mediaPlayerState.setList(); | 44 | mediaPlayerState.setList(); |
45 | } | 45 | } |
46 | 46 | ||
47 | void MediaWidget::paintEvent( QPaintEvent *pe ) | 47 | void MediaWidget::paintEvent( QPaintEvent *pe ) |
48 | { | 48 | { |
49 | QPainter p( this ); | 49 | QPainter p( this ); |
50 | 50 | ||
51 | if ( mediaPlayerState.isFullscreen() ) { | 51 | if ( mediaPlayerState.isFullscreen() ) { |
52 | // Clear the background | 52 | // Clear the background |
53 | p.setBrush( QBrush( Qt::black ) ); | 53 | p.setBrush( QBrush( Qt::black ) ); |
54 | return; | 54 | return; |
55 | } | 55 | } |
56 | 56 | ||
57 | if ( !pe->erased() ) { | 57 | if ( !pe->erased() ) { |
58 | // Combine with background and double buffer | 58 | // Combine with background and double buffer |
59 | QPixmap pix( pe->rect().size() ); | 59 | QPixmap pix( pe->rect().size() ); |
60 | QPainter p( &pix ); | 60 | QPainter p( &pix ); |
61 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | 61 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); |
62 | p.drawTiledPixmap( pe->rect(), backgroundPixmap, pe->rect().topLeft() ); | 62 | p.drawTiledPixmap( pe->rect(), backgroundPixmap, pe->rect().topLeft() ); |
63 | paintAllButtons( p ); | 63 | paintAllButtons( p ); |
64 | QPainter p2( this ); | 64 | QPainter p2( this ); |
65 | p2.drawPixmap( pe->rect().topLeft(), pix ); | 65 | p2.drawPixmap( pe->rect().topLeft(), pix ); |
66 | } else { | 66 | } else { |
67 | QPainter p( this ); | 67 | QPainter p( this ); |
68 | paintAllButtons( p ); | 68 | paintAllButtons( p ); |
69 | } | 69 | } |
70 | } | 70 | } |
71 | 71 | ||
72 | void MediaWidget::mouseMoveEvent( QMouseEvent *event ) | 72 | void MediaWidget::mouseMoveEvent( QMouseEvent *event ) |
73 | { | 73 | { |
74 | for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) { | 74 | for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) { |
75 | Button &button = *it; | 75 | Button &button = *it; |
76 | Command command = button.command; | 76 | Command command = button.command; |
77 | 77 | ||
78 | if ( event->state() == QMouseEvent::LeftButton ) { | 78 | if ( event->state() == QMouseEvent::LeftButton ) { |
79 | // The test to see if the mouse click is inside the button or not | 79 | // The test to see if the mouse click is inside the button or not |
80 | bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, command ); | 80 | bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, command ); |
81 | 81 | ||
82 | if ( isOnButton && !button.isHeld ) { | 82 | if ( isOnButton && !button.isHeld ) { |
83 | button.isHeld = TRUE; | 83 | button.isHeld = TRUE; |
84 | toggleButton( button ); | 84 | toggleButton( button ); |
85 | switch ( command ) { | 85 | switch ( command ) { |
86 | case VolumeUp: | 86 | case VolumeUp: |
87 | emit moreClicked(); | 87 | emit moreClicked(); |
88 | return; | 88 | return; |
89 | case VolumeDown: | 89 | case VolumeDown: |
90 | emit lessClicked(); | 90 | emit lessClicked(); |
91 | return; | 91 | return; |
92 | case Forward: | 92 | case Forward: |
93 | emit forwardClicked(); | 93 | emit forwardClicked(); |
94 | return; | 94 | return; |
95 | case Back: | 95 | case Back: |
96 | emit backClicked(); | 96 | emit backClicked(); |
97 | return; | 97 | return; |
98 | default: break; | 98 | default: break; |
99 | } | 99 | } |
100 | } else if ( !isOnButton && button.isHeld ) { | 100 | } else if ( !isOnButton && button.isHeld ) { |
101 | button.isHeld = FALSE; | 101 | button.isHeld = FALSE; |
102 | toggleButton( button ); | 102 | toggleButton( button ); |
103 | } | 103 | } |
104 | } else { | 104 | } else { |
105 | if ( button.isHeld ) { | 105 | if ( button.isHeld ) { |
106 | button.isHeld = FALSE; | 106 | button.isHeld = FALSE; |
107 | if ( button.type != ToggleButton ) { | 107 | if ( button.type != ToggleButton ) { |
108 | setToggleButton( button, FALSE ); | 108 | setToggleButton( button, FALSE ); |
109 | } | 109 | } |
110 | handleCommand( command, button.isDown ); | 110 | handleCommand( command, button.isDown ); |
111 | } | 111 | } |
112 | } | 112 | } |
113 | } | 113 | } |
114 | } | 114 | } |
115 | 115 | ||
116 | void MediaWidget::mousePressEvent( QMouseEvent *event ) | ||
117 | { | ||
118 | mouseMoveEvent( event ); | ||
119 | } | ||
120 | |||
121 | void MediaWidget::mouseReleaseEvent( QMouseEvent *event ) | ||
122 | { | ||
123 | mouseMoveEvent( event ); | ||
124 | } | ||
125 | |||
116 | void MediaWidget::makeVisible() | 126 | void MediaWidget::makeVisible() |
117 | { | 127 | { |
118 | } | 128 | } |
119 | 129 | ||
120 | void MediaWidget::handleCommand( Command command, bool buttonDown ) | 130 | void MediaWidget::handleCommand( Command command, bool buttonDown ) |
121 | { | 131 | { |
122 | switch ( command ) { | 132 | switch ( command ) { |
123 | case Play: mediaPlayerState.togglePaused(); | 133 | case Play: mediaPlayerState.togglePaused(); |
124 | case Stop: mediaPlayerState.setPlaying(FALSE); return; | 134 | case Stop: mediaPlayerState.setPlaying(FALSE); return; |
125 | case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; | 135 | case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; |
126 | case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; | 136 | case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; |
127 | case Loop: mediaPlayerState.setLooping( buttonDown ); return; | 137 | case Loop: mediaPlayerState.setLooping( buttonDown ); return; |
128 | case VolumeUp: emit moreReleased(); return; | 138 | case VolumeUp: emit moreReleased(); return; |
129 | case VolumeDown: emit lessReleased(); return; | 139 | case VolumeDown: emit lessReleased(); return; |
130 | case PlayList: mediaPlayerState.setList(); return; | 140 | case PlayList: mediaPlayerState.setList(); return; |
131 | case Forward: emit forwardReleased(); return; | 141 | case Forward: emit forwardReleased(); return; |
132 | case Back: emit backReleased(); return; | 142 | case Back: emit backReleased(); return; |
133 | case FullScreen: mediaPlayerState.setFullscreen( true ); makeVisible(); return; | 143 | case FullScreen: mediaPlayerState.setFullscreen( true ); makeVisible(); return; |
134 | default: assert( false ); | 144 | default: assert( false ); |
135 | } | 145 | } |
136 | } | 146 | } |
137 | 147 | ||
138 | bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const | 148 | bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const |
139 | { | 149 | { |
140 | return ( position.x() > 0 && position.y() > 0 && | 150 | return ( position.x() > 0 && position.y() > 0 && |
141 | position.x() < buttonMask.width() && | 151 | position.x() < buttonMask.width() && |
142 | position.y() < buttonMask.height() && | 152 | position.y() < buttonMask.height() && |
143 | buttonMask.pixelIndex( position.x(), position.y() ) == buttonId + 1 ); | 153 | buttonMask.pixelIndex( position.x(), position.y() ) == buttonId + 1 ); |
144 | } | 154 | } |
145 | 155 | ||
146 | void MediaWidget::paintAllButtons( QPainter &p ) | 156 | void MediaWidget::paintAllButtons( QPainter &p ) |
147 | { | 157 | { |
148 | for ( ButtonVector::const_iterator it = buttons.begin(); | 158 | for ( ButtonVector::const_iterator it = buttons.begin(); |
149 | it != buttons.end(); ++it ) | 159 | it != buttons.end(); ++it ) |
150 | paintButton( p, *it ); | 160 | paintButton( p, *it ); |
151 | } | 161 | } |
152 | 162 | ||
153 | void MediaWidget::paintButton( const Button &button ) | 163 | void MediaWidget::paintButton( const Button &button ) |
154 | { | 164 | { |
155 | QPainter p( this ); | 165 | QPainter p( this ); |
156 | paintButton( p, button ); | 166 | paintButton( p, button ); |
157 | } | 167 | } |
158 | 168 | ||
159 | void MediaWidget::paintButton( QPainter &p, const Button &button ) | 169 | void MediaWidget::paintButton( QPainter &p, const Button &button ) |
160 | { | 170 | { |
161 | if ( button.isDown ) | 171 | if ( button.isDown ) |
162 | p.drawPixmap( upperLeftOfButtonMask, button.pixDown ); | 172 | p.drawPixmap( upperLeftOfButtonMask, button.pixDown ); |
163 | else | 173 | else |
164 | p.drawPixmap( upperLeftOfButtonMask, button.pixUp ); | 174 | p.drawPixmap( upperLeftOfButtonMask, button.pixUp ); |
165 | } | 175 | } |
166 | 176 | ||
167 | void MediaWidget::setToggleButton( Command command, bool down ) | 177 | void MediaWidget::setToggleButton( Command command, bool down ) |
168 | { | 178 | { |
169 | for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) | 179 | for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) |
170 | if ( it->command == command ) { | 180 | if ( it->command == command ) { |
171 | setToggleButton( *it, down ); | 181 | setToggleButton( *it, down ); |
172 | return; | 182 | return; |
173 | } | 183 | } |
174 | } | 184 | } |
175 | 185 | ||
176 | void MediaWidget::setToggleButton( Button &button, bool down ) | 186 | void MediaWidget::setToggleButton( Button &button, bool down ) |
177 | { | 187 | { |
178 | if ( down != button.isDown ) | 188 | if ( down != button.isDown ) |
179 | toggleButton( button ); | 189 | toggleButton( button ); |
180 | } | 190 | } |
181 | 191 | ||
182 | void MediaWidget::toggleButton( Button &button ) | 192 | void MediaWidget::toggleButton( Button &button ) |
183 | { | 193 | { |
184 | button.isDown = !button.isDown; | 194 | button.isDown = !button.isDown; |
185 | 195 | ||
186 | paintButton( button ); | 196 | paintButton( button ); |
187 | } | 197 | } |
188 | 198 | ||
189 | /* vim: et sw=4 ts=4 | 199 | /* vim: et sw=4 ts=4 |
190 | */ | 200 | */ |
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h index c261728..9042d5b 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.h +++ b/noncore/multimedia/opieplayer2/mediawidget.h | |||
@@ -1,120 +1,122 @@ | |||
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 | #ifndef MEDIAWIDGET_H | 23 | #ifndef MEDIAWIDGET_H |
24 | #define MEDIAWIDGET_H | 24 | #define MEDIAWIDGET_H |
25 | 25 | ||
26 | #include <qwidget.h> | 26 | #include <qwidget.h> |
27 | #include <qmap.h> | 27 | #include <qmap.h> |
28 | 28 | ||
29 | #include "mediaplayerstate.h" | 29 | #include "mediaplayerstate.h" |
30 | #include "playlistwidget.h" | 30 | #include "playlistwidget.h" |
31 | 31 | ||
32 | #include <vector> | 32 | #include <vector> |
33 | 33 | ||
34 | class MediaWidget : public QWidget | 34 | class MediaWidget : public QWidget |
35 | { | 35 | { |
36 | Q_OBJECT | 36 | Q_OBJECT |
37 | public: | 37 | public: |
38 | enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back, FullScreen, Undefined }; | 38 | enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back, FullScreen, Undefined }; |
39 | enum ButtonType { NormalButton, ToggleButton }; | 39 | enum ButtonType { NormalButton, ToggleButton }; |
40 | 40 | ||
41 | struct Button | 41 | struct Button |
42 | { | 42 | { |
43 | Button() : command( Undefined ), type( NormalButton ), isHeld( false ), isDown( false ) {} | 43 | Button() : command( Undefined ), type( NormalButton ), isHeld( false ), isDown( false ) {} |
44 | 44 | ||
45 | Command command; | 45 | Command command; |
46 | 46 | ||
47 | ButtonType type; // this should be part of the bitfield but gcc2 is too buggy to support this :-( | 47 | ButtonType type; // this should be part of the bitfield but gcc2 is too buggy to support this :-( |
48 | bool isHeld : 1; | 48 | bool isHeld : 1; |
49 | bool isDown : 1; | 49 | bool isDown : 1; |
50 | 50 | ||
51 | QBitmap mask; | 51 | QBitmap mask; |
52 | QPixmap pixUp; | 52 | QPixmap pixUp; |
53 | QPixmap pixDown; | 53 | QPixmap pixDown; |
54 | }; | 54 | }; |
55 | typedef std::vector<Button> ButtonVector; | 55 | typedef std::vector<Button> ButtonVector; |
56 | 56 | ||
57 | struct SkinButtonInfo | 57 | struct SkinButtonInfo |
58 | { | 58 | { |
59 | Command command; | 59 | Command command; |
60 | const char *fileName; | 60 | const char *fileName; |
61 | ButtonType type; | 61 | ButtonType type; |
62 | }; | 62 | }; |
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 | ||
70 | public slots: | 70 | public 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 | signals: | 75 | signals: |
76 | void moreReleased(); | 76 | void moreReleased(); |
77 | void lessReleased(); | 77 | void lessReleased(); |
78 | void forwardReleased(); | 78 | void forwardReleased(); |
79 | void backReleased(); | 79 | void backReleased(); |
80 | void forwardClicked(); | 80 | void forwardClicked(); |
81 | void backClicked(); | 81 | void backClicked(); |
82 | void moreClicked(); | 82 | void moreClicked(); |
83 | void lessClicked(); | 83 | void lessClicked(); |
84 | 84 | ||
85 | protected: | 85 | protected: |
86 | virtual void closeEvent( QCloseEvent * ); | 86 | virtual void closeEvent( QCloseEvent * ); |
87 | 87 | ||
88 | virtual void paintEvent( QPaintEvent *pe ); | 88 | virtual void paintEvent( QPaintEvent *pe ); |
89 | 89 | ||
90 | virtual void mouseMoveEvent( QMouseEvent *event ); | 90 | virtual void mouseMoveEvent( QMouseEvent *event ); |
91 | virtual void mousePressEvent( QMouseEvent *event ); | ||
92 | virtual void mouseReleaseEvent( QMouseEvent *event ); | ||
91 | 93 | ||
92 | virtual void makeVisible(); | 94 | virtual void makeVisible(); |
93 | 95 | ||
94 | void handleCommand( Command command, bool buttonDown ); | 96 | void handleCommand( Command command, bool buttonDown ); |
95 | 97 | ||
96 | bool isOverButton( const QPoint &position, int buttonId ) const; | 98 | bool isOverButton( const QPoint &position, int buttonId ) const; |
97 | 99 | ||
98 | void paintAllButtons( QPainter &p ); | 100 | void paintAllButtons( QPainter &p ); |
99 | void paintButton( const Button &button ); | 101 | void paintButton( const Button &button ); |
100 | void paintButton( QPainter &p, const Button &button ); | 102 | void paintButton( QPainter &p, const Button &button ); |
101 | 103 | ||
102 | void setToggleButton( Button &button, bool down ); | 104 | void setToggleButton( Button &button, bool down ); |
103 | void setToggleButton( Command command, bool down ); | 105 | void setToggleButton( Command command, bool down ); |
104 | void toggleButton( Button &button ); | 106 | void toggleButton( Button &button ); |
105 | 107 | ||
106 | MediaPlayerState &mediaPlayerState; | 108 | MediaPlayerState &mediaPlayerState; |
107 | PlayListWidget &playList; | 109 | PlayListWidget &playList; |
108 | 110 | ||
109 | ButtonVector buttons; | 111 | ButtonVector buttons; |
110 | 112 | ||
111 | QImage buttonMask; | 113 | QImage buttonMask; |
112 | 114 | ||
113 | QPoint upperLeftOfButtonMask; | 115 | QPoint upperLeftOfButtonMask; |
114 | 116 | ||
115 | QPixmap backgroundPixmap; | 117 | QPixmap backgroundPixmap; |
116 | }; | 118 | }; |
117 | 119 | ||
118 | #endif // MEDIAWIDGET_H | 120 | #endif // MEDIAWIDGET_H |
119 | /* vim: et sw=4 ts=4 | 121 | /* vim: et sw=4 ts=4 |
120 | */ | 122 | */ |
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index 26777e6..04b09f9 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp | |||
@@ -52,323 +52,319 @@ | |||
52 | # include <qgfxraster_qws.h> | 52 | # include <qgfxraster_qws.h> |
53 | #endif | 53 | #endif |
54 | 54 | ||
55 | 55 | ||
56 | namespace | 56 | namespace |
57 | { | 57 | { |
58 | 58 | ||
59 | const int xo = 2; // movable x offset | 59 | const int xo = 2; // movable x offset |
60 | const int yo = 0; // movable y offset | 60 | const int yo = 0; // movable y offset |
61 | 61 | ||
62 | const MediaWidget::SkinButtonInfo skinInfo[] = | 62 | const MediaWidget::SkinButtonInfo skinInfo[] = |
63 | { | 63 | { |
64 | { MediaWidget::Play, "play", MediaWidget::ToggleButton }, | 64 | { MediaWidget::Play, "play", MediaWidget::ToggleButton }, |
65 | { MediaWidget::Stop, "stop", MediaWidget::NormalButton }, | 65 | { MediaWidget::Stop, "stop", MediaWidget::NormalButton }, |
66 | { MediaWidget::Next, "fwd", MediaWidget::NormalButton }, | 66 | { MediaWidget::Next, "fwd", MediaWidget::NormalButton }, |
67 | { MediaWidget::Previous, "back", MediaWidget::NormalButton }, | 67 | { MediaWidget::Previous, "back", MediaWidget::NormalButton }, |
68 | { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton }, | 68 | { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton }, |
69 | { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton }, | 69 | { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton }, |
70 | { MediaWidget::FullScreen, "full", MediaWidget::ToggleButton } | 70 | { MediaWidget::FullScreen, "full", MediaWidget::ToggleButton } |
71 | }; | 71 | }; |
72 | 72 | ||
73 | const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] ); | 73 | const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] ); |
74 | 74 | ||
75 | } | 75 | } |
76 | 76 | ||
77 | VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) | 77 | VideoWidget::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 | 82 | ||
83 | videoFrame = new XineVideoWidget ( this, "Video frame" ); | 83 | videoFrame = new XineVideoWidget ( this, "Video frame" ); |
84 | 84 | ||
85 | connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); | 85 | connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); |
86 | connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); | 86 | connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); |
87 | 87 | ||
88 | Config cfg("OpiePlayer"); | 88 | Config cfg("OpiePlayer"); |
89 | cfg.setGroup("Options"); | 89 | cfg.setGroup("Options"); |
90 | skin = cfg.readEntry("Skin","default"); | 90 | skin = cfg.readEntry("Skin","default"); |
91 | 91 | ||
92 | QString skinPath = "opieplayer2/skins/" + skin; | 92 | QString skinPath = "opieplayer2/skins/" + skin; |
93 | backgroundPixmap = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 93 | backgroundPixmap = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
94 | imgUp = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); | 94 | imgUp = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); |
95 | imgDn = QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); | 95 | imgDn = QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); |
96 | 96 | ||
97 | buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); | 97 | buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); |
98 | buttonMask.fill( 0 ); | 98 | buttonMask.fill( 0 ); |
99 | 99 | ||
100 | for ( uint i = 0; i < buttonCount; i++ ) { | 100 | for ( uint i = 0; i < buttonCount; i++ ) { |
101 | Button button; | 101 | Button button; |
102 | button.command = skinInfo[ i ].command; | 102 | button.command = skinInfo[ i ].command; |
103 | button.type = skinInfo[ i ].type; | 103 | button.type = skinInfo[ i ].type; |
104 | 104 | ||
105 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinInfo[i].fileName + ".png" ); | 105 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinInfo[i].fileName + ".png" ); |
106 | button.mask =QBitmap( filename ); | 106 | button.mask =QBitmap( filename ); |
107 | 107 | ||
108 | if ( !button.mask.isNull() ) { | 108 | if ( !button.mask.isNull() ) { |
109 | QImage imgMask = button.mask.convertToImage(); | 109 | QImage imgMask = button.mask.convertToImage(); |
110 | uchar **dest = buttonMask.jumpTable(); | 110 | uchar **dest = buttonMask.jumpTable(); |
111 | for ( int y = 0; y < imgUp.height(); y++ ) { | 111 | for ( int y = 0; y < imgUp.height(); y++ ) { |
112 | uchar *line = dest[y]; | 112 | uchar *line = dest[y]; |
113 | for ( int x = 0; x < imgUp.width(); x++ ) | 113 | for ( int x = 0; x < imgUp.width(); x++ ) |
114 | if ( !qRed( imgMask.pixel( x, y ) ) ) | 114 | if ( !qRed( imgMask.pixel( x, y ) ) ) |
115 | line[x] = button.command + 1; | 115 | line[x] = button.command + 1; |
116 | } | 116 | } |
117 | } | 117 | } |
118 | 118 | ||
119 | buttons.push_back( button ); | 119 | buttons.push_back( button ); |
120 | } | 120 | } |
121 | 121 | ||
122 | setBackgroundPixmap( backgroundPixmap ); | 122 | setBackgroundPixmap( backgroundPixmap ); |
123 | 123 | ||
124 | slider = new QSlider( Qt::Horizontal, this ); | 124 | slider = new QSlider( Qt::Horizontal, this ); |
125 | slider->setMinValue( 0 ); | 125 | slider->setMinValue( 0 ); |
126 | slider->setMaxValue( 1 ); | 126 | slider->setMaxValue( 1 ); |
127 | slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); | 127 | slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); |
128 | //slider->setFocusPolicy( QWidget::NoFocus ); | 128 | //slider->setFocusPolicy( QWidget::NoFocus ); |
129 | 129 | ||
130 | resizeEvent( NULL ); | 130 | resizeEvent( NULL ); |
131 | 131 | ||
132 | setLength( mediaPlayerState.length() ); | 132 | setLength( mediaPlayerState.length() ); |
133 | setPosition( mediaPlayerState.position() ); | 133 | setPosition( mediaPlayerState.position() ); |
134 | setFullscreen( mediaPlayerState.isFullscreen() ); | 134 | setFullscreen( mediaPlayerState.isFullscreen() ); |
135 | setPlaying( mediaPlayerState.isPlaying() ); | 135 | setPlaying( mediaPlayerState.isPlaying() ); |
136 | } | 136 | } |
137 | 137 | ||
138 | 138 | ||
139 | VideoWidget::~VideoWidget() | 139 | VideoWidget::~VideoWidget() |
140 | { | 140 | { |
141 | } | 141 | } |
142 | 142 | ||
143 | QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | 143 | QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { |
144 | QPixmap pix( img.width(), img.height() ); | 144 | QPixmap pix( img.width(), img.height() ); |
145 | QPainter p( &pix ); | 145 | QPainter p( &pix ); |
146 | p.drawTiledPixmap( pix.rect(), bg, offset ); | 146 | p.drawTiledPixmap( pix.rect(), bg, offset ); |
147 | p.drawImage( 0, 0, img ); | 147 | p.drawImage( 0, 0, img ); |
148 | return new QPixmap( pix ); | 148 | return new QPixmap( pix ); |
149 | } | 149 | } |
150 | 150 | ||
151 | QPixmap maskVPixToMask( QPixmap pix, QBitmap mask ) { | 151 | QPixmap maskVPixToMask( QPixmap pix, QBitmap mask ) { |
152 | QPixmap pixmap( pix ); | 152 | QPixmap pixmap( pix ); |
153 | pixmap.setMask( mask ); | 153 | pixmap.setMask( mask ); |
154 | return pixmap; | 154 | return pixmap; |
155 | } | 155 | } |
156 | 156 | ||
157 | void VideoWidget::resizeEvent( QResizeEvent * ) { | 157 | void VideoWidget::resizeEvent( QResizeEvent * ) { |
158 | int h = height(); | 158 | int h = height(); |
159 | int w = width(); | 159 | int w = width(); |
160 | //int Vh = 160; | 160 | //int Vh = 160; |
161 | //int Vw = 220; | 161 | //int Vw = 220; |
162 | 162 | ||
163 | slider->setFixedWidth( w - 20 ); | 163 | slider->setFixedWidth( w - 20 ); |
164 | slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); | 164 | slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); |
165 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); | 165 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); |
166 | slider->setFocusPolicy( QWidget::NoFocus ); | 166 | slider->setFocusPolicy( QWidget::NoFocus ); |
167 | slider->setBackgroundPixmap( backgroundPixmap ); | 167 | slider->setBackgroundPixmap( backgroundPixmap ); |
168 | 168 | ||
169 | upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2; | 169 | upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2; |
170 | if(w>h) | 170 | if(w>h) |
171 | upperLeftOfButtonMask.ry() = 0; | 171 | upperLeftOfButtonMask.ry() = 0; |
172 | else | 172 | else |
173 | upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10; | 173 | upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10; |
174 | QPoint p = upperLeftOfButtonMask; | 174 | QPoint p = upperLeftOfButtonMask; |
175 | 175 | ||
176 | QPixmap *pixUp = combineVImageWithBackground( imgUp, backgroundPixmap, p ); | 176 | QPixmap *pixUp = combineVImageWithBackground( imgUp, backgroundPixmap, p ); |
177 | QPixmap *pixDn = combineVImageWithBackground( imgDn, backgroundPixmap, p ); | 177 | QPixmap *pixDn = combineVImageWithBackground( imgDn, backgroundPixmap, p ); |
178 | 178 | ||
179 | for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) { | 179 | for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) { |
180 | Button &button = *it; | 180 | Button &button = *it; |
181 | 181 | ||
182 | if ( !button.mask.isNull() ) { | 182 | if ( !button.mask.isNull() ) { |
183 | button.pixUp = maskVPixToMask( *pixUp, button.mask ); | 183 | button.pixUp = maskVPixToMask( *pixUp, button.mask ); |
184 | button.pixDown = maskVPixToMask( *pixDn, button.mask ); | 184 | button.pixDown = maskVPixToMask( *pixDn, button.mask ); |
185 | } | 185 | } |
186 | } | 186 | } |
187 | 187 | ||
188 | delete pixUp; | 188 | delete pixUp; |
189 | delete pixDn; | 189 | delete pixDn; |
190 | } | 190 | } |
191 | 191 | ||
192 | void VideoWidget::sliderPressed() { | 192 | void VideoWidget::sliderPressed() { |
193 | videoSliderBeingMoved = TRUE; | 193 | videoSliderBeingMoved = TRUE; |
194 | } | 194 | } |
195 | 195 | ||
196 | void VideoWidget::sliderReleased() { | 196 | void VideoWidget::sliderReleased() { |
197 | videoSliderBeingMoved = FALSE; | 197 | videoSliderBeingMoved = FALSE; |
198 | if ( slider->width() == 0 ) { | 198 | if ( slider->width() == 0 ) { |
199 | return; | 199 | return; |
200 | } | 200 | } |
201 | long val = long((double)slider->value() * mediaPlayerState.length() / slider->width()); | 201 | long val = long((double)slider->value() * mediaPlayerState.length() / slider->width()); |
202 | mediaPlayerState.setPosition( val ); | 202 | mediaPlayerState.setPosition( val ); |
203 | } | 203 | } |
204 | 204 | ||
205 | void VideoWidget::setPosition( long i ) { | 205 | void VideoWidget::setPosition( long i ) { |
206 | updateSlider( i, mediaPlayerState.length() ); | 206 | updateSlider( i, mediaPlayerState.length() ); |
207 | } | 207 | } |
208 | 208 | ||
209 | 209 | ||
210 | void VideoWidget::setLength( long max ) { | 210 | void VideoWidget::setLength( long max ) { |
211 | updateSlider( mediaPlayerState.position(), max ); | 211 | updateSlider( mediaPlayerState.position(), max ); |
212 | } | 212 | } |
213 | 213 | ||
214 | void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) | 214 | void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) |
215 | { | 215 | { |
216 | if ( displayType == MediaPlayerState::Video ) { | 216 | if ( displayType == MediaPlayerState::Video ) { |
217 | makeVisible(); | 217 | makeVisible(); |
218 | return; | 218 | return; |
219 | } | 219 | } |
220 | 220 | ||
221 | // Effectively blank the view next time we show it so it looks nicer | 221 | // Effectively blank the view next time we show it so it looks nicer |
222 | scaledWidth = 0; | 222 | scaledWidth = 0; |
223 | scaledHeight = 0; | 223 | scaledHeight = 0; |
224 | hide(); | 224 | hide(); |
225 | } | 225 | } |
226 | 226 | ||
227 | void VideoWidget::updateSlider( long i, long max ) { | 227 | void VideoWidget::updateSlider( long i, long max ) { |
228 | // Will flicker too much if we don't do this | 228 | // Will flicker too much if we don't do this |
229 | if ( max == 0 ) { | 229 | if ( max == 0 ) { |
230 | return; | 230 | return; |
231 | } | 231 | } |
232 | int width = slider->width(); | 232 | int width = slider->width(); |
233 | int val = int((double)i * width / max); | 233 | int val = int((double)i * width / max); |
234 | if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { | 234 | if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { |
235 | if ( slider->value() != val ) { | 235 | if ( slider->value() != val ) { |
236 | slider->setValue( val ); | 236 | slider->setValue( val ); |
237 | } | 237 | } |
238 | if ( slider->maxValue() != width ) { | 238 | if ( slider->maxValue() != width ) { |
239 | slider->setMaxValue( width ); | 239 | slider->setMaxValue( width ); |
240 | } | 240 | } |
241 | } | 241 | } |
242 | } | 242 | } |
243 | 243 | ||
244 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { | ||
245 | mouseMoveEvent( event ); | ||
246 | } | ||
247 | |||
248 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { | 244 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { |
249 | if ( mediaPlayerState.isFullscreen() ) { | 245 | if ( mediaPlayerState.isFullscreen() ) { |
250 | mediaPlayerState.setFullscreen( FALSE ); | 246 | mediaPlayerState.setFullscreen( FALSE ); |
251 | makeVisible(); | 247 | makeVisible(); |
252 | } | 248 | } |
253 | mouseMoveEvent( event ); | 249 | MediaWidget::mouseReleaseEvent( event ); |
254 | } | 250 | } |
255 | 251 | ||
256 | void VideoWidget::showEvent( QShowEvent* ) { | 252 | void VideoWidget::showEvent( QShowEvent* ) { |
257 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); | 253 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); |
258 | mouseMoveEvent( &event ); | 254 | mouseMoveEvent( &event ); |
259 | } | 255 | } |
260 | 256 | ||
261 | 257 | ||
262 | void VideoWidget::backToNormal() { | 258 | void VideoWidget::backToNormal() { |
263 | mediaPlayerState.setFullscreen( FALSE ); | 259 | mediaPlayerState.setFullscreen( FALSE ); |
264 | makeVisible(); | 260 | makeVisible(); |
265 | } | 261 | } |
266 | 262 | ||
267 | void VideoWidget::makeVisible() { | 263 | void VideoWidget::makeVisible() { |
268 | if ( mediaPlayerState.isFullscreen() ) { | 264 | if ( mediaPlayerState.isFullscreen() ) { |
269 | setBackgroundMode( QWidget::NoBackground ); | 265 | setBackgroundMode( QWidget::NoBackground ); |
270 | showFullScreen(); | 266 | showFullScreen(); |
271 | resize( qApp->desktop()->size() ); | 267 | resize( qApp->desktop()->size() ); |
272 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); | 268 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); |
273 | 269 | ||
274 | slider->hide(); | 270 | slider->hide(); |
275 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 271 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
276 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 272 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
277 | disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 273 | disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
278 | disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 274 | disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
279 | 275 | ||
280 | } else { | 276 | } else { |
281 | showNormal(); | 277 | showNormal(); |
282 | showMaximized(); | 278 | showMaximized(); |
283 | setBackgroundPixmap( backgroundPixmap ); | 279 | setBackgroundPixmap( backgroundPixmap ); |
284 | QWidget *d = QApplication::desktop(); | 280 | QWidget *d = QApplication::desktop(); |
285 | int w = d->width(); | 281 | int w = d->width(); |
286 | int h = d->height(); | 282 | int h = d->height(); |
287 | 283 | ||
288 | if(w>h) { | 284 | if(w>h) { |
289 | int newW=(w/2)-(246/2); //this will only work with 320x240 | 285 | int newW=(w/2)-(246/2); //this will only work with 320x240 |
290 | videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) ); | 286 | videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) ); |
291 | } else { | 287 | } else { |
292 | videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); | 288 | videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); |
293 | } | 289 | } |
294 | 290 | ||
295 | if ( !mediaPlayerState.isSeekable() ) { | 291 | if ( !mediaPlayerState.isSeekable() ) { |
296 | if( !slider->isHidden()) { | 292 | if( !slider->isHidden()) { |
297 | slider->hide(); | 293 | slider->hide(); |
298 | } | 294 | } |
299 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 295 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
300 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 296 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
301 | disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 297 | disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
302 | disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 298 | disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
303 | } else { | 299 | } else { |
304 | slider->show(); | 300 | slider->show(); |
305 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 301 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
306 | connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 302 | connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
307 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 303 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
308 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 304 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
309 | } | 305 | } |
310 | } | 306 | } |
311 | } | 307 | } |
312 | 308 | ||
313 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { | 309 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { |
314 | switch ( e->key() ) { | 310 | switch ( e->key() ) { |
315 | ////////////////////////////// Zaurus keys | 311 | ////////////////////////////// Zaurus keys |
316 | case Key_Home: | 312 | case Key_Home: |
317 | break; | 313 | break; |
318 | case Key_F9: //activity | 314 | case Key_F9: //activity |
319 | break; | 315 | break; |
320 | case Key_F10: //contacts | 316 | case Key_F10: //contacts |
321 | // hide(); | 317 | // hide(); |
322 | break; | 318 | break; |
323 | case Key_F11: //menu | 319 | case Key_F11: //menu |
324 | break; | 320 | break; |
325 | case Key_F12: //home | 321 | case Key_F12: //home |
326 | break; | 322 | break; |
327 | case Key_F13: //mail | 323 | case Key_F13: //mail |
328 | break; | 324 | break; |
329 | case Key_Space: { | 325 | case Key_Space: { |
330 | if(mediaPlayerState.isPlaying()) { | 326 | if(mediaPlayerState.isPlaying()) { |
331 | mediaPlayerState.setPlaying(FALSE); | 327 | mediaPlayerState.setPlaying(FALSE); |
332 | } else { | 328 | } else { |
333 | mediaPlayerState.setPlaying(TRUE); | 329 | mediaPlayerState.setPlaying(TRUE); |
334 | } | 330 | } |
335 | } | 331 | } |
336 | break; | 332 | break; |
337 | case Key_Down: | 333 | case Key_Down: |
338 | // toggleButton(6); | 334 | // toggleButton(6); |
339 | emit lessClicked(); | 335 | emit lessClicked(); |
340 | emit lessReleased(); | 336 | emit lessReleased(); |
341 | // toggleButton(6); | 337 | // toggleButton(6); |
342 | break; | 338 | break; |
343 | case Key_Up: | 339 | case Key_Up: |
344 | // toggleButton(5); | 340 | // toggleButton(5); |
345 | emit moreClicked(); | 341 | emit moreClicked(); |
346 | emit moreReleased(); | 342 | emit moreReleased(); |
347 | // toggleButton(5); | 343 | // toggleButton(5); |
348 | break; | 344 | break; |
349 | case Key_Right: | 345 | case Key_Right: |
350 | mediaPlayerState.setNext(); | 346 | mediaPlayerState.setNext(); |
351 | break; | 347 | break; |
352 | case Key_Left: | 348 | case Key_Left: |
353 | mediaPlayerState.setPrev(); | 349 | mediaPlayerState.setPrev(); |
354 | break; | 350 | break; |
355 | case Key_Escape: | 351 | case Key_Escape: |
356 | break; | 352 | break; |
357 | 353 | ||
358 | }; | 354 | }; |
359 | } | 355 | } |
360 | 356 | ||
361 | XineVideoWidget* VideoWidget::vidWidget() { | 357 | XineVideoWidget* VideoWidget::vidWidget() { |
362 | return videoFrame; | 358 | return videoFrame; |
363 | } | 359 | } |
364 | 360 | ||
365 | 361 | ||
366 | void VideoWidget::setFullscreen ( bool b ) { | 362 | void VideoWidget::setFullscreen ( bool b ) { |
367 | setToggleButton( FullScreen, b ); | 363 | setToggleButton( FullScreen, b ); |
368 | } | 364 | } |
369 | 365 | ||
370 | 366 | ||
371 | void VideoWidget::setPlaying( bool b) { | 367 | void VideoWidget::setPlaying( bool b) { |
372 | setToggleButton( Play, b ); | 368 | setToggleButton( Play, b ); |
373 | } | 369 | } |
374 | 370 | ||
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h index bed2116..985c094 100644 --- a/noncore/multimedia/opieplayer2/videowidget.h +++ b/noncore/multimedia/opieplayer2/videowidget.h | |||
@@ -1,104 +1,103 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #ifndef VIDEO_WIDGET_H | 34 | #ifndef VIDEO_WIDGET_H |
35 | #define VIDEO_WIDGET_H | 35 | #define VIDEO_WIDGET_H |
36 | 36 | ||
37 | #include <qwidget.h> | 37 | #include <qwidget.h> |
38 | #include <qimage.h> | 38 | #include <qimage.h> |
39 | #include <qpixmap.h> | 39 | #include <qpixmap.h> |
40 | #include "xinevideowidget.h" | 40 | #include "xinevideowidget.h" |
41 | 41 | ||
42 | #include "mediawidget.h" | 42 | #include "mediawidget.h" |
43 | 43 | ||
44 | class QPixmap; | 44 | class QPixmap; |
45 | class QSlider; | 45 | class QSlider; |
46 | 46 | ||
47 | class VideoWidget : public MediaWidget { | 47 | class VideoWidget : public MediaWidget { |
48 | Q_OBJECT | 48 | Q_OBJECT |
49 | public: | 49 | public: |
50 | VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); | 50 | VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); |
51 | ~VideoWidget(); | 51 | ~VideoWidget(); |
52 | 52 | ||
53 | 53 | ||
54 | XineVideoWidget* vidWidget(); | 54 | XineVideoWidget* vidWidget(); |
55 | public slots: | 55 | public slots: |
56 | void updateSlider( long, long ); | 56 | void updateSlider( long, long ); |
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 | ||
64 | public: | 64 | public: |
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 | signals: | 69 | signals: |
70 | void moreClicked(); | 70 | void moreClicked(); |
71 | void lessClicked(); | 71 | void lessClicked(); |
72 | void sliderMoved( long ); | 72 | void sliderMoved( long ); |
73 | void videoResized ( const QSize &s ); | 73 | void videoResized ( const QSize &s ); |
74 | 74 | ||
75 | protected: | 75 | protected: |
76 | 76 | ||
77 | void resizeEvent( QResizeEvent * ); | 77 | void resizeEvent( QResizeEvent * ); |
78 | void showEvent( QShowEvent *se ); | 78 | void showEvent( QShowEvent *se ); |
79 | void mousePressEvent( QMouseEvent *event ); | ||
80 | void mouseReleaseEvent( QMouseEvent *event ); | 79 | void mouseReleaseEvent( QMouseEvent *event ); |
81 | void keyReleaseEvent( QKeyEvent *e); | 80 | void keyReleaseEvent( QKeyEvent *e); |
82 | 81 | ||
83 | private: | 82 | private: |
84 | // Ticker songInfo; | 83 | // Ticker songInfo; |
85 | QImage imgUp; | 84 | QImage imgUp; |
86 | QImage imgDn; | 85 | QImage imgDn; |
87 | QString skin; | 86 | QString skin; |
88 | 87 | ||
89 | 88 | ||
90 | 89 | ||
91 | QString backgroundPix; | 90 | QString backgroundPix; |
92 | QSlider *slider; | 91 | QSlider *slider; |
93 | QImage *currentFrame; | 92 | QImage *currentFrame; |
94 | int scaledWidth; | 93 | int scaledWidth; |
95 | int scaledHeight; | 94 | int scaledHeight; |
96 | XineVideoWidget* videoFrame; | 95 | XineVideoWidget* videoFrame; |
97 | 96 | ||
98 | bool videoSliderBeingMoved; | 97 | bool videoSliderBeingMoved; |
99 | }; | 98 | }; |
100 | 99 | ||
101 | #endif // VIDEO_WIDGET_H | 100 | #endif // VIDEO_WIDGET_H |
102 | 101 | ||
103 | 102 | ||
104 | 103 | ||