mirror of
https://github.com/crystalidea/qt-build-tools.git
synced 2024-11-22 19:00:04 +08:00
5.5.14: fix for QTBUG-98093 (backport to 5.15)
This commit is contained in:
parent
446a887d34
commit
f5af6fb404
@ -468,7 +468,11 @@ static bool setupSlider(NSSlider *slider, const QStyleOptionSlider *sl)
|
||||
if (sl->minimum >= sl->maximum)
|
||||
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.maxValue = sl->maximum;
|
||||
slider.intValue = sl->sliderPosition;
|
||||
@ -498,6 +502,14 @@ static bool setupSlider(NSSlider *slider, const QStyleOptionSlider *sl)
|
||||
// the cell for its metrics and to draw itself.
|
||||
[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;
|
||||
}
|
||||
|
||||
@ -844,6 +856,8 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg
|
||||
return ret;
|
||||
}
|
||||
|
||||
const bool isBigSurOrAbove = QOperatingSystemVersion::current() >= QOperatingSystemVersion::MacOSBigSur;
|
||||
|
||||
if (ct == QStyle::CT_CustomBase && widg) {
|
||||
#if QT_CONFIG(pushbutton)
|
||||
if (qobject_cast<const QPushButton *>(widg))
|
||||
@ -1038,6 +1052,8 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg
|
||||
w = qt_mac_aqua_get_metric(HSliderHeight);
|
||||
if (sld->tickPosition() != QSlider::NoTicks)
|
||||
w += qt_mac_aqua_get_metric(HSliderTickHeight);
|
||||
else if (isBigSurOrAbove)
|
||||
w += 3;
|
||||
} else {
|
||||
w = qt_mac_aqua_get_metric(VSliderWidth);
|
||||
if (sld->tickPosition() != QSlider::NoTicks)
|
||||
|
@ -153,6 +153,13 @@ void QSlider::initStyleOption(QStyleOptionSlider *option) const
|
||||
option->pageStep = d->pageStep;
|
||||
if (d->orientation == Qt::Horizontal)
|
||||
option->state |= QStyle::State_Horizontal;
|
||||
|
||||
if (d->pressedControl) {
|
||||
option->activeSubControls = d->pressedControl;
|
||||
option->state |= QStyle::State_Sunken;
|
||||
} else {
|
||||
option->activeSubControls = d->hoverControl;
|
||||
}
|
||||
}
|
||||
|
||||
bool QSliderPrivate::updateHoverControl(const QPoint &pos)
|
||||
@ -315,12 +322,6 @@ void QSlider::paintEvent(QPaintEvent *)
|
||||
opt.subControls = QStyle::SC_SliderGroove | QStyle::SC_SliderHandle;
|
||||
if (d->tickPosition != NoTicks)
|
||||
opt.subControls |= QStyle::SC_SliderTickmarks;
|
||||
if (d->pressedControl) {
|
||||
opt.activeSubControls = d->pressedControl;
|
||||
opt.state |= QStyle::State_Sunken;
|
||||
} else {
|
||||
opt.activeSubControls = d->hoverControl;
|
||||
}
|
||||
|
||||
style()->drawComplexControl(QStyle::CC_Slider, &opt, &p, this);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user