refaktor
This commit is contained in:
@@ -2,70 +2,50 @@ import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Hyprland
|
||||
import Quickshell.Io
|
||||
import "../../../colors"
|
||||
import "../../../config"
|
||||
import "../states/Idle" as Global
|
||||
import "../states/Idle"
|
||||
|
||||
MouseArea {
|
||||
id: idleButton
|
||||
width: Math.max(idleText.width + parent.spacing*2, bar.height)
|
||||
width: Math.max(idleText.width + Config.spacing_fun(height)*2, height)
|
||||
height: bar.height
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
|
||||
Component.onCompleted: {
|
||||
idleStatusScript.running = true
|
||||
onClicked: {
|
||||
var newState = IdleState.idle ? 0 : 1
|
||||
console.log("[IdleButton] Toggling idle: " + (newState ? "enabled" : "disabled"))
|
||||
idleToggleProc.startDetached()
|
||||
IdleState.idle = newState
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: idleButton.containsMouse ? Colors.tertiary : Qt.alpha(Colors.tertiaryContainer, 0.25)
|
||||
radius: Config.radius
|
||||
radius: Config.radius_fun(idleButton.height)
|
||||
border.width: Config.border_width
|
||||
border.color: idleButton.containsMouse ? Colors.tertiaryContainer_fg
|
||||
: Colors.secondaryContainer_fg
|
||||
|
||||
Item {
|
||||
anchors.fill: parent
|
||||
Process {
|
||||
id: idleScript
|
||||
command: ["sh", "-c", Quickshell.env("HOME") + "/.config/quickshell/modules/bar/scripts/Idle.sh"]
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: Global.IdleState.idle ? console.log(`Disabling Idle`) : console.log(`Enabling Idle`)
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
console.log("Running Idle Script")
|
||||
idleScript.startDetached()
|
||||
Global.IdleState.idle = !Global.IdleState.idle
|
||||
console.log("Current Idle State: " + Global.IdleState.idle)
|
||||
}
|
||||
}
|
||||
}
|
||||
border.color: (
|
||||
idleButton.containsMouse ? Colors.tertiaryContainer_fg :
|
||||
Colors.secondaryContainer_fg
|
||||
)
|
||||
|
||||
Text {
|
||||
id: idleText
|
||||
anchors.centerIn: parent
|
||||
text: Global.IdleState.idle ? "" : ""
|
||||
font.pixelSize: Config.big_font_size(bar.height)
|
||||
text: IdleState.idle ? "" : ""
|
||||
font.pixelSize: Config.iconSize(idleButton.height)
|
||||
font.family: Config.font
|
||||
color: idleButton.containsMouse ? Colors.tertiary_fg : idleText.text == "" ? Colors.primary : Colors.tertiary
|
||||
color: (
|
||||
idleButton.containsMouse ? Colors.tertiary_fg :
|
||||
IdleState.idle ? Colors.tertiary
|
||||
: Colors.primary
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Process {
|
||||
id: idleStatusScript
|
||||
command: ["sh", "-c", Quickshell.env("HOME") + "/.config/quickshell/modules/bar/scripts/Idle.sh" + " --status"]
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
Global.IdleState.idle = this.text.trim() === "0" ? 1 : 0
|
||||
}
|
||||
}
|
||||
id: idleToggleProc
|
||||
command: ["sh", "-c", Config.configDir + "/modules/bar/scripts/Idle.sh"]
|
||||
running: false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user