QmlDesigner: Add warning for empty name cell

Change-Id: I028362e9fc329247f5b068eee5f84ede28e65e9c
Reviewed-by: Pranta Ghosh Dastider <pranta.dastider@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
(cherry picked from commit ff5ca5f5b4)
Reviewed-by: Henning Gründl <henning.gruendl@qt.io>
This commit is contained in:
Henning Gruendl
2025-04-03 14:25:49 +02:00
committed by Thomas Hartmann
parent d98725098e
commit 6ee5e09680

View File

@@ -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 {