-
Notifications
You must be signed in to change notification settings - Fork 0
/
BorderedImage.qml
62 lines (55 loc) · 1.78 KB
/
BorderedImage.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import QtQuick 2.7
import QtGraphicalEffects 1.0
import QtQuick.Layouts 1.1
Item {
property alias source: img.source
property alias sourceSize: img.sourceSize
property alias fillMode: img.fillMode
property alias asynchronous: img.asynchronous
property int borderWidth: 0
property int rating: 0
property string borderColor: "white"
property bool hovered: false
Image {
id: img
width: parent.width - 2*parent.borderWidth
height: parent.height - 2*parent.borderWidth
anchors.centerIn: parent
onStatusChanged: {
if (status == Image.Ready) {
borderrect.width = Math.min(Math.floor(img.paintedWidth), img.width) + 2*parent.borderWidth
borderrect.height = Math.min(Math.floor(img.paintedHeight), img.height) + 2*parent.borderWidth
}
}
}
ColorOverlay {
id: overlay
visible: parent.hovered
anchors.fill: img
source: img
color: "#18ffffff"
}
Rectangle {
id: borderrect
anchors.centerIn: img
width: parent.width // Math.min(Math.floor(img.paintedWidth), img.width) + 2*parent.borderWidth
height: parent.height //Math.min(Math.floor(img.paintedHeight), img.height) + 2*parent.borderWidth
border.width: parent.borderWidth
border.color: parent.borderColor
color: "transparent"
}
Row {
anchors.bottom: borderrect.bottom
anchors.left: borderrect.left
leftPadding: parent.borderWidth
bottomPadding: parent.borderWidth
Repeater {
model: rating
Image {
source: "qrc:/icons/one-star.svg"
sourceSize.width: 12
sourceSize.height: 12
}
}
}
}