summaryrefslogtreecommitdiff
path: root/modules/launcher
diff options
context:
space:
mode:
author2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-06-17 15:55:26 +1000
committer2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-06-17 15:55:26 +1000
commit2dbec4489eabc68c071c8bdf5451af2284e20485 (patch)
tree1ee8e8fafdc4fc3b59b1960c510f4942359eb3e5 /modules/launcher
parentlauncher: notify on scheme mode change error (diff)
downloadcaelestia-shell-2dbec4489eabc68c071c8bdf5451af2284e20485.tar.gz
caelestia-shell-2dbec4489eabc68c071c8bdf5451af2284e20485.tar.bz2
caelestia-shell-2dbec4489eabc68c071c8bdf5451af2284e20485.zip
feat: impl scheme launcher action
Diffstat (limited to 'modules/launcher')
-rw-r--r--modules/launcher/Actions.qml1
-rw-r--r--modules/launcher/AppList.qml98
-rw-r--r--modules/launcher/ContentList.qml11
-rw-r--r--modules/launcher/SchemeItem.qml94
-rw-r--r--modules/launcher/Schemes.qml67
5 files changed, 227 insertions, 44 deletions
diff --git a/modules/launcher/Actions.qml b/modules/launcher/Actions.qml
index ae732db..4cb3a31 100644
--- a/modules/launcher/Actions.qml
+++ b/modules/launcher/Actions.qml
@@ -175,7 +175,6 @@ Singleton {
required property string desc
required property string icon
property bool disabled
- property string disabledReason
function onClicked(list: AppList): void {
}
diff --git a/modules/launcher/AppList.qml b/modules/launcher/AppList.qml
index b2b9f57..2a54f60 100644
--- a/modules/launcher/AppList.qml
+++ b/modules/launcher/AppList.qml
@@ -10,14 +10,16 @@ import QtQuick.Controls
ListView {
id: root
- required property int padding
required property TextField search
required property PersistentProperties visibilities
property bool isAction: search.text.startsWith(Config.launcher.actionPrefix)
+ property bool isScheme: search.text.startsWith(`${Config.launcher.actionPrefix}scheme `)
function getModelValues() {
let text = search.text;
+ if (isScheme)
+ return Schemes.fuzzyQuery(text);
if (isAction)
return Actions.fuzzyQuery(text);
if (text.startsWith(Config.launcher.actionPrefix))
@@ -43,7 +45,13 @@ ListView {
opacity: 0.08
}
- delegate: isAction ? actionItem : appItem
+ delegate: {
+ if (isScheme)
+ return schemeItem;
+ if (isAction)
+ return actionItem;
+ return appItem;
+ }
ScrollBar.vertical: StyledScrollBar {}
@@ -110,44 +118,58 @@ ListView {
}
}
+ Component {
+ id: schemeItem
+
+ SchemeItem {
+ visibilities: root.visibilities
+ }
+ }
+
Behavior on isAction {
- SequentialAnimation {
- ParallelAnimation {
- Anim {
- target: root
- property: "opacity"
- from: 1
- to: 0
- duration: Appearance.anim.durations.small
- easing.bezierCurve: Appearance.anim.curves.standardAccel
- }
- Anim {
- target: root
- property: "scale"
- from: 1
- to: 0.9
- duration: Appearance.anim.durations.small
- easing.bezierCurve: Appearance.anim.curves.standardAccel
- }
+ ChangeAnim {}
+ }
+
+ Behavior on isScheme {
+ ChangeAnim {}
+ }
+
+ component ChangeAnim: SequentialAnimation {
+ ParallelAnimation {
+ Anim {
+ target: root
+ property: "opacity"
+ from: 1
+ to: 0
+ duration: Appearance.anim.durations.small
+ easing.bezierCurve: Appearance.anim.curves.standardAccel
+ }
+ Anim {
+ target: root
+ property: "scale"
+ from: 1
+ to: 0.9
+ duration: Appearance.anim.durations.small
+ easing.bezierCurve: Appearance.anim.curves.standardAccel
+ }
+ }
+ PropertyAction {}
+ ParallelAnimation {
+ Anim {
+ target: root
+ property: "opacity"
+ from: 0
+ to: 1
+ duration: Appearance.anim.durations.small
+ easing.bezierCurve: Appearance.anim.curves.standardDecel
}
- PropertyAction {}
- ParallelAnimation {
- Anim {
- target: root
- property: "opacity"
- from: 0
- to: 1
- duration: Appearance.anim.durations.small
- easing.bezierCurve: Appearance.anim.curves.standardDecel
- }
- Anim {
- target: root
- property: "scale"
- from: 0.9
- to: 1
- duration: Appearance.anim.durations.small
- easing.bezierCurve: Appearance.anim.curves.standardDecel
- }
+ Anim {
+ target: root
+ property: "scale"
+ from: 0.9
+ to: 1
+ duration: Appearance.anim.durations.small
+ easing.bezierCurve: Appearance.anim.curves.standardDecel
}
}
}
diff --git a/modules/launcher/ContentList.qml b/modules/launcher/ContentList.qml
index ad116f7..7a3da96 100644
--- a/modules/launcher/ContentList.qml
+++ b/modules/launcher/ContentList.qml
@@ -15,8 +15,8 @@ Item {
required property int padding
required property int rounding
- property bool showWallpapers: search.text.startsWith(`${Config.launcher.actionPrefix}wallpaper `)
- property var currentList: (showWallpapers ? wallpaperList : appList).item
+ readonly property bool showWallpapers: search.text.startsWith(`${Config.launcher.actionPrefix}wallpaper `)
+ property var currentList
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
@@ -29,8 +29,9 @@ Item {
name: "apps"
PropertyChanges {
+ root.currentList: appList.item
root.implicitWidth: Config.launcher.sizes.itemWidth
- root.implicitHeight: Math.max(empty.height, appList.height)
+ root.implicitHeight: Math.max(empty.implicitHeight, appList.implicitHeight)
appList.active: true
}
@@ -43,7 +44,8 @@ Item {
name: "wallpapers"
PropertyChanges {
- root.implicitWidth: Math.max(Config.launcher.sizes.itemWidth, wallpaperList.width)
+ root.currentList: wallpaperList.item
+ root.implicitWidth: Math.max(Config.launcher.sizes.itemWidth, wallpaperList.implicitWidth)
root.implicitHeight: Config.launcher.sizes.wallpaperHeight
wallpaperList.active: true
}
@@ -96,7 +98,6 @@ Item {
anchors.right: parent.right
sourceComponent: AppList {
- padding: root.padding
search: root.search
visibilities: root.visibilities
}
diff --git a/modules/launcher/SchemeItem.qml b/modules/launcher/SchemeItem.qml
new file mode 100644
index 0000000..fa55a65
--- /dev/null
+++ b/modules/launcher/SchemeItem.qml
@@ -0,0 +1,94 @@
+import "root:/widgets"
+import "root:/services"
+import "root:/config"
+import Quickshell
+import Quickshell.Widgets
+import QtQuick
+
+Item {
+ id: root
+
+ required property var modelData
+ required property PersistentProperties visibilities
+
+ implicitHeight: Config.launcher.sizes.itemHeight
+
+ anchors.left: parent?.left
+ anchors.right: parent?.right
+
+ StateLayer {
+ radius: Appearance.rounding.full
+
+ function onClicked(): void {
+ Apps.launch(root.modelData);
+ root.visibilities.launcher = false;
+ }
+ }
+
+ Item {
+ anchors.fill: parent
+ anchors.leftMargin: Appearance.padding.larger
+ anchors.rightMargin: Appearance.padding.larger
+ anchors.margins: Appearance.padding.smaller
+
+ StyledRect {
+ id: preview
+
+ anchors.verticalCenter: parent.verticalCenter
+
+ border.width: 1
+ border.color: Qt.alpha(`#${root.modelData?.colours?.outline}`, 0.5)
+
+ color: `#${root.modelData?.colours?.surface}`
+ radius: Appearance.rounding.full
+ implicitWidth: parent.height * 0.8
+ implicitHeight: parent.height * 0.8
+
+ Item {
+ anchors.top: parent.top
+ anchors.bottom: parent.bottom
+ anchors.right: parent.right
+
+ implicitWidth: parent.implicitWidth / 2
+ clip: true
+
+ StyledRect {
+ anchors.top: parent.top
+ anchors.bottom: parent.bottom
+ anchors.right: parent.right
+
+ implicitWidth: preview.implicitWidth
+ color: `#${root.modelData?.colours?.primary}`
+ radius: Appearance.rounding.full
+ }
+ }
+ }
+
+ Column {
+ anchors.left: preview.right
+ anchors.leftMargin: Appearance.spacing.normal
+ anchors.verticalCenter: parent.verticalCenter
+
+ width: parent.width - preview.width
+ spacing: 0
+
+ StyledText {
+ id: name
+
+ text: root.modelData?.name ?? ""
+ font.pointSize: Appearance.font.size.normal
+ }
+
+ StyledText {
+ id: comment
+
+ text: root.modelData?.flavour ?? ""
+ font.pointSize: Appearance.font.size.small
+ color: Colours.palette.m3outline
+
+ elide: Text.ElideRight
+ width: parent.width - Appearance.rounding.normal * 2
+ }
+ }
+ }
+}
diff --git a/modules/launcher/Schemes.qml b/modules/launcher/Schemes.qml
new file mode 100644
index 0000000..3bdc90a
--- /dev/null
+++ b/modules/launcher/Schemes.qml
@@ -0,0 +1,67 @@
+pragma Singleton
+
+import "root:/utils/scripts/fuzzysort.js" as Fuzzy
+import "root:/config"
+import Quickshell
+import Quickshell.Io
+import QtQuick
+
+Singleton {
+ id: root
+
+ readonly property list<var> preppedActions: 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, {
+ all: true,
+ keys: ["name", "flavour"],
+ scoreFn: r => r[0].score > 0 ? r[0].score * 0.9 + r[1].score * 0.1 : 0
+ }).map(r => r.obj.scheme);
+ }
+
+ Variants {
+ id: schemes
+
+ Scheme {}
+ }
+
+ Process {
+ id: getSchemes
+
+ running: true
+ command: ["caelestia", "scheme", "list"]
+ stdout: StdioCollector {
+ onStreamFinished: {
+ const schemeData = JSON.parse(text);
+ const list = Object.entries(schemeData).map(([name, f]) => Object.entries(f).map(([flavour, colours]) => ({
+ name,
+ flavour,
+ colours
+ })));
+
+ const flat = [];
+ for (const s of list)
+ for (const f of s)
+ flat.push(f);
+
+ schemes.model = flat;
+ }
+ }
+ }
+
+ component Scheme: QtObject {
+ required property var modelData
+ readonly property string name: modelData.name
+ readonly property string flavour: modelData.flavour
+ readonly property var colours: modelData.colours
+
+ function onClicked(list: AppList): void {
+ Quickshell.execDetached(["caelestia", "scheme", "set", "-n", name, "-f", flavour]);
+ list.visibilities.launcher = false;
+ }
+ }
+}