Warning, /plasma/plasma-workspace/lookandfeel/components/UserList.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2014 David Edmundson <davidedmundson@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 import QtQuick 2.15 0008 0009 import org.kde.kirigami 2.20 as Kirigami 0010 0011 /* 0012 * A model with a list of users to show in the view. 0013 * There are different implementations in sddm greeter (UserModel) and 0014 * KScreenLocker (SessionsModel), so some roles will be missing. 0015 * 0016 * type: { 0017 * name: string, 0018 * realName: string, 0019 * homeDir: string, 0020 * icon: string, 0021 * iconName?: string, 0022 * needsPassword?: bool, 0023 * displayNumber?: string, 0024 * vtNumber?: int, 0025 * session?: string 0026 * isTty?: bool, 0027 * } 0028 */ 0029 ListView { 0030 id: view 0031 readonly property string selectedUser: currentItem ? currentItem.userName : "" 0032 readonly property int userItemWidth: Kirigami.Units.gridUnit * 8 0033 readonly property int userItemHeight: Kirigami.Units.gridUnit * 9 0034 readonly property bool constrainText: count > 1 0035 property int fontSize: Kirigami.Theme.defaultFont.pointSize + 2 0036 0037 implicitHeight: userItemHeight 0038 0039 activeFocusOnTab: true 0040 0041 /* 0042 * Signals that a user was explicitly selected 0043 */ 0044 signal userSelected() 0045 0046 orientation: ListView.Horizontal 0047 highlightRangeMode: ListView.StrictlyEnforceRange 0048 0049 //centre align selected item (which implicitly centre aligns the rest 0050 preferredHighlightBegin: width/2 - userItemWidth/2 0051 preferredHighlightEnd: preferredHighlightBegin 0052 0053 // Disable flicking if we only have on user (like on the lockscreen) 0054 interactive: count > 1 0055 0056 delegate: UserDelegate { 0057 avatarPath: model.icon || "" 0058 iconSource: model.iconName || "user-identity" 0059 fontSize: view.fontSize 0060 needsPassword: model.needsPassword !== undefined ? model.needsPassword : true 0061 vtNumber: model.vtNumber 0062 0063 name: { 0064 const displayName = model.realName || model.name 0065 0066 if (model.vtNumber === undefined || model.vtNumber < 0) { 0067 return displayName 0068 } 0069 0070 if (!model.session) { 0071 return i18ndc("plasma_lookandfeel_org.kde.lookandfeel", "Nobody logged in on that session", "Unused") 0072 } 0073 0074 0075 let location = undefined 0076 if (model.isTty) { 0077 location = i18ndc("plasma_lookandfeel_org.kde.lookandfeel", "User logged in on console number", "TTY %1", model.vtNumber) 0078 } else if (model.displayNumber) { 0079 location = i18ndc("plasma_lookandfeel_org.kde.lookandfeel", "User logged in on console (X display number)", "on TTY %1 (Display %2)", model.vtNumber, model.displayNumber) 0080 } 0081 0082 if (location !== undefined) { 0083 return i18ndc("plasma_lookandfeel_org.kde.lookandfeel", "Username (location)", "%1 (%2)", displayName, location) 0084 } 0085 0086 return displayName 0087 } 0088 0089 userName: model.name 0090 0091 width: userItemWidth 0092 height: userItemHeight 0093 0094 //if we only have one delegate, we don't need to clip the text as it won't be overlapping with anything 0095 constrainText: view.constrainText 0096 0097 isCurrent: ListView.isCurrentItem 0098 0099 onClicked: { 0100 ListView.view.currentIndex = index; 0101 ListView.view.userSelected(); 0102 } 0103 } 0104 0105 Keys.onEscapePressed: view.userSelected() 0106 Keys.onEnterPressed: view.userSelected() 0107 Keys.onReturnPressed: view.userSelected() 0108 }