src/hbwidgets/sliders/hbslider.cpp
changeset 28 b7da29130b0e
parent 23 e6ad4ef83b23
equal deleted inserted replaced
23:e6ad4ef83b23 28:b7da29130b0e
   963     if( d->sliderTextString!= text) {
   963     if( d->sliderTextString!= text) {
   964         d->sliderTextString = text;
   964         d->sliderTextString = text;
   965         if ( d->elements.contains( HbSlider::TextElement ))  {
   965         if ( d->elements.contains( HbSlider::TextElement ))  {
   966             d->elementWidget( HbSlider::TextElement );  
   966             d->elementWidget( HbSlider::TextElement );  
   967         }
   967         }
   968         // sets text for tooltip also
       
   969         d->sliderControl->setToolTip( text );
       
   970     }
   968     }
   971 }
   969 }
   972 
   970 
   973 /*!
   971 /*!
   974     @beta
   972     @beta
  1857 /*!
  1855 /*!
  1858     \reimp
  1856     \reimp
  1859  */
  1857  */
  1860 void HbSlider::mousePressEvent( QGraphicsSceneMouseEvent *event )
  1858 void HbSlider::mousePressEvent( QGraphicsSceneMouseEvent *event )
  1861 {
  1859 {
       
  1860 #ifndef HB_GESTURE_FW 
  1862     Q_D( HbSlider );
  1861     Q_D( HbSlider );
  1863     HbWidget::mousePressEvent( event );
  1862     HbWidget::mousePressEvent( event );
  1864     if( d->elementItemMap.contains (HbSlider::IncreaseElement) ) {
  1863     if( d->elementItemMap.contains (HbSlider::IncreaseElement) ) {
  1865         if ( d->elementItemMap[HbSlider::IncreaseElement].touchItem->isUnderMouse( ) ) {
  1864         if ( d->elementItemMap[HbSlider::IncreaseElement].touchItem->isUnderMouse( ) ) {
  1866             // this is used for effect
  1865             // this is used for effect
  1880             //decrement and start decrement timer
  1879             //decrement and start decrement timer
  1881             d->startDecrementing( );
  1880             d->startDecrementing( );
  1882             return;
  1881             return;
  1883         }
  1882         }
  1884     }
  1883     }
       
  1884 #else 
       
  1885     Q_UNUSED(event);
       
  1886 #endif 
  1885 }
  1887 }
  1886 
  1888 
  1887 
  1889 
  1888 /*!
  1890 /*!
  1889     \reimp
  1891     \reimp
  1890 
  1892 
  1891     This Api start the releae effect.
  1893     This Api start the releae effect.
  1892  */
  1894  */
  1893 void HbSlider::mouseReleaseEvent( QGraphicsSceneMouseEvent *event )
  1895 void HbSlider::mouseReleaseEvent( QGraphicsSceneMouseEvent *event )
  1894 {
  1896 {
       
  1897 #ifndef HB_GESTURE_FW 
  1895     Q_D( HbSlider );
  1898     Q_D( HbSlider );
  1896     HbWidget::mouseReleaseEvent( event );
  1899     HbWidget::mouseReleaseEvent( event );
  1897     if( d->elementItemMap.contains(HbSlider::IncreaseElement) ) {
  1900     if( d->elementItemMap.contains(HbSlider::IncreaseElement) ) {
  1898         if ( d->pressOnIncrement ) {
  1901         if ( d->pressOnIncrement ) {
  1899             if( d->elementItemMap[HbSlider::IncreaseElement].touchItem->isUnderMouse( ) ) {
  1902             if( d->elementItemMap[HbSlider::IncreaseElement].touchItem->isUnderMouse( ) ) {
  1915             HbEffect::start( d->elementItemMap[HbSlider::DecreaseElement].item, HB_SLIDER_TYPE, "decreaserelease" );  
  1918             HbEffect::start( d->elementItemMap[HbSlider::DecreaseElement].item, HB_SLIDER_TYPE, "decreaserelease" );  
  1916 #endif
  1919 #endif
  1917         }
  1920         }
  1918     }
  1921     }
  1919     d->stopRepeatAction( );
  1922     d->stopRepeatAction( );
       
  1923 #else
       
  1924     Q_UNUSED( event )
       
  1925 #endif 
  1920 }
  1926 }
  1921 
  1927 
  1922 /*!
  1928 /*!
  1923   reimp
  1929   reimp
  1924 
  1930 
  1930     //consume the event if gesture is on increment or decrement,It is being handled in mouse press and mouse release
  1936     //consume the event if gesture is on increment or decrement,It is being handled in mouse press and mouse release
  1931     //If it is on mute/control igonore the gesture as they are handled separately by HbAbstractButton and HbSlidercontrol classes
  1937     //If it is on mute/control igonore the gesture as they are handled separately by HbAbstractButton and HbSlidercontrol classes
  1932     if (HbTapGesture *tap = qobject_cast<HbTapGesture *>(event->gesture(Qt::TapGesture))) {
  1938     if (HbTapGesture *tap = qobject_cast<HbTapGesture *>(event->gesture(Qt::TapGesture))) {
  1933         QPointF pos = event->mapToGraphicsScene(tap->position());
  1939         QPointF pos = event->mapToGraphicsScene(tap->position());
  1934         bool consumeEvent = false;
  1940         bool consumeEvent = false;
  1935         if ( d->elementItemMap.contains (HbSlider::IncreaseElement ) ) {
  1941         switch( tap->state( ) ) {
  1936             if (d->elementItemMap[HbSlider::IncreaseElement].touchItem ) {
  1942         case Qt::GestureStarted: {
  1937                 if (d->elementItemMap[HbSlider::IncreaseElement].touchItem->sceneBoundingRect().contains(pos)) {
  1943             if ( d->elementItemMap.contains (HbSlider::IncreaseElement ) ) {
  1938                     consumeEvent = true;
  1944                 if (d->elementItemMap[HbSlider::IncreaseElement].touchItem ) {
       
  1945                     if (d->elementItemMap[HbSlider::IncreaseElement].touchItem->sceneBoundingRect().contains(pos)) {
       
  1946                         consumeEvent = true;
       
  1947                         d->pressOnIncrement  = true;
       
  1948                         HbWidgetFeedback::triggered( d->sliderControl, Hb::InstantPressed, Hb::ModifierSliderElement );
       
  1949                         event->accept( );
       
  1950                         // increment and start reapeat timer 
       
  1951                         d->startIncrementing( );
       
  1952                     }
  1939                 }
  1953                 }
  1940             }
  1954             }
  1941         }
  1955             if ( d->elementItemMap.contains (HbSlider::DecreaseElement ) ) {
  1942         if ( d->elementItemMap.contains (HbSlider::DecreaseElement ) ) {
  1956                 if (d->elementItemMap[HbSlider::DecreaseElement].touchItem ) {
  1943             if (d->elementItemMap[HbSlider::DecreaseElement].touchItem ) {
  1957                     if (d->elementItemMap[HbSlider::DecreaseElement].touchItem->sceneBoundingRect().contains(pos))  {
  1944                 if (d->elementItemMap[HbSlider::DecreaseElement].touchItem->sceneBoundingRect().contains(pos))  {
  1958                         consumeEvent = true;
  1945                     consumeEvent = true;
  1959                         d->pressOnIncrement  = false;
       
  1960                         HbWidgetFeedback::triggered( d->sliderControl, Hb::InstantPressed, Hb::ModifierSliderElement );
       
  1961                         event->accept( );
       
  1962                         //decrement and start decrement timer
       
  1963                         d->startDecrementing( );
       
  1964 
       
  1965                     }
  1946                 }
  1966                 }
  1947             }
  1967             }
  1948         }
  1968         }
  1949 
  1969         break;
  1950        if(!consumeEvent) {
  1970         case Qt::GestureCanceled:
       
  1971         case Qt::GestureFinished:            
       
  1972             if ( d->elementItemMap.contains (HbSlider::IncreaseElement ) ) {
       
  1973                 if (d->elementItemMap[HbSlider::IncreaseElement].touchItem ) {
       
  1974                     if ( d->pressOnIncrement ) {
       
  1975                         if( d->elementItemMap[HbSlider::IncreaseElement].touchItem->sceneBoundingRect().contains(pos)) {
       
  1976                             HbWidgetFeedback::triggered( d->sliderControl, Hb::InstantReleased, Hb::ModifierSliderElement );
       
  1977                         }
       
  1978             #ifdef HB_EFFECTS
       
  1979                         HbEffectInternal::add( HB_SLIDER_TYPE,"slidericon_release", "increaserelease" );
       
  1980                         HbEffect::start( d->elementItemMap[HbSlider::IncreaseElement].item, HB_SLIDER_TYPE, "increaserelease" );  
       
  1981             #endif
       
  1982                     }
       
  1983                 }
       
  1984             }
       
  1985             if ( d->elementItemMap.contains (HbSlider::DecreaseElement ) ) {
       
  1986                 if (d->elementItemMap[HbSlider::DecreaseElement].touchItem ) {
       
  1987                     if( d->elementItemMap.contains(HbSlider::DecreaseElement) ) {
       
  1988                         if ( !d->pressOnIncrement ) {
       
  1989                             if( d->elementItemMap[HbSlider::DecreaseElement].touchItem->sceneBoundingRect().contains(pos) ) {
       
  1990                                 HbWidgetFeedback::triggered( d->sliderControl, Hb::InstantReleased, Hb::ModifierSliderElement );
       
  1991                             }
       
  1992                 #ifdef HB_EFFECTS
       
  1993                             HbEffectInternal::add( HB_SLIDER_TYPE,"slidericon_release", "decreaserelease" );
       
  1994                             HbEffect::start( d->elementItemMap[HbSlider::DecreaseElement].item, HB_SLIDER_TYPE, "decreaserelease" );  
       
  1995                 #endif
       
  1996                         }
       
  1997                     }
       
  1998                 }
       
  1999             }
       
  2000             d->stopRepeatAction( );
       
  2001             break;
       
  2002         default: break;
       
  2003         }    
       
  2004         if(!consumeEvent) {
  1951            event->ignore();
  2005            event->ignore();
  1952            HbWidget::gestureEvent(event);
  2006            HbWidget::gestureEvent(event);
  1953        }
  2007        }
  1954     }
  2008     }
  1955         
  2009