QmlDesigner: Fix the position of placeholder in FilterComboBox

The AutoCompleteString view had a bad position. The text property of the
TextMetrics was wrong, which caused the placeholder to have bad position
since the position was calculated with wrong text.

In addition, I prevented showing the placeholder when the root comboBox
is not opened, because otherwise it may show text when no item is
selected.

The main task was QDS-7662, which is now divided.

Task-number: QDS-7912
Change-Id: Ib937d923191ec3c544dae3259774cd2bb5b7adb0
Reviewed-by: Henning Gründl <henning.gruendl@qt.io>
This commit is contained in:
Ali Kianian
2022-10-11 17:47:20 +03:00
parent a0e87e458b
commit 88c7562582

View File

@@ -547,20 +547,27 @@ Item {
] ]
Text { Text {
visible: root.autocompleteString !== "" id: tmpSelectionName
visible: root.autocompleteString !== "" && root.open
text: root.autocompleteString text: root.autocompleteString
x: textInput.leftPadding + textMetrics.advanceWidth x: textInput.leftPadding + textMetrics.advanceWidth
y: (textInput.height - Math.ceil(textMetrics.height)) / 2 y: (textInput.height - Math.ceil(tmpSelectionTextMetrics.height)) / 2
color: "gray" // TODO proper color value color: "gray" // TODO proper color value
font: textInput.font font: textInput.font
renderType: textInput.renderType renderType: textInput.renderType
}
TextMetrics { TextMetrics {
id: textMetrics id: textMetrics
font: textInput.font font: textInput.font
text: textInput.text text: textInput.text
} }
TextMetrics {
id: tmpSelectionTextMetrics
font: tmpSelectionName.font
text: "Xq"
}
}
Rectangle { Rectangle {
id: checkIndicator id: checkIndicator