Verified Commit 83d8d137 authored by Fushan Wen's avatar Fushan Wen 💬
Browse files

applets/userswitcher: add keyboard navigation support

This adds support for Up/Down/Tab/BackTab keys.
parent 3745bd53
Pipeline #212315 passed with stage
in 1 minute and 23 seconds
......@@ -19,9 +19,14 @@ PlasmaComponents3.ItemDelegate {
property alias subText: sublabel.text
property alias iconItem: iconItem.children
highlighted: hovered || activeFocus
highlighted: activeFocus
// sizing: top-down explicit width, bottom-up implicit height
onHoveredChanged: if (hovered) {
if (ListView.view) {
ListView.view.currentIndex = index;
}
forceActiveFocus();
}
contentItem: RowLayout {
id: row
......
......@@ -168,7 +168,6 @@ Item {
width: ListView.view.width
activeFocusOnTab: true
highlighted: ListView.view.isCurrentItem || hovered || activeFocus
text: {
if (!model.session) {
......@@ -195,6 +194,9 @@ Item {
return ""
}
KeyNavigation.up: index === 0 ? currentUserItem.nextItemInFocusChain() : userList.itemAtIndex(index - 1)
KeyNavigation.down: index === userList.count - 1 ? newSessionButton : userList.itemAtIndex(index + 1)
onClicked: sessionsModel.switchUser(model.vtNumber, sessionsModel.shouldLock)
}
}
......@@ -205,6 +207,10 @@ Item {
text: i18nc("@action", "New Session")
icon.name: "system-switch-user"
visible: sessionsModel.canStartNewSession
KeyNavigation.up: userList.count > 0 ? userList.itemAtIndex(userList.count - 1) : currentUserItem.nextItemInFocusChain()
KeyNavigation.down: lockScreenButton
onClicked: sessionsModel.startNewSession(sessionsModel.shouldLock)
}
......@@ -213,6 +219,10 @@ Item {
text: i18nc("@action", "Lock Screen")
icon.name: "system-lock-screen"
visible: pmEngine.data["Sleep States"]["LockScreen"]
KeyNavigation.up: newSessionButton
KeyNavigation.down: leaveButton
onClicked: pmEngine.performOperation("lockScreen")
}
......@@ -220,6 +230,9 @@ Item {
id: leaveButton
text: i18nc("Show a dialog with options to logout/shutdown/restart", "Leave…")
icon.name: "system-shutdown"
KeyNavigation.up: lockScreenButton
onClicked: pmEngine.performOperation("requestShutDown")
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment