src/hbcore/gui/hbpopup.cpp
changeset 30 80e4d18b72f5
parent 28 b7da29130b0e
--- a/src/hbcore/gui/hbpopup.cpp	Fri Sep 17 08:32:10 2010 +0300
+++ b/src/hbcore/gui/hbpopup.cpp	Mon Oct 04 00:38:12 2010 +0300
@@ -283,6 +283,24 @@
 };
 
 /*
+   Currently, virtual keyboard must be able to position a popup
+   containing an editor to an arbitrary place. VKB does its best to
+   reposition the popup back to original position when needed. At least in
+   orientation switch the old position naturally is wrong, hence popup
+   must be relayouted.
+
+   It would be unreasonable to make special checks for popup in vkb
+   side. It also would be unreasonable to do special checks for vkb in
+   popup side. Hence this semi-hidden dynamic property for
+   communicating this special case.
+
+   WARNING: Do not count on this special behaviour, we might remove it
+   without prior notice. If you do require such a behavior, please
+   raise a feature request and we might make this a proper API.
+ */
+const char* KPositionManagedByVKB("PositionManagedByVKB");
+
+/*
     \primitives
     \primitive{background} HbFrameItem representing the popup background. The background can be 
     weak or strong (different graphical styles) depending on popup type.
@@ -424,6 +442,8 @@
     itemFlags |= QGraphicsItem::ItemIsPanel;
     q->setFlags(itemFlags);
     q->setActive(false);
+
+    q->setAcceptTouchEvents(true);
 }
 
 void HbPopupPrivate::_q_appearEffectEnded(HbEffect::EffectStatus status)
@@ -431,6 +451,11 @@
     Q_UNUSED(status);
 }
 
+void HbPopupPrivate::_q_maskEffectDestroyed()
+{
+    mVgMaskEffect = 0;
+}
+
 CSystemToneService* HbPopupPrivate::systemToneService()
 {
     return HbInstancePrivate::d_ptr()->systemTone();
@@ -486,7 +511,7 @@
 {
     Q_Q(HbPopup);
     if (q->isVisible() || q) {
-        QEvent userEvent(QEvent::ContextMenu);
+        QEvent userEvent(QEvent::LayoutRequest);
         QCoreApplication::sendEvent(q, &userEvent);
     }
 
@@ -718,6 +743,10 @@
                 mVgMaskEffect = 0;
             }
         }
+        if (mVgMaskEffect) {
+            // Make sure that mask effect is reset when destroyed
+            QObject::connect(mVgMaskEffect, SIGNAL(destroyed()), q, SLOT(_q_maskEffectDestroyed()));
+        }
     }
     QPixmap image(q->backgroundItem()->boundingRect().size().toSize());
     image.fill(Qt::transparent);
@@ -749,7 +778,7 @@
 {
     Q_D(HbPopup);
     d->q_ptr = this;
-    d->init();    
+    d->init();
 }
 
 
@@ -761,7 +790,7 @@
 {
     Q_D(HbPopup);
     d->q_ptr = this;
-    d->init();    
+    d->init();
 }
 /*!
     Destructor.
@@ -972,7 +1001,15 @@
 {
     Q_D(HbPopup);
 
-    if (change == QGraphicsItem::ItemPositionChange) {
+    if (change == QGraphicsItem::ItemPositionChange) {        
+        // Skipping X-coordinate changes made by VKB since popupmanager handles popup to be in the
+        // center of the screen
+        if (property(KPositionManagedByVKB).isValid() && property(KPositionManagedByVKB).toBool() &&
+            !d->mAutoLayouting && value.isValid() && !value.toPointF().isNull()) {
+            QPointF newPointF(geometry().x(), value.toPointF().y());
+            d->mAutoLayouting = false;
+            return newPointF;
+        }
         d->mAutoLayouting = false;
     }
     if (change == QGraphicsItem::ItemVisibleHasChanged) {
@@ -1224,25 +1261,6 @@
     HbWidget::closeEvent(event);
 }
 
-
-/*
-   Currently, virtual keyboard must be able to position a popup
-   containing an editor to an arbitrary place. VKB does its best to
-   reposition the popup back to original position when needed. At least in
-   orientation switch the old position naturally is wrong, hence popup
-   must be relayouted.
-
-   It would be unreasonable to make special checks for popup in vkb
-   side. It also would be unreasonable to do special checks for vkb in
-   popup side. Hence this semi-hidden dynamic property for
-   communicating this special case.
-
-   WARNING: Do not count on this special behaviour, we might remove it
-   without prior notice. If you do require such a behavior, please
-   raise a feature request and we might make this a proper API.
- */
-const char* KPositionManagedByVKB("PositionManagedByVKB");
-
 /*!
     Reimplemented from QGraphicsWidget. 
  */
@@ -1287,6 +1305,10 @@
         }
 #endif //HB_EFFECTS
         //workaround ends
+    } else if (event->type() == QEvent::TouchBegin) {
+        // Accept all touch begin events to get the full Begin..End sequence
+        event->accept();
+        return true;
     } else if (d->mGestureOverride && event->type() == QEvent::GestureOverride) {
         event->accept();
         return true;