--- a/src/hbwidgets/sliders/hbvolumeslider_p.cpp Thu Sep 02 20:44:51 2010 +0300
+++ b/src/hbwidgets/sliders/hbvolumeslider_p.cpp Fri Sep 17 08:32:10 2010 +0300
@@ -34,6 +34,14 @@
#include <QGraphicsSceneEvent>
#include <QGraphicsScene>
#include <hbwidgetfeedback.h>
+#ifdef HB_GESTURE_FW
+#include <hbtapgesture.h>
+#endif
+#ifdef HB_EFFECTS
+#include "hbeffect.h"
+#include "hbeffectinternal_p.h"
+#define HB_SLIDER_TYPE "HB_SLIDER"
+#endif
/*!
Example usage:
@@ -134,6 +142,9 @@
if( currentValueVisible )
elements<<HbSlider::TextElement;
setElements( elements );
+#ifdef HB_GESTURE_FW
+ q->grabGesture(Qt::TapGesture);
+#endif
// create element because HbSlider will not create element for NULL Icon
// and volume slider Icon is set in style
if ( !elementItemMap.contains(HbSlider::IncreaseElement) ) {
@@ -347,6 +358,8 @@
*/
void HbVolumeSlider::mousePressEvent( QGraphicsSceneMouseEvent *event )
{
+
+#ifndef HB_GESTURE_FW
Q_D( HbVolumeSlider );
if( d->elementItemMap.contains(HbSlider::IncreaseElement) ) {
if ( d->elementItemMap[HbSlider::IncreaseElement].touchItem->isUnderMouse( ) ) {
@@ -394,6 +407,9 @@
}
}
HbSlider::mousePressEvent( event );
+#else
+ Q_UNUSED(event)
+#endif
}
/*!
@@ -402,12 +418,16 @@
*/
void HbVolumeSlider::mouseReleaseEvent( QGraphicsSceneMouseEvent *event )
{
+#ifndef HB_GESTURE_FW
Q_D( HbVolumeSlider );
HbSlider::mouseReleaseEvent( event );
d->stopRepeatAction( );
setProperty("changeincrementState" ,false);
setProperty("changedecrementState" ,false);
setProperty("state", "normal");
+#else
+ Q_UNUSED(event)
+#endif
}
/*!
@@ -453,6 +473,92 @@
d->sliderControl->setFocus( );
}
+/*!
+ \reimp
+ */
+void HbVolumeSlider::gestureEvent(QGestureEvent *event)
+{
+ Q_D(HbVolumeSlider);
+ //consume the event if gesture is on increment or decrement,
+ //if the slide ris muted and then on pressing on icrement/decrement value consider previous value as well
+ if (HbTapGesture *tap = qobject_cast<HbTapGesture *>(event->gesture(Qt::TapGesture))) {
+ QPointF pos = event->mapToGraphicsScene(tap->position());
+ bool consumeEvent = false;
+ switch( tap->state( ) ) {
+ case Qt::GestureStarted: {
+ if ( d->elementItemMap.contains (HbSlider::IncreaseElement ) ) {
+ if (d->elementItemMap[HbSlider::IncreaseElement].touchItem ) {
+ if (d->elementItemMap[HbSlider::IncreaseElement].touchItem->sceneBoundingRect().contains(pos)) {
+ consumeEvent = true;
+ d->pressOnIncrement = true;
+ HbWidgetFeedback::triggered( d->sliderControl, Hb::InstantPressed, Hb::ModifierSliderElement );
+ event->accept( );
+ // if volume was mute
+ if( isIconChecked( ) ){
+ // take to previous value and increase one step
+ setValue( d->previousValue+singleStep( ) );
+ // start timer for repeat action
+ d->sliderControl->setRepeatAction(
+ HbAbstractSliderControl::SliderSingleStepAdd, d->sliderControl->maximum( ) );
+ } else {// simply increase by one step
+ d->startIncrementing( );
+ }
+ setProperty("changeincrementState" ,true);
+ setProperty("changedecrementState" ,false);
+ setProperty("state", "pressed");
+ }
+ }
+ }
+ if ( d->elementItemMap.contains (HbSlider::DecreaseElement ) ) {
+ if (d->elementItemMap[HbSlider::DecreaseElement].touchItem ) {
+ if (d->elementItemMap[HbSlider::DecreaseElement].touchItem->sceneBoundingRect().contains(pos)) {
+ consumeEvent = true;
+ d->pressOnIncrement = false;
+ HbWidgetFeedback::triggered( d->sliderControl, Hb::InstantPressed, Hb::ModifierSliderElement );
+ event->accept( );
+ if( isIconChecked( ) ){
+ //set value to previous value and decrement by one step
+ setValue( d->previousValue-singleStep( ) );
+ if( value( )==minimum( ) ){
+ d->previousValue = value( );
+ setIconEnabled( false );
+ }
+ //start timer for repeat action
+ d->sliderControl->setRepeatAction(
+ HbAbstractSliderControl::SliderSingleStepSub, d->sliderControl->minimum( ) );
+ } else {
+ d->startDecrementing( );
+ }
+ setProperty("changeincrementState" ,false);
+ setProperty("changedecrementState" ,true);
+ setProperty("state", "pressed");
+
+ }
+ }
+ }
+ }
+ break;
+ case Qt::GestureCanceled:
+ case Qt::GestureFinished:
+ setProperty("changeincrementState" ,false);
+ setProperty("changedecrementState" ,false);
+ setProperty("state", "normal");
+ consumeEvent = true;
+ HbSlider::gestureEvent(event);
+ break;
+ default:
+ break;
+ }
+ if(!consumeEvent) {
+ event->ignore();
+ HbSlider::gestureEvent(event);
+ }
+
+
+ }
+
+}
+
#include "moc_hbvolumeslider_p.cpp"