502 @beta |
476 @beta |
503 Returns the icon shown on the button. |
477 Returns the icon shown on the button. |
504 \sa setIcon() |
478 \sa setIcon() |
505 */ |
479 */ |
506 |
480 |
507 HbIcon HbPushButton::icon() const |
481 HbIcon HbPushButton::icon( ) const |
508 { |
482 { |
509 Q_D(const HbPushButton); |
483 Q_D( const HbPushButton ); |
510 return d->icon; |
484 return d->icon; |
511 } |
485 } |
512 |
486 |
513 |
487 /*! |
514 /*! |
488 @beta |
515 \deprecated HbPushButton::setOrientation( Qt::Orientation ) |
|
516 is deprecated. Please use HbPushButton::setStretched(bool) instead |
|
517 |
|
518 Set the orientation.Default orientation is Qt::Vertical. |
|
519 In case of icon ,text and additional text it has to be set to Qt::Horizontal. |
|
520 In case of additionalText and text it has to be set to Qt:Vertical. |
|
521 \sa orientation() |
|
522 */ |
|
523 void HbPushButton::setOrientation( Qt::Orientation orientation ) |
|
524 { |
|
525 Q_D(HbPushButton); |
|
526 if( d->orientation != orientation ) { |
|
527 d->orientation = orientation; |
|
528 // calling setStretchedMode internaly this api is going to be depricated. |
|
529 bool stretched = |
|
530 (d->orientation == Qt::Vertical)?(false):(true); |
|
531 setStretched( stretched ); |
|
532 } |
|
533 qDebug()<<"This api is deprecated use HbPushButton::setStretched( bool stretched )"; |
|
534 } |
|
535 |
|
536 /*! |
|
537 \deprecated HbPushButton::orientation() const |
|
538 is deprecated.Please use bool HbPushButton::isStretched() const instead |
|
539 |
|
540 Returns orientation of button |
|
541 \sa setOrientation () |
|
542 */ |
|
543 Qt::Orientation HbPushButton::orientation() const |
|
544 { |
|
545 Q_D(const HbPushButton); |
|
546 qDebug()<<"This api is deprecated use bool HbPushButton::isStretched() const"; |
|
547 return d->orientation; |
|
548 } |
|
549 |
|
550 /*! |
|
551 Set the text alignment for primarytext and additional text. |
489 Set the text alignment for primarytext and additional text. |
552 The default alignment is Qt::AlignHCenter | Qt::AlignVCenter. |
490 The default alignment is Qt::AlignHCenter | Qt::AlignVCenter. |
553 \sa textAlignment() |
491 \sa textAlignment() |
554 */ |
492 */ |
555 void HbPushButton::setTextAlignment( Qt::Alignment alignment ) |
493 void HbPushButton::setTextAlignment( Qt::Alignment alignment ) |
556 { |
494 { |
557 Q_D(HbPushButton); |
495 Q_D( HbPushButton ); |
558 |
496 |
559 //HbWidgetBase* textItem = static_cast<HbWidgetBase*>(d->textItem); |
497 //HbWidgetBase* textItem = static_cast<HbWidgetBase*>(d->textItem); |
560 if(!d->textItem){ |
498 if( !d->textItem ) { |
561 //need to create text item if user call alignment api before setText. |
499 //need to create text item if user call alignment api before setText. |
562 d->textItem = style()->createPrimitive( HbStyle::P_PushButton_text, this); |
500 d->textItem = style( )->createPrimitive( HbStyle::P_PushButton_text, this); |
563 } |
501 } |
564 //HbWidgetBasePrivate *textItem_p = HbWidgetBasePrivate::d_ptr(textItem); |
502 //HbWidgetBasePrivate *textItem_p = HbWidgetBasePrivate::d_ptr(textItem); |
565 // check for textitem and api protection flag |
503 // check for textitem and api protection flag |
566 if(alignment != d->textAlignment ){ |
504 if( alignment != d->textAlignment ){ |
567 //take the alignment |
505 //take the alignment |
568 d->textAlignment = alignment; |
506 d->textAlignment = alignment; |
569 //set the api protection flag |
507 //set the api protection flag |
570 //HbWidgetBasePrivate::d_ptr(textItem)->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextAlign,true); |
508 //HbWidgetBasePrivate::d_ptr(textItem)->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextAlign,true); |
571 d->hasTextAlignment = true; |
509 d->hasTextAlignment = true; |
587 return d->textAlignment; |
526 return d->textAlignment; |
588 } |
527 } |
589 |
528 |
590 |
529 |
591 /*! |
530 /*! |
|
531 @beta |
592 Set the text alignment for additional text. |
532 Set the text alignment for additional text. |
593 The default alignment is Qt::AlignHCenter | Qt::AlignVCenter. |
533 The default alignment is Qt::AlignHCenter | Qt::AlignVCenter. |
594 \sa additionalTextAlignment() |
534 \sa additionalTextAlignment() |
595 */ |
535 */ |
596 void HbPushButton::setAdditionalTextAlignment( Qt::Alignment alignment ) |
536 void HbPushButton::setAdditionalTextAlignment( Qt::Alignment alignment ) |
597 { |
537 { |
598 Q_D(HbPushButton); |
538 Q_D( HbPushButton ); |
599 |
539 |
600 //HbWidgetBase* additionalTextItem = static_cast<HbWidgetBase*>(d->additionalTextItem); |
540 //HbWidgetBase* additionalTextItem = static_cast<HbWidgetBase*>(d->additionalTextItem); |
601 if(!d->additionalTextItem){ |
541 if(!d->additionalTextItem) { |
602 //need to create text item if user call alignment api before setAdditionalText. |
542 //need to create text item if user call alignment api before setAdditionalText. |
603 d->additionalTextItem = style()->createPrimitive( HbStyle::P_PushButton_additionaltext, this); |
543 d->additionalTextItem = style( )->createPrimitive( HbStyle::P_PushButton_additionaltext, this); |
604 } |
544 } |
605 // check for textitem and api protection flag |
545 // check for textitem and api protection flag |
606 if(alignment != d->additionalTextAlignment ){ |
546 if( alignment != d->additionalTextAlignment ) { |
607 //take the alignment |
547 //take the alignment |
608 d->additionalTextAlignment = alignment; |
548 d->additionalTextAlignment = alignment; |
609 //set the api protection flag |
549 //set the api protection flag |
610 //HbWidgetBasePrivate::d_ptr(additionalTextItem)->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextAlign,true); |
550 //HbWidgetBasePrivate::d_ptr(additionalTextItem)->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextAlign,true); |
611 d->hasAdditionalTextAlignment = true; |
551 d->hasAdditionalTextAlignment = true; |
612 HbStyleOptionPushButton buttonOption; |
552 HbStyleOptionPushButton buttonOption; |
613 initStyleOption( &buttonOption ); |
553 initStyleOption( &buttonOption ); |
614 style()->updatePrimitive( |
554 style( )->updatePrimitive( |
615 d->additionalTextItem, HbStyle::P_PushButton_additionaltext, &buttonOption ); |
555 d->additionalTextItem, HbStyle::P_PushButton_additionaltext, &buttonOption ); |
616 } |
556 } |
617 } |
557 } |
618 |
558 |
619 /*! |
559 /*! |
|
560 @beta |
620 Returns the text alignment for additional text |
561 Returns the text alignment for additional text |
621 \sa setAdditionalTextAlignment() |
562 \sa setAdditionalTextAlignment() |
622 */ |
563 */ |
623 Qt::Alignment HbPushButton::additionalTextAlignment( ) const |
564 Qt::Alignment HbPushButton::additionalTextAlignment( ) const |
624 { |
565 { |
625 Q_D(const HbPushButton); |
566 Q_D(const HbPushButton); |
626 return d->additionalTextAlignment; |
567 return d->additionalTextAlignment; |
627 } |
568 } |
628 |
569 |
629 /*! |
570 /*! |
|
571 @beta |
630 Sets the stretched layout for button by default it set to true. setStretched true/false. |
572 Sets the stretched layout for button by default it set to true. setStretched true/false. |
631 For the case icon and text with value false will appear icon and text vertically aligned. |
573 For the case icon and text with value false will appear icon and text vertically aligned. |
632 and with value true will appear icon and text horizontally aligned. |
574 and with value true will appear icon and text horizontally aligned. |
633 For the case icon , text and additional text with value false will appear like |
575 For the case icon , text and additional text with value false will appear like |
634 both text will be vertically aligned and icon will be horizontally. |
576 both text will be vertically aligned and icon will be horizontally. |
705 delete d->additionalTextItem; |
648 delete d->additionalTextItem; |
706 d->additionalTextItem = 0; |
649 d->additionalTextItem = 0; |
707 delete d->focusItem; |
650 delete d->focusItem; |
708 d->focusItem = 0; |
651 d->focusItem = 0; |
709 |
652 |
710 d->createPrimitives(); |
653 d->createPrimitives( ); |
711 setFrameBackground(0); |
654 setFrameBackground( 0 ); |
712 } |
655 } |
713 /*! |
656 /*! |
714 \reimp |
657 \reimp |
715 */ |
658 */ |
716 void HbPushButton::updatePrimitives() |
659 void HbPushButton::updatePrimitives() |
717 { |
660 { |
718 Q_D(HbPushButton); |
661 Q_D( HbPushButton ); |
719 HbWidget::updatePrimitives(); |
662 HbWidget::updatePrimitives( ); |
720 |
663 |
721 HbStyleOptionPushButton buttonOption; |
664 HbStyleOptionPushButton buttonOption; |
722 initStyleOption(&buttonOption); |
665 initStyleOption(&buttonOption); |
723 if ( d->textItem ) { |
666 if ( d->textItem ) { |
724 style()->updatePrimitive( d->textItem, HbStyle::P_PushButton_text, &buttonOption ); |
667 style()->updatePrimitive( d->textItem, HbStyle::P_PushButton_text, &buttonOption ); |
725 } |
668 } |
726 if ( d->touchArea ) { |
669 if ( d->touchArea ) { |
727 style()->updatePrimitive( d->touchArea, HbStyle::P_PushButton_toucharea, &buttonOption ); |
670 style()->updatePrimitive( d->touchArea, HbStyle::P_PushButton_toucharea, &buttonOption ); |
728 } |
671 } |
729 if( d->additionalTextItem ){ |
672 if( d->additionalTextItem ) { |
730 style()->updatePrimitive( |
673 style()->updatePrimitive( |
731 d->additionalTextItem,HbStyle::P_PushButton_additionaltext,&buttonOption ); |
674 d->additionalTextItem,HbStyle::P_PushButton_additionaltext,&buttonOption ); |
732 } |
675 } |
733 if ( d->iconItem) { |
676 if ( d->iconItem) { |
734 style()->updatePrimitive( d->iconItem, HbStyle::P_PushButton_icon, &buttonOption ); |
677 style()->updatePrimitive( d->iconItem, HbStyle::P_PushButton_icon, &buttonOption ); |
735 } |
678 } |
736 if ( d->frameItem ){ |
679 if ( d->frameItem ) { |
737 style()->updatePrimitive( d->frameItem, HbStyle::P_PushButton_background, &buttonOption ); |
680 style()->updatePrimitive( d->frameItem, HbStyle::P_PushButton_background, &buttonOption ); |
738 } |
681 } |
739 // update will happen only for keyevents when focusItem will be visible. |
682 // update will happen only for keyevents when focusItem will be visible. |
740 if( d->focusItem && hasFocus() && d->focusItem->isVisible() ) { |
683 if( d->focusItem && hasFocus() && d->focusItem->isVisible() ) { |
741 style()->updatePrimitive( d->focusItem,HbStyle::P_PushButton_focus, &buttonOption ); |
684 style()->updatePrimitive( d->focusItem,HbStyle::P_PushButton_focus, &buttonOption ); |
769 option->isCheckable = d->checkable; |
712 option->isCheckable = d->checkable; |
770 option->textAlignment = d->textAlignment; |
713 option->textAlignment = d->textAlignment; |
771 option->additionalTextAlignment = d->additionalTextAlignment; |
714 option->additionalTextAlignment = d->additionalTextAlignment; |
772 option->hasTextAlignment = d->hasTextAlignment; |
715 option->hasTextAlignment = d->hasTextAlignment; |
773 option->hasAdditionalTextAlignment = d->hasAdditionalTextAlignment; |
716 option->hasAdditionalTextAlignment = d->hasAdditionalTextAlignment; |
774 if(option->backgroundFrameDrawer) { |
717 if( option->backgroundFrameDrawer ) { |
775 HbFrameDrawerPool::release(option->backgroundFrameDrawer); |
718 HbFrameDrawerPool::release( option->backgroundFrameDrawer ); |
776 option->backgroundFrameDrawer = 0; |
719 option->backgroundFrameDrawer = 0; |
777 } |
720 } |
778 option->backgroundFrameDrawer=( d->backgroundFrameDrawer ); |
721 option->backgroundFrameDrawer = ( d->backgroundFrameDrawer ); |
779 } |
722 } |
780 |
723 |
781 /*! |
724 /*! |
782 \reimp |
725 \reimp |
783 */ |
726 */ |
784 void HbPushButton::keyPressEvent(QKeyEvent *event) |
727 void HbPushButton::keyPressEvent(QKeyEvent *event) |
785 { |
728 { |
786 Q_D(HbPushButton); |
729 Q_D( HbPushButton ); |
787 |
730 |
788 switch (event->key()) { |
731 switch ( event->key() ) { |
789 case Qt::Key_Select: |
732 case Qt::Key_Select: |
790 case Qt::Key_Enter: |
733 case Qt::Key_Enter: |
791 case Qt::Key_Return:{ |
734 case Qt::Key_Return:{ |
792 if (!event->isAutoRepeat() && !d->autoRepeat && !d->longPressTimer) { |
735 if (!event->isAutoRepeat( ) && !d->autoRepeat && !d->longPressTimer) { |
793 d->longPressTimer = new QTimer(); |
736 d->longPressTimer = new QTimer(); |
794 d->longPressTimer->setInterval(300); |
737 d->longPressTimer->setInterval(300); |
795 connect( d->longPressTimer, SIGNAL(timeout()), this, SLOT(_q_handleLongKeyPress()) ); |
738 connect( d->longPressTimer, SIGNAL( timeout() ), this, SLOT(_q_handleLongKeyPress()) ); |
796 d->longPressTimer->start(); |
739 d->longPressTimer->start(); |
797 }else{ |
740 }else { |
798 #ifdef HB_EFFECTS |
741 #ifdef HB_EFFECTS |
799 HbEffect::start( this, HB_PUSHBUTTON_TYPE, "pressed" ); |
742 HbEffect::start( this, HB_PUSHBUTTON_TYPE, "pressed" ); |
800 #endif |
743 #endif |
801 } |
744 } |
802 } |
745 } |
848 \reimp |
791 \reimp |
849 */ |
792 */ |
850 void HbPushButton::mousePressEvent( QGraphicsSceneMouseEvent *event ) |
793 void HbPushButton::mousePressEvent( QGraphicsSceneMouseEvent *event ) |
851 { |
794 { |
852 #ifndef HB_GESTURE_FW |
795 #ifndef HB_GESTURE_FW |
853 Q_D(HbPushButton); |
796 Q_D( HbPushButton ); |
854 HbAbstractButton::mousePressEvent(event); |
797 HbAbstractButton::mousePressEvent( event ); |
855 HbStyleOptionPushButton buttonOption; |
798 HbStyleOptionPushButton buttonOption; |
856 initStyleOption( &buttonOption ); |
799 initStyleOption( &buttonOption ); |
857 if( d->frameItem ){ |
800 if( d->frameItem ) { |
858 style()->updatePrimitive( d->frameItem, HbStyle::P_PushButton_background, &buttonOption ); |
801 style()->updatePrimitive( d->frameItem, HbStyle::P_PushButton_background, &buttonOption ); |
859 } |
802 } |
860 #ifdef HB_EFFECTS |
803 #ifdef HB_EFFECTS |
861 if ( hitButton(event->pos()) ){ |
804 if ( hitButton(event->pos()) ) { |
862 HbEffect::start( this, HB_PUSHBUTTON_TYPE, "pressed" ); |
805 HbEffect::start( this, HB_PUSHBUTTON_TYPE, "pressed" ); |
863 } |
806 } |
864 #endif |
807 #endif |
865 setProperty("state", "pressed"); |
808 setProperty( "state", "pressed" ); |
866 #else |
809 #else |
867 Q_UNUSED(event) |
810 Q_UNUSED( event ) |
868 #endif |
811 #endif |
869 } |
812 } |
870 |
813 |
871 #ifndef HB_GESTURE_FW |
814 #ifndef HB_GESTURE_FW |
872 /*! |
815 /*! |
873 \reimp |
816 \reimp |
874 */ |
817 */ |
875 void HbPushButton::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) |
818 void HbPushButton::mouseReleaseEvent( QGraphicsSceneMouseEvent *event ) |
876 { |
819 { |
877 Q_D(HbPushButton); |
820 Q_D( HbPushButton ); |
878 HbAbstractButton::mouseReleaseEvent(event); |
821 HbAbstractButton::mouseReleaseEvent( event ); |
879 HbStyleOptionPushButton buttonOption; |
822 HbStyleOptionPushButton buttonOption; |
880 initStyleOption( &buttonOption ); |
823 initStyleOption( &buttonOption ); |
881 if( d->frameItem ){ |
824 if( d->frameItem ) { |
882 style()->updatePrimitive( d->frameItem, HbStyle::P_PushButton_background, &buttonOption ); |
825 style()->updatePrimitive( d->frameItem, HbStyle::P_PushButton_background, &buttonOption ); |
883 } |
826 } |
884 #ifdef HB_EFFECTS |
827 #ifdef HB_EFFECTS |
885 if ( hitButton(event->pos()) ){ |
828 if ( hitButton(event->pos()) ) { |
886 HbEffect::start( this, HB_PUSHBUTTON_TYPE, "released" ); |
829 HbEffect::start( this, HB_PUSHBUTTON_TYPE, "released" ); |
887 } |
830 } |
888 #endif |
831 #endif |
889 setProperty("state", "normal"); |
832 setProperty( "state", "normal" ); |
890 } |
833 } |
891 |
834 |
892 /*! |
835 /*! |
893 \reimp |
836 \reimp |
894 */ |
837 */ |
895 void HbPushButton::mouseMoveEvent(QGraphicsSceneMouseEvent *event) |
838 void HbPushButton::mouseMoveEvent( QGraphicsSceneMouseEvent *event ) |
896 { |
839 { |
897 Q_D(HbPushButton); |
840 Q_D( HbPushButton ); |
898 HbAbstractButton::mouseMoveEvent(event); |
841 HbAbstractButton::mouseMoveEvent( event ); |
899 HbStyleOptionPushButton buttonOption; |
842 HbStyleOptionPushButton buttonOption; |
900 initStyleOption( &buttonOption ); |
843 initStyleOption( &buttonOption ); |
901 if( d->frameItem ){ |
844 if( d->frameItem ) { |
902 style()->updatePrimitive( d->frameItem, HbStyle::P_PushButton_background, &buttonOption ); |
845 style()->updatePrimitive( d->frameItem, HbStyle::P_PushButton_background, &buttonOption ); |
903 } |
846 } |
904 if (d->down) { |
847 if (d->down) { |
905 setProperty("state", "pressed"); |
848 setProperty( "state", "pressed" ); |
906 } else { |
849 } else { |
907 setProperty("state", "normal"); |
850 setProperty( "state", "normal" ); |
908 } |
851 } |
909 } |
852 } |
910 #endif |
853 #endif |
911 |
854 |
912 |
855 |
913 #ifdef HB_GESTURE_FW |
856 #ifdef HB_GESTURE_FW |
914 void HbPushButton::gestureEvent(QGestureEvent *event) |
857 void HbPushButton::gestureEvent( QGestureEvent *event ) |
915 { |
858 { |
916 Q_D(HbPushButton); |
859 Q_D(HbPushButton); |
917 if(HbTapGesture *tap = qobject_cast<HbTapGesture *>(event->gesture(Qt::TapGesture))) { |
860 if(HbTapGesture *tap = qobject_cast<HbTapGesture *>(event->gesture(Qt::TapGesture))) { |
918 switch(tap->state()) { |
861 switch(tap->state()) { |
919 case Qt::GestureStarted:{ |
862 case Qt::GestureStarted:{ |
920 #ifdef HB_EFFECTS |
863 #ifdef HB_EFFECTS |
921 HbEffect::start( this, HB_PUSHBUTTON_TYPE, "pressed" ); |
864 HbEffect::start( this, HB_PUSHBUTTON_TYPE, "pressed" ); |
922 #endif |
865 #endif |
923 if(d->checkable && !d->checked){ |
866 if( d->checkable && !d->checked) { |
924 setProperty("state", "latched"); |
867 setProperty( "state", "latched" ); |
925 }else if(!d->checkable){ |
868 }else if(!d->checkable) { |
926 setProperty("state", "pressed"); |
869 setProperty( "state", "pressed" ); |
927 } |
870 } |
928 } |
871 } |
929 break; |
872 break; |
930 case Qt::GestureUpdated: |
873 case Qt::GestureUpdated: |
931 if(tap->tapStyleHint() == HbTapGesture::TapAndHold) { |
874 if(tap->tapStyleHint() == HbTapGesture::TapAndHold) { |
932 d->longPress = true; |
875 d->longPress = true; |
933 emit longPress(event->mapToGraphicsScene(tap->position())); |
876 emit longPress( event->mapToGraphicsScene(tap->position()) ); |
934 } |
877 } |
935 break; |
878 break; |
936 case Qt::GestureCanceled: |
879 case Qt::GestureCanceled: |
937 setProperty("state", "normal"); |
880 setProperty( "state", "normal" ); |
938 break; |
881 break; |
939 case Qt::GestureFinished:{ |
882 case Qt::GestureFinished:{ |
940 #ifdef HB_EFFECTS |
883 #ifdef HB_EFFECTS |
941 HbEffect::start( this, HB_PUSHBUTTON_TYPE, "released" ); |
884 HbEffect::start( this, HB_PUSHBUTTON_TYPE, "released" ); |
942 #endif |
885 #endif |
943 if( d->checkable && !d->checked){ |
886 if( d->checkable && !d->checked) { |
944 setProperty("state", "latched"); |
887 setProperty( "state", "latched" ); |
945 }else { |
888 }else { |
946 setProperty("state", "normal"); |
889 setProperty( "state", "normal" ); |
947 } |
890 } |
948 |
891 |
949 } |
892 } |
950 break; |
893 break; |
951 default: |
894 default: |
952 break; |
895 break; |
953 } |
896 } |
954 } |
897 } |
955 |
898 |
956 HbAbstractButton::gestureEvent(event); |
899 HbAbstractButton::gestureEvent( event ); |
957 |
900 |
958 } |
901 } |
959 #endif |
902 #endif |
960 |
903 |
961 |
904 |
962 /*! |
905 /*! |
963 \reimp |
906 \reimp |
964 */ |
907 */ |
965 void HbPushButton::resizeEvent(QGraphicsSceneResizeEvent *event) |
908 void HbPushButton::resizeEvent( QGraphicsSceneResizeEvent *event ) |
966 { |
909 { |
967 HbAbstractButton::resizeEvent(event); |
910 HbAbstractButton::resizeEvent( event ); |
968 } |
911 } |
969 /*! |
912 /*! |
970 reimp |
913 reimp |
971 |
914 |
972 */ |
915 */ |
973 void HbPushButton::polish( HbStyleParameters& params ) |
916 void HbPushButton::polish( HbStyleParameters ¶ms ) |
974 { |
917 { |
975 Q_D( HbPushButton ); |
918 Q_D( HbPushButton ); |
976 if(d->stretched && (d->textItem && d->additionalTextItem && !d->iconItem)){ |
919 if( d->stretched && ( d->textItem && d->additionalTextItem && !d->iconItem ) ) { |
977 d->stretched = false; |
920 d->stretched = false; |
978 qWarning()<<"Warning::Invalid Layout: Text and additonalText horizontal appearance not supported"; |
921 qWarning() << "Warning::Invalid Layout: Text and additonalText horizontal appearance not supported"; |
979 } |
922 } |
980 HbAbstractButton::polish( params ); |
923 HbAbstractButton::polish( params ); |
981 } |
924 } |
982 |
925 |
983 |
926 |
984 /*! |
927 /*! |
985 \reimp |
928 \reimp |
986 */ |
929 */ |
987 void HbPushButton::focusInEvent(QFocusEvent *event) |
930 void HbPushButton::focusInEvent( QFocusEvent *event ) |
988 { |
931 { |
989 Q_D(HbPushButton); |
932 Q_D( HbPushButton ); |
990 if((event->reason() == Qt::TabFocusReason || event->reason() == Qt::BacktabFocusReason) |
933 if( ( event->reason() == Qt::TabFocusReason || event->reason() == Qt::BacktabFocusReason ) |
991 && ( d->navigationKeyPress ) ) { |
934 && ( d->navigationKeyPress ) ) { |
992 if(d->focusItem) { |
935 if( d->focusItem ) { |
993 d->focusItem->setVisible(true); |
936 d->focusItem->setVisible( true ); |
994 if( hasFocus()){ |
937 if( hasFocus() ) { |
995 HbStyleOptionPushButton buttonOption; |
938 HbStyleOptionPushButton buttonOption; |
996 initStyleOption( &buttonOption ); |
939 initStyleOption( &buttonOption ); |
997 style()->updatePrimitive( d->focusItem,HbStyle::P_PushButton_focus, &buttonOption ); |
940 style()->updatePrimitive( d->focusItem,HbStyle::P_PushButton_focus, &buttonOption ); |
998 } |
941 } |
999 } else { |
942 } else { |
1000 d->focusItem = style()->createPrimitive(HbStyle::P_PushButton_focus, this); |
943 d->focusItem = style()->createPrimitive(HbStyle::P_PushButton_focus, this); |
1001 } |
944 } |
1002 } |
945 } |
1003 HbAbstractButton::focusInEvent(event); |
946 HbAbstractButton::focusInEvent( event ); |
1004 } |
947 } |
1005 |
948 |
1006 /*! |
949 /*! |
1007 \reimp |
950 \reimp |
1008 */ |
951 */ |
1009 void HbPushButton::focusOutEvent(QFocusEvent *event) |
952 void HbPushButton::focusOutEvent( QFocusEvent *event ) |
1010 { |
953 { |
1011 Q_D(HbPushButton); |
954 Q_D( HbPushButton ); |
1012 if(d->focusItem) { |
955 if( d->focusItem ) { |
1013 d->focusItem->setVisible(false); |
956 d->focusItem->setVisible( false ); |
1014 } |
957 } |
1015 HbAbstractButton::focusOutEvent(event); |
958 HbAbstractButton::focusOutEvent( event ); |
1016 } |
959 } |
1017 |
960 |
1018 /*! |
961 /*! |
1019 \reimp |
962 \reimp |
1020 */ |
963 */ |