aboutsummaryrefslogtreecommitdiffstats
path: root/src/quickcontrols/macos/SpinBox.qml
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2022-12-13 13:04:45 +0100
committerRichard Moe Gustavsen <richard.gustavsen@qt.io>2022-12-19 15:59:40 +0100
commit3f8b598720f2edcf09f1831dc817841b681d12f7 (patch)
treeecc682605f0b6563fcf4c8ba7ebd2d0461f00c43 /src/quickcontrols/macos/SpinBox.qml
parentb307bf3c4f63c6e04874a972c747f18e18ddc199 (diff)
Spinbox: clip contentItem
If the text in a SpinBox is larger than its text field, then the text is drawn outside of the SpinBox covering the spinbox buttons. This patch will set a clip on the SpinBoxes, to ensure that the text is not drawn outside the bounds of the content item. The SpinBox implementation differs a bit from one style to the next, which means that some styles will only need to set a clip, while others will need a bit more change. Especially the Basic style will need to expand the size of the content item to make room for the focus rect (which the other styles don't have, or implement differently). There are also two versions of the SpinBox; One that has the up and down indicators placed on each side of the content item, and another that has them collected on only one side. It seems like the latter implementations has done a copy/paste of the padding from the former, and thereby has set a too large padding. This has also been fixed, as it's related to the clipping bug. Fixes: QTBUG-98355 Pick-to: 6.5 6.4 Change-Id: I2c1ce6d477cf809e2187fd80aecbc9edeb8e0c2d Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quickcontrols/macos/SpinBox.qml')
-rw-r--r--src/quickcontrols/macos/SpinBox.qml11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/quickcontrols/macos/SpinBox.qml b/src/quickcontrols/macos/SpinBox.qml
index 555b49eb32..dcc52f0ab2 100644
--- a/src/quickcontrols/macos/SpinBox.qml
+++ b/src/quickcontrols/macos/SpinBox.qml
@@ -8,9 +8,12 @@ import QtQuick.NativeStyle as NativeStyle
T.SpinBox {
id: control
- implicitWidth: Math.max(implicitContentWidth + leftInset + rightInset)
- implicitHeight: Math.max(implicitContentHeight, up.implicitIndicatorHeight + down.implicitIndicatorHeight)
- + topInset + bottomInset
+ // Note: the width of the indicators are calculated into the padding
+ implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
+ contentItem.implicitWidth + leftPadding + rightPadding)
+ implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
+ implicitContentHeight + topPadding + bottomPadding,
+ up.implicitIndicatorHeight, down.implicitIndicatorHeight)
spacing: 2
rightPadding: up.implicitIndicatorWidth + spacing
@@ -31,7 +34,7 @@ T.SpinBox {
selectedTextColor: control.palette.highlightedText
horizontalAlignment: Qt.AlignLeft
verticalAlignment: Qt.AlignVCenter
- implicitWidth: 100 // From IB XCode
+ implicitWidth: Math.max(100 /* from IB XCode */, contentWidth + leftPadding + rightPadding)
topPadding: 2
bottomPadding: 2