nosignal-shell/modules/dashboard/dash/User.qml
Amstel 9308c9b67f Dashboard Avatar Picker 1.0a
This will allows users to update/change their profile icon from the dashboard by clicking the profile icon.

### How it works?
> Once the profile icon is clicked it will launch zenity file picker.

Once selected the target new profile Icon this script will do the following:

- Deletes the current ~/.face
- Deletes all .face cached files in ~/.cache/caelestia/thumbnails/
- Copies the new selected profile-icon to ~/.face

### Issues
- Once the profile is update, the user must manually reload the shell by restarting the shell session.

**NOTE:**
Make sure to chmod +x the picker.sh before using.

Dependencies:
- zenity
2025-06-11 14:50:31 +08:00

166 lines
4.3 KiB
QML

import "root:/widgets"
import "root:/services"
import "root:/config"
import "root:/utils"
import Quickshell
import Quickshell.Io
import QtQuick
Row {
id: root
padding: Appearance.padding.large
spacing: Appearance.spacing.large
StyledClippingRect {
implicitWidth: info.implicitHeight
implicitHeight: info.implicitHeight
radius: Appearance.rounding.full
color: Colours.palette.m3surfaceContainerHigh
CachingImage {
anchors.fill: parent
path: `${Paths.home}/.face`
fillMode: Image.PreserveAspectCrop
smooth: true
}
Rectangle {
id: overlay
anchors.fill: parent
radius: avatarRect.radius
color: Qt.rgba(0, 0, 0, 0.4)
opacity: mouseArea.containsMouse ? 1.0 : 0.0
visible: opacity > 0
Behavior on opacity {
NumberAnimation {
duration: 300
easing.type: Easing.InOutQuad
}
}
MaterialIcon {
anchors.centerIn: parent
text: "photo_camera"
color: "white"
font.pointSize: info.implicitHeight / 4
}
}
MouseArea {
id: mouseArea
anchors.fill: parent
hoverEnabled: true
onClicked: avatarUpdateProc.running = true
cursorShape: Qt.PointingHandCursor
}
Process {
id: avatarUpdateProc
running: false
command: [`${Paths.home}/.local/share/caelestia/shell/scripts/caelestia-avatar-picker.sh`]
stdout: SplitParser {
onRead: {
notifyProc.running = true
}
}
}
Process {
id: notifyProc
running: false
command: [
"notify-send",
"-u", "low",
"-i", "dialog-information-symbolic",
"Profile Updated",
"Your avatar has been successfully changed.",
"-a", "Shell",
"-A", "OK=Got it!"
]
}
}
Column {
id: info
spacing: Appearance.spacing.normal
InfoLine {
icon: Icons.osIcon
text: Icons.osName
colour: Colours.palette.m3primary
}
InfoLine {
icon: "select_window_2"
text: Quickshell.env("XDG_CURRENT_DESKTOP") || Quickshell.env("XDG_SESSION_DESKTOP")
colour: Colours.palette.m3secondary
}
InfoLine {
icon: "timer"
text: uptimeProc.uptime
colour: Colours.palette.m3tertiary
Timer {
running: true
repeat: true
interval: 15000
onTriggered: uptimeProc.running = true
}
Process {
id: uptimeProc
property string uptime
running: true
command: ["uptime", "-p"]
stdout: SplitParser {
onRead: data => uptimeProc.uptime = data
}
}
}
}
component InfoLine: Item {
id: line
required property string icon
required property string text
required property color colour
implicitWidth: icon.implicitWidth + text.width + text.anchors.leftMargin
implicitHeight: Math.max(icon.implicitHeight, text.implicitHeight)
MaterialIcon {
id: icon
anchors.left: parent.left
anchors.leftMargin: (DashboardConfig.sizes.infoIconSize - implicitWidth) / 2
text: line.icon
color: line.colour
font.pointSize: Appearance.font.size.normal
font.variableAxes: ({
FILL: 1
})
}
StyledText {
id: text
anchors.verticalCenter: icon.verticalCenter
anchors.left: icon.right
anchors.leftMargin: icon.anchors.leftMargin
text: `: ${line.text}`
font.pointSize: Appearance.font.size.normal
width: DashboardConfig.sizes.infoWidth
elide: Text.ElideRight
}
}
}