From 3944c73c512bf601d4b48552f313765cb3c722c8 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Fri, 16 Jun 2017 13:26:32 +0200 Subject: [PATCH] QmlDesigner: Fix combobox for font family The editable combobox had some serious issues. I changed the signals we react to and the properties we use. We react on activated to change to fonts in the model. For some reason using currentText does not work reliable. We have to retrieve the current etxt manually using textAt(). We also react to accepted to changes in the text edit. Here we simply use editText. We also react to selection changes and change the font. Change-Id: I99abd7609f8b64ef446ce154aed0c2a61dfa00f9 Reviewed-by: Tim Jenssen --- .../HelperWidgets/FontComboBox.qml | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/FontComboBox.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/FontComboBox.qml index ffc774d7cd0..6cca085da75 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/FontComboBox.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/FontComboBox.qml @@ -58,12 +58,28 @@ Controls.ComboBox { Layout.fillWidth: true - onCurrentTextChanged: { + onAccepted: { if (backendValue === undefined) return; - if (backendValue.value !== currentText) - backendValue.value = currentText; + if (editText === "") + return + + if (backendValue.value !== editText) + backendValue.value = editText; + } + + onActivated: { + if (backendValue === undefined) + return; + + if (editText === "") + return + + var indexText = comboBox.textAt(index) + + if (backendValue.value !== indexText) + backendValue.value = indexText; } ExtendedFunctionButton { @@ -73,6 +89,13 @@ Controls.ComboBox { visible: comboBox.enabled } + Connections { + target: modelNodeBackend + onSelectionChanged: { + comboBox.editText = backendValue.value + } + } + Component.onCompleted: { //Hack to style the text input for (var i = 0; i < comboBox.children.length; i++) {