style doesn't depend from control properties

This commit is contained in:
Marco Martin 2014-07-24 17:47:19 +02:00
parent a39c8898b3
commit 9b06cbc392
2 changed files with 15 additions and 6 deletions

View File

@ -52,14 +52,18 @@ QtControls.Button {
property font font: theme.defaultFont property font font: theme.defaultFont
/** /**
* Smallest width this button can be to show all the contents * Smallest width this button can be to show all the contents.
* Compatibility with old Button control.
* The plasma style will update this property
*/ */
property real minimumWidth: 0//__style.minimumWidth property real minimumWidth: 0
/** /**
* Smallest height this button can be to show all the contents * Smallest height this button can be to show all the contents
* Compatibility with old Button control.
* The plasma style will update this property
*/ */
property real minimumHeight: 0//__style.minimumHeight property real minimumHeight: 0
style: Styles.ButtonStyle {} style: Styles.ButtonStyle {}
} }

View File

@ -29,6 +29,9 @@ import "../private" as Private
QtQuickControlStyle.ButtonStyle { QtQuickControlStyle.ButtonStyle {
id: style id: style
property int minimumWidth
property int minimumHeight
label: Row { label: Row {
id: buttonContent id: buttonContent
spacing: icon.valid ? units.smallSpacing : 0 spacing: icon.valid ? units.smallSpacing : 0
@ -36,6 +39,7 @@ QtQuickControlStyle.ButtonStyle {
property real minimumWidth: icon.width + label.implicitWidth + style.padding.left + style.padding.right + ((icon.valid) ? style.padding.left : 0) property real minimumWidth: icon.width + label.implicitWidth + style.padding.left + style.padding.right + ((icon.valid) ? style.padding.left : 0)
onMinimumWidthChanged: { onMinimumWidthChanged: {
if (control.minimumWidth !== undefined) { if (control.minimumWidth !== undefined) {
style.minimumWidth = minimumWidth;
control.minimumWidth = minimumWidth; control.minimumWidth = minimumWidth;
} }
} }
@ -43,7 +47,8 @@ QtQuickControlStyle.ButtonStyle {
property real minimumHeight: Math.max(units.iconSizes.small, label.implicitHeight) + style.padding.top + style.padding.bottom property real minimumHeight: Math.max(units.iconSizes.small, label.implicitHeight) + style.padding.top + style.padding.bottom
onMinimumHeightChanged: { onMinimumHeightChanged: {
if (control.minimumHeight !== undefined) { if (control.minimumHeight !== undefined) {
control.minimumHeight = minimumHeight style.minimumHeight = minimumHeight;
control.minimumHeight = minimumHeight;
} }
} }
@ -81,13 +86,13 @@ QtQuickControlStyle.ButtonStyle {
background: Item { background: Item {
implicitHeight: Math.floor(Math.max(theme.mSize(theme.defaultFont).height*1.6, control.minimumHeight)) implicitHeight: Math.floor(Math.max(theme.mSize(theme.defaultFont).height*1.6, style.minimumHeight))
implicitWidth: { implicitWidth: {
if (control.text.length == 0) { if (control.text.length == 0) {
height; height;
} else { } else {
Math.max(theme.mSize(theme.defaultFont).width*12, control.minimumWidth); Math.max(theme.mSize(theme.defaultFont).width*12, style.minimumWidth);
} }
} }