diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-09-19 21:54:52 +0200 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-09-19 21:54:53 +0200 |
commit | 15dc8b1d8e2db00dfcbe8d7f21150658f5de45b6 (patch) | |
tree | 6b9c908ca1cf0b1395fa91415f19b5adf8642ca7 /src/widgets | |
parent | ecc83677006dc7dffcd2417b1e3cff88b0615756 (diff) | |
parent | 6234286925153279ca259cec04429fa584187b16 (diff) |
Merge remote-tracking branch 'origin/5.14' into 5.15
Change-Id: I46ec05ade1c84e61f7f45562a218aa9ff55e2975
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/graphicsview/qgraphicsscene.h | 2 | ||||
-rw-r--r-- | src/widgets/styles/qstylesheetstyle.cpp | 20 |
2 files changed, 13 insertions, 9 deletions
diff --git a/src/widgets/graphicsview/qgraphicsscene.h b/src/widgets/graphicsview/qgraphicsscene.h index 3cc00ead08..d36a871533 100644 --- a/src/widgets/graphicsview/qgraphicsscene.h +++ b/src/widgets/graphicsview/qgraphicsscene.h @@ -115,7 +115,7 @@ public: BspTreeIndex, NoIndex = -1 }; - + Q_ENUM(ItemIndexMethod) enum SceneLayer { ItemLayer = 0x1, BackgroundLayer = 0x2, diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index dd225fbec3..48d2e268b8 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -615,7 +615,7 @@ public: public: int features; QBrush defaultBackground; - QFont font; + QFont font; // Be careful using this font directly. Prefer using font.resolve( ) bool hasFont; QHash<QString, QVariant> styleHints; @@ -3211,7 +3211,7 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC rule.drawRule(p, opt->rect); toolOpt.rect = rule.contentsRect(opt->rect); if (rule.hasFont) - toolOpt.font = rule.font; + toolOpt.font = rule.font.resolve(toolOpt.font); drawControl(CE_ToolButtonLabel, &toolOpt, p, w); } @@ -3514,7 +3514,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q const QFont oldFont = p->font(); if (rule.hasFont) - p->setFont(rule.font); + p->setFont(rule.font.resolve(p->font())); if (rule.hasPosition() && rule.position()->textAlignment != 0) { Qt::Alignment textAlignment = rule.position()->textAlignment; @@ -3678,7 +3678,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q subRule.configurePalette(&mi.palette, QPalette::HighlightedText, QPalette::Highlight); QFont oldFont = p->font(); if (subRule.hasFont) - p->setFont(subRule.font.resolve(p->font())); + p->setFont(subRule.font.resolve(mi.font)); else p->setFont(mi.font); @@ -4084,7 +4084,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q subRule.configurePalette(&boxCopy.palette, QPalette::ButtonText, QPalette::Button); QFont oldFont = p->font(); if (subRule.hasFont) - p->setFont(subRule.font); + p->setFont(subRule.font.resolve(p->font())); boxCopy.rect = subRule.contentsRect(opt->rect); if (subRule.hasImage()) { // the image is already drawn with CE_ToolBoxTabShape, adjust rect here @@ -4171,7 +4171,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q subRule.configurePalette(&tabCopy.palette, QPalette::WindowText, QPalette::Base); QFont oldFont = p->font(); if (subRule.hasFont) - p->setFont(subRule.font); + p->setFont(subRule.font.resolve(p->font())); if (subRule.hasBox() || !subRule.hasNativeBorder()) { tabCopy.rect = ce == CE_TabBarTabShape ? subRule.borderRect(r) : subRule.contentsRect(r); @@ -5035,8 +5035,12 @@ QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *op bool nullIcon = hdr->icon.isNull(); const int margin = pixelMetric(QStyle::PM_HeaderMargin, hdr, w); int iconSize = nullIcon ? 0 : pixelMetric(QStyle::PM_SmallIconSize, hdr, w); - const QSize txt = subRule.hasFont ? QFontMetrics(subRule.font).size(0, hdr->text) - : hdr->fontMetrics.size(0, hdr->text); + QFontMetrics fm = hdr->fontMetrics; + if (subRule.hasFont) { + QFont styleFont = w ? subRule.font.resolve(w->font()) : subRule.font; + fm = QFontMetrics(styleFont); + } + const QSize txt = fm.size(0, hdr->text); nativeContentsSize.setHeight(margin + qMax(iconSize, txt.height()) + margin); nativeContentsSize.setWidth((nullIcon ? 0 : margin) + iconSize + (hdr->text.isNull() ? 0 : margin) + txt.width() + margin); |