51 lines
1.5 KiB
QML
51 lines
1.5 KiB
QML
import QtQuick
|
|
import Quickshell
|
|
import Quickshell.Hyprland
|
|
import Quickshell.Io
|
|
import "../../../config"
|
|
import "../states/Idle"
|
|
|
|
MouseArea {
|
|
id: idleButton
|
|
width: Math.max(idleText.width + Config.spacing_fun(height)*2, height)
|
|
height: bar.height
|
|
hoverEnabled: true
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
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_fun(idleButton.height)
|
|
border.width: Config.border_width
|
|
border.color: (
|
|
idleButton.containsMouse ? Colors.tertiaryContainer_fg :
|
|
Colors.secondaryContainer_fg
|
|
)
|
|
|
|
Text {
|
|
id: idleText
|
|
anchors.centerIn: parent
|
|
text: IdleState.idle ? "" : ""
|
|
font.pixelSize: Config.iconSize(idleButton.height)
|
|
font.family: Config.font
|
|
color: (
|
|
idleButton.containsMouse ? Colors.tertiary_fg :
|
|
IdleState.idle ? Colors.tertiary
|
|
: Colors.primary
|
|
)
|
|
}
|
|
}
|
|
|
|
Process {
|
|
id: idleToggleProc
|
|
command: ["sh", "-c", Config.configDir + "/modules/bar/scripts/Idle.sh"]
|
|
running: false
|
|
}
|
|
} |