KCMUtils

AboutPlugin.qml
1/*
2 SPDX-FileCopyrightText: 2018 Aleix Pol Gonzalez <aleixpol@blue-systems.com>
3 SPDX-FileCopyrightText: 2020 David Redondo <kde@david-redondo.de>
4 SPDX-FileCopyrightText: 2022 Alexander Lohnau <alexander.lohnau@gmx.de>
5
6 SPDX-License-Identifier: LGPL-2.0-or-later
7*/
8
9import QtQuick
10import QtQuick.Controls as QQC2
11import QtQuick.Layouts
12
13import org.kde.kirigami as Kirigami
14
15/**
16 * A copy of Kirigami.AboutPage adapted to KPluginMetadata instead of KAboutData
17 */
18ColumnLayout {
19 id: root
20
21 property var metaData
22
23 // Icon, name, version, and description
24 RowLayout {
25 Layout.fillWidth: true
26 spacing: Kirigami.Units.largeSpacing
27
28 Kirigami.Icon {
29 Layout.preferredHeight: Kirigami.Units.iconSizes.huge
30 Layout.preferredWidth: Kirigami.Units.iconSizes.huge
31 source: root.metaData.iconName
32 fallback: "application-x-plasma"
33 }
34
35 ColumnLayout {
36 Layout.fillWidth: true
37
38 Kirigami.Heading {
39 Layout.fillWidth: true
40 text: root.metaData.version ? i18ndc("kcmutils6", "Plugin name and plugin version", "%1 %2", root.metaData.name, root.metaData.version) : root.metaData.name
41 wrapMode: Text.WordWrap
42 }
43 Kirigami.Heading {
44 Layout.fillWidth: true
45 level: 2
46 text: root.metaData.description
47 wrapMode: Text.WordWrap
48 }
49 }
50 }
51
52
53 Kirigami.Separator {
54 Layout.fillWidth: true
55 Layout.topMargin: Kirigami.Units.largeSpacing
56 Layout.bottomMargin: Kirigami.Units.largeSpacing
57 }
58
59
60 // Copyright
61 Kirigami.Heading {
62 text: i18nd("kcmutils6", "Copyright")
63 }
64 QQC2.Label {
65 Layout.leftMargin: Kirigami.Units.gridUnit
66 text: root.metaData.copyrightText
67 visible: text.length > 0
68 }
69 Kirigami.UrlButton {
70 Layout.leftMargin: Kirigami.Units.gridUnit
71 url: root.metaData.website ? root.metaData.website : ""
72 visible: url.length > 0
73 }
74
75
76 // License
77 RowLayout {
78 QQC2.Label {
79 text: i18nd("kcmutils6", "License:")
80 }
81 Kirigami.LinkButton {
82 text: root.metaData.license
83 onClicked: {
84 licenseSheet.text = root.metaData.licenseText
85 licenseSheet.title = root.metaData.license
86 licenseSheet.open()
87 }
88 }
89 }
90
91
92 // Authors, if any
93 Item {
94 implicitHeight: Kirigami.Units.largeSpacing
95 visible: repAuthors.visible
96 }
97 Kirigami.Heading {
98 text: i18nd("kcmutils6", "Authors")
99 visible: repAuthors.visible
100 }
101 Repeater {
102 id: repAuthors
103 visible: count > 0
104 model: root.metaData.authors
105 delegate: personDelegate
106 }
107
108
109 // Credits, if any
110 Item {
111 implicitHeight: Kirigami.Units.largeSpacing
112 visible: repCredits.visible
113 }
114 Kirigami.Heading {
115 text: i18nd("kcmutils6", "Credits")
116 visible: repCredits.visible
117 }
118 Repeater {
119 id: repCredits
120 visible: count > 0
121 model: root.metaData.otherContributors
122 delegate: personDelegate
123 }
124
125
126 // Translators, if any
127 Item {
128 implicitHeight: Kirigami.Units.largeSpacing
129 visible: repTranslators.visible
130 }
131 Kirigami.Heading {
132 text: i18nd("kcmutils6", "Translators")
133 visible: repTranslators.visible
134 }
135 Repeater {
136 id: repTranslators
137 visible: count > 0
138 model: root.metaData.translators
139 delegate: personDelegate
140 }
141
142
143 Component {
144 id: personDelegate
145
146 RowLayout {
147 height: implicitHeight + (Kirigami.Units.largeSpacing)
148
149 spacing: Kirigami.Units.largeSpacing
150
151 QQC2.Label {
152 text: modelData.name
153 }
154 QQC2.ToolButton {
155 visible: modelData.emailAddress
156 icon.name: "mail-sent"
157 QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
158 QQC2.ToolTip.visible: hovered
159 QQC2.ToolTip.text: i18nd("kcmutils6", "Send an email to %1", modelData.emailAddress)
160 onClicked: Qt.openUrlExternally("mailto:%1".arg(modelData.emailAddress))
161 }
162 QQC2.ToolButton {
163 visible: modelData.webAddress
164 icon.name: "globe"
165 QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
166 QQC2.ToolTip.visible: hovered
167 QQC2.ToolTip.text: modelData.webAddress
168 onClicked: Qt.openUrlExternally(modelData.webAddress)
169 }
170 }
171 }
172
173 QQC2.Dialog {
174 id: licenseSheet
175 property alias text: licenseLabel.text
176
177 width: parent.width
178 height: parent.height
179 anchors.centerIn: parent
180
181 topPadding: 0
182 leftPadding: 0
183 rightPadding: 0
184 bottomPadding: 0
185
186 contentItem: QQC2.ScrollView {
187 id: scroll
188 Component.onCompleted: {
189 if (background) {
190 background.visible = true;
191 }
192 }
193 Flickable {
194 id: flickable
195 contentWidth: width
196 contentHeight: licenseLabel.contentHeight
197 clip: true
198 QQC2.Label {
199 id: licenseLabel
200 width: parent.width
201 wrapMode: Text.WordWrap
202 }
203 }
204 }
205 }
206}
A ScrollView containing a GridView, with the default behavior about sizing and background as recommen...
QString i18ndc(const char *domain, const char *context, const char *text, const TYPE &arg...)
QString i18nd(const char *domain, const char *text, const TYPE &arg...)
QStringView level(QStringView ifopt)
QString name(StandardAction id)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:02:19 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.