1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-09-15 06:52:34 +02:00

Fix website wallpaper validation

This commit is contained in:
Elias Steurer 2023-11-23 12:23:34 +01:00
parent d4c4c46c40
commit 7ae1e97c7c

View File

@ -10,16 +10,25 @@ import ScreenPlayUtil as Util
WizardPage { WizardPage {
id: root id: root
function isValidURL(string) {
var res = string.match(
/(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/g)
return (res !== null)
}
sourceComponent: ColumnLayout { sourceComponent: ColumnLayout {
property bool ready: tfTitle.text.length >= 1 && tfUrl.text.length > 1 id: layout
function validate() {
root.ready = tfTitle.text.length >= 1 && root.isValidURL(tfUrl.text)
}
function create() { function create() {
App.wizards.createWebsiteWallpaper(tfTitle.text, previewSelector.imageSource, tfUrl.text, tagSelector.getTags()); App.wizards.createWebsiteWallpaper(tfTitle.text,
previewSelector.imageSource,
tfUrl.text,
tagSelector.getTags())
} }
spacing: 10 spacing: 10
onReadyChanged: root.ready = ready
anchors { anchors {
top: parent.top top: parent.top
@ -41,11 +50,10 @@ WizardPage {
Util.TextField { Util.TextField {
id: tfTitle id: tfTitle
Layout.fillWidth: true Layout.fillWidth: true
placeholderText: qsTr("Wallpaper name") placeholderText: qsTr("Wallpaper name")
required: true required: true
onTextChanged: root.ready = text.length >= 1 onTextChanged: layout.validate()
} }
Util.TextField { Util.TextField {
@ -65,10 +73,10 @@ WizardPage {
Util.TextField { Util.TextField {
id: tfUrl id: tfUrl
Layout.fillWidth: true Layout.fillWidth: true
required: true required: true
text: "https://" text: "https://"
onTextChanged: layout.validate()
} }
Item { Item {