Simplify reaction delegate
This commit is contained in:
@@ -17,52 +17,38 @@ Flow {
|
|||||||
Repeater {
|
Repeater {
|
||||||
model: reaction
|
model: reaction
|
||||||
|
|
||||||
delegate: Control {
|
delegate: RoundButton {
|
||||||
width: Math.max(implicitWidth, Kirigami.Units.largeSpacing * 3)
|
width: Math.min(implicitWidth, Kirigami.Units.largeSpacing * 4)
|
||||||
height: Kirigami.Units.largeSpacing * 3
|
implicitHeight: Kirigami.Units.largeSpacing * 4
|
||||||
|
|
||||||
horizontalPadding: 6
|
horizontalPadding: 6
|
||||||
verticalPadding: 0
|
verticalPadding: 0
|
||||||
|
|
||||||
contentItem: Label {
|
text: modelData.reaction + (modelData.count > 1 ? " " + modelData.count : "")
|
||||||
height: Kirigami.Units.largeSpacing * 3
|
|
||||||
text: modelData.reaction + (modelData.count > 1 ? " " + modelData.count : "")
|
|
||||||
elide: Text.ElideRight
|
|
||||||
}
|
|
||||||
|
|
||||||
background: Rectangle {
|
checkable: true
|
||||||
radius: height / 2
|
|
||||||
Kirigami.Theme.colorSet: Kirigami.Theme.Window
|
|
||||||
color: Kirigami.Theme.backgroundColor
|
|
||||||
|
|
||||||
MouseArea {
|
checked: modelData.hasLocalUser
|
||||||
anchors.fill: parent
|
|
||||||
|
|
||||||
hoverEnabled: true
|
onToggled: currentRoom.toggleReaction(eventId, modelData.reaction)
|
||||||
|
|
||||||
ToolTip {
|
ToolTip.visible: hovered
|
||||||
visible: parent.containsMouse
|
ToolTip.text: {
|
||||||
text: {
|
var text = "";
|
||||||
var text = "";
|
|
||||||
|
|
||||||
for (var i = 0; i < modelData.authors.length; i++) {
|
for (var i = 0; i < modelData.authors.length; i++) {
|
||||||
if (i === modelData.authors.length - 1 && i !== 0) {
|
if (i === modelData.authors.length - 1 && i !== 0) {
|
||||||
text += i18nc("Seperate the usernames of users", " and ")
|
text += i18nc("Seperate the usernames of users", " and ")
|
||||||
} else if (i !== 0) {
|
} else if (i !== 0) {
|
||||||
text += ", "
|
text += ", "
|
||||||
}
|
|
||||||
|
|
||||||
text += modelData.authors[i].displayName
|
|
||||||
}
|
|
||||||
|
|
||||||
text = i18ncp("%1 is the users who reacted and %2 the emoji that was given", "%2 reacted with %3", "%2 reacted with %3", modelData.authors.length, text, modelData.reaction)
|
|
||||||
|
|
||||||
return text
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onClicked: currentRoom.toggleReaction(eventId, modelData.reaction)
|
text += modelData.authors[i].displayName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
text = i18ncp("%1 is the users who reacted and %2 the emoji that was given", "%2 reacted with %3", "%2 reacted with %3", modelData.authors.length, text, modelData.reaction)
|
||||||
|
|
||||||
|
return text
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user