From 0e548b7d390cfbc3c37689ed9dbff0f1e2eab5cc Mon Sep 17 00:00:00 2001 From: Malte E Date: Wed, 9 Feb 2022 21:36:04 +0100 Subject: fixed most of the binding loops --- resources/qml/delegates/FileMessage.qml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'resources/qml/delegates/FileMessage.qml') 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 -- cgit 1.5.1 From d0ac110cb7013124c511bbe3ea2dc05db9e695b2 Mon Sep 17 00:00:00 2001 From: Malte E Date: Fri, 11 Feb 2022 22:02:30 +0100 Subject: Fix layout - no more binding loops (hopefully) --- resources/qml/MessageView.qml | 4 +-- resources/qml/ReplyPopup.qml | 1 + resources/qml/TimelineRow.qml | 31 +++++++++--------------- resources/qml/delegates/FileMessage.qml | 5 ++-- resources/qml/delegates/ImageMessage.qml | 11 +++------ resources/qml/delegates/MessageDelegate.qml | 13 +++------- resources/qml/delegates/Pill.qml | 4 +-- resources/qml/delegates/PlayableMediaMessage.qml | 11 +++------ resources/qml/delegates/Redacted.qml | 11 +++++---- resources/qml/delegates/Reply.qml | 4 +-- 10 files changed, 35 insertions(+), 60 deletions(-) (limited to 'resources/qml/delegates/FileMessage.qml') diff --git a/resources/qml/MessageView.qml b/resources/qml/MessageView.qml index aef05a63..a00ada3e 100644 --- a/resources/qml/MessageView.qml +++ b/resources/qml/MessageView.qml @@ -33,7 +33,7 @@ ScrollView { //reuseItems: true boundsBehavior: Flickable.StopAtBounds pixelAligned: true - spacing: 4 + spacing: 2 verticalLayoutDirection: ListView.BottomToTop onCountChanged: { // Mark timeline as read @@ -464,7 +464,7 @@ ScrollView { property date timestamp: wrapper.timestamp z: 4 - active: previousMessageUserId !== undefined && previousMessageUserId !== userId || previousMessageDay !== day + active: previousMessageUserId !== undefined && previousMessageUserId !== userId || previousMessageDay !== day || previousMessageIsStateEvent !== isStateEvent //asynchronous: true sourceComponent: sectionHeader visible: status == Loader.Ready diff --git a/resources/qml/ReplyPopup.qml b/resources/qml/ReplyPopup.qml index e6c83835..ef0d7c60 100644 --- a/resources/qml/ReplyPopup.qml +++ b/resources/qml/ReplyPopup.qml @@ -47,6 +47,7 @@ Rectangle { userId: modelData.userId ?? "" userName: modelData.userName ?? "" encryptionError: modelData.encryptionError ?? "" + width: parent.width } ImageButton { diff --git a/resources/qml/TimelineRow.qml b/resources/qml/TimelineRow.qml index b40ce068..85e6fa4b 100644 --- a/resources/qml/TimelineRow.qml +++ b/resources/qml/TimelineRow.qml @@ -47,7 +47,7 @@ Item { anchors.left: parent.left anchors.right: parent.right - height: row.height+reactionRow.height+(Settings.bubbles? 8 : 4) + height: row.height+reactionRow.height Rectangle { color: (Settings.messageHoverHighlight && hoverHandler.hovered) ? Nheko.colors.alternateBase : "transparent" @@ -78,30 +78,19 @@ Item { anchors.rightMargin: 1 anchors.leftMargin: Nheko.avatarSize + 12 // align bubble with section header anchors.left: parent.left - //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 - leftInset: -4 - rightInset: -4 + width: Settings.bubbles? Math.min(maxWidth,implicitWidth+metadata.width) : maxWidth + padding: isStateEvent? 0 : 3 background: Rectangle { - //anchors.fill: msg property color userColor: TimelineManager.userColor(userId, Nheko.colors.base) property color bgColor: Nheko.colors.base - color: Qt.rgba(userColor.r*0.1+bgColor.r*0.9,userColor.g*0.1+bgColor.g*0.9,userColor.b*0.1+bgColor.b*0.9,1) //TimelineManager.userColor(userId, Nheko.colors.base) - radius: 4 + color: Qt.tint(bgColor, Qt.rgba(userColor.r, userColor.g, userColor.b, 0.2)) + radius: parent.padding*2 visible: Settings.bubbles && !isStateEvent } - GridLayout { + contentItem: GridLayout { id: msg - anchors { - right: parent.right - left: parent.left - top: parent.top - } 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 @@ -114,6 +103,8 @@ Item { Layout.column: 0 Layout.fillWidth: true Layout.bottomMargin: visible? 2 : 0 + Layout.preferredHeight: height + Layout.maximumWidth: implicitWidth id: reply function fromModel(role) { @@ -142,7 +133,6 @@ 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 @@ -150,6 +140,8 @@ Item { Layout.row: 1 Layout.column: 0 Layout.fillWidth: true + Layout.preferredHeight: height + Layout.maximumWidth: implicitWidth id: contentItem blurhash: r.blurhash @@ -174,7 +166,6 @@ Item { encryptionError: r.encryptionError relatedEventCacheBuster: r.relatedEventCacheBuster isReply: false - maxWidth: row.maxWidth } RowLayout { @@ -182,7 +173,7 @@ Item { 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.bottomMargin: -4 Layout.alignment: Qt.AlignTop | Qt.AlignRight Layout.preferredWidth: implicitWidth visible: !isStateEvent diff --git a/resources/qml/delegates/FileMessage.qml b/resources/qml/delegates/FileMessage.qml index 2ac2a80a..1e50fe3a 100644 --- a/resources/qml/delegates/FileMessage.qml +++ b/resources/qml/delegates/FileMessage.qml @@ -11,11 +11,10 @@ Item { required property string eventId required property string filename required property string filesize - property int maxWidth height: row.height + 24 - width: maxWidth - implicitWidth: maxWidth + width: parent.width + implicitWidth: row.implicitWidth RowLayout { id: row diff --git a/resources/qml/delegates/ImageMessage.qml b/resources/qml/delegates/ImageMessage.qml index 3bbcd077..a13bb4f6 100644 --- a/resources/qml/delegates/ImageMessage.qml +++ b/resources/qml/delegates/ImageMessage.qml @@ -17,16 +17,11 @@ Item { required property string filename required property bool isReply required property string eventId - 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 + implicitWidth: Math.round(originalWidth*Math.min((timelineView.height/divisor)/(originalWidth*proportionalHeight), 1)) + width: parent.width + height: width*proportionalHeight Image { id: blurhash_ diff --git a/resources/qml/delegates/MessageDelegate.qml b/resources/qml/delegates/MessageDelegate.qml index 5d987841..3210128a 100644 --- a/resources/qml/delegates/MessageDelegate.qml +++ b/resources/qml/delegates/MessageDelegate.qml @@ -35,9 +35,8 @@ 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 + height: chooser.child ? chooser.child.height : Nheko.paddingLarge DelegateChooser { id: chooser @@ -46,8 +45,7 @@ Item { roleValue: type //anchors.fill: parent - anchors.left: parent.left - anchors.right: parent.right + width: parent.width? parent.width: 0 // this should get rid of "cannot read property 'width' of null" DelegateChoice { roleValue: MtxEvent.UnknownMessage @@ -111,7 +109,6 @@ Item { filename: d.filename isReply: d.isReply eventId: d.eventId - maxWidth: d.maxWidth } } @@ -129,7 +126,6 @@ Item { filename: d.filename isReply: d.isReply eventId: d.eventId - maxWidth: d.maxWidth } } @@ -141,7 +137,6 @@ Item { eventId: d.eventId filename: d.filename filesize: d.filesize - maxWidth: d.maxWidth } } @@ -158,7 +153,6 @@ Item { url: d.url body: d.body filesize: d.filesize - maxWidth: d.maxWidth } } @@ -175,7 +169,6 @@ Item { url: d.url body: d.body filesize: d.filesize - maxWidth: d.maxWidth } } @@ -184,7 +177,7 @@ Item { roleValue: MtxEvent.Redacted Redacted { - delegateWidth: d.width + //delegateWidth: d.width } } diff --git a/resources/qml/delegates/Pill.qml b/resources/qml/delegates/Pill.qml index bfc18b9a..a3964f73 100644 --- a/resources/qml/delegates/Pill.qml +++ b/resources/qml/delegates/Pill.qml @@ -11,8 +11,8 @@ Label { property bool isStateEvent color: Nheko.colors.text horizontalAlignment: Text.AlignHCenter - height: contentHeight * 1.2 - width: contentWidth * 1.2 + //height: contentHeight * 1.2 + //width: contentWidth * 1.2 font.pointSize: isStateEvent? 0.75*fontMetrics.font.pointSize : 1*fontMetrics.font.pointSize background: Rectangle { diff --git a/resources/qml/delegates/PlayableMediaMessage.qml b/resources/qml/delegates/PlayableMediaMessage.qml index 805eafbf..9324cdaf 100644 --- a/resources/qml/delegates/PlayableMediaMessage.qml +++ b/resources/qml/delegates/PlayableMediaMessage.qml @@ -22,16 +22,11 @@ Item { required property string url required property string body required property string filesize - 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 + implicitWidth: type == MtxEvent.VideoMessage ? Math.round(originalWidth*Math.min((timelineView.height/divisor)/(originalWidth*proportionalHeight), 1)) : 500 + width: parent.width + height: (type == MtxEvent.VideoMessage ? width*proportionalHeight : 80) + fileInfoLabel.height implicitHeight: height - implicitWidth: width MxcMedia { id: mxcmedia diff --git a/resources/qml/delegates/Redacted.qml b/resources/qml/delegates/Redacted.qml index b0c9abfe..cf723988 100644 --- a/resources/qml/delegates/Redacted.qml +++ b/resources/qml/delegates/Redacted.qml @@ -10,10 +10,10 @@ import im.nheko 1.0 Rectangle{ - required property real delegateWidth + //required property real delegateWidth height: redactedLayout.implicitHeight + Nheko.paddingSmall - width: redactedLayout.implicitWidth + 2 * Nheko.paddingMedium - implicitWidth: width + implicitWidth: redactedLayout.implicitWidth + 2 * Nheko.paddingMedium + //implicitWidth: width radius: fontMetrics.lineSpacing / 2 + 2 * Nheko.paddingSmall color: Nheko.colors.alternateBase @@ -33,8 +33,9 @@ Rectangle{ id: redactedLabel Layout.margins: 0 Layout.alignment: Qt.AlignVCenter | Qt.AlignRight - Layout.fillWidth: true - Layout.maximumWidth: delegateWidth - 4 * Nheko.paddingSmall - trashImg.width - 2 * Nheko.paddingMedium + Layout.preferredWidth: implicitWidth + //Layout.fillWidth: true + //Layout.maximumWidth: delegateWidth - 4 * Nheko.paddingSmall - trashImg.width - 2 * Nheko.paddingMedium property var redactedPair: room.formatRedactedEvent(eventId) text: redactedPair["first"] wrapMode: Label.WordWrap diff --git a/resources/qml/delegates/Reply.qml b/resources/qml/delegates/Reply.qml index 28f0dd21..c60867de 100644 --- a/resources/qml/delegates/Reply.qml +++ b/resources/qml/delegates/Reply.qml @@ -37,8 +37,8 @@ Item { property int relatedEventCacheBuster property int maxWidth - Layout.preferredHeight: replyContainer.height height: replyContainer.height + implicitHeight: replyContainer.height implicitWidth: visible? colorLine.width+replyContainer.implicitWidth : 0 CursorShape { @@ -99,6 +99,7 @@ Item { MessageDelegate { Layout.leftMargin: 4 + Layout.preferredHeight: height id: reply blurhash: r.blurhash body: r.body @@ -125,7 +126,6 @@ Item { enabled: false Layout.fillWidth: true isReply: true - maxWidth: r.maxWidth-4 } } -- cgit 1.5.1 From 414257bf0eba7f8415644509ae617883ac266e40 Mon Sep 17 00:00:00 2001 From: Malte E Date: Mon, 14 Feb 2022 14:03:17 +0100 Subject: fix bugs found by Nico --- resources/qml/MessageView.qml | 2 +- resources/qml/delegates/FileMessage.qml | 3 +-- resources/qml/delegates/PlayableMediaMessage.qml | 3 ++- resources/qml/delegates/Redacted.qml | 3 +-- src/UserSettingsPage.cpp | 4 ++-- 5 files changed, 7 insertions(+), 8 deletions(-) (limited to 'resources/qml/delegates/FileMessage.qml') diff --git a/resources/qml/MessageView.qml b/resources/qml/MessageView.qml index c465c72e..f32d68a0 100644 --- a/resources/qml/MessageView.qml +++ b/resources/qml/MessageView.qml @@ -250,7 +250,7 @@ ScrollView { Column { topPadding: userName_.visible? 4: 0 - bottomPadding: Settings.bubbles? 0 : 3 + bottomPadding: Settings.bubbles? 2 : 3 spacing: 8 visible: (previousMessageUserId !== userId || previousMessageDay !== day || isStateEvent !== previousMessageIsStateEvent) width: parentWidth diff --git a/resources/qml/delegates/FileMessage.qml b/resources/qml/delegates/FileMessage.qml index 1e50fe3a..fd81b176 100644 --- a/resources/qml/delegates/FileMessage.qml +++ b/resources/qml/delegates/FileMessage.qml @@ -87,8 +87,7 @@ Item { color: Nheko.colors.alternateBase z: -1 radius: 10 - height: row.height + 24 - width: 44 + 24 + 24 + Math.max(Math.min(filesize_.width, filesize_.implicitWidth), Math.min(filename_.width, filename_.implicitWidth)) + anchors.fill: parent } } diff --git a/resources/qml/delegates/PlayableMediaMessage.qml b/resources/qml/delegates/PlayableMediaMessage.qml index 9324cdaf..54813d23 100644 --- a/resources/qml/delegates/PlayableMediaMessage.qml +++ b/resources/qml/delegates/PlayableMediaMessage.qml @@ -23,7 +23,8 @@ Item { required property string body required property string filesize property double divisor: isReply ? 4 : 2 - implicitWidth: type == MtxEvent.VideoMessage ? Math.round(originalWidth*Math.min((timelineView.height/divisor)/(originalWidth*proportionalHeight), 1)) : 500 + property int tempWidth: originalWidth < 1? 400: originalWidth + implicitWidth: type == MtxEvent.VideoMessage ? Math.round(tempWidth*Math.min((timelineView.height/divisor)/(tempWidth*proportionalHeight), 1)) : 500 width: parent.width height: (type == MtxEvent.VideoMessage ? width*proportionalHeight : 80) + fileInfoLabel.height implicitHeight: height diff --git a/resources/qml/delegates/Redacted.qml b/resources/qml/delegates/Redacted.qml index cf723988..7e5a10f9 100644 --- a/resources/qml/delegates/Redacted.qml +++ b/resources/qml/delegates/Redacted.qml @@ -10,10 +10,9 @@ import im.nheko 1.0 Rectangle{ - //required property real delegateWidth height: redactedLayout.implicitHeight + Nheko.paddingSmall implicitWidth: redactedLayout.implicitWidth + 2 * Nheko.paddingMedium - //implicitWidth: width + width: parent.width radius: fontMetrics.lineSpacing / 2 + 2 * Nheko.paddingSmall color: Nheko.colors.alternateBase diff --git a/src/UserSettingsPage.cpp b/src/UserSettingsPage.cpp index 000e2976..e3f80699 100644 --- a/src/UserSettingsPage.cpp +++ b/src/UserSettingsPage.cpp @@ -70,8 +70,8 @@ UserSettings::load(std::optional profile) enlargeEmojiOnlyMessages_ = settings.value(QStringLiteral("user/timeline/enlarge_emoji_only_msg"), false).toBool(); markdown_ = settings.value(QStringLiteral("user/markdown_enabled"), true).toBool(); - bubbles_ = settings.value(QStringLiteral("user/bubbles_enabled"), true).toBool(); - smallAvatars_ = settings.value(QStringLiteral("user/small_avatars_enabled"), true).toBool(); + bubbles_ = settings.value(QStringLiteral("user/bubbles_enabled"), false).toBool(); + smallAvatars_ = settings.value(QStringLiteral("user/small_avatars_enabled"), false).toBool(); animateImagesOnHover_ = settings.value(QStringLiteral("user/animate_images_on_hover"), false).toBool(); typingNotifications_ = -- cgit 1.5.1