diff options
Diffstat (limited to 'src/widgets/styles/qstylesheetstyle.cpp')
-rw-r--r-- | src/widgets/styles/qstylesheetstyle.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 2ab9756f8d..9fcb8ba522 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -4449,14 +4449,14 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op case PE_PanelLineEdit: if (const QStyleOptionFrame *frm = qstyleoption_cast<const QStyleOptionFrame *>(opt)) { -#if QT_CONFIG(spinbox) - if (w && qobject_cast<const QAbstractSpinBox *>(w->parentWidget())) { - QRenderRule spinboxRule = renderRule(w->parentWidget(), opt); - if (!spinboxRule.hasNativeBorder() || !spinboxRule.baseStyleCanDraw()) + QWidget *container = containerWidget(w); + if (container != w) { + QRenderRule containerRule = renderRule(container, opt); + if (!containerRule.hasNativeBorder() || !containerRule.baseStyleCanDraw()) return; - rule = spinboxRule; + rule = containerRule; } -#endif + if (rule.hasNativeBorder()) { QStyleOptionFrame frmOpt(*frm); rule.configurePalette(&frmOpt.palette, QPalette::Text, QPalette::Base); @@ -5171,18 +5171,19 @@ QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *op QSize sz(csz); if (mi->text.contains(QLatin1Char('\t'))) sz.rwidth() += 12; //as in QCommonStyle - bool checkable = mi->checkType != QStyleOptionMenuItem::NotCheckable; if (!mi->icon.isNull()) { const int pmSmall = pixelMetric(PM_SmallIconSize); const QSize pmSize = mi->icon.actualSize(QSize(pmSmall, pmSmall)); - sz.rwidth() += pmSize.width() + 4; - } else if (checkable) { + sz.rwidth() += std::max(mi->maxIconWidth, pmSize.width()) + 4; + } else if (mi->menuHasCheckableItems) { QRenderRule subSubRule = renderRule(w, opt, PseudoElement_MenuCheckMark); QRect checkmarkRect = positionRect(w, subRule, subSubRule, PseudoElement_MenuCheckMark, opt->rect, opt->direction); sz.rwidth() += std::max(mi->maxIconWidth, checkmarkRect.width()) + 4; + } else { + sz.rwidth() += mi->maxIconWidth; } if (subRule.hasFont) { - QFontMetrics fm(subRule.font); + QFontMetrics fm(subRule.font.resolve(mi->font)); const QRect r = fm.boundingRect(QRect(), Qt::TextSingleLine | Qt::TextShowMnemonic, mi->text); sz = sz.expandedTo(r.size()); } |