Commit 7d3c5c9b authored by Janet Blackquill's avatar Janet Blackquill 🌈 Committed by Nate Graham
Browse files

[kstyle]: Give active document tabs a thick highlight

BUG: 356037
parent 5e1e5b49
......@@ -1294,8 +1294,11 @@ namespace Breeze
}
//______________________________________________________________________________
void Helper::renderTabBarTab( QPainter* painter, const QRect& rect, const QColor& color, const QColor& outline, Corners corners ) const
{
void Helper::renderTabBarTab(QPainter *painter, const QRect &rect,
const QColor &color, const QColor &highlight,
const QColor &outline, Corners corners,
bool document, bool bottom) const {
// setup painter
painter->setRenderHint( QPainter::Antialiasing, true );
......@@ -1322,6 +1325,22 @@ namespace Breeze
QPainterPath path( roundedPath( frameRect, corners, radius ) );
painter->drawPath( path );
if (highlight.isValid() && document) {
auto rect = frameRect;
rect.setHeight(2);
if (bottom) {
rect.setTop(frameRect.bottom()-2);
rect.setBottom(frameRect.bottom());
}
QPainterPath rectAsPath;
rectAsPath.addRect(rect);
painter->setClipPath(path.intersected(rectAsPath));
painter->setBrush(highlight);
painter->drawRect(frameRect);
}
}
//______________________________________________________________________________
......
......@@ -240,7 +240,10 @@ namespace Breeze
void renderScrollBarBorder( QPainter*, const QRect&, const QColor& ) const;
//* tabbar tab
void renderTabBarTab( QPainter*, const QRect&, const QColor& color, const QColor& outline, Corners ) const;
void renderTabBarTab( QPainter*, const QRect&, const QColor& color, const QColor& highlight, const QColor& outline, Corners, bool document, bool bottom ) const;
// TODO(janet): document should be set based on whether or not we consider the
// tab user-editable, but Qt apps often misuse or don't use documentMode property
// so we're currently just always setting it to true for now
//* generic arrow
void renderArrow( QPainter*, const QRect&, const QColor&, ArrowOrientation ) const;
......
......@@ -5707,6 +5707,8 @@ namespace Breeze
// for QtQuickControls, ovelap is already accounted of in the option. Unlike in the qwidget case
const int overlap( isQtQuickControl ? 0:Metrics::TabBar_TabOverlap );
bool bottom = false;
// adjust rect and define corners based on tabbar orientation
Corners corners;
switch( tabOption->shape )
......@@ -5738,6 +5740,7 @@ namespace Breeze
corners = CornerBottomLeft|CornerBottomRight;
rect.adjust( 0, - 1, 0, 0 );
bottom = true;
} else {
......@@ -5820,18 +5823,24 @@ namespace Breeze
// outline
const auto outline( selected ? _helper->alphaColor( palette.color( QPalette::WindowText ), 0.25 ) : QColor() );
QColor accent;
if ( selected )
{
accent = palette.color( QPalette::Active, QPalette::Highlight );
}
// render
if( selected )
{
QRegion oldRegion( painter->clipRegion() );
painter->setClipRect( option->rect, Qt::IntersectClip );
_helper->renderTabBarTab( painter, rect, color, outline, corners );
_helper->renderTabBarTab( painter, rect, color, accent, outline, corners, true, bottom );
painter->setClipRegion( oldRegion );
} else {
_helper->renderTabBarTab( painter, rect, color, outline, corners );
_helper->renderTabBarTab( painter, rect, color, accent, outline, corners, true, bottom );
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment