diff options
author | Caroline Chao <caroline.chao@digia.com> | 2013-09-02 13:01:32 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-04 08:01:11 +0200 |
commit | afce2b528ce30e19af618b077e3f184cf290fa81 (patch) | |
tree | 1d984f8109043dacaabc9c6bf73bb567372cbc4f /src | |
parent | 7012db159bc4196444ace26991b24a31e3fba495 (diff) |
Fix QSpinBox size calculation problem with stylesheets
Problem caused by change a317ee0a6fa76d1166f6da8593d39eaf7afce83c
Task-number: QTBUG-31602
Change-Id: Ie8948445a58f51946f21d567ba91f9f10b848f8b
Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/widgets/styles/qstylesheetstyle.cpp | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 7b4b882e56..85520d3c40 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -4810,10 +4810,22 @@ QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *op switch (ct) { case CT_SpinBox: // ### hopelessly broken QAbstractSpinBox (part 1) - if (rule.hasBox() || !rule.hasNativeBorder()) - return csz; - return rule.baseStyleCanDraw() ? baseStyle()->sizeFromContents(ct, opt, sz, w) - : QWindowsStyle::sizeFromContents(ct, opt, sz, w); + if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) { + // Add some space for the up/down buttons + QRenderRule subRule = renderRule(w, opt, PseudoElement_SpinBoxUpButton); + if (subRule.hasDrawable()) { + QRect r = positionRect(w, rule, subRule, PseudoElement_SpinBoxUpButton, + opt->rect, opt->direction); + sz += QSize(r.width(), 0); + } else { + QSize defaultUpSize = defaultSize(w, subRule.size(), spinbox->rect, PseudoElement_SpinBoxUpButton); + sz += QSize(defaultUpSize.width(), 0); + } + if (rule.hasBox() || !rule.hasNativeBorder()) + sz = rule.boxSize(sz); + return sz; + } + break; case CT_ToolButton: if (rule.hasBox() || !rule.hasNativeBorder() || !rule.baseStyleCanDraw()) sz += QSize(3, 3); // ### broken QToolButton @@ -4858,14 +4870,8 @@ QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *op case CT_GroupBox: case CT_LineEdit: #ifndef QT_NO_SPINBOX - // ### hopelessly broken QAbstractSpinBox (part 2) - if (QAbstractSpinBox *spinBox = qobject_cast<QAbstractSpinBox *>(w ? w->parentWidget() : 0)) { - QRenderRule rule = renderRule(spinBox, opt); - if (rule.hasBox() || !rule.hasNativeBorder()) - return csz; - return rule.baseStyleCanDraw() ? baseStyle()->sizeFromContents(ct, opt, sz, w) - : QWindowsStyle::sizeFromContents(ct, opt, sz, w); - } + if (qobject_cast<QAbstractSpinBox *>(w ? w->parentWidget() : 0)) + return csz; // we only care about the size hint of the line edit #endif if (rule.hasBox() || !rule.hasNativeBorder()) { return rule.boxSize(sz); |