emailuis/nmhswidget/src/nmhswidgettitlerow.cpp
changeset 76 38bf5461e270
parent 74 6c59112cfd31
equal deleted inserted replaced
74:6c59112cfd31 76:38bf5461e270
   101     NM_FUNCTION;
   101     NM_FUNCTION;
   102 
   102 
   103     if(!loadDocML(loader) || !setupGraphics()){
   103     if(!loadDocML(loader) || !setupGraphics()){
   104         return false;
   104         return false;
   105     }
   105     }
       
   106     
       
   107     HbEffect::add(mBackgroundLayoutItem, "listviewitem_press", "pressed");
       
   108     HbEffect::add(mBackgroundLayoutItem, "listviewitem_release", "released");
       
   109     
   106     return true;
   110     return true;
   107     }
   111     }
   108 
   112 
   109 /*!
   113 /*!
   110  Loads layout data and child items from docml file. Must be called after constructor.
   114  Loads layout data and child items from docml file. Must be called after constructor.
   152 {
   156 {
   153     NM_FUNCTION;
   157     NM_FUNCTION;
   154     
   158     
   155     HbFrameDrawer* backgroundFrameDrawer = 0;
   159     HbFrameDrawer* backgroundFrameDrawer = 0;
   156     QT_TRY{
   160     QT_TRY{
   157         //pressed background
   161         //default background
   158         backgroundFrameDrawer = new HbFrameDrawer("qtg_fr_hsitems_pressed", HbFrameDrawer::NinePieces);
   162         backgroundFrameDrawer = new HbFrameDrawer(KNmHsWidgetBackgroundImage, HbFrameDrawer::NinePieces);
   159         mBackgroundLayoutItem = new HbFrameItem( backgroundFrameDrawer );
   163         mBackgroundLayoutItem = new HbFrameItem( backgroundFrameDrawer );
   160         mContainer->setBackgroundItem( mBackgroundLayoutItem );
   164         mContainer->setBackgroundItem( mBackgroundLayoutItem );
   161 		mBackgroundLayoutItem->hide();
       
   162         
   165         
   163         //set fonts color
   166         //set fonts color
   164 		setHighlighedFontsColor(false);
   167 		setFontsColor();
   165 		
   168 		
   166 		//to get gestures
   169 		//to get gestures
   167 		setGeometry(mContainer->childrenBoundingRect());
   170 		setGeometry(mContainer->childrenBoundingRect());
   168 		
   171 		
   169         return true;
   172         return true;
   240         QFontMetrics fm(mUnreadCountLabel->font());
   243         QFontMetrics fm(mUnreadCountLabel->font());
   241         qreal textWidth = fm.width(unreadCount);
   244         qreal textWidth = fm.width(unreadCount);
   242         mUnreadCountLabel->setMaximumWidth(textWidth);
   245         mUnreadCountLabel->setMaximumWidth(textWidth);
   243     }
   246     }
   244     else {
   247     else {
       
   248         //set empty string as nothing to show
       
   249         mUnreadCountLabel->setPlainText(QString());
   245         mUnreadCountLabel->setMaximumWidth(0);
   250         mUnreadCountLabel->setMaximumWidth(0);
   246     }
   251     }
   247 }
   252 }
   248 
   253 
   249 /*!
   254 /*!
   250     sets fonts color.
   255     sets fonts color.
   251     /param bool pressed indicates if row is pressed down or not
       
   252 */
   256 */
   253 void NmHsWidgetTitleRow::setHighlighedFontsColor( bool pressed )
   257 void NmHsWidgetTitleRow::setFontsColor()
   254     {
   258     {
   255     NM_FUNCTION;
   259     NM_FUNCTION;
   256     QColor newFontColor;
   260     QColor newFontColor = HbColorScheme::color("qtc_hs_list_item_title_normal");
   257     
       
   258     if(pressed){
       
   259         newFontColor = HbColorScheme::color("qtc_hs_list_item_pressed");
       
   260     }
       
   261     else{
       
   262         newFontColor = HbColorScheme::color("qtc_hs_list_item_title_normal");
       
   263     }
       
   264  
   261  
   265     mMailboxInfo->setTextColor(newFontColor);
   262     mMailboxInfo->setTextColor(newFontColor);
   266     mUnreadCountLabel->setTextColor(newFontColor);
   263     mUnreadCountLabel->setTextColor(newFontColor);
   267     }
   264     }
   268 
   265 
   269 /*!
   266 /*!
   270     change background pressed state
   267     hide background
   271     /param bool show if true then shown, false hide
       
   272 */
   268 */
   273 void NmHsWidgetTitleRow::showHighlight( bool show )
   269 void NmHsWidgetTitleRow::hideHighlight(const HbEffect::EffectStatus &status)
   274     {
   270     {
   275     NM_FUNCTION;;
   271     NM_FUNCTION;
   276     
   272 
   277     if(show){
   273     Q_UNUSED(status);
   278         mBackgroundLayoutItem->show();
   274     mBackgroundLayoutItem->frameDrawer().setFrameGraphicsName(KNmHsWidgetBackgroundImage);
   279     }
       
   280     else{
       
   281         mBackgroundLayoutItem->hide();
       
   282     }
       
   283     }
   275     }
   284 
   276 
   285 /*
   277 /*
   286  * NmHsWidgetTitleRow::gestureEvent(QGestureEvent *event)
   278  * NmHsWidgetTitleRow::gestureEvent(QGestureEvent *event)
   287  */
   279  */
   311     }
   303     }
   312     
   304     
   313     if (inArea) {    
   305     if (inArea) {    
   314         switch (gesture->state()) {
   306         switch (gesture->state()) {
   315             case Qt::GestureStarted:
   307             case Qt::GestureStarted:
   316                 setHighlighedFontsColor(true);
   308                 HbEffect::start( mBackgroundLayoutItem, "pressed");
   317                 showHighlight(true);
   309                 mBackgroundLayoutItem->frameDrawer().setFrameGraphicsName("qtg_fr_hsitems_pressed");
   318             break;
   310             break;
   319             case Qt::GestureCanceled:
   311             case Qt::GestureCanceled:
   320                 setHighlighedFontsColor(false);
   312                 HbEffect::start( mBackgroundLayoutItem, "released", this, "hideHighlight");
   321                 showHighlight(false);
       
   322             break;
   313             break;
   323             case Qt::GestureFinished:
   314             case Qt::GestureFinished:
   324                 setHighlighedFontsColor(false);
   315                 HbEffect::start( mBackgroundLayoutItem, "released", this, "hideHighlight");
   325                 showHighlight(false);
       
   326                 if (gesture->tapStyleHint() == HbTapGesture::Tap) {
   316                 if (gesture->tapStyleHint() == HbTapGesture::Tap) {
   327                     HbInstantFeedback::play(HbFeedback::BasicItem);
   317                     HbInstantFeedback::play(HbFeedback::BasicItem);
   328                     emit mailboxLaunchTriggered();
   318                     emit mailboxLaunchTriggered();
   329                 }
   319                 }
   330             break;
   320             break;
   340 bool NmHsWidgetTitleRow::event( QEvent *event )
   330 bool NmHsWidgetTitleRow::event( QEvent *event )
   341 {
   331 {
   342     NM_FUNCTION;
   332     NM_FUNCTION;
   343     QEvent::Type eventType = event->type();
   333     QEvent::Type eventType = event->type();
   344     if( eventType == HbEvent::ThemeChanged ){
   334     if( eventType == HbEvent::ThemeChanged ){
   345         setHighlighedFontsColor(false);
   335         setFontsColor();
   346         return true;
   336         return true;
   347     }
   337     }
   348     return HbWidget::event(event);
   338     return HbWidget::event(event);
   349 }
   339 }