27 #include <hbprogressslider.h> |
27 #include <hbprogressslider.h> |
28 #include <hbstyleoptionprogressslider_p.h> |
28 #include <hbstyleoptionprogressslider_p.h> |
29 #include <hbtooltip.h> |
29 #include <hbtooltip.h> |
30 #include <hbwidgetfeedback.h> |
30 #include <hbwidgetfeedback.h> |
31 #include "hbglobal_p.h" |
31 #include "hbglobal_p.h" |
32 |
32 #include <hbtoucharea.h> |
33 #include <QGraphicsSceneMouseEvent> |
33 #include <QGraphicsSceneMouseEvent> |
34 #include <QApplication> |
34 #include <QApplication> |
35 |
35 |
36 #ifdef HB_EFFECTS |
36 #ifdef HB_EFFECTS |
37 #include <hbeffect.h> |
37 #include <hbeffect.h> |
38 #include "hbeffectinternal_p.h" |
38 #include "hbeffectinternal_p.h" |
39 #define HB_PRGRESSSLIDER_ITEM_TYPE "HB_PROGRESSSLIDER" |
39 #define HB_PRGRESSSLIDER_ITEM_TYPE "HB_PROGRESSSLIDER" |
40 #endif |
40 #endif |
41 |
41 |
|
42 #ifdef HB_GESTURE_FW |
|
43 #include <hbtapgesture.h> |
|
44 #endif |
|
45 |
42 HbProgressSliderPrivate::HbProgressSliderPrivate() |
46 HbProgressSliderPrivate::HbProgressSliderPrivate() |
43 { |
47 { |
44 mDownState=false; |
48 mDownState=false; |
45 handle = 0; |
49 handle = 0; |
46 mSliderValue = 0; |
50 mSliderValue = 0; |
107 #ifdef HB_EFFECTS |
111 #ifdef HB_EFFECTS |
108 HbEffectInternal::add(HB_PRGRESSSLIDER_ITEM_TYPE,"progressslider_trackpress", "progressslider_trackpress"); |
112 HbEffectInternal::add(HB_PRGRESSSLIDER_ITEM_TYPE,"progressslider_trackpress", "progressslider_trackpress"); |
109 HbEffectInternal::add(HB_PRGRESSSLIDER_ITEM_TYPE,"progressslider_trackrelease", "progressslider_trackrelease"); |
113 HbEffectInternal::add(HB_PRGRESSSLIDER_ITEM_TYPE,"progressslider_trackrelease", "progressslider_trackrelease"); |
110 #endif |
114 #endif |
111 |
115 |
112 q->grabGesture(Qt::TapGesture); |
116 #ifdef HB_GESTURE_FW |
113 |
|
114 if(QGraphicsObject *touchArea = mTouchAreaItem->toGraphicsObject()) { |
117 if(QGraphicsObject *touchArea = mTouchAreaItem->toGraphicsObject()) { |
115 touchArea->grabGesture(Qt::TapGesture); |
118 touchArea->grabGesture(Qt::TapGesture); |
116 } |
119 } |
|
120 #endif |
117 } |
121 } |
118 |
122 |
119 void HbProgressSliderPrivate::emitSliderPressed() |
123 void HbProgressSliderPrivate::emitSliderPressed() |
120 { |
124 { |
121 Q_Q(HbProgressSlider); |
125 Q_Q(HbProgressSlider); |
123 } |
127 } |
124 |
128 |
125 void HbProgressSliderPrivate::emitSliderReleased() |
129 void HbProgressSliderPrivate::emitSliderReleased() |
126 { |
130 { |
127 Q_Q(HbProgressSlider); |
131 Q_Q(HbProgressSlider); |
|
132 if(mDownState){ |
|
133 mDownState = false; |
|
134 HbStyleOptionProgressSlider option; |
|
135 q->initStyleOption(&option); |
|
136 if (mFrame) { |
|
137 HbStylePrivate::updatePrimitive(mFrame, HbStylePrivate::P_ProgressSlider_frame, &option); |
|
138 } |
|
139 HbWidgetFeedback::triggered(q, Hb::InstantReleased); |
|
140 |
|
141 #ifdef HB_EFFECTS |
|
142 // HbEffect::start(q, HB_PRGRESSSLIDER_ITEM_TYPE, "progressslider_trackrelease"); |
|
143 #endif |
|
144 } |
|
145 |
128 emit q->sliderReleased(); |
146 emit q->sliderReleased(); |
129 } |
147 } |
130 |
148 |
131 void HbProgressSliderPrivate::emitSliderMoved(int newValue) |
149 void HbProgressSliderPrivate::emitSliderMoved(int newValue) |
132 { |
150 { |
324 \param parent The parent of ProgressBar |
345 \param parent The parent of ProgressBar |
325 */ |
346 */ |
326 HbProgressSlider::HbProgressSlider(HbProgressSliderPrivate &dd,QGraphicsItem *parent) : |
347 HbProgressSlider::HbProgressSlider(HbProgressSliderPrivate &dd,QGraphicsItem *parent) : |
327 HbProgressBar( dd,parent) |
348 HbProgressBar( dd,parent) |
328 { |
349 { |
|
350 HbEffect::disable(this); |
329 Q_D( HbProgressSlider ); |
351 Q_D( HbProgressSlider ); |
330 d->init(); |
352 d->init(); |
331 |
353 |
332 setFocusPolicy(Qt::FocusPolicy(qApp->style()->styleHint(QStyle::SH_Button_FocusPolicy))); |
354 setFocusPolicy(Qt::FocusPolicy(qApp->style()->styleHint(QStyle::SH_Button_FocusPolicy))); |
333 d->handle =new HbProgressSliderHandle(d); |
355 d->handle =new HbProgressSliderHandle(d); |
435 /*! |
459 /*! |
436 \reimp |
460 \reimp |
437 */ |
461 */ |
438 void HbProgressSlider::mousePressEvent(QGraphicsSceneMouseEvent *event) |
462 void HbProgressSlider::mousePressEvent(QGraphicsSceneMouseEvent *event) |
439 { |
463 { |
|
464 #ifndef HB_GESTURE_FW |
440 Q_D(HbProgressSlider); |
465 Q_D(HbProgressSlider); |
441 |
466 |
442 QRectF rect = d->mTouchAreaItem->sceneBoundingRect( ); |
467 QRectF rect = d->mTouchAreaItem->sceneBoundingRect( ); |
443 // return if point is outside track touch area |
468 // return if point is outside track touch area |
444 if ( !rect.contains( event->scenePos( ) ) ) { |
469 if ( !rect.contains( event->scenePos( ) ) ) { |
454 HbStylePrivate::updatePrimitive(d->mFrame, HbStylePrivate::P_ProgressSlider_frame, &option); |
479 HbStylePrivate::updatePrimitive(d->mFrame, HbStylePrivate::P_ProgressSlider_frame, &option); |
455 } |
480 } |
456 |
481 |
457 HbWidgetFeedback::triggered(this, Hb::InstantPressed); |
482 HbWidgetFeedback::triggered(this, Hb::InstantPressed); |
458 d->handle->handleTrackPress(event); |
483 d->handle->handleTrackPress(event); |
459 emit trackPressed(); |
484 emit trackPressed(); |
460 event->accept(); |
485 event->accept(); |
461 #ifdef HB_EFFECTS |
486 #ifdef HB_EFFECTS |
462 HbEffect::start(this, HB_PRGRESSSLIDER_ITEM_TYPE, "progressslider_trackpress"); |
487 HbEffect::start(this, HB_PRGRESSSLIDER_ITEM_TYPE, "progressslider_trackpress"); |
463 #endif |
488 #endif |
464 } else { |
489 } else { |
465 event->ignore(); |
490 event->ignore(); |
466 } |
491 } |
|
492 #else |
|
493 Q_UNUSED(event) |
|
494 #endif |
467 } |
495 } |
468 |
496 |
469 /*! |
497 /*! |
470 \reimp |
498 \reimp |
471 */ |
499 */ |
472 void HbProgressSlider::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) |
500 void HbProgressSlider::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) |
473 { |
501 { |
|
502 #ifndef HB_GESTURE_FW |
474 Q_D(HbProgressSlider); |
503 Q_D(HbProgressSlider); |
475 |
504 |
476 if(flags().testFlag(ItemIsFocusable)) { |
505 if(flags().testFlag(ItemIsFocusable)) { |
477 d->mDownState = false; |
506 d->mDownState = false; |
478 |
507 |
482 HbStylePrivate::updatePrimitive(d->mFrame, HbStylePrivate::P_ProgressSlider_frame, &option); |
511 HbStylePrivate::updatePrimitive(d->mFrame, HbStylePrivate::P_ProgressSlider_frame, &option); |
483 } |
512 } |
484 |
513 |
485 HbWidgetFeedback::triggered(this, Hb::InstantReleased); |
514 HbWidgetFeedback::triggered(this, Hb::InstantReleased); |
486 d->handle->handleTrackRelease(event); |
515 d->handle->handleTrackRelease(event); |
487 emit trackReleased(); |
516 emit trackReleased(); |
488 event->accept(); |
517 event->accept(); |
489 #ifdef HB_EFFECTS |
518 #ifdef HB_EFFECTS |
490 HbEffect::start(this, HB_PRGRESSSLIDER_ITEM_TYPE, "progressslider_trackrelease"); |
519 HbEffect::start(this, HB_PRGRESSSLIDER_ITEM_TYPE, "progressslider_trackrelease"); |
491 #endif |
520 #endif |
492 } else { |
521 } else { |
493 event->ignore(); |
522 event->ignore(); |
494 } |
523 } |
495 } |
524 #else |
|
525 Q_UNUSED(event) |
|
526 #endif |
|
527 } |
|
528 |
|
529 #ifdef HB_GESTURE_FW |
|
530 void HbProgressSlider::gestureEvent(QGestureEvent *event) |
|
531 { |
|
532 Q_D (HbProgressSlider); |
|
533 |
|
534 if(event->gesture(Qt::TapGesture)) { |
|
535 |
|
536 HbTapGesture *tapGesture = static_cast<HbTapGesture *>(event->gesture(Qt::TapGesture)); |
|
537 switch(tapGesture->state()) { |
|
538 case Qt::GestureStarted :{ |
|
539 QRectF rect = d->mTouchAreaItem->sceneBoundingRect( ); |
|
540 // return if point is outside track touch area |
|
541 if ( !rect.contains( event->mapToGraphicsScene(tapGesture->position( ) ) ) ) { |
|
542 event->ignore( ); |
|
543 return; |
|
544 } |
|
545 if(flags().testFlag(ItemIsFocusable)) { |
|
546 #ifdef HB_EFFECTS |
|
547 HbEffect::start(this, HB_PRGRESSSLIDER_ITEM_TYPE, "progressslider_trackpress"); |
|
548 #endif |
|
549 d->mDownState = true; |
|
550 HbStyleOptionProgressSlider option; |
|
551 initStyleOption(&option); |
|
552 d->handle->setPressedState(); |
|
553 if (d->mFrame) { |
|
554 HbStylePrivate::updatePrimitive(d->mFrame, HbStylePrivate::P_ProgressSlider_frame, &option); |
|
555 } |
|
556 |
|
557 HbWidgetFeedback::triggered(this, Hb::InstantPressed); |
|
558 d->handle->handleTrackPress(event); |
|
559 emit trackPressed(); |
|
560 event->accept(); |
|
561 |
|
562 } |
|
563 else { |
|
564 event->ignore(); |
|
565 } |
|
566 } |
|
567 break; |
|
568 |
|
569 case Qt::GestureFinished:{ |
|
570 if(flags().testFlag(ItemIsFocusable)) { |
|
571 #ifdef HB_EFFECTS |
|
572 HbEffect::start(this, HB_PRGRESSSLIDER_ITEM_TYPE, "progressslider_trackrelease"); |
|
573 #endif |
|
574 |
|
575 d->mDownState = false; |
|
576 |
|
577 HbStyleOptionProgressSlider option; |
|
578 initStyleOption(&option); |
|
579 if (d->mFrame) { |
|
580 HbStylePrivate::updatePrimitive(d->mFrame, HbStylePrivate::P_ProgressSlider_frame, &option); |
|
581 } |
|
582 |
|
583 HbWidgetFeedback::triggered(this, Hb::InstantReleased); |
|
584 d->handle->setReleasedState(); |
|
585 d->handle->handleTrackRelease(event); |
|
586 emit trackReleased(); |
|
587 event->accept(); |
|
588 |
|
589 |
|
590 } else { |
|
591 event->ignore(); |
|
592 } |
|
593 |
|
594 } |
|
595 break; |
|
596 default:break; |
|
597 } |
|
598 } |
|
599 |
|
600 } |
|
601 #endif |
|
602 |
|
603 |
496 /*! |
604 /*! |
497 \reimp |
605 \reimp |
498 */ |
606 */ |
499 void HbProgressSlider::setGeometry(const QRectF & rect) |
607 void HbProgressSlider::setGeometry(const QRectF & rect) |
500 { |
608 { |
595 /*! |
703 /*! |
596 \reimp |
704 \reimp |
597 */ |
705 */ |
598 void HbProgressSlider::mouseMoveEvent(QGraphicsSceneMouseEvent *event) |
706 void HbProgressSlider::mouseMoveEvent(QGraphicsSceneMouseEvent *event) |
599 { |
707 { |
|
708 #ifndef HB_GESTURE_FW |
600 Q_D(HbProgressSlider); |
709 Q_D(HbProgressSlider); |
601 QRectF rect = d->mTouchAreaItem->sceneBoundingRect( ); |
710 QRectF rect = d->mTouchAreaItem->sceneBoundingRect( ); |
602 // return if point is outside track touch area |
711 // return if point is outside track touch area |
603 if ( !rect.contains( event->scenePos( ) ) ) { |
712 if ( !rect.contains( event->scenePos( ) ) ) { |
604 event->ignore( ); |
713 event->ignore( ); |
609 d->handle->handleTrackPress(event); |
718 d->handle->handleTrackPress(event); |
610 event->accept(); |
719 event->accept(); |
611 } else { |
720 } else { |
612 event->ignore(); |
721 event->ignore(); |
613 } |
722 } |
614 |
723 #else |
615 } |
724 Q_UNUSED(event) |
616 /*! |
725 #endif |
617 \reimp |
726 } |
618 */ |
|
619 bool HbProgressSlider::sceneEventFilter(QGraphicsItem *obj,QEvent *event) |
|
620 { |
|
621 Q_D(HbProgressSlider); |
|
622 if( obj == d->mTouchAreaItem) { |
|
623 if (!isEnabled() ) { |
|
624 return false; |
|
625 } |
|
626 if (event->type() == QEvent::GraphicsSceneMousePress){ |
|
627 mousePressEvent((QGraphicsSceneMouseEvent *) event); |
|
628 return true; |
|
629 } |
|
630 else if (event->type() == QEvent::GraphicsSceneMouseRelease){ |
|
631 mouseReleaseEvent((QGraphicsSceneMouseEvent *) event); |
|
632 return true; |
|
633 } |
|
634 |
|
635 else if (event->type() == QEvent::GraphicsSceneMouseMove){ |
|
636 mouseMoveEvent((QGraphicsSceneMouseEvent *) event); |
|
637 return true; |
|
638 } |
|
639 } |
|
640 return false; |
|
641 } |
|
642 |
|
643 |
727 |
644 /*! |
728 /*! |
645 @beta |
729 @beta |
646 Sets the tooltip for the Slider handle. By default it shows the slider value. |
730 Sets the tooltip for the Slider handle. By default it shows the slider value. |
647 The application can customize the tooltip text using this API. setting NULL string |
731 The application can customize the tooltip text using this API. setting NULL string |