diff options
author | Jan Arve Sæther <jan-arve.saether@qt.io> | 2020-09-30 19:18:48 +0200 |
---|---|---|
committer | Jan Arve Sæther <jan-arve.saether@qt.io> | 2020-10-06 12:24:42 +0200 |
commit | d1b4b38046388d7823ec66e8875301dc70e0db0f (patch) | |
tree | 4e273b543e3069dcebd74161658744a9fe9bda61 /src/imports/nativestyle/qstyle | |
parent | 44b706274917af7836f4b5bdcd6b7975113a394f (diff) |
nativestyle: SpinBox on Windows
Change-Id: I334af68282a59099698e46020b0644318eae5cce
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/imports/nativestyle/qstyle')
-rw-r--r-- | src/imports/nativestyle/qstyle/qquickcommonstyle.cpp | 16 | ||||
-rw-r--r-- | src/imports/nativestyle/qstyle/windows/qquickwindowsxpstyle.cpp | 8 |
2 files changed, 11 insertions, 13 deletions
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<const QStyleOptionSpinBox *>(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; |