Attempt to round image with mask
This commit is contained in:
parent
1e0057dcaf
commit
81382b213c
4 changed files with 65 additions and 12 deletions
|
|
@ -176,7 +176,7 @@ NLoader {
|
|||
text: settingsPanel.tabsModel[settingsPanel.currentTabIndex].label
|
||||
font.pointSize: Style.fontSizeLarge * scaling
|
||||
font.weight: Style.fontWeightBold
|
||||
color: Colors.accentPrimary
|
||||
color: Colors.textPrimary
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
NIconButton {
|
||||
|
|
|
|||
|
|
@ -36,21 +36,18 @@ Item {
|
|||
|
||||
// Avatar preview
|
||||
Rectangle {
|
||||
width: 40 * scaling
|
||||
height: 40 * scaling
|
||||
radius: 20 * scaling
|
||||
color: Colors.surfaceVariant
|
||||
width: 64 * scaling
|
||||
height: 64 * scaling
|
||||
radius: width * 0.5
|
||||
color: Colors.accentPrimary
|
||||
border.color: Colors.outline
|
||||
border.width: Math.max(1, Style.borderThin * scaling)
|
||||
Image {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 2 * scaling
|
||||
source: Settings.data.general.avatarImage
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
asynchronous: true
|
||||
}
|
||||
}
|
||||
|
||||
NImageRounded {
|
||||
imagePath: Settings.data.general.avatarImage
|
||||
fallbackIcon: "person"
|
||||
}
|
||||
}
|
||||
ColumnLayout {
|
||||
Layout.fillWidth: true
|
||||
spacing: 2 * scaling
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ Singleton {
|
|||
property int pillDelay: 500
|
||||
|
||||
// Margins (for margins and spacing)
|
||||
property int marginTiniest: 2
|
||||
property int marginTiny: 4
|
||||
property int marginSmall: 8
|
||||
property int marginMedium: 12
|
||||
|
|
|
|||
55
Widgets/NImageRounded.qml
Normal file
55
Widgets/NImageRounded.qml
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
import QtQuick
|
||||
import QtQuick.Effects
|
||||
import Quickshell
|
||||
import Quickshell.Widgets
|
||||
import qs.Services
|
||||
|
||||
Rectangle {
|
||||
|
||||
readonly property real scaling: Scaling.scale(screen)
|
||||
property string imagePath: ""
|
||||
property string fallbackIcon: ""
|
||||
|
||||
anchors.fill: parent
|
||||
anchors.margins: Style.marginTiniest * scaling
|
||||
|
||||
Image {
|
||||
id: img
|
||||
anchors.fill: parent
|
||||
source: imagePath
|
||||
visible: false
|
||||
mipmap: true
|
||||
smooth: true
|
||||
asynchronous: true
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
}
|
||||
|
||||
MultiEffect {
|
||||
anchors.fill: parent
|
||||
source: img
|
||||
maskEnabled: true
|
||||
maskSource: mask
|
||||
visible: imagePath !== ""
|
||||
}
|
||||
|
||||
Item {
|
||||
id: mask
|
||||
anchors.fill: parent
|
||||
layer.enabled: true
|
||||
visible: false
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
radius: img.width * 0.5
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback icon
|
||||
NText {
|
||||
anchors.centerIn: parent
|
||||
text: fallbackIcon
|
||||
font.family: "Material Symbols Outlined"
|
||||
font.pointSize: Style.fontSizeXL * scaling
|
||||
visible: fallbackIcon !== undefined && fallbackIcon !== "" && (source === undefined || source === "")
|
||||
z: 0
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue