From fae42e1e73edd2aa18ec257933d856a1d88337a7 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 19 Mar 2018 13:15:00 -0700 Subject: [PATCH] QMacStyle: Don't highlight square buttons text when pressed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Native square buttons keep their text black when pressed or on. Plus using the QStyleOptionButton variable over the QStyleOption one where appropriate. Change-Id: Idba8197e64d408e8a0987f1ef9243fde08e3e839 Reviewed-by: Morten Johan Sørvig --- src/plugins/styles/mac/qmacstyle_mac.mm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 15ffd4853a..043a910a7c 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -3958,8 +3958,8 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter // takes precedence over a normal default button if ((btn->features & QStyleOptionButton::AutoDefaultButton) && isActive && hasFocus) - d->autoDefaultButton = opt->styleObject; - else if (d->autoDefaultButton == opt->styleObject) + d->autoDefaultButton = btn->styleObject; + else if (d->autoDefaultButton == btn->styleObject) d->autoDefaultButton = nullptr; const bool isEnabled = btn->state & State_Enabled; @@ -3971,7 +3971,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter && d->autoDefaultButton == btn->styleObject)); const bool hasMenu = btn->features & QStyleOptionButton::HasMenu; const auto ct = cocoaControlType(btn, w); - const auto cs = d->effectiveAquaSizeConstrain(opt, w); + const auto cs = d->effectiveAquaSizeConstrain(btn, w); const auto cw = QMacStylePrivate::CocoaControl(ct, cs); auto *pb = static_cast(d->cocoaControl(cw)); // Ensure same size and location as we used to have with HITheme. @@ -4041,7 +4041,9 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter const bool isActive = btn.state & State_Active; const bool isPressed = btn.state & State_Sunken; - if (!hasMenu) { + const auto ct = cocoaControlType(&btn, w); + + if (!hasMenu && ct != QMacStylePrivate::Button_SquareButton) { if (isPressed || (isActive && ((btn.features & QStyleOptionButton::DefaultButton && !d->autoDefaultButton)