forked from qt-creator/qt-creator
QmlDesigner: Check the validity before accepting the import dialog
Fixes: QDS-12068 Change-Id: I5341214b43edf8fb7d3693a861a09c7fd3461ac2 Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io> Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
@@ -32,6 +32,11 @@ StudioControls.Dialog {
|
||||
fileName.text = ""
|
||||
}
|
||||
|
||||
function acceptIfIsValid() {
|
||||
if (btnImport.enabled)
|
||||
btnImport.onClicked()
|
||||
}
|
||||
|
||||
RegularExpressionValidator {
|
||||
id: fileNameValidator
|
||||
regularExpression: /^(\w[^*><?|]*)[^/\\:*><?|]$/
|
||||
@@ -67,6 +72,10 @@ StudioControls.Dialog {
|
||||
contentItem: ColumnLayout {
|
||||
spacing: 2
|
||||
|
||||
Keys.onEnterPressed: root.acceptIfIsValid()
|
||||
Keys.onReturnPressed: root.acceptIfIsValid()
|
||||
Keys.onEscapePressed: root.reject()
|
||||
|
||||
Text {
|
||||
text: qsTr("File name")
|
||||
color: StudioTheme.Values.themeTextColor
|
||||
@@ -87,10 +96,6 @@ StudioControls.Dialog {
|
||||
translationIndicator.visible: false
|
||||
validator: fileNameValidator
|
||||
|
||||
Keys.onEnterPressed: btnImport.onClicked()
|
||||
Keys.onReturnPressed: btnImport.onClicked()
|
||||
Keys.onEscapePressed: root.reject()
|
||||
|
||||
onTextChanged: root.fileExists = root.backendValue.isValidUrlToImport(fileName.text)
|
||||
}
|
||||
|
||||
@@ -121,10 +126,6 @@ StudioControls.Dialog {
|
||||
validator: RegularExpressionValidator {
|
||||
regularExpression: /^[\w ]+$/
|
||||
}
|
||||
|
||||
Keys.onEnterPressed: btnImport.onClicked()
|
||||
Keys.onReturnPressed: btnImport.onClicked()
|
||||
Keys.onEscapePressed: root.reject()
|
||||
}
|
||||
|
||||
Spacer { implicitHeight: StudioTheme.Values.controlLabelGap }
|
||||
|
Reference in New Issue
Block a user