From 3fcf6518d25b8fbda218e7245048484dc9e4d590 Mon Sep 17 00:00:00 2001 From: Noelia Date: Fri, 3 Feb 2023 13:27:42 +0100 Subject: [PATCH] fix(CommunityIntroDialog): Improved layout resizing Improved layout resizing. --- .../shared/popups/CommunityIntroDialog.qml | 76 ++++++++++++------- 1 file changed, 49 insertions(+), 27 deletions(-) diff --git a/ui/imports/shared/popups/CommunityIntroDialog.qml b/ui/imports/shared/popups/CommunityIntroDialog.qml index f749f8e673..ee4aaf464a 100644 --- a/ui/imports/shared/popups/CommunityIntroDialog.qml +++ b/ui/imports/shared/popups/CommunityIntroDialog.qml @@ -23,6 +23,26 @@ StatusDialog { signal joined signal cancelMembershipRequest + QtObject { + id: d + + readonly property int maxWidth: 640 + readonly property int minWidth: 300 + readonly property int maxHeight: 640 + + function getHorizontalPaddings() { + return root.leftPadding + root.rightPadding + } + + function getVerticalPaddings() { + return root.topPadding + root.bottomPadding + } + + function getMaxMinWidth() { + return Math.max(introText.implicitWidth, d.minWidth - d.getHorizontalPaddings()) + } + } + title: qsTr("Welcome to %1").arg(name) footer: StatusDialogFooter { @@ -35,12 +55,11 @@ StatusDialog { type: root.isInvitationPending ? StatusBaseButton.Type.Danger : StatusBaseButton.Type.Normal enabled: checkBox.checked || root.isInvitationPending - onClicked: { if (root.isInvitationPending) { root.cancelMembershipRequest() } else { - root.joined() + root.joined() } root.close() @@ -49,44 +68,47 @@ StatusDialog { } } - ColumnLayout { + implicitWidth: Math.min(d.getMaxMinWidth(), d.maxWidth - d.getHorizontalPaddings()) + implicitHeight: Math.min(columnContent.height + footer.height + header.height + d.getVerticalPaddings(), d.maxHeight) + + StatusScrollView { anchors.fill: parent + contentHeight: columnContent.height + contentWidth: columnContent.width + padding: 0 - spacing: 24 + ColumnLayout { + id: columnContent - StatusRoundedImage { - Layout.alignment: Qt.AlignCenter - Layout.preferredHeight: 64 - Layout.preferredWidth: 64 + spacing: 24 + width: Math.max(root.width - d.getHorizontalPaddings(), d.minWidth - d.getHorizontalPaddings()) - visible: image.status == Image.Loading || image.status == Image.Ready - image.source: root.imageSrc - } + StatusRoundedImage { + id: roundImage - StatusScrollView { - Layout.minimumWidth: 300 - Layout.preferredWidth: contentWidth + 2 * padding - - Layout.fillHeight: true - Layout.preferredHeight: contentHeight + 2 * padding - Layout.maximumHeight: 400 + Layout.alignment: Qt.AlignCenter + Layout.preferredHeight: 64 + Layout.preferredWidth: Layout.preferredHeight + visible: image.status == Image.Loading || image.status == Image.Ready + image.source: root.imageSrc + } StatusBaseText { - id: messageContent - - width: Math.min(implicitWidth, 640) + id: introText + Layout.fillWidth: true text: root.introMessage !== "" ? root.introMessage : qsTr("Community %1 has no intro message...").arg(root.name) color: Theme.palette.directColor1 wrapMode: Text.WordWrap } - } - StatusCheckBox { - id: checkBox - Layout.alignment: Qt.AlignCenter - visible: !root.isInvitationPending - text: qsTr("I agree with the above") + StatusCheckBox { + id: checkBox + + Layout.alignment: Qt.AlignCenter + visible: !root.isInvitationPending + text: qsTr("I agree with the above") + } } } }