src/hbcore/gui/hbwidget.cpp
changeset 21 4633027730f5
parent 7 923ff622b8b9
child 23 e6ad4ef83b23
equal deleted inserted replaced
7:923ff622b8b9 21:4633027730f5
    33 #include "hbgraphicsscene.h"
    33 #include "hbgraphicsscene.h"
    34 #include "hbgraphicsscene_p.h"
    34 #include "hbgraphicsscene_p.h"
    35 #include "hbdeviceprofile.h"
    35 #include "hbdeviceprofile.h"
    36 #include "hbtapgesture.h"
    36 #include "hbtapgesture.h"
    37 #include "hbnamespace_p.h"
    37 #include "hbnamespace_p.h"
       
    38 #include "hbstyle_p.h"
    38 #include <QCoreApplication>
    39 #include <QCoreApplication>
    39 #include <QMetaType>
    40 #include <QMetaType>
    40 #include <QAction>
    41 #include <QAction>
    41 #include <QDebug>
    42 #include <QDebug>
    42 #include <QDynamicPropertyChangeEvent>
    43 #include <QDynamicPropertyChangeEvent>
    43 #include <QGraphicsLayout>
    44 #include <QGraphicsLayout>
    44 #include <QInputContext>
    45 #include <QInputContext>
    45 
    46 
    46 #ifdef HB_TESTABILITY
       
    47 /*!
    47 /*!
    48     \internal
    48     \internal
    49  */
    49  */
    50 static void testabilitySignalEnabledChange(bool enabled, void *param)
    50 static void testabilitySignalEnabledChange(bool enabled, void *param)
    51 {
    51 {
    56         // However this should only be done when the testability signal gets
    56         // However this should only be done when the testability signal gets
    57         // enabled because it causes perf regression.
    57         // enabled because it causes perf regression.
    58         widget->setFlag(QGraphicsItem::ItemSendsGeometryChanges, enabled);
    58         widget->setFlag(QGraphicsItem::ItemSendsGeometryChanges, enabled);
    59     }
    59     }
    60 }
    60 }
    61 #endif //HB_TESTABILITY
       
    62 
    61 
    63 HbWidgetPrivate::HbWidgetPrivate()
    62 HbWidgetPrivate::HbWidgetPrivate()
    64   : HbWidgetBasePrivate(),
    63   : HbWidgetBasePrivate(),
    65     style(0),
    64     style(0),
    66     backgroundPrimitiveType(HbStyle::P_None),
    65     backgroundPrimitiveType(HbStylePrivate::P_None),
    67     polished(false),
       
    68     polishPending(false),
    66     polishPending(false),
    69     themingPending(true),
    67     themingPending(true),
    70     repolishOutstanding(false),
    68     repolishOutstanding(false),
    71     mHandlingRepolishSynchronously(false),
    69     mHandlingRepolishSynchronously(false),
    72     notifyScene(false),
    70     notifyScene(false),
    73     focusGroup(0),
    71     focusGroup(0),
    74     focusActiveType(HbStyle::P_None),
    72     focusActiveType(HbStylePrivate::P_None),
    75     focusResidualType(HbStyle::P_None),
    73     focusResidualType(HbStylePrivate::P_None),
    76     highlightExpired(false),
    74     highlightExpired(false),
    77     backgroundItem(0),
    75     backgroundItem(0),
    78     focusActiveItem(0),
    76     focusActiveItem(0),
    79     focusResidualItem(0)
    77     focusResidualItem(0)
    80 {
    78 {
    81     q_ptr = 0;
    79     q_ptr = 0;
    82 #ifdef HB_TESTABILITY 
       
    83 	testabilitySignal = new HbTestabilitySignal_p();
    80 	testabilitySignal = new HbTestabilitySignal_p();
    84 #endif //HB_TESTABILITY 
    81 }
       
    82 
       
    83 void HbWidgetPrivate::init()
       
    84 {
       
    85     Q_Q(HbWidget);
       
    86     q->setAttribute(Hb::Widget, true);
       
    87 
       
    88     if (testabilitySignal) {
       
    89         testabilitySignal->setParent(q);
       
    90         testabilitySignal->notifySignalEnabled(testabilitySignalEnabledChange, q);
       
    91     }
    85 }
    92 }
    86 
    93 
    87 HbWidgetPrivate::~HbWidgetPrivate()
    94 HbWidgetPrivate::~HbWidgetPrivate()
    88 {
    95 {
    89     if (backgroundItem) {
    96     if (backgroundItem) {
    90         delete backgroundItem;
    97         delete backgroundItem;
    91         backgroundItem = 0;
    98         backgroundItem = 0;
    92     }
    99     }
    93 }
   100 }
    94 
   101 
    95 void HbWidgetPrivate::setBackgroundItem(HbStyle::Primitive type, int zValue)
   102 void HbWidgetPrivate::setBackgroundItem(HbStylePrivate::Primitive type, int zValue)
    96 {
   103 {
    97     Q_Q(HbWidget);
   104     Q_Q(HbWidget);
    98     if(type!=backgroundPrimitiveType || type == HbStyle::P_None) {
   105     if(type!=backgroundPrimitiveType || type == HbStylePrivate::P_None) {
    99         if (backgroundItem) {
   106         if (backgroundItem) {
   100             delete backgroundItem;
   107             delete backgroundItem;
   101             backgroundItem = 0;
   108             backgroundItem = 0;
   102         }
   109         }
   103         backgroundPrimitiveType = type;
   110         backgroundPrimitiveType = type;
   104         backgroundItem = q->style()->createPrimitive(backgroundPrimitiveType, const_cast<HbWidget*>(q));
   111         backgroundItem = HbStylePrivate::createPrimitive(backgroundPrimitiveType, const_cast<HbWidget*>(q));
   105         if(backgroundItem) {
   112         if(backgroundItem) {
   106             backgroundItem->setParentItem(q);
   113             backgroundItem->setParentItem(q);
   107         }
   114         }
   108     q->updatePrimitives();
   115     q->updatePrimitives();
   109 }
   116 }
   134     Q_D(HbWidget);
   141     Q_D(HbWidget);
   135     if(d->backgroundItem) {
   142     if(d->backgroundItem) {
   136         delete d->backgroundItem;
   143         delete d->backgroundItem;
   137         d->backgroundItem = 0;
   144         d->backgroundItem = 0;
   138     }
   145     }
   139     d->backgroundPrimitiveType = HbStyle::P_None;
   146     d->backgroundPrimitiveType = HbStylePrivate::P_None;
   140     d->backgroundItem = item;
   147     d->backgroundItem = item;
   141     if(d->backgroundItem) {
   148     if(d->backgroundItem) {
   142         d->backgroundItem->setParentItem(this);
   149         d->backgroundItem->setParentItem(this);
   143         d->backgroundItem->setZValue(zValue);
   150         d->backgroundItem->setZValue(zValue);
   144         d->updateBackgroundItemSize();
   151         d->updateBackgroundItemSize();
   163 QGraphicsItem *HbWidgetPrivate::focusPrimitive(HbWidget::FocusHighlight highlightType) const
   170 QGraphicsItem *HbWidgetPrivate::focusPrimitive(HbWidget::FocusHighlight highlightType) const
   164 {
   171 {
   165     Q_Q(const HbWidget);
   172     Q_Q(const HbWidget);
   166 
   173 
   167     if (highlightType == HbWidget::FocusHighlightActive) {
   174     if (highlightType == HbWidget::FocusHighlightActive) {
   168         if (!focusActiveItem && focusActiveType != HbStyle::P_None) {
   175         if (!focusActiveItem && focusActiveType != HbStylePrivate::P_None) {
   169             focusActiveItem = q->style()->createPrimitive(
   176             focusActiveItem = HbStylePrivate::createPrimitive(
   170                                 focusActiveType, const_cast<HbWidget*>(q));
   177                                 focusActiveType, const_cast<HbWidget*>(q));
   171             focusActiveItem->hide();
   178             focusActiveItem->hide();
   172         }
   179         }
   173         return focusActiveItem;
   180         return focusActiveItem;
   174     } else if (highlightType == HbWidget::FocusHighlightResidual) {
   181     } else if (highlightType == HbWidget::FocusHighlightResidual) {
   175         if (!focusResidualItem && focusResidualType != HbStyle::P_None) {
   182         if (!focusResidualItem && focusResidualType != HbStylePrivate::P_None) {
   176             focusResidualItem = q->style()->createPrimitive(
   183             focusResidualItem = HbStylePrivate::createPrimitive(
   177                                 focusResidualType, const_cast<HbWidget*>(q));
   184                                 focusResidualType, const_cast<HbWidget*>(q));
   178             focusResidualItem->hide();
   185             focusResidualItem->hide();
   179         }
   186         }
   180         return focusResidualItem;
   187         return focusResidualItem;
   181     }
   188     }
   400 HbWidget::HbWidget( QGraphicsItem *parent, Qt::WindowFlags wFlags ):
   407 HbWidget::HbWidget( QGraphicsItem *parent, Qt::WindowFlags wFlags ):
   401     HbWidgetBase( *new HbWidgetPrivate, parent, wFlags )
   408     HbWidgetBase( *new HbWidgetPrivate, parent, wFlags )
   402 {
   409 {
   403     Q_D( HbWidget );
   410     Q_D( HbWidget );
   404     d->q_ptr = this;
   411     d->q_ptr = this;
   405     setAttribute(Hb::Widget, true);
   412     d->init();
   406 
       
   407 #ifdef HB_TESTABILITY 
       
   408 	if(d->testabilitySignal) {
       
   409 		d->testabilitySignal->setParent(this);
       
   410 		d->testabilitySignal->notifySignalEnabled(testabilitySignalEnabledChange, this);
       
   411 	}
       
   412 #endif //HB_TESTABILITY
       
   413 }
   413 }
   414 
   414 
   415 /*!
   415 /*!
   416     Constructs a widget with the given private object, parent item and window flags.
   416     Constructs a widget with the given private object, parent item and window flags.
   417     The given HbWidgetPrivate instance is installed in the widget and deleted in its destructor.
   417     The given HbWidgetPrivate instance is installed in the widget and deleted in its destructor.
   419 HbWidget::HbWidget(HbWidgetPrivate &dd, QGraphicsItem *parent, Qt::WindowFlags wFlags):
   419 HbWidget::HbWidget(HbWidgetPrivate &dd, QGraphicsItem *parent, Qt::WindowFlags wFlags):
   420     HbWidgetBase( dd, parent, wFlags )
   420     HbWidgetBase( dd, parent, wFlags )
   421 {
   421 {
   422     Q_D( HbWidget );
   422     Q_D( HbWidget );
   423     d->q_ptr = this;
   423     d->q_ptr = this;
   424     setAttribute(Hb::Widget, true);
   424     d->init();
   425 
       
   426 #ifdef HB_TESTABILITY 
       
   427 	if (d->testabilitySignal) {
       
   428 		d->testabilitySignal->setParent(this);
       
   429 		d->testabilitySignal->notifySignalEnabled(testabilitySignalEnabledChange, this);
       
   430 	}
       
   431 #endif //HB_TESTABILITY
       
   432 }
   425 }
   433 
   426 
   434 /*!
   427 /*!
   435  Destroys the widget.
   428  Destroys the widget.
   436 */
   429 */
   592     and recreate primitives.
   585     and recreate primitives.
   593 */
   586 */
   594 void HbWidget::recreatePrimitives()
   587 void HbWidget::recreatePrimitives()
   595 {
   588 {
   596     Q_D(HbWidget);
   589     Q_D(HbWidget);
   597     if(d->backgroundPrimitiveType != HbStyle::P_None) {
   590     if(d->backgroundPrimitiveType != HbStylePrivate::P_None) {
   598         if(d->backgroundItem) {
   591         if(d->backgroundItem) {
   599             delete d->backgroundItem;
   592             delete d->backgroundItem;
   600             d->backgroundItem = 0;
   593             d->backgroundItem = 0;
   601         }
   594         }
   602         d->backgroundItem = style()->createPrimitive(d->backgroundPrimitiveType, const_cast<HbWidget*>(this));
   595         d->backgroundItem = HbStylePrivate::createPrimitive(d->backgroundPrimitiveType, const_cast<HbWidget*>(this));
   603     }
   596     }
   604 }
   597 }
   605 
   598 
   606 /*!
   599 /*!
   607     A virtual slot to be called on the derived classes to notify in cases when the style
   600     A virtual slot to be called on the derived classes to notify in cases when the style
   614 
   607 
   615     HbStyleOption option;
   608     HbStyleOption option;
   616     initStyleOption(&option);
   609     initStyleOption(&option);
   617 
   610 
   618     if (backgroundItem()) {
   611     if (backgroundItem()) {
   619         if(d->backgroundPrimitiveType != HbStyle::P_None) {
   612         if(d->backgroundPrimitiveType != HbStylePrivate::P_None) {
   620             style()->updatePrimitive(backgroundItem(), d->backgroundPrimitiveType, &option);
   613             HbStylePrivate::updatePrimitive(backgroundItem(), d->backgroundPrimitiveType, &option);
   621         }
   614         }
   622         d->updateBackgroundItemSize();
   615         d->updateBackgroundItemSize();
   623     }
   616     }
   624     if (d->focusPrimitive(HbWidget::FocusHighlightResidual)) {
   617     if (d->focusPrimitive(HbWidget::FocusHighlightResidual)) {
   625         style()->updatePrimitive(d->focusPrimitive(HbWidget::FocusHighlightResidual),
   618         HbStylePrivate::updatePrimitive(d->focusPrimitive(HbWidget::FocusHighlightResidual),
   626             d->focusResidualType, &option);        
   619             d->focusResidualType, &option);        
   627     }
   620     }
   628 
   621 
   629     if (d->focusPrimitive(HbWidget::FocusHighlightActive)) {
   622     if (d->focusPrimitive(HbWidget::FocusHighlightActive)) {
   630         style()->updatePrimitive(d->focusPrimitive(HbWidget::FocusHighlightActive),
   623         HbStylePrivate::updatePrimitive(d->focusPrimitive(HbWidget::FocusHighlightActive),
   631             d->focusActiveType, &option);
   624             d->focusActiveType, &option);
   632     }
   625     }
   633    
   626    
   634 }
   627 }
   635 
   628 
   752  */
   745  */
   753 QVariant HbWidget::itemChange ( GraphicsItemChange change, const QVariant & value )
   746 QVariant HbWidget::itemChange ( GraphicsItemChange change, const QVariant & value )
   754 {
   747 {
   755     Q_D(HbWidget);
   748     Q_D(HbWidget);
   756 
   749 
   757 #ifdef HB_TESTABILITY
       
   758     if (d->testabilitySignal && d->testabilitySignal->signalEnabled()) {
   750     if (d->testabilitySignal && d->testabilitySignal->signalEnabled()) {
   759     	emit d->testabilitySignal->propertyChanges(change, value);
   751     	emit d->testabilitySignal->propertyChanges(change, value);
   760     }
   752     }
   761 #endif //HB_TESTABILITY
       
   762 
   753 
   763 	if (change == QGraphicsItem::ItemVisibleHasChanged) {
   754 	if (change == QGraphicsItem::ItemVisibleHasChanged) {
   764         if (!d->polished && !value.toBool()) {
   755         if (!d->polished && !value.toBool()) {
   765 
   756 
   766             // temporary solution starts -->>
   757             // temporary solution starts -->>
   777 
   768 
   778             // Don't call baseclass imp to prevent hideEvent()
   769             // Don't call baseclass imp to prevent hideEvent()
   779             // to be sent when the widget is not polished yet.
   770             // to be sent when the widget is not polished yet.
   780             return value;
   771             return value;
   781         }
   772         }
   782         if (d->polishPending && value.toBool()) {
   773         if (value.toBool()) {
   783             d->polishPending = false;
   774             bool notifyGraphicsScene = d->polishPending;
   784             HbStyleParameters params;
   775             if(d->polishPending) {
   785             polish( params );
   776                 d->polishPending = false;
   786             if (scene()) {
   777                 HbStyleParameters params;
   787              // The widget is polished again or is beign polished now. As we set layout to widget in polishEvent,
   778                 polish( params );
   788              // inform scene to polish any new child items and handle any resulting layoutrequest
   779             }
   789              // events before drawing.
   780             //There could be situations where widget is becoming visible and has
       
   781             //polish request pending in event queue.This make's sure we
       
   782             //handle any pending repolish requests of widget before its drawn.
       
   783             if ((notifyGraphicsScene || (d->repolishOutstanding && !d->mHandlingRepolishSynchronously))
       
   784                  &&  scene()) {
       
   785                 //Widget is polished again or is being polished now.
       
   786                 //As we set layout to widget in polishEvent,inform scene to polish any new
       
   787                 //child items and handle any resulting layoutrequest events before drawing.
   790                 HbGraphicsScene *hbscene = qobject_cast<HbGraphicsScene*>(scene());
   788                 HbGraphicsScene *hbscene = qobject_cast<HbGraphicsScene*>(scene());
   791                 if (hbscene) {
   789                 if (hbscene) {
   792                     HbGraphicsScenePrivate::d_ptr(hbscene)->mPolishWidgets = true;
   790                     if (d->repolishOutstanding)
       
   791                         HbGraphicsScenePrivate::d_ptr(hbscene)->mRepolishWidgets = true;
       
   792                     else
       
   793                         HbGraphicsScenePrivate::d_ptr(hbscene)->mPolishWidgets = true;
   793                 }
   794                 }
   794             }
   795             }
   795         }
   796         }
   796     }
   797     }
   797     else if (change == QGraphicsItem::ItemChildAddedChange) {
   798     else if (change == QGraphicsItem::ItemChildAddedChange) {
   815     }
   816     }
   816     else if (change == QGraphicsItem::ItemSceneHasChanged) {
   817     else if (change == QGraphicsItem::ItemSceneHasChanged) {
   817         if (d->focusGroup) {
   818         if (d->focusGroup) {
   818             d->focusGroup->registerChildren(this);
   819             d->focusGroup->registerChildren(this);
   819         }
   820         }
   820         if (d->notifyScene && scene()) {
   821         if (d->notifyScene) {
   821             // The widget has been added to a new scene and this would result in
   822             // The widget has been added to a new scene and this would result in
   822             // polishing widget. As we set layout to widget in polishEvent,
   823             // polishing widget. As we set layout to widget in polishEvent,
   823             // inform scene to handle polish and any resulting layoutrequest
   824             // inform scene to handle polish and any resulting layoutrequest
   824             // events before drawing.
   825             // events before drawing.
   825             d->notifyScene = false;
   826             d->notifyScene = false;
   826             HbGraphicsScene *hbscene = qobject_cast<HbGraphicsScene*>(scene());
   827             if (scene() && isVisible()) {
   827             if (hbscene) {
   828                 HbGraphicsScene *hbscene = qobject_cast<HbGraphicsScene*>(scene());
   828                 HbGraphicsScenePrivate::d_ptr(hbscene)->mPolishWidgets = true;
   829                 if (hbscene) {
       
   830                     HbGraphicsScenePrivate::d_ptr(hbscene)->mPolishWidgets = true;
       
   831                 }
   829             }
   832             }
   830         }
   833         }
   831     }
   834     }
   832     else if( change == QGraphicsItem::ItemEnabledHasChanged) {
   835     else if( change == QGraphicsItem::ItemEnabledHasChanged) {
   833          if(!d->themingPending){
   836          if(!d->themingPending){
   871 void HbWidget::polish( HbStyleParameters& params )
   874 void HbWidget::polish( HbStyleParameters& params )
   872 {
   875 {
   873     Q_D(HbWidget);
   876     Q_D(HbWidget);
   874     if (isVisible()) {
   877     if (isVisible()) {
   875         style()->polish(this, params);
   878         style()->polish(this, params);
   876         d->polished = true;
   879         d->polished = 1;
   877         d->repolishOutstanding = false;
   880         d->repolishOutstanding = false;
   878         if (d->themingPending) {
   881         if (d->themingPending) {
   879             style()->updateThemedParams(this);
   882             style()->updateThemedParams(this);
   880             d->themingPending = false;
   883             d->themingPending = false;
   881         }
   884         }
   904         d->repolishOutstanding = true;
   907         d->repolishOutstanding = true;
   905         QEvent* polishEvent = new QEvent( QEvent::Polish );
   908         QEvent* polishEvent = new QEvent( QEvent::Polish );
   906         QCoreApplication::postEvent(this, polishEvent);
   909         QCoreApplication::postEvent(this, polishEvent);
   907         // If no one is handling repolish synchronously, lets make sure they are handled
   910         // If no one is handling repolish synchronously, lets make sure they are handled
   908         // before painting. For example view items handle them synchronously.
   911         // before painting. For example view items handle them synchronously.
   909         if (scene() && !d->mHandlingRepolishSynchronously) {
   912         if (scene() && isVisible() && !d->mHandlingRepolishSynchronously) {
   910             // The widget needs to be polished again. As we set layout to widget in polishEvent,
   913             // The widget needs to be polished again. As we set layout to widget in polishEvent,
   911             // inform scene to handle polish and any resulting layoutrequest
   914             // inform scene to handle polish and any resulting layoutrequest
   912             // events before drawing.
   915             // events before drawing.
   913             HbGraphicsScene *hbscene = qobject_cast<HbGraphicsScene*>(scene());
   916             HbGraphicsScene *hbscene = qobject_cast<HbGraphicsScene*>(scene());
   914             if (hbscene) {
   917             if (hbscene) {
   924         is deprecated. Use HbWidget::primitive(const QString) instead.
   927         is deprecated. Use HbWidget::primitive(const QString) instead.
   925 */
   928 */
   926 QGraphicsItem *HbWidget::primitive(HbStyle::Primitive primitive) const
   929 QGraphicsItem *HbWidget::primitive(HbStyle::Primitive primitive) const
   927 {
   930 {
   928     Q_D(const HbWidget);
   931     Q_D(const HbWidget);
   929     if (primitive == d->backgroundPrimitiveType) {
   932     const HbStylePrivate::Primitive p = (HbStylePrivate::Primitive)primitive;
       
   933     if (p == d->backgroundPrimitiveType) {
   930         return backgroundItem();
   934         return backgroundItem();
   931     }
   935     }
   932     if (primitive == d->focusActiveType) {
   936     if (p == d->focusActiveType) {
   933         return d->focusPrimitive(HbWidget::FocusHighlightActive);
   937         return d->focusPrimitive(HbWidget::FocusHighlightActive);
   934     }
   938     }
   935     if (primitive == d->focusResidualType) {
   939     if (p == d->focusResidualType) {
   936         return d->focusPrimitive(HbWidget::FocusHighlightResidual);
   940         return d->focusPrimitive(HbWidget::FocusHighlightResidual);
   937     }
   941     }
   938 
   942 
   939     return 0;
   943     return 0;
   940 }
   944 }
  1264 */
  1268 */
  1265 void HbWidget::setFocusHighlight(HbStyle::Primitive type, HbWidget::FocusHighlight focusHighlight)
  1269 void HbWidget::setFocusHighlight(HbStyle::Primitive type, HbWidget::FocusHighlight focusHighlight)
  1266 {
  1270 {
  1267     Q_D(HbWidget);
  1271     Q_D(HbWidget);
  1268     if (focusHighlight == HbWidget::FocusHighlightNone) {
  1272     if (focusHighlight == HbWidget::FocusHighlightNone) {
  1269         d->focusActiveType = HbStyle::P_None;
  1273         d->focusActiveType = HbStylePrivate::P_None;
  1270         d->focusResidualType = HbStyle::P_None;
  1274         d->focusResidualType = HbStylePrivate::P_None;
  1271 
  1275 
  1272         delete d->focusActiveItem;
  1276         delete d->focusActiveItem;
  1273         d->focusActiveItem = 0;
  1277         d->focusActiveItem = 0;
  1274         delete d->focusResidualItem;
  1278         delete d->focusResidualItem;
  1275         d->focusResidualItem = 0;
  1279         d->focusResidualItem = 0;
  1276     } else if (focusHighlight == HbWidget::FocusHighlightActive) {
  1280     } else if (focusHighlight == HbWidget::FocusHighlightActive) {
  1277         d->focusActiveType = type;
  1281         d->focusActiveType = (HbStylePrivate::Primitive)type;
  1278     } else {
  1282     } else {
  1279         d->focusResidualType = type;
  1283         d->focusResidualType = (HbStylePrivate::Primitive)type;
  1280     }
  1284     }
  1281 }
  1285 }
  1282 
  1286 
  1283 /*!
  1287 /*!
  1284 
  1288 
  1289     \param highlightType defines the highlight type.
  1293     \param highlightType defines the highlight type.
  1290 */
  1294 */
  1291 HbStyle::Primitive HbWidget::focusHighlight(HbWidget::FocusHighlight highlightType)
  1295 HbStyle::Primitive HbWidget::focusHighlight(HbWidget::FocusHighlight highlightType)
  1292 {
  1296 {
  1293     Q_D(HbWidget);
  1297     Q_D(HbWidget);
  1294     HbStyle::Primitive primitive(HbStyle::P_None);
  1298     HbStylePrivate::Primitive primitive(HbStylePrivate::P_None);
  1295 
  1299 
  1296     if (highlightType == HbWidget::FocusHighlightActive) {
  1300     if (highlightType == HbWidget::FocusHighlightActive) {
  1297         primitive = d->focusActiveType;
  1301         primitive = d->focusActiveType;
  1298     } else if (highlightType == HbWidget::FocusHighlightResidual) {
  1302     } else if (highlightType == HbWidget::FocusHighlightResidual) {
  1299         primitive = d->focusResidualType;
  1303         primitive = d->focusResidualType;
  1300     }
  1304     }
  1301     return primitive;
  1305     return (HbStyle::Primitive)primitive;
  1302 }
  1306 }
  1303 
  1307 
  1304 bool HbWidget::sceneEventFilter (QGraphicsItem *watched, QEvent *event)
  1308 bool HbWidget::sceneEventFilter (QGraphicsItem *watched, QEvent *event)
  1305 {
  1309 {
  1306     if(event->type() == QEvent::Gesture && watched->type() == Hb::ItemType_TouchArea) {
  1310     if(isEnabled() && event->type() == QEvent::Gesture && watched->type() == Hb::ItemType_TouchArea) {
  1307         QGestureEvent* ge = static_cast<QGestureEvent*>(event);
  1311         QGestureEvent* ge = static_cast<QGestureEvent*>(event);
  1308         HbTapGesture* tap = qobject_cast<HbTapGesture*>(ge->gesture(Qt::TapGesture));
  1312         HbTapGesture* tap = qobject_cast<HbTapGesture*>(ge->gesture(Qt::TapGesture));
  1309 
  1313 
  1310         if (tap && tap->state() == Qt::GestureStarted) {
  1314         if (tap && tap->state() == Qt::GestureStarted) {
  1311             tap->setProperty(HbPrivate::ThresholdRect.latin1(), watched->mapRectToScene(watched->boundingRect()).toRect());
  1315             tap->setProperty(HbPrivate::ThresholdRect.latin1(), watched->mapRectToScene(watched->boundingRect()).toRect());