Changeset 88931 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- May 7, 2021 3:11:06 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.cpp
r88903 r88931 79 79 80 80 QVector<QColor> m_alternateColors; 81 QColor m_selectedTabColor; 81 82 }; 82 83 … … 104 105 { 105 106 QStyleOptionTab opt; 106 m_alternateColors << opt.palette.color(QPalette::Button).lighter(135); 107 m_alternateColors << opt.palette.color(QPalette::Button).darker(135); 107 m_alternateColors << opt.palette.color(QPalette::Button).darker(230); 108 m_alternateColors << opt.palette.color(QPalette::Button).darker(140); 109 m_selectedTabColor = opt.palette.color(QPalette::Window).lighter(300); 108 110 } 109 111 110 112 void UITabBar::paintEvent(QPaintEvent *pEvent) 111 113 { 114 112 115 Q_UNUSED(pEvent); 113 116 QStylePainter painter(this); 114 QStyleOptionTab opt; 115 116 for (int i = 0; i < count(); i++) { 117 118 for (int i = 0; i < count(); i++) 119 { 120 QStyleOptionTab opt; 117 121 initStyleOption(&opt, i); 118 int iColorIndex = tabData(i).toInt(); 119 if (iColorIndex >= 0 && iColorIndex <= m_alternateColors.size()) 120 { 121 opt.palette.setColor(QPalette::Button, m_alternateColors[iColorIndex]); 122 } 123 124 painter.drawControl(QStyle::CE_TabBarTabShape, opt); 125 painter.drawControl(QStyle::CE_TabBarTabLabel, opt); 122 123 if (i == currentIndex()) 124 opt.palette.setColor(QPalette::Window, m_selectedTabColor); 125 else 126 { 127 /* Hack alert. I could not convince drawControl to use the set color if QStyle::State_Selected is not set: */ 128 opt.state |= QStyle::State_Selected; 129 130 int iColorIndex = tabData(i).toInt(); 131 if (iColorIndex >= 0 && iColorIndex <= m_alternateColors.size()) 132 opt.palette.setColor(QPalette::Window, m_alternateColors[iColorIndex]); 133 } 134 painter.drawControl(QStyle::CE_TabBarTab, opt); 126 135 } 127 136 }
Note:
See TracChangeset
for help on using the changeset viewer.