src/hbcore/gui/hbpopupmanager.cpp
changeset 5 627c4a0fd0e7
parent 1 f7ac710697a9
child 6 c3690ec91ef8
equal deleted inserted replaced
3:11d3954df52a 5:627c4a0fd0e7
    92 
    92 
    93 void HbPopupLayoutProxy::setGeometry(const QRectF &rect)
    93 void HbPopupLayoutProxy::setGeometry(const QRectF &rect)
    94 {
    94 {
    95     if (!mPopup.isNull()) {
    95     if (!mPopup.isNull()) {
    96         const QSizeF popupPreferredSize = 
    96         const QSizeF popupPreferredSize = 
    97             mPopup->effectiveSizeHint(Qt::PreferredSize);
    97                 mPopup->effectiveSizeHint(Qt::PreferredSize);
    98         const QSizeF usedSize( qMin(rect.width(),   popupPreferredSize.width() ),
    98         const QSizeF usedSize( qMin(rect.width(),   popupPreferredSize.width() ),
    99                                qMin( rect.height(), popupPreferredSize.height() ) );
    99                                qMin( rect.height(), popupPreferredSize.height() ) );
   100         QPointF usedPos(rect.left(), rect.top());
   100         QPointF usedPos(rect.left(), rect.top());
   101         mPreferredPos = ((HbPopupPrivate*)HbPopupPrivate::d_ptr(mPopup))->preferredPos;
   101         mPreferredPos = ((HbPopupPrivate*)HbPopupPrivate::d_ptr(mPopup))->preferredPos;
   102         mPlacement = ((HbPopupPrivate*)HbPopupPrivate::d_ptr(mPopup))->placement;
   102         mPlacement = ((HbPopupPrivate*)HbPopupPrivate::d_ptr(mPopup))->placement;
   155             if ( usedx < screenMargin ) usedx = screenMargin;
   155             if ( usedx < screenMargin ) usedx = screenMargin;
   156             if ( usedy < screenMargin ) usedy = screenMargin;
   156             if ( usedy < screenMargin ) usedy = screenMargin;
   157 
   157 
   158             usedPos = QPointF(usedx, usedy);
   158             usedPos = QPointF(usedx, usedy);
   159         }
   159         }
   160         mPopup->setGeometry(QRectF(usedPos, usedSize));
   160         if (((HbPopupPrivate*)HbPopupPrivate::d_ptr(mPopup))->mAutoLayouting) {
       
   161             mPopup->setGeometry(QRectF(usedPos, usedSize));
       
   162             ((HbPopupPrivate*)HbPopupPrivate::d_ptr(mPopup))->mAutoLayouting = true;
       
   163         } else {
       
   164             mPopup->resize(usedSize);
       
   165         }
   161     }
   166     }
   162 }
   167 }
   163 
   168 
   164 bool HbPopupLayoutProxy::event( QEvent *e ) 
   169 bool HbPopupLayoutProxy::event( QEvent *e ) 
   165 {
   170 {
   176 bool HbPopupLayoutProxy::eventFilter(QObject *obj, QEvent *event)
   181 bool HbPopupLayoutProxy::eventFilter(QObject *obj, QEvent *event)
   177 {
   182 {
   178     Q_UNUSED( obj );
   183     Q_UNUSED( obj );
   179     switch( event->type() ) {
   184     switch( event->type() ) {
   180         case QEvent::LayoutRequest: {
   185         case QEvent::LayoutRequest: {
   181             updateGeometry();
   186                 updateGeometry();
   182             break;
   187             break;
   183         }
   188         }
   184         case QEvent::ContextMenu: {
   189         case QEvent::ContextMenu: {
   185             updateGeometry();
   190             updateGeometry();
   186             break;
   191             break;
   414                  popup->metaObject()->className() != QLatin1String("HbCharPreviewPane") &&
   419                  popup->metaObject()->className() != QLatin1String("HbCharPreviewPane") &&
   415                  popup->metaObject()->className() != QLatin1String("HbCandidateList") &&
   420                  popup->metaObject()->className() != QLatin1String("HbCandidateList") &&
   416                  popup->metaObject()->className() != QLatin1String("HbExactWordPopup") &&
   421                  popup->metaObject()->className() != QLatin1String("HbExactWordPopup") &&
   417                  popup->metaObject()->className() != QLatin1String("HbInputSmileyPicker") &&
   422                  popup->metaObject()->className() != QLatin1String("HbInputSmileyPicker") &&
   418                  popup->metaObject()->className() != QLatin1String("Hb12KeyCustomKeypad") &&
   423                  popup->metaObject()->className() != QLatin1String("Hb12KeyCustomKeypad") &&
   419 				 popup->metaObject()->className() != QLatin1String("HbInputThaiSpecialPopup") &&
   424 				 !popup->inherits("HbInputVkbWidget")) {
   420                  !popup->inherits("HbInputVkbWidget")) {
       
   421                 setGeometryForPopup( popup );
   425                 setGeometryForPopup( popup );
   422             }
   426             }
   423         }
   427         }
   424 
   428 
   425         // Check if popup is top level popup
   429         // Check if popup is top level popup
   430 
   434 
   431             // If this is the first popup in the stack being launched
   435             // If this is the first popup in the stack being launched
   432             if(!initialFocusedItem && scene) {
   436             if(!initialFocusedItem && scene) {
   433                 initialFocusedItem = scene->focusItem();
   437                 initialFocusedItem = scene->focusItem();
   434             }
   438             }
   435 
   439             
   436             topLevelFocusablePopup->setFocus();
   440             // an embedded graphics item is already having a 
       
   441             // focus so do not set focus as graphicsscene will automatically
       
   442             // set the focus to the embedded item.
       
   443             if (!topLevelFocusablePopup->focusItem())
       
   444                 topLevelFocusablePopup->setFocus();
   437         }
   445         }
   438 
   446 
   439         updateFading();
   447         updateFading();
   440     }
   448     }
   441 }
   449 }