diff options
Diffstat (limited to 'modules/launcher/items')
| -rw-r--r-- | modules/launcher/items/ActionItem.qml | 70 | ||||
| -rw-r--r-- | modules/launcher/items/AppItem.qml | 73 | ||||
| -rw-r--r-- | modules/launcher/items/CalcItem.qml | 162 | ||||
| -rw-r--r-- | modules/launcher/items/SchemeItem.qml | 92 | ||||
| -rw-r--r-- | modules/launcher/items/VariantItem.qml | 70 | ||||
| -rw-r--r-- | modules/launcher/items/WallpaperItem.qml | 96 |
6 files changed, 563 insertions, 0 deletions
diff --git a/modules/launcher/items/ActionItem.qml b/modules/launcher/items/ActionItem.qml new file mode 100644 index 0000000..acacede --- /dev/null +++ b/modules/launcher/items/ActionItem.qml @@ -0,0 +1,70 @@ +import "../services" +import qs.widgets +import qs.services +import qs.config +import QtQuick + +Item { + id: root + + required property Actions.Action 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.normal + 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?.desc ?? "" + 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 + } + } + } +} diff --git a/modules/launcher/items/AppItem.qml b/modules/launcher/items/AppItem.qml new file mode 100644 index 0000000..6c77166 --- /dev/null +++ b/modules/launcher/items/AppItem.qml @@ -0,0 +1,73 @@ +import "../services" +import qs.widgets +import qs.services +import qs.config +import Quickshell +import Quickshell.Widgets +import QtQuick + +Item { + id: root + + required property DesktopEntry 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 + + IconImage { + id: icon + + source: Quickshell.iconPath(root.modelData?.icon, "image-missing") + implicitSize: parent.height * 0.8 + + anchors.verticalCenter: parent.verticalCenter + } + + Item { + anchors.left: icon.right + anchors.leftMargin: Appearance.spacing.normal + anchors.verticalCenter: icon.verticalCenter + + implicitWidth: parent.width - icon.width + implicitHeight: name.implicitHeight + comment.implicitHeight + + StyledText { + id: name + + text: root.modelData?.name ?? "" + font.pointSize: Appearance.font.size.normal + } + + StyledText { + id: comment + + text: (root.modelData?.comment || root.modelData?.genericName || root.modelData?.name) ?? "" + 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 + } + } + } +} diff --git a/modules/launcher/items/CalcItem.qml b/modules/launcher/items/CalcItem.qml new file mode 100644 index 0000000..2e3c901 --- /dev/null +++ b/modules/launcher/items/CalcItem.qml @@ -0,0 +1,162 @@ +import qs.widgets +import qs.services +import qs.config +import Quickshell +import Quickshell.Io +import QtQuick +import QtQuick.Layouts + +Item { + id: root + + required property var list + readonly property string math: list.search.text.slice(`${Config.launcher.actionPrefix}calc `.length) + + function onClicked(): void { + Quickshell.execDetached(["sh", "-c", `qalc -t -m 100 '${root.math}' | wl-copy`]); + root.list.visibilities.launcher = false; + } + + implicitHeight: Config.launcher.sizes.itemHeight + + anchors.left: parent?.left + anchors.right: parent?.right + + onMathChanged: { + if (math) { + qalcProc.command = ["qalc", "-m", "100", math]; + qalcProc.running = true; + } + } + + StateLayer { + radius: Appearance.rounding.full + + function onClicked(): void { + root.onClicked(); + } + } + + Binding { + id: binding + + when: root.math.length > 0 + target: metrics + property: "text" + } + + Process { + id: qalcProc + + stdout: StdioCollector { + onStreamFinished: binding.value = text.trim() + } + } + + RowLayout { + anchors.left: parent.left + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + anchors.margins: Appearance.padding.larger + + spacing: Appearance.spacing.normal + + MaterialIcon { + text: "function" + font.pointSize: Appearance.font.size.extraLarge + Layout.alignment: Qt.AlignVCenter + } + + StyledText { + id: result + + color: { + if (metrics.text.includes("error: ")) + return Colours.palette.m3error; + if (!root.math) + return Colours.palette.m3onSurfaceVariant; + return Colours.palette.m3onSurface; + } + + text: metrics.elidedText + font.pointSize: Appearance.font.size.normal + + Layout.fillWidth: true + Layout.alignment: Qt.AlignVCenter + + TextMetrics { + id: metrics + + text: qsTr("Type an expression to calculate") + font.family: result.font.family + font.pointSize: result.font.pointSize + elide: Text.ElideRight + elideWidth: result.width + } + } + + StyledRect { + color: Colours.palette.m3tertiary + radius: Appearance.rounding.normal + clip: true + + implicitWidth: (stateLayer.containsMouse ? label.implicitWidth + label.anchors.rightMargin : 0) + icon.implicitWidth + Appearance.padding.normal * 2 + implicitHeight: Math.max(label.implicitHeight, icon.implicitHeight) + Appearance.padding.small * 2 + + Layout.alignment: Qt.AlignVCenter + + StateLayer { + id: stateLayer + + color: Colours.palette.m3onTertiary + + function onClicked(): void { + Quickshell.execDetached(["app2unit", "--", "foot", "fish", "-C", `exec qalc -i '${root.math}'`]); + root.list.visibilities.launcher = false; + } + } + + StyledText { + id: label + + anchors.verticalCenter: parent.verticalCenter + anchors.right: icon.left + anchors.rightMargin: Appearance.spacing.small + + text: qsTr("Open in calculator") + color: Colours.palette.m3onTertiary + font.pointSize: Appearance.font.size.normal + + opacity: stateLayer.containsMouse ? 1 : 0 + + Behavior on opacity { + NumberAnimation { + duration: Appearance.anim.durations.normal + easing.type: Easing.BezierSpline + easing.bezierCurve: Appearance.anim.curves.standard + } + } + } + + MaterialIcon { + id: icon + + anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.right + anchors.rightMargin: Appearance.padding.normal + + text: "open_in_new" + color: Colours.palette.m3onTertiary + font.pointSize: Appearance.font.size.large + } + + Behavior on implicitWidth { + NumberAnimation { + duration: Appearance.anim.durations.normal + easing.type: Easing.BezierSpline + easing.bezierCurve: Appearance.anim.curves.emphasized + } + } + } + } +} diff --git a/modules/launcher/items/SchemeItem.qml b/modules/launcher/items/SchemeItem.qml new file mode 100644 index 0000000..94c1818 --- /dev/null +++ b/modules/launcher/items/SchemeItem.qml @@ -0,0 +1,92 @@ +import "../services" +import qs.widgets +import qs.services +import qs.config +import QtQuick + +Item { + id: root + + required property Schemes.Scheme 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 + + 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/items/VariantItem.qml b/modules/launcher/items/VariantItem.qml new file mode 100644 index 0000000..973564a --- /dev/null +++ b/modules/launcher/items/VariantItem.qml @@ -0,0 +1,70 @@ +import "../services" +import qs.widgets +import qs.services +import qs.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 + } + } + } +} diff --git a/modules/launcher/items/WallpaperItem.qml b/modules/launcher/items/WallpaperItem.qml new file mode 100644 index 0000000..e3d84d4 --- /dev/null +++ b/modules/launcher/items/WallpaperItem.qml @@ -0,0 +1,96 @@ +import qs.widgets +import qs.services +import qs.config +import Quickshell +import Quickshell.Widgets +import QtQuick +import QtQuick.Effects + +StyledRect { + id: root + + required property Wallpapers.Wallpaper modelData + required property PersistentProperties visibilities + + scale: 0.5 + opacity: 0 + z: PathView.z ?? 0 + + Component.onCompleted: { + scale = Qt.binding(() => PathView.isCurrentItem ? 1 : PathView.onPath ? 0.8 : 0); + opacity = Qt.binding(() => PathView.onPath ? 1 : 0); + } + + implicitWidth: image.width + Appearance.padding.larger * 2 + implicitHeight: image.height + label.height + Appearance.spacing.small / 2 + Appearance.padding.large + Appearance.padding.normal + + StateLayer { + radius: Appearance.rounding.normal + + function onClicked(): void { + Wallpapers.setWallpaper(root.modelData.path); + root.visibilities.launcher = false; + } + } + + RectangularShadow { + opacity: root.PathView.isCurrentItem ? 0.7 : 0 + anchors.fill: image + radius: image.radius + color: Colours.palette.m3shadow + blur: 10 + spread: 3 + + Behavior on opacity { + Anim {} + } + } + + ClippingRectangle { + id: image + + anchors.horizontalCenter: parent.horizontalCenter + y: Appearance.padding.large + color: "transparent" + radius: Appearance.rounding.normal + + implicitWidth: Config.launcher.sizes.wallpaperWidth + implicitHeight: implicitWidth / 16 * 9 + + CachingImage { + path: root.modelData.path + smooth: !root.PathView.view.moving + + anchors.fill: parent + } + } + + StyledText { + id: label + + anchors.top: image.bottom + anchors.topMargin: Appearance.spacing.small / 2 + anchors.horizontalCenter: parent.horizontalCenter + + width: image.width - Appearance.padding.normal * 2 + horizontalAlignment: Text.AlignHCenter + elide: Text.ElideRight + renderType: Text.QtRendering + text: root.modelData.name + font.pointSize: Appearance.font.size.normal + } + + Behavior on scale { + Anim {} + } + + Behavior on opacity { + Anim {} + } + + component Anim: NumberAnimation { + duration: Appearance.anim.durations.normal + easing.type: Easing.BezierSpline + easing.bezierCurve: Appearance.anim.curves.standard + } +} |