From e0972efdb4b906c719c5f5f80f3040e28a869843 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Wed, 18 Jun 2025 22:33:38 +1000 Subject: feat: dashboard pfp picker --- modules/dashboard/Content.qml | 1 + modules/dashboard/Dash.qml | 3 ++ modules/dashboard/dash/User.qml | 82 +++++++++++++++++++++++++++++++++++++++++ utils/Paths.qml | 16 ++++---- 4 files changed, 93 insertions(+), 9 deletions(-) diff --git a/modules/dashboard/Content.qml b/modules/dashboard/Content.qml index 84079ef..dedee33 100644 --- a/modules/dashboard/Content.qml +++ b/modules/dashboard/Content.qml @@ -85,6 +85,7 @@ Item { Dash { shouldUpdate: visible && this === view.currentItem + visibilities: root.visibilities } Media { diff --git a/modules/dashboard/Dash.qml b/modules/dashboard/Dash.qml index 22132af..869ad90 100644 --- a/modules/dashboard/Dash.qml +++ b/modules/dashboard/Dash.qml @@ -8,6 +8,7 @@ GridLayout { id: root required property bool shouldUpdate + required property var visibilities rowSpacing: Appearance.spacing.normal columnSpacing: Appearance.spacing.normal @@ -20,6 +21,8 @@ GridLayout { User { id: user + + visibilities: root.visibilities } } diff --git a/modules/dashboard/dash/User.qml b/modules/dashboard/dash/User.qml index bf989c6..ead6fcd 100644 --- a/modules/dashboard/dash/User.qml +++ b/modules/dashboard/dash/User.qml @@ -5,10 +5,13 @@ import "root:/utils" import Quickshell import Quickshell.Io import QtQuick +import QtQuick.Dialogs Row { id: root + required property PersistentProperties visibilities + padding: Appearance.padding.large spacing: Appearance.spacing.normal @@ -28,9 +31,88 @@ Row { } CachingImage { + id: pfp + anchors.fill: parent path: `${Paths.home}/.face` } + + MouseArea { + anchors.fill: parent + + cursorShape: Qt.PointingHandCursor + hoverEnabled: true + + onClicked: { + root.visibilities.launcher = false; + dialog.open(); + } + + StyledRect { + anchors.fill: parent + + color: Qt.alpha(Colours.palette.m3primary, 0.1) + opacity: parent.containsMouse ? 1 : 0 + + Behavior on opacity { + NumberAnimation { + duration: Appearance.anim.durations.normal + easing.type: Easing.BezierSpline + easing.bezierCurve: Appearance.anim.curves.standard + } + } + } + + StyledRect { + anchors.centerIn: parent + + implicitWidth: selectIcon.implicitHeight + Appearance.padding.small * 2 + implicitHeight: selectIcon.implicitHeight + Appearance.padding.small * 2 + + radius: Appearance.rounding.normal + color: Colours.palette.m3primary + scale: parent.containsMouse ? 1 : 0.5 + opacity: parent.containsMouse ? 1 : 0 + + MaterialIcon { + id: selectIcon + + anchors.centerIn: parent + anchors.horizontalCenterOffset: -font.pointSize * 0.02 + + text: "frame_person" + color: Colours.palette.m3onPrimary + font.pointSize: Appearance.font.size.extraLarge + } + + Behavior on scale { + NumberAnimation { + duration: Appearance.anim.durations.expressiveFastSpatial + easing.type: Easing.BezierSpline + easing.bezierCurve: Appearance.anim.curves.expressiveFastSpatial + } + } + + Behavior on opacity { + NumberAnimation { + duration: Appearance.anim.durations.expressiveFastSpatial + easing.type: Easing.BezierSpline + easing.bezierCurve: Appearance.anim.curves.expressiveFastSpatial + } + } + } + } + + FileDialog { + id: dialog + + nameFilters: [`Image files (${Wallpapers.extensions.map(e => `*.${e}`).join(" ")})`] + + onAccepted: { + Paths.copy(selectedFile, `${Paths.home}/.face`); + pfp.pathChanged(); + } + } } Column { diff --git a/utils/Paths.qml b/utils/Paths.qml index bd57608..cc8c712 100644 --- a/utils/Paths.qml +++ b/utils/Paths.qml @@ -1,7 +1,6 @@ pragma Singleton import Quickshell -import Quickshell.Io import Qt.labs.platform Singleton { @@ -17,16 +16,15 @@ Singleton { readonly property url imagecache: `${cache}/imagecache` - function mkdir(path: url): void { - mkdirProc.path = path.toString().replace("file://", ""); - mkdirProc.startDetached(); + function strip(path: url): string { + return path.toString().replace("file://", ""); } - Process { - id: mkdirProc - - property string path + function mkdir(path: url): void { + Quickshell.execDetached(["mkdir", "-p", strip(path)]); + } - command: ["mkdir", "-p", path] + function copy(from: url, to: url): void { + Quickshell.execDetached(["cp", strip(from), strip(to)]); } } -- cgit v1.2.3-freya