diff --git a/ui/app/AppLayouts/Communities/popups/CreateCategoryPopup.qml b/ui/app/AppLayouts/Communities/popups/CreateCategoryPopup.qml index 68e7330af6..af7bedded6 100644 --- a/ui/app/AppLayouts/Communities/popups/CreateCategoryPopup.qml +++ b/ui/app/AppLayouts/Communities/popups/CreateCategoryPopup.qml @@ -61,10 +61,16 @@ StatusModal { label: qsTr("Category title") charLimit: maxCategoryNameLength placeholderText: qsTr("Name the category") - validators: [StatusMinLengthValidator { - minLength: 1 - errorMessage: Utils.getErrorMessage(nameInput.errors, qsTr("category name")) - }] + validators: [ + StatusMinLengthValidator { + minLength: 1 + errorMessage: Utils.getErrorMessage(nameInput.errors, qsTr("category name")) + }, + StatusRegularExpressionValidator { + regularExpression: Constants.regularExpressions.alphanumericalExpanded + errorMessage: Constants.errorMessages.alphanumericalExpandedRegExp + } + ] } StatusModalDivider { diff --git a/ui/app/AppLayouts/Communities/popups/CreateChannelPopup.qml b/ui/app/AppLayouts/Communities/popups/CreateChannelPopup.qml index 80e4d8477f..c9fa5ab66f 100644 --- a/ui/app/AppLayouts/Communities/popups/CreateChannelPopup.qml +++ b/ui/app/AppLayouts/Communities/popups/CreateChannelPopup.qml @@ -230,10 +230,16 @@ StatusDialog { input.multiline: true minimumHeight: 88 maximumHeight: 88 - validators: [StatusMinLengthValidator { + validators: [ + StatusMinLengthValidator { minLength: 1 - errorMessage: Utils.getErrorMessage(descriptionTextArea.errors, qsTr("channel description")) - }] + errorMessage: Utils.getErrorMessage(descriptionTextArea.errors, qsTr("channel description")) + }, + StatusRegularExpressionValidator { + regularExpression: Constants.regularExpressions.alphanumericalExpanded + errorMessage: Constants.errorMessages.alphanumericalExpandedRegExp + } + ] } /* TODO: use the code below to enable private channels and message limit */ diff --git a/ui/imports/shared/popups/RenameGroupPopup.qml b/ui/imports/shared/popups/RenameGroupPopup.qml index 97c7582088..10d4150530 100644 --- a/ui/imports/shared/popups/RenameGroupPopup.qml +++ b/ui/imports/shared/popups/RenameGroupPopup.qml @@ -9,6 +9,7 @@ import utils 1.0 import StatusQ.Components 0.1 import StatusQ.Controls 0.1 +import StatusQ.Controls.Validators 0.1 import StatusQ.Core 0.1 import StatusQ.Popups 0.1 import StatusQ.Popups.Dialog 0.1 @@ -39,7 +40,7 @@ StatusDialog { colorSelectionGrid.selectedColor = activeGroupColor for (let i = 0; i < colorSelectionGrid.model.length; i++) { - if(colorSelectionGrid.model[i] === root.activeGroupColor.toUpperCase()) + if(colorSelectionGrid.model[i].toString().toUpperCase() === root.activeGroupColor.toUpperCase()) colorSelectionGrid.selectedColorIndex = i } @@ -56,13 +57,23 @@ StatusDialog { Layout.alignment: Qt.AlignHCenter label: qsTr("Name the group") charLimit: d.nameCharLimit + + validators: [ + StatusMinLengthValidator { + minLength: 1 + errorMessage: Utils.getErrorMessage(groupName.errors, qsTr("group name")) + }, + StatusRegularExpressionValidator { + regularExpression: Constants.regularExpressions.alphanumericalExpanded + errorMessage: Constants.errorMessages.alphanumericalExpandedRegExp + } + ] } StatusBaseText { id: imgText text: qsTr("Group image") leftPadding: groupName.leftPadding - root.padding - font.pixelSize: 15 } EditCroppedImagePanel { @@ -75,49 +86,12 @@ StatusDialog { imageFileDialogTitle: qsTr("Choose an image as logo") title: qsTr("Edit group name and image") acceptButtonText: qsTr("Use as an icon for this group chat") - - backgroundComponent: - StatusLetterIdenticon { - id: letter - color: colorSelectionGrid.selectedColor - name: root.activeGroupName - height: 100 - width: 100 - letterSize: 64 - - StatusRoundButton { - id: addButton - - icon.name: "add" - type: StatusRoundButton.Type.Secondary - - transform: [ - Translate { - x: -addButton.width/2 - 5 - y: -addButton.height/2 + 5 - }, - Rotation { angle: -addRotationTransform.angle }, - Rotation { - id: addRotationTransform - angle: 135 - origin.x: letter.radius - }, - Translate { - x: letter.width - 2 * letter.radius - y: letter.radius - } - ] - - onClicked: imageEditor.chooseImageToCrop() - } - } } StatusBaseText { id: colorText text: qsTr("Standard colours") leftPadding: groupName.leftPadding - root.padding - font.pixelSize: 15 } StatusColorSelectorGrid { diff --git a/ui/imports/utils/Constants.qml b/ui/imports/utils/Constants.qml index 534051b268..6d0225f564 100644 --- a/ui/imports/utils/Constants.qml +++ b/ui/imports/utils/Constants.qml @@ -503,12 +503,12 @@ QtObject { errorMessage: qsTr("Usernames starting with whitespace are not allowed") }, StatusRegularExpressionValidator { - regularExpression: /^[a-zA-Z0-9\-_ ]+$/ + regularExpression: regularExpressions.alphanumericalExpanded errorMessage: errorMessages.alphanumericalExpandedRegExp }, StatusMinLengthValidator { minLength: keypair.nameLengthMin - errorMessage: qsTr("Username must be at least %1 characters").arg(keypair.nameLengthMin) + errorMessage: qsTr("Username must be at least %n character(s)", "", keypair.nameLengthMin) }, StatusValidator { name: "endsWithSpaceValidator" @@ -645,7 +645,7 @@ QtObject { readonly property QtObject regularExpressions: QtObject { readonly property var alphanumerical: /^$|^[a-zA-Z0-9]+$/ - readonly property var alphanumericalExpanded: /^$|^[a-zA-Z0-9\-_ ]+$/ + readonly property var alphanumericalExpanded: /^$|^[a-zA-Z0-9\-_.\u0020]+$/ readonly property var alphanumericalWithSpace: /^$|^[a-zA-Z0-9\s]+$/ readonly property var asciiPrintable: /^$|^[!-~]+$/ readonly property var ascii: /^$|^[\x00-\x7F]+$/ @@ -655,8 +655,8 @@ QtObject { readonly property QtObject errorMessages: QtObject { readonly property string alphanumericalRegExp: qsTr("Only letters and numbers allowed") - readonly property string alphanumericalWithSpaceRegExp: qsTr("Special characters are not allowed") readonly property string alphanumericalExpandedRegExp: qsTr("Only letters, numbers, underscores, whitespaces and hyphens allowed") + readonly property string alphanumericalWithSpaceRegExp: qsTr("Special characters are not allowed") readonly property string asciiRegExp: qsTr("Only letters, numbers and ASCII characters allowed") }