summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPeng Wu <peng.wu@intopalo.com>2016-08-29 13:47:08 +0300
committerAndrew Knight <andrew.knight@intopalo.com>2016-09-04 05:12:20 +0000
commitb94111116f09a6e48741d35cf7abea47af99ef26 (patch)
tree4fa8e0196c387ee31c0a0ebcb12bcae52e5e35a8 /src
parent24bd7fd6518985f00e4102c2702ef50a8852b731 (diff)
Style sheets: detect and apply font set on QHeaderView section
Detect and apply style sheets font set when calculating QHeaderView section content size and drawing it. Change-Id: I542cd0d31bbe62f127c509f297eef0a576fec054 Task-number: QTBUG-55597 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
index 568a4755e4..eae4658bc9 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -3753,6 +3753,13 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
ParentStyle::drawControl(ce, opt, p, w);
return;
}
+ if (subRule.hasFont) {
+ const QFont oldFont = p->font();
+ p->setFont(subRule.font.resolve(p->font()));
+ baseStyle()->drawControl(ce, opt, p, w);
+ p->setFont(oldFont);
+ return;
+ }
}
break;
case CE_HeaderSection:
@@ -4866,13 +4873,14 @@ QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *op
case CT_HeaderSection: {
if (const QStyleOptionHeader *hdr = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
QRenderRule subRule = renderRule(w, opt, PseudoElement_HeaderViewSection);
- if (subRule.hasGeometry() || subRule.hasBox() || !subRule.hasNativeBorder()) {
+ if (subRule.hasGeometry() || subRule.hasBox() || !subRule.hasNativeBorder() || subRule.hasFont) {
sz = subRule.adjustSize(csz);
if (!subRule.hasGeometry()) {
QSize nativeContentsSize;
bool nullIcon = hdr->icon.isNull();
int iconSize = nullIcon ? 0 : pixelMetric(QStyle::PM_SmallIconSize, hdr, w);
- QSize txt = hdr->fontMetrics.size(0, hdr->text);
+ const QSize txt = subRule.hasFont ? QFontMetrics(subRule.font).size(0, hdr->text)
+ : hdr->fontMetrics.size(0, hdr->text);
nativeContentsSize.setHeight(qMax(iconSize, txt.height()));
nativeContentsSize.setWidth(iconSize + txt.width());
sz = sz.expandedTo(nativeContentsSize);