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.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.largeSpacing * 4
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.preferredHeight: Kirigami.Units.iconSizes.huge
102 Layout.preferredWidth: height
103 Layout.maximumWidth: page.width / 3;
104 Layout.rightMargin: Kirigami.Units.largeSpacing
105 source: Kirigami.Settings.applicationWindowIcon || page.aboutData.programLogo || page.aboutData.programIconName || page.aboutData.componentName
106 }
107
108 ColumnLayout {
109 Layout.fillWidth: true
110 spacing: Kirigami.Units.smallSpacing
111
112 Kirigami.Heading {
113 Layout.fillWidth: true
114 text: page.aboutData.displayName + " " + page.aboutData.version
115 wrapMode: Text.WordWrap
116 }
117
118 Kirigami.Heading {
119 Layout.fillWidth: true
120 level: 3
121 type: Kirigami.Heading.Type.Secondary
122 wrapMode: Text.WordWrap
123 text: page.aboutData.shortDescription
124 }
125 }
126 }
127 }
128
130
132 id: copyrightDelegate
133 text: i18nd("kirigami-addons6", "Copyright")
134 descriptionItem.textFormat: Text.PlainText
135 description: aboutData.copyrightStatement
136 }
137 }
138
139 FormHeader {
140 visible: aboutData.otherText.length > 0
141 title: i18nd("kirigami-addons6", "Description")
142 }
143
144 FormCard {
145 visible: aboutData.otherText.length > 0
147 Layout.fillWidth: true
148 textItem.wrapMode: Text.WordWrap
149 text: aboutData.otherText
150 }
151 }
152
153 FormHeader {
154 title: i18ndp("kirigami-addons6", "License", "Licenses", aboutData.licenses.length)
155 visible: aboutData.licenses.length
156 }
157
158 FormCard {
159 visible: aboutData.licenses.length
160
161 Repeater {
162 model: aboutData.licenses
163 delegate: FormButtonDelegate {
164 text: modelData.name
165 Layout.fillWidth: true
166 onClicked: {
167 licenseSheet.text = modelData.text;
168 licenseSheet.title = modelData.name;
169 licenseSheet.open();
170 }
171 }
172 }
173
174 data: KirigamiComponents.MessageDialog {
175 id: licenseSheet
176
177 property alias text: bodyLabel.text
178
179 parent: QQC2.Overlay.overlay
180
181 leftPadding: 0
182 rightPadding: 0
183 bottomPadding: 0
184 topPadding: 0
185
186 header: Kirigami.Heading {
187 text: licenseSheet.title
188 elide: QQC2.Label.ElideRight
189 padding: licenseSheet.padding
190 topPadding: Kirigami.Units.largeSpacing
191 bottomPadding: Kirigami.Units.largeSpacing
192
193 Kirigami.Separator {
194 anchors {
195 left: parent.left
196 right: parent.right
197 bottom: parent.bottom
198 }
199 }
200 }
201
202 contentItem: QQC2.ScrollView {
203 id: scrollView
204
205 Kirigami.SelectableLabel {
206 id: bodyLabel
207 text: licenseSheet.text
208 textMargin: Kirigami.Units.gridUnit
209 }
210 }
211
212 footer: null
213 }
214 }
215
216 FormCard {
217 Layout.topMargin: Kirigami.Units.gridUnit
218
220 id: getInvolvedDelegate
221 text: i18nd("kirigami-addons6", "Homepage")
222 onClicked: Qt.openUrlExternally(aboutData.homepage)
223 visible: aboutData.homepage.length > 0
224 }
225
227 above: getInvolvedDelegate
228 below: donateDelegate
229 visible: aboutData.homepage.length > 0
230 }
231
233 id: donateDelegate
234 text: i18nd("kirigami-addons6", "Donate")
235 onClicked: Qt.openUrlExternally(donateUrl + "?app=" + page.aboutData.componentName)
236 visible: donateUrl.toString().length > 0
237 }
238
240 above: donateDelegate
241 below: homepageDelegate
242 visible: donateUrl.toString().length > 0
243 }
244
246 id: homepageDelegate
247 text: i18nd("kirigami-addons6", "Get Involved")
248 onClicked: Qt.openUrlExternally(page.getInvolvedUrl)
249 visible: page.getInvolvedUrl != ""
250 }
251
253 above: homepageDelegate
254 below: bugDelegate
255 visible: page.getInvolvedUrl != ""
256 }
257
259 id: bugDelegate
260 readonly property string theUrl: {
261 if (aboutData.bugAddress !== "submit@bugs.kde.org") {
262 return aboutData.bugAddress
263 }
264 const elements = aboutData.productName.split('/');
265 let url = `https://bugs.kde.org/enter_bug.cgi?format=guided&product=${elements[0]}&version=${aboutData.version}`;
266 if (elements.length === 2) {
267 url += "&component=" + elements[1];
268 }
269 return url;
270 }
271
272 text: i18nd("kirigami-addons6", "Report a Bug")
273 onClicked: Qt.openUrlExternally(theUrl)
274 visible: theUrl.length > 0
275 }
276 }
277
278 FormHeader {
279 title: i18nd("kirigami-addons6", "Libraries in use")
280 visible: Kirigami.Settings.information
281 }
282
283 FormCard {
284 visible: Kirigami.Settings.information
285
286 Repeater {
287 model: Kirigami.Settings.information
288 delegate: FormTextDelegate {
289 id: libraries
290 Layout.fillWidth: true
291 text: modelData
292 }
293 }
294
295 Repeater {
296 model: aboutData.components
297 delegate: libraryDelegate
298 }
299 }
300
301 FormHeader {
302 title: i18nd("kirigami-addons6", "Authors")
303 visible: aboutData.authors !== undefined && aboutData.authors.length > 0
304 }
305
306 FormCard {
307 visible: aboutData.authors !== undefined && aboutData.authors.length > 0
308
309 Repeater {
310 id: authorsRepeater
311 model: aboutData.authors
312 delegate: personDelegate
313 }
314 }
315
316 FormHeader {
317 title: i18nd("kirigami-addons6", "Credits")
318 visible: aboutData.credits !== undefined && aboutData.credits.length > 0
319 }
320
321 FormCard {
322 visible: aboutData.credits !== undefined && aboutData.credits.length > 0
323
324 Repeater {
325 id: repCredits
326 model: aboutData.credits
327 delegate: personDelegate
328 }
329 }
330
331 FormHeader {
332 title: i18nd("kirigami-addons6", "Translators")
333 visible: aboutData.translators !== undefined && aboutData.translators.length > 0
334 }
335
336 FormCard {
337 visible: aboutData.translators !== undefined && aboutData.translators.length > 0
338
339 Repeater {
340 id: repTranslators
341 model: aboutData.translators
342 delegate: personDelegate
343 }
344 }
345
346 data: [
347 Component {
348 id: personDelegate
349
351 Layout.fillWidth: true
352 background: null
353 contentItem: RowLayout {
354 spacing: Kirigami.Units.smallSpacing * 2
355
356 KirigamiComponents.Avatar {
357 id: avatarIcon
358
359 // TODO FIXME kf6 https://phabricator.kde.org/T15993
360 property bool hasRemoteAvatar: false // (typeof(modelData.ocsUsername) !== "undefined" && modelData.ocsUsername.length > 0)
361 implicitWidth: Kirigami.Units.iconSizes.medium
362 implicitHeight: implicitWidth
363 name: modelData.name
364 source: if (!!modelData.avatarUrl && modelData.avatarUrl.toString().startsWith('https://')) {
365 const url = new URL(modelData.avatarUrl);
366 const params = new URLSearchParams(url.search);
367 params.append("s", width);
368 url.search = params.toString();
369 return url;
370 } else {
371 return '';
372 }
373 }
374
375 ColumnLayout {
376 Layout.fillWidth: true
377 spacing: Kirigami.Units.smallSpacing
378
379 QQC2.Label {
380 Layout.fillWidth: true
381 text: modelData.name
382 elide: Text.ElideRight
383 }
384
385 QQC2.Label {
386 id: internalDescriptionItem
387 Layout.fillWidth: true
388 text: modelData.task
389 color: Kirigami.Theme.disabledTextColor
390 font: Kirigami.Theme.smallFont
391 elide: Text.ElideRight
392 visible: text.length > 0
393 }
394 }
395
396 QQC2.ToolButton {
397 visible: typeof(modelData.ocsUsername) !== "undefined" && modelData.ocsUsername.length > 0
398 icon.name: "get-hot-new-stuff"
399 QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
400 QQC2.ToolTip.visible: hovered
401 QQC2.ToolTip.text: i18nd("kirigami-addons6", "Visit %1's KDE Store page", modelData.name)
402 onClicked: Qt.openUrlExternally("https://store.kde.org/u/%1".arg(modelData.ocsUsername))
403 }
404
405 QQC2.ToolButton {
406 visible: typeof(modelData.emailAddress) !== "undefined" && modelData.emailAddress.length > 0
407 icon.name: "mail-sent"
408 QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
409 QQC2.ToolTip.visible: hovered
410 QQC2.ToolTip.text: i18nd("kirigami-addons6", "Send an email to %1", modelData.emailAddress)
411 onClicked: Qt.openUrlExternally("mailto:%1".arg(modelData.emailAddress))
412 }
413
414 QQC2.ToolButton {
415 visible: typeof(modelData.webAddress) !== "undefined" && modelData.webAddress.length > 0
416 icon.name: "globe"
417 QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
418 QQC2.ToolTip.visible: hovered
419 QQC2.ToolTip.text: (typeof(modelData.webAddress) === "undefined" && modelData.webAddress.length > 0) ? "" : modelData.webAddress
420 onClicked: Qt.openUrlExternally(modelData.webAddress)
421 }
422 }
423 }
424 },
425 Component {
426 id: libraryDelegate
427
429 id: delegate
430
431 required property var modelData
432
433 Layout.fillWidth: true
434 background: null
435 contentItem: RowLayout {
436 spacing: Kirigami.Units.smallSpacing * 2
437
438 ColumnLayout {
439 Layout.fillWidth: true
440 spacing: Kirigami.Units.smallSpacing
441
442 QQC2.Label {
443 Layout.fillWidth: true
444 text: delegate.modelData.name + ' ' + delegate.modelData.version
445 elide: Text.ElideRight
446 }
447
448 QQC2.Label {
449 id: internalDescriptionItem
450 Layout.fillWidth: true
451 text: delegate.modelData.description
452 color: Kirigami.Theme.disabledTextColor
453 font: Kirigami.Theme.smallFont
454 elide: Text.ElideRight
455 visible: text.length > 0
456 }
457 }
458
459 QQC2.ToolButton {
460 visible: modelData.licenses !== 0
461 icon.name: "license"
462
463 QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
464 QQC2.ToolTip.visible: hovered
465 QQC2.ToolTip.text: !visible ? "" : delegate.modelData.licenses.name
466
467 KirigamiComponents.MessageDialog {
468 id: licenseSheet
469
470 parent: root.QQC2.Overlay.overlay
471 title: delegate.modelData.name
472
473 leftPadding: 0
474 rightPadding: 0
475 bottomPadding: 0
476 topPadding: 0
477
478 header: Kirigami.Heading {
479 text: licenseSheet.title
480 elide: QQC2.Label.ElideRight
481 padding: licenseSheet.padding
482 topPadding: Kirigami.Units.largeSpacing
483 bottomPadding: Kirigami.Units.largeSpacing
484
486 anchors {
487 left: parent.left
488 right: parent.right
489 bottom: parent.bottom
490 }
491 }
492 }
493
494 contentItem: QQC2.ScrollView {
496 id: bodyLabel
497 text: delegate.modelData.licenses.text
498 textMargin: Kirigami.Units.gridUnit
499 }
500 }
501
502 footer: null
503 }
504
505 onClicked: licenseSheet.open()
506 }
507
508 QQC2.ToolButton {
509 visible: typeof(modelData.webAddress) !== "undefined" && modelData.webAddress.length > 0
510 icon.name: "globe"
511 QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
512 QQC2.ToolTip.visible: hovered
513 QQC2.ToolTip.text: (typeof(modelData.webAddress) === "undefined" && modelData.webAddress.length > 0) ? "" : modelData.webAddress
514 onClicked: Qt.openUrlExternally(modelData.webAddress)
515 }
516 }
517 }
518 }
519 ]
520}
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...)
QString name(StandardAction id)
KGuiItem open()
NETWORKMANAGERQT_EXPORT QString version()
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 Fri Oct 11 2024 12:10:34 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.