VirtualBox

Changeset 44060 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Dec 7, 2012 1:43:35 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
82546
Message:

FE/Qt: VM group UI: Details-view: More wise geometry update mechanism.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.cpp

    r43989 r44060  
    103103    /* Mark animation as non-running: */
    104104    m_fAnimationRunning = false;
     105
     106    /* Recursively update size-hint: */
     107    updateGeometry();
     108    /* Repaint: */
     109    update();
    105110}
    106111
     
    189194
    190195    /* Calculate minimum-text-width: */
    191     m_iMinimumTextWidth = 0;
     196    int iMinimumTextWidth = 0;
    192197    if (fSingleColumnText)
    193198    {
    194199        /* Take into account only left column: */
    195200        int iMinimumLeftColumnWidth = qMin(iMaximumLeftLineWidth, iMinimumTextColumnWidth);
    196         m_iMinimumTextWidth = iMinimumLeftColumnWidth;
     201        iMinimumTextWidth = iMinimumLeftColumnWidth;
    197202    }
    198203    else
     
    201206        int iMinimumLeftColumnWidth = iMaximumLeftLineWidth;
    202207        int iMinimumRightColumnWidth = qMin(iMaximumRightLineWidth, iMinimumTextColumnWidth);
    203         m_iMinimumTextWidth = iMinimumLeftColumnWidth + iSpacing + iMinimumRightColumnWidth;
     208        iMinimumTextWidth = iMinimumLeftColumnWidth + iSpacing + iMinimumRightColumnWidth;
     209    }
     210
     211    /* Is there something changed? */
     212    if (m_iMinimumTextWidth != iMinimumTextWidth)
     213    {
     214        /* Remember new value: */
     215        m_iMinimumTextWidth = iMinimumTextWidth;
     216        /* Recursively update size-hint: */
     217        updateGeometry();
    204218    }
    205219}
     
    248262
    249263    /* Calculate minimum-text-height: */
    250     m_iMinimumTextHeight = 0;
     264    int iMinimumTextHeight = 0;
    251265    foreach (const UITextTableLine line, m_text)
    252266    {
     
    272286
    273287        /* Append summary text height: */
    274         m_iMinimumTextHeight += qMax(iLeftColumnHeight, iRightColumnHeight);
     288        iMinimumTextHeight += qMax(iLeftColumnHeight, iRightColumnHeight);
     289    }
     290
     291    /* Is there something changed? */
     292    if (m_iMinimumTextHeight != iMinimumTextHeight)
     293    {
     294        /* Remember new value: */
     295        m_iMinimumTextHeight = iMinimumTextHeight;
     296        /* Recursively update size-hint: */
     297        updateGeometry();
    275298    }
    276299}
     
    382405void UIGDetailsElement::updateLayout()
    383406{
    384     /* Update size-hint: */
    385     updateSizeHint();
    386 
    387407    /* Prepare variables: */
    388408    QSize size = geometry().size().toSize();
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsGroup.cpp

    r44019 r44060  
    235235void UIGDetailsGroup::updateLayout()
    236236{
    237     /* Update size-hints for all the children: */
    238     foreach (UIGDetailsItem *pItem, items())
    239         pItem->updateSizeHint();
    240     /* Update size-hint for this item: */
    241     updateSizeHint();
    242 
    243237    /* Prepare variables: */
    244238    int iMargin = data(GroupData_Margin).toInt();
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsItem.cpp

    r44019 r44060  
    8585}
    8686
    87 void UIGDetailsItem::updateSizeHint()
     87void UIGDetailsItem::updateGeometry()
    8888{
    89     /* Update the geometry: */
    90     updateGeometry();
     89    /* Call to base-class: */
     90    QIGraphicsWidget::updateGeometry();
     91
     92    /* Do the same for the parent: */
     93    if (parentItem())
     94        parentItem()->updateGeometry();
    9195}
    9296
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsItem.h

    r44019 r44060  
    7777
    7878    /* API: Layout stuff: */
    79     void updateSizeHint();
     79    void updateGeometry();
    8080    virtual int minimumWidthHint() const = 0;
    8181    virtual int minimumHeightHint() const = 0;
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsSet.cpp

    r44019 r44060  
    124124            /* Show the element: */
    125125            pElement->show();
     126            /* Recursively update size-hint: */
     127            pElement->updateGeometry();
    126128            /* Update layout: */
    127129            model()->updateLayout();
     
    132134            /* Hide the element: */
    133135            pElement->hide();
     136            /* Recursively update size-hint: */
     137            updateGeometry();
    134138            /* Update layout: */
    135139            model()->updateLayout();
     
    435439void UIGDetailsSet::updateLayout()
    436440{
    437     /* Update size-hints for all the items: */
    438     foreach (UIGDetailsItem *pItem, items())
    439         pItem->updateSizeHint();
    440     /* Update size-hint for this item: */
    441     updateSizeHint();
    442 
    443441    /* Prepare variables: */
    444442    int iMargin = data(SetData_Margin).toInt();
     
    474472                /* Move element: */
    475473                pElement->setPos(iMargin, iVerticalIndent);
    476                 /* Resize element to required width: */
     474                /* Calculate required width: */
    477475                int iWidth = iMaximumWidth - 2 * iMargin;
    478476                if (pElement->elementType() == DetailsElementType_General ||
     
    481479                        if (pPreviewElement->isVisible())
    482480                            iWidth -= (iSpacing + pPreviewElement->minimumWidthHint());
     481                /* If element width is wrong: */
     482                if (pElement->geometry().width() != iWidth)
     483                {
     484                    /* Resize element to required width: */
     485                    pElement->resize(iWidth, pElement->geometry().height());
     486                    /* Update minimum-height-hint: */
     487                    pElement->updateMinimumTextHeight();
     488                }
     489                /* Acquire required height: */
    483490                int iHeight = pElement->minimumHeightHint();
    484                 pElement->resize(iWidth, iHeight);
    485                 /* Update minimum-height-hint: */
    486                 pElement->updateMinimumTextHeight();
    487                 pItem->updateSizeHint();
    488                 /* Resize element to required height: */
    489                 iHeight = pElement->minimumHeightHint();
    490                 pElement->resize(iWidth, iHeight);
     491                /* If element height is wrong: */
     492                if (pElement->geometry().height() != iHeight)
     493                {
     494                    /* Resize element to required height: */
     495                    pElement->resize(pElement->geometry().width(), iHeight);
     496                }
    491497                /* Layout element content: */
    492498                pItem->updateLayout();
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette