import QtQuick import QtQuick.Effects import "../../theme" // A picture from disk: rounded, square or circular. Face { id: root readonly property string path: options.path || "" Image { id: picture anchors.fill: parent visible: false source: root.path ? "file://" + encodeURI(root.path).replace(/#/g, "%23").replace(/\?/g, "%3F") : "" sourceSize: Qt.size(Math.max(1, root.width) * 2, Math.max(1, root.height) * 2) fillMode: Image.PreserveAspectCrop asynchronous: true } Item { id: shape anchors.centerIn: parent width: root.variant === "round" ? Math.min(root.width, root.height) : root.width height: root.variant === "round" ? width : root.height visible: false layer.enabled: true Rectangle { anchors.fill: parent radius: root.variant === "round" ? width / 2 : root.variant === "rect" ? 0 : Theme.radius } } MultiEffect { anchors.fill: parent source: picture maskEnabled: true maskSource: shape visible: picture.status === Image.Ready } Rectangle { anchors.fill: shape visible: picture.status !== Image.Ready radius: root.variant === "round" ? width / 2 : root.variant === "rect" ? 0 : Theme.radius color: Theme.fill border.width: 1 border.color: Theme.border Text { anchors.centerIn: parent width: parent.width - 20 horizontalAlignment: Text.AlignHCenter wrapMode: Text.Wrap text: root.path ? "Cannot load image" : "Right-click to choose an image" color: Theme.textSecondary font.pixelSize: 11 } } }