From 09c4c95cf067a7a2a6abf97b60427ae8f7df6bdd Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 14 May 2014 11:10:33 +0200 Subject: TextFieldStyle: more fool-proof size calculation This ensures that such style gets a sensible default size: TextField { text: "Hello" style: TextFieldStyle { font.pixelSize: 30 background: Rectangle { color:"lightgray" } } } Change-Id: I370d8ad324cda09c9b085191ab452c4f8994d1d9 Reviewed-by: Gabriel de Dietrich --- src/controls/Styles/Base/TextFieldStyle.qml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/controls') diff --git a/src/controls/Styles/Base/TextFieldStyle.qml b/src/controls/Styles/Base/TextFieldStyle.qml index 80fa9c8e..d999551c 100644 --- a/src/controls/Styles/Base/TextFieldStyle.qml +++ b/src/controls/Styles/Base/TextFieldStyle.qml @@ -114,9 +114,6 @@ Style { /*! The background of the text field. */ property Component background: Item { - implicitWidth: Math.round(control.__contentHeight * 8) - implicitHeight: Math.max(25, Math.round(control.__contentHeight * 1.2)) - baselineOffset: control.__baselineOffset Rectangle { anchors.fill: parent anchors.bottomMargin: -1 @@ -149,9 +146,9 @@ Style { property color selectionColor: style.selectionColor property color selectedTextColor: style.selectedTextColor - implicitWidth: backgroundLoader.implicitWidth ? backgroundLoader.implicitWidth : 100 - implicitHeight: backgroundLoader.implicitHeight ? backgroundLoader.implicitHeight : 20 - baselineOffset: backgroundLoader.item ? padding.top + backgroundLoader.item.baselineOffset : 0 + implicitWidth: backgroundLoader.implicitWidth || Math.round(control.__contentHeight * 8) + implicitHeight: backgroundLoader.implicitHeight || Math.max(25, Math.round(control.__contentHeight * 1.2)) + baselineOffset: padding.top + control.__baselineOffset property color placeholderTextColor: style.placeholderTextColor property font font: style.font -- cgit v1.2.3