Warning, /plasma/plasma-workspace/kcms/users/src/ui/UserDetailsPage.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2019 Nicolas Fella <nicolas.fella@gmx.de> 0003 SPDX-FileCopyrightText: 2020 Carson Black <uhhadd@gmail.com> 0004 0005 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0006 */ 0007 0008 import QtQuick 2.6 0009 import QtQuick.Layouts 1.3 0010 import QtQuick.Controls 2.5 as QQC2 0011 0012 import org.kde.kirigami 2.13 as Kirigami 0013 import org.kde.kirigamiaddons.components 1.0 as KirigamiComponents 0014 import org.kde.kcmutils as KCM 0015 import org.kde.plasma.kcm.users 1.0 as UsersKCM 0016 0017 KCM.SimpleKCM { 0018 id: usersDetailPage 0019 0020 title: user.displayPrimaryName 0021 0022 property UsersKCM.User user 0023 property bool overrideImage: false 0024 property url oldImage 0025 0026 implicitWidth: Kirigami.Units.gridUnit * 30 0027 implicitHeight: Kirigami.Units.gridUnit * 27 0028 focus: true 0029 0030 Connections { 0031 target: user 0032 function onApplyError(errorText) { 0033 errorMessage.visible = true 0034 errorMessage.text = errorText 0035 } 0036 } 0037 0038 Connections { 0039 target: user 0040 function onPasswordSuccessfullyChanged() { 0041 // Prompt to change the wallet password of the logged-in user 0042 if (usersDetailPage.user.loggedIn && usersDetailPage.user.usesDefaultWallet()) { 0043 changeWalletPassword.open() 0044 } 0045 } 0046 } 0047 0048 Connections { 0049 target: kcm 0050 0051 function onApply() { 0052 errorMessage.visible = false 0053 usersDetailPage.user.realName = realNametextField.text 0054 usersDetailPage.user.email = emailTextField.text 0055 usersDetailPage.user.name = userNameField.text 0056 usersDetailPage.user.administrator = (usertypeBox.model[usertypeBox.currentIndex]["type"] == "administrator") 0057 user.apply() 0058 usersDetailPage.overrideImage = false 0059 usersDetailPage.oldImage = "" 0060 } 0061 0062 function onReset() { 0063 errorMessage.visible = false 0064 realNametextField.text = usersDetailPage.user.realName 0065 emailTextField.text = usersDetailPage.user.email 0066 userNameField.text = usersDetailPage.user.name 0067 usertypeBox.currentIndex = usersDetailPage.user.administrator ? 1 : 0 0068 if (usersDetailPage.oldImage != "") { 0069 usersDetailPage.overrideImage = false 0070 usersDetailPage.user.face = usersDetailPage.oldImage 0071 } 0072 } 0073 } 0074 0075 function resolvePending() { 0076 let pending = false 0077 let user = usersDetailPage.user 0078 pending = pending || user.realName != realNametextField.text 0079 pending = pending || user.email != emailTextField.text 0080 pending = pending || user.name != userNameField.text 0081 pending = pending || user.administrator != (usertypeBox.model[usertypeBox.currentIndex]["type"] == "administrator") 0082 pending = pending || usersDetailPage.overrideImage 0083 return pending 0084 } 0085 0086 Component.onCompleted: { 0087 kcm.needsSave = Qt.binding(resolvePending) 0088 } 0089 0090 ColumnLayout { 0091 Kirigami.InlineMessage { 0092 id: errorMessage 0093 visible: false 0094 type: Kirigami.MessageType.Error 0095 Layout.fillWidth: true 0096 } 0097 0098 KirigamiComponents.AvatarButton { 0099 readonly property int size: 6 * Kirigami.Units.gridUnit 0100 0101 Layout.preferredWidth: size 0102 Layout.preferredHeight: size 0103 Layout.alignment: Qt.AlignHCenter 0104 Layout.topMargin: Kirigami.Units.largeSpacing 0105 0106 source: usersDetailPage.user.face 0107 cache: false 0108 name: user.realName 0109 0110 focus: true 0111 text: i18n("Change avatar") 0112 0113 KeyNavigation.down: realNametextField 0114 0115 onClicked: { 0116 const component = Qt.createComponent("PicturesSheet.qml") 0117 const obj = component.incubateObject(usersDetailPage, { 0118 focus: true, 0119 usersDetailPage: usersDetailPage 0120 }) 0121 if (obj == null) { 0122 console.log(component.errorString()) 0123 } 0124 component.destroy() 0125 } 0126 } 0127 0128 Kirigami.FormLayout { 0129 QQC2.TextField { 0130 id: realNametextField 0131 text: user.realName 0132 Kirigami.FormData.label: i18n("Name:") 0133 0134 KeyNavigation.down: userNameField 0135 } 0136 0137 QQC2.TextField { 0138 id: userNameField 0139 text: user.name 0140 Kirigami.FormData.label: i18n("Username:") 0141 0142 KeyNavigation.down: usertypeBox 0143 } 0144 0145 QQC2.ComboBox { 0146 id: usertypeBox 0147 0148 textRole: "label" 0149 model: [ 0150 { "type": "standard", "label": i18n("Standard") }, 0151 { "type": "administrator", "label": i18n("Administrator") }, 0152 ] 0153 0154 Kirigami.FormData.label: i18n("Account type:") 0155 0156 currentIndex: user.administrator ? 1 : 0 0157 0158 KeyNavigation.down: emailTextField 0159 } 0160 0161 QQC2.TextField { 0162 id: emailTextField 0163 text: user.email 0164 Kirigami.FormData.label: i18n("Email address:") 0165 KeyNavigation.down: changeButton 0166 } 0167 0168 QQC2.Button { 0169 id: changeButton 0170 text: i18n("Change Password") 0171 KeyNavigation.down: deleteUser.enabled ? deleteUser : fingerprintButton 0172 onClicked: { 0173 changePassword.user = user 0174 changePassword.openAndClear() 0175 } 0176 } 0177 0178 Item { 0179 Layout.preferredHeight: deleteUser.height 0180 } 0181 0182 QQC2.Button { 0183 id: deleteUser 0184 0185 enabled: !usersDetailPage.user.loggedIn && (!kcm.userModel.rowCount() < 2) 0186 0187 KeyNavigation.down: fingerprintButton 0188 0189 QQC2.Menu { 0190 id: deleteMenu 0191 modal: true 0192 QQC2.MenuItem { 0193 text: i18n("Delete files") 0194 icon.name: "edit-delete-shred" 0195 onClicked: { 0196 kcm.mainUi.deleteUser(usersDetailPage.user.uid, true) 0197 } 0198 } 0199 QQC2.MenuItem { 0200 text: i18n("Keep files") 0201 icon.name: "document-multiple" 0202 onClicked: { 0203 kcm.mainUi.deleteUser(usersDetailPage.user.uid, false) 0204 } 0205 } 0206 } 0207 text: i18n("Delete User…") 0208 icon.name: "edit-delete" 0209 onClicked: deleteMenu.open() 0210 } 0211 } 0212 0213 QQC2.Button { 0214 id: fingerprintButton 0215 Layout.topMargin: deleteUser.height 0216 Layout.alignment: Qt.AlignHCenter 0217 flat: false 0218 visible: kcm.fingerprintModel.deviceFound 0219 text: i18n("Configure Fingerprint Authentication…") 0220 icon.name: "fingerprint-gui" 0221 0222 property Kirigami.OverlaySheet dialog: null 0223 0224 onClicked: { 0225 if (kcm.fingerprintModel.currentlyEnrolling) { 0226 kcm.fingerprintModel.stopEnrolling(); 0227 } 0228 kcm.fingerprintModel.switchUser(user.name == kcm.userModel.getLoggedInUser().name ? "" : user.name); 0229 0230 if (fingerprintButton.dialog === null) { 0231 const component = Qt.createComponent("FingerprintDialog.qml"); 0232 component.incubateObject(usersDetailPage, { 0233 focus: true, 0234 }); 0235 component.destroy(); 0236 } else { 0237 fingerprintButton.dialog.open() 0238 } 0239 } 0240 } 0241 QQC2.Label { 0242 Layout.fillWidth: true 0243 Layout.leftMargin: Kirigami.Units.largeSpacing * 2 0244 Layout.rightMargin: Kirigami.Units.largeSpacing * 2 0245 0246 visible: kcm.fingerprintModel.deviceFound 0247 0248 text: xi18nc("@info", "Fingerprints can be used in place of a password when unlocking the screen and providing administrator permissions to applications and command-line programs that request them.<nl/><nl/>Logging into the system with your fingerprint is not yet supported.") 0249 textFormat: Text.StyledText 0250 0251 font: Kirigami.Theme.smallFont 0252 wrapMode: Text.Wrap 0253 } 0254 } 0255 0256 ChangePassword { id: changePassword } 0257 ChangeWalletPassword { id: changeWalletPassword } 0258 }