Warning, /plasma/plasma-workspace/kcms/users/src/ui/CreateUser.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2020 Carson Black <uhhadd@gmail.com> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 import QtQuick 2.15 0008 import QtQuick.Layouts 1.3 0009 import QtQuick.Controls 2.5 as QQC2 0010 0011 import org.kde.kcmutils as KCM 0012 import org.kde.kirigami 2.20 as Kirigami 0013 0014 KCM.SimpleKCM { 0015 title: i18n("Create User") 0016 0017 width: mainColumn.childrenRect.width + (Kirigami.Units.largeSpacing * 10) 0018 height: mainColumn.childrenRect.height + (Kirigami.Units.largeSpacing * 10) 0019 0020 onVisibleChanged: { 0021 realNameField.text = ""; 0022 userNameField.text = ""; 0023 passwordField.text = ""; 0024 verifyField.text = ""; 0025 usertypeBox.currentIndex = 0; 0026 } 0027 Component.onCompleted: realNameField.forceActiveFocus() 0028 0029 Kirigami.FormLayout { 0030 anchors.centerIn: parent 0031 QQC2.TextField { 0032 id: realNameField 0033 Kirigami.FormData.label: i18n("Name:") 0034 } 0035 QQC2.TextField { 0036 id: userNameField 0037 Kirigami.FormData.label: i18n("Username:") 0038 validator: RegularExpressionValidator { 0039 regularExpression: /^[a-z_]([a-z0-9_-]{0,31}|[a-z0-9_-]{0,30}\$)$/ 0040 } 0041 } 0042 QQC2.ComboBox { 0043 id: usertypeBox 0044 0045 textRole: "label" 0046 model: [ 0047 { type: "standard", label: i18n("Standard") }, 0048 { type: "administrator", label: i18n("Administrator") }, 0049 ] 0050 0051 Kirigami.FormData.label: i18n("Account type:") 0052 } 0053 Kirigami.PasswordField { 0054 id: passwordField 0055 onTextChanged: debouncer.reset() 0056 Kirigami.FormData.label: i18n("Password:") 0057 } 0058 Kirigami.PasswordField { 0059 id: verifyField 0060 onTextChanged: debouncer.reset() 0061 Kirigami.FormData.label: i18n("Confirm password:") 0062 } 0063 Kirigami.InlineMessage { 0064 id: passwordWarning 0065 0066 Layout.fillWidth: true 0067 type: Kirigami.MessageType.Error 0068 text: i18n("Passwords must match") 0069 visible: passwordField.text !== "" 0070 && verifyField.text !== "" 0071 && passwordField.text !== verifyField.text 0072 && debouncer.isTriggered 0073 } 0074 Debouncer { 0075 id: debouncer 0076 } 0077 QQC2.Button { 0078 text: i18n("Create") 0079 enabled: !passwordWarning.visible 0080 && realNameField.text !== "" 0081 && userNameField.text !== "" 0082 && passwordField.text !== "" 0083 && verifyField.text !== "" 0084 0085 onClicked: { 0086 if (passwordField.text !== verifyField.text) { 0087 debouncer.isTriggered = true; 0088 return; 0089 } 0090 kcm.mainUi.createUser(userNameField.text, realNameField.text, passwordField.text, (usertypeBox.model[usertypeBox.currentIndex]["type"] === "administrator")); 0091 } 0092 } 0093 } 0094 }