@@ -89,7 +89,15 @@ void QgsLayerTreeViewItemDelegate::paint( QPainter *painter, const QStyleOptionV
89
89
QBrush pb = painter->brush ();
90
90
QPen pp = painter->pen ();
91
91
painter->setPen ( QPen ( Qt::NoPen ) );
92
- painter->setBrush ( QBrush ( opt.palette .mid () ) );
92
+ QBrush b = QBrush ( opt.palette .mid () );
93
+ QColor bc = b.color ();
94
+ // mix mid color with base color for a less dominant, yet still opaque, version of the color
95
+ const QColor baseColor = opt.palette .base ().color ();
96
+ bc.setRed ( static_cast < int >( bc.red () * 0.3 + baseColor.red () * 0.7 ) );
97
+ bc.setGreen ( static_cast < int >( bc.green () * 0.3 + baseColor.green () * 0.7 ) );
98
+ bc.setBlue ( static_cast < int >( bc.blue () * 0.3 + baseColor.blue () * 0.7 ) );
99
+ b.setColor ( bc );
100
+ painter->setBrush ( b );
93
101
painter->drawRect ( mRect );
94
102
painter->setBrush ( pb );
95
103
painter->setPen ( pp );
@@ -120,7 +128,13 @@ void QgsLayerTreeViewItemDelegate::paint( QPainter *painter, const QStyleOptionV
120
128
qreal bradius = spacing;
121
129
QBrush pb = painter->brush ();
122
130
QPen pp = painter->pen ();
123
- painter->setBrush ( opt.palette .midlight () );
131
+ QBrush b = QBrush ( opt.palette .midlight () );
132
+ QColor bc = b.color ();
133
+ bc.setRed ( static_cast < int >( bc.red () * 0.3 + baseColor.red () * 0.7 ) );
134
+ bc.setGreen ( static_cast < int >( bc.green () * 0.3 + baseColor.green () * 0.7 ) );
135
+ bc.setBlue ( static_cast < int >( bc.blue () * 0.3 + baseColor.blue () * 0.7 ) );
136
+ b.setColor ( bc );
137
+ painter->setBrush ( b );
124
138
painter->setPen ( QPen ( QBrush ( opt.palette .mid () ), 0.25 ) );
125
139
painter->drawRoundedRect ( rect, bradius, bradius );
126
140
painter->setBrush ( pb );
@@ -145,8 +159,6 @@ bool QgsLayerTreeViewItemDelegate::helpEvent( QHelpEvent *event, QAbstractItemVi
145
159
{
146
160
if ( event && event->type () == QEvent::ToolTip )
147
161
{
148
- QHelpEvent *he = static_cast <QHelpEvent *>( event );
149
-
150
162
QgsLayerTreeNode *node = mLayerTreeView ->layerTreeModel ()->index2node ( index );
151
163
if ( node )
152
164
{
@@ -159,15 +171,15 @@ bool QgsLayerTreeViewItemDelegate::helpEvent( QHelpEvent *event, QAbstractItemVi
159
171
160
172
QRect indRect = mLayerTreeView ->style ()->subElementRect ( static_cast <QStyle::SubElement>( QgsLayerTreeViewProxyStyle::SE_LayerTreeItemIndicator ), &opt, mLayerTreeView );
161
173
162
- if ( indRect.contains ( he ->pos () ) )
174
+ if ( indRect.contains ( event ->pos () ) )
163
175
{
164
- int indicatorIndex = ( he ->pos ().x () - indRect.left () ) / indRect.height ();
176
+ int indicatorIndex = ( event ->pos ().x () - indRect.left () ) / indRect.height ();
165
177
if ( indicatorIndex >= 0 && indicatorIndex < indicators.count () )
166
178
{
167
179
const QString tooltip = indicators[indicatorIndex]->toolTip ();
168
180
if ( !tooltip.isEmpty () )
169
181
{
170
- QToolTip::showText ( he ->globalPos (), tooltip, view );
182
+ QToolTip::showText ( event ->globalPos (), tooltip, view );
171
183
return true ;
172
184
}
173
185
}
0 commit comments