summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-09 15:49:37 (UTC)
committer simon <simon>2002-12-09 15:49:37 (UTC)
commit743155915f659d701ad468eadcc2b2173b6e2770 (patch) (unidiff)
treee95ff8ac9e8781865214e92e8a7e84bbdd04b645
parentaa766a6a0818ed0b756f8cd67fc4a1c85906f224 (diff)
downloadopie-743155915f659d701ad468eadcc2b2173b6e2770.zip
opie-743155915f659d701ad468eadcc2b2173b6e2770.tar.gz
opie-743155915f659d701ad468eadcc2b2173b6e2770.tar.bz2
- less indexing in the mouse event handler
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp25
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp27
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
@@ -330,49 +330,52 @@ void AudioWidget::timerEvent( QTimerEvent * ) {
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
336void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { 336void 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
377void AudioWidget::mousePressEvent( QMouseEvent *event ) { 380void AudioWidget::mousePressEvent( QMouseEvent *event ) {
378 mouseMoveEvent( event ); 381 mouseMoveEvent( event );
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
@@ -239,53 +239,56 @@ void VideoWidget::updateSlider( long i, long max ) {
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
245void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { 245void 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;