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
6import QtQuick.Controls as QQC2
7import QtQuick.Window
8import QtQuick.Layouts
9import org.kde.kirigami as Kirigami
10import org.kde.kirigamiaddons.components as KirigamiComponents
11import org.kde.kirigamiaddons.formcard as FormCardModule
12import org.kde.coreaddons as Core
13
14import "private" as Private
15
16/**
17 * @brief An AboutPage that displays the about data using Form components.
18 *
19 * This component consists of an internationalized "About" page with the
20 * metadata of your program.
21 *
22 * It allows to show the copyright notice of the application together with
23 * the contributors and some information of which platform it's running on.
24 *
25 * @since KirigamiAddons 0.11.0
26 * @inherit org:kde::kirigami::ScrollablePage
27 */
29 id: page
30
31 /**
32 * @brief This property holds an object with the same shape as KAboutData.
33 *
34 * Set this property to either a KAboutData instance exposed from C++, or directly via a JSON object.
35 *
36 * Example usage:
37 * @code{json}
38 * aboutData: {
39 "displayName" : "KirigamiApp",
40 "productName" : "kirigami/app",
41 "componentName" : "kirigamiapp",
42 "shortDescription" : "A Kirigami example",
43 "homepage" : "",
44 "bugAddress" : "submit@bugs.kde.org",
45 "version" : "5.14.80",
46 "otherText" : "",
47 "authors" : [
48 {
49 "name" : "...",
50 "task" : "...",
51 "emailAddress" : "somebody@kde.org",
52 "webAddress" : "",
53 "ocsUsername" : ""
54 }
55 ],
56 "credits" : [],
57 "translators" : [],
58 "licenses" : [
59 {
60 "name" : "GPL v2",
61 "text" : "long, boring, license text",
62 "spdx" : "GPL-2.0"
63 }
64 ],
65 "copyrightStatement" : "© 2010-2018 Plasma Development Team",
66 "desktopFileName" : "org.kde.kirigamiapp"
67 }
68 @endcode
69 *
70 * @see KAboutData
71 */
72 property var aboutData: Core.AboutData
73
74 /**
75 * @brief This property holds a link to a "Get Involved" page.
76 *
77 * default: `"https://community.kde.org/Get_Involved" when the
78 * application ID starts with "org.kde.", otherwise empty.`
79 */
80 property url getInvolvedUrl: aboutData.desktopFileName.startsWith("org.kde.") ? "https://community.kde.org/Get_Involved" : ""
81
82 /**
83 * @brief This property holds a link to a "Donate" page.
84 *
85 * default: `"https://www.kde.org/donate" when the application ID starts with "org.kde.", otherwise empty.`
86 */
87 property url donateUrl: aboutData.desktopFileName.startsWith("org.kde.") ? "https://www.kde.org/donate" : ""
88
89 title: i18nd("kirigami-addons6", "About %1", page.aboutData.displayName)
90
91 FormCard {
92 Layout.topMargin: Kirigami.Units.largeSpacing * 4
93
94 AbstractFormDelegate {
95 id: generalDelegate
96 Layout.fillWidth: true
97 background: null
98 contentItem: RowLayout {
99 spacing: Kirigami.Units.smallSpacing * 2
100
101 Kirigami.Icon {
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.copyrightStatement
137 }
138 }
139
140 FormHeader {
141 visible: aboutData.otherText.length > 0
142 title: i18nd("kirigami-addons6", "Description")
143 }
144
145 FormCard {
146 visible: aboutData.otherText.length > 0
148 Layout.fillWidth: true
149 textItem.wrapMode: Text.WordWrap
150 text: aboutData.otherText
151 }
152 }
153
154 FormHeader {
155 title: i18ndp("kirigami-addons6", "License", "Licenses", aboutData.licenses.length)
156 visible: aboutData.licenses.length
157 }
158
159 FormCard {
160 visible: aboutData.licenses.length
161
162 Repeater {
163 model: aboutData.licenses
164 delegate: FormButtonDelegate {
165 text: modelData.name
166 Layout.fillWidth: true
167 onClicked: {
168 licenseSheet.text = modelData.text;
169 licenseSheet.title = modelData.name;
170 licenseSheet.open();
171 }
172 }
173 }
174
175 data: KirigamiComponents.MessageDialog {
176 id: licenseSheet
177
178 property alias text: bodyLabel.text
179
180 parent: QQC2.Overlay.overlay
181
182 leftPadding: 0
183 rightPadding: 0
184 bottomPadding: 0
185 topPadding: 0
186
187 header: Kirigami.Heading {
188 text: licenseSheet.title
189 elide: QQC2.Label.ElideRight
190 padding: licenseSheet.padding
191 topPadding: Kirigami.Units.largeSpacing
192 bottomPadding: Kirigami.Units.largeSpacing
193
194 Kirigami.Separator {
195 anchors {
196 left: parent.left
197 right: parent.right
198 bottom: parent.bottom
199 }
200 }
201 }
202
203 contentItem: QQC2.ScrollView {
204 id: scrollView
205
206 Kirigami.SelectableLabel {
207 id: bodyLabel
208 text: licenseSheet.text
209 textMargin: Kirigami.Units.gridUnit
210 }
211 }
212
213 footer: null
214 }
215 }
216
217 FormCard {
218 Layout.topMargin: Kirigami.Units.gridUnit
219
221 id: getInvolvedDelegate
222 text: i18nd("kirigami-addons6", "Homepage")
223 onClicked: Qt.openUrlExternally(aboutData.homepage)
224 visible: aboutData.homepage.length > 0
225 }
226
228 above: getInvolvedDelegate
229 below: donateDelegate
230 visible: aboutData.homepage.length > 0
231 }
232
234 id: donateDelegate
235 text: i18nd("kirigami-addons6", "Donate")
236 onClicked: Qt.openUrlExternally(donateUrl + "?app=" + page.aboutData.componentName)
237 visible: donateUrl.toString().length > 0
238 }
239
241 above: donateDelegate
242 below: homepageDelegate
243 visible: donateUrl.toString().length > 0
244 }
245
247 id: homepageDelegate
248 text: i18nd("kirigami-addons6", "Get Involved")
249 onClicked: Qt.openUrlExternally(page.getInvolvedUrl)
250 visible: page.getInvolvedUrl != ""
251 }
252
254 above: homepageDelegate
255 below: bugDelegate
256 visible: page.getInvolvedUrl != ""
257 }
258
260 id: bugDelegate
261 readonly property string theUrl: {
262 if (aboutData.bugAddress !== "submit@bugs.kde.org") {
263 return aboutData.bugAddress
264 }
265 const elements = aboutData.productName.split('/');
266 let url = `https://bugs.kde.org/enter_bug.cgi?format=guided&product=${elements[0]}&version=${aboutData.version}`;
267 if (elements.length === 2) {
268 url += "&component=" + elements[1];
269 }
270 return url;
271 }
272
273 text: i18nd("kirigami-addons6", "Report a Bug")
274 onClicked: Qt.openUrlExternally(theUrl)
275 visible: theUrl.length > 0
276 }
277 }
278
279 FormHeader {
280 title: i18nd("kirigami-addons6", "Libraries in use")
281 }
282
283 FormCard {
284 Repeater {
285 model: FormCardModule.AboutComponent.components
286 delegate: libraryDelegate
287 }
288 }
289
290 FormHeader {
291 title: i18nd("kirigami-addons6", "Authors")
292 visible: aboutData.authors !== undefined && aboutData.authors.length > 0
293 }
294
295 FormCard {
296 visible: aboutData.authors !== undefined && aboutData.authors.length > 0
297
298 Repeater {
299 id: authorsRepeater
300 model: aboutData.authors
301 delegate: personDelegate
302 }
303 }
304
305 FormHeader {
306 title: i18nd("kirigami-addons6", "Credits")
307 visible: aboutData.credits !== undefined && aboutData.credits.length > 0
308 }
309
310 FormCard {
311 visible: aboutData.credits !== undefined && aboutData.credits.length > 0
312
313 Repeater {
314 id: repCredits
315 model: aboutData.credits
316 delegate: personDelegate
317 }
318 }
319
320 FormHeader {
321 title: i18nd("kirigami-addons6", "Translators")
322 visible: aboutData.translators !== undefined && aboutData.translators.length > 0
323 }
324
325 FormCard {
326 visible: aboutData.translators !== undefined && aboutData.translators.length > 0
327
328 Repeater {
329 id: repTranslators
330 model: aboutData.translators
331 delegate: personDelegate
332 }
333 }
334
335 data: [
336 Component {
337 id: personDelegate
338
340 Layout.fillWidth: true
341 background: null
342 contentItem: RowLayout {
343 spacing: Private.FormCardUnits.horizontalSpacing
344
345 KirigamiComponents.Avatar {
346 id: avatarIcon
347
348 implicitWidth: Kirigami.Units.iconSizes.medium
349 implicitHeight: implicitWidth
350 name: modelData.name
351 source: if (!!modelData.avatarUrl && modelData.avatarUrl.toString().startsWith('https://')) {
352 const url = new URL(modelData.avatarUrl);
353 const params = new URLSearchParams(url.search);
354 params.append("s", width);
355 url.search = params.toString();
356 return url;
357 } else {
358 return '';
359 }
360
361 Layout.rightMargin: Private.FormCardUnits.horizontalSpacing
362 }
363
364 ColumnLayout {
365 Layout.fillWidth: true
366 spacing: Private.FormCardUnits.verticalSpacing
367
368 QQC2.Label {
369 Layout.fillWidth: true
370 text: modelData.name
371 elide: Text.ElideRight
372 }
373
374 QQC2.Label {
375 id: internalDescriptionItem
376 Layout.fillWidth: true
377 text: modelData.task
378 color: Kirigami.Theme.disabledTextColor
379 font: Kirigami.Theme.smallFont
380 elide: Text.ElideRight
381 visible: text.length > 0
382 }
383 }
384
385 QQC2.ToolButton {
386 visible: typeof(modelData.ocsUsername) !== "undefined" && modelData.ocsUsername.length > 0
387 icon.name: "get-hot-new-stuff"
388 QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
389 QQC2.ToolTip.visible: hovered
390 QQC2.ToolTip.text: i18nd("kirigami-addons6", "Visit %1's KDE Store page", modelData.name)
391 onClicked: Qt.openUrlExternally("https://store.kde.org/u/%1".arg(modelData.ocsUsername))
392 }
393
394 QQC2.ToolButton {
395 visible: typeof(modelData.emailAddress) !== "undefined" && modelData.emailAddress.length > 0
396 icon.name: "mail-sent"
397 QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
398 QQC2.ToolTip.visible: hovered
399 QQC2.ToolTip.text: i18nd("kirigami-addons6", "Send an email to %1", modelData.emailAddress)
400 onClicked: Qt.openUrlExternally("mailto:%1".arg(modelData.emailAddress))
401 }
402
403 QQC2.ToolButton {
404 visible: typeof(modelData.webAddress) !== "undefined" && modelData.webAddress.length > 0
405 icon.name: "globe"
406 QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
407 QQC2.ToolTip.visible: hovered
408 QQC2.ToolTip.text: (typeof(modelData.webAddress) === "undefined" && modelData.webAddress.length > 0) ? "" : modelData.webAddress
409 onClicked: Qt.openUrlExternally(modelData.webAddress)
410 }
411 }
412 }
413 },
414 Component {
415 id: libraryDelegate
416
418 id: delegate
419
420 required property var modelData
421
422 Layout.fillWidth: true
423 background: null
424 contentItem: RowLayout {
425 spacing: Private.FormCardUnits.horizontalSpacing
426
427 ColumnLayout {
428 Layout.fillWidth: true
429 spacing: Private.FormCardUnits.verticalSpacing
430
431 QQC2.Label {
432 Layout.fillWidth: true
433 text: delegate.modelData.name + ' ' + delegate.modelData.version
434 elide: Text.ElideRight
435 }
436
437 QQC2.Label {
438 id: internalDescriptionItem
439 Layout.fillWidth: true
440 text: delegate.modelData.description
441 color: Kirigami.Theme.disabledTextColor
442 font: Kirigami.Theme.smallFont
443 elide: Text.ElideRight
444 visible: text.length > 0
445 }
446 }
447
448 QQC2.ToolButton {
449 id: licenseButton
450 visible: modelData.licenses !== 0
451 icon.name: "license"
452
453 QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
454 QQC2.ToolTip.visible: hovered
455 QQC2.ToolTip.text: !visible ? "" : delegate.modelData.licenses.name
456
457 KirigamiComponents.MessageDialog {
458 id: licenseSheet
459
460 title: delegate.modelData.name
461
462 parent: licenseButton.QQC2.Overlay.overlay
463 implicitWidth: Math.min(parent.width - Kirigami.Units.gridUnit * 2, implicitContentWidth)
464
465 leftPadding: 0
466 rightPadding: 0
467 bottomPadding: 0
468 topPadding: 0
469
470 header: QQC2.Control {
471 padding: licenseSheet.padding
472 topPadding: Kirigami.Units.largeSpacing
473 bottomPadding: Kirigami.Units.largeSpacing
474
475 contentItem: RowLayout {
476 spacing: Kirigami.Units.largeSpacing
477
479 text: licenseSheet.title
480 elide: QQC2.Label.ElideRight
481 padding: 0
482 leftPadding: Kirigami.Units.largeSpacing
483 Layout.fillWidth: true
484 }
485
486 QQC2.ToolButton {
487 icon.name: hovered ? "window-close" : "window-close-symbolic"
488 text: i18nc("@action:button", "Close")
489 display: QQC2.ToolButton.IconOnly
490 onClicked: licenseSheet.close()
491 }
492 }
493
495 anchors {
496 left: parent.left
497 right: parent.right
498 bottom: parent.bottom
499 }
500 }
501 }
502
503 contentItem: QQC2.ScrollView {
505 id: bodyLabel
506 text: delegate.modelData.licenses.text
507 textMargin: Kirigami.Units.gridUnit
508 }
509 }
510
511 footer: null
512 }
513
514 onClicked: licenseSheet.open()
515 }
516
517 QQC2.ToolButton {
518 visible: typeof(modelData.webAddress) !== "undefined" && modelData.webAddress.length > 0
519 icon.name: "globe"
520 QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
521 QQC2.ToolTip.visible: hovered
522 QQC2.ToolTip.text: (typeof(modelData.webAddress) === "undefined" && modelData.webAddress.length > 0) ? "" : modelData.webAddress
523 onClicked: Qt.openUrlExternally(modelData.webAddress)
524 }
525 }
526 }
527 }
528 ]
529}
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 i18nc(const char *context, const char *text, const TYPE &arg...)
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(GameStandardAction id)
KGuiItem open()
KGuiItem close()
ElideRight
QTextStream & left(QTextStream &stream)
QTextStream & right(QTextStream &stream)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:33:45 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.