aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2020-09-16 14:56:39 +0200
committerRichard Moe Gustavsen <richard.gustavsen@qt.io>2020-09-17 14:14:52 +0200
commite5827955cfae9928d4d0213b7db51f72fd765562 (patch)
treef850ef613b0304a72ad9e84fad803689b74e353b
parentae6132cb20584357fb342ef51f15523e53b7532a (diff)
Native style: implement implicit minimum size
QStyle doesn't calculate a sensible minimum implicit size for us, only a implicit size that matches the size of the contents. This means that if the contents is empty (e.g a TextField that has no text), the implicit size will typically be smaller than what a sensible minimum should be. Note that for widgets, a sensible preffered size is set from the widgets themselves, and not QStyle. Which explains why the sizes we get from QStyle can sometimes be too small. Therefore, add a sensible minimum implicit size to all the controls that suffers from this problem. We let QStyle continue to calculate the actual minimum size given the contents as before (which will end up as the StyleItem's implicit size), and instead fix the recommended minimum size directly in the QML style files. Change-Id: Ic4097776e40d0de64312e4099d7fe4c7fc1ca9d1 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r--src/imports/controls/macos/SpinBox.qml3
-rw-r--r--src/imports/nativestyle/controls/DefaultComboBox.qml3
-rw-r--r--src/imports/nativestyle/controls/DefaultDial.qml6
-rw-r--r--src/imports/nativestyle/controls/DefaultProgressBar.qml6
-rw-r--r--src/imports/nativestyle/controls/DefaultSlider.qml6
-rw-r--r--src/imports/nativestyle/controls/DefaultSpinBox.qml5
6 files changed, 19 insertions, 10 deletions
diff --git a/src/imports/controls/macos/SpinBox.qml b/src/imports/controls/macos/SpinBox.qml
index 9de95c16..a178dd14 100644
--- a/src/imports/controls/macos/SpinBox.qml
+++ b/src/imports/controls/macos/SpinBox.qml
@@ -48,7 +48,8 @@ T.SpinBox {
font.pixelSize: nativeBackground ? background.styleFont(control).pixelSize : undefined
- implicitWidth: implicitBackgroundWidth + leftInset + rightInset
+ implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
+ 90 /* minimum */ )
implicitHeight: Math.max(implicitBackgroundHeight, up.implicitIndicatorHeight + down.implicitIndicatorHeight)
+ topInset + bottomInset
diff --git a/src/imports/nativestyle/controls/DefaultComboBox.qml b/src/imports/nativestyle/controls/DefaultComboBox.qml
index 1205d0b6..91726921 100644
--- a/src/imports/nativestyle/controls/DefaultComboBox.qml
+++ b/src/imports/nativestyle/controls/DefaultComboBox.qml
@@ -47,7 +47,8 @@ T.ComboBox {
readonly property bool nativeBackground: background instanceof NativeStyle.StyleItem
implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
- implicitContentWidth + leftPadding + rightPadding)
+ implicitContentWidth + leftPadding + rightPadding,
+ 90 /* minimum */ )
implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
implicitContentHeight + topPadding + bottomPadding,
implicitIndicatorHeight + topPadding + bottomPadding)
diff --git a/src/imports/nativestyle/controls/DefaultDial.qml b/src/imports/nativestyle/controls/DefaultDial.qml
index 0f1d2c7d..42cc1271 100644
--- a/src/imports/nativestyle/controls/DefaultDial.qml
+++ b/src/imports/nativestyle/controls/DefaultDial.qml
@@ -45,9 +45,11 @@ T.Dial {
readonly property bool nativeBackground: background instanceof NativeStyle.StyleItem
implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
- implicitContentWidth + leftPadding + rightPadding)
+ implicitContentWidth + leftPadding + rightPadding,
+ 80 /* minimum */ )
implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
- implicitContentHeight + topPadding + bottomPadding)
+ implicitContentHeight + topPadding + bottomPadding,
+ 80 /* minimum */ )
font.pixelSize: nativeBackground ? background.styleFont(control).pixelSize : undefined
diff --git a/src/imports/nativestyle/controls/DefaultProgressBar.qml b/src/imports/nativestyle/controls/DefaultProgressBar.qml
index 0bf23ec4..80b0b94a 100644
--- a/src/imports/nativestyle/controls/DefaultProgressBar.qml
+++ b/src/imports/nativestyle/controls/DefaultProgressBar.qml
@@ -45,9 +45,11 @@ T.ProgressBar {
readonly property bool nativeBackground: background instanceof NativeStyle.StyleItem
implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
- implicitContentWidth + leftPadding + rightPadding)
+ implicitContentWidth + leftPadding + rightPadding,
+ control.horizontal ? 90 : 0 /* minimum */ )
implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
- implicitContentHeight + topPadding + bottomPadding)
+ implicitContentHeight + topPadding + bottomPadding,
+ control.vertical ? 90 : 0 /* minimum */ )
font.pixelSize: nativeIndicator ? indicator.styleFont(control).pixelSize : undefined
diff --git a/src/imports/nativestyle/controls/DefaultSlider.qml b/src/imports/nativestyle/controls/DefaultSlider.qml
index 8648143d..02459497 100644
--- a/src/imports/nativestyle/controls/DefaultSlider.qml
+++ b/src/imports/nativestyle/controls/DefaultSlider.qml
@@ -45,9 +45,11 @@ T.Slider {
readonly property bool nativeBackground: background instanceof NativeStyle.StyleItem
implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
- implicitHandleWidth + leftPadding + rightPadding)
+ implicitHandleWidth + leftPadding + rightPadding,
+ control.horizontal ? 90 : 0 /* minimum */ )
implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
- implicitHandleHeight + topPadding + bottomPadding)
+ implicitHandleHeight + topPadding + bottomPadding,
+ control.vertical ? 90 : 0 /* minimum */ )
font.pixelSize: nativeBackground ? background.styleFont(control).pixelSize : undefined
diff --git a/src/imports/nativestyle/controls/DefaultSpinBox.qml b/src/imports/nativestyle/controls/DefaultSpinBox.qml
index c959516a..100ccf6a 100644
--- a/src/imports/nativestyle/controls/DefaultSpinBox.qml
+++ b/src/imports/nativestyle/controls/DefaultSpinBox.qml
@@ -44,8 +44,9 @@ T.SpinBox {
readonly property bool nativeBackground: background instanceof NativeStyle.StyleItem
- implicitWidth: implicitBackgroundWidth + spacing + up.implicitIndicatorWidth
- + leftInset + rightInset
+ implicitWidth: Math.max(implicitBackgroundWidth + spacing + up.implicitIndicatorWidth
+ + leftInset + rightInset,
+ 90 /* minimum */ )
implicitHeight: Math.max(implicitBackgroundHeight, up.implicitIndicatorHeight + down.implicitIndicatorHeight
+ (spacing * 3)) + topInset + bottomInset