src/hbcore/gui/hbpopupmanager.cpp
changeset 30 80e4d18b72f5
parent 28 b7da29130b0e
--- a/src/hbcore/gui/hbpopupmanager.cpp	Fri Sep 17 08:32:10 2010 +0300
+++ b/src/hbcore/gui/hbpopupmanager.cpp	Mon Oct 04 00:38:12 2010 +0300
@@ -39,9 +39,10 @@
 #include <QGraphicsWidget>
 #include <QGraphicsSceneMouseEvent>
 #include <QGraphicsLayout>
-#include <QDebug>
 #include <QEvent>
 
+extern const char* KPositionManagedByVKB;
+
 HbPopupLayoutSpacer::HbPopupLayoutSpacer( QGraphicsItem *parent )
 : HbWidgetBase( parent )
 {
@@ -77,7 +78,7 @@
 
 void HbPopupLayoutProxy::setGeometry(const QRectF &rect)
 {
-    if (!mPopup.isNull()) {
+     if (!mPopup.isNull()) {
         const QSizeF popupPreferredSize = 
                 mPopup->effectiveSizeHint(Qt::PreferredSize);
         const QSizeF usedSize( qMin(rect.width(),   popupPreferredSize.width() ),
@@ -122,8 +123,16 @@
                 usedy = qMin(y-uh/2, ph-uh);
                 break;
             case HbPopup::BottomEdgeCenter:
+                {
                 usedx = qMin(x-uw/2, pw-uw);
-                usedy = qMin(y-uh, ph-uh);
+                HbMenu *menu = qobject_cast<HbMenu*>(mPopup);
+                if(menu && ((y-uh) < 0)) {
+                    usedy = qMin(y,ph-uh);
+                }
+                else {
+                    usedy = qMin(y-uh, ph-uh);
+                }
+                }
                 break;
             case HbPopup::LeftEdgeCenter:
                 usedx = qMin(x, pw-uw);
@@ -137,14 +146,23 @@
                 //should not happen
                 break;
             }
+
             if ( usedx < screenMargin ) usedx = screenMargin;
             if ( usedy < screenMargin ) usedy = screenMargin;
-
             usedPos = QPointF(usedx, usedy);
         }
         if (((HbPopupPrivate*)HbPopupPrivate::d_ptr(mPopup))->mAutoLayouting) {
             mPopup->setGeometry(QRectF(usedPos, usedSize));
+            ((HbPopupPrivate*)HbPopupPrivate::d_ptr(mPopup))->mAutoLayouting = true;            
+        } else if (mPopup->property(KPositionManagedByVKB).isValid() &&
+                   mPopup->property(KPositionManagedByVKB).toBool()) {
+            //Special case for the popups which y-position is handled by VKB
+            QPointF currentPos = mPopup->pos();
+            currentPos.setX(usedPos.x());
+            bool previousLayouting = ((HbPopupPrivate*)HbPopupPrivate::d_ptr(mPopup))->mAutoLayouting;
             ((HbPopupPrivate*)HbPopupPrivate::d_ptr(mPopup))->mAutoLayouting = true;
+            mPopup->setGeometry(QRectF(currentPos, usedSize));
+            ((HbPopupPrivate*)HbPopupPrivate::d_ptr(mPopup))->mAutoLayouting = previousLayouting;
         } else {
             mPopup->resize(usedSize);
         }
@@ -168,7 +186,6 @@
     Q_UNUSED( obj );
     switch( event->type() ) {
         case QEvent::LayoutRequest:
-        case QEvent::ContextMenu:
         case QEvent::Close:
             {
             updateGeometry();