VirtualBox

Ignore:
Timestamp:
Nov 26, 2012 8:46:58 AM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
82297
Message:

FE/Qt: VM group UI: Chooser-view: Machine-item layout management rework.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItem.cpp

    r43885 r43955  
    157157void UIGChooserItem::updateGeometry()
    158158{
     159    /* Call to base-class: */
    159160    QIGraphicsWidget::updateGeometry();
     161
     162    /* Update parent's geometry: */
     163    if (parentItem())
     164        parentItem()->updateGeometry();
    160165}
    161166
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemGroup.cpp

    r43954 r43955  
    930930}
    931931
    932 void UIGChooserItemGroup::updateGeometry()
    933 {
    934     /* Call to base-class: */
    935     UIGChooserItem::updateGeometry();
    936 
    937     /* Update parent's geometry: */
    938     if (parentItem())
    939         parentItem()->updateGeometry();
    940 }
    941 
    942932void UIGChooserItemGroup::updateLayout()
    943933{
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemGroup.h

    r43954 r43955  
    146146
    147147    /* Helpers: Layout stuff: */
    148     void updateGeometry();
    149148    void updateLayout();
    150149    int minimumWidthHint(bool fOpenedGroup) const;
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.cpp

    r43887 r43955  
    208208    /* First row update required? */
    209209    bool fFirstRowUpdateRequired = false;
     210    bool fSecondRowUpdateRequired = false;
    210211
    211212    /* Update pixmap: */
    212213    QIcon icon = osIcon();
    213214    QSize iconSize = icon.availableSizes().first();
    214     m_pixmap = icon.pixmap(iconSize);
     215    QPixmap pixmap = icon.pixmap(iconSize);
     216    if (m_pixmap.toImage() != pixmap.toImage())
     217    {
     218        m_pixmap = pixmap;
     219        update();
     220    }
    215221    if (m_pixmapSize != iconSize)
    216222    {
     
    223229    QSize stateIconSize = stateIcon.availableSizes().first();
    224230    m_statePixmap = stateIcon.pixmap(stateIconSize);
     231    QPixmap statePixmap = icon.pixmap(stateIconSize);
     232    if (m_statePixmap.toImage() != statePixmap.toImage())
     233    {
     234        m_statePixmap = statePixmap;
     235        update();
     236    }
    225237    if (m_statePixmapSize != stateIconSize)
    226238    {
    227239        m_statePixmapSize = stateIconSize;
     240        fSecondRowUpdateRequired = true;
    228241    }
    229242
    230243    /* Update linked values: */
     244    if (fFirstRowUpdateRequired || fSecondRowUpdateRequired)
     245        updateGeometry();
    231246    if (fFirstRowUpdateRequired)
    232247        updateFirstRowMaximumWidth();
     
    297312    QFontMetrics fm(m_nameFont, pPaintDevice);
    298313    m_iMinimumNameWidth = fm.width(compressText(m_nameFont, pPaintDevice, m_strName, textWidth(m_nameFont, pPaintDevice, 15)));
     314
     315    /* Update linked values: */
     316    updateGeometry();
    299317}
    300318
     
    317335    }
    318336
    319     /* Calculate linked values: */
     337    /* Update linked values: */
     338    updateGeometry();
    320339    updateMaximumNameWidth();
    321340}
     
    347366    m_strVisibleName = compressText(m_nameFont, pPaintDevice, m_strName, m_iMaximumNameWidth);
    348367    m_visibleNameSize = textSize(m_nameFont, pPaintDevice, m_strVisibleName);
     368
     369    /* Update linked values: */
     370    updateGeometry();
     371    updateMaximumSnapshotNameWidth();
    349372    update();
    350 
    351     /* Update linked values: */
    352     updateMaximumSnapshotNameWidth();
    353373}
    354374
     
    364384    m_strVisibleSnapshotName = QString("(%1)").arg(strVisibleSnapshotName);
    365385    m_visibleSnapshotNameSize = textSize(m_snapshotNameFont, pPaintDevice, m_strVisibleSnapshotName);
     386
     387    /* Update linked values: */
     388    updateGeometry();
    366389    update();
    367390}
     
    369392void UIGChooserItemMachine::updateStateText()
    370393{
     394    /* Something changed? */
     395    QString strStateText = machineStateName();
     396    if (m_strStateText == strStateText)
     397        return;
     398
    371399    /* Update state text: */
    372     m_strStateText = machineStateName();
     400    m_strStateText = strStateText;
    373401    m_stateTextSize = textSize(m_stateTextFont, model()->paintDevice(), m_strStateText);
     402
     403    /* Update linked values: */
     404    updateGeometry();
    374405    update();
    375406}
     
    439470    updateStateText();
    440471    updateToolTip();
    441     update();
    442472
    443473    /* Update parent group-item: */
     
    493523void UIGChooserItemMachine::updateLayout()
    494524{
    495     /* Update size-hint for this item: */
    496     updateGeometry();
    497 
    498525    /* Update tool-bar: */
    499526    if (m_pToolBar)
     
    529556    int iMachineItemMajorSpacing = data(MachineItemData_MajorSpacing).toInt();
    530557    int iMachineItemMinorSpacing = data(MachineItemData_MinorSpacing).toInt();
    531     int iMachinePixmapWidth = m_pixmapSize.width();
    532     int iMachineStatePixmapWidth = m_statePixmapSize.width();
    533     int iMachineStateTextWidth = m_stateTextSize.width();
    534558    int iToolBarWidth = data(MachineItemData_ToolBarSize).toSize().width();
    535559
     
    543567                        iMachineItemMinorSpacing +
    544568                        m_iMinimumSnapshotNameWidth;
    545     int iBottomLineWidth = iMachineStatePixmapWidth +
     569    int iBottomLineWidth = m_statePixmapSize.width() +
    546570                           iMachineItemMinorSpacing +
    547                            iMachineStateTextWidth;
     571                           m_stateTextSize.width();
    548572    int iRightColumnWidth = qMax(iTopLineWidth, iBottomLineWidth);
    549     int iMachineItemWidth = iMachinePixmapWidth +
     573    int iMachineItemWidth = m_pixmapSize.width() +
    550574                            iMachineItemMajorSpacing +
    551575                            iRightColumnWidth;
     
    563587    int iMachineItemMargin = data(MachineItemData_Margin).toInt();
    564588    int iMachineItemTextSpacing = data(MachineItemData_TextSpacing).toInt();
    565     int iMachinePixmapHeight = m_pixmapSize.height();
    566     int iMachineNameHeight = m_visibleNameSize.height();
    567     int iSnapshotNameHeight = m_visibleSnapshotNameSize.height();
    568     int iMachineStatePixmapHeight = m_statePixmapSize.height();
    569     int iMachineStateTextHeight = m_stateTextSize.height();
    570589    int iToolBarHeight = data(MachineItemData_ToolBarSize).toSize().height();
    571590
     
    576595    iProposedHeight += 2 * iMachineItemMargin;
    577596    /* And machine-item content to take into account: */
    578     int iTopLineHeight = qMax(iMachineNameHeight, iSnapshotNameHeight);
    579     int iBottomLineHeight = qMax(iMachineStatePixmapHeight, iMachineStateTextHeight);
     597    int iTopLineHeight = qMax(m_visibleNameSize.height(), m_visibleSnapshotNameSize.height());
     598    int iBottomLineHeight = qMax(m_statePixmapSize.height(), m_stateTextSize.height());
    580599    int iRightColumnHeight = iTopLineHeight +
    581                               iMachineItemTextSpacing +
    582                               iBottomLineHeight;
     600                             iMachineItemTextSpacing +
     601                             iBottomLineHeight;
    583602    QList<int> heights;
    584     heights << iMachinePixmapHeight << iRightColumnHeight << iToolBarHeight;
     603    heights << m_pixmapSize.height() << iRightColumnHeight << iToolBarHeight;
    585604    int iMaxHeight = 0;
    586605    foreach (int iHeight, heights)
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