For launcher and session, give back focus to previously open one on close Also use execDetached for session buttons
118 lines
2.9 KiB
QML
118 lines
2.9 KiB
QML
pragma ComponentBehavior: Bound
|
|
|
|
import "root:/widgets"
|
|
import "root:/services"
|
|
import "root:/config"
|
|
import Quickshell
|
|
import QtQuick
|
|
|
|
Column {
|
|
id: root
|
|
|
|
required property PersistentProperties visibilities
|
|
|
|
padding: Appearance.padding.large
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
anchors.left: parent.left
|
|
|
|
spacing: Appearance.spacing.large
|
|
|
|
SessionButton {
|
|
id: logout
|
|
|
|
icon: "logout"
|
|
command: ["loginctl", "terminate-user", ""]
|
|
|
|
KeyNavigation.down: shutdown
|
|
|
|
Connections {
|
|
target: root.visibilities
|
|
|
|
function onSessionChanged(): void {
|
|
if (root.visibilities.session)
|
|
logout.focus = true;
|
|
}
|
|
|
|
function onLauncherChanged(): void {
|
|
if (root.visibilities.session && !root.visibilities.launcher)
|
|
logout.focus = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
SessionButton {
|
|
id: shutdown
|
|
|
|
icon: "power_settings_new"
|
|
command: ["systemctl", "poweroff"]
|
|
|
|
KeyNavigation.up: logout
|
|
KeyNavigation.down: hibernate
|
|
}
|
|
|
|
AnimatedImage {
|
|
width: Config.session.sizes.button
|
|
height: Config.session.sizes.button
|
|
sourceSize.width: width
|
|
sourceSize.height: height
|
|
|
|
playing: visible
|
|
asynchronous: true
|
|
speed: 0.7
|
|
source: "root:/assets/kurukuru.gif"
|
|
}
|
|
|
|
SessionButton {
|
|
id: hibernate
|
|
|
|
icon: "downloading"
|
|
command: ["systemctl", "hibernate"]
|
|
|
|
KeyNavigation.up: shutdown
|
|
KeyNavigation.down: reboot
|
|
}
|
|
|
|
SessionButton {
|
|
id: reboot
|
|
|
|
icon: "cached"
|
|
command: ["systemctl", "reboot"]
|
|
|
|
KeyNavigation.up: hibernate
|
|
}
|
|
|
|
component SessionButton: StyledRect {
|
|
id: button
|
|
|
|
required property string icon
|
|
required property list<string> command
|
|
|
|
implicitWidth: Config.session.sizes.button
|
|
implicitHeight: Config.session.sizes.button
|
|
|
|
radius: Appearance.rounding.large
|
|
color: button.activeFocus ? Colours.palette.m3secondaryContainer : Colours.palette.m3surfaceContainer
|
|
|
|
Keys.onEnterPressed: Quickshell.execDetached(button.command)
|
|
Keys.onReturnPressed: Quickshell.execDetached(button.command)
|
|
Keys.onEscapePressed: root.visibilities.session = false
|
|
|
|
StateLayer {
|
|
radius: parent.radius
|
|
color: button.activeFocus ? Colours.palette.m3onSecondaryContainer : Colours.palette.m3onSurface
|
|
|
|
function onClicked(): void {
|
|
Quickshell.execDetached(button.command);
|
|
}
|
|
}
|
|
|
|
MaterialIcon {
|
|
anchors.centerIn: parent
|
|
|
|
text: button.icon
|
|
color: button.activeFocus ? Colours.palette.m3onSecondaryContainer : Colours.palette.m3onSurface
|
|
font.pointSize: Appearance.font.size.extraLarge
|
|
}
|
|
}
|
|
}
|