70 lines
1.4 KiB
QML
70 lines
1.4 KiB
QML
import QtQuick
|
|
import QtQuick.Effects
|
|
import Quickshell
|
|
import Quickshell.Widgets
|
|
import qs.Services
|
|
|
|
Rectangle {
|
|
id: root
|
|
color: "transparent"
|
|
property real imageRadius: width * 0.5
|
|
radius: imageRadius
|
|
|
|
readonly property real scaling: Scaling.scale(screen)
|
|
property string imagePath: ""
|
|
property string fallbackIcon: ""
|
|
property color borderColor: "transparent"
|
|
property real borderWidth: 0
|
|
|
|
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 {
|
|
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: root.imageRadius
|
|
}
|
|
}
|
|
|
|
// 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
|
|
}
|
|
}
|