VirtualBox

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


Ignore:
Timestamp:
Aug 21, 2017 9:31:21 AM (7 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:8900: UITabBar: Extend with API to define position style (like Left, Right, Middle, Single item).

Location:
trunk/src/VBox/Frontends/VirtualBox/src/widgets
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UITabBar.cpp

    r68304 r68480  
    8181public:
    8282
     83    /** Position styles. */
     84    enum PositionStyle { PositionStyle_Left, PositionStyle_Middle, PositionStyle_Right, PositionStyle_Single };
     85
    8386    /** Holds the mime-type for the D&D system. */
    8487    static const QString MimeType;
     
    9396    /** Returns item name. */
    9497    const QString name() const { return m_strName; }
     98
     99    /** Defines the item @a enmPositionStyle. */
     100    void setPositionStyle(PositionStyle enmPositionStyle);
    95101
    96102    /** Marks item @a fCurrent. */
     
    130136    QString      m_strName;
    131137
     138    /** Holds the item position style. */
     139    PositionStyle m_enmPosition;
     140
    132141    /** Holds whether the item is current. */
    133142    bool  m_fCurrent;
     
    165174    , m_icon(icon)
    166175    , m_strName(strName)
     176    , m_enmPosition(PositionStyle_Single)
    167177    , m_fCurrent(false)
    168178    , m_fHovered(false)
     
    177187    /* Prepare: */
    178188    prepare();
     189}
     190
     191void UITabBarItem::setPositionStyle(PositionStyle enmPosition)
     192{
     193    /* Remember the position: */
     194    m_enmPosition = enmPosition;
     195
     196    /* And call for repaint: */
     197    update();
    179198}
    180199
     
    475494        m_pLayoutTab->insertWidget(0, pItem);
    476495        m_aItems.prepend(pItem);
     496        /* Update children styles: */
     497        updateChildrenStyles();
    477498        /* Return unique ID: */
    478499        return uuid;
     
    514535            sltHandleMakeChildCurrent(m_aItems.first());
    515536    }
     537
     538    /* Update children styles: */
     539    updateChildrenStyles();
    516540
    517541    /* Return result: */
     
    687711    m_aItems.insert(iPosition, pItemDropped);
    688712    m_pLayoutTab->insertWidget(iPosition, pItemDropped);
     713
     714    /* Update children styles: */
     715    updateChildrenStyles();
    689716}
    690717
     
    756783}
    757784
     785void UITabBar::updateChildrenStyles()
     786{
     787    /* Single child has corresponding (rounded) style: */
     788    if (m_aItems.size() == 1)
     789        m_aItems.first()->setPositionStyle(UITabBarItem::PositionStyle_Single);
     790    /* If there are more than one child: */
     791    else if (m_aItems.size() > 1)
     792    {
     793        /* First make all children have no rounded sides: */
     794        foreach (UITabBarItem *pItem, m_aItems)
     795            pItem->setPositionStyle(UITabBarItem::PositionStyle_Middle);
     796        /* Then make first child rounded left, while last rounded right: */
     797        m_aItems.first()->setPositionStyle(UITabBarItem::PositionStyle_Left);
     798        m_aItems.last()->setPositionStyle(UITabBarItem::PositionStyle_Right);
     799    }
     800    /* Repaint: */
     801    update();
     802}
     803
    758804#include "UITabBar.moc"
    759805
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UITabBar.h

    r68304 r68480  
    100100    void prepare();
    101101
     102    /** Updates children styles. */
     103    void updateChildrenStyles();
     104
    102105    /** @name Contents: Widgets
    103106      * @{ */
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