From 15026f309b3c69b94de39e0cbeba09dd8bdd5e29 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Mon, 27 Apr 2020 15:28:10 +0200 Subject: QMacStyle - change the arrow type only for 'OnlyOneTab' option It appears the hack was not needed when we have several tabs (popup button works as expected). Otherwise, this button suddenly has a different size: it's bigger when selected and smaller if not (and the holes clipped under the tab shape are becoming quite visible in the dark mode to the left and right of a tabbar). For the single tab we need some adjustment in the size not to have visible difference between inactive/selected tab. Fixes: QTBUG-83216 Change-Id: I52511e610ae7b36f261e0218b7e432e747bc9491 Reviewed-by: Volker Hilsheimer --- src/plugins/styles/mac/qmacstyle_mac.mm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/plugins/styles/mac/qmacstyle_mac.mm') diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 8e4aaa19c7..84233d6521 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -3977,13 +3977,19 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter // which makes no sense on tabs. NSPopUpArrowPosition oldPosition = NSPopUpArrowAtCenter; NSPopUpButtonCell *pbCell = nil; - if (isPopupButton) { + auto rAdjusted = r; + if (isPopupButton && tp == QStyleOptionTab::OnlyOneTab) { pbCell = static_cast(pb.cell); oldPosition = pbCell.arrowPosition; pbCell.arrowPosition = NSPopUpNoArrow; + if (pb.state == NSOffState) { + // NSPopUpButton in this state is smaller. + rAdjusted.origin.x -= 3; + rAdjusted.size.width += 6; + } } - [pb.cell drawBezelWithFrame:r inView:pb.superview]; + [pb.cell drawBezelWithFrame:rAdjusted inView:pb.superview]; if (pbCell) // Restore, we may reuse it for a ComboBox. pbCell.arrowPosition = oldPosition; -- cgit v1.2.3