diff options
author | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2021-08-17 08:39:18 +0200 |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2021-08-18 11:42:19 +0200 |
commit | 0d43643844c9e4ac05ae6175e03f722bc54fff7e (patch) | |
tree | e63431740132e86c6ed19262404b425776d1b973 | |
parent | 0362c1e8bf5c42940b686347af495b888f0001e3 (diff) |
macOS: ensure that you can set a custom button background
As it stood, the implicit size of a button would be empty
if assigning it a custom background with an implicit size.
This differs from the other styles.
This patch will follow the same logic as in e.g the Fusion
style, and use the maximum size of the background
and the content item as the buttons implicit size.
Task-number: QTBUG-95544
Change-Id: Ic868a5f78cfc7ea6b2dd00c84689c5ab24891121
(adapted from commit 20054ba885804e928)
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r-- | src/imports/nativestyle/controls/DefaultButton.qml | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/imports/nativestyle/controls/DefaultButton.qml b/src/imports/nativestyle/controls/DefaultButton.qml index 7e55aaa2..696becb2 100644 --- a/src/imports/nativestyle/controls/DefaultButton.qml +++ b/src/imports/nativestyle/controls/DefaultButton.qml @@ -45,11 +45,10 @@ T.Button { readonly property bool __nativeBackground: background instanceof NativeStyle.StyleItem - // Since QQuickControl will subtract the insets from the control size to - // figure out the background size, we need to reverse that here, otherwise - // the control ends up too big. - implicitWidth: implicitBackgroundWidth + leftInset + rightInset - implicitHeight: implicitBackgroundHeight + topInset + bottomInset + implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, + implicitContentWidth + leftPadding + rightPadding) + implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, + implicitContentHeight + topPadding + bottomPadding) font.pixelSize: __nativeBackground ? background.styleFont(control).pixelSize : undefined |