From a7c137ca39353f9e2250a7f81db2648270297be0 Mon Sep 17 00:00:00 2001 From: James Graham Date: Sun, 3 Jul 2022 14:26:08 +0100 Subject: [PATCH] Allow the delegate and bubble widths to grow when the ListView is very wide. Disable user message on the right setting when in compact mode as it doesn't work anyway. --- .../NeoChat/Component/Timeline/TimelineContainer.qml | 10 ++++++---- imports/NeoChat/Settings/AppearanceSettingsPage.qml | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/imports/NeoChat/Component/Timeline/TimelineContainer.qml b/imports/NeoChat/Component/Timeline/TimelineContainer.qml index d2b8d9f2a..f67b7cb74 100644 --- a/imports/NeoChat/Component/Timeline/TimelineContainer.qml +++ b/imports/NeoChat/Component/Timeline/TimelineContainer.qml @@ -19,8 +19,11 @@ QQC2.ItemDelegate { property bool isEmote: false property bool cardBackground: true - readonly property int bubbleMaxWidth: Kirigami.Units.gridUnit * 20 - readonly property int delegateMaxWidth: Config.compactLayout ? messageListView.width : Math.min(messageListView.width, Kirigami.Units.gridUnit * 40) + // The bubble and delegate widths are allowed to grow once the ListView gets beyond a certain size + // extraWidth defines this as the excess after a certain ListView width, capped to a max value + readonly property int extraWidth: Math.min((messageListView.width - Kirigami.Units.gridUnit * 40), Kirigami.Units.gridUnit * 20) + readonly property int bubbleMaxWidth: Kirigami.Units.gridUnit * 20 + extraWidth * 0.5 + readonly property int delegateMaxWidth: Config.compactLayout ? messageListView.width : Math.min(messageListView.width, Kirigami.Units.gridUnit * 40 + extraWidth) readonly property int contentMaxWidth: Config.compactLayout ? width - (Config.showAvatarInTimeline ? Kirigami.Units.gridUnit * 2 : 0) - Kirigami.Units.largeSpacing * 4 : Math.min(width - Kirigami.Units.gridUnit * 2 - Kirigami.Units.largeSpacing * 6, bubbleMaxWidth) property bool showUserMessageOnRight: Config.showLocalMessagesOnRight && @@ -38,6 +41,7 @@ QQC2.ItemDelegate { topPadding: 0 bottomPadding: 0 width: delegateMaxWidth + height: sectionDelegate.height + Math.max(model.showAuthor ? avatar.height : 0, bubble.implicitHeight) + loader.height + (showAuthor ? Kirigami.Units.largeSpacing : 0) background: null property Item hoverComponent @@ -85,8 +89,6 @@ QQC2.ItemDelegate { } ] - height: sectionDelegate.height + Math.max(model.showAuthor ? avatar.height : 0, bubble.implicitHeight) + loader.height + (showAuthor ? Kirigami.Units.largeSpacing : 0) - SectionDelegate { id: sectionDelegate width: parent.width diff --git a/imports/NeoChat/Settings/AppearanceSettingsPage.qml b/imports/NeoChat/Settings/AppearanceSettingsPage.qml index e23ec44d6..0682b2674 100644 --- a/imports/NeoChat/Settings/AppearanceSettingsPage.qml +++ b/imports/NeoChat/Settings/AppearanceSettingsPage.qml @@ -245,7 +245,7 @@ Kirigami.ScrollablePage { QQC2.CheckBox { text: i18n("Show your messages on the right") checked: Config.showLocalMessagesOnRight - enabled: !Config.isShowLocalMessagesOnRightImmutable + enabled: !Config.isShowLocalMessagesOnRightImmutable && !Config.compactLayout onToggled: { Config.showLocalMessagesOnRight = checked Config.save()