mirror of
https://github.com/crystalidea/qt-build-tools.git
synced 2024-11-26 12:37:11 +08:00
5.15.2: fix for QTBUG-98093 (backport of macOS: Fix QSlider's knob positioning on Monterey (4bee9cdc0a
)
This commit is contained in:
parent
adb5e94f20
commit
7c1d9e7708
@ -472,7 +472,11 @@ static bool setupSlider(NSSlider *slider, const QStyleOptionSlider *sl)
|
|||||||
if (sl->minimum >= sl->maximum)
|
if (sl->minimum >= sl->maximum)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
slider.frame = sl->rect.toCGRect();
|
// NSSlider seems to cache values based on tracking and the last layout of the
|
||||||
|
// NSView, resulting in incorrect knob rects that break the interaction with
|
||||||
|
// multiple sliders. So completely reinitialize the slider.
|
||||||
|
[slider initWithFrame:sl->rect.toCGRect()];
|
||||||
|
|
||||||
slider.minValue = sl->minimum;
|
slider.minValue = sl->minimum;
|
||||||
slider.maxValue = sl->maximum;
|
slider.maxValue = sl->maximum;
|
||||||
slider.intValue = sl->sliderPosition;
|
slider.intValue = sl->sliderPosition;
|
||||||
@ -502,6 +506,14 @@ static bool setupSlider(NSSlider *slider, const QStyleOptionSlider *sl)
|
|||||||
// the cell for its metrics and to draw itself.
|
// the cell for its metrics and to draw itself.
|
||||||
[slider layoutSubtreeIfNeeded];
|
[slider layoutSubtreeIfNeeded];
|
||||||
|
|
||||||
|
if (sl->state & QStyle::State_Sunken) {
|
||||||
|
const CGRect knobRect = [slider.cell knobRectFlipped:slider.isFlipped];
|
||||||
|
CGPoint pressPoint;
|
||||||
|
pressPoint.x = CGRectGetMidX(knobRect);
|
||||||
|
pressPoint.y = CGRectGetMidY(knobRect);
|
||||||
|
[slider.cell startTrackingAt:pressPoint inView:slider];
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user