Limit the maximum number of avatars shown

Limit the maximum number of avatars shown for other user read markers and collapsed state events

For state events \
![image](/uploads/0d3ec7c3da02a8832dfdb18dc265db92/image.png)

For read markers \
![image](/uploads/5694f14927e5c10b2159e58445c8a0a3/image.png)
This commit is contained in:
James Graham
2023-05-12 15:54:15 +00:00
parent 023c51ac62
commit 88fada89ea
7 changed files with 130 additions and 8 deletions

View File

@@ -12,19 +12,46 @@ Flow {
property var avatarSize: Kirigami.Units.iconSizes.small
property alias model: avatarFlowRepeater.model
property string toolTipText
property alias excessAvatars: excessAvatarsLabel.text
spacing: -avatarSize / 2
Repeater {
id: avatarFlowRepeater
delegate: Kirigami.Avatar {
topInset: Kirigami.Units.smallSpacing / 2
topPadding: Kirigami.Units.smallSpacing / 2
implicitWidth: avatarSize
implicitHeight: avatarSize
implicitHeight: avatarSize + Kirigami.Units.smallSpacing / 2
name: modelData.displayName
source: modelData.avatarSource
color: modelData.color
}
}
QQC2.Label {
id: excessAvatarsLabel
visible: text !== ""
color: Kirigami.Theme.textColor
horizontalAlignment: Text.AlignHCenter
background: Kirigami.ShadowedRectangle {
color: Kirigami.Theme.backgroundColor
Kirigami.Theme.inherit: false
Kirigami.Theme.colorSet: Kirigami.Theme.View
radius: height / 2
shadow.size: Kirigami.Units.smallSpacing
shadow.color: Qt.rgba(Kirigami.Theme.textColor.r, Kirigami.Theme.textColor.g, Kirigami.Theme.textColor.b, 0.10)
border.color: Kirigami.ColorUtils.tintWithAlpha(color, Kirigami.Theme.textColor, 0.15)
border.width: 1
}
height: Kirigami.Units.iconSizes.small + Kirigami.Units.smallSpacing
width: Math.max(excessAvatarsTextMetrics.advanceWidth + Kirigami.Units.smallSpacing * 2, height)
TextMetrics {
id: excessAvatarsTextMetrics
text: excessAvatarsLabel.text
}
}
QQC2.ToolTip.text: toolTipText
QQC2.ToolTip.visible: hoverHandler.hovered

View File

@@ -78,14 +78,41 @@ QQC2.Control {
Repeater {
model: authorList
delegate: Kirigami.Avatar {
topInset: Kirigami.Units.smallSpacing / 2
topPadding: Kirigami.Units.smallSpacing / 2
implicitWidth: Kirigami.Units.iconSizes.small
implicitHeight: Kirigami.Units.iconSizes.small
implicitHeight: Kirigami.Units.iconSizes.small + Kirigami.Units.smallSpacing / 2
name: modelData.displayName
source: modelData.avatarSource
color: modelData.color
}
}
QQC2.Label {
id: excessAuthorsLabel
text: model.excessAuthors
visible: model.excessAuthors !== ""
color: Kirigami.Theme.textColor
horizontalAlignment: Text.AlignHCenter
background: Kirigami.ShadowedRectangle {
color: Kirigami.Theme.backgroundColor
Kirigami.Theme.inherit: false
Kirigami.Theme.colorSet: Kirigami.Theme.View
radius: height / 2
shadow.size: Kirigami.Units.smallSpacing
shadow.color: Qt.rgba(Kirigami.Theme.textColor.r, Kirigami.Theme.textColor.g, Kirigami.Theme.textColor.b, 0.10)
border.color: Kirigami.ColorUtils.tintWithAlpha(color, Kirigami.Theme.textColor, 0.15)
border.width: 1
}
height: Kirigami.Units.iconSizes.small + Kirigami.Units.smallSpacing
width: Math.max(excessAuthorsTextMetrics.advanceWidth + Kirigami.Units.smallSpacing * 2, height)
TextMetrics {
id: excessAuthorsTextMetrics
text: excessAuthorsLabel.text
}
}
}
QQC2.Label {
Layout.fillWidth: true
@@ -140,6 +167,7 @@ QQC2.Control {
visible: showReadMarkers
model: readMarkers
toolTipText: readMarkersString
excessAvatars: excessReadMarkers
}
}
}

View File

@@ -342,6 +342,7 @@ ColumnLayout {
visible: showReadMarkers
model: readMarkers
toolTipText: readMarkersString
excessAvatars: excessReadMarkers
}
function isVisibleInTimeline() {