QMacStyle: skip 'custom' rendering of CE_HeaderLabel
Instead, similar to 'Fusion' style use what common style can do, thus respecting text alignment and not always forcing VCenter alignment. Fixes: QTBUG-97698 Change-Id: I89ad01807afc217c3c33650e1f1d255d0b81ed46 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
7d7663cfc4
commit
081a2b9b1f
@ -3556,34 +3556,6 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
|
|||||||
ir.right() - headerSectionSeparatorInset, ir.bottom()));
|
ir.right() - headerSectionSeparatorInset, ir.bottom()));
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
|
||||||
case CE_HeaderLabel:
|
|
||||||
if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
|
|
||||||
p->save();
|
|
||||||
QRect textr = header->rect;
|
|
||||||
if (!header->icon.isNull()) {
|
|
||||||
QIcon::Mode mode = QIcon::Disabled;
|
|
||||||
if (opt->state & State_Enabled)
|
|
||||||
mode = QIcon::Normal;
|
|
||||||
int iconExtent = proxy()->pixelMetric(PM_SmallIconSize);
|
|
||||||
QPixmap pixmap = header->icon.pixmap(QSize(iconExtent, iconExtent), p->device()->devicePixelRatio(), mode);
|
|
||||||
|
|
||||||
QRect pixr = header->rect;
|
|
||||||
QSizeF size = pixmap.deviceIndependentSize();
|
|
||||||
pixr.setY(header->rect.center().y() - (size.height() - 1) / 2);
|
|
||||||
proxy()->drawItemPixmap(p, pixr, Qt::AlignVCenter, pixmap);
|
|
||||||
textr.translate(size.width() + 2, 0);
|
|
||||||
}
|
|
||||||
QString text = header->text;
|
|
||||||
if (const QStyleOptionHeaderV2 *headerV2 = qstyleoption_cast<const QStyleOptionHeaderV2 *>(header)) {
|
|
||||||
if (headerV2->textElideMode != Qt::ElideNone)
|
|
||||||
text = header->fontMetrics.elidedText(text, headerV2->textElideMode, textr.width());
|
|
||||||
}
|
|
||||||
|
|
||||||
proxy()->drawItemText(p, textr, header->textAlignment | Qt::AlignVCenter, header->palette,
|
|
||||||
header->state.testFlag(State_Enabled), text, QPalette::ButtonText);
|
|
||||||
p->restore();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case CE_ToolButtonLabel:
|
case CE_ToolButtonLabel:
|
||||||
if (const QStyleOptionToolButton *tb = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) {
|
if (const QStyleOptionToolButton *tb = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user