Make avatar images rounded

This commit is contained in:
Ly-sec 2025-08-12 12:47:20 +02:00
parent 81382b213c
commit 54b2673f9a
3 changed files with 24 additions and 33 deletions

View file

@ -35,18 +35,13 @@ Item {
spacing: Style.marginMedium * scaling spacing: Style.marginMedium * scaling
// Avatar preview // Avatar preview
Rectangle { NImageRounded {
width: 64 * scaling width: 64 * scaling
height: 64 * scaling height: 64 * scaling
radius: width * 0.5 imagePath: Settings.data.general.avatarImage
color: Colors.accentPrimary fallbackIcon: "person"
border.color: Colors.outline borderColor: Colors.accentPrimary
border.width: Math.max(1, Style.borderThin * scaling) borderWidth: Math.max(1, Style.borderMedium * scaling)
NImageRounded {
imagePath: Settings.data.general.avatarImage
fallbackIcon: "person"
}
} }
ColumnLayout { ColumnLayout {
Layout.fillWidth: true Layout.fillWidth: true

View file

@ -25,30 +25,13 @@ NBox {
anchors.margins: Style.marginMedium * scaling anchors.margins: Style.marginMedium * scaling
spacing: Style.marginMedium * scaling spacing: Style.marginMedium * scaling
Item { NImageRounded {
id: avatarBox
width: Style.baseWidgetSize * 1.25 * scaling width: Style.baseWidgetSize * 1.25 * scaling
height: Style.baseWidgetSize * 1.25 * scaling height: Style.baseWidgetSize * 1.25 * scaling
imagePath: Settings.data.general.avatarImage
Image { fallbackIcon: "person"
id: avatarImage borderColor: Colors.accentPrimary
anchors.fill: parent borderWidth: Math.max(1, Style.borderMedium * scaling)
source: Settings.data.general.avatarImage
fillMode: Image.PreserveAspectCrop
asynchronous: true
}
// Ensure rounded corners consistently across renderers
MultiEffect {
anchors.fill: avatarImage
source: avatarImage
maskEnabled: true
maskSource: Rectangle {
anchors.fill: parent
color: "white"
radius: Style.radiusMedium * scaling
}
}
} }
ColumnLayout { ColumnLayout {

View file

@ -5,14 +5,27 @@ import Quickshell.Widgets
import qs.Services import qs.Services
Rectangle { Rectangle {
color: "transparent"
radius: width * 0.5
readonly property real scaling: Scaling.scale(screen) readonly property real scaling: Scaling.scale(screen)
property string imagePath: "" property string imagePath: ""
property string fallbackIcon: "" property string fallbackIcon: ""
property color borderColor: "transparent"
property real borderWidth: 0
anchors.fill: parent
anchors.margins: Style.marginTiniest * scaling anchors.margins: Style.marginTiniest * scaling
// Border
Rectangle {
anchors.fill: parent
radius: parent.radius
color: "transparent"
border.color: parent.borderColor
border.width: parent.borderWidth
z: 10
}
Image { Image {
id: img id: img
anchors.fill: parent anchors.fill: parent