diff --git a/Config/Launcher.qml b/Config/Launcher.qml index fe9264d..a195868 100644 --- a/Config/Launcher.qml +++ b/Config/Launcher.qml @@ -35,6 +35,14 @@ JsonObject { enabled: true, dangerous: false }, + { + name: "Variant", + icon: "colors", + description: "Change the current scheme variant", + command: ["autocomplete", "variant"], + enabled: true, + dangerous: false + }, { name: "Shutdown", icon: "power_settings_new", diff --git a/Modules/Launcher/AppList.qml b/Modules/Launcher/AppList.qml index 4ed025d..a9dc2a5 100644 --- a/Modules/Launcher/AppList.qml +++ b/Modules/Launcher/AppList.qml @@ -131,6 +131,14 @@ CustomListView { model.values: [0] root.delegate: calcItem } + }, + State { + name: "variant" + + PropertyChanges { + model.values: SchemeVariants.query(search.text) + root.delegate: variantItem + } } ] transitions: Transition { @@ -211,4 +219,12 @@ CustomListView { list: root } } + + Component { + id: variantItem + + VariantItem { + list: root + } + } } diff --git a/Modules/Launcher/Content.qml b/Modules/Launcher/Content.qml index eeeef2b..2365fca 100644 --- a/Modules/Launcher/Content.qml +++ b/Modules/Launcher/Content.qml @@ -123,11 +123,6 @@ Item { search.text = ""; } - function onSessionChanged(): void { - if (!root.visibilities.session) - search.forceActiveFocus(); - } - target: root.visibilities } } diff --git a/Modules/Launcher/Items/VariantItem.qml b/Modules/Launcher/Items/VariantItem.qml new file mode 100644 index 0000000..2b0b096 --- /dev/null +++ b/Modules/Launcher/Items/VariantItem.qml @@ -0,0 +1,74 @@ +import QtQuick +import qs.Components +import qs.Modules.Launcher.Services +import qs.Config + +Item { + id: root + + required property var list + required property SchemeVariants.Variant modelData + + anchors.left: parent?.left + anchors.right: parent?.right + implicitHeight: Config.launcher.sizes.itemHeight + + StateLayer { + function onClicked(): void { + root.modelData?.onClicked(root.list); + } + + radius: Appearance.rounding.normal + } + + Item { + anchors.fill: parent + anchors.leftMargin: Appearance.padding.larger + anchors.margins: Appearance.padding.smaller + anchors.rightMargin: Appearance.padding.larger + + MaterialIcon { + id: icon + + anchors.verticalCenter: parent.verticalCenter + font.pointSize: Appearance.font.size.extraLarge + text: root.modelData?.icon ?? "" + } + + Column { + anchors.left: icon.right + anchors.leftMargin: Appearance.spacing.larger + anchors.verticalCenter: icon.verticalCenter + spacing: 0 + width: parent.width - icon.width - anchors.leftMargin - (current.active ? current.width + Appearance.spacing.normal : 0) + + CustomText { + font.pointSize: Appearance.font.size.normal + text: root.modelData?.name ?? "" + } + + CustomText { + anchors.left: parent.left + anchors.right: parent.right + color: DynamicColors.palette.m3outline + elide: Text.ElideRight + font.pointSize: Appearance.font.size.small + text: root.modelData?.description ?? "" + } + } + + Loader { + id: current + + active: root.modelData?.variant === Config.colors.schemeType + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + + sourceComponent: MaterialIcon { + color: DynamicColors.palette.m3onSurfaceVariant + font.pointSize: Appearance.font.size.large + text: "check" + } + } + } +} diff --git a/Modules/Launcher/Services/SchemeVariants.qml b/Modules/Launcher/Services/SchemeVariants.qml new file mode 100644 index 0000000..c943010 --- /dev/null +++ b/Modules/Launcher/Services/SchemeVariants.qml @@ -0,0 +1,88 @@ +pragma Singleton + +import Quickshell +import QtQuick +import qs.Modules.Launcher +import qs.Config +import qs.Helpers + +Searcher { + id: root + + function transformSearch(search: string): string { + return search.slice(`${Config.launcher.actionPrefix}variant `.length); + } + + useFuzzy: Config.launcher.useFuzzy.variants + + list: [ + Variant { + description: qsTr("Maximum chroma at each tone.") + icon: "sentiment_very_dissatisfied" + name: qsTr("Vibrant") + variant: "vibrant" + }, + Variant { + description: qsTr("Pastel palette with a low chroma.") + icon: "android" + name: qsTr("Tonal Spot") + variant: "tonalspot" + }, + Variant { + description: qsTr("Hue-shifted, artistic or playful colors.") + icon: "compare_arrows" + name: qsTr("Expressive") + variant: "expressive" + }, + Variant { + description: qsTr("Preserve source color exactly.") + icon: "compare" + name: qsTr("Fidelity") + variant: "fidelity" + }, + Variant { + description: qsTr("Almost identical to fidelity.") + icon: "sentiment_calm" + name: qsTr("Content") + variant: "content" + }, + Variant { + description: qsTr("The seed colour's hue does not appear in the theme.") + icon: "nutrition" + name: qsTr("Fruit Salad") + variant: "fruit-salad" + }, + Variant { + description: qsTr("Like Fruit Salad but different hues.") + icon: "looks" + name: qsTr("Rainbow") + variant: "rainbow" + }, + Variant { + description: qsTr("Close to grayscale, a hint of chroma.") + icon: "contrast" + name: qsTr("Neutral") + variant: "neutral" + }, + Variant { + description: qsTr("All colours are grayscale, no chroma.") + icon: "filter_b_and_w" + name: qsTr("Monochrome") + variant: "monochrome" + } + ] + + component Variant: QtObject { + required property string description + required property string icon + required property string name + required property string variant + + function onClicked(list: AppList): void { + list.visibilities.launcher = false; + Quickshell.execDetached(["zshell-cli", "scheme", "generate", "--scheme", variant]); + Config.colors.schemeType = variant; + Config.save(); + } + } +}