NightLight: refactored the code to make simpler

- using intensity instead of warmth
- animated color transition
- removed unecessary bindings and double properties
- using better icons to avoid confusion with brightness
- polished settings UI
This commit is contained in:
LemmyCook 2025-08-26 18:48:10 -04:00
parent 76f0368a64
commit 4cd94f0426
6 changed files with 113 additions and 216 deletions

View file

@ -11,17 +11,11 @@ Variants {
required property ShellScreen modelData
readonly property real scaling: ScalingService.scale(modelData)
active: NightLightService.enabled
active: NightLightService.isActive
sourceComponent: PanelWindow {
id: nightlightWindow
screen: modelData
visible: NightLightService.isActive
color: Color.transparent
mask: Region {}
anchors {
top: true
bottom: true
@ -29,6 +23,9 @@ Variants {
right: true
}
// Ensure a full click through
mask: Region {}
WlrLayershell.layer: WlrLayershell.Overlay
WlrLayershell.exclusionMode: ExclusionMode.Ignore
WlrLayershell.keyboardFocus: WlrKeyboardFocus.None
@ -37,29 +34,13 @@ Variants {
Rectangle {
anchors.fill: parent
color: NightLightService.overlayColor
}
// Safe connection that checks if the window still exists
Connections {
target: NightLightService
function onIsActiveChanged() {
if (nightlightWindow && typeof nightlightWindow.visible !== 'undefined') {
nightlightWindow.visible = NightLightService.isActive
Behavior on color {
ColorAnimation {
duration: Style.animationSlow
}
}
}
// Cleanup when component is being destroyed
Component.onDestruction: {
Logger.log("NightLight", "PanelWindow being destroyed")
}
}
// Safe state changes
onActiveChanged: {
if (!active) {
Logger.log("NightLight", "Loader deactivating for screen:", modelData.name)
}
}
}
}