fix(@desktop/timeline): timeline and images area bugfixes

This commit is contained in:
Andrei Smirnov 2021-07-13 10:34:13 +03:00 committed by Iuri Matias
parent aa5f861cb8
commit fcc2a9e025
5 changed files with 89 additions and 81 deletions

View File

@ -113,6 +113,13 @@ ScrollView {
model: messageListDelegate model: messageListDelegate
section.property: "sectionIdentifier" section.property: "sectionIdentifier"
section.criteria: ViewSection.FullString section.criteria: ViewSection.FullString
Connections {
target: chatsModel.messageView
onMessagesLoaded: {
Qt.callLater(chatLogView.positionViewAtBeginning)
}
}
} }
DelegateModelGeneralized { DelegateModelGeneralized {

View File

@ -549,11 +549,11 @@ QtObject {
} }
function hasImageExtension(url) { function hasImageExtension(url) {
return Constants.acceptedImageExtensions.some(ext => url.includes(ext)) return Constants.acceptedImageExtensions.some(ext => url.toLowerCase().includes(ext))
} }
function hasDragNDropImageExtension(url) { function hasDragNDropImageExtension(url) {
return Constants.acceptedDragNDropImageExtensions.some(ext => url.includes(ext)) return Constants.acceptedDragNDropImageExtensions.some(ext => url.toLowerCase().includes(ext))
} }
function deduplicate(array) { function deduplicate(array) {

View File

@ -10,11 +10,7 @@ StatusChatImageValidator {
errorMessage: qsTr("You can only upload %1 images at a time").arg(Constants.maxUploadFiles) errorMessage: qsTr("You can only upload %1 images at a time").arg(Constants.maxUploadFiles)
onImagesChanged: { onImagesChanged: {
let isValid = true root.isValid = images.length <= Constants.maxUploadFiles
if (images.length > Constants.maxUploadFiles) {
isValid = false
}
root.isValid = isValid
root.validImages = images.slice(0, Constants.maxUploadFiles) root.validImages = images.slice(0, Constants.maxUploadFiles)
} }
} }

View File

@ -805,7 +805,7 @@ Rectangle {
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: control.isStatusUpdateInput ? actions.width + 2* Style.current.padding : Style.current.halfPadding anchors.rightMargin: control.isStatusUpdateInput ? actions.width + 2* Style.current.padding : Style.current.halfPadding
anchors.top: parent.top anchors.top: parent.top
anchors.topMargin: control.isStatusUpdateInput ? 0 : Style.current.halfPadding anchors.topMargin: Style.current.halfPadding
visible: isImage visible: isImage
width: messageInputField.width - actions.width width: messageInputField.width - actions.width
onImageRemoved: { onImageRemoved: {

View File

@ -6,19 +6,22 @@ import "../../shared"
Row { Row {
id: imageArea id: imageArea
spacing: Style.current.halfPadding spacing: 0
signal imageRemoved(int index) signal imageRemoved(int index)
property alias imageSource: rptImages.model property alias imageSource: rptImages.model
Repeater { Repeater {
id: rptImages id: rptImages
Item { Item {
height: chatImage.paintedHeight + closeBtn.height - 5 height: Style.current.halfPadding * 2 + chatImage.height + closeBtn.height / 3
width: chatImage.width width: chatImage.width + closeBtn.width / 3
Image { Image {
id: chatImage id: chatImage
property bool hovered: false anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
width: 64 width: 64
height: 64 height: 64
fillMode: Image.PreserveAspectCrop fillMode: Image.PreserveAspectCrop
@ -26,18 +29,6 @@ Row {
smooth: false smooth: false
antialiasing: true antialiasing: true
source: modelData source: modelData
MouseArea {
cursorShape: Qt.PointingHandCursor
anchors.fill: parent
hoverEnabled: true
onEntered: {
chatImage.hovered = true
}
onExited: {
chatImage.hovered = false
}
}
layer.enabled: true layer.enabled: true
layer.effect: OpacityMask { layer.effect: OpacityMask {
maskSource: Item { maskSource: Item {
@ -61,19 +52,31 @@ Row {
} }
} }
} }
MouseArea {
id: mouseArea
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
hoverEnabled: true
onClicked: {
console.log("opening image...")
imagePopup.openPopup(chatImage)
}
}
RoundButton { RoundButton {
id: closeBtn id: closeBtn
implicitWidth: 24 width: 24
implicitHeight: 24 height: 24
padding: 0 padding: 0
anchors.top: chatImage.top
anchors.topMargin: -5
anchors.right: chatImage.right anchors.right: chatImage.right
anchors.rightMargin: -Style.current.halfPadding anchors.rightMargin: -width / 3
visible: chatImage.hovered || hovered anchors.top: chatImage.top
anchors.topMargin: -height / 3
hoverEnabled: false
opacity: mouseArea.containsMouse || buttonMouseArea.containsMouse ? 1 : 0
contentItem: SVGImage { contentItem: SVGImage {
source: !closeBtn.hovered ? source: !buttonMouseArea.containsMouse ? "../../app/img/close-filled.svg" : "../../app/img/close-filled-hovered.svg"
"../../app/img/close-filled.svg" : "../../app/img/close-filled-hovered.svg"
width: closeBtn.width width: closeBtn.width
height: closeBtn.height height: closeBtn.height
} }
@ -86,9 +89,11 @@ Row {
rptImages.model = tmp rptImages.model = tmp
} }
MouseArea { MouseArea {
cursorShape: Qt.PointingHandCursor id: buttonMouseArea
anchors.fill: parent anchors.fill: parent
onPressed: mouse.accepted = false cursorShape: Qt.PointingHandCursor
hoverEnabled: true
onClicked: closeBtn.clicked()
} }
} }
} }