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 <volker.hilsheimer@qt.io>
bb10
Timur Pocheptsov 2020-04-27 15:28:10 +02:00
parent 5e8bd204e2
commit 15026f309b
1 changed files with 8 additions and 2 deletions

View File

@ -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<NSPopUpButtonCell *>(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;