Warning, /plasma/kscreenlocker/greeter/fallbacktheme/SessionSwitching.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2011 Martin Gräßlin <mgraesslin@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 import QtQuick 2.15 0008 0009 import org.kde.plasma.components 2.0 as PlasmaComponents 0010 import org.kde.plasma.extras 2.0 as PlasmaExtras 0011 0012 Item { 0013 readonly property bool switchUserSupported: sessionsModel.canSwitchUser 0014 0015 signal sessionActivated() 0016 signal newSessionStarted() 0017 signal switchingCanceled() 0018 0019 implicitWidth: theme.mSize(theme.defaultFont).width * 55 0020 implicitHeight: theme.mSize(theme.defaultFont).height * 25 0021 0022 anchors { 0023 fill: parent 0024 margins: 6 0025 } 0026 0027 PlasmaExtras.ScrollArea { 0028 anchors { 0029 left: parent.left 0030 right: parent.right 0031 bottom: buttonRow.top 0032 bottomMargin: 5 0033 } 0034 height: parent.height - explainText.implicitHeight - buttonRow.height - 10 0035 0036 ListView { 0037 id: userSessionsView 0038 0039 model: sessionsModel 0040 anchors.fill: parent 0041 0042 delegate: PlasmaComponents.ListItem { 0043 readonly property int userVt: model.vtNumber 0044 0045 content: PlasmaComponents.Label { 0046 text: { 0047 var display = model.isTty ? i18ndc("kscreenlocker_greet", "User logged in on console", "TTY") : model.displayNumber || "" 0048 0049 return i18ndc("kscreenlocker_greet", "username (terminal, display)", "%1 (%2)", 0050 (model.realName || model.name || i18ndc("kscreenlocker_greet", "Nobody logged in", "Unused")), 0051 display ? i18ndc("kscreenlocker_greet", "vt, display", "%1, %2", model.vtNumber, display) 0052 : model.vtNumber 0053 ) 0054 } 0055 } 0056 } 0057 highlight: PlasmaComponents.Highlight { 0058 hover: true 0059 width: parent.width 0060 } 0061 focus: true 0062 0063 MouseArea { 0064 anchors.fill: parent 0065 onClicked: userSessionsView.currentIndex = userSessionsView.indexAt(mouse.x, mouse.y) 0066 onDoubleClicked: { 0067 sessionsModel.switchUser(userSessionsView.indexAt(mouse.x, mouse.y).userVt) 0068 sessionActivated(); 0069 } 0070 } 0071 } 0072 } 0073 0074 PlasmaComponents.Label { 0075 id: explainText 0076 text: i18nd("kscreenlocker_greet", "The current session will be hidden " + 0077 "and a new login screen or an existing session will be displayed.\n" + 0078 "An F-key is assigned to each session; " + 0079 "F%1 is usually assigned to the first session, " + 0080 "F%2 to the second session and so on. " + 0081 "You can switch between sessions by pressing " + 0082 "Ctrl, Alt and the appropriate F-key at the same time. " + 0083 "Additionally, the KDE Panel and Desktop menus have " + 0084 "actions for switching between sessions.", 0085 7, 8) 0086 wrapMode: Text.Wrap 0087 anchors { 0088 top: parent.top 0089 left: parent.left 0090 right: parent.right 0091 } 0092 } 0093 PlasmaComponents.ButtonRow { 0094 id: buttonRow 0095 exclusive: false 0096 spacing: theme.mSize(theme.defaultFont).width / 2 0097 property bool showAccel: false 0098 0099 AccelButton { 0100 id: activateSession 0101 label: i18nd("kscreenlocker_greet", "Activate") 0102 iconSource: "fork" 0103 onClicked: { 0104 sessionsModel.switchUser(userSessionsView.currentItem.userVt) 0105 sessionActivated(); 0106 } 0107 } 0108 AccelButton { 0109 id: newSession 0110 label: i18nd("kscreenlocker_greet", "Start New Session") 0111 iconSource: "fork" 0112 visible: sessionsModel.canStartNewSession 0113 onClicked: { 0114 sessionsModel.startNewSession() 0115 newSessionStarted(); 0116 } 0117 } 0118 AccelButton { 0119 id: cancelSession 0120 label: i18nd("kscreenlocker_greet", "Cancel") 0121 iconSource: "dialog-cancel" 0122 onClicked: switchingCanceled() 0123 } 0124 anchors.bottom: parent.bottom 0125 anchors.horizontalCenter: userSessionsUI.horizontalCenter 0126 } 0127 0128 Keys.onPressed: { 0129 const alt = event.modifiers & Qt.AltModifier; 0130 buttonRow.showAccel = alt; 0131 0132 if (alt) { 0133 const buttons = [activateSession, newSession, cancelSession]; 0134 for (let b = 0; b < buttons.length; ++b) { 0135 if (event.key == buttons[b].accelKey) { 0136 buttonRow.showAccel = false; 0137 buttons[b].clicked(); 0138 break; 0139 } 0140 } 0141 } 0142 } 0143 0144 Keys.onReleased: { 0145 buttonRow.showAccel = event.modifiers & Qt.AltModifier; 0146 } 0147 }