Skip to content

Commit 2483868

Browse files
committed
feat: add license dialog and update about dialog
1. Added new LicenseDialog.qml component for displaying open-source software licenses 2. Modified AboutDialog.qml to replace inline license text with link to license dialog 3. Updated DialogTitleBar.qml to support left content area for back navigation 4. Added DLicenseInfoProvider C++ class to parse and provide license information 5. Updated copyright years from 2022 to 2026 across modified files 6. Added LicenseDialog to QML resources and build system Log: Added license dialog for displaying open-source software acknowledgements feat: 添加许可证对话框并更新关于对话框 1. 新增 LicenseDialog.qml 组件用于显示开源软件许可证信息 2. 修改 AboutDialog.qml,将内联许可证文本替换为指向许可证对话框的链接 3. 更新 DialogTitleBar.qml 以支持左侧内容区域用于返回导航 4. 新增 DLicenseInfoProvider C++ 类用于解析和提供许可证信息 5. 将修改文件的版权年份从 2022 更新至 2026 6. 将 LicenseDialog 添加到 QML 资源和构建系统中 Log: 新增用于显示开源软件致谢的许可证对话框 PMS: TASK-387863
1 parent 224f6f8 commit 2483868

57 files changed

Lines changed: 2770 additions & 1317 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

qmlplugin/qmlplugin_plugin.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2020 - 2022 UnionTech Software Technology Co., Ltd.
1+
// SPDX-FileCopyrightText: 2020 - 2026 UnionTech Software Technology Co., Ltd.
22
//
33
// SPDX-License-Identifier: LGPL-3.0-or-later
44

@@ -28,6 +28,7 @@
2828
#include "private/dquickarrowboxpath_p.h"
2929
#include "private/dquickcoloroverlay_p.h"
3030
#include "private/dquickapploaderitem_p.h"
31+
#include "private/dlicenseinfoprovider_p.h"
3132
#endif
3233

3334
#include "private/dquickimageprovider_p.h"
@@ -195,6 +196,7 @@ void QmlpluginPlugin::registerTypes(const char *uri)
195196
dtkRegisterType<DQuickArrowBoxPath>(uri, implUri, 1, 0, "ArrowBoxPath");
196197
dtkRegisterType<DQuickAppLoaderItem>(uri, implUri, 1, 0, "AppLoader");
197198
dtkRegisterType<DQuickColorOverlay>(uri, implUri, 1, 0, "SoftwareColorOverlay");
199+
dtkRegisterType<DLicenseInfoProvider>(uri, implUri, 1, 0, "LicenseInfoProvider");
198200

199201
dtkRegisterAnonymousType<DQUICK_NAMESPACE::DQuickDciIcon>(uri, implUri, 1);
200202
dtkRegisterAnonymousType<DQuickControlColor>(uri, implUri, 1);

qt6/src/qml.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ set(QML_DTK_CONTROLS
100100
"qml/ControlGroup.qml"
101101
"qml/ControlGroupItem.qml"
102102
"qml/DragItemsImage.qml"
103+
"qml/LicenseDialog.qml"
103104
)
104105

105106
foreach(QML_FILE ${QML_DTK_CONTROLS})

qt6/src/qml/AboutDialog.qml

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2021 - 2022 UnionTech Software Technology Co., Ltd.
1+
// SPDX-FileCopyrightText: 2021 - 2026 UnionTech Software Technology Co., Ltd.
22
//
33
// SPDX-License-Identifier: LGPL-3.0-or-later
44

@@ -18,8 +18,9 @@ DialogWindow {
1818
property alias productIcon: logoLabel.icon.name
1919
property alias version: versionLabel.text
2020
property alias description: descriptionLabel.text
21-
property alias license: licenseLabel.text
2221
property alias companyLogo: companyLogoLabel.source
22+
property alias license: licenseLabel.text
23+
property string licensePath
2324
property string websiteName
2425
property string websiteLink
2526

@@ -59,6 +60,7 @@ DialogWindow {
5960
Layout.alignment: Qt.AlignCenter
6061
Layout.topMargin: 30
6162
}
63+
6264
Label {
6365
id: licenseLabel
6466
font: D.DTK.fontManager.t10
@@ -68,7 +70,7 @@ DialogWindow {
6870
Layout.leftMargin: 30
6971
wrapMode: Text.WordWrap
7072
elide: Text.ElideRight
71-
visible: license !== ""
73+
visible: control.license !== ""
7274
}
7375
}
7476
ColumnLayout {
@@ -127,6 +129,31 @@ DialogWindow {
127129
elide: Text.ElideRight
128130
}
129131
}
132+
133+
ColumnLayout {
134+
spacing: 1
135+
Label {
136+
font: D.DTK.fontManager.t10
137+
text: qsTr("Acknowledgements")
138+
}
139+
Label {
140+
id: acknowledgmentsLabel
141+
text: qsTr("Sincerely appreciate the %1 used.").arg(control.__websiteLinkTemplate.arg("-").arg(qsTr("open-source software")))
142+
textFormat: Text.RichText
143+
Layout.fillWidth: true
144+
font: D.DTK.fontManager.t8
145+
wrapMode: Text.WordWrap
146+
elide: Text.ElideRight
147+
148+
onLinkActivated: function(link) {
149+
licenseDialogLoader.active = true
150+
}
151+
152+
HoverHandler {
153+
cursorShape: acknowledgmentsLabel.hoveredLink !== "" ? Qt.PointingHandCursor : Qt.ArrowCursor
154+
}
155+
}
156+
}
130157
}
131158

