-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 25 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 27 |
2 files changed, 29 insertions, 23 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index ef606ab..714509e 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp | |||
@@ -290,129 +290,132 @@ void AudioWidget::updateSlider( long i, long max ) { | |||
290 | if ( max == 0 ) { | 290 | if ( max == 0 ) { |
291 | return; | 291 | return; |
292 | } | 292 | } |
293 | // Will flicker too much if we don't do this | 293 | // Will flicker too much if we don't do this |
294 | // Scale to something reasonable | 294 | // Scale to something reasonable |
295 | int width = slider.width(); | 295 | int width = slider.width(); |
296 | int val = int((double)i * width / max); | 296 | int val = int((double)i * width / max); |
297 | if ( !audioSliderBeingMoved ) { | 297 | if ( !audioSliderBeingMoved ) { |
298 | if ( slider.value() != val ) { | 298 | if ( slider.value() != val ) { |
299 | slider.setValue( val ); | 299 | slider.setValue( val ); |
300 | } | 300 | } |
301 | 301 | ||
302 | if ( slider.maxValue() != width ) { | 302 | if ( slider.maxValue() != width ) { |
303 | slider.setMaxValue( width ); | 303 | slider.setMaxValue( width ); |
304 | } | 304 | } |
305 | } | 305 | } |
306 | } | 306 | } |
307 | 307 | ||
308 | void AudioWidget::skipFor() { | 308 | void AudioWidget::skipFor() { |
309 | skipDirection = +1; | 309 | skipDirection = +1; |
310 | startTimer( 50 ); | 310 | startTimer( 50 ); |
311 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); | 311 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); |
312 | } | 312 | } |
313 | 313 | ||
314 | void AudioWidget::skipBack() { | 314 | void AudioWidget::skipBack() { |
315 | skipDirection = -1; | 315 | skipDirection = -1; |
316 | startTimer( 50 ); | 316 | startTimer( 50 ); |
317 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); | 317 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); |
318 | } | 318 | } |
319 | 319 | ||
320 | 320 | ||
321 | 321 | ||
322 | void AudioWidget::stopSkip() { | 322 | void AudioWidget::stopSkip() { |
323 | killTimers(); | 323 | killTimers(); |
324 | } | 324 | } |
325 | 325 | ||
326 | 326 | ||
327 | void AudioWidget::timerEvent( QTimerEvent * ) { | 327 | void AudioWidget::timerEvent( QTimerEvent * ) { |
328 | if ( skipDirection == +1 ) { | 328 | if ( skipDirection == +1 ) { |
329 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); | 329 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); |
330 | } else if ( skipDirection == -1 ) { | 330 | } else if ( skipDirection == -1 ) { |
331 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); | 331 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); |
332 | } | 332 | } |
333 | } | 333 | } |
334 | 334 | ||
335 | 335 | ||
336 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { | 336 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { |
337 | for ( unsigned int i = 0; i < buttons.count(); i++ ) { | 337 | for ( unsigned int i = 0; i < buttons.count(); i++ ) { |
338 | |||
339 | Button &button = buttons[ i ]; | ||
340 | |||
338 | if ( event->state() == QMouseEvent::LeftButton ) { | 341 | if ( event->state() == QMouseEvent::LeftButton ) { |
339 | // The test to see if the mouse click is inside the button or not | 342 | // The test to see if the mouse click is inside the button or not |
340 | bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i ); | 343 | bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i ); |
341 | 344 | ||
342 | if ( isOnButton && !buttons[i].isHeld ) { | 345 | if ( isOnButton && !button.isHeld ) { |
343 | buttons[i].isHeld = TRUE; | 346 | button.isHeld = TRUE; |
344 | toggleButton( buttons[ i ] ); | 347 | toggleButton( button ); |
345 | switch (i) { | 348 | switch (i) { |
346 | case VolumeUp: | 349 | case VolumeUp: |
347 | emit moreClicked(); | 350 | emit moreClicked(); |
348 | return; | 351 | return; |
349 | case VolumeDown: | 352 | case VolumeDown: |
350 | emit lessClicked(); | 353 | emit lessClicked(); |
351 | return; | 354 | return; |
352 | case Forward: | 355 | case Forward: |
353 | emit forwardClicked(); | 356 | emit forwardClicked(); |
354 | return; | 357 | return; |
355 | case Back: | 358 | case Back: |
356 | emit backClicked(); | 359 | emit backClicked(); |
357 | return; | 360 | return; |
358 | } | 361 | } |
359 | } else if ( !isOnButton && buttons[i].isHeld ) { | 362 | } else if ( !isOnButton && button.isHeld ) { |
360 | buttons[i].isHeld = FALSE; | 363 | button.isHeld = FALSE; |
361 | toggleButton( buttons[ i ] ); | 364 | toggleButton( button ); |
362 | } | 365 | } |
363 | } else { | 366 | } else { |
364 | if ( buttons[i].isHeld ) { | 367 | if ( button.isHeld ) { |
365 | buttons[i].isHeld = FALSE; | 368 | button.isHeld = FALSE; |
366 | if ( buttons[i].type != ToggleButton ) { | 369 | if ( button.type != ToggleButton ) { |
367 | setToggleButton( buttons[ i ], FALSE ); | 370 | setToggleButton( button, FALSE ); |
368 | } | 371 | } |
369 | qDebug("mouseEvent %d", i); | 372 | qDebug("mouseEvent %d", i); |
370 | handleCommand( static_cast<Command>( i ), buttons[ i ].isDown ); | 373 | handleCommand( static_cast<Command>( i ), button.isDown ); |
371 | } | 374 | } |
372 | } | 375 | } |
373 | } | 376 | } |
374 | } | 377 | } |
375 | 378 | ||
376 | 379 | ||
377 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { | 380 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { |
378 | mouseMoveEvent( event ); | 381 | mouseMoveEvent( event ); |
379 | } | 382 | } |
380 | 383 | ||
381 | 384 | ||
382 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { | 385 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { |
383 | mouseMoveEvent( event ); | 386 | mouseMoveEvent( event ); |
384 | } | 387 | } |
385 | 388 | ||
386 | 389 | ||
387 | void AudioWidget::showEvent( QShowEvent* ) { | 390 | void AudioWidget::showEvent( QShowEvent* ) { |
388 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); | 391 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); |
389 | mouseMoveEvent( &event ); | 392 | mouseMoveEvent( &event ); |
390 | } | 393 | } |
391 | 394 | ||
392 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { | 395 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { |
393 | switch ( e->key() ) { | 396 | switch ( e->key() ) { |
394 | ////////////////////////////// Zaurus keys | 397 | ////////////////////////////// Zaurus keys |
395 | case Key_Home: | 398 | case Key_Home: |
396 | break; | 399 | break; |
397 | case Key_F9: //activity | 400 | case Key_F9: //activity |
398 | hide(); | 401 | hide(); |
399 | // qDebug("Audio F9"); | 402 | // qDebug("Audio F9"); |
400 | break; | 403 | break; |
401 | case Key_F10: //contacts | 404 | case Key_F10: //contacts |
402 | break; | 405 | break; |
403 | case Key_F11: //menu | 406 | case Key_F11: //menu |
404 | mediaPlayerState.toggleBlank(); | 407 | mediaPlayerState.toggleBlank(); |
405 | break; | 408 | break; |
406 | case Key_F12: //home | 409 | case Key_F12: //home |
407 | break; | 410 | break; |
408 | case Key_F13: //mail | 411 | case Key_F13: //mail |
409 | mediaPlayerState.toggleBlank(); | 412 | mediaPlayerState.toggleBlank(); |
410 | break; | 413 | break; |
411 | case Key_Space: { | 414 | case Key_Space: { |
412 | mediaPlayerState.togglePaused(); | 415 | mediaPlayerState.togglePaused(); |
413 | } | 416 | } |
414 | break; | 417 | break; |
415 | case Key_Down: | 418 | case Key_Down: |
416 | // toggleButton(6); | 419 | // toggleButton(6); |
417 | emit lessClicked(); | 420 | emit lessClicked(); |
418 | emit lessReleased(); | 421 | emit lessReleased(); |
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index 673c9e8..9782b68 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp | |||
@@ -199,133 +199,136 @@ void VideoWidget::sliderReleased() { | |||
199 | if ( slider->width() == 0 ) { | 199 | if ( slider->width() == 0 ) { |
200 | return; | 200 | return; |
201 | } | 201 | } |
202 | long val = long((double)slider->value() * mediaPlayerState.length() / slider->width()); | 202 | long val = long((double)slider->value() * mediaPlayerState.length() / slider->width()); |
203 | mediaPlayerState.setPosition( val ); | 203 | mediaPlayerState.setPosition( val ); |
204 | } | 204 | } |
205 | 205 | ||
206 | void VideoWidget::setPosition( long i ) { | 206 | void VideoWidget::setPosition( long i ) { |
207 | updateSlider( i, mediaPlayerState.length() ); | 207 | updateSlider( i, mediaPlayerState.length() ); |
208 | } | 208 | } |
209 | 209 | ||
210 | 210 | ||
211 | void VideoWidget::setLength( long max ) { | 211 | void VideoWidget::setLength( long max ) { |
212 | updateSlider( mediaPlayerState.position(), max ); | 212 | updateSlider( mediaPlayerState.position(), max ); |
213 | } | 213 | } |
214 | 214 | ||
215 | void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) | 215 | void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) |
216 | { | 216 | { |
217 | if ( displayType == MediaPlayerState::Video ) { | 217 | if ( displayType == MediaPlayerState::Video ) { |
218 | makeVisible(); | 218 | makeVisible(); |
219 | return; | 219 | return; |
220 | } | 220 | } |
221 | 221 | ||
222 | // Effectively blank the view next time we show it so it looks nicer | 222 | // Effectively blank the view next time we show it so it looks nicer |
223 | scaledWidth = 0; | 223 | scaledWidth = 0; |
224 | scaledHeight = 0; | 224 | scaledHeight = 0; |
225 | hide(); | 225 | hide(); |
226 | } | 226 | } |
227 | 227 | ||
228 | void VideoWidget::updateSlider( long i, long max ) { | 228 | void VideoWidget::updateSlider( long i, long max ) { |
229 | // Will flicker too much if we don't do this | 229 | // Will flicker too much if we don't do this |
230 | if ( max == 0 ) { | 230 | if ( max == 0 ) { |
231 | return; | 231 | return; |
232 | } | 232 | } |
233 | int width = slider->width(); | 233 | int width = slider->width(); |
234 | int val = int((double)i * width / max); | 234 | int val = int((double)i * width / max); |
235 | if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { | 235 | if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { |
236 | if ( slider->value() != val ) { | 236 | if ( slider->value() != val ) { |
237 | slider->setValue( val ); | 237 | slider->setValue( val ); |
238 | } | 238 | } |
239 | if ( slider->maxValue() != width ) { | 239 | if ( slider->maxValue() != width ) { |
240 | slider->setMaxValue( width ); | 240 | slider->setMaxValue( width ); |
241 | } | 241 | } |
242 | } | 242 | } |
243 | } | 243 | } |
244 | 244 | ||
245 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | 245 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { |
246 | for ( unsigned int i = 0; i < buttons.count(); i++ ) { | 246 | for ( unsigned int i = 0; i < buttons.count(); i++ ) { |
247 | |||
248 | Button &button = buttons[ i ]; | ||
249 | |||
247 | if ( event->state() == QMouseEvent::LeftButton ) { | 250 | if ( event->state() == QMouseEvent::LeftButton ) { |
248 | // The test to see if the mouse click is inside the button or not | 251 | // The test to see if the mouse click is inside the button or not |
249 | bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i ); | 252 | bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i ); |
250 | 253 | ||
251 | if ( isOnButton && !buttons[i].isHeld ) { | 254 | if ( isOnButton && !button.isHeld ) { |
252 | buttons[i].isHeld = TRUE; | 255 | button.isHeld = TRUE; |
253 | toggleButton( buttons[ i ] ); | 256 | toggleButton( button ); |
254 | 257 | ||
255 | switch (i) { | 258 | switch (i) { |
256 | case VideoVolUp: | 259 | case VideoVolUp: |
257 | emit moreClicked(); | 260 | emit moreClicked(); |
258 | return; | 261 | return; |
259 | case VideoVolDown: | 262 | case VideoVolDown: |
260 | emit lessClicked(); | 263 | emit lessClicked(); |
261 | return; | 264 | return; |
262 | } | 265 | } |
263 | } else if ( !isOnButton && buttons[i].isHeld ) { | 266 | } else if ( !isOnButton && button.isHeld ) { |
264 | buttons[i].isHeld = FALSE; | 267 | button.isHeld = FALSE; |
265 | toggleButton( buttons[ i ] ); | 268 | toggleButton( button ); |
266 | } | 269 | } |
267 | } else { | 270 | } else { |
268 | 271 | ||
269 | if ( buttons[i].isHeld ) { | 272 | if ( button.isHeld ) { |
270 | buttons[i].isHeld = FALSE; | 273 | button.isHeld = FALSE; |
271 | if ( buttons[i].type != ToggleButton ) { | 274 | if ( button.type != ToggleButton ) { |
272 | setToggleButton( buttons[ i ], FALSE ); | 275 | setToggleButton( button, FALSE ); |
273 | } | 276 | } |
274 | 277 | ||
275 | switch(i) { | 278 | switch(i) { |
276 | 279 | ||
277 | case VideoPlay: { | 280 | case VideoPlay: { |
278 | if( mediaPlayerState.isPaused() ) { | 281 | if( mediaPlayerState.isPaused() ) { |
279 | setToggleButton( buttons[ i ], FALSE ); | 282 | setToggleButton( button, FALSE ); |
280 | mediaPlayerState.setPaused( FALSE ); | 283 | mediaPlayerState.setPaused( FALSE ); |
281 | return; | 284 | return; |
282 | } else if( !mediaPlayerState.isPaused() ) { | 285 | } else if( !mediaPlayerState.isPaused() ) { |
283 | setToggleButton( buttons[ i ], TRUE ); | 286 | setToggleButton( button, TRUE ); |
284 | mediaPlayerState.setPaused( TRUE ); | 287 | mediaPlayerState.setPaused( TRUE ); |
285 | return; | 288 | return; |
286 | } else { | 289 | } else { |
287 | return; | 290 | return; |
288 | } | 291 | } |
289 | } | 292 | } |
290 | 293 | ||
291 | case VideoStop: mediaPlayerState.setPlaying( FALSE ); return; | 294 | case VideoStop: mediaPlayerState.setPlaying( FALSE ); return; |
292 | case VideoNext: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; | 295 | case VideoNext: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; |
293 | case VideoPrevious: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; | 296 | case VideoPrevious: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; |
294 | case VideoVolUp: emit moreReleased(); return; | 297 | case VideoVolUp: emit moreReleased(); return; |
295 | case VideoVolDown: emit lessReleased(); return; | 298 | case VideoVolDown: emit lessReleased(); return; |
296 | case VideoFullscreen: mediaPlayerState.setFullscreen( TRUE ); makeVisible(); return; | 299 | case VideoFullscreen: mediaPlayerState.setFullscreen( TRUE ); makeVisible(); return; |
297 | } | 300 | } |
298 | } | 301 | } |
299 | } | 302 | } |
300 | } | 303 | } |
301 | } | 304 | } |
302 | 305 | ||
303 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { | 306 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { |
304 | mouseMoveEvent( event ); | 307 | mouseMoveEvent( event ); |
305 | } | 308 | } |
306 | 309 | ||
307 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { | 310 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { |
308 | if ( mediaPlayerState.isFullscreen() ) { | 311 | if ( mediaPlayerState.isFullscreen() ) { |
309 | mediaPlayerState.setFullscreen( FALSE ); | 312 | mediaPlayerState.setFullscreen( FALSE ); |
310 | makeVisible(); | 313 | makeVisible(); |
311 | } | 314 | } |
312 | mouseMoveEvent( event ); | 315 | mouseMoveEvent( event ); |
313 | } | 316 | } |
314 | 317 | ||
315 | void VideoWidget::showEvent( QShowEvent* ) { | 318 | void VideoWidget::showEvent( QShowEvent* ) { |
316 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); | 319 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); |
317 | mouseMoveEvent( &event ); | 320 | mouseMoveEvent( &event ); |
318 | } | 321 | } |
319 | 322 | ||
320 | 323 | ||
321 | void VideoWidget::backToNormal() { | 324 | void VideoWidget::backToNormal() { |
322 | mediaPlayerState.setFullscreen( FALSE ); | 325 | mediaPlayerState.setFullscreen( FALSE ); |
323 | makeVisible(); | 326 | makeVisible(); |
324 | } | 327 | } |
325 | 328 | ||
326 | void VideoWidget::makeVisible() { | 329 | void VideoWidget::makeVisible() { |
327 | if ( mediaPlayerState.isFullscreen() ) { | 330 | if ( mediaPlayerState.isFullscreen() ) { |
328 | setBackgroundMode( QWidget::NoBackground ); | 331 | setBackgroundMode( QWidget::NoBackground ); |
329 | showFullScreen(); | 332 | showFullScreen(); |
330 | resize( qApp->desktop()->size() ); | 333 | resize( qApp->desktop()->size() ); |
331 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); | 334 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); |