feat: dashboard pfp picker
This commit is contained in:
parent
c94b761459
commit
e0972efdb4
4 changed files with 93 additions and 9 deletions
|
|
@ -85,6 +85,7 @@ Item {
|
|||
|
||||
Dash {
|
||||
shouldUpdate: visible && this === view.currentItem
|
||||
visibilities: root.visibilities
|
||||
}
|
||||
|
||||
Media {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
function mkdir(path: url): void {
|
||||
Quickshell.execDetached(["mkdir", "-p", strip(path)]);
|
||||
}
|
||||
|
||||
property string path
|
||||
|
||||
command: ["mkdir", "-p", path]
|
||||
function copy(from: url, to: url): void {
|
||||
Quickshell.execDetached(["cp", strip(from), strip(to)]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue