Changeset 74318 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Sep 17, 2018 4:19:38 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UIToolsItem.cpp
r74272 r74318 695 695 pPainter->save(); 696 696 697 /* Prepare color: */697 /* Prepare variables: */ 698 698 const QPalette pal = palette(); 699 699 … … 702 702 { 703 703 /* Prepare color: */ 704 const QColor highlight = pal.color(QPalette::Active, QPalette::Highlight); 704 const QColor backgroundColor = isEnabled() 705 ? pal.color(QPalette::Active, QPalette::Highlight) 706 : pal.color(QPalette::Disabled, QPalette::Midlight); 705 707 /* Draw gradient: */ 706 708 QLinearGradient bgGrad(rectangle.topLeft(), rectangle.bottomLeft()); 707 bgGrad.setColorAt(0, highlight.lighter(m_iHighlightLightnessMax));708 bgGrad.setColorAt(1, highlight.lighter(m_iHighlightLightnessMin));709 bgGrad.setColorAt(0, backgroundColor.lighter(m_iHighlightLightnessMax)); 710 bgGrad.setColorAt(1, backgroundColor.lighter(m_iHighlightLightnessMin)); 709 711 pPainter->fillRect(rectangle, bgGrad); 710 712 } … … 713 715 { 714 716 /* Prepare color: */ 715 const QColor highlight = pal.color(QPalette::Active, QPalette::Highlight); 717 const QColor backgroundColor = isEnabled() 718 ? pal.color(QPalette::Active, QPalette::Highlight) 719 : pal.color(QPalette::Disabled, QPalette::Midlight); 716 720 /* Draw gradient: */ 717 721 QLinearGradient bgGrad(rectangle.topLeft(), rectangle.bottomLeft()); 718 bgGrad.setColorAt(0, highlight.lighter(m_iHoverLightnessMax));719 bgGrad.setColorAt(1, highlight.lighter(m_iHoverLightnessMin));722 bgGrad.setColorAt(0, backgroundColor.lighter(m_iHoverLightnessMax)); 723 bgGrad.setColorAt(1, backgroundColor.lighter(m_iHoverLightnessMin)); 720 724 pPainter->fillRect(rectangle, bgGrad); 721 725 } … … 724 728 { 725 729 /* Prepare color: */ 726 const QColor usual = pal.color(QPalette::Active, QPalette::Mid); 730 const QColor backgroundColor = isEnabled() 731 ? pal.color(QPalette::Active, QPalette::Mid) 732 : pal.color(QPalette::Disabled, QPalette::Midlight); 727 733 /* Draw gradient: */ 728 734 QLinearGradient bgGrad(rectangle.topLeft(), rectangle.bottomLeft()); 729 bgGrad.setColorAt(0, usual.lighter(m_iHoverLightnessMax));730 bgGrad.setColorAt(1, usual.lighter(m_iHoverLightnessMin));735 bgGrad.setColorAt(0, backgroundColor.lighter(m_iHoverLightnessMax)); 736 bgGrad.setColorAt(1, backgroundColor.lighter(m_iHoverLightnessMin)); 731 737 pPainter->fillRect(rectangle, bgGrad); 732 738 } … … 769 775 const int iMargin = data(ToolsItemData_Margin).toInt(); 770 776 const int iSpacing = data(ToolsItemData_Spacing).toInt(); 777 const QPalette pal = palette(); 771 778 772 779 /* Selected item foreground: */ 773 780 if (model()->currentItem() == this) 774 781 { 775 QPalette pal = palette(); 776 pPainter->setPen(pal.color(QPalette::HighlightedText)); 782 const QColor textColor = isEnabled() 783 ? pal.color(QPalette::Active, QPalette::HighlightedText) 784 : pal.color(QPalette::Disabled, QPalette::Text); 785 pPainter->setPen(textColor); 777 786 } 778 787 /* Hovered item foreground: */ … … 780 789 { 781 790 /* Prepare color: */ 782 QPalette pal = palette(); 783 QColor highlight = pal.color(QPalette::Active, QPalette::Highlight); 784 QColor hhl = highlight.lighter(m_iHoverLightnessMax); 785 if (hhl.value() - hhl.saturation() > 0) 786 pPainter->setPen(pal.color(QPalette::Active, QPalette::Text)); 791 QColor defaultHighlighted = pal.color(QPalette::Active, QPalette::Highlight); 792 QColor hoveredHighlighted = defaultHighlighted.lighter(m_iHoverLightnessMax); 793 QColor textColor; 794 if (hoveredHighlighted.value() - hoveredHighlighted.saturation() > 0) 795 textColor = isEnabled() 796 ? pal.color(QPalette::Active, QPalette::Text) 797 : pal.color(QPalette::Disabled, QPalette::Text); 787 798 else 788 pPainter->setPen(pal.color(QPalette::Active, QPalette::HighlightedText)); 799 textColor = isEnabled() 800 ? pal.color(QPalette::Active, QPalette::HighlightedText) 801 : pal.color(QPalette::Disabled, QPalette::Text); 802 pPainter->setPen(textColor); 803 } 804 /* Default item foreground: */ 805 else 806 { 807 const QColor textColor = isEnabled() 808 ? pal.color(QPalette::Active, QPalette::Text) 809 : pal.color(QPalette::Disabled, QPalette::Text); 810 pPainter->setPen(textColor); 789 811 } 790 812
Note:
See TracChangeset
for help on using the changeset viewer.