Commit 74b05b5c authored by J-P Nurmi's avatar J-P Nurmi
Browse files

Android: text entry implicit size fits 20 characters


A native unlayouted EditText control fits 20 characters by default.
Let Qt Quick Controls Android Style use the same metrics instead of
adjusting to the textual contents. This gives empty TextField,
SpinBox and ComboBox sensible implicit sizes instead of shrinking
them down to something unusable.

Change-Id: I3cd3948aa3d64daada9d0b7d773cebb6627263f6
Reviewed-by: default avatarMitch Curtis <mitch.curtis@digia.com>
parent 1f6041cb
No related merge requests found
Showing with 22 additions and 7 deletions
......@@ -37,7 +37,7 @@
** $QT_END_LICENSE$
**
****************************************************************************/
import QtQuick 2.2
import QtQuick 2.4
import QtQuick.Window 2.2
import QtQuick.Controls 1.2
import QtQuick.Controls.Private 1.0
......@@ -70,7 +70,7 @@ Style {
readonly property real minWidth: styleDef.View_minWidth || 0
readonly property real minHeight: styleDef.View_minHeight || 0
readonly property real labelWidth: label.implicitWidth + paddingStart + paddingEnd
readonly property real labelWidth: Math.max(label.implicitWidth, metrics.width) + paddingStart + paddingEnd
readonly property real labelHeight: label.implicitHeight + bg.padding.top + bg.padding.bottom
implicitWidth: Math.max(minWidth, Math.max(bg.implicitWidth, labelWidth))
......@@ -85,6 +85,11 @@ Style {
styleDef: panel.styleDef.View_background
}
TextMetrics {
id: metrics
text: "12345678901234567890"
}
LabelStyle {
id: label
text: control.currentText
......
......@@ -37,7 +37,7 @@
** $QT_END_LICENSE$
**
****************************************************************************/
import QtQuick 2.2
import QtQuick 2.4
import QtQuick.Window 2.2
import QtQuick.Controls 1.2
import QtQuick.Controls.Private 1.0
......@@ -58,7 +58,7 @@ Style {
readonly property real contentWidth: Math.max(styleDef.View_minWidth || 0, styleData.contentWidth)
readonly property real contentHeight: Math.max(styleDef.View_minHeight || 0, styleData.contentHeight)
readonly property real labelWidth: label.implicitWidth + bg.padding.left + bg.padding.right
readonly property real labelWidth: Math.max(label.implicitWidth, metrics.width) + bg.padding.left + bg.padding.right
readonly property real labelHeight: label.implicitHeight + bg.padding.top + bg.padding.bottom
implicitWidth: Math.max(contentWidth, Math.max(bg.implicitWidth, labelWidth))
......@@ -88,6 +88,11 @@ Style {
readonly property int horizontalAlignment: Qt.AlignLeft
readonly property int verticalAlignment: Qt.AlignVCenter
TextMetrics {
id: metrics
text: "12345678901234567890"
}
LabelStyle {
id: label
visible: false
......
......@@ -37,7 +37,7 @@
** $QT_END_LICENSE$
**
****************************************************************************/
import QtQuick 2.2
import QtQuick 2.4
import QtQuick.Window 2.2
import QtQuick.Controls 1.2
import QtQuick.Controls.Private 1.0
......@@ -56,7 +56,7 @@ Style {
readonly property real minWidth: styleDef.View_minWidth || 0
readonly property real minHeight: styleDef.View_minHeight || 0
readonly property real labelWidth: label.implicitWidth + bg.padding.left + bg.padding.right
readonly property real labelWidth: Math.max(label.implicitWidth, metrics.width) + bg.padding.left + bg.padding.right
readonly property real labelHeight: label.implicitHeight + bg.padding.top + bg.padding.bottom
implicitWidth: Math.max(minWidth, Math.max(bg.implicitWidth, labelWidth))
......@@ -81,10 +81,15 @@ Style {
readonly property alias selectionColor: label.selectionColor
readonly property color selectedTextColor: label.selectedTextColor
TextMetrics {
id: metrics
text: "12345678901234567890"
}
LabelStyle {
id: label
visible: false
text: control.text
text: control.text || control.placeholderText
focused: control.activeFocus
window_focused: focused && control.Window.active
styleDef: panel.styleDef
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment