VirtualBox

Changeset 68208 in vbox


Ignore:
Timestamp:
Jul 31, 2017 3:06:46 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
117307
Message:

FE/Qt: bugref:8900: UITabBar: A bit of cleanup; Rework UITabBarItem's close-button to be QToolButton instead of QIToolButton.

File:
1 edited

Legend:

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

    r68206 r68208  
    2727# include <QPainter>
    2828# include <QStyle>
     29# include <QToolButton>
    2930
    3031/* GUI includes: */
    31 # include "QIToolButton.h"
    3232# include "UIIconPool.h"
    3333# include "UITabBar.h"
     
    4343class QLabel;
    4444class QStyle;
     45class QToolButton;
    4546
    4647
     
    104105
    105106    /** Holds the main layout instance. */
    106     QHBoxLayout  *m_pLayout;
     107    QHBoxLayout *m_pLayout;
     108
    107109    /** Holds the icon label instance. */
    108     QLabel       *m_pLabelIcon;
     110    QLabel      *m_pLabelIcon;
    109111    /** Holds the name label instance. */
    110     QLabel       *m_pLabelName;
     112    QLabel      *m_pLabelName;
    111113    /** Holds the close button instance. */
    112     QIToolButton *m_pButtonClose;
     114    QToolButton *m_pButtonClose;
    113115};
    114116
     
    147149    {
    148150        /* Update the hovered state on/off: */
    149         case QEvent::Enter: m_fHovered = true; update(); break;
    150         case QEvent::Leave: m_fHovered = false; update(); break;
     151        case QEvent::Enter:
     152        {
     153            m_fHovered = true;
     154            update();
     155            break;
     156        }
     157        case QEvent::Leave:
     158        {
     159            m_fHovered = false;
     160            update();
     161            break;
     162        }
    151163
    152164        /* Notify listeners about the item was clicked: */
    153         case QEvent::MouseButtonRelease: emit sigClicked(this); break;
     165        case QEvent::MouseButtonRelease:
     166        {
     167            emit sigClicked(this);
     168            break;
     169        }
    154170
    155171        default: break;
     
    240256void UITabBarItem::prepare()
    241257{
     258    /* Configure self: */
     259    setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
     260
    242261    /* Create main layout: */
    243262    m_pLayout = new QHBoxLayout(this);
     
    260279            /* Configure label: */
    261280            m_pLabelIcon->setPixmap(m_icon.pixmap(iMetric));
    262 
    263             /* Add into layout: */
    264             m_pLayout->addWidget(m_pLabelIcon);
    265281        }
    266282
     
    271287            /* Configure label: */
    272288            m_pLabelName->setText(m_strName);
    273 
    274             /* Add into layout: */
    275             m_pLayout->addWidget(m_pLabelName);
    276289        }
    277290
    278291        /* Create close button: */
    279         m_pButtonClose = new QIToolButton;
     292        m_pButtonClose = new QToolButton;
    280293        AssertPtrReturnVoid(m_pButtonClose);
    281294        {
    282295            /* Configure button: */
     296            m_pButtonClose->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    283297            m_pButtonClose->setIconSize(QSize(iMetricCloseButton, iMetricCloseButton));
    284298            m_pButtonClose->setIcon(UIIconPool::iconSet(":/close_16px.png"));
    285             connect(m_pButtonClose, &QIToolButton::clicked, this, &UITabBarItem::sltCloseClicked);
    286 
    287             /* Add into layout: */
    288             m_pLayout->addWidget(m_pButtonClose);
    289         }
     299            m_pButtonClose->setStyleSheet("QToolButton { border: 0px }");
     300            connect(m_pButtonClose, &QToolButton::clicked, this, &UITabBarItem::sltCloseClicked);
     301        }
     302
     303        /* Add everything into main-layout: */
     304        m_pLayout->addWidget(m_pLabelIcon);
     305        m_pLayout->addWidget(m_pLabelName);
     306        m_pLayout->addWidget(m_pButtonClose);
    290307    }
    291308}
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