Warning, /libraries/kirigami-addons/src/formcard/AboutPage.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2018 Aleix Pol Gonzalez <aleixpol@blue-systems.com> 0002 // SPDX-FileCopyrightText: 2021 Carl Schwan <carl@carlschwan.eu> 0003 // SPDX-License-Identifier: LGPL-2.0-or-later 0004 0005 import QtQuick 2.15 0006 import QtQuick.Controls 2.15 as QQC2 0007 import QtQuick.Window 2.15 0008 import QtQuick.Layouts 1.15 0009 import org.kde.kirigami 2.20 as Kirigami 0010 import org.kde.kirigamiaddons.components 1.0 as KirigamiComponents 0011 0012 import "private" as Private 0013 0014 /** 0015 * @brief An AboutPage that displays the about data using Form components. 0016 * 0017 * This component consists of an internationalized "About" page with the 0018 * metadata of your program. 0019 * 0020 * It allows to show the copyright notice of the application together with 0021 * the contributors and some information of which platform it's running on. 0022 * 0023 * @since KirigamiAddons 0.11.0 0024 * @inherit org:kde::kirigami::ScrollablePage 0025 */ 0026 FormCardPage { 0027 id: page 0028 0029 /** 0030 * @brief This property holds an object with the same shape as KAboutData. 0031 * 0032 * Set this property to either a KAboutData instance exposed from C++, or directly via a JSON object. 0033 * 0034 * Example usage: 0035 * @code{json} 0036 * aboutData: { 0037 "displayName" : "KirigamiApp", 0038 "productName" : "kirigami/app", 0039 "componentName" : "kirigamiapp", 0040 "shortDescription" : "A Kirigami example", 0041 "homepage" : "", 0042 "bugAddress" : "submit@bugs.kde.org", 0043 "version" : "5.14.80", 0044 "otherText" : "", 0045 "authors" : [ 0046 { 0047 "name" : "...", 0048 "task" : "...", 0049 "emailAddress" : "somebody@kde.org", 0050 "webAddress" : "", 0051 "ocsUsername" : "" 0052 } 0053 ], 0054 "credits" : [], 0055 "translators" : [], 0056 "licenses" : [ 0057 { 0058 "name" : "GPL v2", 0059 "text" : "long, boring, license text", 0060 "spdx" : "GPL-2.0" 0061 } 0062 ], 0063 "copyrightStatement" : "© 2010-2018 Plasma Development Team", 0064 "desktopFileName" : "org.kde.kirigamiapp" 0065 } 0066 @endcode 0067 * 0068 * @see KAboutData 0069 */ 0070 property var aboutData 0071 0072 /** 0073 * @brief This property holds a link to a "Get Involved" page. 0074 * 0075 * default: `"https://community.kde.org/Get_Involved" when the 0076 * application ID starts with "org.kde.", otherwise empty.` 0077 */ 0078 property url getInvolvedUrl: aboutData.desktopFileName.startsWith("org.kde.") ? "https://community.kde.org/Get_Involved" : "" 0079 0080 /** 0081 * @brief This property holds a link to a "Donate" page. 0082 * 0083 * default: `"https://www.kde.org/donate" when the application ID starts with "org.kde.", otherwise empty.` 0084 */ 0085 property url donateUrl: aboutData.desktopFileName.startsWith("org.kde.") ? "https://www.kde.org/donate" : "" 0086 0087 title: i18nd("kirigami-addons6", "About %1", page.aboutData.displayName) 0088 0089 FormCard { 0090 Layout.topMargin: Kirigami.Units.gridUnit 0091 0092 AbstractFormDelegate { 0093 id: generalDelegate 0094 Layout.fillWidth: true 0095 background: null 0096 contentItem: RowLayout { 0097 spacing: Kirigami.Units.smallSpacing * 2 0098 0099 Kirigami.Icon { 0100 Layout.rowSpan: 3 0101 Layout.preferredHeight: Kirigami.Units.iconSizes.huge 0102 Layout.preferredWidth: height 0103 Layout.maximumWidth: page.width / 3; 0104 Layout.rightMargin: Kirigami.Units.largeSpacing 0105 source: Kirigami.Settings.applicationWindowIcon || page.aboutData.programLogo || page.aboutData.programIconName || page.aboutData.componentName 0106 } 0107 0108 ColumnLayout { 0109 Layout.fillWidth: true 0110 spacing: Kirigami.Units.smallSpacing 0111 0112 Kirigami.Heading { 0113 Layout.fillWidth: true 0114 text: page.aboutData.displayName + " " + page.aboutData.version 0115 wrapMode: Text.WordWrap 0116 } 0117 0118 Kirigami.Heading { 0119 Layout.fillWidth: true 0120 level: 3 0121 type: Kirigami.Heading.Type.Secondary 0122 wrapMode: Text.WordWrap 0123 text: page.aboutData.shortDescription 0124 } 0125 } 0126 } 0127 } 0128 0129 FormDelegateSeparator {} 0130 0131 FormTextDelegate { 0132 id: copyrightDelegate 0133 text: i18nd("kirigami-addons6", "Copyright") 0134 descriptionItem.textFormat: Text.PlainText 0135 description: aboutData.otherText + (aboutData.otherText.length > 0 ? '</br>' : '') 0136 + aboutData.copyrightStatement 0137 } 0138 } 0139 0140 FormHeader { 0141 title: i18ndp("kirigami-addons6", "License", "Licenses", aboutData.licenses.length) 0142 visible: aboutData.licenses.length 0143 } 0144 0145 FormCard { 0146 visible: aboutData.licenses.length 0147 0148 Repeater { 0149 model: aboutData.licenses 0150 delegate: FormButtonDelegate { 0151 text: modelData.name 0152 Layout.fillWidth: true 0153 onClicked: { 0154 licenseSheet.text = modelData.text; 0155 licenseSheet.title = modelData.name; 0156 licenseSheet.open(); 0157 } 0158 } 0159 } 0160 0161 data: KirigamiComponents.MessageDialog { 0162 id: licenseSheet 0163 0164 property alias text: bodyLabel.text 0165 0166 parent: applicationWindow().overlay 0167 iconName: "license" 0168 0169 leftPadding: 0 0170 rightPadding: 0 0171 bottomPadding: 0 0172 0173 contentItem: QQC2.ScrollView { 0174 leftPadding: Kirigami.Units.gridUnit 0175 rightPadding: Kirigami.Units.gridUnit 0176 0177 Kirigami.SelectableLabel { 0178 id: bodyLabel 0179 text: licenseSheet.text 0180 } 0181 } 0182 0183 footer: null 0184 } 0185 } 0186 0187 FormCard { 0188 Layout.topMargin: Kirigami.Units.gridUnit 0189 0190 FormButtonDelegate { 0191 id: getInvolvedDelegate 0192 text: i18nd("kirigami-addons6", "Homepage") 0193 onClicked: Qt.openUrlExternally(aboutData.homepage) 0194 visible: aboutData.homepage.length > 0 0195 } 0196 0197 FormDelegateSeparator { 0198 above: getInvolvedDelegate 0199 below: donateDelegate 0200 visible: aboutData.homepage.length > 0 0201 } 0202 0203 FormButtonDelegate { 0204 id: donateDelegate 0205 text: i18nd("kirigami-addons6", "Donate") 0206 onClicked: Qt.openUrlExternally(donateUrl + "?app=" + page.aboutData.componentName) 0207 visible: donateUrl.toString().length > 0 0208 } 0209 0210 FormDelegateSeparator { 0211 above: donateDelegate 0212 below: homepageDelegate 0213 visible: donateUrl.toString().length > 0 0214 } 0215 0216 FormButtonDelegate { 0217 id: homepageDelegate 0218 text: i18nd("kirigami-addons6", "Get Involved") 0219 onClicked: Qt.openUrlExternally(page.getInvolvedUrl) 0220 visible: page.getInvolvedUrl != "" 0221 } 0222 0223 FormDelegateSeparator { 0224 above: homepageDelegate 0225 below: bugDelegate 0226 visible: page.getInvolvedUrl != "" 0227 } 0228 0229 FormButtonDelegate { 0230 id: bugDelegate 0231 readonly property string theUrl: { 0232 if (aboutData.bugAddress !== "submit@bugs.kde.org") { 0233 return aboutData.bugAddress 0234 } 0235 const elements = aboutData.productName.split('/'); 0236 let url = `https://bugs.kde.org/enter_bug.cgi?format=guided&product=${elements[0]}&version=${aboutData.version}`; 0237 if (elements.length === 2) { 0238 url += "&component=" + elements[1]; 0239 } 0240 return url; 0241 } 0242 0243 text: i18nd("kirigami-addons6", "Report a bug") 0244 onClicked: Qt.openUrlExternally(theUrl) 0245 visible: theUrl.length > 0 0246 } 0247 } 0248 0249 FormHeader { 0250 title: i18nd("kirigami-addons6", "Libraries in use") 0251 visible: Kirigami.Settings.information 0252 } 0253 0254 FormCard { 0255 visible: Kirigami.Settings.information 0256 0257 Repeater { 0258 model: Kirigami.Settings.information 0259 delegate: FormTextDelegate { 0260 id: libraries 0261 Layout.fillWidth: true 0262 text: modelData 0263 } 0264 } 0265 0266 Repeater { 0267 model: aboutData.components 0268 delegate: libraryDelegate 0269 } 0270 } 0271 0272 FormHeader { 0273 title: i18nd("kirigami-addons6", "Authors") 0274 visible: aboutData.authors !== undefined && aboutData.authors.length > 0 0275 } 0276 0277 FormCard { 0278 visible: aboutData.authors !== undefined && aboutData.authors.length > 0 0279 0280 Repeater { 0281 id: authorsRepeater 0282 model: aboutData.authors 0283 delegate: personDelegate 0284 } 0285 } 0286 0287 FormHeader { 0288 title: i18nd("kirigami-addons6", "Credits") 0289 visible: aboutData.credits !== undefined && aboutData.credits.length > 0 0290 } 0291 0292 FormCard { 0293 visible: aboutData.credits !== undefined && aboutData.credits.length > 0 0294 0295 Repeater { 0296 id: repCredits 0297 model: aboutData.credits 0298 delegate: personDelegate 0299 } 0300 } 0301 0302 FormHeader { 0303 title: i18nd("kirigami-addons6", "Translators") 0304 visible: aboutData.translators !== undefined && aboutData.translators.length > 0 0305 } 0306 0307 FormCard { 0308 visible: aboutData.translators !== undefined && aboutData.translators.length > 0 0309 0310 Repeater { 0311 id: repTranslators 0312 model: aboutData.translators 0313 delegate: personDelegate 0314 } 0315 } 0316 0317 data: [ 0318 Component { 0319 id: personDelegate 0320 0321 AbstractFormDelegate { 0322 Layout.fillWidth: true 0323 background: null 0324 contentItem: RowLayout { 0325 spacing: Kirigami.Units.smallSpacing * 2 0326 0327 KirigamiComponents.Avatar { 0328 id: avatarIcon 0329 0330 // TODO FIXME kf6 https://phabricator.kde.org/T15993 0331 property bool hasRemoteAvatar: false // (typeof(modelData.ocsUsername) !== "undefined" && modelData.ocsUsername.length > 0) 0332 implicitWidth: Kirigami.Units.iconSizes.medium 0333 implicitHeight: implicitWidth 0334 name: modelData.name 0335 source: if (!!modelData.avatarUrl && modelData.avatarUrl.toString().startsWith('https://')) { 0336 const url = new URL(modelData.avatarUrl); 0337 const params = new URLSearchParams(url.search); 0338 params.append("s", width); 0339 url.search = params.toString(); 0340 return url; 0341 } else { 0342 return ''; 0343 } 0344 } 0345 0346 ColumnLayout { 0347 Layout.fillWidth: true 0348 spacing: Kirigami.Units.smallSpacing 0349 0350 QQC2.Label { 0351 Layout.fillWidth: true 0352 text: modelData.name 0353 elide: Text.ElideRight 0354 } 0355 0356 QQC2.Label { 0357 id: internalDescriptionItem 0358 Layout.fillWidth: true 0359 text: modelData.task 0360 color: Kirigami.Theme.disabledTextColor 0361 font: Kirigami.Theme.smallFont 0362 elide: Text.ElideRight 0363 visible: text.length > 0 0364 } 0365 } 0366 0367 QQC2.ToolButton { 0368 visible: typeof(modelData.ocsUsername) !== "undefined" && modelData.ocsUsername.length > 0 0369 icon.name: "get-hot-new-stuff" 0370 QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay 0371 QQC2.ToolTip.visible: hovered 0372 QQC2.ToolTip.text: i18nd("kirigami-addons6", "Visit %1's KDE Store page", modelData.name) 0373 onClicked: Qt.openUrlExternally("https://store.kde.org/u/%1".arg(modelData.ocsUsername)) 0374 } 0375 0376 QQC2.ToolButton { 0377 visible: typeof(modelData.emailAddress) !== "undefined" && modelData.emailAddress.length > 0 0378 icon.name: "mail-sent" 0379 QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay 0380 QQC2.ToolTip.visible: hovered 0381 QQC2.ToolTip.text: i18nd("kirigami-addons6", "Send an email to %1", modelData.emailAddress) 0382 onClicked: Qt.openUrlExternally("mailto:%1".arg(modelData.emailAddress)) 0383 } 0384 0385 QQC2.ToolButton { 0386 visible: typeof(modelData.webAddress) !== "undefined" && modelData.webAddress.length > 0 0387 icon.name: "globe" 0388 QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay 0389 QQC2.ToolTip.visible: hovered 0390 QQC2.ToolTip.text: (typeof(modelData.webAddress) === "undefined" && modelData.webAddress.length > 0) ? "" : modelData.webAddress 0391 onClicked: Qt.openUrlExternally(modelData.webAddress) 0392 } 0393 } 0394 } 0395 }, 0396 Component { 0397 id: libraryDelegate 0398 0399 AbstractFormDelegate { 0400 id: delegate 0401 0402 required property var modelData 0403 0404 Layout.fillWidth: true 0405 background: null 0406 contentItem: RowLayout { 0407 spacing: Kirigami.Units.smallSpacing * 2 0408 0409 ColumnLayout { 0410 Layout.fillWidth: true 0411 spacing: Kirigami.Units.smallSpacing 0412 0413 QQC2.Label { 0414 Layout.fillWidth: true 0415 text: delegate.modelData.name + ' ' + delegate.modelData.version 0416 elide: Text.ElideRight 0417 } 0418 0419 QQC2.Label { 0420 id: internalDescriptionItem 0421 Layout.fillWidth: true 0422 text: delegate.modelData.description 0423 color: Kirigami.Theme.disabledTextColor 0424 font: Kirigami.Theme.smallFont 0425 elide: Text.ElideRight 0426 visible: text.length > 0 0427 } 0428 } 0429 0430 QQC2.ToolButton { 0431 visible: modelData.licenses !== 0 0432 icon.name: "license" 0433 0434 QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay 0435 QQC2.ToolTip.visible: hovered 0436 QQC2.ToolTip.text: !visible ? "" : delegate.modelData.licenses.name 0437 0438 KirigamiComponents.MessageDialog { 0439 id: licenseSheet 0440 0441 parent: applicationWindow().overlay 0442 iconName: "license" 0443 0444 leftPadding: 0 0445 rightPadding: 0 0446 bottomPadding: 0 0447 0448 title: delegate.modelData.licenses.name 0449 0450 contentItem: QQC2.ScrollView { 0451 leftPadding: Kirigami.Units.gridUnit 0452 rightPadding: Kirigami.Units.gridUnit 0453 0454 Kirigami.SelectableLabel { 0455 id: bodyLabel 0456 text: delegate.modelData.licenses.text 0457 } 0458 } 0459 0460 footer: null 0461 } 0462 0463 onClicked: licenseSheet.open() 0464 } 0465 0466 QQC2.ToolButton { 0467 visible: typeof(modelData.webAddress) !== "undefined" && modelData.webAddress.length > 0 0468 icon.name: "globe" 0469 QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay 0470 QQC2.ToolTip.visible: hovered 0471 QQC2.ToolTip.text: (typeof(modelData.webAddress) === "undefined" && modelData.webAddress.length > 0) ? "" : modelData.webAddress 0472 onClicked: Qt.openUrlExternally(modelData.webAddress) 0473 } 0474 } 0475 } 0476 } 0477 ] 0478 }