132159
Component.onCompleted: {
@@ -141,4 +168,18 @@ DialogWindow {
141168
event.accepted = true
142169
}
143170
}
171+
172+
Loader {
173+
id: licenseDialogLoader
174+
active: false
175+
sourceComponent: LicenseDialog {
176+
licensePath: control.licensePath
177+
onClosing: function (close) {
178+
licenseDialogLoader.active = false
179+
}
180+
}
181+
onLoaded: function () {
182+
licenseDialogLoader.item.show()
183+
}
184+
}
144185
}

qt6/src/qml/DialogTitleBar.qml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2021 - 2022 UnionTech Software Technology Co., Ltd.
1+
// SPDX-FileCopyrightText: 2021 - 2026 UnionTech Software Technology Co., Ltd.
22
//
33
// SPDX-License-Identifier: LGPL-3.0-or-later
44

@@ -15,6 +15,7 @@ Item {
1515
height: DS.Style.dialogWindow.titleBarHeight
1616

1717
// custom control
18+
property alias leftContent: customLeft.sourceComponent
1819
property alias content: customCenter.sourceComponent
1920
// dialog icon
2021
property alias icon: iconLabel
@@ -54,7 +55,7 @@ Item {
5455
}
5556

5657
RowLayout {
57-
spacing: 0
58+
spacing: 10
5859
Layout.alignment: Qt.AlignHCenter
5960
Layout.fillHeight: true
6061
Layout.preferredWidth: parent.width
@@ -75,10 +76,17 @@ Item {
7576
}
7677
}
7778

79+
// left custom area
80+
Loader {
81+
id: customLeft
82+
Layout.alignment: Qt.AlignLeft
83+
Layout.fillHeight: true
84+
sourceComponent: null
85+
}
86+
7887
// center custom area
7988
Loader {
8089
id: customCenter
81-
Layout.leftMargin: closeBtn.width - iconLabel.width
8290
Layout.alignment: Qt.AlignHCenter
8391
Layout.fillHeight: true
8492
Layout.fillWidth: true

qt6/src/qml/DialogWindow.qml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ Window {
4747
sourceComponent: DialogTitleBar {
4848
enableInWindowBlendBlur: true
4949
icon.name: control.icon
50+
title: control.title
5051
}
5152
}
5253

qt6/src/qml/LicenseDialog.qml

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
// SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd.
2+
//
3+
// SPDX-License-Identifier: LGPL-3.0-or-later
4+
5+
import QtQuick
6+
import QtQuick.Layouts
7+
import QtQuick.Window
8+
import QtQuick.Controls
9+
import org.deepin.dtk 1.0 as D
10+
import org.deepin.dtk.style 1.0 as DS
11+
12+
DialogWindow {
13+
id: control
14+
width: 800
15+
height: 900
16+
title: qsTr("open-source software")
17+
18+
property alias licensePath: licenseProvider.path
19+
20+
header: D.DialogTitleBar {
21+
title: control.title
22+
leftContent: Item {
23+
width: 32
24+
D.IconButton {
25+
anchors.centerIn: parent
26+
visible: stackView.depth > 1
27+
icon.name: "arrow_ordinary_left"
28+
implicitWidth: 32
29+
implicitHeight: 32
30+
icon.width: 12
31+
icon.height: 12
32+
onClicked: stackView.pop()
33+
}
34+
}
35+
}
36+
37+
Item {
38+
implicitWidth: control.width - control.leftPadding - control.rightPadding
39+
implicitHeight: control.height - DS.Style.dialogWindow.titleBarHeight - DS.Style.dialogWindow.contentHMargin
40+
41+
D.LicenseInfoProvider {
42+
id: licenseProvider
43+
}
44+
45+
StackView {
46+
id: stackView
47+
anchors.fill: parent
48+
initialItem: listPage
49+
clip: true
50+
}
51+
52+
Component {
53+
id: listPage
54+
Item {
55+
ListView {
56+
id: licenseList
57+
anchors.fill: parent
58+
clip: true
59+
model: licenseProvider.licenseList
60+
ScrollBar.vertical: ScrollBar {}
61+
62+
delegate: D.ItemDelegate {
63+
id: delegateItem
64+
implicitWidth: licenseList.width
65+
implicitHeight: 50
66+
text: modelData.name
67+
palette.windowText: undefined
68+
property D.Palette colorOdd: D.Palette {
69+
normal: Qt.rgba(0, 0, 0, 0.05)
70+
hovered: Qt.rgba(0, 0, 0, 0.1)
71+
}
72+
property D.Palette colorEven: D.Palette {
73+
normal: Qt.rgba(0, 0, 0, 0.02)
74+
hovered: Qt.rgba(0, 0, 0, 0.1)
75+
}
76+
77+
onClicked: {
78+
stackView.push(detailPage, {
79+
packageName: modelData.name,
80+
licenseText: licenseProvider.licenseContent(modelData.licenseName)
81+
})
82+
}
83+
background: D.BoxPanel {
84+
color1: index % 2 === 0 ? delegateItem.colorOdd : delegateItem.colorEven
85+
insideBorderColor: null
86+
outsideBorderColor: null
87+
dropShadowColor: null
88+
innerShadowColor1: null
89+
innerShadowColor2: null
90+
}
91+
}
92+
}
93+
}
94+
}
95+
96+
Component {
97+
id: detailPage
98+
Item {
99+
property string packageName: ""
100+
property string licenseText: ""
101+
102+
Flickable {
103+
anchors.fill: parent
104+
contentWidth: width
105+
contentHeight: detailColumn.implicitHeight
106+
clip: true
107+
topMargin: 20
108+
ScrollBar.vertical: ScrollBar {}
109+
110+
ColumnLayout {
111+
id: detailColumn
112+
width: parent.width
113+
spacing: 20
114+
115+
Text {
116+
Layout.fillWidth: true
117+
text: packageName
118+
font.pixelSize: D.DTK.fontManager.t5.pixelSize
119+
font.family: D.DTK.fontManager.t5.family
120+
font.bold: true
121+
color: D.DTK.palette.windowText
122+
}
123+
124+
MenuSeparator{}
125+
126+
Text {
127+
Layout.fillWidth: true
128+
text: licenseText
129+
font: D.DTK.fontManager.t6
130+
color: D.DTK.palette.windowText
131+
wrapMode: Text.WordWrap
132+
verticalAlignment: Text.AlignTop
133+
}
134+
}
135+
}
136+
}
137+
}
138+
}
139+
}

src/dtkdeclarative_qml.qrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,5 +115,6 @@
115115
<file>qml/private/ColorOverlay.qml</file>
116116
<file>qml/private/SoftwareColorOverlay.qml</file>
117117
<file>qml/private/ArrowListViewButton.qml</file>
118+
<file>qml/LicenseDialog.qml</file>
118119
</qresource>
119120
</RCC>
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd.
2+
//
3+
// SPDX-License-Identifier: LGPL-3.0-or-later
4+
5+
#include "dlicenseinfoprovider_p.h"
6+
7+
DQUICK_BEGIN_NAMESPACE
8+
9+
DLicenseInfoProvider::DLicenseInfoProvider(QObject *parent)
10+
: QObject(parent)
11+
{
12+
}
13+
14+
DLicenseInfoProvider::~DLicenseInfoProvider() = default;
15+
16+
QVariantList DLicenseInfoProvider::licenseList() const
17+
{
18+
auto componentInfos = m_licenseInfo.componentInfos();
19+
QVariantList list;
20+
for (const auto &info : componentInfos) {
21+
QVariantMap map;
22+
map.insert("name", info->name());
23+
map.insert("version", info->version());
24+
map.insert("copyRight", info->copyRight());
25+
map.insert("licenseName", info->licenseName());
26+
list.append(map);
27+
}
28+
return list;
29+
}
30+
31+
QString DLicenseInfoProvider::path() const
32+
{
33+
return m_path;
34+
}
35+
36+
void DLicenseInfoProvider::setPath(const QString &path)
37+
{
38+
if (m_path == path)
39+
return;
40+
m_path = path;
41+
Q_EMIT pathChanged();
42+
setValid(m_licenseInfo.loadFile(path));
43+
Q_EMIT licenseListChanged();
44+
}
45+
46+
bool DLicenseInfoProvider::isValid() const
47+
{
48+
return m_valid;
49+
}
50+
51+
void DLicenseInfoProvider::setValid(bool valid)
52+
{
53+
if (m_valid == valid)
54+
return;
55+
m_valid = valid;
56+
Q_EMIT validChanged();
57+
}
58+
59+
QString DLicenseInfoProvider::licenseContent(const QString &licenseName)
60+
{
61+
return QString::fromUtf8(m_licenseInfo.licenseContent(licenseName));
62+
}
63+
64+
void DLicenseInfoProvider::componentComplete()
65+
{
66+
setValid(m_licenseInfo.loadFile({}));
67+
Q_EMIT licenseListChanged();
68+
}
69+
70+
DQUICK_END_NAMESPACE

0 commit comments

Comments
 (0)