VirtualBox

Ignore:
Timestamp:
Jul 31, 2017 3:11:13 PM (7 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:8900: UITabBar: Proper macOS layout for close-button.

File:
1 edited

Legend:

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

    r68208 r68209  
    2626# include <QLabel>
    2727# include <QPainter>
     28# ifdef VBOX_WS_MAC
     29#  include <QStackedLayout>
     30# endif
    2831# include <QStyle>
    2932# include <QToolButton>
     
    4245class QHBoxLayout;
    4346class QLabel;
     47#ifdef VBOX_WS_MAC
     48class QStackedLayout;
     49#endif
    4450class QStyle;
    4551class QToolButton;
     
    105111
    106112    /** Holds the main layout instance. */
    107     QHBoxLayout *m_pLayout;
     113    QHBoxLayout    *m_pLayout;
     114#ifdef VBOX_WS_MAC
     115    /** Holds the stacked layout instance. */
     116    QStackedLayout *m_pLayoutStacked;
     117#endif
    108118
    109119    /** Holds the icon label instance. */
     
    127137    , m_fHovered(false)
    128138    , m_pLayout(0)
     139#ifdef VBOX_WS_MAC
     140    , m_pLayoutStacked(0)
     141#endif
    129142    , m_pLabelIcon(0)
    130143    , m_pLabelName(0)
     
    151164        case QEvent::Enter:
    152165        {
     166#ifdef VBOX_WS_MAC
     167            m_pLayoutStacked->setCurrentWidget(m_pButtonClose);
     168#endif
    153169            m_fHovered = true;
    154170            update();
     
    157173        case QEvent::Leave:
    158174        {
     175#ifdef VBOX_WS_MAC
     176            m_pLayoutStacked->setCurrentWidget(m_pLabelIcon);
     177#endif
    159178            m_fHovered = false;
    160179            update();
     
    267286        const int iMargin = iMetric / 2;
    268287        const int iSpacing = iMargin / 2;
     288#ifdef VBOX_WS_MAC
     289        const int iMetricCloseButton = iMetric * 3 / 4;
     290#else
    269291        const int iMetricCloseButton = iMetric * 2 / 3;
     292#endif
    270293
    271294        /* Configure layout: */
     295#ifdef VBOX_WS_MAC
     296        m_pLayout->setContentsMargins(iMargin + iSpacing, 0, iMargin + iSpacing, 0);
     297#else
    272298        m_pLayout->setContentsMargins(iMargin + iSpacing, 0, iMargin, 0);
     299#endif
    273300        m_pLayout->setSpacing(iSpacing);
    274301
     
    301328        }
    302329
     330#ifdef VBOX_WS_MAC
     331        /* Create stacked-layout: */
     332        m_pLayoutStacked = new QStackedLayout(m_pLayout);
     333        {
     334            m_pLayoutStacked->setAlignment(Qt::AlignCenter);
     335
     336            /* Add icon-label and close-button into stacked-layout: */
     337            m_pLayoutStacked->addWidget(m_pLabelIcon);
     338            m_pLayoutStacked->addWidget(m_pButtonClose);
     339            m_pLayoutStacked->setAlignment(m_pLabelIcon, Qt::AlignCenter);
     340            m_pLayoutStacked->setAlignment(m_pButtonClose, Qt::AlignCenter);
     341
     342            /* Add stacked-layout into main-layout: */
     343            m_pLayout->addLayout(m_pLayoutStacked);
     344        }
     345
     346        /* Add name-label into main-layout: */
     347        m_pLayout->addWidget(m_pLabelName);
     348#else /* !VBOX_WS_MAC */
    303349        /* Add everything into main-layout: */
    304350        m_pLayout->addWidget(m_pLabelIcon);
    305351        m_pLayout->addWidget(m_pLabelName);
    306352        m_pLayout->addWidget(m_pButtonClose);
     353#endif /* !VBOX_WS_MAC */
    307354    }
    308355}
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