VirtualBox

Changeset 77827 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Mar 21, 2019 2:37:07 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9241: VirtualBox Manager: Chooser pane: Reworking group styling representation for better user experience with grouped items; this should allow to more easily distinguish existing group borders.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItem.cpp

    r77756 r77827  
    222222    , m_pParent(pParent)
    223223    , m_pNode(pNode)
    224     , m_iLevel(-1)
    225224    , m_fHovered(false)
    226225    , m_pHoveringMachine(0)
     
    394393{
    395394    return node()->position();
    396 }
    397 
    398 int UIChooserItem::level() const
    399 {
    400     /* Check whether it is specified manually: */
    401     if (m_iLevel != -1)
    402         return m_iLevel;
    403 
    404     /* Otherwise calculate ourself: */
    405     int iLevel = 0;
    406     UIChooserItem *pParentItem = parentItem();
    407     while (pParentItem && !pParentItem->isRoot())
    408     {
    409         pParentItem = pParentItem->parentItem();
    410         ++iLevel;
    411     }
    412     return iLevel;
    413 }
    414 
    415 void UIChooserItem::setLevel(int iLevel)
    416 {
    417     m_iLevel = iLevel;
    418395}
    419396
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItem.h

    r77756 r77827  
    136136        /** Returns item position. */
    137137        int position() const;
    138 
    139         /** Returns a level of item. */
    140         int level() const;
    141         /** Defines a @a iLevel of item. */
    142         void setLevel(int iLevel);
    143138
    144139        /** Returns whether item is hovered. */
     
    321316        /** Holds the node this item is built for. */
    322317        UIChooserNode *m_pNode;
    323 
    324         /** Holds the item level according to root. */
    325         int  m_iLevel;
    326318
    327319        /** Holds whether item is hovered. */
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGroup.cpp

    r77826 r77827  
    639639            int iToggleButtonHeight = m_toggleButtonSize.height();
    640640            /* Layout toggle-button: */
    641             int iToggleButtonX = iMarginHL + iParentIndent * level();;
     641            int iToggleButtonX = iMarginHL;
    642642            int iToggleButtonY = iToggleButtonHeight == iFullHeaderHeight ? iMarginV :
    643643                                 iMarginV + (iFullHeaderHeight - iToggleButtonHeight) / 2;
     
    668668        itemSize.setHeight(itemSize.height() - iPreviousVerticalIndent);
    669669        /* Adjust favorite children container: */
    670         m_pContainerFavorite->resize(itemSize.width(), m_pContainerFavorite->minimumSizeHint().height());
    671         m_pContainerFavorite->setPos(0, iPreviousVerticalIndent);
     670        m_pContainerFavorite->resize(itemSize.width() - iParentIndent, m_pContainerFavorite->minimumSizeHint().height());
     671        m_pContainerFavorite->setPos(iParentIndent, iPreviousVerticalIndent);
    672672        iPreviousVerticalIndent += m_pContainerFavorite->minimumSizeHint().height();
    673673        /* Adjust other children scroll-area: */
    674         m_pScrollArea->resize(itemSize.width(), itemSize.height() - m_pContainerFavorite->minimumSizeHint().height());
    675         m_pScrollArea->setPos(0, iPreviousVerticalIndent);
     674        m_pScrollArea->resize(itemSize.width() - iParentIndent, itemSize.height() - m_pContainerFavorite->minimumSizeHint().height());
     675        m_pScrollArea->setPos(iParentIndent, iPreviousVerticalIndent);
    676676    }
    677677
     
    12361236        case GroupItemData_HeaderSpacing:   return QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) / 2;
    12371237        case GroupItemData_ChildrenSpacing: return 1;
    1238         case GroupItemData_ParentIndent:    return QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize);
     1238        case GroupItemData_ParentIndent:    return QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) / 2;
    12391239
    12401240        /* Default: */
     
    13771377        const int iMarginHL = data(GroupItemData_MarginHL).toInt();
    13781378        const int iMarginHR = data(GroupItemData_MarginHR).toInt();
    1379         const int iParentIndent = data(GroupItemData_ParentIndent).toInt();
    13801379
    13811380        /* Basically we have to take header width into account: */
     
    13911390
    13921391        /* And 2 margins at last - left and right: */
    1393         iProposedWidth += iMarginHL + iMarginHR + iParentIndent * level();
     1392        iProposedWidth += iMarginHL + iMarginHR;
    13941393    }
    13951394
     
    16501649        pPainter->fillRect(tRect, tGradient);
    16511650
     1651        /* Calculate bottom rectangle: */
     1652        if (node()->toGroupNode()->isOpened())
     1653        {
     1654            QRect bRect = rect;
     1655            bRect.setTop(bRect.top() + iFullHeaderHeight);
     1656
     1657            /* Fill top rectangle: */
     1658            pPainter->fillRect(bRect, headerColor.darker(headerDarkness()));
     1659        }
     1660
    16521661        /* Paint drag token UP? */
    16531662        if (dragTokenPlace() != UIChooserItemDragToken_Off)
     
    16881697    /* Prepare variables: */
    16891698    const int iMarginV = data(GroupItemData_MarginV).toInt();
     1699    const int iParentIndent = data(GroupItemData_ParentIndent).toInt();
    16901700    const int iFullHeaderHeight = 2 * iMarginV + m_minimumHeaderSize.height();
    16911701
     
    17071717
    17081718    /* Draw borders: */
    1709     pPainter->drawLine(topRect.bottomLeft(), topRect.bottomRight() + QPoint(1, 0));
    1710     pPainter->drawLine(topRect.topLeft(),    topRect.bottomLeft());
     1719    if (node()->hasNodes() && node()->toGroupNode()->isOpened())
     1720        pPainter->drawLine(topRect.bottomLeft() + QPoint(iParentIndent, 0), topRect.bottomRight() + QPoint(1, 0));
     1721    else
     1722        pPainter->drawLine(topRect.bottomLeft(), topRect.bottomRight() + QPoint(1, 0));
     1723    pPainter->drawLine(rectangle.topLeft(), rectangle.bottomLeft());
    17111724
    17121725    /* Restore painter: */
     
    17251738    const int iMarginV = data(GroupItemData_MarginV).toInt();
    17261739    const int iHeaderSpacing = data(GroupItemData_HeaderSpacing).toInt();
    1727     const int iParentIndent = data(GroupItemData_ParentIndent).toInt();
    17281740    const int iFullHeaderHeight = m_minimumHeaderSize.height();
    17291741
     
    17341746
    17351747    /* Paint name: */
    1736     int iNameX = iMarginHL + iParentIndent * level();
     1748    int iNameX = iMarginHL;
    17371749    if (isRoot())
    17381750        iNameX += m_exitButtonSize.width();
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemMachine.cpp

    r77826 r77827  
    285285    const int iMajorSpacing = data(MachineItemData_MajorSpacing).toInt();
    286286    const int iMinorSpacing = data(MachineItemData_MinorSpacing).toInt();
    287     const int iParentIndent = data(MachineItemData_ParentIndent).toInt();
    288287    const int iButtonMargin = data(MachineItemData_ButtonMargin).toInt();
    289288
     
    292291
    293292    /* Two margins: */
    294     iProposedWidth += iMarginHL + iMarginHR + iParentIndent * level();
     293    iProposedWidth += iMarginHL + iMarginHR;
    295294    /* And machine-item content to take into account: */
    296295    int iTopLineWidth = m_iMinimumNameWidth;
     
    573572        case MachineItemData_MinorSpacing: return QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) / 4;
    574573        case MachineItemData_TextSpacing:  return 0;
    575         case MachineItemData_ParentIndent: return QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize);
    576574        case MachineItemData_ButtonMargin: return QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) / 4;
    577575
     
    667665    const int iMarginHR = data(MachineItemData_MarginHR).toInt();
    668666    const int iMajorSpacing = data(MachineItemData_MajorSpacing).toInt();
    669     const int iParentIndent = data(MachineItemData_ParentIndent).toInt();
    670667    const int iButtonMargin = data(MachineItemData_ButtonMargin).toInt();
    671668
    672669    /* Calculate new maximum width for the first row: */
    673670    int iFirstRowMaximumWidth = (int)geometry().width();
    674     iFirstRowMaximumWidth -= iParentIndent * level();
    675671    iFirstRowMaximumWidth -= iMarginHL; /* left margin */
    676672    iFirstRowMaximumWidth -= m_pixmapSize.width(); /* left pixmap width */
     
    10311027    const int iMinorSpacing = data(MachineItemData_MinorSpacing).toInt();
    10321028    const int iMachineItemTextSpacing = data(MachineItemData_TextSpacing).toInt();
    1033     const int iParentIndent = data(MachineItemData_ParentIndent).toInt();
    10341029    const int iButtonMargin = data(MachineItemData_ButtonMargin).toInt();
    10351030
     
    10481043
    10491044    /* Calculate indents: */
    1050     int iLeftColumnIndent = iMarginHL + iParentIndent * level();
     1045    int iLeftColumnIndent = iMarginHL;
    10511046
    10521047    /* Paint left column: */
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemMachine.h

    r77805 r77827  
    185185        MachineItemData_MinorSpacing,
    186186        MachineItemData_TextSpacing,
    187         MachineItemData_ParentIndent,
    188187        MachineItemData_ButtonMargin,
    189188        /* Pixmaps: */
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