macOS: make the slider knob big enough for BigSur and Monterey

The slider is very touch friendly from macOS 11 on, and the knob is quite
large. Give it some extra pixels, and adjust the test accordingly.

Pick-to: 6.2
Task-number: QTBUG-98093
Change-Id: Iedf6db1081cdd4013ca29ce760aea1e0361b1123
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
This commit is contained in:
Volker Hilsheimer 2021-11-10 15:04:58 +01:00
parent eab40726be
commit 6ff07ec23b
2 changed files with 10 additions and 2 deletions

View File

@ -844,6 +844,8 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QStyleOption
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))
@ -1024,6 +1026,8 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QStyleOption
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)

View File

@ -83,6 +83,10 @@ private:
#define SIZE(x, y, z) \
((size == QStyleHelper::SizeLarge) ? (x) : (size == QStyleHelper::SizeSmall) ? (y) : (z))
static bool bigSurOrAbove() {
return QOperatingSystemVersion::current() >= QOperatingSystemVersion::MacOSBigSur;
}
void tst_QMacStyle::sizeHints_data()
{
QTest::addColumn<QStyleHelper::WidgetSizePolicy>("size");
@ -133,7 +137,7 @@ void tst_QMacStyle::sizeHints()
QCOMPARE(sh(&comboBox3).height(), SIZE(32, -1, -1));
QSlider slider1(Qt::Horizontal, &w);
QCOMPARE(sh(&slider1).height(), SIZE(15, 12, 10));
QCOMPARE(sh(&slider1).height(), SIZE(bigSurOrAbove() ? 18 : 15, 12, 10));
slider1.setTickPosition(QSlider::TicksAbove);
QCOMPARE(sh(&slider1).height(), SIZE(24, 17, 16)); // Builder
@ -142,7 +146,7 @@ void tst_QMacStyle::sizeHints()
QCOMPARE(sh(&slider1).height(), SIZE(24, 17, 16)); // Builder
slider1.setTickPosition(QSlider::TicksBothSides);
QVERIFY(sh(&slider1).height() > SIZE(15, 12, 10)); // common sense
QVERIFY(sh(&slider1).height() > SIZE(bigSurOrAbove() ? 18 : 15, 12, 10)); // common sense
QPushButton ok1("OK", &w);
QPushButton cancel1("Cancel", &w);