fix: fix text selection by putting mouseArea under text

And put link click handling by the TextField itself
This commit is contained in:
Jonathan Rainville 2020-07-20 17:59:01 -04:00 committed by Iuri Matias
parent 601d237fde
commit a9cddde37e
4 changed files with 20 additions and 17 deletions

View File

@ -234,6 +234,7 @@ QtObject:
proc joinChat*(self: ChatsView, channel: string, chatTypeInt: int): int {.slot.} = proc joinChat*(self: ChatsView, channel: string, chatTypeInt: int): int {.slot.} =
self.status.chat.join(channel, ChatType(chatTypeInt)) self.status.chat.join(channel, ChatType(chatTypeInt))
self.setActiveChannel(channel)
proc joinGroup*(self: ChatsView) {.slot.} = proc joinGroup*(self: ChatsView) {.slot.} =
self.status.chat.confirmJoiningGroup(self.activeChannel.id) self.status.chat.confirmJoiningGroup(self.activeChannel.id)

View File

@ -35,6 +35,7 @@ Rectangle {
wrapMode: Text.Wrap wrapMode: Text.Wrap
anchors.left: parent.left anchors.left: parent.left
anchors.right: chatReply.longReply ? parent.right : undefined anchors.right: chatReply.longReply ? parent.right : undefined
z: 51
} }
Separator { Separator {

View File

@ -12,6 +12,21 @@ StyledTextEdit {
readOnly: true readOnly: true
selectByMouse: true selectByMouse: true
color: Style.current.textColor color: Style.current.textColor
z: 51
onLinkActivated: function (link) {
if(link.startsWith("#")){
chatsModel.joinChat(link.substring(1), Constants.chatTypePublic);
return;
}
if (link.startsWith('//')) {
let pk = link.replace("//", "");
profileClick(chatsModel.userNameOrAlias(pk), pk, chatsModel.generateIdenticon(pk))
return;
}
Qt.openUrlExternally(link)
}
text: { text: {
if(contentType === Constants.stickerType) return ""; if(contentType === Constants.stickerType) return "";
let msg = Utils.linkifyAndXSS(message); let msg = Utils.linkifyAndXSS(message);
@ -44,6 +59,5 @@ StyledTextEdit {
`</body>`+ `</body>`+
`</html>`; `</html>`;
} }
} }
} }

View File

@ -3,27 +3,14 @@ import "../../../../../shared"
import "../../../../../imports" import "../../../../../imports"
MouseArea { MouseArea {
cursorShape: chatText.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor cursorShape: chatText.hoveredLink ? Qt.PointingHandCursor : undefined
acceptedButtons: Qt.LeftButton | Qt.RightButton acceptedButtons: Qt.RightButton
z: 50
onClicked: { onClicked: {
if(mouse.button & Qt.RightButton) { if(mouse.button & Qt.RightButton) {
clickMessage() clickMessage()
return; return;
} }
let link = chatText.hoveredLink;
if(link.startsWith("#")){
chatsModel.joinChat(link.substring(1), Constants.chatTypePublic);
return;
}
if (link.startsWith('//')) {
let pk = link.replace("//", "");
profileClick(chatsModel.userNameOrAlias(pk), pk, chatsModel.generateIdenticon(pk))
return;
}
Qt.openUrlExternally(link)
} }
} }