refactor: Integrate IdleMonitor and IdleInhibitor into IdleState to manage system idle and inhibit functionality in singleton and not multiple times
This commit is contained in:
@@ -2,11 +2,28 @@ pragma Singleton
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Io
|
import Quickshell.Io
|
||||||
|
import Quickshell.Wayland
|
||||||
import "../../../../config"
|
import "../../../../config"
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
// true = inhibit idle (prevent hypridle/lock/dpms), false = allow idle
|
// true = inhibit idle (prevent hypridle/lock/dpms), false = allow idle
|
||||||
property bool idle: false
|
property bool idle: false
|
||||||
|
property bool isIdle: idleMonitor.isIdle
|
||||||
|
|
||||||
|
property PanelWindow panelWindow: null
|
||||||
|
|
||||||
|
IdleInhibitor {
|
||||||
|
id: idleInhibitor
|
||||||
|
window: panelWindow
|
||||||
|
enabled: IdleState.idle
|
||||||
|
}
|
||||||
|
|
||||||
|
IdleMonitor {
|
||||||
|
id: idleMonitor
|
||||||
|
enabled: true
|
||||||
|
timeout: 30
|
||||||
|
respectInhibitors: true
|
||||||
|
}
|
||||||
|
|
||||||
// may need this in hypridle.conf
|
// may need this in hypridle.conf
|
||||||
// general {
|
// general {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Hyprland
|
import Quickshell.Hyprland
|
||||||
import Quickshell.Wayland
|
|
||||||
import Quickshell.Io
|
import Quickshell.Io
|
||||||
import "../../../config"
|
import "../../../config"
|
||||||
import "../states/Idle"
|
import "../states/Idle"
|
||||||
@@ -13,21 +12,6 @@ MouseArea {
|
|||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
|
||||||
required property PanelWindow panelWindow
|
|
||||||
|
|
||||||
IdleInhibitor {
|
|
||||||
id: idleInhibitor
|
|
||||||
window: panelWindow
|
|
||||||
enabled: IdleState.idle
|
|
||||||
}
|
|
||||||
|
|
||||||
IdleMonitor {
|
|
||||||
id: idleMonitor
|
|
||||||
enabled: true
|
|
||||||
timeout: 30
|
|
||||||
respectInhibitors: true
|
|
||||||
}
|
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
IdleState.idle = !IdleState.idle
|
IdleState.idle = !IdleState.idle
|
||||||
console.log("[IdleButton] Toggling idle: " + (IdleState.idle ? "enabled" : "disabled"))
|
console.log("[IdleButton] Toggling idle: " + (IdleState.idle ? "enabled" : "disabled"))
|
||||||
@@ -35,7 +19,7 @@ MouseArea {
|
|||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
color: idleButton.containsMouse ? Colors.tertiary : idleMonitor.isIdle ? Qt.alpha(Colors.secondary, 0.25) : Qt.alpha(Colors.tertiaryContainer, 0.25)
|
color: idleButton.containsMouse ? Colors.tertiary : IdleState.isIdle ? Qt.alpha(Colors.secondary, 0.25) : Qt.alpha(Colors.tertiaryContainer, 0.25)
|
||||||
radius: Config.radius_fun(idleButton.height)
|
radius: Config.radius_fun(idleButton.height)
|
||||||
border.width: Config.border_width
|
border.width: Config.border_width
|
||||||
border.color: (
|
border.color: (
|
||||||
|
|||||||
Reference in New Issue
Block a user