-
Notifications
You must be signed in to change notification settings - Fork 53
feat(lockscreen): add power actions to shutdown view #1417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
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 | ||
|
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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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, Triggers: When one or more power capabilities are unavailable or 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 | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.