From ff5ca5f5b4a36bac8bbc5455f7465a7cb9dea038 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 Change-Id: I028362e9fc329247f5b068eee5f84ede28e65e9c Reviewed-by: Pranta Ghosh Dastider Reviewed-by: Thomas Hartmann --- 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 9578c6f8ef1..ae082adef4d 100644 --- a/share/qtcreator/qmldesigner/designsystem/Main.qml +++ b/share/qtcreator/qmldesigner/designsystem/Main.qml @@ -127,7 +127,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)) @@ -136,7 +136,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() } @@ -1095,8 +1095,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 {