1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-28 07:22:50 -05:00

Add systemd-inhibit widget

This commit is contained in:
bbedward
2025-08-15 21:52:44 -04:00
parent f67b90cfbe
commit af9607fdbe
6 changed files with 335 additions and 0 deletions

View File

@@ -0,0 +1,73 @@
import QtQuick
import QtQuick.Controls
import Quickshell
import qs.Common
import qs.Services
import qs.Widgets
Rectangle {
id: root
property string section: "right"
property var popupTarget: null
property var parentScreen: null
width: 40
height: 30
radius: Theme.cornerRadius
color: {
const baseColor = mouseArea.containsMouse
? Theme.primaryPressed
: (IdleInhibitorService.idleInhibited ? Theme.primaryHover : Theme.secondaryHover)
return Qt.rgba(baseColor.r, baseColor.g, baseColor.b,
baseColor.a * Theme.widgetTransparency)
}
DankIcon {
anchors.centerIn: parent
name: IdleInhibitorService.idleInhibited ? "motion_sensor_active" : "motion_sensor_idle"
size: Theme.iconSize - 6
color: Theme.surfaceText
}
MouseArea {
id: mouseArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: {
IdleInhibitorService.toggleIdleInhibit()
}
}
ToolTip {
visible: mouseArea.containsMouse
delay: 1000
text: IdleInhibitorService.idleInhibited
? "Screen timeout disabled\nClick to enable"
: "Screen timeout enabled\nClick to disable"
contentItem: Text {
text: parent.text || ""
font.family: Theme.fontFamily || "Sans"
font.pixelSize: Theme.fontSize - 2
color: Theme.surfaceText
}
background: Rectangle {
color: Theme.surfaceContainer
radius: Theme.cornerRadius
border.color: Theme.outline
border.width: 1
}
}
Behavior on color {
ColorAnimation {
duration: Theme.shortDuration
easing.type: Theme.standardEasing
}
}
}

View File

@@ -312,6 +312,8 @@ PanelWindow {
return true
case "controlCenterButton":
return true
case "idleInhibitor":
return true
case "spacer":
return true
case "separator":
@@ -355,6 +357,8 @@ PanelWindow {
return batteryComponent
case "controlCenterButton":
return controlCenterButtonComponent
case "idleInhibitor":
return idleInhibitorComponent
case "spacer":
return spacerComponent
case "separator":
@@ -953,6 +957,23 @@ PanelWindow {
}
}
Component {
id: idleInhibitorComponent
IdleInhibitor {
section: {
if (parent && parent.parent === leftSection)
return "left"
if (parent && parent.parent === rightSection)
return "right"
if (parent && parent.parent === centerSection)
return "center"
return "right"
}
parentScreen: root.screen
}
}
Component {
id: spacerComponent