/*Copyright 2020 Carson Black <uhhadd@gmail.com>This library is free software; you can redistribute it and/ormodify it under the terms of the GNU Lesser General PublicLicense as published by the Free Software Foundation; eitherversion 2.1 of the License, or (at your option) version 3, or anylater version accepted by the membership of KDE e.V. (or itssuccessor approved by the membership of KDE e.V.), which shallact as a proxy defined in Section 6 of version 3 of the license.This library is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNULesser General Public License for more details.You should have received a copy of the GNU Lesser General PublicLicense along with this library. If not, see <http://www.gnu.org/licenses/>.*/import QtQuick 2.6import QtQuick.Dialogs 1.1import QtQuick.Layouts 1.3import QtQuick.Controls 2.5 as QQC2import org.kde.kcm 1.2 as KCMimport org.kde.kirigami 2.4 as KirigamiKCM.SimpleKCM {title: i18n("Create User")width: mainColumn.childrenRect.width + (Kirigami.Units.largeSpacing*10)height: mainColumn.childrenRect.height + (Kirigami.Units.largeSpacing*10)onVisibleChanged: {userNameField.text = realNameField.text = verifyField.text = passwordField.text = ""usertypeBox.currentIndex = 0}Kirigami.FormLayout {anchors.centerIn: parentQQC2.TextField {id: realNameFieldKirigami.FormData.label: i18n("Name:")Component.onCompleted: realNameField.forceActiveFocus()}QQC2.TextField {id: userNameFieldKirigami.FormData.label: i18n("Username:")validator: RegExpValidator {regExp: /^[a-z_]([a-z0-9_-]{0,31}|[a-z0-9_-]{0,30}\$)$/}}QQC2.ComboBox {id: usertypeBoxtextRole: "label"model: [{ "type": "standard", "label": i18n("Standard") },{ "type": "administrator", "label": i18n("Administrator") },]Kirigami.FormData.label: i18n("Account type:")}QQC2.TextField {id: passwordFieldechoMode: TextInput.PasswordKirigami.FormData.label: i18n("Password:")}QQC2.TextField {id: verifyFieldechoMode: TextInput.PasswordKirigami.FormData.label: i18n("Confirm password:")}Kirigami.InlineMessage {id: passwordWarningLayout.fillWidth: truetype: Kirigami.MessageType.Errortext: i18n("Passwords must match")visible: passwordField.text != "" && verifyField.text != "" && passwordField.text != verifyField.text}QQC2.Button {text: i18n("Create")enabled: !passwordWarning.visible && verifyField.text && passwordField.text && realNameField.text && userNameField.textonClicked: {if (kcm.createUser(userNameField.text, realNameField.text, passwordField.text, (usertypeBox.model[usertypeBox.currentIndex]["type"] == "administrator"))) {kcm.pop()}}}}}