void Ut_MPannableViewport::setWidget() { QGraphicsWidget *widget = new QGraphicsWidget(); subject->setWidget(widget); widget->setZValue(1); QCOMPARE(widget->zValue(), 1.0); QCOMPARE(static_cast<MPannableViewportPrivate *>(subject->d_ptr)->pannedWidget, widget); QCOMPARE(static_cast<MPannableViewportPrivate *>(subject->d_ptr)->pannedWidget->parentItem(), subject); }
void PulseAnimation::setCopy() { QGraphicsWidget *target = targetWidget(); if (!target) { m_under.clear(); return; } if (!m_under.data()) { m_under = new WidgetSnapShot; } m_under.data()->setTarget(target); m_zvalue = target->zValue() - 1; m_scale = target->scale(); m_under.data()->setOpacity(m_opacity); m_under.data()->setScale(m_scale); m_under.data()->setZValue(m_zvalue); }
void HbComboBoxPrivate::positionDropDown( ) { Q_Q( HbComboBox ); QRectF popupRect; QRectF sceneRect( QPointF( ), HbDeviceProfile::profile( q ).logicalSize( ) ); QPointF widgetPos = q->scenePos( ); QAbstractItemModel *model = mDropDown->mList->model( ); calculateListItemHeight( ); qreal totalHeightRequd = model->rowCount( ) * mListItemHeight; qreal maxPopupHeight = 0.0; //read the maximum rows in drop down for different orientation from css if( q->mainWindow( )->orientation( ) == Qt::Horizontal ) { if( mDropDownRowsInLandscape == -1 ) { HbStyleParameters params; q->style( )->parameters( params ); params.addParameter( "max-rows-in-dropdown" ); q->polish( params ); mDropDownRowsInLandscape = params.value( "max-rows-in-dropdown" ).toInt( ); } maxPopupHeight = mDropDownRowsInLandscape * mListItemHeight; } else if( q->mainWindow( )->orientation( ) == Qt::Vertical ) { if( mDropDownRowsInPortrait == -1 ) { HbStyleParameters params; q->style( )->parameters( params ); params.addParameter( "max-rows-in-dropdown" ); q->polish( params ); mDropDownRowsInPortrait = params.value( "max-rows-in-dropdown" ).toInt( ); } maxPopupHeight = mDropDownRowsInPortrait * mListItemHeight; } if ( totalHeightRequd < maxPopupHeight ) { maxPopupHeight = totalHeightRequd; } QSizeF popupSize = QSizeF( q->rect( ).width( ), maxPopupHeight ); QPointF popupPos; if( !mDropDown->vkbOpened ) { //position of drop down in both editable and non-editable combobox depends upon //the available space above and below combobox if( ( widgetPos.y( ) + q->rect( ).height( ) + maxPopupHeight) < sceneRect.height( ) ) { popupPos = QPointF( widgetPos.x( ), widgetPos.y( ) + q->rect( ).height( ) ); #ifdef HB_EFFECTS if ( !mHasDownEffect ) { mHasDownEffect = true; mHasUpEffect = false; // this is temporary until proper effect theming comes. //this Effect will be shown when there is space in the view bottom. HbEffectInternal::add( mDropDown, "combo_appear_down", "appear" ); HbEffectInternal::add( mDropDown, "combo_disappear_downl", "disappear" ); } #endif } else if( widgetPos.y( ) - maxPopupHeight > 0.0 ) { popupPos = QPointF( widgetPos.x( ), widgetPos.y( ) - maxPopupHeight ); #ifdef HB_EFFECTS if ( !mHasUpEffect ) { // this is temporary until proper effect theming comes. //this Effect will be shown when there is no space in the view bottom mHasUpEffect = true; mHasDownEffect = false; HbEffectInternal::add( mDropDown, "combo_appear_up", "appear" ); HbEffectInternal::add( mDropDown, "combo_disappear_up", "disappear" ); } #endif } else { qreal topScreenHeight = sceneRect.height( ) - maxPopupHeight; if( topScreenHeight > sceneRect.height( ) - topScreenHeight ) { popupPos = QPointF( widgetPos.x( ), 0.0 ); #ifdef HB_EFFECTS if ( !mHasDownEffect ) { mHasDownEffect = true; mHasUpEffect = false; // this is temporary until proper effect theming comes. //this Effect will be shown when there is more space in the view bottom. HbEffectInternal::add( mDropDown, "combo_appear_down", "appear" ); HbEffectInternal::add( mDropDown, "combo_disappear_down", "disappear" ); } #endif } else { popupPos = QPointF( widgetPos.x( ), sceneRect.height( ) - maxPopupHeight ); #ifdef HB_EFFECTS if ( !mHasUpEffect ) { mHasUpEffect = true; mHasDownEffect = false; // this is temporary until proper effect theming comes. //this Effect will be shown when there is more space in the view bottom. HbEffectInternal::add( mDropDown, "combo_appear_up", "appear" ); HbEffectInternal::add( mDropDown, "combo_disappear_up", "disappear" ); } #endif } } } else { // positioning drop down when vkb is positioned // drop down will come on top/below of combo based upon which side has more space // available HbEditorInterface editorInterface( q ); HbVkbHost *host = editorInterface.vkbHost( ); if ( host ) { QSizeF keyBoardArea = host->keyboardArea( ); QSize screenSize = HbDeviceProfile::profile( q ).logicalSize( ); qreal heightDifference = screenSize.height( ) - keyBoardArea.height( ); qreal topSpace = widgetPos.y( ); qreal bottomSpace = heightDifference - topSpace - q->boundingRect( ).height( ); if( topSpace > bottomSpace ) { //display drop down at top if( widgetPos.y( ) - maxPopupHeight > 0.0 ) { popupPos = QPointF( widgetPos.x( ), widgetPos.y( ) - maxPopupHeight ); } else { popupPos = QPointF( widgetPos.x( ), 0.0 ); popupSize.setHeight( topSpace ); } #ifdef HB_EFFECTS if ( !mHasUpEffect ) { mHasUpEffect = true; mHasDownEffect = false; // this is temporary until proper effect theming comes. //this Effect will be shown when there is more space in the view bottom. HbEffectInternal::add( mDropDown, "combo_appear_up", "appear" ); HbEffectInternal::add( mDropDown, "combo_disappear_up", "disappear" ); } #endif } else { //display drop down at bottom popupPos = QPointF( widgetPos.x( ), widgetPos.y( ) + q->rect( ).height( ) ); if( bottomSpace < maxPopupHeight ) { popupSize.setHeight( bottomSpace ); } #ifdef HB_EFFECTS if ( !mHasDownEffect ) { mHasDownEffect = true; mHasUpEffect = false; // this is temporary until proper effect theming comes. //this Effect will be shown when there is more space in the view bottom. HbEffectInternal::add( mDropDown, "combo_appear_down", "appear" ); HbEffectInternal::add( mDropDown, "combo_disappear_down", "disappear" ); } #endif } } } mDropDown->setPreferredSize( popupSize ); mDropDown->setMinimumSize( popupSize ); mDropDown->setMaximumSize( popupSize ); mDropDown->setPos( popupPos ); QGraphicsWidget *p = q; while ( p->parentWidget( ) ) { p = p->parentWidget( ); } mDropDown->setZValue( p->zValue( ) + 1 ); }