various tweaks, bw->kpxc temporarily

This commit is contained in:
atagen 2025-09-09 08:05:23 +10:00
parent e06ce60bfe
commit 6b2b079a18
15 changed files with 180 additions and 157 deletions

View file

@ -11,13 +11,16 @@ Singleton {
required property real width
required property real height
property real openTime: 600
default property list<LogoutButton> buttons
Timer {
id: closeTimer
interval: topLevel.openTime
running: false
repeat: false
onTriggered: logoutData.active = false
onTriggered: {
logoutData.active = false;
}
}
PersistentProperties {
@ -25,32 +28,7 @@ Singleton {
property bool open: false
property bool active: false
property real openness: 0
property var buttons: [
{
name: "Logout",
icon: "",
key: "e",
action: ["loginctl", "terminate-user", "1000"]
},
{
name: "Suspend",
icon: "",
key: "s",
action: ["systemctl", "suspend"]
},
{
name: "Shutdown",
icon: "",
key: "d",
action: ["systemctl", "poweroff"]
},
{
name: "Reboot",
icon: "",
key: "r",
action: ["systemctl", "reboot"]
}
]
property int selected: -1
onOpenChanged: {
if (open) {
@ -103,12 +81,28 @@ Singleton {
keyboardFocus: WlrKeyboardFocus.Exclusive
focusable: true
exclusionMode: ExclusionMode.Ignore
Item {
contentItem {
focus: true
Keys.onPressed: event => {
console.log(event);
if (event.key == Qt.Key_Escape) {
logoutData.open = false;
} else {
for (let i = 0; i < topLevel.buttons.length; ++i) {
let button = topLevel.buttons[i];
if (event.key == button.keybind) {
logoutData.open = false;
button.exec();
}
}
}
}
}
MouseArea {
anchors.fill: parent
onClicked: logoutData.open = false
}
Rectangle {
id: gridParent
radius: 24
@ -134,37 +128,24 @@ Singleton {
bottomRightRadius: 0
topRightRadius: 10
bottomLeftRadius: 10
Keys.onPressed: event => {
console.log(event);
if (event.key == Qt.Key_Escape) {
logoutData.open = false;
}
}
Column {
spacing: gridParent.margins.v
padding: gridParent.margins.v
// horizontalItemAlignment: Grid.AlignHCenter
// verticalItemAlignment: Grid.AlignVCenter
anchors {
fill: parent
centerIn: parent
alignWhenCentered: true
verticalCenter: parent.verticalCenter
// topMargin: gridParent.margins.v
// bottomMargin: gridParent.margins.v
}
width: parent.width / 3 * 2
height: parent.height / 6 * 5
Repeater {
model: logoutData.buttons.length
model: topLevel.buttons.length
Button {
id: button
required property int index
anchors.horizontalCenter: parent.horizontalCenter
Process {
id: thisProcess
running: false
command: logoutData.buttons[button.index].action
}
implicitWidth: gridParent.dims.h
implicitHeight: gridParent.dims.v
@ -175,14 +156,20 @@ Singleton {
}
background: Rectangle {
color: button.hovered ? "#ffb852" : "#272a2a"
Behavior on color {
ColorAnimation {
duration: 150
}
}
border.color: "#ffab5b"
border.width: 2
radius: 6
}
text: logoutData.buttons[index].name
text: topLevel.buttons[index].text
onClicked: {
logoutData.open = false;
thisProcess.running = true;
logoutData.selected = index;
topLevel.buttons[index].exec();
}
}
}

View file

@ -0,0 +1,20 @@
import QtQuick
import Quickshell.Io
QtObject {
required property string command
required property string text
// required property string icon
property var keybind: null
id: button
readonly property var process: Process {
command: ["sh", "-c", button.command]
}
function exec() {
process.startDetached();
}
}

View file

@ -35,7 +35,7 @@ ShellRoot {
}
}
}
// rhs main
Variants {
model: Quickshell.screens
@ -196,7 +196,7 @@ ShellRoot {
}
border {
width: 1
color: tag.urgent ? Colours.c.red_b : Colours.c.yellow_b
color: tag.urgent ? Colours.c.red_b : Colours.c.yellow_b
Behavior on color {
ColorAnimation {
duration: 300
@ -238,5 +238,25 @@ ShellRoot {
Logout.Logout {
width: 2560
height: 1440
Logout.LogoutButton {
text: "Logout"
keybind: Qt.Key_E
command: "loginctl terminate-user 1000"
}
Logout.LogoutButton {
text: "Suspend"
keybind: Qt.Key_S
command: "systemctl suspend"
}
Logout.LogoutButton {
text: "Shutdown"
keybind: Qt.Key_D
command: "systemctl poweroff"
}
Logout.LogoutButton {
text: "Reboot"
keybind: Qt.Key_R
command: "systemctl reboot"
}
}
}