380 //updatePrimitives(); |
370 //updatePrimitives(); |
381 if( d->textItem ) { |
371 if( d->textItem ) { |
382 HbStyleOptionPushButton buttonOption; |
372 HbStyleOptionPushButton buttonOption; |
383 initStyleOption( &buttonOption ); |
373 initStyleOption( &buttonOption ); |
384 style( )->updatePrimitive( d->textItem, HbStyle::P_PushButton_text, &buttonOption); |
374 style( )->updatePrimitive( d->textItem, HbStyle::P_PushButton_text, &buttonOption); |
|
375 if ( isEnabled() ) { |
|
376 setProperty("state", "normal"); |
|
377 } |
385 } |
378 } |
386 if(doPolish) { |
379 if(doPolish) { |
387 repolish( ); |
380 repolish( ); |
388 } |
381 } |
389 } |
382 } |
422 // updatePrimitives(); |
415 // updatePrimitives(); |
423 if( d->additionalTextItem ) { |
416 if( d->additionalTextItem ) { |
424 HbStyleOptionPushButton buttonOption; |
417 HbStyleOptionPushButton buttonOption; |
425 initStyleOption( &buttonOption ); |
418 initStyleOption( &buttonOption ); |
426 style( )->updatePrimitive( d->additionalTextItem, HbStyle::P_PushButton_additionaltext, &buttonOption); |
419 style( )->updatePrimitive( d->additionalTextItem, HbStyle::P_PushButton_additionaltext, &buttonOption); |
|
420 if ( isEnabled() ) { |
|
421 setProperty("state", "normal"); |
|
422 } |
427 } |
423 } |
428 if( doPolish ) { |
424 if( doPolish ) { |
429 repolish(); |
425 repolish(); |
430 } |
426 } |
431 } |
427 } |
454 void HbPushButton::setIcon( const HbIcon &icon ) |
450 void HbPushButton::setIcon( const HbIcon &icon ) |
455 { |
451 { |
456 Q_D(HbPushButton); |
452 Q_D(HbPushButton); |
457 |
453 |
458 if ( d->icon != icon ) { |
454 if ( d->icon != icon ) { |
459 bool doPolish = icon.isNull( ) || d->icon.isNull(); |
455 //checking for d->polished to avoid extra polish loop |
|
456 bool doPolish = (icon.isNull( ) || d->icon.isNull()) && d->polished; |
460 d->icon = icon; |
457 d->icon = icon; |
461 d->createPrimitives( ); |
458 d->createPrimitives( ); |
462 //updatePrimitives(); |
459 //updatePrimitives(); |
463 if( d->iconItem ) { |
460 if( d->iconItem ) { |
464 HbStyleOptionPushButton buttonOption; |
461 HbStyleOptionPushButton buttonOption; |
465 initStyleOption( &buttonOption ); |
462 initStyleOption( &buttonOption ); |
466 style()->updatePrimitive( d->iconItem, HbStyle::P_PushButton_icon, &buttonOption ); |
463 style()->updatePrimitive( d->iconItem, HbStyle::P_PushButton_icon, &buttonOption ); |
|
464 if ( isEnabled() ) { |
|
465 setProperty("state", "normal"); |
|
466 } |
467 |
467 |
468 } |
468 } |
469 if( doPolish ) { |
469 if( doPolish ) { |
470 repolish(); |
470 repolish(); |
471 } |
471 } |
692 HbAbstractButton(dd, parent) |
692 HbAbstractButton(dd, parent) |
693 { |
693 { |
694 } |
694 } |
695 |
695 |
696 /*! |
696 /*! |
|
697 \reimp |
697 Initializes \a option with the values from this HbPushButton. |
698 Initializes \a option with the values from this HbPushButton. |
698 This method is useful for subclasses when they need a HbStyleOptionPushButton, |
699 This method is useful for subclasses when they need a HbStyleOptionPushButton, |
699 but don't want to fill in all the information themselves. |
700 but don't want to fill in all the information themselves. |
700 */ |
701 */ |
701 void HbPushButton::initStyleOption( HbStyleOptionPushButton *option ) const |
702 void HbPushButton::initStyleOption( HbStyleOptionPushButton *option ) const |
856 #ifdef HB_GESTURE_FW |
859 #ifdef HB_GESTURE_FW |
857 void HbPushButton::gestureEvent( QGestureEvent *event ) |
860 void HbPushButton::gestureEvent( QGestureEvent *event ) |
858 { |
861 { |
859 Q_D(HbPushButton); |
862 Q_D(HbPushButton); |
860 if(HbTapGesture *tap = qobject_cast<HbTapGesture *>(event->gesture(Qt::TapGesture))) { |
863 if(HbTapGesture *tap = qobject_cast<HbTapGesture *>(event->gesture(Qt::TapGesture))) { |
|
864 bool hit = hitButton(mapFromScene(event->mapToGraphicsScene(tap->position()))); |
861 switch(tap->state()) { |
865 switch(tap->state()) { |
862 case Qt::GestureStarted:{ |
866 case Qt::GestureStarted: |
|
867 if( hit ){ |
863 #ifdef HB_EFFECTS |
868 #ifdef HB_EFFECTS |
864 HbEffect::start( this, HB_PUSHBUTTON_TYPE, "pressed" ); |
869 HbEffect::start( this, HB_PUSHBUTTON_TYPE, "pressed" ); |
865 #endif |
870 #endif |
|
871 if( d->checkable && !d->checked) { |
|
872 setProperty( "state", "latched" ); |
|
873 }else if(!d->checkable) { |
|
874 setProperty( "state", "pressed" ); |
|
875 } |
|
876 } |
|
877 break; |
|
878 case Qt::GestureUpdated: |
|
879 if(tap->tapStyleHint() == HbTapGesture::TapAndHold && hit) { |
|
880 d->longPress = true; |
|
881 emit longPress( event->mapToGraphicsScene(tap->position()) ); |
|
882 } |
|
883 break; |
|
884 case Qt::GestureCanceled: |
|
885 setProperty( "state", "normal" ); |
|
886 break; |
|
887 case Qt::GestureFinished: |
|
888 if( hit ){ |
|
889 #ifdef HB_EFFECTS |
|
890 HbEffect::start( this, HB_PUSHBUTTON_TYPE, "released" ); |
|
891 #endif |
|
892 } |
866 if( d->checkable && !d->checked) { |
893 if( d->checkable && !d->checked) { |
867 setProperty( "state", "latched" ); |
894 setProperty( "state", "latched" ); |
868 }else if(!d->checkable) { |
895 }else { |
869 setProperty( "state", "pressed" ); |
|
870 } |
|
871 } |
|
872 break; |
|
873 case Qt::GestureUpdated: |
|
874 if(tap->tapStyleHint() == HbTapGesture::TapAndHold) { |
|
875 d->longPress = true; |
|
876 emit longPress( event->mapToGraphicsScene(tap->position()) ); |
|
877 } |
|
878 break; |
|
879 case Qt::GestureCanceled: |
|
880 setProperty( "state", "normal" ); |
|
881 break; |
|
882 case Qt::GestureFinished:{ |
|
883 #ifdef HB_EFFECTS |
|
884 HbEffect::start( this, HB_PUSHBUTTON_TYPE, "released" ); |
|
885 #endif |
|
886 if( d->checkable && !d->checked) { |
|
887 setProperty( "state", "latched" ); |
|
888 }else { |
|
889 setProperty( "state", "normal" ); |
896 setProperty( "state", "normal" ); |
890 } |
897 } |
891 |
898 break; |
892 } |
899 default: |
893 break; |
900 break; |
894 default: |
901 } |
895 break; |
902 } |
896 } |
|
897 } |
|
898 |
|
899 HbAbstractButton::gestureEvent( event ); |
903 HbAbstractButton::gestureEvent( event ); |
900 |
|
901 } |
904 } |
902 #endif |
905 #endif |
903 |
906 |
904 |
907 |
905 /*! |
908 /*! |