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-12-09 12:53:40 +00:00
|
|
|
|
2022-01-17 08:56:44 +00:00
|
|
|
property var messageContextMenu
|
2021-12-09 12:53:40 +00:00
|
|
|
property string displayName
|
|
|
|
property string localName
|
|
|
|
property bool amISender
|
|
|
|
|
2021-10-01 15:58:36 +00:00
|
|
|
signal clickMessage(bool isProfileClick)
|
2020-12-08 15:45:43 +00:00
|
|
|
|
|
|
|
StyledTextEdit {
|
|
|
|
id: chatName
|
2021-12-09 12:53:40 +00:00
|
|
|
text: displayName
|
|
|
|
color: text.startsWith("@") || amISender || 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: {
|
2022-01-17 08:56:44 +00:00
|
|
|
if (!!root.messageContextMenu) {
|
2021-10-01 15:58:36 +00:00
|
|
|
// Set parent, X & Y positions for the messageContextMenu
|
2022-01-17 08:56:44 +00:00
|
|
|
root.messageContextMenu.parent = root
|
|
|
|
root.messageContextMenu.setXPosition = function() { return 0}
|
|
|
|
root.messageContextMenu.setYPosition = function() { return root.height + 4}
|
2021-10-01 15:58:36 +00:00
|
|
|
}
|
|
|
|
root.clickMessage(true);
|
2020-12-08 15:45:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
id: ensOrAlias
|
2021-12-09 12:53:40 +00:00
|
|
|
visible: localName !== "" && displayName.startsWith("@")
|
|
|
|
text: displayName
|
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
|
|
|
}
|
|
|
|
}
|