QMacStyle: Remove HITheme calls for QSizeGrip

That's no longer a thing on macOS. We still keep it around for
QMdiSubWindow, but we should support 4-edge resizing there as
do native windows.

In practice, because of WA_MacOpaqueSizeGrip, we were already
rendering the size grip manually instead of relying on HITheme.

Change-Id: If613a14f03dc650b457688f3f2f57631b5fb30a3
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
This commit is contained in:
Gabriel de Dietrich 2017-08-30 11:53:59 +07:00
parent d47a467ca6
commit b8947e9194

View File

@ -928,24 +928,15 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg
break; break;
} }
case QStyle::CT_SizeGrip: case QStyle::CT_SizeGrip:
// Not HIG kosher: mimic what we were doing earlier until we support 4-edge resizing in MDI subwindows
if (sz == QStyleHelper::SizeLarge || sz == QStyleHelper::SizeSmall) { if (sz == QStyleHelper::SizeLarge || sz == QStyleHelper::SizeSmall) {
CGRect r; int s = sz == QStyleHelper::SizeSmall ? 16 : 22; // large: pixel measured from HITheme, small: from my hat
CGPoint p = { 0, 0 };
HIThemeGrowBoxDrawInfo gbi;
gbi.version = 0;
gbi.state = kThemeStateActive;
gbi.kind = kHIThemeGrowBoxKindNormal;
gbi.direction = QApplication::isRightToLeft() ? kThemeGrowLeft | kThemeGrowDown
: kThemeGrowRight | kThemeGrowDown;
gbi.size = sz == QStyleHelper::SizeSmall ? kHIThemeGrowBoxSizeSmall : kHIThemeGrowBoxSizeNormal;
if (HIThemeGetGrowBoxBounds(&p, &gbi, &r) == noErr) {
int width = 0; int width = 0;
#if QT_CONFIG(mdiarea) #if QT_CONFIG(mdiarea)
if (widg && qobject_cast<QMdiSubWindow *>(widg->parentWidget())) if (widg && qobject_cast<QMdiSubWindow *>(widg->parentWidget()))
width = r.size.width; width = s;
#endif #endif
ret = QSize(width, r.size.height); ret = QSize(width, s);
}
} }
break; break;
case QStyle::CT_ComboBox: case QStyle::CT_ComboBox:
@ -4510,18 +4501,15 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
} }
break; break;
case CE_SizeGrip: { case CE_SizeGrip: {
if (w && w->testAttribute(Qt::WA_MacOpaqueSizeGrip)) { // This is not HIG kosher: Fall back to the old stuff until we decide what to do.
HIThemeGrowBoxDrawInfo gdi; #ifndef QT_NO_MDIAREA
gdi.version = qt_mac_hitheme_version; if (!w || !qobject_cast<QMdiSubWindow *>(w->parentWidget()))
gdi.state = tds; #endif
gdi.kind = kHIThemeGrowBoxKindNormal; break;
gdi.direction = kThemeGrowRight | kThemeGrowDown;
gdi.size = kHIThemeGrowBoxSizeNormal; if (w->testAttribute(Qt::WA_MacOpaqueSizeGrip))
CGPoint pt = CGPointMake(opt->rect.x(), opt->rect.y()); p->fillRect(opt->rect, opt->palette.window());
HIThemeDrawGrowBox(&pt, &gdi, cg, kHIThemeOrientationNormal);
} else {
// It isn't possible to draw a transparent size grip with the
// native API, so we do it ourselves here.
QPen lineColor = QColor(82, 82, 82, 192); QPen lineColor = QColor(82, 82, 82, 192);
lineColor.setWidth(1); lineColor.setWidth(1);
p->save(); p->save();
@ -4542,7 +4530,6 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
p->drawLine(start, end); p->drawLine(start, end);
} }
p->restore(); p->restore();
}
break; break;
} }
case CE_Splitter: case CE_Splitter: