From 1a4c1d7eebcf1e901b3109b26bae70c56a80f0d2 Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Sun, 18 Oct 2015 23:52:00 +0100 Subject: [PATCH] Fix Button minimumWidth property Plasma's Button has an extra property "minimumWidth" which is an extra hint not in QQC to say "what is the size to exactly fit the contents". (it's a bit confusing, as we can perfectly handle a button below it's "minmimum" size) This should be based on the size the contents want to be (the implicitWidth), not how small the contents can go (which with is pretty meaningless when our button can elide) It got broken at some point recently. BUG: 353584 Change-Id: I637898c3abf98183bbae30d8f15c4d72801a3650 REVIEW: 125698 --- src/declarativeimports/plasmastyle/ButtonStyle.qml | 5 +++-- tests/components/button.qml | 13 ++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/declarativeimports/plasmastyle/ButtonStyle.qml b/src/declarativeimports/plasmastyle/ButtonStyle.qml index febec70fe..a96251293 100644 --- a/src/declarativeimports/plasmastyle/ButtonStyle.qml +++ b/src/declarativeimports/plasmastyle/ButtonStyle.qml @@ -32,13 +32,14 @@ import "private" as Private QtQuickControlStyle.ButtonStyle { id: style + //this is the minimum size that can hold the entire contents property int minimumWidth property int minimumHeight label: RowLayout { spacing: units.smallSpacing - property real minimumWidth: Layout.minimumWidth + style.padding.left + style.padding.right + property real minimumWidth: implicitWidth + style.padding.left + style.padding.right onMinimumWidthChanged: { if (control.minimumWidth !== undefined) { style.minimumWidth = minimumWidth; @@ -46,7 +47,7 @@ QtQuickControlStyle.ButtonStyle { } } - property real minimumHeight: Layout.preferredHeight + style.padding.top + style.padding.bottom + property real minimumHeight: implicitHeight + style.padding.top + style.padding.bottom onMinimumHeightChanged: { if (control.minimumHeight !== undefined) { style.minimumHeight = minimumHeight; diff --git a/tests/components/button.qml b/tests/components/button.qml index fdfc42d58..a645537ab 100644 --- a/tests/components/button.qml +++ b/tests/components/button.qml @@ -7,7 +7,7 @@ import QtQuick.Layouts 1.2 Rectangle { width: 500 - height: 300 + height: 500 color: "white" Grid { @@ -107,6 +107,17 @@ Rectangle } } + Label { + text: "minimum width property. Should be two letters wide" + } + + RowLayout { + PlasmaComponents.Button { + text: "AA" + implicitWidth: minimumWidth + } + } + } }