Changeset 74467 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Sep 25, 2018 6:25:36 PM (6 years ago)
- 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 38 38 # include "COMEnums.h" 39 39 # include "CMachine.h" 40 41 /* Other VBox includes: */ 42 #include "iprt/cpp/utils.h" 40 43 41 44 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ … … 245 248 } 246 249 247 void UIChooserItemMachine::paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption, QWidget* /* pWidget = 0 */) 248 { 249 /* Paint decorations: */ 250 paintDecorations(pPainter, pOption); 250 void 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); 251 259 /* Paint machine info: */ 252 paintMachineInfo(pPainter, pOption);260 paintMachineInfo(pPainter, rectangle); 253 261 } 254 262 … … 883 891 } 884 892 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) 893 void UIChooserItemMachine::paintBackground(QPainter *pPainter, const QRect &rectangle) const 897 894 { 898 895 /* Save painter: */ … … 900 897 901 898 /* Prepare color: */ 902 QPalette pal = palette();899 const QPalette pal = palette(); 903 900 904 901 /* Selection background: */ 905 if (model()->currentItems().contains( this))902 if (model()->currentItems().contains(unconst(this))) 906 903 { 907 904 /* Prepare color: */ 908 QColor highlight= pal.color(QPalette::Active, QPalette::Highlight);905 QColor backgroundColor = pal.color(QPalette::Active, QPalette::Highlight); 909 906 /* 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); 914 911 } 915 912 /* Hovering background: */ … … 917 914 { 918 915 /* Prepare color: */ 919 QColor highlight= pal.color(QPalette::Active, QPalette::Highlight);916 QColor backgroundColor = pal.color(QPalette::Active, QPalette::Highlight); 920 917 /* 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); 925 922 } 926 923 /* Default background: */ … … 928 925 { 929 926 /* Prepare color: */ 930 QColor usual= pal.color(QPalette::Active, QPalette::Mid);927 QColor backgroundColor = pal.color(QPalette::Active, QPalette::Mid); 931 928 /* 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); 936 933 } 937 934 … … 940 937 { 941 938 /* 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)) ? 943 940 QPalette::Highlight : QPalette::Window); 944 941 QLinearGradient dragTokenGradient; 945 QRect dragTokenRect = rect ;942 QRect dragTokenRect = rectangle; 946 943 if (dragTokenPlace() == DragToken_Up) 947 944 { … … 965 962 } 966 963 967 void UIChooserItemMachine::paintFrame Rectangle(QPainter *pPainter, const QRect &rect)964 void UIChooserItemMachine::paintFrame(QPainter *pPainter, const QRect &rectangle) const 968 965 { 969 966 /* Save painter: */ … … 971 968 972 969 /* Prepare color: */ 973 QPalette pal = palette();970 const QPalette pal = palette(); 974 971 QColor strokeColor; 975 972 976 973 /* Selection frame: */ 977 if (model()->currentItems().contains( this))974 if (model()->currentItems().contains(unconst(this))) 978 975 strokeColor = pal.color(QPalette::Active, QPalette::Highlight).lighter(m_iHighlightLightnessMin - 40); 979 976 /* Hovering frame: */ … … 990 987 991 988 /* 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()); 995 992 996 993 /* Restore painter: */ … … 998 995 } 999 996 1000 void UIChooserItemMachine::paintMachineInfo(QPainter *pPainter, const Q StyleOptionGraphicsItem *pOption)997 void UIChooserItemMachine::paintMachineInfo(QPainter *pPainter, const QRect &rectangle) const 1001 998 { 1002 999 /* Prepare variables: */ 1003 QRect fullRect = pOption->rect; 1004 const int iFullHeight = fullRect.height(); 1000 const int iFullHeight = rectangle.height(); 1005 1001 const int iMargin = data(MachineItemData_Margin).toInt(); 1006 1002 const int iMajorSpacing = data(MachineItemData_MajorSpacing).toInt(); … … 1010 1006 1011 1007 /* Selected item foreground: */ 1012 if (model()->currentItems().contains( this))1008 if (model()->currentItems().contains(unconst(this))) 1013 1009 { 1014 1010 QPalette pal = palette(); -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemMachine.h
r74002 r74467 247 247 /** @name Painting stuff. 248 248 * @{ */ 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; 257 255 /** @} */ 258 256 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UIToolsItem.cpp
r74463 r74467 403 403 void UIToolsItem::paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOptions, QWidget * /* pWidget = 0 */) 404 404 { 405 /* Setup: */406 pPainter->setRenderHint(QPainter::Antialiasing);407 408 405 /* Acquire rectangle: */ 409 406 const QRect rectangle = pOptions->rect; … … 439 436 m_iHoverLightnessMax = 120; 440 437 #else /* VBOX_WS_MAC */ 441 m_iHighlightLightnessMin = 1 20;438 m_iHighlightLightnessMin = 130; 442 439 m_iHighlightLightnessMax = 160; 443 m_iHoverLightnessMin = 1 55;444 m_iHoverLightnessMax = 1 75;440 m_iHoverLightnessMin = 160; 441 m_iHoverLightnessMax = 190; 445 442 #endif /* !VBOX_WS_MAC */ 446 443 … … 753 750 /* Selection frame: */ 754 751 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); 756 756 /* Default frame: */ 757 757 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); 762 764 763 765 /* Draw frame: */
Note:
See TracChangeset
for help on using the changeset viewer.