diff --git a/src/app/commoncomponents/MaterialTextField.qml b/src/app/commoncomponents/MaterialTextField.qml index 155347eb3363de50bbd0d43beeab08f938aae202..4982a8ca78e4e90b624136c7dc47fc9c6b361be0 100644 --- a/src/app/commoncomponents/MaterialTextField.qml +++ b/src/app/commoncomponents/MaterialTextField.qml @@ -26,7 +26,7 @@ TextField { // We need to remove focus when another widget takes activeFocus, // except the context menu. - property bool isActive: activeFocus || contextMenu.active || root.text.toString() !== '' + property bool isActive: activeFocus || contextMenu.active onActiveFocusChanged: { if (!activeFocus && !contextMenu.active) { root.focus = false @@ -76,11 +76,10 @@ TextField { bottomPadding: 20 topPadding: 2 - onIsActiveChanged: if (!isActive && !readOnly) text = '' Keys.onPressed: function (event) { if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return) { - if (inputIsValid) { + if (inputIsValid && acceptableInput) { root.accepted() } event.accepted = true @@ -94,6 +93,7 @@ TextField { lineEditObj: root selectOnly: readOnly } + onReleased: function (event) { if (event.button === Qt.RightButton) contextMenu.openMenuAt(event) @@ -107,7 +107,7 @@ TextField { anchors.horizontalCenter: root.horizontalCenter text: root.placeholderText color: root.baseColor - visible: !root.isActive && !readOnly + visible: !root.isActive && !readOnly && root.text.toString() === "" } Rectangle { @@ -150,7 +150,7 @@ TextField { color: root.baseColor // Show the alternate placeholder while the user types. - visible: root.text.toString() !== '' && !readOnly + visible: root.isActive && !readOnly } TextFieldIcon { diff --git a/src/app/commoncomponents/ModalTextEdit.qml b/src/app/commoncomponents/ModalTextEdit.qml index cd39b2c85d41d46620ef76a5912e419d2b5bf5bd..d584fa18e9c18ca876d3721bfe5f453d2549b867 100644 --- a/src/app/commoncomponents/ModalTextEdit.qml +++ b/src/app/commoncomponents/ModalTextEdit.qml @@ -40,6 +40,7 @@ Loader { property bool fontBold: false property int echoMode: TextInput.Normal + property QtObject textValidator: RegularExpressionValidator { id: defaultValidator } // Always start with the static text component displayed first. property bool editMode: true @@ -47,6 +48,8 @@ Loader { // Emitted when the editor has been accepted. signal accepted + signal activeChanged(bool active) + // Always give up focus when accepted. onAccepted: focus = false @@ -59,10 +62,10 @@ Loader { // This is used when the user is not editing the text. Component { - id: displayComp - MaterialTextField { + MaterialTextField { + id: displayCompField font.pointSize: root.fontPointSize readOnly: true text: staticText @@ -75,7 +78,6 @@ Loader { id: editComp MaterialTextField { - id: editCompField focus: true @@ -92,19 +94,24 @@ Loader { placeholderText: root.placeholderText onAccepted: root.accepted() onTextChanged: dynamicText = text - onVisibleChanged: text = dynamicText + text: staticText inputIsValid: root.inputIsValid - onFocusChanged: if (!focus) root.editMode = false + onFocusChanged: { + if (!focus) { + root.editMode = false + } + activeChanged(root.editMode) + } + onIsActiveChanged: activeChanged(isActive) + validator: root.textValidator } } // We use a loader to switch between the two components depending on the // editMode property. sourceComponent: { - editMode || isPersistent ? editComp : displayComp } - } diff --git a/src/app/commoncomponents/PasswordDialog.qml b/src/app/commoncomponents/PasswordDialog.qml index 2526b829df3561c4a1cd4bbe03b0d226940239ea..b9cc627f76a81b0956f16ad8475f632303ee1cca 100644 --- a/src/app/commoncomponents/PasswordDialog.qml +++ b/src/app/commoncomponents/PasswordDialog.qml @@ -88,7 +88,7 @@ BaseModalDialog { btnConfirm.enabled = currentPasswordEdit.dynamicText.length > 0 break case PasswordDialog.SetPassword: - btnConfirm.enabled = passwordEdit.length > 0 && + btnConfirm.enabled = passwordEdit.dynamicText.length > 0 && passwordEdit.dynamicText === confirmPasswordEdit.dynamicText break default: diff --git a/src/app/commoncomponents/UsernameLineEdit.qml b/src/app/commoncomponents/UsernameLineEdit.qml deleted file mode 100644 index 3cb75e4785b77e7641ff8313641fe66e3707fead..0000000000000000000000000000000000000000 --- a/src/app/commoncomponents/UsernameLineEdit.qml +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (C) 2021-2023 Savoir-faire Linux Inc. - * Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - */ - -import QtQuick -import Qt5Compat.GraphicalEffects - -import net.jami.Adapters 1.1 -import net.jami.Models 1.1 -import net.jami.Constants 1.1 - -EditableLineEdit { - id: root - - placeholderText: JamiStrings.chooseYourUserName - - firstIco: readOnly? "" : JamiResources.person_24dp_svg - firstIcoColor: "#03B9E9" - - secondIco: readOnly? "" : JamiResources.outline_info_24dp_svg - secondIcoColor: "#005699" - - informationToolTip: JamiStrings.usernameToolTip - - enum NameRegistrationState { - BLANK, - INVALID, - TAKEN, - FREE, - SEARCHING - } - - property int nameRegistrationState: UsernameLineEdit.NameRegistrationState.BLANK - property string accountId: CurrentAccount.id - - selectByMouse: true - font.pointSize: JamiTheme.usernameLineEditPointSize - font.kerning: true - - validator: RegularExpressionValidator { regularExpression: /[A-z0-9_]{0,32}/ } - - Connections { - id: registeredNameFoundConnection - - target: NameDirectory - enabled: root.text.length !== 0 - - function onRegisteredNameFound(status, address, name) { - if (text === name) { - switch(status) { - case NameDirectory.LookupStatus.NOT_FOUND: - nameRegistrationState = UsernameLineEdit.NameRegistrationState.FREE - break - case NameDirectory.LookupStatus.ERROR: - case NameDirectory.LookupStatus.INVALID_NAME: - case NameDirectory.LookupStatus.INVALID: - nameRegistrationState = UsernameLineEdit.NameRegistrationState.INVALID - break - case NameDirectory.LookupStatus.SUCCESS: - nameRegistrationState = UsernameLineEdit.NameRegistrationState.TAKEN - break - } - } - } - } - - Timer { - id: lookupTimer - - repeat: false - interval: JamiTheme.usernameLineEditlookupInterval - - onTriggered: { - if (text.length !== 0 && readOnly === false) { - nameRegistrationState = UsernameLineEdit.NameRegistrationState.SEARCHING - NameDirectory.lookupName(root.accountId, text) - } else { - nameRegistrationState = UsernameLineEdit.NameRegistrationState.BLANK - } - } - } - - onNameRegistrationStateChanged: { - if (readOnly || !enabled) - borderColor = "transparent" - - switch(nameRegistrationState){ - case UsernameLineEdit.NameRegistrationState.BLANK: - firstIco="" - borderColor = "transparent" - error = false - validated = false - break - case UsernameLineEdit.NameRegistrationState.FREE: - firstIco = JamiResources.circled_green_check_svg - borderColor = validatedColor - firstIcoColor = "transparent" - validated = true - error = false - - break - case UsernameLineEdit.NameRegistrationState.INVALID: - case UsernameLineEdit.NameRegistrationState.TAKEN: - firstIco = JamiResources.circled_red_cross_svg - borderColor = errorColor - firstIcoColor = "transparent" - error = true - validated = false - break - } - } - - onTextChanged: lookupTimer.restart() -} diff --git a/src/app/commoncomponents/UsernameTextEdit.qml b/src/app/commoncomponents/UsernameTextEdit.qml index 774e53ff26514a6c0c2c23872dbe97e11cc4e95a..d6614a306aa130133b252f7c37cb4d2bbfd1cbdb 100644 --- a/src/app/commoncomponents/UsernameTextEdit.qml +++ b/src/app/commoncomponents/UsernameTextEdit.qml @@ -26,24 +26,24 @@ ModalTextEdit { prefixIconSrc: { switch(nameRegistrationState){ - case UsernameLineEdit.NameRegistrationState.FREE: + case UsernameTextEdit.NameRegistrationState.FREE: return JamiResources.circled_green_check_svg - case UsernameLineEdit.NameRegistrationState.INVALID: - case UsernameLineEdit.NameRegistrationState.TAKEN: + case UsernameTextEdit.NameRegistrationState.INVALID: + case UsernameTextEdit.NameRegistrationState.TAKEN: return JamiResources.circled_red_cross_svg - case UsernameLineEdit.NameRegistrationState.BLANK: + case UsernameTextEdit.NameRegistrationState.BLANK: default: return JamiResources.person_24dp_svg } } prefixIconColor: { switch(nameRegistrationState){ - case UsernameLineEdit.NameRegistrationState.FREE: + case UsernameTextEdit.NameRegistrationState.FREE: return "#009980" - case UsernameLineEdit.NameRegistrationState.INVALID: - case UsernameLineEdit.NameRegistrationState.TAKEN: + case UsernameTextEdit.NameRegistrationState.INVALID: + case UsernameTextEdit.NameRegistrationState.TAKEN: return "#CC0022" - case UsernameLineEdit.NameRegistrationState.BLANK: + case UsernameTextEdit.NameRegistrationState.BLANK: default: return JamiTheme.editLineColor } @@ -51,18 +51,25 @@ ModalTextEdit { suffixIconSrc: JamiResources.outline_info_24dp_svg suffixIconColor: JamiTheme.buttonTintedBlue + property bool isActive: false property string infohash: CurrentAccount.uri property string registeredName: CurrentAccount.registeredName - property bool hasRegisteredName: registeredName !== '' + staticText: root.isActive ? registeredName : (registeredName ? registeredName : infohash) infoTipText: JamiStrings.usernameToolTip placeholderText: JamiStrings.chooseAUsername + textValidator: RegularExpressionValidator { regularExpression: /[A-Za-z0-9-]{0,32}/ } + enum NameRegistrationState { BLANK, INVALID, TAKEN, FREE, SEARCHING } - property int nameRegistrationState: UsernameLineEdit.NameRegistrationState.BLANK + property int nameRegistrationState: UsernameTextEdit.NameRegistrationState.BLANK inputIsValid: dynamicText.length === 0 - || nameRegistrationState === UsernameLineEdit.NameRegistrationState.FREE + || nameRegistrationState === UsernameTextEdit.NameRegistrationState.FREE + + onActiveChanged: function(active) { + root.isActive = active + } Connections { target: CurrentAccount @@ -82,15 +89,15 @@ ModalTextEdit { if (dynamicText === name) { switch(status) { case NameDirectory.LookupStatus.NOT_FOUND: - nameRegistrationState = UsernameLineEdit.NameRegistrationState.FREE + nameRegistrationState = UsernameTextEdit.NameRegistrationState.FREE break case NameDirectory.LookupStatus.ERROR: case NameDirectory.LookupStatus.INVALID_NAME: case NameDirectory.LookupStatus.INVALID: - nameRegistrationState = UsernameLineEdit.NameRegistrationState.INVALID + nameRegistrationState = UsernameTextEdit.NameRegistrationState.INVALID break case NameDirectory.LookupStatus.SUCCESS: - nameRegistrationState = UsernameLineEdit.NameRegistrationState.TAKEN + nameRegistrationState = UsernameTextEdit.NameRegistrationState.TAKEN break } } @@ -101,24 +108,25 @@ ModalTextEdit { id: lookupTimer repeat: false - interval: JamiTheme.usernameLineEditlookupInterval + interval: JamiTheme.usernameTextEditlookupInterval onTriggered: { if (dynamicText.length !== 0) { - nameRegistrationState = UsernameLineEdit.NameRegistrationState.SEARCHING + nameRegistrationState = UsernameTextEdit.NameRegistrationState.SEARCHING NameDirectory.lookupName(CurrentAccount.id, dynamicText) } else { - nameRegistrationState = UsernameLineEdit.NameRegistrationState.BLANK + nameRegistrationState = UsernameTextEdit.NameRegistrationState.BLANK } } } + onDynamicTextChanged: lookupTimer.restart() function startEditing() { - if (!hasRegisteredName) { + if (!registeredName) { root.editMode = true forceActiveFocus() - nameRegistrationState = UsernameLineEdit.NameRegistrationState.BLANK + nameRegistrationState = UsernameTextEdit.NameRegistrationState.BLANK } } } diff --git a/src/app/constant/JamiStrings.qml b/src/app/constant/JamiStrings.qml index f22c6509f7e8a7337d6c4eac9a7e044c6559997d..bae1f47d55b4e46d08e8926bbf7c6839a62652c6 100644 --- a/src/app/constant/JamiStrings.qml +++ b/src/app/constant/JamiStrings.qml @@ -390,7 +390,6 @@ Item { property string chooseUsernameForAccount: qsTr("You can choose a username to help others more easily find and reach you on Jami.") property string chooseUsernameForRV: qsTr("Choose a name for your rendezvous point") property string chooseAName: qsTr("Choose a name") - property string chooseYourUserName: qsTr("Choose username") property string invalidName: qsTr("Invalid name") property string invalidUsername: qsTr("Invalid username") property string nameAlreadyTaken: qsTr("Name already taken") diff --git a/src/app/constant/JamiTheme.qml b/src/app/constant/JamiTheme.qml index c04d5a68f2d308f59d162da95c753556842ba6fa..a8cf11707464dc620024d8e798ddb61c934ab4df 100644 --- a/src/app/constant/JamiTheme.qml +++ b/src/app/constant/JamiTheme.qml @@ -518,9 +518,9 @@ Item { //MaterialButton property real buttontextPadding: 10 - // UsernameLineEdit - property real usernameLineEditPointSize:calcSize(9 + fontSizeOffset) - property real usernameLineEditlookupInterval: 200 + // UsernameTextEdit + property real usernameTextEditPointSize:calcSize(9 + fontSizeOffset) + property real usernameTextEditlookupInterval: 200 // JamiScrollBar property int scrollBarHandleSize: 6 diff --git a/src/app/mainview/components/CustomizeTipBox.qml b/src/app/mainview/components/CustomizeTipBox.qml index 5d0287f4aa06e5de21a5fe65bd86c31b5f2f6226..bbbc48fe1b9851cb29b562be06f49b388dc1f1fc 100644 --- a/src/app/mainview/components/CustomizeTipBox.qml +++ b/src/app/mainview/components/CustomizeTipBox.qml @@ -95,8 +95,7 @@ ColumnLayout { } - EditableLineEdit { - + ModalTextEdit { id: displayNameLineEdit visible: opened @@ -105,16 +104,10 @@ ColumnLayout { Layout.preferredWidth: root.width - 32 Layout.topMargin: -10 - text: CurrentAccount.alias + staticText: CurrentAccount.alias placeholderText: JamiStrings.enterNickname - color: JamiTheme.textColor - - fontSize: JamiTheme.tipBoxContentFontSize - - onEditingFinished: { - AccountAdapter.setCurrAccDisplayName(text) - } + onAccepted: AccountAdapter.setCurrAccDisplayName(dynamicText) } Text { diff --git a/src/app/mainview/components/JamiIdentifier.qml b/src/app/mainview/components/JamiIdentifier.qml index c622d6962ea6ad49c15395e31b3da5d4f5410de8..0929a4da8bde48f1ad10913332823531038a4fb0 100644 --- a/src/app/mainview/components/JamiIdentifier.qml +++ b/src/app/mainview/components/JamiIdentifier.qml @@ -101,12 +101,12 @@ Item { if (!usernameTextEdit.editMode) return true switch(usernameTextEdit.nameRegistrationState) { - case UsernameLineEdit.NameRegistrationState.BLANK: - case UsernameLineEdit.NameRegistrationState.FREE: + case UsernameTextEdit.NameRegistrationState.BLANK: + case UsernameTextEdit.NameRegistrationState.FREE: return true - case UsernameLineEdit.NameRegistrationState.SEARCHING: - case UsernameLineEdit.NameRegistrationState.INVALID: - case UsernameLineEdit.NameRegistrationState.TAKEN: + case UsernameTextEdit.NameRegistrationState.SEARCHING: + case UsernameTextEdit.NameRegistrationState.INVALID: + case UsernameTextEdit.NameRegistrationState.TAKEN: return false } } @@ -149,7 +149,6 @@ Item { Layout.leftMargin: JamiTheme.preferredMarginSize Layout.rightMargin: JamiTheme.preferredMarginSize fontPointSize: JamiTheme.textFontSize + 1 - staticText: hasRegisteredName ? registeredName : infohash editMode: false isPersistent: false @@ -162,8 +161,8 @@ Item { "settingsview/components/NameRegistrationDialog.qml", { registeredName: dynamicText }) dlg.accepted.connect(function() { - currentRegisteredID.nameRegistrationState = - UsernameLineEdit.NameRegistrationState.BLANK + usernameTextEdit.nameRegistrationState = + UsernameTextEdit.NameRegistrationState.BLANK }) } } diff --git a/src/app/settingsview/components/AccountProfile.qml b/src/app/settingsview/components/AccountProfile.qml index 5ad133f26ec5c1f805cbadecd9af789e5ca54c8a..5dae06baf879f6ed3fca2ee913fafe2680172adf 100644 --- a/src/app/settingsview/components/AccountProfile.qml +++ b/src/app/settingsview/components/AccountProfile.qml @@ -70,24 +70,16 @@ ColumnLayout { buttonSize: JamiTheme.smartListAvatarSize } - MaterialLineEdit { + ModalTextEdit { id: displayNameLineEdit Layout.alignment: Qt.AlignCenter - Layout.preferredHeight: JamiTheme.preferredFieldHeight + Layout.preferredHeight: JamiTheme.preferredFieldHeight + 8 Layout.preferredWidth: JamiTheme.preferredFieldWidth - font.pointSize: JamiTheme.textFontSize - font.kerning: true - text: CurrentAccount.alias + staticText: CurrentAccount.alias placeholderText: JamiStrings.enterNickname - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - padding: 8 - - loseFocusWhenEnterPressed: true - - onEditingFinished: AccountAdapter.setCurrAccDisplayName(text) + onAccepted: AccountAdapter.setCurrAccDisplayName(dynamicText) } } diff --git a/src/app/settingsview/components/AdvancedConnectivitySettings.qml b/src/app/settingsview/components/AdvancedConnectivitySettings.qml index cdaba5fcd7796ff1ea9b636cf5e8bbea76804e80..a595b9db262c2fc6bebabbd358fb9c16fdf70eb6 100644 --- a/src/app/settingsview/components/AdvancedConnectivitySettings.qml +++ b/src/app/settingsview/components/AdvancedConnectivitySettings.qml @@ -114,7 +114,7 @@ ColumnLayout { onSwitchToggled: CurrentAccount.enable_TURN = checked } - SettingsMaterialLineEdit { + SettingsMaterialTextEdit { id: lineEditTurnAddress Layout.fillWidth: true @@ -130,7 +130,7 @@ ColumnLayout { onEditFinished: CurrentAccount.server_TURN = dynamicText } - SettingsMaterialLineEdit { + SettingsMaterialTextEdit { id: lineEditTurnUsername Layout.fillWidth: true @@ -146,7 +146,7 @@ ColumnLayout { onEditFinished: CurrentAccount.username_TURN = dynamicText } - SettingsMaterialLineEdit { + SettingsMaterialTextEdit { id: lineEditTurnPassword Layout.fillWidth: true @@ -162,7 +162,7 @@ ColumnLayout { onEditFinished: CurrentAccount.password_TURN = dynamicText } - SettingsMaterialLineEdit { + SettingsMaterialTextEdit { id: lineEditTurnRealmSIP Layout.fillWidth: true @@ -192,7 +192,7 @@ ColumnLayout { onSwitchToggled: CurrentAccount.enable_STUN = checked } - SettingsMaterialLineEdit { + SettingsMaterialTextEdit { id: lineEditSTUNAddress Layout.fillWidth: true diff --git a/src/app/settingsview/components/AdvancedJamiSecuritySettings.qml b/src/app/settingsview/components/AdvancedJamiSecuritySettings.qml index 8a417c8b20d9e2dadb19de52e9004d24fa745fc1..168a9147dd23cb633341ce6711001708accb7774 100644 --- a/src/app/settingsview/components/AdvancedJamiSecuritySettings.qml +++ b/src/app/settingsview/components/AdvancedJamiSecuritySettings.qml @@ -122,7 +122,7 @@ ColumnLayout { }) } - SettingsMaterialLineEdit { + SettingsMaterialTextEdit { id: lineEditCertPassword Layout.fillWidth: true diff --git a/src/app/settingsview/components/AdvancedNameServerSettings.qml b/src/app/settingsview/components/AdvancedNameServerSettings.qml index b0a373697c33c9ec9d1ed35a43edbb5687e26053..9441bd2cd239c2bb231c4163f1c4fa8c6b9afc1e 100644 --- a/src/app/settingsview/components/AdvancedNameServerSettings.qml +++ b/src/app/settingsview/components/AdvancedNameServerSettings.qml @@ -45,7 +45,7 @@ ColumnLayout { elide: Text.ElideRight } - SettingsMaterialLineEdit { + SettingsMaterialTextEdit { id: lineEditNameServer Layout.fillWidth: true diff --git a/src/app/settingsview/components/AdvancedOpenDHTSettings.qml b/src/app/settingsview/components/AdvancedOpenDHTSettings.qml index c59562d4c413861f6c5cd7590a7c37d990252be1..14274b468144f02318bde8621178dc6d740a3827 100644 --- a/src/app/settingsview/components/AdvancedOpenDHTSettings.qml +++ b/src/app/settingsview/components/AdvancedOpenDHTSettings.qml @@ -74,7 +74,7 @@ ColumnLayout { onSwitchToggled: CurrentAccount.proxyEnabled = checked } - SettingsMaterialLineEdit { + SettingsMaterialTextEdit { id: lineEditProxy Layout.fillWidth: true @@ -90,7 +90,7 @@ ColumnLayout { onEditFinished: CurrentAccount.proxyServer = dynamicText } - SettingsMaterialLineEdit { + SettingsMaterialTextEdit { id: lineEditBootstrap Layout.fillWidth: true diff --git a/src/app/settingsview/components/AdvancedPublicAddressSettings.qml b/src/app/settingsview/components/AdvancedPublicAddressSettings.qml index 54024707e6f70627cee8b93f1a218476cec077c1..d71dcdea844a64d8d073e47cfbaf2c3d2ca20693 100644 --- a/src/app/settingsview/components/AdvancedPublicAddressSettings.qml +++ b/src/app/settingsview/components/AdvancedPublicAddressSettings.qml @@ -71,7 +71,7 @@ ColumnLayout { onSwitchToggled: CurrentAccount.publishedSameAsLocal = checked } - SettingsMaterialLineEdit { + SettingsMaterialTextEdit { id: lineEditSIPCustomAddress Layout.fillWidth: true diff --git a/src/app/settingsview/components/AdvancedSIPSecuritySettings.qml b/src/app/settingsview/components/AdvancedSIPSecuritySettings.qml index b3ef0beb55521298dcb80d14f7f516dde61f3574..673ba8c2204fb506fd30abb3fc450086afcc9d12 100644 --- a/src/app/settingsview/components/AdvancedSIPSecuritySettings.qml +++ b/src/app/settingsview/components/AdvancedSIPSecuritySettings.qml @@ -178,11 +178,10 @@ ColumnLayout { } // Private key password - SettingsMaterialLineEdit { + SettingsMaterialTextEdit { id: lineEditSIPCertPassword Layout.fillWidth: true - Layout.preferredHeight: JamiTheme.preferredFieldHeight enabled: CurrentAccount.enable_TLS @@ -262,7 +261,7 @@ ColumnLayout { parseInt(comboModel.get(modelIndex).secondArg) } - SettingsMaterialLineEdit { + SettingsMaterialTextEdit { id: outgoingTLSServerNameLineEdit Layout.fillWidth: true diff --git a/src/app/settingsview/components/AdvancedVoiceMailSettings.qml b/src/app/settingsview/components/AdvancedVoiceMailSettings.qml index 941398d96d484aaf9579e1e4b74b2b6b96d32f6c..91319b9855d9d5ee41453944732aede3d74362cc 100644 --- a/src/app/settingsview/components/AdvancedVoiceMailSettings.qml +++ b/src/app/settingsview/components/AdvancedVoiceMailSettings.qml @@ -40,7 +40,7 @@ ColumnLayout { maxWidth: width } - SettingsMaterialLineEdit { + SettingsMaterialTextEdit { id: lineEditVoiceMailDialCode Layout.fillWidth: true diff --git a/src/app/settingsview/components/JamiUserIdentity.qml b/src/app/settingsview/components/JamiUserIdentity.qml index fcdbfd6b47ef7b402833cec21c42a288ec003bbc..94878ccd57a98be0d74bab58d5954671c2ec6f8f 100644 --- a/src/app/settingsview/components/JamiUserIdentity.qml +++ b/src/app/settingsview/components/JamiUserIdentity.qml @@ -109,65 +109,33 @@ ColumnLayout { verticalAlignment: Text.AlignVCenter } - UsernameLineEdit { + UsernameTextEdit { id: currentRegisteredID - anchors.verticalCenter: parent.verticalCenter - - height: JamiTheme.preferredFieldHeight width: JamiTheme.preferredFieldWidth - - padding: 8 - horizontalAlignment: CurrentAccount.registeredName === "" ? Text.AlignLeft : - Text.AlignRight - verticalAlignment: Text.AlignVCenter - wrapMode: Text.NoWrap - placeholderText: CurrentAccount.registeredName === "" ? - JamiStrings.registerAUsername : "" - text: CurrentAccount.registeredName - readOnly: CurrentAccount.registeredName !== "" - font.bold: CurrentAccount.registeredName !== "" - - loseFocusWhenEnterPressed: btnRegisterName.visible - - onEditingFinished: { - if (btnRegisterName.visible) - btnRegisterName.clicked() - } - } - } - - MaterialButton { - id: btnRegisterName - - Layout.alignment: Qt.AlignVCenter | Qt.AlignRight - Layout.rightMargin: currentRegisteredID.width / 2 - width / 2 - - preferredWidth: 120 - preferredHeight: 30 - - visible: CurrentAccount.registeredName === "" && - currentRegisteredID.nameRegistrationState === - UsernameLineEdit.NameRegistrationState.FREE - - text: JamiStrings.register - toolTipText: JamiStrings.registerUsername - color: JamiTheme.buttonTintedGrey - hoveredColor: JamiTheme.buttonTintedGreyHovered - pressedColor: JamiTheme.buttonTintedGreyPressed - - onClicked: { - if (currentRegisteredID.text === '') { - return + height: JamiTheme.preferredFieldHeight + 16 + + anchors.margins: 8 + + fontPointSize: JamiTheme.textFontSize + 1 + staticText: CurrentAccount.registeredName + placeholderText: JamiStrings.chooseUsername + editMode: !CurrentAccount.registeredName + isPersistent: !CurrentAccount.registeredName + + onAccepted: { + if (dynamicText === '') { + return + } + var dlg = viewCoordinator.presentDialog( + appWindow, + "settingsview/components/NameRegistrationDialog.qml", + { registeredName: dynamicText }) + dlg.accepted.connect(function() { + currentRegisteredID.nameRegistrationState = + UsernameTextEdit.NameRegistrationState.BLANK + }) } - var dlg = viewCoordinator.presentDialog( - appWindow, - "settingsview/components/NameRegistrationDialog.qml", - { registeredName: currentRegisteredID.text }) - dlg.accepted.connect(function() { - currentRegisteredID.nameRegistrationState = - UsernameLineEdit.NameRegistrationState.BLANK - }) } } } diff --git a/src/app/settingsview/components/SIPUserIdentity.qml b/src/app/settingsview/components/SIPUserIdentity.qml index ef6a155b86615a94e7a7ca5379d5f77f23e511b4..1ee75e16e5fe592ac794b04e136ca074254ad07f 100644 --- a/src/app/settingsview/components/SIPUserIdentity.qml +++ b/src/app/settingsview/components/SIPUserIdentity.qml @@ -30,7 +30,7 @@ ColumnLayout { property int itemWidth - SettingsMaterialLineEdit { + SettingsMaterialTextEdit { id: usernameSIP Layout.fillWidth: true @@ -44,7 +44,7 @@ ColumnLayout { onEditFinished: CurrentAccount.username = dynamicText } - SettingsMaterialLineEdit { + SettingsMaterialTextEdit { id: hostnameSIP Layout.fillWidth: true @@ -58,7 +58,7 @@ ColumnLayout { onEditFinished: CurrentAccount.hostname = dynamicText } - SettingsMaterialLineEdit { + SettingsMaterialTextEdit { id: proxySIP Layout.fillWidth: true @@ -72,17 +72,17 @@ ColumnLayout { onEditFinished: CurrentAccount.routeset = dynamicText } - SettingsMaterialLineEdit { + SettingsMaterialTextEdit { id: passSIPlineEdit - staticText: CurrentAccount.password - Layout.fillWidth: true Layout.preferredHeight: JamiTheme.preferredFieldHeight - titleField: JamiStrings.password + staticText: CurrentAccount.password + titleField: JamiStrings.password itemWidth: root.itemWidth + isPassword: true onEditFinished: CurrentAccount.password = dynamicText } diff --git a/src/app/settingsview/components/SettingsMaterialLineEdit.qml b/src/app/settingsview/components/SettingsMaterialTextEdit.qml similarity index 68% rename from src/app/settingsview/components/SettingsMaterialLineEdit.qml rename to src/app/settingsview/components/SettingsMaterialTextEdit.qml index 4f767fb9290e02531519ee7967d96ecd65783f3a..77e68e6208569dc79ab5aaf1a8c40be63c2afc7e 100644 --- a/src/app/settingsview/components/SettingsMaterialLineEdit.qml +++ b/src/app/settingsview/components/SettingsMaterialTextEdit.qml @@ -29,10 +29,11 @@ RowLayout { id: root property alias titleField: title.text - property alias staticText: modalTextEdit.staticText - property alias placeholderText: modalTextEdit.placeholderText - property alias enabled: modalTextEdit.enabled - property alias dynamicText: modalTextEdit.dynamicText + property string staticText + property string placeholderText + property string dynamicText + + property bool isPassword: false property int itemWidth @@ -56,13 +57,35 @@ RowLayout { ModalTextEdit { id: modalTextEdit + + visible: !root.isPassword + + Layout.alignment: Qt.AlignCenter + Layout.preferredWidth: itemWidth + Layout.maximumHeight: 40 + staticText: root.staticText + placeholderText: root.placeholderText ? root.placeholderText : root.titleField + + onAccepted: { + root.dynamicText = dynamicText + editFinished() + } + + } + + PasswordTextEdit { + id: passwordTextEdit + + visible: root.isPassword + Layout.alignment: Qt.AlignCenter Layout.preferredWidth: itemWidth Layout.maximumHeight: 40 - staticText: staticText - placeholderText: "" + staticText: root.staticText + placeholderText: root.placeholderText ? root.placeholderText : root.titleField onAccepted: { + root.dynamicText = dynamicText editFinished() } diff --git a/src/app/wizardview/components/AdvancedAccountSettings.qml b/src/app/wizardview/components/AdvancedAccountSettings.qml index 2336538289f988a809edf7eb04c574c600e823f7..5a700fbc642f3a71b496d23cec332c8da6f7a9b0 100644 --- a/src/app/wizardview/components/AdvancedAccountSettings.qml +++ b/src/app/wizardview/components/AdvancedAccountSettings.qml @@ -545,8 +545,10 @@ Rectangle { preferredWidth: Math.min(JamiTheme.wizardButtonWidth, root.width - JamiTheme.preferredMarginSize * 2) text: JamiStrings.optionSave - onClicked: { root.saveButtonClicked() - root.alias = displayNameLineEdit.dynamicText} + onClicked: { + root.saveButtonClicked() + root.alias = displayNameLineEdit.dynamicText + } } } diff --git a/src/app/wizardview/components/CreateAccountPage.qml b/src/app/wizardview/components/CreateAccountPage.qml index c5347b9f653e941ed43ad402ac84be3a684c9ac9..187b168a717d0f3e94acd708606b57ae594901a3 100644 --- a/src/app/wizardview/components/CreateAccountPage.qml +++ b/src/app/wizardview/components/CreateAccountPage.qml @@ -136,7 +136,7 @@ Rectangle { Layout.alignment: Qt.AlignHCenter Layout.preferredWidth: Math.min(440, root.width - JamiTheme.preferredMarginSize * 2) placeholderText: root.isRendezVous ? JamiStrings.chooseAName : - JamiStrings.chooseYourUserName + JamiStrings.chooseUsername staticText: "" editMode: true focus: visible @@ -162,16 +162,16 @@ Rectangle { text: { switch(usernameEdit.nameRegistrationState){ - case UsernameLineEdit.NameRegistrationState.BLANK: + case UsernameTextEdit.NameRegistrationState.BLANK: return " " - case UsernameLineEdit.NameRegistrationState.SEARCHING: + case UsernameTextEdit.NameRegistrationState.SEARCHING: return " " - case UsernameLineEdit.NameRegistrationState.FREE: + case UsernameTextEdit.NameRegistrationState.FREE: return " " - case UsernameLineEdit.NameRegistrationState.INVALID: + case UsernameTextEdit.NameRegistrationState.INVALID: return root.isRendezVous ? JamiStrings.invalidName : JamiStrings.invalidUsername - case UsernameLineEdit.NameRegistrationState.TAKEN: + case UsernameTextEdit.NameRegistrationState.TAKEN: return root.isRendezVous ? JamiStrings.nameAlreadyTaken : JamiStrings.usernameAlreadyTaken } @@ -194,8 +194,8 @@ Rectangle { color: enabled? JamiTheme.buttonTintedBlue : JamiTheme.buttonTintedGrey text: !enabled ? JamiStrings.creatingAccount : root.isRendezVous ? JamiStrings.chooseName : JamiStrings.joinJami - enabled: usernameEdit.nameRegistrationState === UsernameLineEdit.NameRegistrationState.FREE - || usernameEdit.nameRegistrationState === UsernameLineEdit.NameRegistrationState.BLANK + enabled: usernameEdit.nameRegistrationState === UsernameTextEdit.NameRegistrationState.FREE + || usernameEdit.nameRegistrationState === UsernameTextEdit.NameRegistrationState.BLANK KeyNavigation.tab: showAdvancedButton @@ -212,13 +212,13 @@ Rectangle { avatar: UtilsAdapter.tempCreationImage(), isRendezVous: root.isRendezVous }) - if (usernameEdit.nameRegistrationState === UsernameLineEdit.NameRegistrationState.FREE) { + if (usernameEdit.nameRegistrationState === UsernameTextEdit.NameRegistrationState.FREE) { enabled = false showAdvancedButton.enabled = false WizardViewStepModel.nextStep() } - if(usernameEdit.nameRegistrationState === UsernameLineEdit.NameRegistrationState.BLANK) + if(usernameEdit.nameRegistrationState === UsernameTextEdit.NameRegistrationState.BLANK) popup.visible = true } diff --git a/src/app/wizardview/components/CreateSIPAccountPage.qml b/src/app/wizardview/components/CreateSIPAccountPage.qml index 3e41c8ee50dd68a30085c0aa2ae21084f04c5d82..00da8430b2041e90b4519e99ae4093968ec89b6e 100644 --- a/src/app/wizardview/components/CreateSIPAccountPage.qml +++ b/src/app/wizardview/components/CreateSIPAccountPage.qml @@ -265,7 +265,6 @@ Rectangle { } ModalTextEdit { - id: displayNameLineEdit Layout.alignment: Qt.AlignCenter diff --git a/tests/qml/to_fix/tst_WizardView.qml b/tests/qml/to_fix/tst_WizardView.qml index 984d64c15b50307c9c017028b7abb023b28a87c7..b10e279352898511095d353c6c5f72b0ee6f44fe 100644 --- a/tests/qml/to_fix/tst_WizardView.qml +++ b/tests/qml/to_fix/tst_WizardView.qml @@ -704,7 +704,7 @@ WizardView { // With username usernameEdit.nameRegistrationState = - UsernameLineEdit.NameRegistrationState.FREE + UsernameTextEdit.NameRegistrationState.FREE keyClick(Qt.Key_Tab) compare(chooseUsernameButton.focus, true)