From 0e548b7d390cfbc3c37689ed9dbff0f1e2eab5cc Mon Sep 17 00:00:00 2001 From: Malte E Date: Wed, 9 Feb 2022 21:36:04 +0100 Subject: [PATCH] fixed most of the binding loops --- resources/qml/TimelineRow.qml | 4 +++- resources/qml/delegates/FileMessage.qml | 4 +++- resources/qml/delegates/ImageMessage.qml | 5 ++++- resources/qml/delegates/MessageDelegate.qml | 10 ++++++++-- resources/qml/delegates/PlayableMediaMessage.qml | 5 ++++- resources/qml/delegates/Redacted.qml | 1 + resources/qml/delegates/Reply.qml | 2 ++ 7 files changed, 25 insertions(+), 6 deletions(-) diff --git a/resources/qml/TimelineRow.qml b/resources/qml/TimelineRow.qml index 51275f4e..b40ce068 100644 --- a/resources/qml/TimelineRow.qml +++ b/resources/qml/TimelineRow.qml @@ -102,7 +102,7 @@ Item { left: parent.left top: parent.top } - property bool narrowLayout: (r.width < 500) && Settings.bubbles + property bool narrowLayout: Settings.bubbles //&& (timelineView.width < 500) // timelineView causes fewew binding loops than r. But maybe it shouldn't depend on width anyway rowSpacing: 0 columnSpacing: 2 columns: narrowLayout? 1 : 2 @@ -142,6 +142,7 @@ Item { callType: r.relatedEventCacheBuster, fromModel(Room.CallType) ?? "" encryptionError: r.relatedEventCacheBuster, fromModel(Room.EncryptionError) ?? "" relatedEventCacheBuster: r.relatedEventCacheBuster, fromModel(Room.RelatedEventCacheBuster) ?? 0 + maxWidth: row.maxWidth } // actual message content @@ -173,6 +174,7 @@ Item { encryptionError: r.encryptionError relatedEventCacheBuster: r.relatedEventCacheBuster isReply: false + maxWidth: row.maxWidth } RowLayout { diff --git a/resources/qml/delegates/FileMessage.qml b/resources/qml/delegates/FileMessage.qml index f1fd07b9..2ac2a80a 100644 --- a/resources/qml/delegates/FileMessage.qml +++ b/resources/qml/delegates/FileMessage.qml @@ -11,9 +11,11 @@ Item { required property string eventId required property string filename required property string filesize + property int maxWidth height: row.height + 24 - width: parent.width + width: maxWidth + implicitWidth: maxWidth RowLayout { id: row diff --git a/resources/qml/delegates/ImageMessage.qml b/resources/qml/delegates/ImageMessage.qml index da15bdfe..3bbcd077 100644 --- a/resources/qml/delegates/ImageMessage.qml +++ b/resources/qml/delegates/ImageMessage.qml @@ -17,13 +17,16 @@ Item { required property string filename required property bool isReply required property string eventId - property double tempWidth: Math.min(parent.width, originalWidth < 1 ? 200 : originalWidth) + property int maxWidth + property double tempWidth: Math.min(maxWidth, originalWidth < 1 ? 200 : originalWidth) property double tempHeight: tempWidth * proportionalHeight property double divisor: isReply ? 5 : 3 property bool tooHigh: tempHeight > timelineView.height / divisor height: Math.round(tooHigh ? timelineView.height / divisor : tempHeight) width: Math.round(tooHigh ? (timelineView.height / divisor) / proportionalHeight : tempWidth) + implicitHeight: height + implicitWidth: width Image { id: blurhash_ diff --git a/resources/qml/delegates/MessageDelegate.qml b/resources/qml/delegates/MessageDelegate.qml index 0cec51bc..5d987841 100644 --- a/resources/qml/delegates/MessageDelegate.qml +++ b/resources/qml/delegates/MessageDelegate.qml @@ -13,7 +13,7 @@ Item { required property bool isReply property alias child: chooser.child - implicitWidth: (chooser.child && chooser.child.implicitWidth) ? chooser.child.implicitWidth : width + implicitWidth: (chooser.child && chooser.child.implicitWidth) ? chooser.child.implicitWidth : 0 required property double proportionalHeight required property int type required property string typeString @@ -35,6 +35,7 @@ Item { required property string callType required property int encryptionError required property int relatedEventCacheBuster + property int maxWidth Layout.preferredHeight: chooser.child ? chooser.child.height : Nheko.paddingLarge @@ -110,6 +111,7 @@ Item { filename: d.filename isReply: d.isReply eventId: d.eventId + maxWidth: d.maxWidth } } @@ -127,6 +129,7 @@ Item { filename: d.filename isReply: d.isReply eventId: d.eventId + maxWidth: d.maxWidth } } @@ -138,6 +141,7 @@ Item { eventId: d.eventId filename: d.filename filesize: d.filesize + maxWidth: d.maxWidth } } @@ -154,6 +158,7 @@ Item { url: d.url body: d.body filesize: d.filesize + maxWidth: d.maxWidth } } @@ -170,6 +175,7 @@ Item { url: d.url body: d.body filesize: d.filesize + maxWidth: d.maxWidth } } @@ -372,7 +378,7 @@ Item { isOnlyEmoji: false isReply: d.isReply isStateEvent: d.isStateEvent - formatted: qsTr("% is negotiating the call...").arg(d.userName) + formatted: qsTr("%1 is negotiating the call...").arg(d.userName) } } diff --git a/resources/qml/delegates/PlayableMediaMessage.qml b/resources/qml/delegates/PlayableMediaMessage.qml index 389d1814..805eafbf 100644 --- a/resources/qml/delegates/PlayableMediaMessage.qml +++ b/resources/qml/delegates/PlayableMediaMessage.qml @@ -22,13 +22,16 @@ Item { required property string url required property string body required property string filesize - property double tempWidth: Math.min(parent.width, originalWidth < 1 ? 400 : originalWidth) + property int maxWidth + property double tempWidth: Math.min(maxWidth, originalWidth < 1 ? 400 : originalWidth) property double tempHeight: tempWidth * proportionalHeight property double divisor: isReply ? 4 : 2 property bool tooHigh: tempHeight > timelineRoot.height / divisor height: (type == MtxEvent.VideoMessage ? tooHigh ? timelineRoot.height / divisor : tempHeight : 80) + fileInfoLabel.height width: type == MtxEvent.VideoMessage ? tooHigh ? (timelineRoot.height / divisor) / proportionalHeight : tempWidth : 250 + implicitHeight: height + implicitWidth: width MxcMedia { id: mxcmedia diff --git a/resources/qml/delegates/Redacted.qml b/resources/qml/delegates/Redacted.qml index 10b92173..b0c9abfe 100644 --- a/resources/qml/delegates/Redacted.qml +++ b/resources/qml/delegates/Redacted.qml @@ -13,6 +13,7 @@ Rectangle{ required property real delegateWidth height: redactedLayout.implicitHeight + Nheko.paddingSmall width: redactedLayout.implicitWidth + 2 * Nheko.paddingMedium + implicitWidth: width radius: fontMetrics.lineSpacing / 2 + 2 * Nheko.paddingSmall color: Nheko.colors.alternateBase diff --git a/resources/qml/delegates/Reply.qml b/resources/qml/delegates/Reply.qml index 7c8bccce..28f0dd21 100644 --- a/resources/qml/delegates/Reply.qml +++ b/resources/qml/delegates/Reply.qml @@ -35,6 +35,7 @@ Item { property string callType property int encryptionError property int relatedEventCacheBuster + property int maxWidth Layout.preferredHeight: replyContainer.height height: replyContainer.height @@ -124,6 +125,7 @@ Item { enabled: false Layout.fillWidth: true isReply: true + maxWidth: r.maxWidth-4 } }