diff options
author | Henning Gruendl <henning.gruendl@qt.io> | 2023-05-10 10:06:39 +0200 |
---|---|---|
committer | Henning Gründl <henning.gruendl@qt.io> | 2023-05-12 10:14:32 +0000 |
commit | c4ff1921ee8f14ecdce1146f936a099ae7973e58 (patch) | |
tree | 571a1131a826a5e858651ebdc77b79e1893df865 | |
parent | 8188bd2b3a15eb6b6ecb670690accd98789e736d (diff) | |
download | qt-creator-c4ff1921ee8f14ecdce1146f936a099ae7973e58.tar.gz |
QmlDesigner: Fix ItemFilterComboBox arbitrary edit
- Add onAccepted handler
- Fix onAccepted early return when manualMapping active in base
- Remove import version
- Replace RegExpValidator with RegularExpressionValidator
Task-number: QDS-9858
Change-Id: I5a967abb28dd70e4215efcc3993e084366d4e020
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2 files changed, 13 insertions, 20 deletions
diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ComboBox.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ComboBox.qml index 813aa1c759..4db5a98c22 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ComboBox.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ComboBox.qml @@ -1,7 +1,7 @@ // Copyright (C) 2016 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 -import QtQuick 2.15 +import QtQuick import StudioControls 1.0 as StudioControls import StudioTheme 1.0 as StudioTheme @@ -152,7 +152,7 @@ StudioControls.ComboBox { } onAccepted: { - if (!comboBox.__isCompleted) + if (!comboBox.__isCompleted || comboBox.backendValue === undefined || comboBox.manualMapping) return let inputText = comboBox.editText @@ -167,13 +167,7 @@ StudioControls.ComboBox { } onCompressedActivated: { - if (!comboBox.__isCompleted) - return - - if (comboBox.backendValue === undefined) - return - - if (comboBox.manualMapping) + if (!comboBox.__isCompleted || comboBox.backendValue === undefined || comboBox.manualMapping) return if (comboBox.valueRole && comboBox.textRole !== comboBox.valueRole) { diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ItemFilterComboBox.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ItemFilterComboBox.qml index 2f749271d7..316207e5f5 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ItemFilterComboBox.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ItemFilterComboBox.qml @@ -1,7 +1,7 @@ // Copyright (C) 2021 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only -import QtQuick 2.15 +import QtQuick import HelperWidgets 2.0 as HelperWidgets HelperWidgets.ComboBox { @@ -13,7 +13,7 @@ HelperWidgets.ComboBox { editable: true model: comboBox.addDefaultItem(itemFilterModel.itemModel) - validator: RegExpValidator { regExp: /(^$|^[a-z_]\w*)/ } + validator: RegularExpressionValidator { regularExpression: /(^$|^[a-z_]\w*)/ } HelperWidgets.ItemFilterModel { id: itemFilterModel @@ -32,17 +32,18 @@ HelperWidgets.ComboBox { comboBox.setCurrentText(comboBox.textValue) } onModelChanged: comboBox.setCurrentText(comboBox.textValue) - onCompressedActivated: function(index, reason) { comboBox.handleActivate(index) } - Component.onCompleted: comboBox.setCurrentText(comboBox.textValue) - onEditTextChanged: comboBox.dirty = true onFocusChanged: { if (comboBox.dirty) comboBox.handleActivate(comboBox.currentIndex) } - function handleActivate(index) - { + onCompressedActivated: function(index, reason) { comboBox.handleActivate(index) } + onAccepted: comboBox.setCurrentText(comboBox.editText) + + Component.onCompleted: comboBox.setCurrentText(comboBox.textValue) + + function handleActivate(index) { if (!comboBox.__isCompleted || comboBox.backendValue === undefined) return @@ -52,8 +53,7 @@ HelperWidgets.ComboBox { comboBox.block = false } - function setCurrentText(text) - { + function setCurrentText(text) { if (!comboBox.__isCompleted || comboBox.backendValue === undefined) return @@ -78,8 +78,7 @@ HelperWidgets.ComboBox { comboBox.dirty = false } - function addDefaultItem(arr) - { + function addDefaultItem(arr) { var copy = arr.slice() copy.unshift(comboBox.defaultItem) return copy |