VirtualBox

Changeset 43847 in vbox


Ignore:
Timestamp:
Nov 9, 2012 11:50:23 AM (12 years ago)
Author:
vboxsync
Message:

FE/Qt: VM group UI: Caching pixmap sizes for group-item.

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

Legend:

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

    r43846 r43847  
    379379        case GroupItemData_MinorSpacing: return 3;
    380380        case GroupItemData_RootIndent: return 2;
    381         /* Sizes: */
    382         case GroupItemData_ToggleButtonSize: return m_pToggleButton ? m_pToggleButton->minimumSizeHint().toSize() : QSize(0, 0);
    383         case GroupItemData_EnterButtonSize: return m_pEnterButton ? m_pEnterButton->minimumSizeHint().toSize() : QSize(0, 0);
    384         case GroupItemData_ExitButtonSize: return m_pExitButton ? m_pExitButton->minimumSizeHint().toSize() : QSize(0, 0);
    385         case GroupItemData_GroupPixmapSize: return isMainRoot() ? QSize(0, 0) : m_groupsPixmap.size();
    386         case GroupItemData_MachinePixmapSize: return isMainRoot() ? QSize(0, 0) : m_machinesPixmap.size();
    387         case GroupItemData_FullHeaderSize: return m_headerSize;
     381
    388382        /* Default: */
    389383        default: break;
     
    410404    m_groupsPixmap = QPixmap(":/nw_16px.png");
    411405    m_machinesPixmap = QPixmap(":/machine_16px.png");
     406    m_pixmapSizeGroups = m_groupsPixmap.size();
     407    m_pixmapSizeMachines = m_machinesPixmap.size();
    412408
    413409    /* Items except roots: */
     
    444440        m_pExitButton->hide();
    445441    }
     442
     443    /* Button sizes: */
     444    m_toggleButtonSize = m_pToggleButton ? m_pToggleButton->minimumSizeHint().toSize() : QSize(0, 0);
     445    m_enterButtonSize = m_pEnterButton ? m_pEnterButton->minimumSizeHint().toSize() : QSize(0, 0);
     446    m_exitButtonSize = m_pExitButton ? m_pExitButton->minimumSizeHint().toSize() : QSize(0, 0);
    446447}
    447448
     
    476477    int iMinorSpacing = data(GroupItemData_MinorSpacing).toInt();
    477478    int iRootIndent = data(GroupItemData_RootIndent).toInt();
    478     int iToggleButtonWidth = data(GroupItemData_ToggleButtonSize).toSize().width();
    479     int iEnterButtonWidth = data(GroupItemData_EnterButtonSize).toSize().width();
    480     int iExitButtonWidth = data(GroupItemData_ExitButtonSize).toSize().width();
    481     int iGroupPixmapWidth = data(GroupItemData_GroupPixmapSize).toSize().width();
    482     int iMachinePixmapWidth = data(GroupItemData_MachinePixmapSize).toSize().width();
     479    int iToggleButtonWidth = m_toggleButtonSize.width();
     480    int iEnterButtonWidth = m_enterButtonSize.width();
     481    int iExitButtonWidth = m_exitButtonSize.width();
     482    int iGroupPixmapWidth = m_pixmapSizeGroups.width();
     483    int iMachinePixmapWidth = m_pixmapSizeMachines.width();
    483484    int iGroupCountTextWidth = m_infoSizeGroups.width();
    484485    int iMachineCountTextWidth = m_infoSizeMachines.width();
     
    546547    int iMajorSpacing = data(GroupItemData_MajorSpacing).toInt();
    547548    int iMinorSpacing = data(GroupItemData_MinorSpacing).toInt();
    548     QSize exitButtonSize = data(GroupItemData_ExitButtonSize).toSize();
    549     QSize toggleButtonSize = data(GroupItemData_ToggleButtonSize).toSize();
    550     QSize groupPixmapSize = data(GroupItemData_GroupPixmapSize).toSize();
    551     QSize machinePixmapSize = data(GroupItemData_MachinePixmapSize).toSize();
    552     QSize enterButtonSize = data(GroupItemData_EnterButtonSize).toSize();
    553549
    554550    /* Calculate minimum visible name size: */
     
    564560    /* Button width: */
    565561    if (isRoot())
    566         iHeaderWidth += exitButtonSize.width();
     562        iHeaderWidth += m_exitButtonSize.width();
    567563    else
    568         iHeaderWidth += toggleButtonSize.width();
     564        iHeaderWidth += m_toggleButtonSize.width();
    569565    iHeaderWidth += /* Spacing between button and name: */
    570566                    iMajorSpacing +
     
    575571    /* Group info width: */
    576572    if (!m_groupItems.isEmpty())
    577         iHeaderWidth += (groupPixmapSize.width() + m_infoSizeGroups.width());
     573        iHeaderWidth += (m_pixmapSizeGroups.width() + m_infoSizeGroups.width());
    578574    /* Machine info width: */
    579575    if (!m_machineItems.isEmpty())
    580         iHeaderWidth += (machinePixmapSize.width() + m_infoSizeMachines.width());
     576        iHeaderWidth += (m_pixmapSizeMachines.width() + m_infoSizeMachines.width());
    581577    /* Spacing + button width: */
    582578    if (!isRoot())
    583         iHeaderWidth += (iMinorSpacing + enterButtonSize.width());
     579        iHeaderWidth += (iMinorSpacing + m_enterButtonSize.width());
    584580
    585581    /* Search for maximum height: */
     
    587583    /* Button height: */
    588584    if (isRoot())
    589         heights << exitButtonSize.height();
     585        heights << m_exitButtonSize.height();
    590586    else
    591         heights << toggleButtonSize.height();
     587        heights << m_toggleButtonSize.height();
    592588    heights /* Minimum name height: */
    593589            << iMinimumNameHeight
    594590            /* Group info heights: */
    595             << groupPixmapSize.height() << m_infoSizeGroups.height()
     591            << m_pixmapSizeGroups.height() << m_infoSizeGroups.height()
    596592            /* Machine info heights: */
    597             << machinePixmapSize.height() << m_infoSizeMachines.height();
     593            << m_pixmapSizeMachines.height() << m_infoSizeMachines.height();
    598594    /* Button height: */
    599595    if (!isRoot())
    600         heights << enterButtonSize.height();
     596        heights << m_enterButtonSize.height();
    601597    int iHeaderHeight = 0;
    602598    foreach (int iHeight, heights)
     
    952948    int iVerticalMargin = data(GroupItemData_VerticalMargin).toInt();
    953949    int iMinorSpacing = data(GroupItemData_MinorSpacing).toInt();
    954     int iFullHeaderHeight = data(GroupItemData_FullHeaderSize).toSize().height();
     950    int iFullHeaderHeight = m_headerSize.height();
    955951    int iRootIndent = data(GroupItemData_RootIndent).toInt();
    956952    int iPreviousVerticalIndent = 0;
     
    978974            {
    979975                /* Prepare variables: */
    980                 int iExitButtonHeight = data(GroupItemData_ExitButtonSize).toSize().height();
     976                int iExitButtonHeight = m_exitButtonSize.height();
    981977                /* Layout exit-button: */
    982978                int iExitButtonX = iHorizontalMargin + iRootIndent;
     
    995991    else
    996992    {
    997         /* Prepare variables: */
    998         QSize toggleButtonSize = data(GroupItemData_ToggleButtonSize).toSize();
    999 
    1000993        /* Hide unnecessary button: */
    1001994        if (m_pExitButton)
     
    1006999        {
    10071000            /* Prepare variables: */
    1008             int iToggleButtonHeight = toggleButtonSize.height();
     1001            int iToggleButtonHeight = m_toggleButtonSize.height();
    10091002            /* Layout toggle-button: */
    10101003            int iToggleButtonX = iHorizontalMargin;
     
    10211014            /* Prepare variables: */
    10221015            int iFullWidth = geometry().width();
    1023             QSizeF enterButtonSize = data(GroupItemData_EnterButtonSize).toSize();
    1024             int iEnterButtonWidth = enterButtonSize.width();
    1025             int iEnterButtonHeight = enterButtonSize.height();
     1016            int iEnterButtonWidth = m_enterButtonSize.width();
     1017            int iEnterButtonHeight = m_enterButtonSize.height();
    10261018            /* Layout enter-button: */
    10271019            int iEnterButtonX = iFullWidth - iHorizontalMargin - iEnterButtonWidth;
     
    10361028            /* Prepare variables: */
    10371029            int iMajorSpacing = data(GroupItemData_MajorSpacing).toInt();
    1038             int iToggleButtonWidth = toggleButtonSize.width();
     1030            int iToggleButtonWidth = m_toggleButtonSize.width();
    10391031            /* Layout name-editor: */
    10401032            int iNameEditorX = iHorizontalMargin + iToggleButtonWidth + iMajorSpacing;
     
    10891081    int iHorizontalMargin = data(GroupItemData_HorizonalMargin).toInt();
    10901082    int iRootIndent = data(GroupItemData_RootIndent).toInt();
    1091     int iFullHeaderWidth = data(GroupItemData_FullHeaderSize).toSize().width();
     1083    int iFullHeaderWidth = m_headerSize.width();
    10921084
    10931085    /* Calculating proposed width: */
     
    11211113    int iVerticalMargin = data(GroupItemData_VerticalMargin).toInt();
    11221114    int iMinorSpacing = data(GroupItemData_MinorSpacing).toInt();
    1123     int iFullHeaderHeight = data(GroupItemData_FullHeaderSize).toSize().height();
     1115    int iFullHeaderHeight = m_headerSize.height();
    11241116
    11251117    /* Calculating proposed height: */
     
    13951387    QPoint pos = pEvent->pos().toPoint();
    13961388    int iMargin = data(GroupItemData_VerticalMargin).toInt();
    1397     int iHeaderHeight = data(GroupItemData_FullHeaderSize).toSize().height();
     1389    int iHeaderHeight = m_headerSize.height();
    13981390    int iFullHeaderHeight = 2 * iMargin + iHeaderHeight;
    13991391    /* Skip if hovered part out of the header: */
     
    14591451            int iMargin = data(GroupItemData_VerticalMargin).toInt();
    14601452            int iRootIndent = data(GroupItemData_RootIndent).toInt();
    1461             int iHeaderHeight = data(GroupItemData_FullHeaderSize).toSize().height();
     1453            int iHeaderHeight = m_headerSize.height();
    14621454            int iFullHeaderHeight = 2 * iMargin + iHeaderHeight;
    14631455            QRect backgroundRect = QRect(0, 0, rect.width(), iFullHeaderHeight);
     
    14901482        /* Prepare variables: */
    14911483        int iMargin = data(GroupItemData_VerticalMargin).toInt();
    1492         int iHeaderHeight = data(GroupItemData_FullHeaderSize).toSize().height();
     1484        int iHeaderHeight = m_headerSize.height();
    14931485        int iFullHeaderHeight = 2 * iMargin + iHeaderHeight;
    14941486        int iFullHeight = rect.height();
     
    15681560    int iMajorSpacing = data(GroupItemData_MajorSpacing).toInt();
    15691561    int iRootIndent = data(GroupItemData_RootIndent).toInt();
    1570     QSize toggleButtonSize = data(GroupItemData_ToggleButtonSize).toSize();
    1571     QSize exitButtonSize = data(GroupItemData_ExitButtonSize).toSize();
    1572     int iFullHeaderHeight = data(GroupItemData_FullHeaderSize).toSize().height();
     1562    int iFullHeaderHeight = m_headerSize.height();
    15731563
    15741564    /* Update palette: */
     
    15901580    int iNameX = iHorizontalMargin;
    15911581    if (isRoot())
    1592         iNameX += iRootIndent + exitButtonSize.width();
     1582        iNameX += iRootIndent + m_exitButtonSize.width();
    15931583    else
    1594         iNameX += toggleButtonSize.width();
     1584        iNameX += m_toggleButtonSize.width();
    15951585    iNameX += iMajorSpacing;
    15961586    int iNameY = m_visibleNameSize.height() == iFullHeaderHeight ? iVerticalMargin :
     
    16161606        /* Prepare variables: */
    16171607        int iMinorSpacing = data(GroupItemData_MinorSpacing).toInt();
    1618         int iEnterButtonWidth = data(GroupItemData_EnterButtonSize).toSize().width();
    1619         QSize groupPixmapSize = data(GroupItemData_GroupPixmapSize).toSize();
    1620         QSize machinePixmapSize = data(GroupItemData_MachinePixmapSize).toSize();
     1608        int iEnterButtonWidth = m_enterButtonSize.width();
    16211609
    16221610        /* Indent: */
     
    16431631                      m_strInfoMachines);
    16441632
    1645             iHorizontalIndent -= machinePixmapSize.width();
     1633            iHorizontalIndent -= m_pixmapSizeMachines.width();
    16461634            int iMachinePixmapX = iHorizontalIndent;
    1647             int iMachinePixmapY = machinePixmapSize.height() == iFullHeaderHeight ?
    1648                                   iVerticalMargin : iVerticalMargin + (iFullHeaderHeight - machinePixmapSize.height()) / 2;
     1635            int iMachinePixmapY = m_pixmapSizeMachines.height() == iFullHeaderHeight ?
     1636                                  iVerticalMargin : iVerticalMargin + (iFullHeaderHeight - m_pixmapSizeMachines.height()) / 2;
    16491637            paintPixmap(/* Painter: */
    16501638                        pPainter,
    16511639                        /* Rectangle to paint in: */
    1652                         QRect(QPoint(iMachinePixmapX, iMachinePixmapY), machinePixmapSize),
     1640                        QRect(QPoint(iMachinePixmapX, iMachinePixmapY), m_pixmapSizeMachines),
    16531641                        /* Pixmap to paint: */
    16541642                        m_machinesPixmap);
     
    16731661                      m_strInfoGroups);
    16741662
    1675             iHorizontalIndent -= groupPixmapSize.width();
     1663            iHorizontalIndent -= m_pixmapSizeGroups.width();
    16761664            int iGroupPixmapX = iHorizontalIndent;
    1677             int iGroupPixmapY = groupPixmapSize.height() == iFullHeaderHeight ?
    1678                                 iVerticalMargin : iVerticalMargin + (iFullHeaderHeight - groupPixmapSize.height()) / 2;
     1665            int iGroupPixmapY = m_pixmapSizeGroups.height() == iFullHeaderHeight ?
     1666                                iVerticalMargin : iVerticalMargin + (iFullHeaderHeight - m_pixmapSizeGroups.height()) / 2;
    16791667            paintPixmap(/* Painter: */
    16801668                        pPainter,
    16811669                        /* Rectangle to paint in: */
    1682                         QRect(QPoint(iGroupPixmapX, iGroupPixmapY), groupPixmapSize),
     1670                        QRect(QPoint(iGroupPixmapX, iGroupPixmapY), m_pixmapSizeGroups),
    16831671                        /* Pixmap to paint: */
    16841672                        m_groupsPixmap);
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemGroup.h

    r43846 r43847  
    109109        GroupItemData_MinorSpacing,
    110110        GroupItemData_RootIndent,
    111         /* Sizes: */
    112         GroupItemData_ToggleButtonSize,
    113         GroupItemData_EnterButtonSize,
    114         GroupItemData_ExitButtonSize,
    115         GroupItemData_GroupPixmapSize,
    116         GroupItemData_MachinePixmapSize,
    117         GroupItemData_FullHeaderSize
    118111    };
    119112
     
    209202    QSize m_infoSizeGroups;
    210203    QSize m_infoSizeMachines;
     204    QSize m_pixmapSizeGroups;
     205    QSize m_pixmapSizeMachines;
    211206    QSize m_headerSize;
     207    QSize m_toggleButtonSize;
     208    QSize m_enterButtonSize;
     209    QSize m_exitButtonSize;
    212210    QFont m_nameFont;
    213211    QFont m_infoFont;
Note: See TracChangeset for help on using the changeset viewer.

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