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
section.property: "sectionIdentifier"
section.criteria: ViewSection.FullString
Connections {
target: chatsModel.messageView
onMessagesLoaded: {
Qt.callLater(chatLogView.positionViewAtBeginning)
}
}
}
DelegateModelGeneralized {

View File

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

View File

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

View File

@ -224,10 +224,10 @@ Rectangle {
function parseMarkdown(markdownText) {
const htmlText = markdownText
.replace(/\~\~([^*]+)\~\~/gim, '~~<span style="text-decoration: line-through">$1</span>~~')
.replace(/\*\*([^*]+)\*\*/gim, ':asterisk::asterisk:<b>$1</b>:asterisk::asterisk:')
.replace(/\`([^*]+)\`/gim, '`<code>$1</code>`')
.replace(/\*([^*]+)\*/gim, ':asterisk:<i>$1</i>:asterisk:')
.replace(/\~\~([^*]+)\~\~/gim, '~~<span style="text-decoration: line-through">$1</span>~~')
.replace(/\*\*([^*]+)\*\*/gim, ':asterisk::asterisk:<b>$1</b>:asterisk::asterisk:')
.replace(/\`([^*]+)\`/gim, '`<code>$1</code>`')
.replace(/\*([^*]+)\*/gim, ':asterisk:<i>$1</i>:asterisk:')
return htmlText.replace(/\:asterisk\:/gim, "*")
}
@ -326,9 +326,9 @@ Rectangle {
insertInTextInput(0, finalText)
} else {
if (event.key === Qt.Key_Asterisk ||
event.key === Qt.Key_QuoteLeft ||
event.key === Qt.Key_Space ||
event.key === Qt.Key_AsciiTilde) {
event.key === Qt.Key_QuoteLeft ||
event.key === Qt.Key_Space ||
event.key === Qt.Key_AsciiTilde) {
formatInputMessage()
}
}
@ -502,9 +502,9 @@ Rectangle {
function isKeyValid(key) {
if (key === Qt.Key_Space || key === Qt.Key_Tab ||
(key >= Qt.Key_Exclam && key <= Qt.Key_Slash) ||
(key >= Qt.Key_Semicolon && key <= Qt.Key_Question) ||
(key >= Qt.Key_BracketLeft && key <= Qt.Key_hyphen))
(key >= Qt.Key_Exclam && key <= Qt.Key_Slash) ||
(key >= Qt.Key_Semicolon && key <= Qt.Key_Question) ||
(key >= Qt.Key_BracketLeft && key <= Qt.Key_hyphen))
return false;
return true;
}
@ -553,12 +553,12 @@ Rectangle {
Connections {
target: applicationWindow.dragAndDrop
onDroppedOnValidScreen: (drop) => {
let validImages = validateImages(drop.urls)
if (validImages.length > 0) {
showImageArea(validImages)
drop.acceptProposedAction()
}
}
let validImages = validateImages(drop.urls)
if (validImages.length > 0) {
showImageArea(validImages)
drop.acceptProposedAction()
}
}
}
ListModel {
@ -742,42 +742,42 @@ Rectangle {
color: isEdit ? Style.current.secondaryinputBackground : Style.current.inputBackground
radius: control.isStatusUpdateInput ? 36 :
height > defaultInputFieldHeight + 1 || extendedArea.visible ? 16 : 32
height > defaultInputFieldHeight + 1 || extendedArea.visible ? 16 : 32
ColumnLayout {
id: validators
anchors.bottom: control.imageErrorMessageLocation === StatusChatInput.ImageErrorMessageLocation.Top ? extendedArea.top : undefined
anchors.bottomMargin: control.imageErrorMessageLocation === StatusChatInput.ImageErrorMessageLocation.Top ? -4 : undefined
anchors.top: control.imageErrorMessageLocation === StatusChatInput.ImageErrorMessageLocation.Bottom ? extendedArea.bottom : undefined
anchors.topMargin: control.imageErrorMessageLocation === StatusChatInput.ImageErrorMessageLocation.Bottom ? (isImage ? -4 : 4) : undefined
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width
z: 1
StatusChatImageExtensionValidator {
Layout.alignment: Qt.AlignHCenter
ColumnLayout {
id: validators
anchors.bottom: control.imageErrorMessageLocation === StatusChatInput.ImageErrorMessageLocation.Top ? extendedArea.top : undefined
anchors.bottomMargin: control.imageErrorMessageLocation === StatusChatInput.ImageErrorMessageLocation.Top ? -4 : undefined
anchors.top: control.imageErrorMessageLocation === StatusChatInput.ImageErrorMessageLocation.Bottom ? extendedArea.bottom : undefined
anchors.topMargin: control.imageErrorMessageLocation === StatusChatInput.ImageErrorMessageLocation.Bottom ? (isImage ? -4 : 4) : undefined
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width
z: 1
StatusChatImageExtensionValidator {
Layout.alignment: Qt.AlignHCenter
}
StatusChatImageSizeValidator {
Layout.alignment: Qt.AlignHCenter
}
StatusChatImageQtyValidator {
Layout.alignment: Qt.AlignHCenter
}
}
StatusChatImageSizeValidator {
Layout.alignment: Qt.AlignHCenter
}
StatusChatImageQtyValidator {
Layout.alignment: Qt.AlignHCenter
}
}
Rectangle {
id: extendedArea
visible: isImage || isReply
height: {
if (visible) {
if (isImage) {
return imageArea.height
}
if (visible) {
if (isImage) {
return imageArea.height
}
if (isReply) {
return replyArea.height + replyArea.anchors.topMargin
}
}
return 0
if (isReply) {
return replyArea.height + replyArea.anchors.topMargin
}
}
return 0
}
anchors.left: messageInput.left
anchors.right: messageInput.right
@ -805,7 +805,7 @@ Rectangle {
anchors.right: parent.right
anchors.rightMargin: control.isStatusUpdateInput ? actions.width + 2* Style.current.padding : Style.current.halfPadding
anchors.top: parent.top
anchors.topMargin: control.isStatusUpdateInput ? 0 : Style.current.halfPadding
anchors.topMargin: Style.current.halfPadding
visible: isImage
width: messageInputField.width - actions.width
onImageRemoved: {
@ -892,7 +892,7 @@ Rectangle {
// If it's a double click, just check the mouse position
// If it's a mouse select, use the start and end position average)
let x = now < messageInputField.lastClick + 500 ? x = event.x :
(messageInputField.cursorRectangle.x + event.x) / 2
(messageInputField.cursorRectangle.x + event.x) / 2
x -= textFormatMenu.width / 2
textFormatMenu.popup(x, -messageInputField.height-2)
@ -1029,8 +1029,8 @@ Rectangle {
Item {
id: actions
width: control.isStatusUpdateInput ?
imageBtn2.width + sendBtn.anchors.leftMargin + sendBtn.width :
emojiBtn.width + stickersBtn.anchors.leftMargin + stickersBtn.width
imageBtn2.width + sendBtn.anchors.leftMargin + sendBtn.width :
emojiBtn.width + stickersBtn.anchors.leftMargin + stickersBtn.width
anchors.bottom: control.isStatusUpdateInput && extendedArea.visible ? extendedArea.bottom : parent.bottom
anchors.bottomMargin: control.isStatusUpdateInput ? Style.current.smallPadding+2: 4
anchors.right: parent.right

View File

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