making userName_ an AbstractButton should play nicely with ListView (#961)

* making userName_ an AbstractButton should make it play nicely with the ListView

* make Avatar an AbstractButton

* make userName_ in Reply.qml an AbstractButton

* use alias for avatar background color and fix margin of username in reply
This commit is contained in:
Malte E 2022-02-24 03:16:39 +01:00 committed by GitHub
parent ebc0384ebb
commit 5108955df2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 45 deletions

View file

@ -9,7 +9,7 @@ import QtQuick.Controls 2.15
import QtQuick.Window 2.15
import im.nheko 1.0
Rectangle {
AbstractButton {
id: avatar
property string url
@ -18,13 +18,15 @@ Rectangle {
property string displayName
property alias textColor: label.color
property bool crop: true
signal clicked(var mouse)
property alias color: bg.color
width: 48
height: 48
background: Rectangle {
id: bg
radius: Settings.avatarCircles ? height / 2 : height / 8
color: Nheko.colors.alternateBase
}
Label {
id: label
@ -101,13 +103,6 @@ Rectangle {
cursorShape: Qt.PointingHandCursor
}
TapHandler {
id: mouseArea
onSingleTapped: avatar.clicked(eventPoint)
dragThreshold: 0
}
Ripple {
color: Qt.rgba(Nheko.colors.alternateBase.r, Nheko.colors.alternateBase.g, Nheko.colors.alternateBase.b, 0.5)
}

View file

@ -302,14 +302,9 @@ Item {
displayName: userName
userid: userId
onClicked: room.openUserProfile(userId)
ToolTip.visible: avatarHover.hovered
ToolTip.visible: messageUserAvatar.hovered
ToolTip.delay: Nheko.tooltipDelay
ToolTip.text: userid
HoverHandler {
id: avatarHover
}
}
Connections {
@ -323,31 +318,23 @@ Item {
target: chat.model
}
Label {
AbstractButton {
contentItem: Label {
id: userName_
text: TimelineManager.escapeEmoji(userName)
color: TimelineManager.userColor(userId, Nheko.colors.base)
textFormat: Text.RichText
ToolTip.visible: displayNameHover.hovered
}
ToolTip.visible: hovered
ToolTip.delay: Nheko.tooltipDelay
ToolTip.text: userId
TapHandler {
onSingleTapped: chat.model.openUserProfile(userId)
dragThreshold: 0
}
onClicked: chat.model.openUserProfile(userId)
CursorShape {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
}
HoverHandler {
id: displayNameHover
}
}
Label {

View file

@ -82,19 +82,16 @@ Item {
gesturePolicy: TapHandler.ReleaseWithinBounds
}
Text {
Layout.leftMargin: 4
AbstractButton {
id: userName_
Layout.leftMargin: 4
contentItem: Text {
text: TimelineManager.escapeEmoji(userName)
color: r.userColor
textFormat: Text.RichText
TapHandler {
onSingleTapped: room.openUserProfile(userId)
gesturePolicy: TapHandler.ReleaseWithinBounds
}
onClicked: room.openUserProfile(userId)
}
MessageDelegate {