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
13 changes: 11 additions & 2 deletions src/plugins/lockscreen/qml/ControlAction.qml
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,20 @@ RowLayout {
x: 0
y: rootItem.height / 5 * 2
modal: true
contentItem: PowerList { }
contentItem: PowerList {
id: innerPowerList
}
background: MouseArea {
onClicked: powerItem.closePopup()
}
onClosed: powerItem.expand = false
onOpened: {
innerPowerList.focusPowerOff()
innerPowerList.enableLoopInside()
}
onClosed: {
innerPowerList.loopInside = false
powerItem.expand = false
}
}
onClicked: {
powerItem.expand = true
Expand Down
52 changes: 51 additions & 1 deletion src/plugins/lockscreen/qml/PowerList.qml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,26 @@ FocusScope {
property alias modelChildren: objModel.children
property alias leftModelChildren: leftObjeModel.children

property alias listPowerOffBtn: powerOffBtn
property alias listHibernateBtn: hibernateBtn

property bool loopInside: false

signal tabOutForward()
signal tabOutBackward()

implicitWidth: layout.width
implicitHeight: layout.height

function focusPowerOff() {
powerOffBtn.forceActiveFocus()
}
function focusHibernate() {
hibernateBtn.forceActiveFocus()
}
Comment thread
wineee marked this conversation as resolved.
function enableLoopInside() {
loopInside = true
}
RowLayout {
id: layout
spacing: 100
Expand All @@ -30,36 +47,69 @@ FocusScope {
id: objModel

ShutdownButton {
id: powerOff
id: powerOffBtn
enabled: GreeterProxy.canPowerOff
text: qsTr("Shut Down")
icon.name: "login_shutdown"
onClicked: GreeterProxy.powerOff()
KeyNavigation.tab: rebootBtn
KeyNavigation.backtab: hibernateBtn
Keys.onBacktabPressed :function(event) {
if(root.loopInside)
{
Comment on lines +55 to +59
event.accepted = false
}
else
{
root.tabOutBackward()
event.accepted = true
}
}
}

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: powerOffBtn
KeyNavigation.backtab: suspendBtn
Keys.onTabPressed :function(event) {
if(root.loopInside)
{
event.accepted = false
}
else
{
root.tabOutForward()
event.accepted = true
}
}
}
}
}
Expand Down
24 changes: 16 additions & 8 deletions src/plugins/lockscreen/qml/ShutdownButton.qml
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,18 @@ D.Button {
RoundBlur {
anchors.fill: parent
radius: btn.width / 2
color: root.D.ColorSelector.backgroundColor
color: root.activeFocus && !root.hovered && !root.pressed
? Qt.rgba(1.0, 1.0, 1.0, 0.2)
: root.D.ColorSelector.backgroundColor
}
D.OutsideBoxBorder {
anchors.fill: parent
visible: root.pressed
borderWidth: 3
visible: root.activeFocus || root.pressed
borderWidth: root.activeFocus ? 2 : 3
radius: width / 2
color: Qt.rgba(1.0, 1.0, 1.0, 0.3)
color: root.activeFocus
? "#FFFFFF"
: Qt.rgba(1.0, 1.0, 1.0, 0.3)
}
}
}
Expand All @@ -73,18 +77,22 @@ D.Button {
color: root.D.ColorSelector.textColor

background: Item {
visible: root.pressed || root.hovered
visible: root.activeFocus || root.hovered || root.pressed
RoundBlur {
anchors.fill: parent
radius: 6
color: root.D.ColorSelector.backgroundColor
color: root.activeFocus && !root.hovered && !root.pressed
? Qt.rgba(1.0, 1.0, 1.0, 0.2)
: root.D.ColorSelector.backgroundColor
}
D.OutsideBoxBorder {
visible: root.pressed
visible: root.activeFocus || root.pressed
anchors.fill: parent
borderWidth: 2
radius: 6
color: Qt.rgba(1.0, 1.0, 1.0, 0.3)
color: root.activeFocus
? "#FFFFFF"
: Qt.rgba(1.0, 1.0, 1.0, 0.3)
}
}
}
Expand Down
17 changes: 17 additions & 0 deletions src/plugins/lockscreen/qml/ShutdownView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ FocusScope {
id: root

signal switchUser()
Component.onCompleted: {
lockBtn.forceActiveFocus()
}
Comment on lines +12 to +14

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

锁屏状态打开关机界面时,只会创建PowerList,不会创建ShutdownView(ShutdownView包含一个PowerList和三个单独的按钮),不会被抢焦点,见ControlAction.qml中修改部分



MouseArea {
anchors.fill: parent
Expand All @@ -17,6 +21,10 @@ FocusScope {
}

PowerList {
id:powerList
onTabOutForward: lockBtn.forceActiveFocus()
onTabOutBackward: logoutBtn.forceActiveFocus()
Comment on lines +24 to +26

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

跟上面哪个一样,已锁定状态下不会加载ShutdownView这个界面,不会出现焦点推送到不可见对象的情况。


width: parent.width
height: 140
anchors {
Expand All @@ -27,23 +35,32 @@ FocusScope {

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
}
]
}
Expand Down
Loading