From d235a6d80728d605fc745f0a45d700b8ac3ba8c7 Mon Sep 17 00:00:00 2001 From: Henning Gruendl Date: Thu, 20 Aug 2020 16:38:05 +0200 Subject: QmlDesigner: Fix focus on EditableListView * Add an enum to the StudioControls ComboBox to indicate type of interaction * Force focus on last used ComboBox if activated signal wasn't send due to editing of the ComboBoxInput Task-number: QDS-2626 Change-Id: I20b1660a05923baacef30f91080642baacee0378 Reviewed-by: Miikka Heikkinen Reviewed-by: Thomas Hartmann --- .../imports/HelperWidgets/EditableListView.qml | 9 ++++++++- .../imports/StudioControls/ComboBox.qml | 10 +++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) (limited to 'share') diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/EditableListView.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/EditableListView.qml index c3344fcfe02..7fc3c9f3f2f 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/EditableListView.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/EditableListView.qml @@ -53,6 +53,8 @@ Rectangle { property string typeFilter: "QtQuick3D.Material" + property int activatedReason: ComboBox.ActivatedReason.Other + color: "transparent" border.color: StudioTheme.Values.themeControlOutline border.width: StudioTheme.Values.border @@ -89,11 +91,13 @@ Rectangle { } onCompressedActivated: { + editableListView.activatedReason = reason + if (itemFilterComboBox.empty && itemFilterComboBox.editText !== "") { myRepeater.dirty = false editableListView.add(itemFilterComboBox.editText) } else { - editableListView.replace(myIndex, itemFilterComboBox.editText) + editableListView.replace(itemFilterComboBox.myIndex, itemFilterComboBox.editText) } } } @@ -156,6 +160,9 @@ Rectangle { myColumn.currentIndex = lastIndex else myColumn.currentIndex = myRepeater.localModel.length - 1 + + if (editableListView.activatedReason === ComboBox.ActivatedReason.Other) + myColumn.currentItem.forceActiveFocus() } } diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/ComboBox.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/ComboBox.qml index 1c3dc46c15f..449a40432a1 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/ComboBox.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/ComboBox.qml @@ -46,7 +46,9 @@ T.ComboBox { property alias textInput: comboBoxInput - signal compressedActivated(int index) + signal compressedActivated(int index, int reason) + + enum ActivatedReason { EditingFinished, Other } width: StudioTheme.Values.squareComponentWidth * 5 height: StudioTheme.Values.height @@ -81,7 +83,8 @@ T.ComboBox { if (myComboBox.dirty) { myTimer.stop() myComboBox.dirty = false - myComboBox.compressedActivated(myComboBox.find(myComboBox.editText)) + myComboBox.compressedActivated(myComboBox.find(myComboBox.editText), + ComboBox.ActivatedReason.EditingFinished) } } onTextEdited: myComboBox.dirty = true @@ -114,7 +117,8 @@ T.ComboBox { repeat: false running: false interval: 100 - onTriggered: myComboBox.compressedActivated(myTimer.activatedIndex) + onTriggered: myComboBox.compressedActivated(myTimer.activatedIndex, + ComboBox.ActivatedReason.Other) } onActivated: { -- cgit v1.2.3