mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
60 lines
1.3 KiB
QML
60 lines
1.3 KiB
QML
import QtQuick
|
|
import QtQuick.Effects
|
|
import Quickshell
|
|
import Quickshell.Widgets
|
|
import qs.Commons
|
|
|
|
Item {
|
|
id: root
|
|
|
|
property real radius: 0
|
|
property string imagePath: ""
|
|
property string fallbackIcon: ""
|
|
property real fallbackIconSize: Style.fontSizeXXL
|
|
property real borderWidth: 0
|
|
property color borderColor: Color.transparent
|
|
|
|
readonly property bool showFallback: (fallbackIcon !== undefined && fallbackIcon !== "") && (imagePath === undefined || imagePath === "")
|
|
|
|
signal statusChanged(int status)
|
|
|
|
ClippingWrapperRectangle {
|
|
anchors.fill: parent
|
|
color: Color.transparent
|
|
radius: root.radius
|
|
border.color: root.borderColor
|
|
border.width: root.borderWidth
|
|
|
|
Item {
|
|
anchors.fill: parent
|
|
Loader {
|
|
active: true
|
|
anchors.fill: parent
|
|
sourceComponent: showFallback ? fallback : image
|
|
}
|
|
|
|
Component {
|
|
id: image
|
|
Image {
|
|
source: imagePath
|
|
mipmap: true
|
|
smooth: true
|
|
asynchronous: true
|
|
antialiasing: true
|
|
fillMode: Image.PreserveAspectCrop
|
|
onStatusChanged: root.statusChanged(status)
|
|
}
|
|
}
|
|
|
|
Component {
|
|
id: fallback
|
|
NIcon {
|
|
anchors.centerIn: parent
|
|
icon: fallbackIcon
|
|
pointSize: fallbackIconSize
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|