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 = ""
|
fileName.text = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function acceptIfIsValid() {
|
||||||
|
if (btnImport.enabled)
|
||||||
|
btnImport.onClicked()
|
||||||
|
}
|
||||||
|
|
||||||
RegularExpressionValidator {
|
RegularExpressionValidator {
|
||||||
id: fileNameValidator
|
id: fileNameValidator
|
||||||
regularExpression: /^(\w[^*><?|]*)[^/\\:*><?|]$/
|
regularExpression: /^(\w[^*><?|]*)[^/\\:*><?|]$/
|
||||||
@@ -67,6 +72,10 @@ StudioControls.Dialog {
|
|||||||
contentItem: ColumnLayout {
|
contentItem: ColumnLayout {
|
||||||
spacing: 2
|
spacing: 2
|
||||||
|
|
||||||
|
Keys.onEnterPressed: root.acceptIfIsValid()
|
||||||
|
Keys.onReturnPressed: root.acceptIfIsValid()
|
||||||
|
Keys.onEscapePressed: root.reject()
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
text: qsTr("File name")
|
text: qsTr("File name")
|
||||||
color: StudioTheme.Values.themeTextColor
|
color: StudioTheme.Values.themeTextColor
|
||||||
@@ -87,10 +96,6 @@ StudioControls.Dialog {
|
|||||||
translationIndicator.visible: false
|
translationIndicator.visible: false
|
||||||
validator: fileNameValidator
|
validator: fileNameValidator
|
||||||
|
|
||||||
Keys.onEnterPressed: btnImport.onClicked()
|
|
||||||
Keys.onReturnPressed: btnImport.onClicked()
|
|
||||||
Keys.onEscapePressed: root.reject()
|
|
||||||
|
|
||||||
onTextChanged: root.fileExists = root.backendValue.isValidUrlToImport(fileName.text)
|
onTextChanged: root.fileExists = root.backendValue.isValidUrlToImport(fileName.text)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,10 +126,6 @@ StudioControls.Dialog {
|
|||||||
validator: RegularExpressionValidator {
|
validator: RegularExpressionValidator {
|
||||||
regularExpression: /^[\w ]+$/
|
regularExpression: /^[\w ]+$/
|
||||||
}
|
}
|
||||||
|
|
||||||
Keys.onEnterPressed: btnImport.onClicked()
|
|
||||||
Keys.onReturnPressed: btnImport.onClicked()
|
|
||||||
Keys.onEscapePressed: root.reject()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Spacer { implicitHeight: StudioTheme.Values.controlLabelGap }
|
Spacer { implicitHeight: StudioTheme.Values.controlLabelGap }
|
||||||
|
Reference in New Issue
Block a user