diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-08-31 14:34:22 +1000 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-08-31 14:34:22 +1000 |
| commit | d66f4ca0f37d585a86145c0a27e79e89c3a815c8 (patch) | |
| tree | b5cebc4457e9c02f4eb20ff23abbe0613375b21e /services/Colours.qml | |
| parent | [CI] chore: update flake (diff) | |
| download | caelestia-shell-d66f4ca0f37d585a86145c0a27e79e89c3a815c8.tar.gz caelestia-shell-d66f4ca0f37d585a86145c0a27e79e89c3a815c8.tar.bz2 caelestia-shell-d66f4ca0f37d585a86145c0a27e79e89c3a815c8.zip | |
plugin/cutils: add getAverageLuminance
Fixes stutters in wallpaper list
Also fix crash when saveItem target doesn't have a window
Diffstat (limited to 'services/Colours.qml')
| -rw-r--r-- | services/Colours.qml | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/services/Colours.qml b/services/Colours.qml index 8470cfa..ca78abc 100644 --- a/services/Colours.qml +++ b/services/Colours.qml @@ -3,6 +3,7 @@ pragma ComponentBehavior: Bound import qs.config import qs.utils +import Caelestia import Quickshell import Quickshell.Io import QtQuick @@ -21,7 +22,7 @@ Singleton { readonly property M3Palette current: M3Palette {} readonly property M3Palette preview: M3Palette {} readonly property Transparency transparency: Transparency {} - readonly property color wallColour: quantizer.colors[0] ?? "black" + property real wallLuminance function getLuminance(c: color): real { if (c.r == 0 && c.g == 0 && c.b == 0) @@ -30,7 +31,6 @@ Singleton { } function alterColour(c: color, a: real, layer: int): color { - const wallLuminance = getLuminance(wallColour); const luminance = getLuminance(c); const offset = (!light || layer == 1 ? 1 : -layer / 2) * (light ? 0.2 : 0.3) * (1 - transparency.base) * (1 + wallLuminance * (light ? (layer == 1 ? 3 : 1) : 2.5)); @@ -85,12 +85,16 @@ Singleton { onLoaded: root.load(text(), false) } - ColorQuantizer { - id: quantizer + Connections { + target: Wallpapers - source: Qt.resolvedUrl(Wallpapers.current) - depth: 0 - rescaleSize: 128 + function onCurrentChanged(): void { + const current = Wallpapers.current; + CUtils.getAverageLuminance(current, l => { + if (Wallpapers.current == current) + root.wallLuminance = l; + }); + } } component Transparency: QtObject { |