From d1b4b38046388d7823ec66e8875301dc70e0db0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Arve=20S=C3=A6ther?= Date: Wed, 30 Sep 2020 19:18:48 +0200 Subject: nativestyle: SpinBox on Windows Change-Id: I334af68282a59099698e46020b0644318eae5cce Reviewed-by: Richard Moe Gustavsen --- src/imports/nativestyle/qstyle/qquickcommonstyle.cpp | 16 +++++++++++----- .../nativestyle/qstyle/windows/qquickwindowsxpstyle.cpp | 8 -------- 2 files changed, 11 insertions(+), 13 deletions(-) (limited to 'src/imports/nativestyle/qstyle') diff --git a/src/imports/nativestyle/qstyle/qquickcommonstyle.cpp b/src/imports/nativestyle/qstyle/qquickcommonstyle.cpp index 6e662e3d..45f23f05 100644 --- a/src/imports/nativestyle/qstyle/qquickcommonstyle.cpp +++ b/src/imports/nativestyle/qstyle/qquickcommonstyle.cpp @@ -4652,11 +4652,17 @@ QSize QCommonStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, c case CT_SpinBox: if (const QStyleOptionSpinBox *vopt = qstyleoption_cast(opt)) { // Add button + frame widths - const qreal dpi = QStyleHelper::dpi(opt); - const bool hasButtons = (vopt->buttonSymbols != QStyleOptionSpinBox::NoButtons); - const int buttonWidth = hasButtons ? qRound(QStyleHelper::dpiScaled(16, dpi)) : 0; - const int fw = vopt->frame ? proxy()->pixelMetric(PM_SpinBoxFrameWidth, vopt) : 0; - sz += QSize(buttonWidth + 2*fw, 2*fw); + if (vopt->subControls == SC_SpinBoxFrame) { + const qreal dpi = QStyleHelper::dpi(opt); + const bool hasButtons = (vopt->buttonSymbols != QStyleOptionSpinBox::NoButtons); + const int buttonWidth = hasButtons ? qRound(QStyleHelper::dpiScaled(16, dpi)) : 0; + const int fw = vopt->frame ? proxy()->pixelMetric(PM_SpinBoxFrameWidth, vopt) : 0; + sz += QSize(buttonWidth + 2*fw, 1 + 2*fw); + } else { + const QSize buttonSize = proxy()->subControlRect(CC_SpinBox, vopt, SC_SpinBoxUp).size(); + const int upAndDownTogetherHeight = buttonSize.height() * 2; + sz += QSize(buttonSize.width(), upAndDownTogetherHeight); + } } break; case CT_Slider: diff --git a/src/imports/nativestyle/qstyle/windows/qquickwindowsxpstyle.cpp b/src/imports/nativestyle/qstyle/windows/qquickwindowsxpstyle.cpp index d736f832..69180c62 100644 --- a/src/imports/nativestyle/qstyle/windows/qquickwindowsxpstyle.cpp +++ b/src/imports/nativestyle/qstyle/windows/qquickwindowsxpstyle.cpp @@ -3406,14 +3406,6 @@ QSize QWindowsXPStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt } } break; - case CT_SpinBox: - { - //Spinbox adds frame twice - sz = QWindowsStyle::sizeFromContents(ct, option, contentsSize); - int border = proxy()->pixelMetric(PM_SpinBoxFrameWidth, option); - sz -= QSize(2*border, 2*border); - } - break; case CT_TabWidget: sz += QSize(6, 6); break; -- cgit v1.2.3