2020-07-15 21:04:14 +00:00
|
|
|
import QtQuick 2.3
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared.controls 1.0
|
|
|
|
import shared 1.0
|
|
|
|
import shared.panels 1.0
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2020-07-15 21:04:14 +00:00
|
|
|
|
2020-12-08 15:45:43 +00:00
|
|
|
Item {
|
|
|
|
id: root
|
2021-01-25 20:50:42 +00:00
|
|
|
property bool isHovered: false
|
2020-12-08 15:45:43 +00:00
|
|
|
height: childrenRect.height
|
2020-12-10 10:56:35 +00:00
|
|
|
width: chatName.width + (ensOrAlias.visible ? ensOrAlias.width + ensOrAlias.anchors.leftMargin : 0)
|
2020-12-08 15:45:43 +00:00
|
|
|
property alias label: chatName
|
2021-10-01 15:58:36 +00:00
|
|
|
// property var messageContextMenu
|
|
|
|
// property bool isCurrentUser: false
|
|
|
|
// property string userName: ""
|
|
|
|
// property string localName: ""
|
|
|
|
// property string displayUserName: ""
|
|
|
|
signal clickMessage(bool isProfileClick)
|
|
|
|
//TODO remove dynamic scoping
|
|
|
|
//visible: isMessage && authorCurrentMsg != authorPrevMsg
|
2020-12-08 15:45:43 +00:00
|
|
|
|
|
|
|
StyledTextEdit {
|
|
|
|
id: chatName
|
2021-04-29 19:08:57 +00:00
|
|
|
text: displayUserName
|
2020-12-11 18:15:40 +00:00
|
|
|
color: text.startsWith("@") || isCurrentUser || localName !== "" ? Style.current.blue : Style.current.secondaryText
|
2020-12-08 15:45:43 +00:00
|
|
|
font.weight: Font.Medium
|
|
|
|
font.pixelSize: Style.current.secondaryTextFontSize
|
2021-01-25 20:50:42 +00:00
|
|
|
font.underline: root.isHovered
|
2020-12-08 15:45:43 +00:00
|
|
|
readOnly: true
|
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
selectByMouse: true
|
|
|
|
MouseArea {
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
|
|
|
anchors.fill: parent
|
|
|
|
hoverEnabled: true
|
|
|
|
onEntered: {
|
2021-01-25 20:50:42 +00:00
|
|
|
root.isHovered = true
|
2020-12-08 15:45:43 +00:00
|
|
|
}
|
|
|
|
onExited: {
|
2021-01-25 20:50:42 +00:00
|
|
|
root.isHovered = false
|
2020-12-08 15:45:43 +00:00
|
|
|
}
|
|
|
|
onClicked: {
|
2021-10-01 15:58:36 +00:00
|
|
|
if (!!messageContextMenu) {
|
|
|
|
// Set parent, X & Y positions for the messageContextMenu
|
|
|
|
messageContextMenu.parent = root
|
|
|
|
messageContextMenu.setXPosition = function() { return 0}
|
|
|
|
messageContextMenu.setYPosition = function() { return root.height + 4}
|
|
|
|
}
|
|
|
|
root.clickMessage(true);
|
2020-12-08 15:45:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
id: ensOrAlias
|
2020-12-11 18:15:40 +00:00
|
|
|
visible: localName !== "" && userName.startsWith("@")
|
|
|
|
text: userName
|
2020-12-08 15:45:43 +00:00
|
|
|
color: Style.current.secondaryText
|
|
|
|
font.pixelSize: chatName.font.pixelSize
|
|
|
|
anchors.left: chatName.right
|
|
|
|
anchors.leftMargin: chatName.visible ? 4 : 0
|
2020-07-15 21:04:14 +00:00
|
|
|
}
|
|
|
|
}
|