From f52fb9bd9ee73d785c5a7141c1924a89e05f212a Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Sat, 23 Aug 2025 16:53:15 +1000 Subject: launcher: show current scheme/variant Also qsTr variant stuff --- modules/launcher/AppList.qml | 5 +++++ modules/launcher/items/SchemeItem.qml | 29 ++++++++++++++++++------- modules/launcher/items/VariantItem.qml | 29 +++++++++++++++++-------- modules/launcher/services/M3Variants.qml | 36 ++++++++++++++++---------------- modules/launcher/services/Schemes.qml | 23 +++++++++++++++++++- 5 files changed, 86 insertions(+), 36 deletions(-) (limited to 'modules/launcher') diff --git a/modules/launcher/AppList.qml b/modules/launcher/AppList.qml index 2ede78e..9e10087 100644 --- a/modules/launcher/AppList.qml +++ b/modules/launcher/AppList.qml @@ -50,6 +50,11 @@ StyledListView { return "apps"; } + onStateChanged: { + if (state === "scheme" || state === "variant") + Schemes.reload(); + } + states: [ State { name: "apps" diff --git a/modules/launcher/items/SchemeItem.qml b/modules/launcher/items/SchemeItem.qml index 8cc2e33..f2246dc 100644 --- a/modules/launcher/items/SchemeItem.qml +++ b/modules/launcher/items/SchemeItem.qml @@ -67,25 +67,38 @@ Item { anchors.leftMargin: Appearance.spacing.normal anchors.verticalCenter: parent.verticalCenter - width: parent.width - preview.width + width: parent.width - preview.width - anchors.leftMargin - (current.active ? current.width + Appearance.spacing.normal : 0) spacing: 0 StyledText { - id: name - - text: root.modelData?.name ?? "" + text: root.modelData?.flavour ?? "" font.pointSize: Appearance.font.size.normal } StyledText { - id: comment - - text: root.modelData?.flavour ?? "" + text: root.modelData?.name ?? "" font.pointSize: Appearance.font.size.small color: Colours.palette.m3outline elide: Text.ElideRight - width: parent.width - Appearance.rounding.normal * 2 + anchors.left: parent.left + anchors.right: parent.right + } + } + + Loader { + id: current + + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + + active: `${root.modelData?.name} ${root.modelData?.flavour}` === Schemes.currentScheme + asynchronous: true + + sourceComponent: MaterialIcon { + text: "check" + color: Colours.palette.m3onSurfaceVariant + font.pointSize: Appearance.font.size.large } } } diff --git a/modules/launcher/items/VariantItem.qml b/modules/launcher/items/VariantItem.qml index 71621ad..c7db975 100644 --- a/modules/launcher/items/VariantItem.qml +++ b/modules/launcher/items/VariantItem.qml @@ -38,32 +38,43 @@ Item { anchors.verticalCenter: parent.verticalCenter } - Item { + Column { anchors.left: icon.right anchors.leftMargin: Appearance.spacing.larger anchors.verticalCenter: icon.verticalCenter - implicitWidth: parent.width - icon.width - implicitHeight: name.implicitHeight + desc.implicitHeight + width: parent.width - icon.width - anchors.leftMargin - (current.active ? current.width + Appearance.spacing.normal : 0) + spacing: 0 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.palette.m3outline elide: Text.ElideRight - width: root.width - icon.width - Appearance.rounding.normal * 2 + anchors.left: parent.left + anchors.right: parent.right + } + } + + Loader { + id: current + + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + + active: root.modelData?.variant === Schemes.currentVariant + asynchronous: true - anchors.top: name.bottom + sourceComponent: MaterialIcon { + text: "check" + color: Colours.palette.m3onSurfaceVariant + font.pointSize: Appearance.font.size.large } } } diff --git a/modules/launcher/services/M3Variants.qml b/modules/launcher/services/M3Variants.qml index 9232883..963a4d4 100644 --- a/modules/launcher/services/M3Variants.qml +++ b/modules/launcher/services/M3Variants.qml @@ -17,56 +17,56 @@ Searcher { Variant { variant: "vibrant" icon: "sentiment_very_dissatisfied" - name: "Vibrant" - description: "A high chroma palette. The primary palette's chroma is at maximum." + name: qsTr("Vibrant") + description: qsTr("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." + name: qsTr("Tonal Spot") + description: qsTr("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." + name: qsTr("Expressive") + description: qsTr("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)." + name: qsTr("Fidelity") + description: qsTr("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." + name: qsTr("Content") + description: qsTr("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." + name: qsTr("Fruit Salad") + description: qsTr("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." + name: qsTr("Rainbow") + description: qsTr("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." + name: qsTr("Neutral") + description: qsTr("Close to grayscale, a hint of chroma.") }, Variant { variant: "monochrome" icon: "filter_b_and_w" - name: "Monochrome" - description: "All colours are grayscale, no chroma." + name: qsTr("Monochrome") + description: qsTr("All colours are grayscale, no chroma.") } ] useFuzzy: Config.launcher.useFuzzy.variants diff --git a/modules/launcher/services/Schemes.qml b/modules/launcher/services/Schemes.qml index a5891d5..dbb2dac 100644 --- a/modules/launcher/services/Schemes.qml +++ b/modules/launcher/services/Schemes.qml @@ -10,6 +10,9 @@ import QtQuick Searcher { id: root + property string currentScheme + property string currentVariant + function transformSearch(search: string): string { return search.slice(`${Config.launcher.actionPrefix}scheme `.length); } @@ -18,6 +21,10 @@ Searcher { return `${item.name} ${item.flavour}`; } + function reload(): void { + getCurrent.running = true; + } + list: schemes.instances useFuzzy: Config.launcher.useFuzzy.schemes keys: ["name", "flavour"] @@ -48,7 +55,21 @@ Searcher { for (const f of s) flat.push(f); - schemes.model = flat; + schemes.model = flat.sort((a, b) => (a.name + a.flavour).localeCompare((b.name + b.flavour))); + } + } + } + + Process { + id: getCurrent + + running: true + command: ["caelestia", "scheme", "get", "-nfv"] + stdout: StdioCollector { + onStreamFinished: { + const [name, flavour, variant] = text.trim().split("\n"); + root.currentScheme = `${name} ${flavour}`; + root.currentVariant = variant; } } } -- cgit v1.2.3-freya