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 QtQuick.Window 2.15
import im.nheko 1.0 import im.nheko 1.0
Rectangle { AbstractButton {
id: avatar id: avatar
property string url property string url
@ -18,13 +18,15 @@ Rectangle {
property string displayName property string displayName
property alias textColor: label.color property alias textColor: label.color
property bool crop: true property bool crop: true
property alias color: bg.color
signal clicked(var mouse)
width: 48 width: 48
height: 48 height: 48
background: Rectangle {
id: bg
radius: Settings.avatarCircles ? height / 2 : height / 8 radius: Settings.avatarCircles ? height / 2 : height / 8
color: Nheko.colors.alternateBase color: Nheko.colors.alternateBase
}
Label { Label {
id: label id: label
@ -101,13 +103,6 @@ Rectangle {
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
} }
TapHandler {
id: mouseArea
onSingleTapped: avatar.clicked(eventPoint)
dragThreshold: 0
}
Ripple { Ripple {
color: Qt.rgba(Nheko.colors.alternateBase.r, Nheko.colors.alternateBase.g, Nheko.colors.alternateBase.b, 0.5) 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 displayName: userName
userid: userId userid: userId
onClicked: room.openUserProfile(userId) onClicked: room.openUserProfile(userId)
ToolTip.visible: avatarHover.hovered ToolTip.visible: messageUserAvatar.hovered
ToolTip.delay: Nheko.tooltipDelay ToolTip.delay: Nheko.tooltipDelay
ToolTip.text: userid ToolTip.text: userid
HoverHandler {
id: avatarHover
}
} }
Connections { Connections {
@ -323,31 +318,23 @@ Item {
target: chat.model target: chat.model
} }
AbstractButton {
Label { contentItem: Label {
id: userName_ id: userName_
text: TimelineManager.escapeEmoji(userName) text: TimelineManager.escapeEmoji(userName)
color: TimelineManager.userColor(userId, Nheko.colors.base) color: TimelineManager.userColor(userId, Nheko.colors.base)
textFormat: Text.RichText textFormat: Text.RichText
ToolTip.visible: displayNameHover.hovered }
ToolTip.visible: hovered
ToolTip.delay: Nheko.tooltipDelay ToolTip.delay: Nheko.tooltipDelay
ToolTip.text: userId ToolTip.text: userId
onClicked: chat.model.openUserProfile(userId)
TapHandler {
onSingleTapped: chat.model.openUserProfile(userId)
dragThreshold: 0
}
CursorShape { CursorShape {
anchors.fill: parent anchors.fill: parent
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
} }
HoverHandler {
id: displayNameHover
}
} }
Label { Label {

View file

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