extract loadColor gradient function into Theme service

This commit is contained in:
Damocles 2026-04-23 23:22:55 +02:00
parent 1db16b435c
commit 7d9800374f
5 changed files with 16 additions and 39 deletions

View file

@ -39,6 +39,15 @@ QtObject {
property bool _reducedMotionConfig: false
readonly property bool reducedMotion: _reducedMotionConfig || PowerProfileService.powerSaver
// Green -> yellow -> red gradient for 0-100% load/usage values
function loadColor(pct) {
const t = Math.max(0, Math.min(100, pct)) / 100;
const a = t < 0.5 ? root.base0B : root.base0A;
const b = t < 0.5 ? root.base0A : root.base08;
const u = t < 0.5 ? t * 2 : (t - 0.5) * 2;
return Qt.rgba(a.r + (b.r - a.r) * u, a.g + (b.g - a.g) * u, a.b + (b.b - a.b) * u, 1);
}
property FileView _themeFile: FileView {
path: (Quickshell.env("XDG_CONFIG_HOME") || (Quickshell.env("HOME") + "/.config")) + "/nova-shell/theme.json"
watchChanges: true