2020-09-29 09:06:57 +00:00
|
|
|
import QtQuick 2.13
|
2020-11-12 14:33:18 +00:00
|
|
|
import QtGraphicalEffects 1.13
|
2020-09-29 09:06:57 +00:00
|
|
|
import QtQuick.Controls 2.13
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared 1.0
|
|
|
|
import shared.panels 1.0
|
2020-09-29 09:06:57 +00:00
|
|
|
|
2021-03-10 04:59:01 +00:00
|
|
|
Row {
|
2020-09-29 09:06:57 +00:00
|
|
|
id: imageArea
|
2021-07-13 07:34:13 +00:00
|
|
|
spacing: 0
|
2020-09-29 09:06:57 +00:00
|
|
|
|
2021-03-10 04:59:01 +00:00
|
|
|
signal imageRemoved(int index)
|
|
|
|
property alias imageSource: rptImages.model
|
|
|
|
|
|
|
|
Repeater {
|
|
|
|
id: rptImages
|
2021-07-13 07:34:13 +00:00
|
|
|
|
2021-03-10 04:59:01 +00:00
|
|
|
Item {
|
2021-07-13 07:34:13 +00:00
|
|
|
height: Style.current.halfPadding * 2 + chatImage.height + closeBtn.height / 3
|
|
|
|
width: chatImage.width + closeBtn.width / 3
|
|
|
|
|
2021-03-10 04:59:01 +00:00
|
|
|
Image {
|
|
|
|
id: chatImage
|
2021-07-13 07:34:13 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2021-03-10 04:59:01 +00:00
|
|
|
width: 64
|
|
|
|
height: 64
|
|
|
|
fillMode: Image.PreserveAspectCrop
|
|
|
|
mipmap: true
|
|
|
|
smooth: false
|
|
|
|
antialiasing: true
|
|
|
|
source: modelData
|
|
|
|
layer.enabled: true
|
|
|
|
layer.effect: OpacityMask {
|
|
|
|
maskSource: Item {
|
|
|
|
width: chatImage.width
|
|
|
|
height: chatImage.height
|
2020-11-12 14:33:18 +00:00
|
|
|
|
2021-03-10 04:59:01 +00:00
|
|
|
Rectangle {
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.left: parent.left
|
|
|
|
width: chatImage.width
|
|
|
|
height: chatImage.height
|
|
|
|
radius: 16
|
|
|
|
}
|
|
|
|
Rectangle {
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.right: parent.right
|
|
|
|
width: 32
|
|
|
|
height: 32
|
|
|
|
radius: 4
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-07-13 07:34:13 +00:00
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
id: mouseArea
|
|
|
|
anchors.fill: parent
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
hoverEnabled: true
|
|
|
|
onClicked: {
|
|
|
|
imagePopup.openPopup(chatImage)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-10 04:59:01 +00:00
|
|
|
RoundButton {
|
|
|
|
id: closeBtn
|
2021-07-13 07:34:13 +00:00
|
|
|
width: 24
|
|
|
|
height: 24
|
2021-03-10 04:59:01 +00:00
|
|
|
padding: 0
|
|
|
|
anchors.right: chatImage.right
|
2021-07-13 07:34:13 +00:00
|
|
|
anchors.rightMargin: -width / 3
|
|
|
|
anchors.top: chatImage.top
|
|
|
|
anchors.topMargin: -height / 3
|
|
|
|
hoverEnabled: false
|
|
|
|
opacity: mouseArea.containsMouse || buttonMouseArea.containsMouse ? 1 : 0
|
2021-03-10 04:59:01 +00:00
|
|
|
contentItem: SVGImage {
|
2021-09-28 15:04:06 +00:00
|
|
|
source: Style.svg( !buttonMouseArea.containsMouse ? "close-filled" : "close-filled-hovered")
|
2021-03-10 04:59:01 +00:00
|
|
|
width: closeBtn.width
|
|
|
|
height: closeBtn.height
|
|
|
|
}
|
|
|
|
background: Rectangle {
|
|
|
|
color: "transparent"
|
|
|
|
}
|
|
|
|
onClicked: {
|
|
|
|
imageArea.imageRemoved(index)
|
|
|
|
const tmp = imageArea.imageSource.filter((url, idx) => idx !== index)
|
|
|
|
rptImages.model = tmp
|
2020-11-12 14:33:18 +00:00
|
|
|
}
|
2021-03-10 04:59:01 +00:00
|
|
|
MouseArea {
|
2021-07-13 07:34:13 +00:00
|
|
|
id: buttonMouseArea
|
2021-03-10 04:59:01 +00:00
|
|
|
anchors.fill: parent
|
2021-07-13 07:34:13 +00:00
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
hoverEnabled: true
|
|
|
|
onClicked: closeBtn.clicked()
|
2020-11-12 14:33:18 +00:00
|
|
|
}
|
2020-09-29 09:06:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|