From 0a8a73ca902df4df14d9246ce7c2977150947cce Mon Sep 17 00:00:00 2001 From: zhaofangxun Date: Wed, 20 May 2026 18:11:58 +0800 Subject: [PATCH] fix: add scroll support and fix title bar layout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Wrap right content area in a Flickable with vertical ScrollBar to handle overflow when content exceeds dialog height 2. Fix content height calculation to use explicit height instead of implicitHeight for proper layout 3. Hide title bar label when title is empty using a Loader 4. Adjust padding to remove top and right padding for better alignment 5. Add bottom margin to acknowledgements section to prevent content cutoff at the bottom Log: Fix about dialog content overflow by adding scrollable area and correct title bar layout fix: 添加滚动支持并修复标题栏布局 1. 将右侧内容区域包裹在带垂直滚动条的 Flickable 中,解决内容超出 对话框高度时的显示问题 2. 修复内容高度计算,使用显式高度替代 implicitHeight 以确保正确布局 3. 使用 Loader 在标题为空时隐藏标题栏文本 4. 调整内边距,移除顶部和右侧内边距以改善对齐效果 5. 为致谢部分添加底部边距,防止内容在底部被截断 Log: 修复关于对话框内容溢出问题,添加可滚动区域并修正标题栏布局 PMS: BUG-361037 --- qt6/src/qml/AboutDialog.qml | 172 +++++++++++++++++++---------------- qt6/src/qml/DialogWindow.qml | 13 ++- 2 files changed, 104 insertions(+), 81 deletions(-) diff --git a/qt6/src/qml/AboutDialog.qml b/qt6/src/qml/AboutDialog.qml index 006d7d9a..88ba78da 100644 --- a/qt6/src/qml/AboutDialog.qml +++ b/qt6/src/qml/AboutDialog.qml @@ -4,6 +4,7 @@ import QtQuick import QtQuick.Layouts +import QtQuick.Controls import QtQuick.Window import org.deepin.dtk 1.0 as D import org.deepin.dtk.style 1.0 as DS @@ -12,6 +13,8 @@ DialogWindow { id: control width: DS.Style.aboutDialog.width height: DS.Style.aboutDialog.height + topPadding: 0 + rightPadding: 0 property alias windowTitle: control.title property alias productName: productNameLabel.text @@ -30,7 +33,7 @@ DialogWindow { RowLayout { id: contentView width: parent.width - implicitHeight: contentLayout.implicitHeight + height: control.height - DS.Style.dialogWindow.titleBarHeight D.LicenseInfoProvider { id: licensePathChecker @@ -79,94 +82,109 @@ DialogWindow { visible: control.license !== "" } } - ColumnLayout { + Flickable { + id: rightContentView + ScrollBar.vertical: ScrollBar {} Layout.alignment: Qt.AlignLeft | Qt.AlignTop - spacing: 10 Layout.fillWidth: true Layout.fillHeight: true - Layout.rightMargin: 20 - ColumnLayout { - spacing: 1 - Label { - font: D.DTK.fontManager.t10 - text: qsTr("Version") - } - Label { - id: versionLabel - font: D.DTK.fontManager.t8 - wrapMode: Text.WordWrap - text: Qt.application.version - Layout.fillWidth: true - } - } - ColumnLayout { - spacing: 1 - Label { - font: D.DTK.fontManager.t10 - text: qsTr("Homepage") - } - Label { - id: websiteLabel - font: D.DTK.fontManager.t8 - textFormat: Text.RichText - text: (control.websiteLink === "" || control.websiteName === "") ? - "" : control.__websiteLinkTemplate.arg(websiteLink).arg(control.websiteName) - wrapMode: Text.WordWrap - Layout.fillWidth: true - - MouseArea { - anchors.fill: parent - cursorShape: Qt.PointingHandCursor - acceptedButtons: Qt.NoButton + clip: true + contentWidth: width + contentHeight: rightContentLayout.height + boundsBehavior: Flickable.StopAtBounds + flickableDirection: Flickable.VerticalFlick + + Item { + ColumnLayout { + id: rightContentLayout + width: rightContentView.width + spacing: 10 + + ColumnLayout { + spacing: 1 + Label { + font: D.DTK.fontManager.t10 + text: qsTr("Version") + } + Label { + id: versionLabel + font: D.DTK.fontManager.t8 + wrapMode: Text.WordWrap + text: Qt.application.version + Layout.fillWidth: true + } } - } - } - ColumnLayout { - spacing: 1 - Label { - font: D.DTK.fontManager.t10 - text: qsTr("Description") - } - Label { - id: descriptionLabel - Layout.fillWidth: true - font: D.DTK.fontManager.t8 - wrapMode: Text.WordWrap - elide: Text.ElideRight - } - } + ColumnLayout { + spacing: 1 + Label { + font: D.DTK.fontManager.t10 + text: qsTr("Homepage") + } + Label { + id: websiteLabel + font: D.DTK.fontManager.t8 + textFormat: Text.RichText + text: (control.websiteLink === "" || control.websiteName === "") ? + "" : control.__websiteLinkTemplate.arg(websiteLink).arg(control.websiteName) + wrapMode: Text.WordWrap + Layout.fillWidth: true - ColumnLayout { - spacing: 1 - Label { - font: D.DTK.fontManager.t10 - text: qsTr("Acknowledgements") - } - Label { - id: acknowledgmentsLabel - text: { - var softwareText = qsTr("open-source software"); - if (licensePathChecker.valid) - return qsTr("Sincerely appreciate the %1 used.").arg(control.__websiteLinkTemplate.arg("-").arg(softwareText)); - else - return qsTr("Sincerely appreciate the %1 used.").arg(softwareText); + MouseArea { + anchors.fill: parent + cursorShape: Qt.PointingHandCursor + acceptedButtons: Qt.NoButton + } + } } - textFormat: Text.RichText - Layout.fillWidth: true - font: D.DTK.fontManager.t8 - wrapMode: Text.WordWrap + ColumnLayout { + spacing: 1 + Label { + font: D.DTK.fontManager.t10 + text: qsTr("Description") + } + Label { + id: descriptionLabel + Layout.fillWidth: true + font: D.DTK.fontManager.t8 + wrapMode: Text.WordWrap elide: Text.ElideRight - - onLinkActivated: function(link) { - licenseDialogLoader.active = true + } } - HoverHandler { - cursorShape: acknowledgmentsLabel.hoveredLink !== "" ? Qt.PointingHandCursor : Qt.ArrowCursor + ColumnLayout { + Layout.bottomMargin: 30 + spacing: 1 + Label { + font: D.DTK.fontManager.t10 + text: qsTr("Acknowledgements") + } + Label { + id: acknowledgmentsLabel + text: { + var softwareText = qsTr("open-source software"); + if (licensePathChecker.valid) + return qsTr("Sincerely appreciate the %1 used.").arg(control.__websiteLinkTemplate.arg("-").arg(softwareText)); + else + return qsTr("Sincerely appreciate the %1 used.").arg(softwareText); + } + textFormat: Text.RichText + Layout.fillWidth: true + font: D.DTK.fontManager.t8 + wrapMode: Text.WordWrap + elide: Text.ElideRight + + onLinkActivated: function(link) { + licenseDialogLoader.active = true + } + + HoverHandler { + cursorShape: acknowledgmentsLabel.hoveredLink !== "" ? Qt.PointingHandCursor : Qt.ArrowCursor + } + } } } } - } + } Component.onCompleted: { websiteLabel.linkActivated.connect(D.ApplicationHelper.openUrl) diff --git a/qt6/src/qml/DialogWindow.qml b/qt6/src/qml/DialogWindow.qml index 3e49812c..7b23b992 100644 --- a/qt6/src/qml/DialogWindow.qml +++ b/qt6/src/qml/DialogWindow.qml @@ -66,12 +66,17 @@ Window { } } - D.Label { - text: control.title + Loader { + active: title !== "" Layout.fillWidth: true Layout.alignment: Qt.AlignHCenter - elide: Text.ElideRight - horizontalAlignment: Text.AlignHCenter + sourceComponent: Component { + D.Label { + text: control.title + elide: Text.ElideRight + horizontalAlignment: Text.AlignHCenter + } + } } Item {