VirtualBox

Changeset 74481 in vbox for trunk


Ignore:
Timestamp:
Sep 26, 2018 3:43:18 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: VirtualBox Manager: Chooser pane: Sync painting rules between machine and global items as well (s.a. r125322).

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

Legend:

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

    r74246 r74481  
    3232# include "UIVirtualBoxManager.h"
    3333
     34/* Other VBox includes: */
     35#include "iprt/cpp/utils.h"
     36
    3437#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
    3538
     
    176179}
    177180
    178 void UIChooserItemGlobal::paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption, QWidget * /* pWidget = 0 */)
    179 {
    180     /* Setup: */
    181     pPainter->setRenderHint(QPainter::Antialiasing);
    182 
    183     /* Paint decorations: */
    184     paintDecorations(pPainter, pOption);
    185 
     181void UIChooserItemGlobal::paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOptions, QWidget * /* pWidget = 0 */)
     182{
     183    /* Acquire rectangle: */
     184    const QRect rectangle = pOptions->rect;
     185
     186    /* Paint background: */
     187    paintBackground(pPainter, rectangle);
     188    /* Paint frame: */
     189    paintFrame(pPainter, rectangle);
    186190    /* Paint global info: */
    187     paintGlobalInfo(pPainter, pOption);
     191    paintGlobalInfo(pPainter, rectangle);
    188192}
    189193
     
    508512}
    509513
    510 void UIChooserItemGlobal::paintDecorations(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption)
    511 {
    512     /* Prepare variables: */
    513     QRect fullRect = pOption->rect;
    514 
    515     /* Paint background: */
    516     paintBackground(pPainter, fullRect);
    517 
    518     /* Paint frame: */
    519     paintFrameRectangle(pPainter, fullRect);
    520 }
    521 
    522 void UIChooserItemGlobal::paintBackground(QPainter *pPainter, const QRect &rect)
     514void UIChooserItemGlobal::paintBackground(QPainter *pPainter, const QRect &rectangle) const
    523515{
    524516    /* Save painter: */
     
    529521
    530522    /* Selection background: */
    531     if (model()->currentItems().contains(this))
     523    if (model()->currentItems().contains(unconst(this)))
    532524    {
    533525        /* Prepare color: */
    534526        QColor highlight = pal.color(QPalette::Active, QPalette::Highlight);
    535527        /* Draw gradient: */
    536         QLinearGradient bgGrad(rect.topLeft(), rect.bottomLeft());
     528        QLinearGradient bgGrad(rectangle.topLeft(), rectangle.bottomLeft());
    537529        bgGrad.setColorAt(0, highlight.lighter(m_iHighlightLightness));
    538530        bgGrad.setColorAt(1, highlight);
    539         pPainter->fillRect(rect, bgGrad);
     531        pPainter->fillRect(rectangle, bgGrad);
    540532    }
    541533    /* Hovering background: */
     
    545537        QColor highlight = pal.color(QPalette::Active, QPalette::Highlight);
    546538        /* Draw gradient: */
    547         QLinearGradient bgGrad(rect.topLeft(), rect.bottomLeft());
     539        QLinearGradient bgGrad(rectangle.topLeft(), rectangle.bottomLeft());
    548540        bgGrad.setColorAt(0, highlight.lighter(m_iHoverHighlightLightness));
    549541        bgGrad.setColorAt(1, highlight.lighter(m_iHoverLightness));
    550         pPainter->fillRect(rect, bgGrad);
     542        pPainter->fillRect(rectangle, bgGrad);
    551543    }
    552544
     
    555547}
    556548
    557 void UIChooserItemGlobal::paintFrameRectangle(QPainter *pPainter, const QRect &rect)
     549void UIChooserItemGlobal::paintFrame(QPainter *pPainter, const QRect &rectangle) const
    558550{
    559551    /* Only chosen and/or hovered item should have a frame: */
    560     if (!model()->currentItems().contains(this) && !isHovered())
     552    if (!model()->currentItems().contains(unconst(this)) && !isHovered())
    561553        return;
    562554
    563     /* Simple frame: */
     555    /* Save painter: */
    564556    pPainter->save();
     557
     558    /* Prepare color: */
    565559    const QPalette pal = palette();
    566560    QColor strokeColor = pal.color(QPalette::Active,
    567                                    model()->currentItems().contains(this) ?
     561                                   model()->currentItems().contains(unconst(this)) ?
    568562                                   QPalette::Mid : QPalette::Highlight);
    569     pPainter->setPen(strokeColor);
    570     pPainter->drawRect(rect);
     563
     564    /* Create/assign pen: */
     565    QPen pen(strokeColor);
     566    pen.setWidth(0);
     567    pPainter->setPen(pen);
     568
     569    /* Draw rectangle: */
     570    pPainter->drawRect(rectangle);
     571
     572    /* Restore painter: */
    571573    pPainter->restore();
    572574}
    573575
    574 void UIChooserItemGlobal::paintGlobalInfo(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption)
     576void UIChooserItemGlobal::paintGlobalInfo(QPainter *pPainter, const QRect &rectangle) const
    575577{
    576578    /* Prepare variables: */
    577     const QRect fullRect = pOption->rect;
    578     const int iFullHeight = fullRect.height();
     579    const int iFullHeight = rectangle.height();
    579580    const int iMargin = data(GlobalItemData_Margin).toInt();
    580581    const int iSpacing = data(GlobalItemData_Spacing).toInt();
    581582
    582583    /* Selected item foreground: */
    583     if (model()->currentItems().contains(this))
     584    if (model()->currentItems().contains(unconst(this)))
    584585    {
    585586        const QPalette pal = palette();
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGlobal.h

    r74138 r74481  
    205205    /** @name Painting stuff.
    206206      * @{ */
    207         /** Paints decorations using specified @a pPainter and certain @a pOptions. */
    208         void paintDecorations(QPainter *pPainter, const QStyleOptionGraphicsItem *pOptions);
    209         /** Paints background using specified @a pPainter and certain @a rect. */
    210         void paintBackground(QPainter *pPainter, const QRect &rect);
    211         /** Paints frame rectangle using specified @a pPainter and certain @a rect. */
    212         void paintFrameRectangle(QPainter *pPainter, const QRect &rect);
     207        /** Paints background using specified @a pPainter and certain @a rectangle. */
     208        void paintBackground(QPainter *pPainter, const QRect &rectangle) const;
     209        /** Paints frame using specified @a pPainter and certain @a rect. */
     210        void paintFrame(QPainter *pPainter, const QRect &rectangle) const;
    213211        /** Paints global info using specified @a pPainter and certain @a pOptions. */
    214         void paintGlobalInfo(QPainter *pPainter, const QStyleOptionGraphicsItem *pOptions);
     212        void paintGlobalInfo(QPainter *pPainter, const QRect &rectangle) const;
    215213    /** @} */
    216214
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