KCMUtils

AboutPlugin.qml
1 /*
2  SPDX-FileCopyrightText: 2018 Aleix Pol Gonzalez <[email protected]>
3  SPDX-FileCopyrightText: 2020 David Redondo <[email protected]>
4  SPDX-FileCopyrightText: 2022 Alexander Lohnau <[email protected]>
5 
6  SPDX-License-Identifier: LGPL-2.0-or-later
7 */
8 
9 import QtQuick 2.4
10 import QtQuick.Controls 2.4 as QQC2
11 import QtQuick.Layouts 1.3
12 
13 import org.kde.kirigami 2.6 as Kirigami
14 
15 /**
16  * A copy of Kirigami.AboutPage adapted to KPluginMetadata instead of KAboutData
17  */
18 
19 
20 ColumnLayout {
21  id: root
22 
23  property var metaData
24 
25  // Icon, name, version, and description
26  RowLayout {
27  Layout.fillWidth: true
28  spacing: Kirigami.Units.largeSpacing
29 
30  Kirigami.Icon {
31  Layout.preferredHeight: Kirigami.Units.iconSizes.huge
32  Layout.preferredWidth: Kirigami.Units.iconSizes.huge
33  source: root.metaData.iconName
34  fallback: "application-x-plasma"
35  }
36 
37  ColumnLayout {
38  Layout.fillWidth: true
39 
40  Kirigami.Heading {
41  Layout.fillWidth: true
42  text: root.metaData.version ? i18nc("Plugin name and plugin version", "%1 %2", root.metaData.name, root.metaData.version) : root.metaData.name
43  wrapMode: Text.WordWrap
44  }
45  Kirigami.Heading {
46  Layout.fillWidth: true
47  level: 2
48  text: root.metaData.description
49  wrapMode: Text.WordWrap
50  }
51  }
52  }
53 
54 
55  Kirigami.Separator {
56  Layout.fillWidth: true
57  Layout.topMargin: Kirigami.Units.largeSpacing
58  Layout.bottomMargin: Kirigami.Units.largeSpacing
59  }
60 
61 
62  // Copyright
63  Kirigami.Heading {
64  text: i18nd("org.kde.kcmutils", "Copyright")
65  }
66  QQC2.Label {
67  Layout.leftMargin: Kirigami.Units.gridUnit
68  text: root.metaData.copyrightText
69  visible: text.length > 0
70  }
71  Kirigami.UrlButton {
72  Layout.leftMargin: Kirigami.Units.gridUnit
73  url: root.metaData.website ? root.metaData.website : ""
74  visible: url.length > 0
75  }
76 
77 
78  // License
79  RowLayout {
80  QQC2.Label {
81  text: i18nd("org.kde.kcmutils", "License:")
82  }
83  Kirigami.LinkButton {
84  text: root.metaData.license
85  onClicked: {
86  licenseSheet.text = root.metaData.licenseText
87  licenseSheet.title = root.metaData.license
88  licenseSheet.open()
89  }
90  }
91  }
92 
93 
94  // Authors, if any
95  Item {
96  implicitHeight: Kirigami.Units.largeSpacing
97  visible: repAuthors.visible
98  }
99  Kirigami.Heading {
100  text: i18nd("org.kde.kcmutils", "Authors")
101  visible: repAuthors.visible
102  }
103  Repeater {
104  id: repAuthors
105  visible: count > 0
106  model: root.metaData.authors
107  delegate: personDelegate
108  }
109 
110 
111  // Credits, if any
112  Item {
113  implicitHeight: Kirigami.Units.largeSpacing
114  visible: repCredits.visible
115  }
116  Kirigami.Heading {
117  text: i18nd("org.kde.kcmutils", "Credits")
118  visible: repCredits.visible
119  }
120  Repeater {
121  id: repCredits
122  visible: count > 0
123  model: root.metaData.otherContributors
124  delegate: personDelegate
125  }
126 
127 
128  // Translators, if any
129  Item {
130  implicitHeight: Kirigami.Units.largeSpacing
131  visible: repTranslators.visible
132  }
133  Kirigami.Heading {
134  text: i18nd("org.kde.kcmutils", "Translators")
135  visible: repTranslators.visible
136  }
137  Repeater {
138  id: repTranslators
139  visible: count > 0
140  model: root.metaData.translators
141  delegate: personDelegate
142  }
143 
144 
145  Component {
146  id: personDelegate
147 
148  RowLayout {
149  height: implicitHeight + (Kirigami.Units.largeSpacing)
150 
151  spacing: Kirigami.Units.largeSpacing
152 
153  QQC2.Label {
154  text: modelData.name
155  }
156  QQC2.ToolButton {
157  visible: modelData.emailAddress
158  icon.name: "mail-sent"
159  QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
160  QQC2.ToolTip.visible: hovered
161  QQC2.ToolTip.text: i18nd("org.kde.kcmutils", "Send an email to %1", modelData.emailAddress)
162  onClicked: Qt.openUrlExternally("mailto:%1".arg(modelData.emailAddress))
163  }
164  QQC2.ToolButton {
165  visible: modelData.webAddress
166  icon.name: "globe"
167  QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
168  QQC2.ToolTip.visible: hovered
169  QQC2.ToolTip.text: modelData.webAddress
170  onClicked: Qt.openUrlExternally(modelData.webAddress)
171  }
172  }
173  }
174 
175  QQC2.Dialog {
176  id: licenseSheet
177  property alias text: licenseLabel.text
178 
179  width: parent.width
180  height: parent.height
181  anchors.centerIn: parent
182 
183  topPadding: 0
184  leftPadding: 0
185  rightPadding: 0
186  bottomPadding: 0
187 
188  contentItem: QQC2.ScrollView {
189  id: scroll
190  Component.onCompleted: background.visible = true
191  Flickable {
192  id: flickable
193  contentWidth: width
194  contentHeight: licenseLabel.contentHeight
195  clip: true
196  QQC2.Label {
197  id: licenseLabel
198  width: parent.width
199  wrapMode: Text.WordWrap
200  }
201  }
202  }
203  }
204 }
205 
QString i18nd(const char *domain, const char *text, const TYPE &arg...)
IconSizes iconSizes
QString i18nc(const char *context, const char *text, const TYPE &arg...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Jun 25 2022 06:17:34 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.