status-desktop/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/UsernameLabel.qml

57 lines
1.8 KiB
QML
Raw Normal View History

import QtQuick 2.3
import "../../../../../shared"
import "../../../../../shared/controls"
import "../../../../../shared/panels"
import utils 1.0
Item {
id: root
property bool isHovered: false
height: childrenRect.height
width: chatName.width + (ensOrAlias.visible ? ensOrAlias.width + ensOrAlias.anchors.leftMargin : 0)
property alias label: chatName
2020-07-20 17:34:20 +00:00
visible: isMessage && authorCurrentMsg != authorPrevMsg
StyledTextEdit {
id: chatName
text: displayUserName
2020-12-11 18:15:40 +00:00
color: text.startsWith("@") || isCurrentUser || localName !== "" ? Style.current.blue : Style.current.secondaryText
font.weight: Font.Medium
font.pixelSize: Style.current.secondaryTextFontSize
font.underline: root.isHovered
readOnly: true
wrapMode: Text.WordWrap
selectByMouse: true
MouseArea {
cursorShape: Qt.PointingHandCursor
acceptedButtons: Qt.LeftButton | Qt.RightButton
anchors.fill: parent
hoverEnabled: true
onEntered: {
root.isHovered = true
}
onExited: {
root.isHovered = false
}
onClicked: {
// Set parent, X & Y positions for the messageContextMenu
messageContextMenu.parent = root
messageContextMenu.setXPosition = function() { return 0}
messageContextMenu.setYPosition = function() { return root.height + 4}
clickMessage(true)
}
}
}
StyledText {
id: ensOrAlias
2020-12-11 18:15:40 +00:00
visible: localName !== "" && userName.startsWith("@")
text: userName
color: Style.current.secondaryText
font.pixelSize: chatName.font.pixelSize
anchors.left: chatName.right
anchors.leftMargin: chatName.visible ? 4 : 0
}
}