Kirigami-addons

AboutPage.qml
1// SPDX-FileCopyrightText: 2018 Aleix Pol Gonzalez <aleixpol@blue-systems.com>
2// SPDX-FileCopyrightText: 2021 Carl Schwan <carl@carlschwan.eu>
3// SPDX-License-Identifier: LGPL-2.0-or-later
4
5import QtQuick 2.15
6import QtQuick.Controls 2.15 as QQC2
7import QtQuick.Window 2.15
8import QtQuick.Layouts 1.15
9import org.kde.kirigami 2.20 as Kirigami
10import org.kde.kirigamiaddons.components 1.0 as KirigamiComponents
11import org.kde.coreaddons as Core
12
13import "private" as Private
14
15/**
16 * @brief An AboutPage that displays the about data using Form components.
17 *
18 * This component consists of an internationalized "About" page with the
19 * metadata of your program.
20 *
21 * It allows to show the copyright notice of the application together with
22 * the contributors and some information of which platform it's running on.
23 *
24 * @since KirigamiAddons 0.11.0
25 * @inherit org:kde::kirigami::ScrollablePage
26 */
28 id: page
29
30 /**
31 * @brief This property holds an object with the same shape as KAboutData.
32 *
33 * Set this property to either a KAboutData instance exposed from C++, or directly via a JSON object.
34 *
35 * Example usage:
36 * @code{json}
37 * aboutData: {
38 "displayName" : "KirigamiApp",
39 "productName" : "kirigami/app",
40 "componentName" : "kirigamiapp",
41 "shortDescription" : "A Kirigami example",
42 "homepage" : "",
43 "bugAddress" : "submit@bugs.kde.org",
44 "version" : "5.14.80",
45 "otherText" : "",
46 "authors" : [
47 {
48 "name" : "...",
49 "task" : "...",
50 "emailAddress" : "somebody@kde.org",
51 "webAddress" : "",
52 "ocsUsername" : ""
53 }
54 ],
55 "credits" : [],
56 "translators" : [],
57 "licenses" : [
58 {
59 "name" : "GPL v2",
60 "text" : "long, boring, license text",
61 "spdx" : "GPL-2.0"
62 }
63 ],
64 "copyrightStatement" : "© 2010-2018 Plasma Development Team",
65 "desktopFileName" : "org.kde.kirigamiapp"
66 }
67 @endcode
68 *
69 * @see KAboutData
70 */
71 property var aboutData: Core.AboutData
72
73 /**
74 * @brief This property holds a link to a "Get Involved" page.
75 *
76 * default: `"https://community.kde.org/Get_Involved" when the
77 * application ID starts with "org.kde.", otherwise empty.`
78 */
79 property url getInvolvedUrl: aboutData.desktopFileName.startsWith("org.kde.") ? "https://community.kde.org/Get_Involved" : ""
80
81 /**
82 * @brief This property holds a link to a "Donate" page.
83 *
84 * default: `"https://www.kde.org/donate" when the application ID starts with "org.kde.", otherwise empty.`
85 */
86 property url donateUrl: aboutData.desktopFileName.startsWith("org.kde.") ? "https://www.kde.org/donate" : ""
87
88 title: i18nd("kirigami-addons6", "About %1", page.aboutData.displayName)
89
90 FormCard {
91 Layout.topMargin: Kirigami.Units.gridUnit
92
94 id: generalDelegate
95 Layout.fillWidth: true
96 background: null
97 contentItem: RowLayout {
98 spacing: Kirigami.Units.smallSpacing * 2
99
100 Kirigami.Icon {
101 Layout.rowSpan: 3
102 Layout.preferredHeight: Kirigami.Units.iconSizes.huge
103 Layout.preferredWidth: height
104 Layout.maximumWidth: page.width / 3;
105 Layout.rightMargin: Kirigami.Units.largeSpacing
106 source: Kirigami.Settings.applicationWindowIcon || page.aboutData.programLogo || page.aboutData.programIconName || page.aboutData.componentName
107 }
108
109 ColumnLayout {
110 Layout.fillWidth: true
111 spacing: Kirigami.Units.smallSpacing
112
113 Kirigami.Heading {
114 Layout.fillWidth: true
115 text: page.aboutData.displayName + " " + page.aboutData.version
116 wrapMode: Text.WordWrap
117 }
118
119 Kirigami.Heading {
120 Layout.fillWidth: true
121 level: 3
122 type: Kirigami.Heading.Type.Secondary
123 wrapMode: Text.WordWrap
124 text: page.aboutData.shortDescription
125 }
126 }
127 }
128 }
129
131
133 id: copyrightDelegate
134 text: i18nd("kirigami-addons6", "Copyright")
135 descriptionItem.textFormat: Text.PlainText
136 description: aboutData.otherText + (aboutData.otherText.length > 0 ? '\n' : '')
137 + aboutData.copyrightStatement
138 }
139 }
140
141 FormHeader {
142 title: i18ndp("kirigami-addons6", "License", "Licenses", aboutData.licenses.length)
143 visible: aboutData.licenses.length
144 }
145
146 FormCard {
147 visible: aboutData.licenses.length
148
149 Repeater {
150 model: aboutData.licenses
151 delegate: FormButtonDelegate {
152 text: modelData.name
153 Layout.fillWidth: true
154 onClicked: {
155 licenseSheet.text = modelData.text;
156 licenseSheet.title = modelData.name;
157 licenseSheet.open();
158 }
159 }
160 }
161
162 data: KirigamiComponents.MessageDialog {
163 id: licenseSheet
164
165 property alias text: bodyLabel.text
166
167 parent: applicationWindow().overlay
168 iconName: "license"
169
170 leftPadding: 0
171 rightPadding: 0
172 bottomPadding: 0
173
174 contentItem: QQC2.ScrollView {
175 leftPadding: Kirigami.Units.gridUnit
176 rightPadding: Kirigami.Units.gridUnit
177
178 Kirigami.SelectableLabel {
179 id: bodyLabel
180 text: licenseSheet.text
181 }
182 }
183
184 footer: null
185 }
186 }
187
188 FormCard {
189 Layout.topMargin: Kirigami.Units.gridUnit
190
192 id: getInvolvedDelegate
193 text: i18nd("kirigami-addons6", "Homepage")
194 onClicked: Qt.openUrlExternally(aboutData.homepage)
195 visible: aboutData.homepage.length > 0
196 }
197
199 above: getInvolvedDelegate
200 below: donateDelegate
201 visible: aboutData.homepage.length > 0
202 }
203
205 id: donateDelegate
206 text: i18nd("kirigami-addons6", "Donate")
207 onClicked: Qt.openUrlExternally(donateUrl + "?app=" + page.aboutData.componentName)
208 visible: donateUrl.toString().length > 0
209 }
210
212 above: donateDelegate
213 below: homepageDelegate
214 visible: donateUrl.toString().length > 0
215 }
216
218 id: homepageDelegate
219 text: i18nd("kirigami-addons6", "Get Involved")
220 onClicked: Qt.openUrlExternally(page.getInvolvedUrl)
221 visible: page.getInvolvedUrl != ""
222 }
223
225 above: homepageDelegate
226 below: bugDelegate
227 visible: page.getInvolvedUrl != ""
228 }
229
231 id: bugDelegate
232 readonly property string theUrl: {
233 if (aboutData.bugAddress !== "submit@bugs.kde.org") {
234 return aboutData.bugAddress
235 }
236 const elements = aboutData.productName.split('/');
237 let url = `https://bugs.kde.org/enter_bug.cgi?format=guided&product=${elements[0]}&version=${aboutData.version}`;
238 if (elements.length === 2) {
239 url += "&component=" + elements[1];
240 }
241 return url;
242 }
243
244 text: i18nd("kirigami-addons6", "Report a bug")
245 onClicked: Qt.openUrlExternally(theUrl)
246 visible: theUrl.length > 0
247 }
248 }
249
250 FormHeader {
251 title: i18nd("kirigami-addons6", "Libraries in use")
252 visible: Kirigami.Settings.information
253 }
254
255 FormCard {
256 visible: Kirigami.Settings.information
257
258 Repeater {
259 model: Kirigami.Settings.information
260 delegate: FormTextDelegate {
261 id: libraries
262 Layout.fillWidth: true
263 text: modelData
264 }
265 }
266
267 Repeater {
268 model: aboutData.components
269 delegate: libraryDelegate
270 }
271 }
272
273 FormHeader {
274 title: i18nd("kirigami-addons6", "Authors")
275 visible: aboutData.authors !== undefined && aboutData.authors.length > 0
276 }
277
278 FormCard {
279 visible: aboutData.authors !== undefined && aboutData.authors.length > 0
280
281 Repeater {
282 id: authorsRepeater
283 model: aboutData.authors
284 delegate: personDelegate
285 }
286 }
287
288 FormHeader {
289 title: i18nd("kirigami-addons6", "Credits")
290 visible: aboutData.credits !== undefined && aboutData.credits.length > 0
291 }
292
293 FormCard {
294 visible: aboutData.credits !== undefined && aboutData.credits.length > 0
295
296 Repeater {
297 id: repCredits
298 model: aboutData.credits
299 delegate: personDelegate
300 }
301 }
302
303 FormHeader {
304 title: i18nd("kirigami-addons6", "Translators")
305 visible: aboutData.translators !== undefined && aboutData.translators.length > 0
306 }
307
308 FormCard {
309 visible: aboutData.translators !== undefined && aboutData.translators.length > 0
310
311 Repeater {
312 id: repTranslators
313 model: aboutData.translators
314 delegate: personDelegate
315 }
316 }
317
318 data: [
319 Component {
320 id: personDelegate
321
323 Layout.fillWidth: true
324 background: null
325 contentItem: RowLayout {
326 spacing: Kirigami.Units.smallSpacing * 2
327
328 KirigamiComponents.Avatar {
329 id: avatarIcon
330
331 // TODO FIXME kf6 https://phabricator.kde.org/T15993
332 property bool hasRemoteAvatar: false // (typeof(modelData.ocsUsername) !== "undefined" && modelData.ocsUsername.length > 0)
333 implicitWidth: Kirigami.Units.iconSizes.medium
334 implicitHeight: implicitWidth
335 name: modelData.name
336 source: if (!!modelData.avatarUrl && modelData.avatarUrl.toString().startsWith('https://')) {
337 const url = new URL(modelData.avatarUrl);
338 const params = new URLSearchParams(url.search);
339 params.append("s", width);
340 url.search = params.toString();
341 return url;
342 } else {
343 return '';
344 }
345 }
346
347 ColumnLayout {
348 Layout.fillWidth: true
349 spacing: Kirigami.Units.smallSpacing
350
351 QQC2.Label {
352 Layout.fillWidth: true
353 text: modelData.name
354 elide: Text.ElideRight
355 }
356
357 QQC2.Label {
358 id: internalDescriptionItem
359 Layout.fillWidth: true
360 text: modelData.task
361 color: Kirigami.Theme.disabledTextColor
362 font: Kirigami.Theme.smallFont
363 elide: Text.ElideRight
364 visible: text.length > 0
365 }
366 }
367
368 QQC2.ToolButton {
369 visible: typeof(modelData.ocsUsername) !== "undefined" && modelData.ocsUsername.length > 0
370 icon.name: "get-hot-new-stuff"
371 QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
372 QQC2.ToolTip.visible: hovered
373 QQC2.ToolTip.text: i18nd("kirigami-addons6", "Visit %1's KDE Store page", modelData.name)
374 onClicked: Qt.openUrlExternally("https://store.kde.org/u/%1".arg(modelData.ocsUsername))
375 }
376
377 QQC2.ToolButton {
378 visible: typeof(modelData.emailAddress) !== "undefined" && modelData.emailAddress.length > 0
379 icon.name: "mail-sent"
380 QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
381 QQC2.ToolTip.visible: hovered
382 QQC2.ToolTip.text: i18nd("kirigami-addons6", "Send an email to %1", modelData.emailAddress)
383 onClicked: Qt.openUrlExternally("mailto:%1".arg(modelData.emailAddress))
384 }
385
386 QQC2.ToolButton {
387 visible: typeof(modelData.webAddress) !== "undefined" && modelData.webAddress.length > 0
388 icon.name: "globe"
389 QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
390 QQC2.ToolTip.visible: hovered
391 QQC2.ToolTip.text: (typeof(modelData.webAddress) === "undefined" && modelData.webAddress.length > 0) ? "" : modelData.webAddress
392 onClicked: Qt.openUrlExternally(modelData.webAddress)
393 }
394 }
395 }
396 },
397 Component {
398 id: libraryDelegate
399
401 id: delegate
402
403 required property var modelData
404
405 Layout.fillWidth: true
406 background: null
407 contentItem: RowLayout {
408 spacing: Kirigami.Units.smallSpacing * 2
409
410 ColumnLayout {
411 Layout.fillWidth: true
412 spacing: Kirigami.Units.smallSpacing
413
414 QQC2.Label {
415 Layout.fillWidth: true
416 text: delegate.modelData.name + ' ' + delegate.modelData.version
417 elide: Text.ElideRight
418 }
419
420 QQC2.Label {
421 id: internalDescriptionItem
422 Layout.fillWidth: true
423 text: delegate.modelData.description
424 color: Kirigami.Theme.disabledTextColor
425 font: Kirigami.Theme.smallFont
426 elide: Text.ElideRight
427 visible: text.length > 0
428 }
429 }
430
431 QQC2.ToolButton {
432 visible: modelData.licenses !== 0
433 icon.name: "license"
434
435 QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
436 QQC2.ToolTip.visible: hovered
437 QQC2.ToolTip.text: !visible ? "" : delegate.modelData.licenses.name
438
439 KirigamiComponents.MessageDialog {
440 id: licenseSheet
441
442 parent: applicationWindow().overlay
443 iconName: "license"
444
445 leftPadding: 0
446 rightPadding: 0
447 bottomPadding: 0
448
449 title: delegate.modelData.licenses.name
450
451 contentItem: QQC2.ScrollView {
452 leftPadding: Kirigami.Units.gridUnit
453 rightPadding: Kirigami.Units.gridUnit
454
456 id: bodyLabel
457 text: delegate.modelData.licenses.text
458 }
459 }
460
461 footer: null
462 }
463
464 onClicked: licenseSheet.open()
465 }
466
467 QQC2.ToolButton {
468 visible: typeof(modelData.webAddress) !== "undefined" && modelData.webAddress.length > 0
469 icon.name: "globe"
470 QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
471 QQC2.ToolTip.visible: hovered
472 QQC2.ToolTip.text: (typeof(modelData.webAddress) === "undefined" && modelData.webAddress.length > 0) ? "" : modelData.webAddress
473 onClicked: Qt.openUrlExternally(modelData.webAddress)
474 }
475 }
476 }
477 }
478 ]
479}
A base item for delegates to be used in a FormCard.
A Form delegate that corresponds to a clickable button.
A scrollable page used as a container for one or more FormCards.
A single card that follows a form style.
Definition FormCard.qml:35
A context-aware separator.
A header item for a form card.
A Form delegate that corresponds to a text label and a description.
A dialog to show a message.
QString i18ndp(const char *domain, const char *singular, const char *plural, const TYPE &arg...)
QString i18nd(const char *domain, const char *text, const TYPE &arg...)
KDB_EXPORT KDbVersionInfo version()
QString name(StandardShortcut id)
const QList< QKeySequence > & open()
ElideRight
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 3 2024 11:46:57 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.