Rewrite HTile and adapt components using it
Rewrite HTile in a more standard way, hopefully fixing the mysterious segfault on some systems
This commit is contained in:
@@ -3,32 +3,49 @@
|
||||
import QtQuick 2.12
|
||||
import Clipboard 0.1
|
||||
import "../../../Base"
|
||||
import "../../../Base/HTile"
|
||||
|
||||
HTileDelegate {
|
||||
id: memberDelegate
|
||||
id: member
|
||||
backgroundColor: theme.chat.roomPane.listView.member.background
|
||||
contentOpacity:
|
||||
model.invited ? theme.chat.roomPane.listView.member.invitedOpacity : 1
|
||||
|
||||
image: HUserAvatar {
|
||||
userId: model.id
|
||||
displayName: model.display_name
|
||||
mxc: model.avatar_url
|
||||
powerLevel: model.power_level
|
||||
shiftMembershipIconPosition: ! roomPane.collapsed
|
||||
invited: model.invited
|
||||
compact: memberDelegate.compact
|
||||
contentItem: ContentRow {
|
||||
tile: member
|
||||
|
||||
HUserAvatar {
|
||||
id: avatar
|
||||
userId: model.id
|
||||
displayName: model.display_name
|
||||
mxc: model.avatar_url
|
||||
powerLevel: model.power_level
|
||||
shiftMembershipIconPosition: ! roomPane.collapsed
|
||||
invited: model.invited
|
||||
compact: member.compact
|
||||
}
|
||||
|
||||
HColumnLayout {
|
||||
TitleLabel {
|
||||
text: model.display_name || model.id
|
||||
color:
|
||||
member.hovered ?
|
||||
utils.nameColor(
|
||||
model.display_name || model.id.substring(1)
|
||||
) :
|
||||
theme.chat.roomPane.listView.member.name
|
||||
|
||||
Behavior on color { HColorAnimation {} }
|
||||
}
|
||||
|
||||
SubtitleLabel {
|
||||
tile: member
|
||||
text: model.display_name ? model.id : ""
|
||||
color: theme.chat.roomPane.listView.member.subtitle
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
title.text: model.display_name || model.id
|
||||
title.color:
|
||||
memberDelegate.hovered ?
|
||||
utils.nameColor(model.display_name || model.id.substring(1)) :
|
||||
theme.chat.roomPane.listView.member.name
|
||||
|
||||
subtitle.text: model.display_name ? model.id : ""
|
||||
subtitle.color: theme.chat.roomPane.listView.member.subtitle
|
||||
|
||||
contextMenu: HMenu {
|
||||
HMenuItem {
|
||||
icon.name: "copy-user-id"
|
||||
@@ -38,13 +55,11 @@ HTileDelegate {
|
||||
}
|
||||
|
||||
|
||||
Behavior on title.color { HColorAnimation {} }
|
||||
Behavior on contentOpacity { HNumberAnimation {} }
|
||||
Behavior on spacing { HNumberAnimation {} }
|
||||
|
||||
Binding on spacing {
|
||||
value: (roomPane.minimumSize - loadedImage.width) / 2
|
||||
when: loadedImage &&
|
||||
roomPane.width < loadedImage.width + theme.spacing * 2
|
||||
value: (roomPane.minimumSize - avatar.width) / 2
|
||||
when: avatar && roomPane.width < avatar.width + theme.spacing * 2
|
||||
}
|
||||
}
|
||||
|
@@ -4,6 +4,7 @@ import QtQuick 2.12
|
||||
import QtQuick.Layouts 1.12
|
||||
import CppUtils 0.1
|
||||
import "../../../Base"
|
||||
import "../../../Base/HTile"
|
||||
|
||||
HTile {
|
||||
id: file
|
||||
@@ -14,12 +15,27 @@ HTile {
|
||||
)
|
||||
height: Math.max(theme.chat.message.avatarSize, implicitHeight)
|
||||
|
||||
title.text: loader.singleMediaInfo.media_title || qsTr("Untitled file")
|
||||
title.elide: Text.ElideMiddle
|
||||
subtitle.text: CppUtils.formattedBytes(loader.singleMediaInfo.media_size)
|
||||
contentItem: ContentRow {
|
||||
tile: file
|
||||
|
||||
image: HIcon {
|
||||
svgName: "download"
|
||||
HIcon {
|
||||
svgName: "download"
|
||||
}
|
||||
|
||||
HColumnLayout {
|
||||
TitleLabel {
|
||||
elide: Text.ElideMiddle
|
||||
text: loader.singleMediaInfo.media_title ||
|
||||
qsTr("Untitled file")
|
||||
}
|
||||
|
||||
SubtitleLabel {
|
||||
tile: file
|
||||
text: CppUtils.formattedBytes(
|
||||
loader.singleMediaInfo.media_size,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onRightClicked: eventDelegate.openContextMenu()
|
||||
|
Reference in New Issue
Block a user