summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/Colours.qml39
1 files changed, 19 insertions, 20 deletions
diff --git a/services/Colours.qml b/services/Colours.qml
index cc07959..e83e353 100644
--- a/services/Colours.qml
+++ b/services/Colours.qml
@@ -14,13 +14,11 @@ Singleton {
property bool showPreview
property string scheme
property string flavour
- readonly property bool light: showPreview ? previewLight : currentLight
- property bool currentLight
- property bool previewLight
- readonly property M3Palette palette: showPreview ? preview : current
+ property bool light
+ property M3Palette palette: M3Palette {}
+
readonly property M3TPalette tPalette: M3TPalette {}
- readonly property M3Palette current: M3Palette {}
- readonly property M3Palette preview: M3Palette {}
+ readonly property M3Palette defaultPalette: M3Palette {}
readonly property Transparency transparency: Transparency {}
readonly property alias wallLuminance: analyser.luminance
@@ -55,22 +53,23 @@ Singleton {
return Qt.hsla(c.hslHue, c.hslSaturation, 0.1, 1);
}
- function load(data: string, isPreview: bool): void {
- const colours = isPreview ? preview : current;
+ function load(data: string): void {
+ const colours = palette;
const scheme = JSON.parse(data);
- if (!isPreview) {
- root.scheme = scheme.name;
- flavour = scheme.flavour;
- currentLight = scheme.mode === "light";
- } else {
- previewLight = scheme.mode === "light";
- }
+ root.scheme = scheme.name ?? "";
+ flavour = scheme.flavour ?? "";
+ light = scheme?.mode === "light";
- for (const [name, colour] of Object.entries(scheme.colours)) {
- const propName = name.startsWith("term") ? name : `m3${name}`;
- if (colours.hasOwnProperty(propName))
- colours[propName] = `#${colour}`;
+ for (const propName of Object.keys(defaultPalette)) {
+ if (typeof defaultPalette[propName] === "function")
+ continue;
+ const name = propName.startsWith("m3") ? propName.substring(2) : propName;
+ if (scheme?.colours[name]) {
+ colours[propName] = `#${scheme?.colours[name]}`;
+ } else {
+ colours[propName] = defaultPalette[propName];
+ }
}
}
@@ -82,7 +81,7 @@ Singleton {
path: `${Paths.config}/scheme.json`
watchChanges: true
onFileChanged: reload()
- onLoaded: root.load(text(), false)
+ onLoaded: root.load(text())
}
ImageAnalyser {