2020-08-25 16:05:56 +02:00
/* === This file is part of Calamares - <https:/ / calamares . io > ===
2020-08-11 13:46:05 +02:00
*
2021-06-26 18:14:19 +02:00
* SPDX - FileCopyrightText: 2020 - 2021 Anke Boersma < demm @ kaosx . us >
* SPDX - FileCopyrightText: 2021 Adriaan de Groot < groot @ kde . org >
2020-08-11 13:46:05 +02:00
* SPDX - License - Identifier: GPL - 3.0 - or - later
*
2020-08-25 16:05:56 +02:00
* Calamares is Free Software: see the License - Identifier above .
2020-08-11 13:46:05 +02:00
*
* /
import io . calamares . core 1.0
import io . calamares . ui 1.0
2021-06-30 18:29:32 +02:00
import QtQuick 2.15
2020-08-11 13:46:05 +02:00
import QtQuick . Controls 2.10
import QtQuick . Layouts 1.3
import org . kde . kirigami 2.7 as Kirigami
import QtGraphicalEffects 1.0
import QtQuick . Window 2.3
Kirigami . ScrollablePage {
width: parent . width
height: parent . height
2020-08-25 16:05:56 +02:00
2021-06-26 18:14:19 +02:00
header: Kirigami . Heading {
2020-08-11 13:46:05 +02:00
Layout.fillWidth: true
height: 50
horizontalAlignment: Qt . AlignHCenter
color: Kirigami . Theme . textColor
font.weight: Font . Medium
font.pointSize: 12
text: qsTr ( "Pick your user name and credentials to login and perform admin tasks" )
}
ColumnLayout {
id: _formLayout
spacing: Kirigami . Units . smallSpacing
Column {
Layout.fillWidth: true
spacing: Kirigami . Units . smallSpacing
Label {
width: parent . width
text: qsTr ( "What is your name?" )
}
TextField {
id: _userNameField
width: parent . width
2021-03-15 12:51:42 +01:00
enabled: config . isEditable ( "fullName" )
2020-08-11 13:46:05 +02:00
placeholderText: qsTr ( "Your Full Name" )
2021-03-15 11:45:57 +01:00
text: config . fullName
2021-07-03 00:10:31 +02:00
onTextChanged: config . setFullName ( text )
2021-07-07 01:56:45 +02:00
palette.base: _userNameField . text . length ? Kirigami.Theme.backgroundColor : Kirigami . Theme . backgroundColor
palette.highlight : _userNameField . text . length ? Kirigami.Theme.positiveBackgroundColor : Kirigami . Theme . backgroundColor
2020-08-11 13:46:05 +02:00
}
}
Column {
Layout.fillWidth: true
spacing: Kirigami . Units . smallSpacing
Label {
width: parent . width
text: qsTr ( "What name do you want to use to log in?" )
}
TextField {
id: _userLoginField
width: parent . width
2021-03-15 12:51:42 +01:00
enabled: config . isEditable ( "loginName" )
2020-08-11 13:46:05 +02:00
placeholderText: qsTr ( "Login Name" )
2021-03-15 00:04:39 +01:00
text: config . loginName
2021-06-30 18:29:32 +02:00
validator: RegularExpressionValidator { regularExpression: /[a-z_][a-z0-9_-]*[$]?$/ }
2020-08-11 13:46:05 +02:00
2021-07-03 00:10:31 +02:00
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"
2021-07-07 01:56:45 +02:00
? Kirigami.Theme.negativeBackgroundColor : Kirigami . Theme . backgroundColor ) : Kirigami . Theme . negativeBackgroundColor ) : Kirigami . Theme . backgroundColor
palette.highlight : _userLoginField . text . length ? Kirigami.Theme.positiveBackgroundColor : Kirigami . Theme . backgroundColor
2020-08-11 13:46:05 +02:00
}
Label {
width: parent . width
text: qsTr ( "If more than one person will use this computer, you can create multiple accounts after installation." )
font.weight: Font . Thin
font.pointSize: 8
}
}
2021-06-26 18:14:19 +02:00
Kirigami . InlineMessage {
id: userMessage
Layout.fillWidth: true
visible: false
type: Kirigami . MessageType . Error
2021-06-30 22:29:32 +02:00
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." )
2021-06-26 18:14:19 +02:00
}
2020-08-11 13:46:05 +02:00
2021-06-26 18:14:19 +02:00
Column {
2020-08-11 13:46:05 +02:00
Layout.fillWidth: true
spacing: Kirigami . Units . smallSpacing
Label {
width: parent . width
text: qsTr ( "What is the name of this computer?" )
}
TextField {
id: _hostName
width: parent . width
placeholderText: qsTr ( "Computer Name" )
text: config . hostName
2021-06-30 18:29:32 +02:00
validator: RegularExpressionValidator { regularExpression: /[a-zA-Z0-9][-a-zA-Z0-9_]+/ }
2021-07-07 01:56:45 +02:00
color: Kirigami . Theme . textColor
2021-07-03 00:10:31 +02:00
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
2021-07-07 01:56:45 +02:00
? ( _hostName . text === "localhost" ? Kirigami.Theme.negativeBackgroundColor : Kirigami . Theme . backgroundColor )
: Kirigami . Theme . negativeBackgroundColor )
: Kirigami . Theme . backgroundColor
palette.highlight : _hostName . text . length ? Kirigami.Theme.positiveBackgroundColor : Kirigami . Theme . backgroundColor
2020-08-11 13:46:05 +02:00
}
Label {
width: parent . width
text: qsTr ( "This name will be used if you make the computer visible to others on a network." )
font.weight: Font . Thin
font.pointSize: 8
}
}
2021-06-26 18:14:19 +02:00
Kirigami . InlineMessage {
id: hostMessage
Layout.fillWidth: true
visible: false
type: Kirigami . MessageType . Error
2021-07-13 12:46:04 +02:00
text: qsTr ( "Only letters, numbers, underscore and hyphen are allowed, minimal of two characters." )
2021-06-26 18:14:19 +02:00
}
2020-08-11 13:46:05 +02:00
2021-06-30 22:29:32 +02:00
Kirigami . InlineMessage {
id: forbiddenHost
Layout.fillWidth: true
visible: false
type: Kirigami . MessageType . Error
text: qsTr ( "localhost is not allowed as hostname." )
}
2021-06-26 18:14:19 +02:00
Column {
2020-08-11 13:46:05 +02:00
Layout.fillWidth: true
spacing: Kirigami . Units . smallSpacing
Label {
width: parent . width
text: qsTr ( "Choose a password to keep your account safe." )
}
Row {
width: parent . width
spacing: 20
TextField {
id: _passwordField
width: parent . width / 2 - 10
placeholderText: qsTr ( "Password" )
2021-03-15 11:45:57 +01:00
text: config . userPassword
onTextChanged: config . setUserPassword ( text )
2021-07-03 00:10:31 +02:00
2021-07-07 01:56:45 +02:00
palette.base: _passwordField . text . length ? Kirigami.Theme.backgroundColor : Kirigami . Theme . neutralBackgroundColor
palette.highlight : _passwordField . text . length ? Kirigami.Theme.positiveBackgroundColor : Kirigami . Theme . backgroundColor
2021-03-15 11:45:57 +01:00
2020-08-11 13:46:05 +02:00
echoMode: TextInput . Password
passwordMaskDelay: 300
inputMethodHints: Qt . ImhNoAutoUppercase
}
TextField {
id: _verificationPasswordField
width: parent . width / 2 - 10
placeholderText: qsTr ( "Repeat Password" )
2021-03-15 11:45:57 +01:00
text: config . userPasswordSecondary
2021-06-30 18:29:32 +02:00
2021-07-03 00:10:31 +02:00
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
2021-07-07 01:56:45 +02:00
? Kirigami.Theme.backgroundColor : Kirigami . Theme . negativeBackgroundColor )
: Kirigami . Theme . backgroundColor
palette.highlight : _verificationPasswordField . text . length ? Kirigami.Theme.positiveBackgroundColor : Kirigami . Theme . backgroundColor
2021-03-15 11:45:57 +01:00
2020-08-11 13:46:05 +02:00
echoMode: TextInput . Password
passwordMaskDelay: 300
inputMethodHints: Qt . ImhNoAutoUppercase
}
}
Label {
width: parent . width
text: qsTr ( "Enter the same password twice, so that it can be checked for typing errors. A good password will contain a mixture of letters, numbers and punctuation, should be at least eight characters long, and should be changed at regular intervals." )
font.weight: Font . Thin
font.pointSize: 8
wrapMode: Text . WordWrap
}
}
2020-08-25 16:05:56 +02:00
2021-06-30 18:29:32 +02:00
Kirigami . InlineMessage {
id: passMessage
Layout.fillWidth: true
2021-07-03 14:23:01 +02:00
showCloseButton: true
2021-06-30 18:29:32 +02:00
visible: false
type: Kirigami . MessageType . Error
2021-07-03 00:10:31 +02:00
text: config . userPasswordMessage
}
Kirigami . InlineMessage {
id: validityMessage
Layout.fillWidth: true
2021-07-03 14:23:01 +02:00
showCloseButton: true
2021-07-03 00:10:31 +02:00
visible: false
type: config . userPasswordValidity
? ( config . requireStrongPasswords
? Kirigami.MessageType.Error : Kirigami . MessageType . Warning )
: Kirigami . MessageType . Positive
text: config . userPasswordMessage
2021-06-30 18:29:32 +02:00
}
2020-08-11 13:46:05 +02:00
CheckBox {
id: root
2021-03-15 00:04:39 +01:00
visible: config . writeRootPassword
2020-08-11 13:46:05 +02:00
text: qsTr ( "Reuse user password as root password" )
checked: config . reuseUserPasswordForRoot
2021-03-15 12:36:54 +01:00
onCheckedChanged: config . setReuseUserPasswordForRoot ( checked )
2020-08-11 13:46:05 +02:00
}
2020-08-25 16:05:56 +02:00
2020-08-11 13:46:05 +02:00
Label {
visible: root . checked
width: parent . width
text: qsTr ( "Use the same password for the administrator account." )
font.weight: Font . Thin
font.pointSize: 8
}
Column {
visible: ! root . checked
Layout.fillWidth: true
spacing: Kirigami . Units . smallSpacing
Label {
width: parent . width
text: qsTr ( "Choose a root password to keep your account safe." )
}
Row {
width: parent . width
spacing: 20
TextField {
id: _rootPasswordField
width: parent . width / 2 - 10
placeholderText: qsTr ( "Root Password" )
2021-03-15 12:36:54 +01:00
text: config . rootPassword
2021-07-03 00:10:31 +02:00
2021-03-15 12:36:54 +01:00
onTextChanged: config . setRootPassword ( text )
2021-07-03 00:10:31 +02:00
2021-07-07 01:56:45 +02:00
palette.base: _rootPasswordField . text . length ? Kirigami.Theme.backgroundColor : Kirigami . Theme . neutralBackgroundColor
palette.highlight : _rootPasswordField . text . length ? Kirigami.Theme.positiveBackgroundColor : Kirigami . Theme . backgroundColor
2021-03-15 12:36:54 +01:00
2020-08-11 13:46:05 +02:00
echoMode: TextInput . Password
passwordMaskDelay: 300
inputMethodHints: Qt . ImhNoAutoUppercase
}
TextField {
id: _verificationRootPasswordField
width: parent . width / 2 - 10
placeholderText: qsTr ( "Repeat Root Password" )
2021-03-15 12:36:54 +01:00
text: config . rootPasswordSecondary
2021-06-30 22:29:32 +02:00
2021-07-03 00:10:31 +02:00
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
2021-07-07 01:56:45 +02:00
? Kirigami.Theme.backgroundColor : Kirigami . Theme . negativeBackgroundColor ) : Kirigami . Theme . backgroundColor
palette.highlight : _verificationRootPasswordField . text . length ? Kirigami.Theme.positiveBackgroundColor : Kirigami . Theme . backgroundColor
2021-03-15 12:36:54 +01:00
2020-08-11 13:46:05 +02:00
echoMode: TextInput . Password
passwordMaskDelay: 300
inputMethodHints: Qt . ImhNoAutoUppercase
}
}
Label {
visible: ! root . checked
width: parent . width
text: qsTr ( "Enter the same password twice, so that it can be checked for typing errors." )
font.weight: Font . Thin
font.pointSize: 8
color: "#6D6D6D"
}
}
2021-06-26 18:14:19 +02:00
2021-06-30 18:29:32 +02:00
Kirigami . InlineMessage {
id: rootPassMessage
Layout.fillWidth: true
2021-07-03 14:23:01 +02:00
showCloseButton: true
2021-06-30 18:29:32 +02:00
visible: false
type: Kirigami . MessageType . Error
2021-07-03 00:10:31 +02:00
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
2021-06-30 18:29:32 +02:00
}
2021-06-26 18:14:19 +02:00
CheckBox {
Layout.alignment: Qt . AlignCenter
text: qsTr ( "Log in automatically without asking for the password" )
checked: config . doAutoLogin
onCheckedChanged: config . setAutoLogin ( checked )
}
CheckBox {
visible: config . permitWeakPasswords
Layout.alignment: Qt . AlignCenter
text: qsTr ( "Validate passwords quality" )
checked: config . requireStrongPasswords
2021-07-03 00:10:31 +02:00
onCheckedChanged: config . setRequireStrongPasswords ( checked ) ,
rootPassMessage . visible = false
2021-06-26 18:14:19 +02:00
}
Label {
visible: config . permitWeakPasswords
width: parent . width
Layout.alignment: Qt . AlignCenter
text: qsTr ( "When this box is checked, password-strength checking is done and you will not be able to use a weak password." )
font.weight: Font . Thin
font.pointSize: 8
}
2020-08-11 13:46:05 +02:00
}
}