From 6ee5e096803888d5ddf02f04c9aa1ae466e48569 Mon Sep 17 00:00:00 2001 From: Henning Gruendl Date: Thu, 3 Apr 2025 14:25:49 +0200 Subject: [PATCH] QmlDesigner: Add warning for empty name cell MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I028362e9fc329247f5b068eee5f84ede28e65e9c Reviewed-by: Pranta Ghosh Dastider Reviewed-by: Thomas Hartmann (cherry picked from commit ff5ca5f5b4a36bac8bbc5455f7465a7cb9dea038) Reviewed-by: Henning Gründl --- share/qtcreator/qmldesigner/designsystem/Main.qml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/share/qtcreator/qmldesigner/designsystem/Main.qml b/share/qtcreator/qmldesigner/designsystem/Main.qml index 08434a46b97..33f15dff998 100644 --- a/share/qtcreator/qmldesigner/designsystem/Main.qml +++ b/share/qtcreator/qmldesigner/designsystem/Main.qml @@ -130,7 +130,7 @@ Rectangle { overlayInvalid.show() } - function showHeaderData(section: int, orientation: var) { + function showHeaderData(section: int, orientation: var, message: string) { if (orientation === Qt.Horizontal) { overlayInvalid.parent = horizontalHeaderView.contentItem overlayInvalid.cellItem = horizontalHeaderView.itemAtCell(Qt.point(overlay.section, 0)) @@ -139,7 +139,7 @@ Rectangle { overlayInvalid.cellItem = verticalHeaderView.itemAtCell(Qt.point(0, overlay.section)) } - notification.message = qsTr("This name is already in use, please use a different name.") + notification.message = message overlayInvalid.show() } @@ -1098,8 +1098,14 @@ Rectangle { // Revoke active focus from text field by forcing active focus on another item tableView.forceActiveFocus() - if (!result && overlayTextField.previousText !== overlayTextField.text) - overlayInvalid.showHeaderData(overlay.section, overlay.orientation) + if (overlayTextField.text === "") + overlayInvalid.showHeaderData(overlay.section, + overlay.orientation, + qsTr("No name found, please enter a valid name.")) + else if (!result && overlayTextField.previousText !== overlayTextField.text) + overlayInvalid.showHeaderData(overlay.section, + overlay.orientation, + qsTr("This name is already in use, please use a different name.")) } Text {