VirtualBox

Ignore:
Timestamp:
Sep 25, 2018 6:25:36 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: VirtualBox Manager: Chooser and Tools panes: Sync painting rules.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/manager
Files:
3 edited

Legend:

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

    r74407 r74467  
    3838# include "COMEnums.h"
    3939# include "CMachine.h"
     40
     41/* Other VBox includes: */
     42#include "iprt/cpp/utils.h"
    4043
    4144#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
     
    245248}
    246249
    247 void UIChooserItemMachine::paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption, QWidget* /* pWidget = 0 */)
    248 {
    249     /* Paint decorations: */
    250     paintDecorations(pPainter, pOption);
     250void UIChooserItemMachine::paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOptions, QWidget* /* pWidget = 0 */)
     251{
     252    /* Acquire rectangle: */
     253    const QRect rectangle = pOptions->rect;
     254
     255    /* Paint background: */
     256    paintBackground(pPainter, rectangle);
     257    /* Paint frame: */
     258    paintFrame(pPainter, rectangle);
    251259    /* Paint machine info: */
    252     paintMachineInfo(pPainter, pOption);
     260    paintMachineInfo(pPainter, rectangle);
    253261}
    254262
     
    883891}
    884892
    885 void UIChooserItemMachine::paintDecorations(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption)
    886 {
    887     /* Prepare variables: */
    888     const QRect fullRect = pOption->rect;
    889 
    890     /* Paint background: */
    891     paintBackground(pPainter, fullRect);
    892     /* Paint frame: */
    893     paintFrameRectangle(pPainter, fullRect);
    894 }
    895 
    896 void UIChooserItemMachine::paintBackground(QPainter *pPainter, const QRect &rect)
     893void UIChooserItemMachine::paintBackground(QPainter *pPainter, const QRect &rectangle) const
    897894{
    898895    /* Save painter: */
     
    900897
    901898    /* Prepare color: */
    902     QPalette pal = palette();
     899    const QPalette pal = palette();
    903900
    904901    /* Selection background: */
    905     if (model()->currentItems().contains(this))
     902    if (model()->currentItems().contains(unconst(this)))
    906903    {
    907904        /* Prepare color: */
    908         QColor highlight = pal.color(QPalette::Active, QPalette::Highlight);
     905        QColor backgroundColor = pal.color(QPalette::Active, QPalette::Highlight);
    909906        /* Draw gradient: */
    910         QLinearGradient bgGrad(rect.topLeft(), rect.bottomLeft());
    911         bgGrad.setColorAt(0, highlight.lighter(m_iHighlightLightnessMax));
    912         bgGrad.setColorAt(1, highlight.lighter(m_iHighlightLightnessMin));
    913         pPainter->fillRect(rect, bgGrad);
     907        QLinearGradient bgGrad(rectangle.topLeft(), rectangle.bottomLeft());
     908        bgGrad.setColorAt(0, backgroundColor.lighter(m_iHighlightLightnessMax));
     909        bgGrad.setColorAt(1, backgroundColor.lighter(m_iHighlightLightnessMin));
     910        pPainter->fillRect(rectangle, bgGrad);
    914911    }
    915912    /* Hovering background: */
     
    917914    {
    918915        /* Prepare color: */
    919         QColor highlight = pal.color(QPalette::Active, QPalette::Highlight);
     916        QColor backgroundColor = pal.color(QPalette::Active, QPalette::Highlight);
    920917        /* Draw gradient: */
    921         QLinearGradient bgGrad(rect.topLeft(), rect.bottomLeft());
    922         bgGrad.setColorAt(0, highlight.lighter(m_iHoverLightnessMax));
    923         bgGrad.setColorAt(1, highlight.lighter(m_iHoverLightnessMin));
    924         pPainter->fillRect(rect, bgGrad);
     918        QLinearGradient bgGrad(rectangle.topLeft(), rectangle.bottomLeft());
     919        bgGrad.setColorAt(0, backgroundColor.lighter(m_iHoverLightnessMax));
     920        bgGrad.setColorAt(1, backgroundColor.lighter(m_iHoverLightnessMin));
     921        pPainter->fillRect(rectangle, bgGrad);
    925922    }
    926923    /* Default background: */
     
    928925    {
    929926        /* Prepare color: */
    930         QColor usual = pal.color(QPalette::Active, QPalette::Mid);
     927        QColor backgroundColor = pal.color(QPalette::Active, QPalette::Mid);
    931928        /* Draw gradient: */
    932         QLinearGradient bgGrad(rect.topLeft(), rect.bottomLeft());
    933         bgGrad.setColorAt(0, usual.lighter(m_iHoverLightnessMax));
    934         bgGrad.setColorAt(1, usual.lighter(m_iHoverLightnessMin));
    935         pPainter->fillRect(rect, bgGrad);
     929        QLinearGradient bgGrad(rectangle.topLeft(), rectangle.bottomLeft());
     930        bgGrad.setColorAt(0, backgroundColor.lighter(m_iHoverLightnessMax));
     931        bgGrad.setColorAt(1, backgroundColor.lighter(m_iHoverLightnessMin));
     932        pPainter->fillRect(rectangle, bgGrad);
    936933    }
    937934
     
    940937    {
    941938        /* Window color: */
    942         QColor base = pal.color(QPalette::Active, model()->currentItems().contains(this) ?
     939        QColor base = pal.color(QPalette::Active, model()->currentItems().contains(unconst(this)) ?
    943940                                QPalette::Highlight : QPalette::Window);
    944941        QLinearGradient dragTokenGradient;
    945         QRect dragTokenRect = rect;
     942        QRect dragTokenRect = rectangle;
    946943        if (dragTokenPlace() == DragToken_Up)
    947944        {
     
    965962}
    966963
    967 void UIChooserItemMachine::paintFrameRectangle(QPainter *pPainter, const QRect &rect)
     964void UIChooserItemMachine::paintFrame(QPainter *pPainter, const QRect &rectangle) const
    968965{
    969966    /* Save painter: */
     
    971968
    972969    /* Prepare color: */
    973     QPalette pal = palette();
     970    const QPalette pal = palette();
    974971    QColor strokeColor;
    975972
    976973    /* Selection frame: */
    977     if (model()->currentItems().contains(this))
     974    if (model()->currentItems().contains(unconst(this)))
    978975        strokeColor = pal.color(QPalette::Active, QPalette::Highlight).lighter(m_iHighlightLightnessMin - 40);
    979976    /* Hovering frame: */
     
    990987
    991988    /* Draw borders: */
    992     pPainter->drawLine(rect.topLeft(),    rect.topRight()    + QPoint(1, 0));
    993     pPainter->drawLine(rect.bottomLeft(), rect.bottomRight() + QPoint(1, 0));
    994     pPainter->drawLine(rect.topLeft(),    rect.bottomLeft());
     989    pPainter->drawLine(rectangle.topLeft(),    rectangle.topRight()    + QPoint(1, 0));
     990    pPainter->drawLine(rectangle.bottomLeft(), rectangle.bottomRight() + QPoint(1, 0));
     991    pPainter->drawLine(rectangle.topLeft(),    rectangle.bottomLeft());
    995992
    996993    /* Restore painter: */
     
    998995}
    999996
    1000 void UIChooserItemMachine::paintMachineInfo(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption)
     997void UIChooserItemMachine::paintMachineInfo(QPainter *pPainter, const QRect &rectangle) const
    1001998{
    1002999    /* Prepare variables: */
    1003     QRect fullRect = pOption->rect;
    1004     const int iFullHeight = fullRect.height();
     1000    const int iFullHeight = rectangle.height();
    10051001    const int iMargin = data(MachineItemData_Margin).toInt();
    10061002    const int iMajorSpacing = data(MachineItemData_MajorSpacing).toInt();
     
    10101006
    10111007    /* Selected item foreground: */
    1012     if (model()->currentItems().contains(this))
     1008    if (model()->currentItems().contains(unconst(this)))
    10131009    {
    10141010        QPalette pal = palette();
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemMachine.h

    r74002 r74467  
    247247    /** @name Painting stuff.
    248248      * @{ */
    249         /** Paints decorations using specified @a pPainter and certain @a pOptions. */
    250         void paintDecorations(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption);
    251         /** Paints background using specified @a pPainter and certain @a rect. */
    252         void paintBackground(QPainter *pPainter, const QRect &rect);
    253         /** Paints frame rectangle using specified @a pPainter and certain @a rect. */
    254         void paintFrameRectangle(QPainter *pPainter, const QRect &rect);
    255         /** Paints machine info using specified @a pPainter and certain @a pOptions. */
    256         void paintMachineInfo(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption);
     249        /** Paints background using specified @a pPainter and certain @a rectangle. */
     250        void paintBackground(QPainter *pPainter, const QRect &rectangle) const;
     251        /** Paints frame using specified @a pPainter and certain @a rectangle. */
     252        void paintFrame(QPainter *pPainter, const QRect &rectangle) const;
     253        /** Paints machine info using specified @a pPainter and certain @a rectangle. */
     254        void paintMachineInfo(QPainter *pPainter, const QRect &rectangle) const;
    257255    /** @} */
    258256
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UIToolsItem.cpp

    r74463 r74467  
    403403void UIToolsItem::paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOptions, QWidget * /* pWidget = 0 */)
    404404{
    405     /* Setup: */
    406     pPainter->setRenderHint(QPainter::Antialiasing);
    407 
    408405    /* Acquire rectangle: */
    409406    const QRect rectangle = pOptions->rect;
     
    439436    m_iHoverLightnessMax = 120;
    440437#else /* VBOX_WS_MAC */
    441     m_iHighlightLightnessMin = 120;
     438    m_iHighlightLightnessMin = 130;
    442439    m_iHighlightLightnessMax = 160;
    443     m_iHoverLightnessMin = 155;
    444     m_iHoverLightnessMax = 175;
     440    m_iHoverLightnessMin = 160;
     441    m_iHoverLightnessMax = 190;
    445442#endif /* !VBOX_WS_MAC */
    446443
     
    753750    /* Selection frame: */
    754751    if (model()->currentItem() == this)
    755         strokeColor = pal.color(QPalette::Active, QPalette::Mid).darker(110);
     752        strokeColor = pal.color(QPalette::Active, QPalette::Highlight).lighter(m_iHighlightLightnessMin - 40);
     753    /* Hovering frame: */
     754    else if (isHovered())
     755        strokeColor = pal.color(QPalette::Active, QPalette::Highlight).lighter(m_iHoverLightnessMin - 50);
    756756    /* Default frame: */
    757757    else
    758         strokeColor = pal.color(QPalette::Active, QPalette::Midlight).darker(110);
    759 
    760     /* Assign pen: */
    761     pPainter->setPen(strokeColor);
     758        strokeColor = pal.color(QPalette::Active, QPalette::Mid).lighter(m_iHoverLightnessMin);
     759
     760    /* Create/assign pen: */
     761    QPen pen(strokeColor);
     762    pen.setWidth(0);
     763    pPainter->setPen(pen);
    762764
    763765    /* Draw frame: */
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