VirtualBox

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


Ignore:
Timestamp:
Sep 5, 2018 4:34:53 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: QISplitter: Support for flat splitter handle.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QISplitter.cpp

    r74087 r74088  
    3333
    3434
     35/** QSplitterHandle subclass representing flat line. */
     36class QIFlatSplitterHandle : public QSplitterHandle
     37{
     38    Q_OBJECT;
     39
     40public:
     41
     42    /** Constructs flat splitter handle passing @a enmOrientation and @a pParent to the base-class. */
     43    QIFlatSplitterHandle(Qt::Orientation enmOrientation, QISplitter *pParent);
     44
     45    /** Defines @a color. */
     46    void configureColor(const QColor &color);
     47
     48protected:
     49
     50    /** Handles paint @a pEvent. */
     51    virtual void paintEvent(QPaintEvent *pEvent) /* override */;
     52
     53private:
     54
     55    /** Holds the main color. */
     56    QColor m_color;
     57};
     58
     59
    3560/** QSplitterHandle subclass representing shaded line. */
    3661class QIShadeSplitterHandle : public QSplitterHandle
     
    82107};
    83108#endif /* VBOX_WS_MAC */
     109
     110
     111/*********************************************************************************************************************************
     112*   Class QIFlatSplitterHandle implementation.                                                                                   *
     113*********************************************************************************************************************************/
     114
     115QIFlatSplitterHandle::QIFlatSplitterHandle(Qt::Orientation enmOrientation, QISplitter *pParent)
     116    : QSplitterHandle(enmOrientation, pParent)
     117{
     118}
     119
     120void QIFlatSplitterHandle::configureColor(const QColor &color)
     121{
     122    m_color = color;
     123    update();
     124}
     125
     126void QIFlatSplitterHandle::paintEvent(QPaintEvent *pEvent)
     127{
     128    QPainter painter(this);
     129    painter.fillRect(pEvent->rect(), m_color);
     130}
    84131
    85132
     
    205252{
    206253    qApp->installEventFilter(this);
     254}
     255
     256void QISplitter::configureColor(const QColor &color)
     257{
     258    m_color = color;
     259    QIFlatSplitterHandle *pHandle = qobject_cast<QIFlatSplitterHandle*>(handle(1));
     260    if (pHandle && m_color.isValid())
     261        pHandle->configureColor(m_color);
    207262}
    208263
     
    332387    switch (m_enmType)
    333388    {
     389        case Flat:
     390        {
     391            QIFlatSplitterHandle *pHandle = new QIFlatSplitterHandle(orientation(), this);
     392            if (m_color.isValid())
     393                pHandle->configureColor(m_color);
     394            return pHandle;
     395        }
    334396        case Shade:
    335397        {
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QISplitter.h

    r74087 r74088  
    3636
    3737    /** Handle types. */
    38     enum Type { Shade, Native };
     38    enum Type { Flat, Shade, Native };
    3939
    4040    /** Constructs splitter passing @a pParent to the base-class. */
     
    4444    QISplitter(Qt::Orientation enmOrientation, Type enmType, QWidget *pParent = 0);
    4545
     46    /** Configure custom color defined as @a color. */
     47    void configureColor(const QColor &color);
    4648    /** Configure custom colors defined as @a color1 and @a color2. */
    4749    void configureColors(const QColor &color1, const QColor &color2);
     
    7375#endif
    7476
     77    /** Holds color. */
     78    QColor m_color;
    7579    /** Holds color1. */
    7680    QColor m_color1;
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