From 6fa1038a85f8e0da7c91b510cf01fe1bbcf37c0f Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Tue, 8 Dec 2020 21:23:48 +0100 Subject: QHeaderView: respect the font role while calculating the elided text MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Amends 4d943846128118e1b9932a17ce6f977a0f4127a5: - The macOS style must now elide the text by it's own since it is no longer done by QHeaderView - Add documentation of QStyleOptionHeader::textElideMode - Remove unused variables from QHeaderView::initStyleOptionForIndex() Task-number: QTBUG-86426 Change-Id: I98fc6771c0cd56d6002390125ffbab1269f6dd39 Reviewed-by: Tor Arne Vestbø --- src/plugins/styles/mac/qmacstyle_mac.mm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/plugins/styles') diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 152d51da1a..e6939a0fda 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -3520,9 +3520,12 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter proxy()->drawItemPixmap(p, pixr, Qt::AlignVCenter, pixmap); textr.translate(pixmap.width() / pixmap.devicePixelRatio() + 2, 0); } + QString text = header->text; + if (header->textElideMode != Qt::ElideNone) + text = header->fontMetrics.elidedText(text, header->textElideMode, textr.width()); proxy()->drawItemText(p, textr, header->textAlignment | Qt::AlignVCenter, header->palette, - header->state & State_Enabled, header->text, QPalette::ButtonText); + header->state.testFlag(State_Enabled), text, QPalette::ButtonText); p->restore(); } break; -- cgit v1.2.3