summaryrefslogtreecommitdiffstats
path: root/src/plugins/styles/mac/qmacstyle_mac.mm
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2020-01-04 15:32:34 +0100
committerLiang Qi <liang.qi@qt.io>2020-01-04 15:32:34 +0100
commita503bf54705d89204007e8f887b668fe5ef519fc (patch)
treeb2d1a452da39450eac78a1aeb1df116a73f64b23 /src/plugins/styles/mac/qmacstyle_mac.mm
parente65c43fd0ffa57248e7d750570b7deae171a82f5 (diff)
parent1f87fb359fdff14e42662384a9c8a0bcb3837671 (diff)
Merge remote-tracking branch 'origin/5.15' into dev
Conflicts: src/corelib/tools/qvector.h Make QVector(DataPointer dd) public to be able to properly merge 5b4b437b30b320e2cd7c9a566999a39772e5d431 from 5.15 into dev. src/widgets/kernel/qapplication.cpp tests/auto/tools/moc/allmocs_baseline_in.json Done-With: Christian Ehrlicher <ch.ehrlicher@gmx.de> Change-Id: I929ba7c036d570382d0454c2c75f6f0d96ddbc01
Diffstat (limited to 'src/plugins/styles/mac/qmacstyle_mac.mm')
-rw-r--r--src/plugins/styles/mac/qmacstyle_mac.mm26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm
index fd268e3787..f0bc51b796 100644
--- a/src/plugins/styles/mac/qmacstyle_mac.mm
+++ b/src/plugins/styles/mac/qmacstyle_mac.mm
@@ -236,6 +236,18 @@ static QLinearGradient titlebarGradientInactive()
}
#if QT_CONFIG(tabwidget)
+/*
+ Since macOS 10.14 AppKit is using transparency more extensively, especially for the
+ dark theme. Inactive buttons, for example, are semi-transparent. And we use them to
+ draw tab widget's tab bar. The combination of NSBox (also a part of tab widget)
+ and these transparent buttons gives us an undesired side-effect: an outline of
+ NSBox is visible through transparent buttons. To avoid this, we have this hack below:
+ we clip the area where the line would be visible through the buttons. The area we
+ want to clip away can be described as an intersection of the option's rect and
+ the tab widget's tab bar rect. But some adjustments are required, since those rects
+ are anyway adjusted during the rendering and they are not exactly what you'll see on
+ the screen. Thus this switch-statement inside.
+*/
static void clipTabBarFrame(const QStyleOption *option, const QMacStyle *style, CGContextRef ctx)
{
Q_ASSERT(option);
@@ -246,7 +258,19 @@ static void clipTabBarFrame(const QStyleOption *option, const QMacStyle *style,
QTabWidget *tabWidget = qobject_cast<QTabWidget *>(option->styleObject);
Q_ASSERT(tabWidget);
- const QRect tabBarRect = style->subElementRect(QStyle::SE_TabWidgetTabBar, option, tabWidget).adjusted(2, 2, -3, -2);
+ QRect tabBarRect = style->subElementRect(QStyle::SE_TabWidgetTabBar, option, tabWidget).adjusted(2, 0, -3, 0);
+ switch (tabWidget->tabPosition()) {
+ case QTabWidget::South:
+ tabBarRect.setY(tabBarRect.y() + tabBarRect.height() / 2);
+ break;
+ case QTabWidget::North:
+ case QTabWidget::West:
+ tabBarRect = tabBarRect.adjusted(0, 2, 0, -2);
+ break;
+ case QTabWidget::East:
+ tabBarRect = tabBarRect.adjusted(tabBarRect.width() / 2, 2, tabBarRect.width() / 2, -2);
+ }
+
const QRegion clipPath = QRegion(option->rect) - tabBarRect;
QVarLengthArray<CGRect, 3> cgRects;
for (const QRect &qtRect : clipPath)