From a2749dc9c71809c9ce3566d741cf133b5bf7e046 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 8 Mar 2019 15:40:30 +0100 Subject: [PATCH] textfield height based only on clear text Summary: as the implicit height could change when switching to password mode, use a textmetrics which always computes it from the visible text BUG:399155 Test Plan: height doesn't change Reviewers: #plasma, ngraham, rooty Reviewed By: ngraham, rooty Subscribers: sitter, rooty, ngraham, kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D19599 --- src/declarativeimports/plasmastyle/TextFieldStyle.qml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/declarativeimports/plasmastyle/TextFieldStyle.qml b/src/declarativeimports/plasmastyle/TextFieldStyle.qml index 33814b3cc..d2d602d91 100644 --- a/src/declarativeimports/plasmastyle/TextFieldStyle.qml +++ b/src/declarativeimports/plasmastyle/TextFieldStyle.qml @@ -17,7 +17,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA. */ -import QtQuick 2.0 +import QtQuick 2.6 import QtQuick.Window 2.2 import QtQuick.Controls 1.0 import QtQuick.Controls.Styles 1.1 as QtQuickControlStyle @@ -57,10 +57,17 @@ QtQuickControlStyle.TextFieldStyle { //In order to get the same height in both buttons and lineedits we need to apply the same rule here - implicitHeight: Math.max(control.cursorRectangle.height * 1.6, control.cursorRectangle.height + base.margins.top + base.margins.bottom) + implicitHeight: Math.max(metrics.height * 1.6, + metrics.height + base.margins.top + base.margins.bottom) implicitWidth: theme.mSize(theme.defaultFont).width * 12 opacity: control.enabled ? 1 : 0.6 + TextMetrics { + id: metrics + text: "M" + font: control.font + } + Private.TextFieldFocus { id: hover state: control.activeFocus ? "focus" : (control.hovered ? "hover" : "hidden")