VirtualBox

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


Ignore:
Timestamp:
Nov 28, 2012 3:08:01 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
82361
Message:

FE/Qt: VM group UI: Details-view: Some code reordering.

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

    r43985 r43987  
    352352}
    353353
     354int UIGDetailsElement::minimumHeightHint(bool fClosed) const
     355{
     356    /* Prepare variables: */
     357    int iMargin = data(ElementData_Margin).toInt();
     358    int iProposedHeight = 0;
     359
     360    /* Two margins: */
     361    iProposedHeight += 2 * iMargin;
     362
     363    /* Header height: */
     364    iProposedHeight += m_iMinimumHeaderHeight;
     365
     366    /* Element is opened? */
     367    if (!fClosed)
     368    {
     369        /* Add text height: */
     370        if (!m_text.isEmpty())
     371            iProposedHeight += 2 * iMargin + m_iMinimumTextHeight;
     372    }
     373
     374    /* Additional height during animation: */
     375    if (m_fAnimationRunning)
     376        iProposedHeight += m_iAdditionalHeight;
     377
     378    /* Return value: */
     379    return iProposedHeight;
     380}
     381
     382QSizeF UIGDetailsElement::sizeHint(Qt::SizeHint which, const QSizeF &constraint /* = QSizeF() */) const
     383{
     384    /* If Qt::MinimumSize requested: */
     385    if (which == Qt::MinimumSize || which == Qt::PreferredSize)
     386    {
     387        /* Return wrappers: */
     388        return QSizeF(minimumWidthHint(), minimumHeightHint());
     389    }
     390
     391    /* Call to base-class: */
     392    return UIGDetailsItem::sizeHint(which, constraint);
     393}
     394
     395void UIGDetailsElement::updateLayout()
     396{
     397    /* Update size-hint: */
     398    updateSizeHint();
     399
     400    /* Prepare variables: */
     401    QSize size = geometry().size().toSize();
     402    int iMargin = data(ElementData_Margin).toInt();
     403    int iButtonWidth = m_buttonSize.width();
     404    int iButtonHeight = m_buttonSize.height();
     405
     406    /* Layout button: */
     407    int iButtonX = size.width() - 2 * iMargin - iButtonWidth;
     408    int iButtonY = iButtonHeight == m_iMinimumHeaderHeight ? iMargin :
     409                   iMargin + (m_iMinimumHeaderHeight - iButtonHeight) / 2;
     410    m_pButton->setPos(iButtonX, iButtonY);
     411}
     412
     413void UIGDetailsElement::setAdditionalHeight(int iAdditionalHeight)
     414{
     415    /* Cache new value: */
     416    m_iAdditionalHeight = iAdditionalHeight;
     417    /* Update layout: */
     418    updateLayout();
     419    /* Repaint: */
     420    update();
     421}
     422
    354423void UIGDetailsElement::addItem(UIGDetailsItem*)
    355424{
     
    430499    connect(m_pButton, SIGNAL(sigRotationFinish(bool)), this, SLOT(sltElementToggleFinish(bool)));
    431500    m_buttonSize = m_pButton->minimumSizeHint().toSize();
    432 }
    433 
    434 void UIGDetailsElement::updateLayout()
    435 {
    436     /* Update size-hint: */
    437     updateSizeHint();
    438 
    439     /* Prepare variables: */
    440     QSize size = geometry().size().toSize();
    441     int iMargin = data(ElementData_Margin).toInt();
    442     int iButtonWidth = m_buttonSize.width();
    443     int iButtonHeight = m_buttonSize.height();
    444 
    445     /* Layout button: */
    446     int iButtonX = size.width() - 2 * iMargin - iButtonWidth;
    447     int iButtonY = iButtonHeight == m_iMinimumHeaderHeight ? iMargin :
    448                    iMargin + (m_iMinimumHeaderHeight - iButtonHeight) / 2;
    449     m_pButton->setPos(iButtonX, iButtonY);
    450 }
    451 
    452 void UIGDetailsElement::setAdditionalHeight(int iAdditionalHeight)
    453 {
    454     /* Cache new value: */
    455     m_iAdditionalHeight = iAdditionalHeight;
    456     /* Update layout: */
    457     updateLayout();
    458     /* Repaint: */
    459     update();
    460 }
    461 
    462 int UIGDetailsElement::minimumHeightHint(bool fClosed) const
    463 {
    464     /* Prepare variables: */
    465     int iMargin = data(ElementData_Margin).toInt();
    466     int iProposedHeight = 0;
    467 
    468     /* Two margins: */
    469     iProposedHeight += 2 * iMargin;
    470 
    471     /* Header height: */
    472     iProposedHeight += m_iMinimumHeaderHeight;
    473 
    474     /* Element is opened? */
    475     if (!fClosed)
    476     {
    477         /* Add text height: */
    478         if (!m_text.isEmpty())
    479             iProposedHeight += 2 * iMargin + m_iMinimumTextHeight;
    480     }
    481 
    482     /* Additional height during animation: */
    483     if (m_fAnimationRunning)
    484         iProposedHeight += m_iAdditionalHeight;
    485 
    486     /* Return value: */
    487     return iProposedHeight;
    488 }
    489 
    490 QSizeF UIGDetailsElement::sizeHint(Qt::SizeHint which, const QSizeF &constraint /* = QSizeF() */) const
    491 {
    492     /* If Qt::MinimumSize requested: */
    493     if (which == Qt::MinimumSize || which == Qt::PreferredSize)
    494     {
    495         /* Return wrappers: */
    496         return QSizeF(minimumWidthHint(), minimumHeightHint());
    497     }
    498 
    499     /* Call to base-class: */
    500     return UIGDetailsItem::sizeHint(which, constraint);
    501501}
    502502
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.h

    r43985 r43987  
    137137    int minimumHeaderWidth() const { return m_iMinimumHeaderWidth; }
    138138    int minimumHeaderHeight() const { return m_iMinimumHeaderHeight; }
     139    virtual int minimumHeightHint(bool fClosed) const;
     140    QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
    139141    void updateLayout();
    140142
     
    161163    void prepareElement();
    162164    void prepareButton();
    163 
    164     /* Helpers: Layout stuff: */
    165     virtual int minimumHeightHint(bool fClosed) const;
    166     QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
    167165
    168166    /* Helpers: Paint stuff: */
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsGroup.cpp

    r43982 r43987  
    214214void UIGDetailsGroup::prepareSets(const QList<UIVMItem*> &items)
    215215{
    216     /* Remove superflous sets: */
     216    /* Cleanup superflous sets: */
    217217    while (m_sets.size() > items.size())
    218218        delete m_sets.last();
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsSet.cpp

    r43985 r43987  
    253253        return pItem->toElement();
    254254    return 0;
     255}
     256
     257int UIGDetailsSet::minimumWidthHint() const
     258{
     259    /* Prepare variables: */
     260    int iMargin = data(SetData_Margin).toInt();
     261    int iSpacing = data(SetData_Spacing).toInt();
     262    int iProposedWidth = 0;
     263
     264    /* Layout all the elements: */
     265    foreach (UIGDetailsItem *pItem, items())
     266    {
     267        /* Get particular element: */
     268        UIGDetailsElement *pElement = pItem->toElement();
     269        if (!pElement->isVisible())
     270            continue;
     271
     272        /* For each particular element: */
     273        switch (pElement->elementType())
     274        {
     275            case DetailsElementType_General:
     276            case DetailsElementType_System:
     277            case DetailsElementType_Display:
     278            case DetailsElementType_Storage:
     279            case DetailsElementType_Audio:
     280            case DetailsElementType_Network:
     281            case DetailsElementType_Serial:
     282#ifdef VBOX_WITH_PARALLEL_PORTS
     283            case DetailsElementType_Parallel:
     284#endif /* VBOX_WITH_PARALLEL_PORTS */
     285            case DetailsElementType_USB:
     286            case DetailsElementType_SF:
     287            case DetailsElementType_Description:
     288            {
     289                iProposedWidth = qMax(iProposedWidth, pElement->minimumWidthHint());
     290                break;
     291            }
     292            case DetailsElementType_Preview:
     293            {
     294                UIGDetailsElement *pGeneralElement = element(DetailsElementType_General);
     295                UIGDetailsElement *pSystemElement = element(DetailsElementType_System);
     296                int iGeneralElementWidth = pGeneralElement ? pGeneralElement->minimumWidthHint() : 0;
     297                int iSystemElementWidth = pSystemElement ? pSystemElement->minimumWidthHint() : 0;
     298                int iFirstColumnWidth = qMax(iGeneralElementWidth, iSystemElementWidth);
     299                iProposedWidth = qMax(iProposedWidth, iFirstColumnWidth + iSpacing + pElement->minimumWidthHint());
     300                break;
     301            }
     302        }
     303    }
     304
     305    /* Two margins finally: */
     306    iProposedWidth += 2 * iMargin;
     307
     308    /* Return result: */
     309    return iProposedWidth;
     310}
     311
     312int UIGDetailsSet::minimumHeightHint() const
     313{
     314    /* Prepare variables: */
     315    int iMargin = data(SetData_Margin).toInt();
     316    int iSpacing = data(SetData_Spacing).toInt();
     317    int iProposedHeight = 0;
     318
     319    /* Layout all the elements: */
     320    foreach (UIGDetailsItem *pItem, items())
     321    {
     322        /* Get particular element: */
     323        UIGDetailsElement *pElement = pItem->toElement();
     324        if (!pElement->isVisible())
     325            continue;
     326
     327        /* For each particular element: */
     328        switch (pElement->elementType())
     329        {
     330            case DetailsElementType_General:
     331            case DetailsElementType_System:
     332            case DetailsElementType_Display:
     333            case DetailsElementType_Storage:
     334            case DetailsElementType_Audio:
     335            case DetailsElementType_Network:
     336            case DetailsElementType_Serial:
     337#ifdef VBOX_WITH_PARALLEL_PORTS
     338            case DetailsElementType_Parallel:
     339#endif /* VBOX_WITH_PARALLEL_PORTS */
     340            case DetailsElementType_USB:
     341            case DetailsElementType_SF:
     342            case DetailsElementType_Description:
     343            {
     344                iProposedHeight += (pElement->minimumHeightHint() + iSpacing);
     345                break;
     346            }
     347            case DetailsElementType_Preview:
     348            {
     349                iProposedHeight = qMax(iProposedHeight, pElement->minimumHeightHint() + iSpacing);
     350                break;
     351            }
     352        }
     353    }
     354
     355    /* Minus last spacing: */
     356    iProposedHeight -= iSpacing;
     357
     358    /* Two margins finally: */
     359    iProposedHeight += 2 * iMargin;
     360
     361    /* Return result: */
     362    return iProposedHeight;
     363}
     364
     365QSizeF UIGDetailsSet::sizeHint(Qt::SizeHint which, const QSizeF &constraint /* = QSizeF() */) const
     366{
     367    /* If Qt::MinimumSize requested: */
     368    if (which == Qt::MinimumSize || which == Qt::PreferredSize)
     369    {
     370        /* Return wrappers: */
     371        return QSizeF(minimumWidthHint(), minimumHeightHint());
     372    }
     373
     374    /* Call to base-class: */
     375    return UIGDetailsItem::sizeHint(which, constraint);
    255376}
    256377
     
    341462}
    342463
    343 int UIGDetailsSet::minimumWidthHint() const
    344 {
    345     /* Prepare variables: */
    346     int iMargin = data(SetData_Margin).toInt();
    347     int iSpacing = data(SetData_Spacing).toInt();
    348     int iProposedWidth = 0;
    349 
    350     /* Layout all the elements: */
    351     foreach (UIGDetailsItem *pItem, items())
    352     {
    353         /* Get particular element: */
    354         UIGDetailsElement *pElement = pItem->toElement();
    355         if (!pElement->isVisible())
    356             continue;
    357 
    358         /* For each particular element: */
    359         switch (pElement->elementType())
    360         {
    361             case DetailsElementType_General:
    362             case DetailsElementType_System:
    363             case DetailsElementType_Display:
    364             case DetailsElementType_Storage:
    365             case DetailsElementType_Audio:
    366             case DetailsElementType_Network:
    367             case DetailsElementType_Serial:
    368 #ifdef VBOX_WITH_PARALLEL_PORTS
    369             case DetailsElementType_Parallel:
    370 #endif /* VBOX_WITH_PARALLEL_PORTS */
    371             case DetailsElementType_USB:
    372             case DetailsElementType_SF:
    373             case DetailsElementType_Description:
    374             {
    375                 iProposedWidth = qMax(iProposedWidth, pElement->minimumWidthHint());
    376                 break;
    377             }
    378             case DetailsElementType_Preview:
    379             {
    380                 UIGDetailsElement *pGeneralElement = element(DetailsElementType_General);
    381                 UIGDetailsElement *pSystemElement = element(DetailsElementType_System);
    382                 int iGeneralElementWidth = pGeneralElement ? pGeneralElement->minimumWidthHint() : 0;
    383                 int iSystemElementWidth = pSystemElement ? pSystemElement->minimumWidthHint() : 0;
    384                 int iFirstColumnWidth = qMax(iGeneralElementWidth, iSystemElementWidth);
    385                 iProposedWidth = qMax(iProposedWidth, iFirstColumnWidth + iSpacing + pElement->minimumWidthHint());
    386                 break;
    387             }
    388         }
    389     }
    390 
    391     /* Two margins finally: */
    392     iProposedWidth += 2 * iMargin;
    393 
    394     /* Return result: */
    395     return iProposedWidth;
    396 }
    397 
    398 int UIGDetailsSet::minimumHeightHint() const
    399 {
    400     /* Prepare variables: */
    401     int iMargin = data(SetData_Margin).toInt();
    402     int iSpacing = data(SetData_Spacing).toInt();
    403     int iProposedHeight = 0;
    404 
    405     /* Layout all the elements: */
    406     foreach (UIGDetailsItem *pItem, items())
    407     {
    408         /* Get particular element: */
    409         UIGDetailsElement *pElement = pItem->toElement();
    410         if (!pElement->isVisible())
    411             continue;
    412 
    413         /* For each particular element: */
    414         switch (pElement->elementType())
    415         {
    416             case DetailsElementType_General:
    417             case DetailsElementType_System:
    418             case DetailsElementType_Display:
    419             case DetailsElementType_Storage:
    420             case DetailsElementType_Audio:
    421             case DetailsElementType_Network:
    422             case DetailsElementType_Serial:
    423 #ifdef VBOX_WITH_PARALLEL_PORTS
    424             case DetailsElementType_Parallel:
    425 #endif /* VBOX_WITH_PARALLEL_PORTS */
    426             case DetailsElementType_USB:
    427             case DetailsElementType_SF:
    428             case DetailsElementType_Description:
    429             {
    430                 iProposedHeight += (pElement->minimumHeightHint() + iSpacing);
    431                 break;
    432             }
    433             case DetailsElementType_Preview:
    434             {
    435                 iProposedHeight = qMax(iProposedHeight, pElement->minimumHeightHint() + iSpacing);
    436                 break;
    437             }
    438         }
    439     }
    440 
    441     /* Minus last spacing: */
    442     iProposedHeight -= iSpacing;
    443 
    444     /* Two margins finally: */
    445     iProposedHeight += 2 * iMargin;
    446 
    447     /* Return result: */
    448     return iProposedHeight;
    449 }
    450 
    451 QSizeF UIGDetailsSet::sizeHint(Qt::SizeHint which, const QSizeF &constraint /* = QSizeF() */) const
    452 {
    453     /* If Qt::MinimumSize requested: */
    454     if (which == Qt::MinimumSize || which == Qt::PreferredSize)
    455     {
    456         /* Return wrappers: */
    457         return QSizeF(minimumWidthHint(), minimumHeightHint());
    458     }
    459 
    460     /* Call to base-class: */
    461     return UIGDetailsItem::sizeHint(which, constraint);
    462 }
    463 
    464464void UIGDetailsSet::prepareElements()
    465465{
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsSet.h

    r42863 r43987  
    9696
    9797    /* Helpers: Layout stuff: */
    98     void updateLayout();
    9998    int minimumWidthHint() const;
    10099    int minimumHeightHint() const;
    101100    QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
     101    void updateLayout();
    102102
    103103    /* Helpers: Prepare stuff: */
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