feat(Components): introduce StatusRoundedImage

A component that renders an image as a circle, given some URL.

Usage:

```
StatusRoundedImage {
    image.source: "..." // some url
}
```

Closes #32
This commit is contained in:
Pascal Precht 2021-05-06 09:52:47 +02:00 committed by Michał Cieślak
parent ac90eff84c
commit 50506b40a1
3 changed files with 36 additions and 0 deletions

View File

@ -17,4 +17,8 @@ GridLayout {
StatusLetterIdenticon {
name: "#status"
}
StatusRoundedImage {
image.source: "https://pbs.twimg.com/profile_images/1369221718338895873/T_5fny6o_400x400.jpg"
}
}

View File

@ -0,0 +1,31 @@
import QtQuick 2.13
import QtGraphicalEffects 1.0
import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1
Rectangle {
id: statusRoundImage
property alias image: image
implicitWidth: 40
implicitHeight: 40
color: "transparent"
radius: width / 2
layer.enabled: true
layer.effect: OpacityMask {
maskSource: Rectangle {
x: statusRoundImage.x; y: statusRoundImage.y
width: statusRoundImage.width
height: statusRoundImage.height
radius: statusRoundImage.radius
}
}
Image {
id: image
sourceSize.width: parent.implicitWidth
sourceSize.height: parent.implicitHeight
fillMode: Image.PreserveAspectFit
cache: true
}
}

View File

@ -2,3 +2,4 @@ module StatusQ.Components
StatusLetterIdenticon 0.1 StatusLetterIdenticon.qml
StatusLoadingIndicator 0.1 StatusLoadingIndicator.qml
StatusRoundedImage 0.1 StatusRoundedImage.qml