phoneplugins/dialerwidgetplugin/src/dialerwidget.cpp
changeset 56 5bcb308bd24d
parent 46 bc5a64e5bc3c
child 64 6aaf0276100e
--- a/phoneplugins/dialerwidgetplugin/src/dialerwidget.cpp	Tue Jul 06 14:15:47 2010 +0300
+++ b/phoneplugins/dialerwidgetplugin/src/dialerwidget.cpp	Wed Aug 18 09:48:26 2010 +0300
@@ -15,6 +15,8 @@
 *
 */
 
+#include <QGraphicsSceneMouseEvent>
+
 #include <HbStyle>
 #include <HbStyleLoader>
 #include <HbFrameItem>
@@ -22,6 +24,7 @@
 #include <HbIconItem>
 #include <HbTextItem>
 #include <HbTouchArea>
+#include <HbInstantFeedback>
 #include "dialerwidgetengine.h"
 #include "dialerwidget.h"
 #include "qtphonelog.h"
@@ -38,8 +41,9 @@
 
 namespace
 {
-    const char KDialerWidgetIcon[] = ":/icons/resource/qtg_graf_hs_dialer";
-    const char KMissedCallShortcutBadge[] = ":/icons/resource/qtg_fr_shortcut_badge_bg";
+    const char KDialerWidgetIconNormal[] = "qtg_graf_hs_dialer_normal";
+    const char KDialerWidgetIconPressed[] = "qtg_graf_hs_dialer_pressed";
+    const char KMissedCallShortcutBadge[] = "qtg_fr_shortcut_badge_bg";
     const char KDialerWidgetWidgetml[] = ":/data/resource/dialerwidget.widgetml";
     const char KDialerWidgetCss[] = ":/data/resource/dialerwidget.css";
 }
@@ -57,7 +61,8 @@
 */
 DialerWidget::DialerWidget(QGraphicsItem *parent, Qt::WindowFlags flags)
   : HsWidget(parent, flags),
-    m_background(0), m_badgeBackground(0), m_text(0), m_touchArea(0)
+    m_background(0), m_badgeBackground(0), m_text(0), m_touchArea(0),
+    m_engine(0)
 {   
     PHONE_TRACE 
 }
@@ -194,16 +199,38 @@
     }
 }
 
-/*!
-    \fn void DialerWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
+void DialerWidget::mousePressEvent(QGraphicsSceneMouseEvent *event)
+{
+    PHONE_TRACE;
+    Q_UNUSED(event)
+    setBackgroundToPressed();
+}
+
+void DialerWidget::handleMouseMoveEvent(QGraphicsSceneMouseEvent *event)
+{
+    if (contains(event->pos())) {
+        setBackgroundToPressed();
+    } else {
+        setBackgroundToNormal();
+    }
+}
 
-    Dialer widget start is triggered from release \a event.
-    \sa startDialer()
-*/
 void DialerWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
-{   
+{
+    PHONE_TRACE;
     Q_UNUSED(event);
-    startDialer();
+    HbInstantFeedback::play(HbFeedback::Basic);
+    setBackgroundToNormal();
+    startDialer();    
+}
+
+bool DialerWidget::sceneEvent(QEvent *event)
+{
+    if (event->type() == QEvent::UngrabMouse) {
+        setBackgroundToNormal();
+    }
+
+    return HsWidget::sceneEvent(event);;
 }
 
 HsWidget::StartResult DialerWidget::onStart()
@@ -229,9 +256,9 @@
     // Background
     if (!m_background) {
         HbFrameDrawer *drawer = new HbFrameDrawer(
-                KDialerWidgetIcon, HbFrameDrawer::OnePiece);
+            KDialerWidgetIconNormal, HbFrameDrawer::OnePiece);
         m_background = new HbFrameItem(drawer, this);
-        style()->setItemName(m_background, /*QLatin1String(*/"background"/*)*/);
+        style()->setItemName(m_background, QLatin1String("background"));
         m_background->moveBy(0,10);
         m_background->resize(81,81);
     }
@@ -239,7 +266,7 @@
     // Badge background
     if (!m_badgeBackground) {
         HbFrameDrawer *badgedrawer = new HbFrameDrawer(
-                KMissedCallShortcutBadge, HbFrameDrawer::ThreePiecesHorizontal);
+            KMissedCallShortcutBadge, HbFrameDrawer::ThreePiecesHorizontal);
         m_badgeBackground = new HbFrameItem(badgedrawer, this);
         style()->setItemName(m_background, QLatin1String("badgeBackground"));
         m_badgeBackground->resize(20,20);
@@ -272,3 +299,19 @@
     }
 }
 
+void DialerWidget::setBackgroundToNormal()
+{
+    if (m_background) {
+        m_background->frameDrawer().
+            setFrameGraphicsName(KDialerWidgetIconNormal);
+    }
+}
+
+void DialerWidget::setBackgroundToPressed()
+{
+    if (m_background) {
+        m_background->frameDrawer().
+            setFrameGraphicsName(KDialerWidgetIconPressed);
+    }
+}
+