nosignal-shell/modules/lock/Buttons.qml
Joel R. 7dc5b65d22
session: add custom session/lock menu button commands (#292)
* session: add custom menu-buttons commands

* lock: use custom session-menu buttons

* readme: update config options for custom commands
2025-07-29 12:45:33 +10:00

109 lines
2.8 KiB
QML

pragma ComponentBehavior: Bound
import qs.widgets
import qs.services
import qs.config
import Quickshell
import QtQuick
import QtQuick.Layouts
Item {
id: root
readonly property real nonAnimMargin: handler.hovered ? Appearance.padding.large * 1.5 : Appearance.padding.large
readonly property real nonAnimWidth: handler.hovered ? Config.lock.sizes.buttonsWidth : Config.lock.sizes.buttonsWidthSmall
readonly property real nonAnimHeight: (nonAnimWidth + nonAnimMargin * 2) / 4
implicitWidth: nonAnimWidth
implicitHeight: nonAnimHeight
Behavior on implicitWidth {
NumberAnimation {
duration: Appearance.anim.durations.large
easing.type: Easing.BezierSpline
easing.bezierCurve: Appearance.anim.curves.emphasized
}
}
Behavior on implicitHeight {
NumberAnimation {
duration: Appearance.anim.durations.large
easing.type: Easing.BezierSpline
easing.bezierCurve: Appearance.anim.curves.emphasized
}
}
HoverHandler {
id: handler
target: parent
}
RowLayout {
id: layout
anchors.fill: parent
anchors.margins: root.nonAnimMargin
anchors.rightMargin: 0
anchors.bottomMargin: 0
spacing: Appearance.spacing.normal
SessionButton {
icon: "logout"
command: Config.session.commands.logout
}
SessionButton {
icon: "power_settings_new"
command: Config.session.commands.shutdown
}
SessionButton {
icon: "downloading"
command: Config.session.commands.hibernate
}
SessionButton {
icon: "cached"
command: Config.session.commands.reboot
}
Behavior on anchors.margins {
NumberAnimation {
duration: Appearance.anim.durations.large
easing.type: Easing.BezierSpline
easing.bezierCurve: Appearance.anim.curves.emphasized
}
}
}
component SessionButton: StyledRect {
required property string icon
required property list<string> command
Layout.fillWidth: true
Layout.preferredHeight: width
radius: Appearance.rounding.large * 1.2
color: Colours.palette.m3secondaryContainer
StateLayer {
id: stateLayer
color: Colours.palette.m3onSecondaryContainer
function onClicked(): void {
Quickshell.execDetached(parent.command);
}
}
MaterialIcon {
anchors.centerIn: parent
text: parent.icon
color: Colours.palette.m3onSecondaryContainer
font.pointSize: (parent.width * 0.4) || 1
font.weight: handler.hovered ? 500 : 400
}
}
}