diff options
Diffstat (limited to 'modules/launcher')
| -rw-r--r-- | modules/launcher/AppList.qml | 19 | ||||
| -rw-r--r-- | modules/launcher/M3Variants.qml | 91 | ||||
| -rw-r--r-- | modules/launcher/SchemeItem.qml | 7 | ||||
| -rw-r--r-- | modules/launcher/Schemes.qml | 4 | ||||
| -rw-r--r-- | modules/launcher/VariantItem.qml | 69 |
5 files changed, 183 insertions, 7 deletions
diff --git a/modules/launcher/AppList.qml b/modules/launcher/AppList.qml index 2a54f60..c06893a 100644 --- a/modules/launcher/AppList.qml +++ b/modules/launcher/AppList.qml @@ -15,11 +15,14 @@ ListView { property bool isAction: search.text.startsWith(Config.launcher.actionPrefix) property bool isScheme: search.text.startsWith(`${Config.launcher.actionPrefix}scheme `) + property bool isVariant: search.text.startsWith(`${Config.launcher.actionPrefix}variant `) function getModelValues() { let text = search.text; if (isScheme) return Schemes.fuzzyQuery(text); + if (isVariant) + return M3Variants.fuzzyQuery(text); if (isAction) return Actions.fuzzyQuery(text); if (text.startsWith(Config.launcher.actionPrefix)) @@ -48,6 +51,8 @@ ListView { delegate: { if (isScheme) return schemeItem; + if (isVariant) + return variantItem; if (isAction) return actionItem; return appItem; @@ -122,7 +127,15 @@ ListView { id: schemeItem SchemeItem { - visibilities: root.visibilities + list: root + } + } + + Component { + id: variantItem + + VariantItem { + list: root } } @@ -134,6 +147,10 @@ ListView { ChangeAnim {} } + Behavior on isVariant { + ChangeAnim {} + } + component ChangeAnim: SequentialAnimation { ParallelAnimation { Anim { diff --git a/modules/launcher/M3Variants.qml b/modules/launcher/M3Variants.qml new file mode 100644 index 0000000..a4b797a --- /dev/null +++ b/modules/launcher/M3Variants.qml @@ -0,0 +1,91 @@ +pragma Singleton + +import "root:/utils/scripts/fuzzysort.js" as Fuzzy +import "root:/config" +import Quickshell +import QtQuick + +Singleton { + id: root + + readonly property list<Variant> list: [ + Variant { + variant: "vibrant" + icon: "sentiment_very_dissatisfied" + name: "Vibrant" + description: "A high chroma palette. The primary palette's chroma is at maximum." + }, + Variant { + variant: "tonalspot" + icon: "android" + name: "Tonal Spot" + description: "Default for Material theme colours. A pastel palette with a low chroma." + }, + Variant { + variant: "expressive" + icon: "compare_arrows" + name: "Expressive" + description: "A medium chroma palette. The primary palette's hue is different from the seed colour, for variety." + }, + Variant { + variant: "fidelity" + icon: "compare" + name: "Fidelity" + description: "Matches the seed colour, even if the seed colour is very bright (high chroma)." + }, + Variant { + variant: "content" + icon: "sentiment_calm" + name: "Content" + description: "Almost identical to fidelity." + }, + Variant { + variant: "fruitsalad" + icon: "nutrition" + name: "Fruit Salad" + description: "A playful theme - the seed colour's hue does not appear in the theme." + }, + Variant { + variant: "rainbow" + icon: "looks" + name: "Rainbow" + description: "A playful theme - the seed colour's hue does not appear in the theme." + }, + Variant { + variant: "neutral" + icon: "contrast" + name: "Neutral" + description: "Close to grayscale, a hint of chroma." + }, + Variant { + variant: "monochrome" + icon: "filter_b_and_w" + name: "Monochrome" + description: "All colours are grayscale, no chroma." + } + ] + + readonly property list<var> preppedVariants: list.map(v => ({ + name: Fuzzy.prepare(v.variant), + variant: v + })) + + function fuzzyQuery(search: string): var { + return Fuzzy.go(search.slice(`${Config.launcher.actionPrefix}variant `.length), preppedVariants, { + all: true, + key: "name" + }).map(r => r.obj.variant); + } + + component Variant: QtObject { + required property string variant + required property string icon + required property string name + required property string description + + function onClicked(list: AppList): void { + list.visibilities.launcher = false; + Quickshell.execDetached(["caelestia", "scheme", "set", "-v", variant]); + } + } +} diff --git a/modules/launcher/SchemeItem.qml b/modules/launcher/SchemeItem.qml index fa55a65..df635f5 100644 --- a/modules/launcher/SchemeItem.qml +++ b/modules/launcher/SchemeItem.qml @@ -8,8 +8,8 @@ import QtQuick Item { id: root - required property var modelData - required property PersistentProperties visibilities + required property Schemes.Scheme modelData + required property var list implicitHeight: Config.launcher.sizes.itemHeight @@ -20,8 +20,7 @@ Item { radius: Appearance.rounding.full function onClicked(): void { - Apps.launch(root.modelData); - root.visibilities.launcher = false; + root.modelData?.onClicked(root.list); } } diff --git a/modules/launcher/Schemes.qml b/modules/launcher/Schemes.qml index b81dbe4..abdaaf2 100644 --- a/modules/launcher/Schemes.qml +++ b/modules/launcher/Schemes.qml @@ -9,14 +9,14 @@ import QtQuick Singleton { id: root - readonly property list<var> preppedActions: schemes.instances.map(s => ({ + readonly property list<var> preppedSchemes: schemes.instances.map(s => ({ name: Fuzzy.prepare(s.name), flavour: Fuzzy.prepare(s.flavour), scheme: s })) function fuzzyQuery(search: string): var { - return Fuzzy.go(search.slice(`${Config.launcher.actionPrefix}scheme `.length), preppedActions, { + return Fuzzy.go(search.slice(`${Config.launcher.actionPrefix}scheme `.length), preppedSchemes, { all: true, keys: ["name", "flavour"], scoreFn: r => r[0].score > 0 ? r[0].score * 0.9 + r[1].score * 0.1 : 0 diff --git a/modules/launcher/VariantItem.qml b/modules/launcher/VariantItem.qml new file mode 100644 index 0000000..2b5ae2e --- /dev/null +++ b/modules/launcher/VariantItem.qml @@ -0,0 +1,69 @@ +import "root:/widgets" +import "root:/services" +import "root:/config" +import QtQuick + +Item { + id: root + + required property M3Variants.Variant modelData + required property var list + + implicitHeight: Config.launcher.sizes.itemHeight + + anchors.left: parent?.left + anchors.right: parent?.right + + StateLayer { + radius: Appearance.rounding.full + + function onClicked(): void { + root.modelData?.onClicked(root.list); + } + } + + Item { + anchors.fill: parent + anchors.leftMargin: Appearance.padding.larger + anchors.rightMargin: Appearance.padding.larger + anchors.margins: Appearance.padding.smaller + + MaterialIcon { + id: icon + + text: root.modelData?.icon ?? "" + font.pointSize: Appearance.font.size.extraLarge + + anchors.verticalCenter: parent.verticalCenter + } + + Item { + anchors.left: icon.right + anchors.leftMargin: Appearance.spacing.larger + anchors.verticalCenter: icon.verticalCenter + + implicitWidth: parent.width - icon.width + implicitHeight: name.implicitHeight + desc.implicitHeight + + StyledText { + id: name + + text: root.modelData?.name ?? "" + font.pointSize: Appearance.font.size.normal + } + + StyledText { + id: desc + + text: root.modelData?.description ?? "" + font.pointSize: Appearance.font.size.small + color: Colours.alpha(Colours.palette.m3outline, true) + + elide: Text.ElideRight + width: root.width - icon.width - Appearance.rounding.normal * 2 + + anchors.top: name.bottom + } + } + } +} |