From 00b6694073ce66b0a157eeb3696cd34e647ece64 Mon Sep 17 00:00:00 2001 From: demmm Date: Wed, 30 Jun 2021 18:29:32 +0200 Subject: [PATCH 1/5] [usersq] use validator for login & hostname pallette for colors inline warning messages now work, password fields checks included left to implement are password validation inline messages --- src/modules/usersq/usersq.qml | 90 ++++++++++++++++------------------- 1 file changed, 41 insertions(+), 49 deletions(-) diff --git a/src/modules/usersq/usersq.qml b/src/modules/usersq/usersq.qml index 2199ac676..fbd748f11 100644 --- a/src/modules/usersq/usersq.qml +++ b/src/modules/usersq/usersq.qml @@ -11,7 +11,7 @@ import io.calamares.core 1.0 import io.calamares.ui 1.0 -import QtQuick 2.10 +import QtQuick 2.15 import QtQuick.Controls 2.10 import QtQuick.Layouts 1.3 import org.kde.kirigami 2.7 as Kirigami @@ -56,13 +56,8 @@ Kirigami.ScrollablePage { placeholderText: qsTr("Your Full Name") text: config.fullName onTextChanged: config.setFullName(text); - - background: Rectangle { - radius: 2 - opacity: 0.9 - //border.color: _userNameField.text === "" ? Kirigami.Theme.backgroundColor : ( config.fullNameReady ? Kirigami.Theme.backgroundColor : Kirigami.Theme.negativeTextColor) - color: _userNameField.text.length ? ( config.fullNameChanged ? "#f0fff0" : "#ffdae0") : "#FBFBFB" - } + palette.base: _userNameField.text.length ? "#f0fff0" : "#FBFBFB" + palette.highlight : _userNameField.text.length ? "#dcffdc" : "#FBFBFB" } } @@ -81,14 +76,11 @@ Kirigami.ScrollablePage { enabled: config.isEditable("loginName") placeholderText: qsTr("Login Name") text: config.loginName - //onTextChanged: config.setLoginName(text) - onTextChanged: config.loginNameStatusChanged ? ( config.setLoginName(text),userMessage.visible = false ) : ( userMessage.visible = true ) + validator: RegularExpressionValidator { regularExpression: /[a-z_][a-z0-9_-]*[$]?$/ } + onTextChanged: acceptableInput ? ( config.setLoginName(text),userMessage.visible = false ) : ( userMessage.visible = true,console.log("Invalid") ) - background: Rectangle { - opacity: 0.9 - //border.color: _userLoginField.text === "" ? Kirigami.Theme.backgroundColor : ( config.userNameReady ? Kirigami.Theme.backgroundColor : Kirigami.Theme.negativeTextColor) - color: _userLoginField.text.length ? ( config.loginNameStatusChanged ? "#f0fff0" : "#ffdae0") : "#FBFBFB" - } + palette.base: _userLoginField.text.length ? "#f0fff0" : "#FBFBFB" + palette.highlight : _userLoginField.text.length ? "#dcffdc" : "#FBFBFB" } Label { @@ -105,7 +97,7 @@ Kirigami.ScrollablePage { Layout.fillWidth: true visible: false type: Kirigami.MessageType.Error - text: qsTr("Your username must start with a lowercase letter or underscore.") + text: qsTr("Your username must start with a lowercase letter or underscore, minimal of two characters.") } Column { @@ -122,13 +114,11 @@ Kirigami.ScrollablePage { width: parent.width placeholderText: qsTr("Computer Name") text: config.hostName - onTextChanged: config.hostNameStatusChanged ? (config.setHostName(text),hostMessage.visible = false) : hostMessage.visible = true + validator: RegularExpressionValidator { regularExpression: /[a-zA-Z0-9][-a-zA-Z0-9_]+/ } + onTextChanged: acceptableInput ? (config.setHostName(text),hostMessage.visible = false) : hostMessage.visible = true - background: Rectangle { - opacity: 0.9 - //border.color: _hostName.text === "" ? Kirigami.Theme.backgroundColor : ( config.hostNameStatusChanged ? Kirigami.Theme.backgroundColor : Kirigami.Theme.negativeTextColor) - color: _hostName.text.length ? ( config.hostNameStatusChanged ? "#f0fff0" : "#ffdae0") : "#FBFBFB" - } + palette.base: _hostName.text.length ? ( acceptableInput ? "#f0fff0" : "#ffdae0") : "#FBFBFB" + palette.highlight : _hostName.text.length ? "#dcffdc" : "#FBFBFB" } Label { @@ -145,7 +135,7 @@ Kirigami.ScrollablePage { Layout.fillWidth: true visible: false type: Kirigami.MessageType.Error - text: qsTr("Only letter, numbers, underscore and hyphen are allowed.") + text: qsTr("Only letter, numbers, underscore and hyphen are allowed, minimal of two characters.") } Column { @@ -167,16 +157,12 @@ Kirigami.ScrollablePage { placeholderText: qsTr("Password") text: config.userPassword onTextChanged: config.setUserPassword(text) + palette.base: _passwordField.text.length ? "#f0fff0" : "#FBFBFB" + palette.highlight : _passwordField.text.length ? "#dcffdc" : "#FBFBFB" echoMode: TextInput.Password passwordMaskDelay: 300 inputMethodHints: Qt.ImhNoAutoUppercase - - background: Rectangle { - opacity: 0.9 - //border.color: _passwordField.text === "" ? Kirigami.Theme.backgroundColor : ( config.passwordReady ? Kirigami.Theme.backgroundColor : Kirigami.Theme.negativeTextColor) - color: _passwordField.text.length ? ( config.userPasswordStatusChanged ? "#f0fff0" : "#ffdae0") : "#FBFBFB" - } } TextField { @@ -184,17 +170,14 @@ Kirigami.ScrollablePage { width: parent.width / 2 - 10 placeholderText: qsTr("Repeat Password") text: config.userPasswordSecondary - onTextChanged: config.setUserPasswordSecondary(text) + onTextChanged: _passwordField.text === _verificationPasswordField.text ? (config.setUserPasswordSecondary(text),passMessage.visible = false) : passMessage.visible = true + + palette.base: _verificationPasswordField.text.length ? ( _passwordField.text === _verificationPasswordField.text ? "#f0fff0" : "#ffdae0") : "#FBFBFB" + palette.highlight : _verificationPasswordField.text.length ? "#dcffdc" : "#FBFBFB" echoMode: TextInput.Password passwordMaskDelay: 300 inputMethodHints: Qt.ImhNoAutoUppercase - - background: Rectangle { - opacity: 0.9 - //border.color: _verificationpasswordField.text === "" ? Kirigami.Theme.backgroundColor : ( config.passwordReady ? Kirigami.Theme.backgroundColor : Kirigami.Theme.negativeTextColor) - color: _verificationPasswordField.text.length ? ( config.userPasswordSecondaryChanged ? "#f0fff0" : "#ffdae0") : "#FBFBFB" - } } } @@ -208,6 +191,14 @@ Kirigami.ScrollablePage { } } + Kirigami.InlineMessage { + id: passMessage + Layout.fillWidth: true + visible: false + type: Kirigami.MessageType.Error + text: qsTr("Your passwords do not match!") + } + CheckBox { id: root visible: config.writeRootPassword @@ -245,16 +236,12 @@ Kirigami.ScrollablePage { placeholderText: qsTr("Root Password") text: config.rootPassword onTextChanged: config.setRootPassword(text) + palette.base: _rootPasswordField.text.length ? "#f0fff0" : "#FBFBFB" + palette.highlight : _rootPasswordField.text.length ? "#dcffdc" : "#FBFBFB" echoMode: TextInput.Password passwordMaskDelay: 300 inputMethodHints: Qt.ImhNoAutoUppercase - - background: Rectangle { - opacity: 0.9 - //border.color: _rootPasswordField.text === "" ? Kirigami.Theme.backgroundColor : ( config.rootPasswordReady ? Kirigami.Theme.backgroundColor : Kirigami.Theme.negativeTextColor) - color: _rootPasswordField.text.length ? ( config.rootPasswordReady ? "#f0fff0" : "#ffdae0") : "#FBFBFB" - } } TextField { @@ -262,17 +249,14 @@ Kirigami.ScrollablePage { width: parent.width / 2 -10 placeholderText: qsTr("Repeat Root Password") text: config.rootPasswordSecondary - onTextChanged: config.setRootPasswordSecondary(text) + //onTextChanged: config.setRootPasswordSecondary(text) + onTextChanged: _rootPasswordField.text === _verificationRootPasswordField.text ? (config.setRootPasswordSecondary(text),rootPassMessage.visible = false) : rootPassMessage.visible = true + palette.base: _verificationRootPasswordField.text.length ? ( _rootPasswordField.text === _verificationRootPasswordField.text ? "#f0fff0" : "#ffdae0") : "#FBFBFB" + palette.highlight : _verificationRootPasswordField.text.length ? "#dcffdc" : "#FBFBFB" echoMode: TextInput.Password passwordMaskDelay: 300 inputMethodHints: Qt.ImhNoAutoUppercase - - background: Rectangle { - opacity: 0.9 - //border.color: _verificationRootPasswordField.text === "" ? Kirigami.Theme.backgroundColor : ( config.rootPasswordReady ? Kirigami.Theme.backgroundColor : Kirigami.Theme.negativeTextColor) - color: _verificationRootPasswordField.text.length ? ( config.rootPasswordReady ? "#f0fff0" : "#ffdae0") : "#FBFBFB" - } } } @@ -286,6 +270,14 @@ Kirigami.ScrollablePage { } } + Kirigami.InlineMessage { + id: rootPassMessage + Layout.fillWidth: true + visible: false + type: Kirigami.MessageType.Error + text: qsTr("Your passwords do not match!") + } + CheckBox { Layout.alignment: Qt.AlignCenter text: qsTr("Log in automatically without asking for the password") From ce699d8e3d4d88079ca205fac1ab3a261ca8fde7 Mon Sep 17 00:00:00 2001 From: demmm Date: Wed, 30 Jun 2021 22:29:32 +0200 Subject: [PATCH 2/5] [usersq] add warnings for forbidden names root & localhost set as forbidden in loginname & hostname --- src/modules/usersq/usersq.qml | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/modules/usersq/usersq.qml b/src/modules/usersq/usersq.qml index fbd748f11..064ffcc34 100644 --- a/src/modules/usersq/usersq.qml +++ b/src/modules/usersq/usersq.qml @@ -77,9 +77,9 @@ Kirigami.ScrollablePage { placeholderText: qsTr("Login Name") text: config.loginName validator: RegularExpressionValidator { regularExpression: /[a-z_][a-z0-9_-]*[$]?$/ } - onTextChanged: acceptableInput ? ( config.setLoginName(text),userMessage.visible = false ) : ( userMessage.visible = true,console.log("Invalid") ) + onTextChanged: acceptableInput ? ( _userLoginField.text === "root" ? forbiddenMessage.visible=true : ( config.setLoginName(text),userMessage.visible = false,forbiddenMessage.visible=false ) ) : ( userMessage.visible = true,console.log("Invalid") ) - palette.base: _userLoginField.text.length ? "#f0fff0" : "#FBFBFB" + palette.base: _userLoginField.text.length ? ( acceptableInput ? ( _userLoginField.text === "root" ? "#ffdae0" : "#f0fff0" ) : "#ffdae0") : "#FBFBFB" palette.highlight : _userLoginField.text.length ? "#dcffdc" : "#FBFBFB" } @@ -97,7 +97,15 @@ Kirigami.ScrollablePage { Layout.fillWidth: true visible: false type: Kirigami.MessageType.Error - text: qsTr("Your username must start with a lowercase letter or underscore, minimal of two characters.") + text: qsTr("Only lowercase letters, numbers, underscore and hyphen are allowed.") + } + + Kirigami.InlineMessage { + id: forbiddenMessage + Layout.fillWidth: true + visible: false + type: Kirigami.MessageType.Error + text: qsTr("root is not allowed as username.") } Column { @@ -115,9 +123,9 @@ Kirigami.ScrollablePage { placeholderText: qsTr("Computer Name") text: config.hostName validator: RegularExpressionValidator { regularExpression: /[a-zA-Z0-9][-a-zA-Z0-9_]+/ } - onTextChanged: acceptableInput ? (config.setHostName(text),hostMessage.visible = false) : hostMessage.visible = true + onTextChanged: acceptableInput ? ( _hostName.text === "localhost" ? forbiddenHost.visible=true : (config.setHostName(text),hostMessage.visible = false,forbiddenHost.visible = false) ) : hostMessage.visible = true - palette.base: _hostName.text.length ? ( acceptableInput ? "#f0fff0" : "#ffdae0") : "#FBFBFB" + palette.base: _hostName.text.length ? ( acceptableInput ? ( _hostName.text === "localhost" ? "#ffdae0" : "#f0fff0" ) : "#ffdae0") : "#FBFBFB" palette.highlight : _hostName.text.length ? "#dcffdc" : "#FBFBFB" } @@ -138,6 +146,14 @@ Kirigami.ScrollablePage { text: qsTr("Only letter, numbers, underscore and hyphen are allowed, minimal of two characters.") } + Kirigami.InlineMessage { + id: forbiddenHost + Layout.fillWidth: true + visible: false + type: Kirigami.MessageType.Error + text: qsTr("localhost is not allowed as hostname.") + } + Column { Layout.fillWidth: true spacing: Kirigami.Units.smallSpacing @@ -251,6 +267,7 @@ Kirigami.ScrollablePage { text: config.rootPasswordSecondary //onTextChanged: config.setRootPasswordSecondary(text) onTextChanged: _rootPasswordField.text === _verificationRootPasswordField.text ? (config.setRootPasswordSecondary(text),rootPassMessage.visible = false) : rootPassMessage.visible = true + palette.base: _verificationRootPasswordField.text.length ? ( _rootPasswordField.text === _verificationRootPasswordField.text ? "#f0fff0" : "#ffdae0") : "#FBFBFB" palette.highlight : _verificationRootPasswordField.text.length ? "#dcffdc" : "#FBFBFB" From a156d2e63ff54215da74c2558c8b58d8adb14b7e Mon Sep 17 00:00:00 2001 From: demmm Date: Sat, 3 Jul 2021 00:10:31 +0200 Subject: [PATCH 3/5] [usersq] working password validity check kirigami inlinemessages adjusted for password fields coding style, break lines in variables add closing button for root password inline message, needed bc of re-use root password option does not remove all messages --- src/modules/usersq/usersq.qml | 89 ++++++++++++++++++++++++++++++----- 1 file changed, 76 insertions(+), 13 deletions(-) diff --git a/src/modules/usersq/usersq.qml b/src/modules/usersq/usersq.qml index 064ffcc34..0654c4619 100644 --- a/src/modules/usersq/usersq.qml +++ b/src/modules/usersq/usersq.qml @@ -55,7 +55,8 @@ Kirigami.ScrollablePage { enabled: config.isEditable("fullName") placeholderText: qsTr("Your Full Name") text: config.fullName - onTextChanged: config.setFullName(text); + onTextChanged: config.setFullName(text) + palette.base: _userNameField.text.length ? "#f0fff0" : "#FBFBFB" palette.highlight : _userNameField.text.length ? "#dcffdc" : "#FBFBFB" } @@ -77,9 +78,18 @@ Kirigami.ScrollablePage { placeholderText: qsTr("Login Name") text: config.loginName validator: RegularExpressionValidator { regularExpression: /[a-z_][a-z0-9_-]*[$]?$/ } - onTextChanged: acceptableInput ? ( _userLoginField.text === "root" ? forbiddenMessage.visible=true : ( config.setLoginName(text),userMessage.visible = false,forbiddenMessage.visible=false ) ) : ( userMessage.visible = true,console.log("Invalid") ) - palette.base: _userLoginField.text.length ? ( acceptableInput ? ( _userLoginField.text === "root" ? "#ffdae0" : "#f0fff0" ) : "#ffdae0") : "#FBFBFB" + onTextChanged: acceptableInput + ? ( _userLoginField.text === "root" + ? forbiddenMessage.visible=true + : ( config.setLoginName(text), + userMessage.visible = false,forbiddenMessage.visible=false ) ) + : ( userMessage.visible = true,console.log("Invalid") ) + + palette.base: _userLoginField.text.length + ? ( acceptableInput + ? ( _userLoginField.text === "root" + ? "#ffdae0" : "#f0fff0" ) : "#ffdae0" ) : "#FBFBFB" palette.highlight : _userLoginField.text.length ? "#dcffdc" : "#FBFBFB" } @@ -123,9 +133,19 @@ Kirigami.ScrollablePage { placeholderText: qsTr("Computer Name") text: config.hostName validator: RegularExpressionValidator { regularExpression: /[a-zA-Z0-9][-a-zA-Z0-9_]+/ } - onTextChanged: acceptableInput ? ( _hostName.text === "localhost" ? forbiddenHost.visible=true : (config.setHostName(text),hostMessage.visible = false,forbiddenHost.visible = false) ) : hostMessage.visible = true - palette.base: _hostName.text.length ? ( acceptableInput ? ( _hostName.text === "localhost" ? "#ffdae0" : "#f0fff0" ) : "#ffdae0") : "#FBFBFB" + onTextChanged: acceptableInput + ? ( _hostName.text === "localhost" + ? forbiddenHost.visible=true + : ( config.setHostName(text), + hostMessage.visible = false,forbiddenHost.visible = false ) ) + : hostMessage.visible = true + + palette.base: _hostName.text.length + ? ( acceptableInput + ? ( _hostName.text === "localhost" ? "#ffdae0" : "#f0fff0" ) + : "#ffdae0") + : "#FBFBFB" palette.highlight : _hostName.text.length ? "#dcffdc" : "#FBFBFB" } @@ -173,6 +193,7 @@ Kirigami.ScrollablePage { placeholderText: qsTr("Password") text: config.userPassword onTextChanged: config.setUserPassword(text) + palette.base: _passwordField.text.length ? "#f0fff0" : "#FBFBFB" palette.highlight : _passwordField.text.length ? "#dcffdc" : "#FBFBFB" @@ -186,9 +207,18 @@ Kirigami.ScrollablePage { width: parent.width / 2 - 10 placeholderText: qsTr("Repeat Password") text: config.userPasswordSecondary - onTextChanged: _passwordField.text === _verificationPasswordField.text ? (config.setUserPasswordSecondary(text),passMessage.visible = false) : passMessage.visible = true - palette.base: _verificationPasswordField.text.length ? ( _passwordField.text === _verificationPasswordField.text ? "#f0fff0" : "#ffdae0") : "#FBFBFB" + onTextChanged: _passwordField.text === _verificationPasswordField.text + ? ( config.setUserPasswordSecondary(text), + passMessage.visible = false, + validityMessage.visible = true ) + : ( passMessage.visible = true, + validityMessage.visible = false ) + + palette.base: _verificationPasswordField.text.length + ? ( _passwordField.text === _verificationPasswordField.text + ? "#f0fff0" : "#ffdae0" ) + : "#FBFBFB" palette.highlight : _verificationPasswordField.text.length ? "#dcffdc" : "#FBFBFB" echoMode: TextInput.Password @@ -212,7 +242,18 @@ Kirigami.ScrollablePage { Layout.fillWidth: true visible: false type: Kirigami.MessageType.Error - text: qsTr("Your passwords do not match!") + text: config.userPasswordMessage + } + + Kirigami.InlineMessage { + id: validityMessage + Layout.fillWidth: true + visible: false + type: config.userPasswordValidity + ? ( config.requireStrongPasswords + ? Kirigami.MessageType.Error : Kirigami.MessageType.Warning ) + : Kirigami.MessageType.Positive + text: config.userPasswordMessage } CheckBox { @@ -251,7 +292,9 @@ Kirigami.ScrollablePage { width: parent.width / 2 -10 placeholderText: qsTr("Root Password") text: config.rootPassword + onTextChanged: config.setRootPassword(text) + palette.base: _rootPasswordField.text.length ? "#f0fff0" : "#FBFBFB" palette.highlight : _rootPasswordField.text.length ? "#dcffdc" : "#FBFBFB" @@ -265,10 +308,17 @@ Kirigami.ScrollablePage { width: parent.width / 2 -10 placeholderText: qsTr("Repeat Root Password") text: config.rootPasswordSecondary - //onTextChanged: config.setRootPasswordSecondary(text) - onTextChanged: _rootPasswordField.text === _verificationRootPasswordField.text ? (config.setRootPasswordSecondary(text),rootPassMessage.visible = false) : rootPassMessage.visible = true - palette.base: _verificationRootPasswordField.text.length ? ( _rootPasswordField.text === _verificationRootPasswordField.text ? "#f0fff0" : "#ffdae0") : "#FBFBFB" + onTextChanged: _rootPasswordField.text === _verificationRootPasswordField.text + ? ( config.setRootPasswordSecondary(text), + rootPassMessage.visible = false, + rootValidityMessage.visible = true ) + : ( rootPassMessage.visible = true, + rootValidityMessage.visible = false ) + + palette.base: _verificationRootPasswordField.text.length + ? ( _rootPasswordField.text === _verificationRootPasswordField.text + ? "#f0fff0" : "#ffdae0") : "#FBFBFB" palette.highlight : _verificationRootPasswordField.text.length ? "#dcffdc" : "#FBFBFB" echoMode: TextInput.Password @@ -292,7 +342,19 @@ Kirigami.ScrollablePage { Layout.fillWidth: true visible: false type: Kirigami.MessageType.Error - text: qsTr("Your passwords do not match!") + text: config.rootPasswordMessage + } + + Kirigami.InlineMessage { + id: rootValidityMessage + Layout.fillWidth: true + showCloseButton: true + visible: false + type: config.rootPasswordValidity + ? ( config.requireStrongPasswords + ? Kirigami.MessageType.Error : Kirigami.MessageType.Warning ) + : Kirigami.MessageType.Positive + text: config.rootPasswordMessage } CheckBox { @@ -307,7 +369,8 @@ Kirigami.ScrollablePage { Layout.alignment: Qt.AlignCenter text: qsTr("Validate passwords quality") checked: config.requireStrongPasswords - onCheckedChanged: config.setRequireStrongPasswords(checked) + onCheckedChanged: config.setRequireStrongPasswords(checked), + rootPassMessage.visible = false } Label { From fce798dadf74bfb4d2e7c2e6270bbdfe47b1140a Mon Sep 17 00:00:00 2001 From: demmm Date: Sat, 3 Jul 2021 14:21:07 +0200 Subject: [PATCH 4/5] [users] add an OK message to password message fields empty text box on all good status in usersq is confusing --- src/modules/users/Config.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/users/Config.cpp b/src/modules/users/Config.cpp index 6560d06ac..b19d29e6a 100644 --- a/src/modules/users/Config.cpp +++ b/src/modules/users/Config.cpp @@ -545,7 +545,7 @@ Config::passwordStatus( const QString& pw1, const QString& pw2 ) const } } - return qMakePair( PasswordValidity::Valid, QString() ); + return qMakePair( PasswordValidity::Valid, tr( "OK!" ) ); } From 8b561a29f51cdaf1e9f048449d2b79ffb3e14a86 Mon Sep 17 00:00:00 2001 From: demmm Date: Sat, 3 Jul 2021 14:23:01 +0200 Subject: [PATCH 5/5] [usersq] add close button to all password message fields --- src/modules/usersq/usersq.qml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/modules/usersq/usersq.qml b/src/modules/usersq/usersq.qml index 0654c4619..2eb4be1e1 100644 --- a/src/modules/usersq/usersq.qml +++ b/src/modules/usersq/usersq.qml @@ -240,6 +240,7 @@ Kirigami.ScrollablePage { Kirigami.InlineMessage { id: passMessage Layout.fillWidth: true + showCloseButton: true visible: false type: Kirigami.MessageType.Error text: config.userPasswordMessage @@ -248,6 +249,7 @@ Kirigami.ScrollablePage { Kirigami.InlineMessage { id: validityMessage Layout.fillWidth: true + showCloseButton: true visible: false type: config.userPasswordValidity ? ( config.requireStrongPasswords @@ -340,6 +342,7 @@ Kirigami.ScrollablePage { Kirigami.InlineMessage { id: rootPassMessage Layout.fillWidth: true + showCloseButton: true visible: false type: Kirigami.MessageType.Error text: config.rootPasswordMessage