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

KDE's Doxygen guidelines are available online.