34 #include <hbinstance.h> |
34 #include <hbinstance.h> |
35 #include <hbtheme.h> |
35 #include <hbtheme.h> |
36 #include <hbtooltip.h> |
36 #include <hbtooltip.h> |
37 #include <hbwidgetfeedback.h> |
37 #include <hbwidgetfeedback.h> |
38 #include <hbgraphicsscene.h> |
38 #include <hbgraphicsscene.h> |
|
39 #include <hbtoucharea.h> |
|
40 #include <hbslider.h> |
39 #include <QGraphicsItem> |
41 #include <QGraphicsItem> |
40 #include <QGraphicsSceneMouseEvent> |
42 #include <QGraphicsSceneMouseEvent> |
41 #ifdef HB_GESTURE_FW |
43 #ifdef HB_GESTURE_FW |
42 #include "hbtapgesture.h" |
44 #include "hbtapgesture.h" |
43 #include "hbpangesture.h" |
45 #include "hbpangesture.h" |
|
46 #include "hbtapandholdgesture.h" |
|
47 |
44 #endif |
48 #endif |
45 |
49 |
46 #ifdef HB_EFFECTS |
50 #ifdef HB_EFFECTS |
47 #include "hbeffect.h" |
51 #include "hbeffect.h" |
48 #include "hbeffectinternal_p.h" |
52 #include "hbeffectinternal_p.h" |
61 majorTickInterval( 0 ),// major tick interval |
65 majorTickInterval( 0 ),// major tick interval |
62 minorTickInterval( 0 ),// minor tick interval |
66 minorTickInterval( 0 ),// minor tick interval |
63 groove( 0 ), //slider groove |
67 groove( 0 ), //slider groove |
64 progressGroove( 0 ),//progress mask top of groove |
68 progressGroove( 0 ),//progress mask top of groove |
65 displayCurrValueToolTip( true ), // holds whether to show current value tooltip or not |
69 displayCurrValueToolTip( true ), // holds whether to show current value tooltip or not |
66 toolTipAlignment( Qt::AlignTop|Qt::AlignRight ), // tooltip alignment |
70 toolTipAlignment( Qt::AlignTop ), // tooltip alignment |
67 groovePressed( false ), // hold whether groove is pressed or not |
71 groovePressed( false ), // hold whether groove is pressed or not |
68 setDefault( false ), // holds whther default value for track press is set |
72 setDefault( false ), // holds whther default value for track press is set |
69 previousValue( 0 ), // default value for track press |
73 previousValue( 0 ), // default value for track press |
70 trackHandlingEnable( false ),// this variable holds whether track will be interective or not |
74 trackHandlingEnable( false ),// this variable holds whether track will be interective or not |
71 handleMoving( false ), |
75 handleMoving( false ), |
72 grooveTouchArea ( 0 ), |
76 grooveTouchArea ( 0 ), |
73 enableProgressTrack ( true ), |
77 enableProgressTrack ( true ), |
74 userDefinedTooltipAlign ( false ) |
78 userDefinedTooltipAlign ( false ), |
|
79 tooltipArea(0), |
|
80 tooltipBorderHeight( 0 ) |
75 { |
81 { |
76 |
82 |
77 majorLabel.clear(); |
83 majorLabel.clear(); |
78 minorLabel.clear(); |
84 minorLabel.clear(); |
79 |
85 |
97 |
103 |
98 q->enableTrackEventHandling( true ); |
104 q->enableTrackEventHandling( true ); |
99 |
105 |
100 // creating handle |
106 // creating handle |
101 handle = createHandle(); |
107 handle = createHandle(); |
102 if(handle) { |
108 if (handle) { |
103 HbStyle::setItemName( handle, "handle" ); |
109 HbStyle::setItemName( handle, "handle" ); |
104 } |
110 } |
105 #if defined( QT_KEYPAD_NAVIGATION ) && !defined( Q_OS_SYMBIAN ) |
111 #if defined( QT_KEYPAD_NAVIGATION ) && !defined( Q_OS_SYMBIAN ) |
106 q->setFocusPolicy( Qt::FocusPolicy( ( qApp->style( ) )->styleHint( QStyle::SH_Button_FocusPolicy ) ) ); |
112 q->setFocusPolicy( Qt::FocusPolicy( ( qApp->style( ) )->styleHint( QStyle::SH_Button_FocusPolicy ) ) ); |
107 #endif |
113 #endif |
108 groove = createGroove(); |
114 groove = createGroove(); |
109 if(groove) { |
115 if (groove) { |
110 HbStyle::setItemName( groove, "groove" ); |
116 HbStyle::setItemName( groove, "groove" ); |
111 } |
117 } |
112 #ifdef HB_GESTURE_FW |
118 #ifdef HB_GESTURE_FW |
113 q->setFiltersChildEvents(true) ; |
119 q->setFiltersChildEvents(true) ; |
114 #endif |
120 #endif |
115 |
121 |
116 //filled item top of groove |
122 //filled item top of groove |
117 if ( enableProgressTrack ) { |
123 if ( enableProgressTrack ) { |
118 progressGroove = createProgressGroove(); |
124 progressGroove = createProgressGroove(); |
119 if(progressGroove) { |
125 if (progressGroove) { |
120 HbStyle::setItemName( progressGroove, "progressgroove"); |
126 HbStyle::setItemName( progressGroove, "progressgroove"); |
121 } |
127 } |
122 } |
128 } |
|
129 tooltipArea = new HbTouchArea(q); |
123 q->connect( hbInstance->theme( ), SIGNAL( changed( ) ), q, SLOT( updateTheme( ) ) ); |
130 q->connect( hbInstance->theme( ), SIGNAL( changed( ) ), q, SLOT( updateTheme( ) ) ); |
124 q->connect( q , SIGNAL( actionTriggered( int ) ), q , SLOT( showToolTip( ) ) ); |
131 // q->connect( q , SIGNAL( actionTriggered( int ) ), q , SLOT( showToolTip( ) ) ); |
125 q->connect( q , SIGNAL( sliderReleased( ) ), q , SLOT( hideToolTip( ) ) ); |
132 q->connect( q , SIGNAL( sliderReleased( ) ), q , SLOT( hideToolTip( ) ) ); |
126 #if defined( QT_KEYPAD_NAVIGATION ) && !defined( Q_OS_SYMBIAN ) |
133 #if defined( QT_KEYPAD_NAVIGATION ) && !defined( Q_OS_SYMBIAN ) |
127 q->setFlags( QGraphicsItem::ItemIsFocusable ); |
134 q->setFlags( QGraphicsItem::ItemIsFocusable ); |
128 #endif |
135 #endif |
129 } |
136 } |
130 |
137 |
131 |
138 int HbSliderControlPrivate::calculateSliderPosition(QPointF relativePos) |
|
139 { |
|
140 Q_Q (HbSliderControl); |
|
141 qreal span = 0; |
|
142 qreal handlePos = 0; |
|
143 QRectF bounds = q->boundingRect( ); |
|
144 QRectF handleBounds = handle->boundingRect( ); |
|
145 bounds.adjust( 0, 0, -handleBounds.width( ), -handleBounds.height( ) ); |
|
146 // calculate handle position and span |
|
147 switch ( q->orientation( ) ) { |
|
148 case Qt::Horizontal: |
|
149 handlePos = relativePos.x( ) - handleBounds.width( ) / 2; |
|
150 span = bounds.width( ); |
|
151 break; |
|
152 case Qt::Vertical: |
|
153 handlePos = relativePos.y( ) - handleBounds.height( ) / 2; |
|
154 span = bounds.height( ); |
|
155 break; |
|
156 default: |
|
157 break; |
|
158 } |
|
159 HbStyleOptionSlider opt; |
|
160 q->initStyleOption( &opt ); |
|
161 int pressValue = QStyle::sliderValueFromPosition( opt.minimum, opt.maximum, |
|
162 static_cast<int>( handlePos ),static_cast<int>( span ),opt.upsideDown ); |
|
163 return pressValue; |
|
164 |
|
165 |
|
166 } |
132 |
167 |
133 /*! |
168 /*! |
134 \internal |
169 \internal |
135 This is used to create the handle, it is virtual and can be overridden to create different handle. |
170 This is used to create the handle, it is virtual and can be overridden to create different handle. |
136 */ |
171 */ |
636 if ( !eventRect.contains( event->scenePos( ) ) ) { |
680 if ( !eventRect.contains( event->scenePos( ) ) ) { |
637 event->ignore( ); |
681 event->ignore( ); |
638 return; |
682 return; |
639 } |
683 } |
640 event->accept( ); |
684 event->accept( ); |
641 if( d->onHandle( event->scenePos( ) ) ) { |
685 if ( d->onHandle( event->scenePos( ) ) ) { |
642 HbWidgetFeedback::triggered( this, Hb::InstantPressed, Hb::ModifierSliderHandle ); |
686 HbWidgetFeedback::triggered( this, Hb::InstantPressed, Hb::ModifierSliderHandle ); |
643 setSliderDown( true ); |
687 setSliderDown( true ); |
644 d->handle->updatePrimitives( ); |
688 d->handle->updatePrimitives( ); |
645 d->handleMoving = true; |
689 d->handleMoving = true; |
646 } |
690 } |
647 else { |
691 else { |
648 // effect |
692 // effect |
649 #ifdef HB_EFFECTS |
693 #ifdef HB_EFFECTS |
650 if( d->grooveTouchArea->sceneBoundingRect( ).contains( event->scenePos( ) ) ) { |
694 if ( d->grooveTouchArea->sceneBoundingRect( ).contains( event->scenePos( ) ) ) { |
651 if( orientation( ) == Qt::Horizontal ) { |
695 if ( orientation( ) == Qt::Horizontal ) { |
652 // effect for horizontal track press |
696 // effect for horizontal track press |
653 HbEffectInternal::add( HB_SLIDERCONTROL_TYPE,"slider_h_trackpress", "h_trackpress" ); |
697 HbEffectInternal::add( HB_SLIDERCONTROL_TYPE,"slider_h_trackpress", "h_trackpress" ); |
654 HbEffect::start( d->groove, HB_SLIDERCONTROL_TYPE, "h_trackrpress" ); |
698 HbEffect::start( d->groove, HB_SLIDERCONTROL_TYPE, "h_trackrpress" ); |
655 } |
699 } |
656 else { |
700 else { |
779 */ |
823 */ |
780 #ifdef HB_GESTURE_FW |
824 #ifdef HB_GESTURE_FW |
781 void HbSliderControl::gestureEvent(QGestureEvent *event) |
825 void HbSliderControl::gestureEvent(QGestureEvent *event) |
782 { |
826 { |
783 Q_D(HbSliderControl); |
827 Q_D(HbSliderControl); |
784 if(HbTapGesture *tap = qobject_cast<HbTapGesture *>(event->gesture(Qt::TapGesture))) { |
828 if ( HbTapAndHoldGesture *tapandHold = qobject_cast<HbTapAndHoldGesture *> ( event->gesture( Qt::TapAndHoldGesture ) ) ) { |
785 if( d->onHandle( event->mapToGraphicsScene(tap->position( ) ) ) ){ |
829 if (tapandHold->state() == Qt::GestureStarted) { |
|
830 QPointF relativePos = mapFromScene( event->mapToGraphicsScene(tapandHold->position( ) ) ); |
|
831 int pressValue = d->calculateSliderPosition( relativePos ); |
|
832 setToolTip(QString::number( pressValue ) ); |
|
833 QRectF handleRect=d->handle->boundingRect(); |
|
834 QRectF tooltipRect = handleRect; |
|
835 QRectF touchPointRect=handleRect; |
|
836 if (orientation() == Qt::Horizontal) { |
|
837 touchPointRect.moveCenter(QPointF( boundingRect().width()/2,boundingRect( ).height()/2 ) ); |
|
838 touchPointRect.moveLeft(relativePos.rx() - touchPointRect.width( )/2); |
|
839 |
|
840 } else { |
|
841 touchPointRect.moveCenter(QPointF( boundingRect().width()/2,boundingRect( ).height()/2 ) ); |
|
842 touchPointRect.moveTop( relativePos.ry() - touchPointRect.height()/2 ); |
|
843 } |
|
844 tooltipRect.setHeight ( d->tooltipBorderHeight); |
|
845 tooltipRect.moveBottom( touchPointRect.top() ); |
|
846 tooltipRect.moveLeft (touchPointRect.left( ) ); |
|
847 d->tooltipArea->setGeometry(tooltipRect); |
|
848 d->tooltipArea->setGeometry(tooltipRect); |
|
849 d->tooltipArea->update(); |
|
850 if ( d->displayCurrValueToolTip ) { |
|
851 HbToolTip::showText( toolTip( ) , d->tooltipArea, d->toolTipAlignment ); |
|
852 } |
|
853 |
|
854 return; |
|
855 } |
|
856 } |
|
857 if ( HbTapGesture *tap = qobject_cast<HbTapGesture *> (event->gesture( Qt::TapGesture ) )) { |
|
858 if ( d->onHandle( event->mapToGraphicsScene(tap->position( ) ) ) ) { |
786 event->ignore(); |
859 event->ignore(); |
787 return; |
860 return; |
788 } |
861 } |
789 switch(tap->state()) { |
862 switch( tap->state( ) ) { |
790 case Qt::GestureStarted: { |
863 case Qt::GestureStarted: { |
791 QRectF eventRect = d->grooveTouchArea->sceneBoundingRect( ); |
864 QRectF eventRect = d->grooveTouchArea->sceneBoundingRect( ); |
792 if ( !d->trackHandlingEnable || maximum( ) == minimum( ) || |
865 if ( !d->trackHandlingEnable || maximum( ) == minimum( ) || |
793 !eventRect.contains( event->mapToGraphicsScene(tap->position( ) ) ) ){ |
866 !eventRect.contains( event->mapToGraphicsScene(tap->position( ) ) ) ) { |
794 event->ignore( ); |
867 event->ignore( ); |
795 return; |
868 return; |
796 } |
869 } |
797 |
870 |
798 #if defined( QT_KEYPAD_NAVIGATION ) && !defined( Q_OS_SYMBIAN ) |
871 #if defined( QT_KEYPAD_NAVIGATION ) && !defined( Q_OS_SYMBIAN ) |
801 } |
874 } |
802 #endif |
875 #endif |
803 event->accept( ); |
876 event->accept( ); |
804 // effect |
877 // effect |
805 #ifdef HB_EFFECTS |
878 #ifdef HB_EFFECTS |
806 if( orientation( ) == Qt::Horizontal ) { |
879 if ( orientation( ) == Qt::Horizontal ) { |
807 // effect for horizontal track press |
880 // effect for horizontal track press |
808 HbEffectInternal::add( HB_SLIDERCONTROL_TYPE,"slider_h_trackpress", "h_trackpress" ); |
881 HbEffectInternal::add( HB_SLIDERCONTROL_TYPE,"slider_h_trackpress", "h_trackpress" ); |
809 HbEffect::start( d->groove, HB_SLIDERCONTROL_TYPE, "h_trackrpress" ); |
882 HbEffect::start( d->groove, HB_SLIDERCONTROL_TYPE, "h_trackrpress" ); |
810 } |
883 } else { |
811 else { |
|
812 HbEffectInternal::add( HB_SLIDERCONTROL_TYPE,"slider_v_trackpress", "v_trackpress" ); |
884 HbEffectInternal::add( HB_SLIDERCONTROL_TYPE,"slider_v_trackpress", "v_trackpress" ); |
813 HbEffect::start( d->groove, HB_SLIDERCONTROL_TYPE, "v_trackpress" ); |
885 HbEffect::start( d->groove, HB_SLIDERCONTROL_TYPE, "v_trackpress" ); |
814 } |
886 } |
815 |
887 |
816 #endif |
888 #endif |
824 case Qt::GestureFinished:{ |
896 case Qt::GestureFinished:{ |
825 if ( !d->trackHandlingEnable ) { |
897 if ( !d->trackHandlingEnable ) { |
826 event->ignore( ); |
898 event->ignore( ); |
827 return; |
899 return; |
828 } |
900 } |
829 qreal handlePos = 0; |
|
830 qreal span = 0; |
|
831 QRectF bounds = boundingRect( ); |
|
832 QRectF handleBounds = d->handle->boundingRect( ); |
|
833 bounds.adjust( 0, 0, -handleBounds.width( ), -handleBounds.height( ) ); |
|
834 QPointF relativePos = mapFromScene( event->mapToGraphicsScene(tap->position( ) ) ); |
901 QPointF relativePos = mapFromScene( event->mapToGraphicsScene(tap->position( ) ) ); |
835 // calculate handle position and span |
902 int pressValue = d->calculateSliderPosition (relativePos); |
836 switch ( orientation( ) ) { |
|
837 case Qt::Horizontal: |
|
838 handlePos = relativePos.x( ) - handleBounds.width( ) / 2; |
|
839 span = bounds.width( ); |
|
840 break; |
|
841 case Qt::Vertical: |
|
842 handlePos = relativePos.y( ) - handleBounds.height( ) / 2; |
|
843 span = bounds.height( ); |
|
844 break; |
|
845 default: |
|
846 break; |
|
847 } |
|
848 HbStyleOptionSlider opt; |
|
849 initStyleOption( &opt ); |
|
850 |
|
851 int pressValue = QStyle::sliderValueFromPosition( opt.minimum, opt.maximum, |
|
852 static_cast<int>( handlePos ),static_cast<int>( span ),opt.upsideDown ); |
|
853 |
|
854 |
|
855 // if default is set then don't increment or decrement slider value |
903 // if default is set then don't increment or decrement slider value |
856 // just set default value to slider |
904 // just set default value to slider |
857 setSliderPosition( pressValue ); |
905 setSliderPosition( pressValue ); |
858 triggerAction( SliderMove ); |
906 triggerAction( SliderMove ); |
859 setRepeatAction( SliderNoAction, pressValue ); |
907 setRepeatAction( SliderNoAction, pressValue ); |
860 HbWidgetFeedback::triggered( this, Hb::InstantReleased ); |
908 HbWidgetFeedback::triggered( this, Hb::InstantReleased ); |
861 if ( d->groovePressed ) { |
909 if ( d->groovePressed ) { |
862 #ifdef HB_EFFECTS |
910 #ifdef HB_EFFECTS |
863 if( orientation( ) == Qt::Horizontal ) { |
911 if ( orientation( ) == Qt::Horizontal ) { |
864 HbEffectInternal::add( HB_SLIDERCONTROL_TYPE,"slider_h_trackrelease", "h_trackrelease" ); |
912 HbEffectInternal::add( HB_SLIDERCONTROL_TYPE,"slider_h_trackrelease", "h_trackrelease" ); |
865 HbEffect::start( d->groove, HB_SLIDERCONTROL_TYPE, "h_trackrelease" ); |
913 HbEffect::start( d->groove, HB_SLIDERCONTROL_TYPE, "h_trackrelease" ); |
866 } else { |
914 } else { |
867 HbEffectInternal::add( HB_SLIDERCONTROL_TYPE,"slider_v_trackrelease", "v_trackrelease" ); |
915 HbEffectInternal::add( HB_SLIDERCONTROL_TYPE,"slider_v_trackrelease", "v_trackrelease" ); |
868 HbEffect::start( d->groove, HB_SLIDERCONTROL_TYPE, "v_trackrelease" ); |
916 HbEffect::start( d->groove, HB_SLIDERCONTROL_TYPE, "v_trackrelease" ); |
878 break; |
926 break; |
879 |
927 |
880 case Qt::GestureCanceled: { |
928 case Qt::GestureCanceled: { |
881 if ( d->groovePressed ) { |
929 if ( d->groovePressed ) { |
882 #ifdef HB_EFFECTS |
930 #ifdef HB_EFFECTS |
883 if( orientation( ) == Qt::Horizontal ) { |
931 if ( orientation( ) == Qt::Horizontal ) { |
884 HbEffectInternal::add( HB_SLIDERCONTROL_TYPE,"slider_h_trackrelease", "h_trackrelease" ); |
932 HbEffectInternal::add( HB_SLIDERCONTROL_TYPE,"slider_h_trackrelease", "h_trackrelease" ); |
885 HbEffect::start( d->groove, HB_SLIDERCONTROL_TYPE, "h_trackrelease" ); |
933 HbEffect::start( d->groove, HB_SLIDERCONTROL_TYPE, "h_trackrelease" ); |
886 } else { |
934 } else { |
887 HbEffectInternal::add( HB_SLIDERCONTROL_TYPE,"slider_v_trackrelease", "v_trackrelease" ); |
935 HbEffectInternal::add( HB_SLIDERCONTROL_TYPE,"slider_v_trackrelease", "v_trackrelease" ); |
888 HbEffect::start( d->groove, HB_SLIDERCONTROL_TYPE, "v_trackrelease" ); |
936 HbEffect::start( d->groove, HB_SLIDERCONTROL_TYPE, "v_trackrelease" ); |
899 |
947 |
900 default: |
948 default: |
901 break; |
949 break; |
902 } |
950 } |
903 } |
951 } |
904 if (HbPanGesture *panGesture = qobject_cast<HbPanGesture*>(event->gesture(Qt::PanGesture))) { |
952 if ( HbPanGesture *panGesture = qobject_cast<HbPanGesture*> (event->gesture(Qt::PanGesture) ) ) { |
905 switch(panGesture->state( )) { |
953 switch(panGesture->state( ) ) { |
906 case Qt::GestureStarted: |
954 case Qt::GestureStarted: |
907 case Qt::GestureUpdated:{ |
955 case Qt::GestureUpdated:{ |
908 QPointF startPoint = event->mapToGraphicsScene(panGesture->offset()+panGesture->startPos( ) ); |
956 QPointF startPoint = event->mapToGraphicsScene(panGesture->offset()+panGesture->startPos( ) ); |
909 //if the position is on thumb , then start moving the thumb |
957 //if the position is on thumb , then start moving the thumb |
910 if( ( d->onHandle( startPoint) && d->grooveTouchArea->sceneBoundingRect( ).contains( startPoint))||isSliderDown( ) ) { |
958 if ( ( d->onHandle( startPoint) && d->grooveTouchArea->sceneBoundingRect( ).contains( startPoint) )||isSliderDown( ) ) { |
911 qreal handlePos = 0; |
959 QPointF relativePos = mapFromScene( event->mapToGraphicsScene(panGesture->startPos( ) + panGesture->offset() ) ); |
912 qreal span = 0; |
960 int pressValue = d->calculateSliderPosition (relativePos); |
913 QRectF bounds = boundingRect( ); |
|
914 QRectF handleBounds = d->handle->boundingRect( ); |
|
915 bounds.adjust( 0, 0, -handleBounds.width( ), -handleBounds.height( ) ); |
|
916 QPointF relativePos = mapFromScene( event->mapToGraphicsScene(panGesture->startPos( ) + panGesture->offset()) ); |
|
917 // calculate handle position and span |
|
918 switch ( orientation( ) ) { |
|
919 case Qt::Horizontal: |
|
920 handlePos = relativePos.x( ) - handleBounds.width( ) / 2; |
|
921 span = bounds.width( ); |
|
922 break; |
|
923 case Qt::Vertical: |
|
924 handlePos = relativePos.y( ) - handleBounds.height( ) / 2; |
|
925 span = bounds.height( ); |
|
926 break; |
|
927 default: |
|
928 break; |
|
929 } |
|
930 HbStyleOptionSlider opt; |
|
931 initStyleOption( &opt ); |
|
932 |
|
933 int pressValue = QStyle::sliderValueFromPosition( opt.minimum, opt.maximum, |
|
934 static_cast<int>( handlePos ),static_cast<int>( span ),opt.upsideDown ); |
|
935 setRepeatAction( SliderNoAction,static_cast<int>( pressValue ) ); |
961 setRepeatAction( SliderNoAction,static_cast<int>( pressValue ) ); |
936 setSliderDown( true ); |
962 setSliderDown( true ); |
937 setSliderPosition( pressValue ); |
963 setSliderPosition( pressValue ); |
|
964 setToolTip( QString::number( pressValue ) ); |
938 showToolTip( ); |
965 showToolTip( ); |
939 d->groovePressed = false; |
966 d->groovePressed = false; |
940 updatePrimitives(); |
967 updatePrimitives(); |
941 d->handleMoving = true ; |
968 d->handleMoving = true ; |
942 break; |
969 break; |
943 } else if(d->grooveTouchArea->sceneBoundingRect().contains(startPoint) ){ |
970 } else if (d->grooveTouchArea->sceneBoundingRect().contains(startPoint) ) { |
|
971 QPointF relativePos = mapFromScene( event->mapToGraphicsScene(panGesture->startPos( ) + panGesture->offset() ) ); |
|
972 int pressValue = d->calculateSliderPosition (relativePos); |
|
973 setToolTip( QString::number( pressValue ) ); |
|
974 QRectF handleRect=d->handle->boundingRect(); |
|
975 QRectF tooltipRect = handleRect; |
|
976 QRectF touchPointRect=handleRect; |
|
977 if (orientation() == Qt::Horizontal) { |
|
978 touchPointRect.moveCenter(QPointF( boundingRect().width()/2,boundingRect( ).height()/2 ) ); |
|
979 touchPointRect.moveLeft(relativePos.rx() - touchPointRect.width( )/2); |
|
980 } else { |
|
981 touchPointRect.moveCenter(QPointF( boundingRect().width()/2,boundingRect( ).height()/2 ) ); |
|
982 touchPointRect.moveTop( relativePos.ry() - touchPointRect.height()/2 ); |
|
983 } |
|
984 tooltipRect.setHeight ( d->tooltipBorderHeight); |
|
985 tooltipRect.moveBottom( touchPointRect.top() ); |
|
986 tooltipRect.moveLeft (touchPointRect.left( ) ); |
|
987 d->tooltipArea->setGeometry(tooltipRect); |
|
988 d->tooltipArea->setGeometry(tooltipRect); |
|
989 d->tooltipArea->update(); |
|
990 if ( d->displayCurrValueToolTip ) { |
|
991 HbToolTip::showText( toolTip( ) , d->tooltipArea, d->toolTipAlignment ); |
|
992 } |
|
993 d->groovePressed = true; |
944 HbStyleOptionSlider opt; |
994 HbStyleOptionSlider opt; |
945 d->groovePressed = true; |
|
946 initStyleOption( &opt ); |
995 initStyleOption( &opt ); |
947 HbStylePrivate::updatePrimitive( d->groove, HbStylePrivate::P_Slider_groove, &opt ); |
996 HbStylePrivate::updatePrimitive( d->groove, HbStylePrivate::P_Slider_groove, &opt ); |
948 event->ignore(); |
997 event->ignore(); |
|
998 QPointF diffOffset = panGesture->offset() - panGesture->lastOffset(); |
|
999 if (orientation() == Qt::Horizontal) { |
|
1000 if (qAbs(diffOffset.x() ) < qAbs(diffOffset.y())) { |
|
1001 HbAbstractSliderControl::gestureEvent(event); |
|
1002 |
|
1003 } |
|
1004 } else { |
|
1005 if (qAbs(diffOffset.y() ) < qAbs(diffOffset.x())) { |
|
1006 HbAbstractSliderControl::gestureEvent(event); |
|
1007 } |
|
1008 } |
|
1009 |
949 break; |
1010 break; |
950 } else { |
1011 } else { |
951 setSliderDown( false ); |
1012 setSliderDown( false ); |
952 d->groovePressed = false; |
1013 d->groovePressed = false; |
953 updatePrimitives( ); |
1014 updatePrimitives( ); |
959 |
1020 |
960 } |
1021 } |
961 break; |
1022 break; |
962 case Qt::GestureFinished: |
1023 case Qt::GestureFinished: |
963 case Qt::GestureCanceled: { |
1024 case Qt::GestureCanceled: { |
|
1025 QPointF startPoint = event->mapToGraphicsScene(panGesture->offset()+panGesture->startPos( ) ); |
964 setSliderDown( false ); |
1026 setSliderDown( false ); |
965 d->groovePressed = false; |
1027 d->groovePressed = false; |
966 updatePrimitives( ); |
1028 updatePrimitives( ); |
967 d->handle->updatePrimitives(); |
1029 d->handle->updatePrimitives(); |
968 d->handleMoving = false; |
1030 d->handleMoving = false; |
969 int pressValue = sliderPosition(); |
1031 if (d->grooveTouchArea->sceneBoundingRect().contains(startPoint) ) { |
970 setRepeatAction( SliderNoAction,static_cast<int>( pressValue ) ); |
1032 QPointF relativePos = mapFromScene( event->mapToGraphicsScene(panGesture->startPos( ) + panGesture->offset() ) ); |
|
1033 int pressValue = d->calculateSliderPosition (relativePos); |
|
1034 setRepeatAction( SliderNoAction,static_cast<int>( pressValue ) ); |
|
1035 setSliderPosition( pressValue ); |
|
1036 setToolTip( QString::number( pressValue ) ); |
|
1037 showToolTip( ); |
|
1038 } |
971 event->ignore(); |
1039 event->ignore(); |
972 HbWidgetFeedback::triggered(this, Hb::InstantReleased); |
|
973 HbAbstractSliderControl::gestureEvent(event); |
1040 HbAbstractSliderControl::gestureEvent(event); |
974 } |
1041 } |
975 break; |
1042 break; |
976 default: |
1043 default: |
977 break; |
1044 break; |