summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTimur Pocheptsov <timur.pocheptsov@qt.io>2022-02-23 10:03:28 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-02-28 11:36:49 +0000
commit853d3ef89308e6c90a331449a1deaba9d7721538 (patch)
tree459ce5ce6b8f3633aff7071012838f1acef56428 /src
parent70828223f3e0f1a168e14b7d6bc556a52fb7a1e2 (diff)
QMacStyle: fix tool buttons (in checked mode)
While switching to the 'momentary push in' button type, the old code that shows button as pressed/checked was removed. Since 'square' buttons were sharing this part with rounded push buttons, the change broke checked square buttons. So we retain the old code for this particular case. Also, add a minimal baseline test for this scenario: square button, triggering 'toolbutton' style with/out 'checked' state. Fixes: QTBUG-100802 Change-Id: Ib7b15b13ead834c7bb2cd36de76ccd5bedb07810 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit af05f278ed236e0f699e0af79524cf55054ba49f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/styles/mac/qmacstyle_mac.mm11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm
index 757835f3ac..181122acb4 100644
--- a/src/plugins/styles/mac/qmacstyle_mac.mm
+++ b/src/plugins/styles/mac/qmacstyle_mac.mm
@@ -3722,9 +3722,14 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
// not show its state otherwise):
[pb highlight:isPressed];
- // For default/checked button this will give the required
- // button accent color:
- pb.keyEquivalent = isHighlighted ? @"\r" : @"";
+
+ if (cw.type == QMacStylePrivate::Button_SquareButton) {
+ pb.state = isHighlighted && !isPressed ? NSControlStateValueOn : NSControlStateValueOff;
+ } else {
+ // For default/checked button this will give the required
+ // button accent color:
+ pb.keyEquivalent = isHighlighted ? @"\r" : @"";
+ }
d->drawNSViewInRect(pb, frameRect, p, ^(CGContextRef, const CGRect &r) {
[pb.cell drawBezelWithFrame:r inView:pb.superview];