diff options
author | Richard Moe Gustavsen <[email protected]> | 2021-08-12 13:25:27 +0200 |
---|---|---|
committer | Richard Moe Gustavsen <[email protected]> | 2021-08-12 15:11:25 +0200 |
commit | 9738d49b65b63da2a26035ad250f48fac182dfad (patch) | |
tree | d0d21af1b9c05511f1e69410a7563621819df973 | |
parent | 20054ba885804e928726a5c515ab29306aff036b (diff) |
Windows, Button.qml: inherit from DefaultButton, and remove duplicated code
Let Button.qml inherit from DefaultButton.qml, since they share
a lot of the same code. This then means we can remove a lot of
the duplicated code. We will also get any bug fixes done to
DefaultButton.qml for free, like ensuring that you can use
Button together with custom background delegates.
Pick-to: 6.2 6.1
Fixes: QTBUG-95544
Change-Id: Ie5edae58a44ae6e7b86cc016a07439844e387b1e
Reviewed-by: Mitch Curtis <[email protected]>
-rw-r--r-- | src/quickcontrols2/windows/Button.qml | 23 |
1 files changed, 1 insertions, 22 deletions
diff --git a/src/quickcontrols2/windows/Button.qml b/src/quickcontrols2/windows/Button.qml index 1b73e1de00..6b28f8e7c5 100644 --- a/src/quickcontrols2/windows/Button.qml +++ b/src/quickcontrols2/windows/Button.qml @@ -36,27 +36,11 @@ import QtQuick import QtQuick.Controls.impl -import QtQuick.Templates as T import QtQuick.NativeStyle as NativeStyle -T.Button { +NativeStyle.DefaultButton { id: control - 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 - - font.pixelSize: __nativeBackground ? background.styleFont(control).pixelSize : undefined - - leftPadding: __nativeBackground ? background.contentPadding.left : 5 - rightPadding: __nativeBackground ? background.contentPadding.right : 5 - topPadding: __nativeBackground ? background.contentPadding.top : 5 - bottomPadding: __nativeBackground ? background.contentPadding.bottom : 5 - background: NativeStyle.Button { control: control contentWidth: contentItem.implicitWidth @@ -79,11 +63,6 @@ T.Button { Behavior on opacity { NumberAnimation { duration: hoverButton.transitionDuration } } } - icon.width: 24 - icon.height: 24 - icon.color: control.checked || control.highlighted ? control.palette.brightText : - control.flat && !control.down ? (control.visualFocus ? control.palette.highlight : control.palette.windowText) : control.palette.buttonText - contentItem: IconLabel { spacing: control.spacing mirrored: control.mirrored |