|
| 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 | +} |
0 commit comments