summaryrefslogtreecommitdiff
path: root/services/Colours.qml
diff options
context:
space:
mode:
author2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-08-31 14:34:22 +1000
committer2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-08-31 14:34:22 +1000
commitd66f4ca0f37d585a86145c0a27e79e89c3a815c8 (patch)
treeb5cebc4457e9c02f4eb20ff23abbe0613375b21e /services/Colours.qml
parent[CI] chore: update flake (diff)
downloadcaelestia-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.qml18
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 {