Use lineedit svg margins in sizeHint calculation

QQC button heights are max(backgroundHeight, label + margins).
QQC lineedits are only from the background

We need to take the margins into consideration when deciding how high
the textbox should be otherwise we're effectively just ignoring what the
SVG says.

This means button and textbox on the login screen are now the same
height.

REVIEW: 125240
This commit is contained in:
David Edmundson 2015-09-15 13:25:20 +01:00
parent 4b4461d76b
commit 7453beb9ce
2 changed files with 21 additions and 3 deletions

View File

@ -42,7 +42,13 @@ QtQuickControlStyle.TextFieldStyle {
renderType: control.echoMode == TextInput.Normal ? Text.NativeRendering : Text.QtRendering
background: Item {
implicitHeight: theme.mSize(theme.defaultFont).height * 1.6
//QQC button heights are max(backgroundHeight, label + margins).
//QQC lineedits are only from the background (and if background is not set, just an arbirtary value of 25)
//Why? I don't know
//In order to get the same height in both buttons and lineedits we need to apply the same rule here
implicitHeight: Math.max(theme.mSize(theme.defaultFont).height * 1.6, theme.mSize(theme.defaultFont).height + base.margins.top + base.margins.bottom)
implicitWidth: theme.mSize(theme.defaultFont).width * 12
Private.TextFieldFocus {
@ -53,8 +59,6 @@ QtQuickControlStyle.TextFieldStyle {
PlasmaCore.FrameSvgItem {
id: base
anchors.fill: parent
// TODO: see what is the correct policy for margins
//anchors.fill: parent
imagePath: "widgets/lineedit"
prefix: "base"
}

View File

@ -2,6 +2,7 @@ import QtQuick 2.0
import org.kde.plasma.components 2.0 as PlasmaComponents
import QtQuick.Controls 1.2
import QtQuick.Layouts 1.2
Rectangle
{
@ -93,6 +94,19 @@ Rectangle
}
}
}
Label {
text: "button and textfield should have the same height"
}
RowLayout {
PlasmaComponents.Button {
text: "test"
}
PlasmaComponents.TextField {
}
}
}
}