Variable width bubbles (still has binding loop)

This commit is contained in:
Malte E 2022-02-09 17:53:02 +01:00
parent e290f9938a
commit 5db7ec7f03
4 changed files with 15 additions and 7 deletions

View file

@ -78,7 +78,9 @@ Item {
anchors.rightMargin: 1
anchors.leftMargin: Nheko.avatarSize + 12 // align bubble with section header
anchors.left: parent.left
anchors.right: parent.right
//anchors.right: parent.right
property int maxWidth: parent.width-anchors.leftMargin-anchors.rightMargin
width: Math.min(maxWidth,msg.implicitWidth)
height: msg.height
topInset: -4
bottomInset: -4
@ -100,7 +102,7 @@ Item {
left: parent.left
top: parent.top
}
property bool narrowLayout: (row.width < 350) && Settings.bubbles
property bool narrowLayout: (r.width < 500) && Settings.bubbles
rowSpacing: 0
columnSpacing: 2
columns: narrowLayout? 1 : 2
@ -174,18 +176,21 @@ Item {
}
RowLayout {
id: metadata
Layout.column: msg.narrowLayout? 0 : 1
Layout.row: msg.narrowLayout? 2 : 0
Layout.rowSpan: msg.narrowLayout? 1 : 2
Layout.bottomMargin: msg.narrowLayout? -4 : 0
Layout.alignment: Qt.AlignTop | Qt.AlignRight
Layout.preferredWidth: implicitWidth
visible: !isStateEvent
property double scaling: msg.narrowLayout? 0.75 : 1
StatusIndicator {
Layout.alignment: Qt.AlignRight | Qt.AlignTop
Layout.preferredHeight: 16*parent.scaling
width: 16*parent.scaling
Layout.preferredWidth: 16*parent.scaling
status: r.status
eventId: r.eventId
}
@ -195,8 +200,6 @@ Item {
Layout.alignment: Qt.AlignRight | Qt.AlignTop
Layout.preferredHeight: 16*parent.scaling
Layout.preferredWidth: 16*parent.scaling
height: 16*parent.scaling
width: 16*parent.scaling
sourceSize.width: 16 * Screen.devicePixelRatio*parent.scaling
sourceSize.height: 16 * Screen.devicePixelRatio*parent.scaling
source: "image://colorimage/:/icons/icons/ui/edit.svg?" + ((eventId == chat.model.edit) ? Nheko.colors.highlight : Nheko.colors.buttonText)
@ -217,12 +220,14 @@ Item {
Layout.alignment: Qt.AlignRight | Qt.AlignTop
Layout.preferredHeight: 16*parent.scaling
Layout.preferredWidth: 16*parent.scaling
sourceSize.width: 16 * Screen.devicePixelRatio*parent.scaling
sourceSize.height: 16 * Screen.devicePixelRatio*parent.scaling
}
Label {
Layout.alignment: Qt.AlignRight | Qt.AlignTop
Layout.preferredWidth: implicitWidth
text: timestamp.toLocaleTimeString(Locale.ShortFormat)
width: Math.max(implicitWidth, text.length * fontMetrics.maximumCharacterWidth)
color: Nheko.inactiveColors.text
ToolTip.visible: ma.hovered
ToolTip.delay: Nheko.tooltipDelay

View file

@ -17,6 +17,7 @@ Rectangle {
radius: fontMetrics.lineSpacing / 2 + Nheko.paddingMedium
width: parent.width
implicitWidth: encryptedText.implicitWidth+24+Nheko.paddingMedium*3 // Column doesn't provide a useful implicitWidth, should be replaced by ColumnLayout
height: contents.implicitHeight + Nheko.paddingMedium * 2
color: Nheko.colors.alternateBase
@ -39,6 +40,7 @@ Rectangle {
Layout.fillWidth: true
MatrixText {
id: encryptedText
text: {
switch (encryptionError) {
case Olm.MissingSession:

View file

@ -13,7 +13,7 @@ Item {
required property bool isReply
property alias child: chooser.child
property real implicitWidth: (chooser.child && chooser.child.implicitWidth) ? chooser.child.implicitWidth : width
implicitWidth: (chooser.child && chooser.child.implicitWidth) ? chooser.child.implicitWidth : width
required property double proportionalHeight
required property int type
required property string typeString

View file

@ -38,6 +38,7 @@ Item {
Layout.preferredHeight: replyContainer.height
height: replyContainer.height
implicitWidth: visible? colorLine.width+replyContainer.implicitWidth : 0
CursorShape {
anchors.fill: parent