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
3 files changed, 24 insertions, 45 deletions
diff --git a/resources/qml/Avatar.qml b/resources/qml/Avatar.qml
index 5875e309..09529fcd 100644
--- a/resources/qml/Avatar.qml
+++ b/resources/qml/Avatar.qml
@@ -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
- radius: Settings.avatarCircles ? height / 2 : height / 8
- color: Nheko.colors.alternateBase
+ 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)
}
diff --git a/resources/qml/MessageView.qml b/resources/qml/MessageView.qml
index 542304d8..7f2a2f57 100644
--- a/resources/qml/MessageView.qml
+++ b/resources/qml/MessageView.qml
@@ -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 {
- id: userName_
-
- text: TimelineManager.escapeEmoji(userName)
- color: TimelineManager.userColor(userId, Nheko.colors.base)
- textFormat: Text.RichText
- ToolTip.visible: displayNameHover.hovered
+ AbstractButton {
+ contentItem: Label {
+ id: userName_
+ text: TimelineManager.escapeEmoji(userName)
+ color: TimelineManager.userColor(userId, Nheko.colors.base)
+ textFormat: Text.RichText
+ }
+ 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 {
diff --git a/resources/qml/delegates/Reply.qml b/resources/qml/delegates/Reply.qml
index a439b2eb..f26bc5aa 100644
--- a/resources/qml/delegates/Reply.qml
+++ b/resources/qml/delegates/Reply.qml
@@ -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
+ text: TimelineManager.escapeEmoji(userName)
+ color: r.userColor
+ textFormat: Text.RichText
}
-
+ onClicked: room.openUserProfile(userId)
}
MessageDelegate {
|