Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/plugins/lockscreen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ qt_add_qml_module(lockscreen
qml/Greeter.qml
qml/LockView.qml
qml/LoginView.qml
qml/PowerList.qml
qml/RoundBlur.qml
qml/ShutdownButton.qml
qml/TimeDateWidget.qml
Expand Down
28 changes: 6 additions & 22 deletions src/plugins/lockscreen/qml/ControlAction.qml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RowLayout {

required property Item rootItem
property int buttonSize: 30
property bool powerVisible: powerList.visible
property bool powerVisible: powerShutdownView.visible

signal otherUserRequested()

Expand Down Expand Up @@ -79,36 +79,20 @@ RowLayout {
text: qsTr("Power")
}

Item {
id: powerList
ShutdownView {
id: powerShutdownView
parent: rootItem
visible: powerItem.expand
width: rootItem.width
height: rootItem.height
x: 0
y: 0

// Click outside the PowerList to close
MouseArea {
anchors.fill: parent
onClicked: {
powerItem.expand = false
innerPowerList.loopInside = false
}
}

PowerList {
id: innerPowerList
width: rootItem.width
height: 140
x: 0
y: rootItem.height / 5 * 2
}
onOutsideClicked: powerItem.expand = false
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
onSwitchUser: bottomGroup.otherUserRequested()
}
onClicked: {
powerItem.expand = true
innerPowerList.focusPowerOff()
innerPowerList.enableLoopInside()
powerShutdownView.focusFirstButton()
}
}

Expand Down
1 change: 1 addition & 0 deletions src/plugins/lockscreen/qml/LoginView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ FocusScope {
onSwitchUser: {
root.switchUser()
}
onOutsideClicked: GreeterProxy.showShutdownView = false
}
}

Expand Down
113 changes: 0 additions & 113 deletions src/plugins/lockscreen/qml/PowerList.qml

This file was deleted.

130 changes: 91 additions & 39 deletions src/plugins/lockscreen/qml/ShutdownView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -4,63 +4,115 @@
import QtQuick
import Treeland
import QtQuick.Controls
import QtQuick.Layouts

FocusScope {
id: root

signal switchUser()
signal outsideClicked()

Component.onCompleted: {
lockBtn.forceActiveFocus()
if (root.visible) {
focusFirstButton()
}
}

function focusFirstButton() {
const buttons = GreeterProxy.isLocked
? [powerOffBtn, rebootBtn, suspendBtn, hibernateBtn]
: [lockBtn, switchBtn, logoutBtn]
for (let btn of buttons) {
if (btn.visible && btn.enabled) {
btn.forceActiveFocus()
return
}
}
}

MouseArea {
anchors.fill: parent
enabled: true
onClicked: GreeterProxy.showShutdownView = false
onClicked: root.outsideClicked()
}

PowerList {
id: powerList
onTabOutForward: lockBtn.forceActiveFocus()
onTabOutBackward: logoutBtn.forceActiveFocus()
width: parent.width
height: 140
RowLayout {
id: layout
spacing: 100
anchors {
top: parent.top
topMargin: parent.height / 5 * 2
horizontalCenter: parent.horizontalCenter
}

modelChildren: [
ShutdownButton {
id: lockBtn
visible: !GreeterProxy.isLocked
text: qsTr("lock")
icon.name: "login_lock"
onClicked: GreeterProxy.lock()
KeyNavigation.tab: switchBtn
KeyNavigation.backtab: powerList.listHibernateBtn
},
ShutdownButton {
id: switchBtn
visible: !GreeterProxy.isLocked
text: qsTr("switch user")
icon.name: "login_switchuser"
enabled: UserModel.count > 1
onClicked: root.switchUser()
KeyNavigation.tab: logoutBtn
KeyNavigation.backtab: lockBtn
},
ShutdownButton {
id: logoutBtn
visible: !GreeterProxy.isLocked
text: qsTr("Logout")
icon.name: "login_logout"
onClicked: GreeterProxy.logout()
KeyNavigation.tab: powerList.listPowerOffBtn
KeyNavigation.backtab: switchBtn
}
]
ShutdownButton {
id: powerOffBtn
enabled: GreeterProxy.canPowerOff
text: qsTr("Shut Down")
icon.name: "login_shutdown"
onClicked: GreeterProxy.powerOff()
KeyNavigation.tab: rebootBtn
KeyNavigation.backtab: logoutBtn
Comment thread
gugullll marked this conversation as resolved.
}

ShutdownButton {
id: rebootBtn
enabled: GreeterProxy.canReboot
text: qsTr("Reboot")
icon.name: "login_reboot"
onClicked: GreeterProxy.reboot()
KeyNavigation.tab: suspendBtn
KeyNavigation.backtab: powerOffBtn
}

ShutdownButton {
id: suspendBtn
enabled: GreeterProxy.canSuspend
text: qsTr("Suspend")
icon.name: "login_suspend"
onClicked: GreeterProxy.suspend()
KeyNavigation.tab: hibernateBtn
KeyNavigation.backtab: rebootBtn
}

ShutdownButton {
id: hibernateBtn
enabled: GreeterProxy.canHibernate
text: qsTr("Hibernate")
icon.name: "login_hibernate"
onClicked: GreeterProxy.hibernate()
KeyNavigation.tab: lockBtn
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
KeyNavigation.backtab: suspendBtn
}

ShutdownButton {
id: lockBtn
visible: !GreeterProxy.isLocked
text: qsTr("lock")
icon.name: "login_lock"
onClicked: GreeterProxy.lock()
KeyNavigation.tab: switchBtn
KeyNavigation.backtab: hibernateBtn
}

ShutdownButton {
id: switchBtn
visible: !GreeterProxy.isLocked
text: qsTr("switch user")
icon.name: "login_switchuser"
enabled: UserModel.count > 1
onClicked: root.switchUser()
KeyNavigation.tab: logoutBtn
KeyNavigation.backtab: lockBtn
}

ShutdownButton {
id: logoutBtn
visible: !GreeterProxy.isLocked
text: qsTr("Logout")
icon.name: "login_logout"
onClicked: GreeterProxy.logout()
KeyNavigation.tab: powerOffBtn
Comment on lines +53 to +114

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): Keyboard navigation points directly to buttons that are hidden when disabled or when the lock state changes, so Tab or Backtab stops instead of moving to the next available action. For example, when switching users is unavailable, lockBtn navigates to the invisible switchBtn rather than logoutBtn, and logoutBtn navigates to the potentially invisible powerOffBtn.

Triggers: When one or more power capabilities are unavailable or UserModel.count is less than two.

Suggested fix: Update the tab and backtab targets dynamically, or implement navigation that searches for the next visible and enabled button before assigning focus.

KeyNavigation.backtab: switchBtn
}
}
}
Loading
Loading