KCoreAddons

kaboutdata.cpp
1 /*
2  This file is part of the KDE Libraries
3 
4  SPDX-FileCopyrightText: 2000 Espen Sand <[email protected]>
5  SPDX-FileCopyrightText: 2006 Nicolas GOUTTE <[email protected]>
6  SPDX-FileCopyrightText: 2008 Friedrich W. H. Kossebau <[email protected]>
7  SPDX-FileCopyrightText: 2010 Teo Mrnjavac <[email protected]>
8  SPDX-FileCopyrightText: 2017 Harald Sitter <[email protected]>
9  SPDX-FileCopyrightText: 2021 Julius K├╝nzel <[email protected]>
10 
11  SPDX-License-Identifier: LGPL-2.0-or-later
12 */
13 
14 #include "kaboutdata.h"
15 #include "kjsonutils.h"
16 #include "kpluginmetadata.h"
17 
18 #include <QCommandLineOption>
19 #include <QCommandLineParser>
20 #include <QCoreApplication>
21 #include <QFile>
22 #include <QHash>
23 #include <QJsonObject>
24 #include <QList>
25 #include <QLoggingCategory>
26 #include <QSharedData>
27 #include <QStandardPaths>
28 #include <QTextStream>
29 #include <QUrl>
30 
31 #include <algorithm>
32 
33 Q_DECLARE_LOGGING_CATEGORY(KABOUTDATA)
34 // logging category for this framework, default: log stuff >= warning
35 Q_LOGGING_CATEGORY(KABOUTDATA, "kf.coreaddons.kaboutdata", QtWarningMsg)
36 
37 class KAboutPersonPrivate : public QSharedData
38 {
39 public:
40  QString _name;
41  QString _task;
42  QString _emailAddress;
43  QString _webAddress;
44  QString _ocsUsername;
45 };
46 
47 KAboutPerson::KAboutPerson(const QString &_name, const QString &_task, const QString &_emailAddress, const QString &_webAddress, const QString &_ocsUsername)
48  : d(new KAboutPersonPrivate)
49 {
50  d->_name = _name;
51  d->_task = _task;
52  d->_emailAddress = _emailAddress;
53  d->_webAddress = _webAddress;
54  d->_ocsUsername = _ocsUsername;
55 }
56 
57 KAboutPerson::KAboutPerson(const QString &_name, const QString &_email, bool)
58  : d(new KAboutPersonPrivate)
59 {
60  d->_name = _name;
61  d->_emailAddress = _email;
62 }
63 
64 KAboutPerson::KAboutPerson(const KAboutPerson &other) = default;
65 
66 KAboutPerson::~KAboutPerson() = default;
67 
69 {
70  return d->_name;
71 }
72 
74 {
75  return d->_task;
76 }
77 
79 {
80  return d->_emailAddress;
81 }
82 
84 {
85  return d->_webAddress;
86 }
87 
89 {
90  return d->_ocsUsername;
91 }
92 
93 KAboutPerson &KAboutPerson::operator=(const KAboutPerson &other) = default;
94 
96 {
97  const QString name = KJsonUtils::readTranslatedString(obj, QStringLiteral("Name"));
98  const QString task = KJsonUtils::readTranslatedString(obj, QStringLiteral("Task"));
99  const QString email = obj[QStringLiteral("Email")].toString();
100  const QString website = obj[QStringLiteral("Website")].toString();
101  const QString userName = obj[QStringLiteral("UserName")].toString();
102  return KAboutPerson(name, task, email, website, userName);
103 }
104 
105 class KAboutLicensePrivate : public QSharedData
106 {
107 public:
108  KAboutLicensePrivate(KAboutLicense::LicenseKey licenseType, KAboutLicense::VersionRestriction versionRestriction, const KAboutData *aboutData);
109  KAboutLicensePrivate(const KAboutLicensePrivate &other);
110 
111  QString spdxID() const;
112 
113  KAboutLicense::LicenseKey _licenseKey;
114  QString _licenseText;
115  QString _pathToLicenseTextFile;
116  KAboutLicense::VersionRestriction _versionRestriction;
117  // needed for access to the possibly changing copyrightStatement()
118  const KAboutData *_aboutData;
119 };
120 
121 KAboutLicensePrivate::KAboutLicensePrivate(KAboutLicense::LicenseKey licenseType,
122  KAboutLicense::VersionRestriction versionRestriction,
123  const KAboutData *aboutData)
124  : QSharedData()
125  , _licenseKey(licenseType)
126  , _versionRestriction(versionRestriction)
127  , _aboutData(aboutData)
128 {
129 }
130 
131 KAboutLicensePrivate::KAboutLicensePrivate(const KAboutLicensePrivate &other)
132  : QSharedData(other)
133  , _licenseKey(other._licenseKey)
134  , _licenseText(other._licenseText)
135  , _pathToLicenseTextFile(other._pathToLicenseTextFile)
136  , _versionRestriction(other._versionRestriction)
137  , _aboutData(other._aboutData)
138 {
139 }
140 
141 QString KAboutLicensePrivate::spdxID() const
142 {
143  switch (_licenseKey) {
144  case KAboutLicense::GPL_V2:
145  return QStringLiteral("GPL-2.0");
146  case KAboutLicense::LGPL_V2:
147  return QStringLiteral("LGPL-2.0");
148  case KAboutLicense::BSDL:
149  return QStringLiteral("BSD-2-Clause");
150  case KAboutLicense::Artistic:
151  return QStringLiteral("Artistic-1.0");
152  case KAboutLicense::QPL_V1_0:
153  return QStringLiteral("QPL-1.0");
154  case KAboutLicense::GPL_V3:
155  return QStringLiteral("GPL-3.0");
156  case KAboutLicense::LGPL_V3:
157  return QStringLiteral("LGPL-3.0");
159  return QStringLiteral("LGPL-2.1");
160  case KAboutLicense::Custom:
161  case KAboutLicense::File:
162  case KAboutLicense::Unknown:
163  return QString();
164  }
165  return QString();
166 }
167 
169  : d(new KAboutLicensePrivate(Unknown, {}, nullptr))
170 {
171 }
172 
173 KAboutLicense::KAboutLicense(LicenseKey licenseType, VersionRestriction versionRestriction, const KAboutData *aboutData)
174  : d(new KAboutLicensePrivate(licenseType, versionRestriction, aboutData))
175 {
176 }
177 
178 KAboutLicense::KAboutLicense(LicenseKey licenseType, const KAboutData *aboutData)
179  : d(new KAboutLicensePrivate(licenseType, OnlyThisVersion, aboutData))
180 {
181 }
182 
184  : d(new KAboutLicensePrivate(Unknown, OnlyThisVersion, aboutData))
185 {
186 }
187 
189  : d(other.d)
190 {
191 }
192 
193 KAboutLicense::~KAboutLicense()
194 {
195 }
196 
197 void KAboutLicense::setLicenseFromPath(const QString &pathToFile)
198 {
199  d->_licenseKey = KAboutLicense::File;
200  d->_pathToLicenseTextFile = pathToFile;
201 }
202 
203 void KAboutLicense::setLicenseFromText(const QString &licenseText)
204 {
205  d->_licenseKey = KAboutLicense::Custom;
206  d->_licenseText = licenseText;
207 }
208 
210 {
211  QString result;
212 
213  const QString lineFeed = QStringLiteral("\n\n");
214 
215  if (d->_aboutData && !d->_aboutData->copyrightStatement().isEmpty()) {
216  result = d->_aboutData->copyrightStatement() + lineFeed;
217  }
218 
219  bool knownLicense = false;
220  QString pathToFile; // rel path if known license
221  switch (d->_licenseKey) {
222  case KAboutLicense::File:
223  pathToFile = d->_pathToLicenseTextFile;
224  break;
225  case KAboutLicense::GPL_V2:
226  knownLicense = true;
227  pathToFile = QStringLiteral("GPL_V2");
228  break;
229  case KAboutLicense::LGPL_V2:
230  knownLicense = true;
231  pathToFile = QStringLiteral("LGPL_V2");
232  break;
233  case KAboutLicense::BSDL:
234  knownLicense = true;
235  pathToFile = QStringLiteral("BSD");
236  break;
237  case KAboutLicense::Artistic:
238  knownLicense = true;
239  pathToFile = QStringLiteral("ARTISTIC");
240  break;
241  case KAboutLicense::QPL_V1_0:
242  knownLicense = true;
243  pathToFile = QStringLiteral("QPL_V1.0");
244  break;
245  case KAboutLicense::GPL_V3:
246  knownLicense = true;
247  pathToFile = QStringLiteral("GPL_V3");
248  break;
249  case KAboutLicense::LGPL_V3:
250  knownLicense = true;
251  pathToFile = QStringLiteral("LGPL_V3");
252  break;
254  knownLicense = true;
255  pathToFile = QStringLiteral("LGPL_V21");
256  break;
257  case KAboutLicense::Custom:
258  if (!d->_licenseText.isEmpty()) {
259  result = d->_licenseText;
260  break;
261  }
262  Q_FALLTHROUGH();
263  // fall through
264  default:
265  result += QCoreApplication::translate("KAboutLicense",
266  "No licensing terms for this program have been specified.\n"
267  "Please check the documentation or the source for any\n"
268  "licensing terms.\n");
269  }
270 
271  if (knownLicense) {
272  pathToFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("kf5/licenses/") + pathToFile);
273  result += QCoreApplication::translate("KAboutLicense", "This program is distributed under the terms of the %1.").arg(name(KAboutLicense::ShortName));
274  if (!pathToFile.isEmpty()) {
275  result += lineFeed;
276  }
277  }
278 
279  if (!pathToFile.isEmpty()) {
280  QFile file(pathToFile);
281  if (file.open(QIODevice::ReadOnly)) {
282  QTextStream str(&file);
283  result += str.readAll();
284  }
285  }
286 
287  return result;
288 }
289 
291 {
292  // SPDX licenses are comprised of an identifier (e.g. GPL-2.0), an optional + to denote 'or
293  // later versions' and optional ' WITH $exception' to denote standardized exceptions from the
294  // core license. As we do not offer exceptions we effectively only return GPL-2.0 or GPL-2.0+,
295  // this may change in the future. To that end the documentation makes no assertions about the
296  // actual content of the SPDX license expression we return.
297  // Expressions can in theory also contain AND, OR and () to build constructs involving more than
298  // one license. As this is outside the scope of a single license object we'll ignore this here
299  // for now.
300  // The expectation is that the return value is only run through spec-compliant parsers, so this
301  // can potentially be changed.
302 
303  auto id = d->spdxID();
304  if (id.isNull()) { // Guard against potential future changes which would allow 'Foo+' as input.
305  return id;
306  }
307  return d->_versionRestriction == OrLaterVersions ? id.append(QLatin1Char('+')) : id;
308 }
309 
310 QString KAboutLicense::name(KAboutLicense::NameFormat formatName) const
311 {
312  QString licenseShort;
313  QString licenseFull;
314 
315  switch (d->_licenseKey) {
316  case KAboutLicense::GPL_V2:
317  licenseShort = QCoreApplication::translate("KAboutLicense", "GPL v2", "@item license (short name)");
318  licenseFull = QCoreApplication::translate("KAboutLicense", "GNU General Public License Version 2", "@item license");
319  break;
320  case KAboutLicense::LGPL_V2:
321  licenseShort = QCoreApplication::translate("KAboutLicense", "LGPL v2", "@item license (short name)");
322  licenseFull = QCoreApplication::translate("KAboutLicense", "GNU Lesser General Public License Version 2", "@item license");
323  break;
324  case KAboutLicense::BSDL:
325  licenseShort = QCoreApplication::translate("KAboutLicense", "BSD License", "@item license (short name)");
326  licenseFull = QCoreApplication::translate("KAboutLicense", "BSD License", "@item license");
327  break;
328  case KAboutLicense::Artistic:
329  licenseShort = QCoreApplication::translate("KAboutLicense", "Artistic License", "@item license (short name)");
330  licenseFull = QCoreApplication::translate("KAboutLicense", "Artistic License", "@item license");
331  break;
332  case KAboutLicense::QPL_V1_0:
333  licenseShort = QCoreApplication::translate("KAboutLicense", "QPL v1.0", "@item license (short name)");
334  licenseFull = QCoreApplication::translate("KAboutLicense", "Q Public License", "@item license");
335  break;
336  case KAboutLicense::GPL_V3:
337  licenseShort = QCoreApplication::translate("KAboutLicense", "GPL v3", "@item license (short name)");
338  licenseFull = QCoreApplication::translate("KAboutLicense", "GNU General Public License Version 3", "@item license");
339  break;
340  case KAboutLicense::LGPL_V3:
341  licenseShort = QCoreApplication::translate("KAboutLicense", "LGPL v3", "@item license (short name)");
342  licenseFull = QCoreApplication::translate("KAboutLicense", "GNU Lesser General Public License Version 3", "@item license");
343  break;
345  licenseShort = QCoreApplication::translate("KAboutLicense", "LGPL v2.1", "@item license (short name)");
346  licenseFull = QCoreApplication::translate("KAboutLicense", "GNU Lesser General Public License Version 2.1", "@item license");
347  break;
348  case KAboutLicense::Custom:
349  case KAboutLicense::File:
350  licenseShort = licenseFull = QCoreApplication::translate("KAboutLicense", "Custom", "@item license");
351  break;
352  default:
353  licenseShort = licenseFull = QCoreApplication::translate("KAboutLicense", "Not specified", "@item license");
354  }
355 
356  const QString result = (formatName == KAboutLicense::ShortName) ? licenseShort : (formatName == KAboutLicense::FullName) ? licenseFull : QString();
357 
358  return result;
359 }
360 
362 {
363  d = other.d;
364  return *this;
365 }
366 
368 {
369  return d->_licenseKey;
370 }
371 
373 {
374  // Setup keyword->enum dictionary on first call.
375  // Use normalized keywords, by the algorithm below.
376  static const QHash<QByteArray, KAboutLicense::LicenseKey> licenseDict{
377  {"gpl", KAboutLicense::GPL}, {"gplv2", KAboutLicense::GPL_V2},
378  {"gplv2+", KAboutLicense::GPL_V2}, {"gpl20", KAboutLicense::GPL_V2},
379  {"gpl20+", KAboutLicense::GPL_V2}, {"lgpl", KAboutLicense::LGPL},
380  {"lgplv2", KAboutLicense::LGPL_V2}, {"lgplv2+", KAboutLicense::LGPL_V2},
381  {"lgpl20", KAboutLicense::LGPL_V2}, {"lgpl20+", KAboutLicense::LGPL_V2},
382  {"bsd", KAboutLicense::BSDL}, {"bsd2clause", KAboutLicense::BSDL},
383  {"artistic", KAboutLicense::Artistic}, {"artistic10", KAboutLicense::Artistic},
384  {"qpl", KAboutLicense::QPL}, {"qplv1", KAboutLicense::QPL_V1_0},
385  {"qplv10", KAboutLicense::QPL_V1_0}, {"qpl10", KAboutLicense::QPL_V1_0},
386  {"gplv3", KAboutLicense::GPL_V3}, {"gplv3+", KAboutLicense::GPL_V3},
387  {"gpl30", KAboutLicense::GPL_V3}, {"gpl30+", KAboutLicense::GPL_V3},
388  {"lgplv3", KAboutLicense::LGPL_V3}, {"lgplv3+", KAboutLicense::LGPL_V3},
389  {"lgpl30", KAboutLicense::LGPL_V3}, {"lgpl30+", KAboutLicense::LGPL_V3},
390  {"lgplv21", KAboutLicense::LGPL_V2_1}, {"lgplv21+", KAboutLicense::LGPL_V2_1},
391  {"lgpl21", KAboutLicense::LGPL_V2_1}, {"lgpl21+", KAboutLicense::LGPL_V2_1},
392  };
393 
394  // Normalize keyword.
395  QString keyword = rawKeyword;
396  keyword = keyword.toLower();
397  keyword.remove(QLatin1Char(' '));
398  keyword.remove(QLatin1Char('.'));
399  keyword.remove(QLatin1Char('-'));
400 
401  LicenseKey license = licenseDict.value(keyword.toLatin1(), KAboutLicense::Custom);
402  auto restriction = keyword.endsWith(QLatin1Char('+')) ? OrLaterVersions : OnlyThisVersion;
403  return KAboutLicense(license, restriction, nullptr);
404 }
405 
406 class KAboutComponentPrivate : public QSharedData
407 {
408 public:
409  QString _name;
410  QString _description;
411  QString _version;
412  QString _webAddress;
413  KAboutLicense _license;
414 };
415 
416 KAboutComponent::KAboutComponent(const QString &_name, const QString &_description, const QString &_version, const QString &_webAddress, enum KAboutLicense::LicenseKey licenseType)
417  : d(new KAboutComponentPrivate)
418 {
419  d->_name = _name;
420  d->_description = _description;
421  d->_version = _version;
422  d->_webAddress = _webAddress;
423  d->_license = KAboutLicense(licenseType, nullptr);
424 }
425 
426 KAboutComponent::KAboutComponent(const QString &_name, const QString &_description, const QString &_version, const QString &_webAddress, const QString &pathToLicenseFile)
427  : d(new KAboutComponentPrivate)
428 {
429  d->_name = _name;
430  d->_description = _description;
431  d->_version = _version;
432  d->_webAddress = _webAddress;
433  d->_license = KAboutLicense();
434  d->_license.setLicenseFromPath(pathToLicenseFile);
435 }
436 
437 KAboutComponent::KAboutComponent(const KAboutComponent &other) = default;
438 
439 KAboutComponent::~KAboutComponent() = default;
440 
442 {
443  return d->_name;
444 }
445 
447 {
448  return d->_description;
449 }
450 
452 {
453  return d->_version;
454 }
455 
457 {
458  return d->_webAddress;
459 }
460 
462 {
463  return d->_license;
464 }
465 
467 
468 class KAboutDataPrivate
469 {
470 public:
471  KAboutDataPrivate()
472  : customAuthorTextEnabled(false)
473  {
474  }
475  QString _componentName;
476  QString _displayName;
477  QString _shortDescription;
478  QString _copyrightStatement;
479  QString _otherText;
480  QString _homepageAddress;
481  QList<KAboutPerson> _authorList;
482  QList<KAboutPerson> _creditList;
483  QList<KAboutPerson> _translatorList;
484  QList<KAboutComponent> _componentList;
485  QList<KAboutLicense> _licenseList;
486 #if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 2)
487  QString programIconName;
488 #endif
489  QVariant programLogo;
490  QString customAuthorPlainText, customAuthorRichText;
491  bool customAuthorTextEnabled;
492 
493  QString organizationDomain;
494  QString _ocsProviderUrl;
495  QString desktopFileName;
496 
497  // Everything dr.konqi needs, we store as utf-8, so we
498  // can just give it a pointer, w/o any allocations.
499  QByteArray _internalProgramName;
500  QByteArray _version;
501  QByteArray _bugAddress;
502  QByteArray productName;
503 
504  static QList<KAboutPerson> parseTranslators(const QString &translatorName, const QString &translatorEmail);
505 };
506 
507 KAboutData::KAboutData(const QString &_componentName,
508  const QString &_displayName,
509  const QString &_version,
510  const QString &_shortDescription,
511  enum KAboutLicense::LicenseKey licenseType,
512  const QString &_copyrightStatement,
513  const QString &text,
514  const QString &homePageAddress,
515  const QString &bugAddress)
516  : d(new KAboutDataPrivate)
517 {
518  d->_componentName = _componentName;
519  int p = d->_componentName.indexOf(QLatin1Char('/'));
520  if (p >= 0) {
521  d->_componentName = d->_componentName.mid(p + 1);
522  }
523 
524  d->_displayName = _displayName;
525  if (!d->_displayName.isEmpty()) { // KComponentData("klauncher") gives empty program name
526  d->_internalProgramName = _displayName.toUtf8();
527  }
528  d->_version = _version.toUtf8();
529  d->_shortDescription = _shortDescription;
530  d->_licenseList.append(KAboutLicense(licenseType, this));
531  d->_copyrightStatement = _copyrightStatement;
532  d->_otherText = text;
533  d->_homepageAddress = homePageAddress;
534  d->_bugAddress = bugAddress.toUtf8();
535 
536  QUrl homePageUrl(homePageAddress);
537  if (!homePageUrl.isValid() || homePageUrl.scheme().isEmpty()) {
538  // Default domain if nothing else is better
539  homePageUrl.setUrl(QStringLiteral("https://kde.org/"));
540  }
541 
542  const QChar dotChar(QLatin1Char('.'));
543  QStringList hostComponents = homePageUrl.host().split(dotChar);
544 
545  // Remove leading component unless 2 (or less) components are present
546  if (hostComponents.size() > 2) {
547  hostComponents.removeFirst();
548  }
549 
550  d->organizationDomain = hostComponents.join(dotChar);
551 
552  // KF6: do not set a default desktopFileName value here, but remove this code and leave it empty
553  // see KAboutData::desktopFileName() for details
554 
555  // desktop file name is reverse domain name
556  std::reverse(hostComponents.begin(), hostComponents.end());
557  hostComponents.append(_componentName);
558 
559  d->desktopFileName = hostComponents.join(dotChar);
560 }
561 
562 KAboutData::KAboutData(const QString &_componentName, const QString &_displayName, const QString &_version)
563  : d(new KAboutDataPrivate)
564 {
565  d->_componentName = _componentName;
566  int p = d->_componentName.indexOf(QLatin1Char('/'));
567  if (p >= 0) {
568  d->_componentName = d->_componentName.mid(p + 1);
569  }
570 
571  d->_displayName = _displayName;
572  if (!d->_displayName.isEmpty()) { // KComponentData("klauncher") gives empty program name
573  d->_internalProgramName = _displayName.toUtf8();
574  }
575  d->_version = _version.toUtf8();
576 
577  // match behaviour of other constructors
578  d->_licenseList.append(KAboutLicense(KAboutLicense::Unknown, this));
579  d->_bugAddress = "[email protected]";
580  d->organizationDomain = QStringLiteral("kde.org");
581  // KF6: do not set a default desktopFileName value here, but remove this code and leave it empty
582  // see KAboutData::desktopFileName() for details
583  d->desktopFileName = QLatin1String("org.kde.") + d->_componentName;
584 }
585 
586 KAboutData::~KAboutData() = default;
587 
589  : d(new KAboutDataPrivate)
590 {
591  *d = *other.d;
592  QList<KAboutLicense>::iterator it = d->_licenseList.begin();
593  QList<KAboutLicense>::iterator itEnd = d->_licenseList.end();
594  for (; it != itEnd; ++it) {
595  KAboutLicense &al = *it;
596  al.d.detach();
597  al.d->_aboutData = this;
598  }
599 }
600 
602 {
603  if (this != &other) {
604  *d = *other.d;
605  QList<KAboutLicense>::iterator it = d->_licenseList.begin();
606  QList<KAboutLicense>::iterator itEnd = d->_licenseList.end();
607  for (; it != itEnd; ++it) {
608  KAboutLicense &al = *it;
609  al.d.detach();
610  al.d->_aboutData = this;
611  }
612  }
613  return *this;
614 }
615 
616 #if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 65)
618 {
619  KAboutData ret(plugin.pluginId(),
620  plugin.name(),
621  plugin.version(),
622  plugin.description(),
623  KAboutLicense::byKeyword(plugin.license()).key(),
624  plugin.copyrightText(),
625  plugin.extraInformation(),
626  plugin.website());
627 #if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 2)
628  ret.d->programIconName = plugin.iconName();
629 #endif
630  ret.d->_authorList = plugin.authors();
631  ret.d->_translatorList = plugin.translators();
632  ret.d->_creditList = plugin.otherContributors();
633  return ret;
634 }
635 #endif
636 
637 KAboutData &KAboutData::addAuthor(const QString &name, const QString &task, const QString &emailAddress, const QString &webAddress, const QString &ocsUsername)
638 {
639  d->_authorList.append(KAboutPerson(name, task, emailAddress, webAddress, ocsUsername));
640  return *this;
641 }
642 
643 KAboutData &KAboutData::addCredit(const QString &name, const QString &task, const QString &emailAddress, const QString &webAddress, const QString &ocsUsername)
644 {
645  d->_creditList.append(KAboutPerson(name, task, emailAddress, webAddress, ocsUsername));
646  return *this;
647 }
648 
649 KAboutData &KAboutData::setTranslator(const QString &name, const QString &emailAddress)
650 {
651  d->_translatorList = KAboutDataPrivate::parseTranslators(name, emailAddress);
652  return *this;
653 }
654 
655 KAboutData &KAboutData::addComponent(const QString &name, const QString &description, const QString &version, const QString &webAddress, KAboutLicense::LicenseKey licenseKey)
656 {
657  d->_componentList.append(KAboutComponent(name, description, version, webAddress, licenseKey));
658  return *this;
659 }
660 
661 KAboutData &KAboutData::addComponent(const QString &name, const QString &description, const QString &version, const QString &webAddress, const QString &pathToLicenseFile)
662 {
663  d->_componentList.append(KAboutComponent(name, description, version, webAddress, pathToLicenseFile));
664  return *this;
665 }
666 
668 {
669  d->_licenseList[0] = KAboutLicense(this);
670  d->_licenseList[0].setLicenseFromText(licenseText);
671  return *this;
672 }
673 
675 {
676  // if the default license is unknown, overwrite instead of append
677  KAboutLicense &firstLicense = d->_licenseList[0];
678  KAboutLicense newLicense(this);
679  newLicense.setLicenseFromText(licenseText);
680  if (d->_licenseList.count() == 1 && firstLicense.d->_licenseKey == KAboutLicense::Unknown) {
681  firstLicense = newLicense;
682  } else {
683  d->_licenseList.append(newLicense);
684  }
685 
686  return *this;
687 }
688 
690 {
691  d->_licenseList[0] = KAboutLicense(this);
692  d->_licenseList[0].setLicenseFromPath(pathToFile);
693  return *this;
694 }
695 
697 {
698  // if the default license is unknown, overwrite instead of append
699  KAboutLicense &firstLicense = d->_licenseList[0];
700  KAboutLicense newLicense(this);
701  newLicense.setLicenseFromPath(pathToFile);
702  if (d->_licenseList.count() == 1 && firstLicense.d->_licenseKey == KAboutLicense::Unknown) {
703  firstLicense = newLicense;
704  } else {
705  d->_licenseList.append(newLicense);
706  }
707  return *this;
708 }
709 
711 {
712  d->_componentName = componentName;
713  return *this;
714 }
715 
717 {
718  d->_displayName = _displayName;
719  d->_internalProgramName = _displayName.toUtf8();
720  return *this;
721 }
722 
724 {
725  d->_ocsProviderUrl = _ocsProviderUrl;
726  return *this;
727 }
728 
730 {
731  d->_version = _version;
732  return *this;
733 }
734 
736 {
737  d->_shortDescription = _shortDescription;
738  return *this;
739 }
740 
742 {
743  return setLicense(licenseKey, KAboutLicense::OnlyThisVersion);
744 }
745 
747 {
748  d->_licenseList[0] = KAboutLicense(licenseKey, versionRestriction, this);
749  return *this;
750 }
751 
753 {
754  return addLicense(licenseKey, KAboutLicense::OnlyThisVersion);
755 }
756 
758 {
759  // if the default license is unknown, overwrite instead of append
760  KAboutLicense &firstLicense = d->_licenseList[0];
761  if (d->_licenseList.count() == 1 && firstLicense.d->_licenseKey == KAboutLicense::Unknown) {
762  firstLicense = KAboutLicense(licenseKey, versionRestriction, this);
763  } else {
764  d->_licenseList.append(KAboutLicense(licenseKey, versionRestriction, this));
765  }
766  return *this;
767 }
768 
770 {
771  d->_copyrightStatement = _copyrightStatement;
772  return *this;
773 }
774 
776 {
777  d->_otherText = _otherText;
778  return *this;
779 }
780 
782 {
783  d->_homepageAddress = homepage;
784  return *this;
785 }
786 
788 {
789  d->_bugAddress = _bugAddress;
790  return *this;
791 }
792 
794 {
795  d->organizationDomain = QString::fromLatin1(domain.data());
796  return *this;
797 }
798 
800 {
801  d->productName = _productName;
802  return *this;
803 }
804 
806 {
807  return d->_componentName;
808 }
809 
811 {
812  if (!d->productName.isEmpty()) {
813  return QString::fromUtf8(d->productName);
814  }
815  return componentName();
816 }
817 
819 {
820  return d->productName.isEmpty() ? nullptr : d->productName.constData();
821 }
822 
824 {
825  if (!d->_displayName.isEmpty()) {
826  return d->_displayName;
827  }
828  return componentName();
829 }
830 
831 /// @internal
832 /// Return the program name. It is always pre-allocated.
833 /// Needed for KCrash in particular.
835 {
836  return d->_internalProgramName.constData();
837 }
838 
839 #if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 2)
841 {
842  return d->programIconName.isEmpty() ? componentName() : d->programIconName;
843 }
844 
846 {
847  d->programIconName = iconName;
848  return *this;
849 }
850 #endif
851 
853 {
854  return d->programLogo;
855 }
856 
858 {
859  d->programLogo = image;
860  return *this;
861 }
862 
864 {
865  return d->_ocsProviderUrl;
866 }
867 
869 {
870  return QString::fromUtf8(d->_version.data());
871 }
872 
873 /// @internal
874 /// Return the untranslated and uninterpreted (to UTF8) string
875 /// for the version information. Used in particular for KCrash.
876 const char *KAboutData::internalVersion() const
877 {
878  return d->_version.constData();
879 }
880 
882 {
883  return d->_shortDescription;
884 }
885 
887 {
888  return d->_homepageAddress;
889 }
890 
892 {
893  return QString::fromUtf8(d->_bugAddress.constData());
894 }
895 
897 {
898  return d->organizationDomain;
899 }
900 
901 /// @internal
902 /// Return the untranslated and uninterpreted (to UTF8) string
903 /// for the bug mail address. Used in particular for KCrash.
905 {
906  if (d->_bugAddress.isEmpty()) {
907  return nullptr;
908  }
909  return d->_bugAddress.constData();
910 }
911 
913 {
914  return d->_authorList;
915 }
916 
918 {
919  return d->_creditList;
920 }
921 
922 QList<KAboutPerson> KAboutDataPrivate::parseTranslators(const QString &translatorName, const QString &translatorEmail)
923 {
924  QList<KAboutPerson> personList;
925  if (translatorName.isEmpty() || translatorName == QLatin1String("Your names")) {
926  return personList;
927  }
928 
929  const QStringList nameList(translatorName.split(QLatin1Char(',')));
930 
931  QStringList emailList;
932  if (!translatorEmail.isEmpty() && translatorEmail != QLatin1String("Your emails")) {
933  emailList = translatorEmail.split(QLatin1Char(','), Qt::KeepEmptyParts);
934  }
935 
937  QStringList::const_iterator eit = emailList.constBegin();
938 
939  for (nit = nameList.constBegin(); nit != nameList.constEnd(); ++nit) {
940  QString email;
941  if (eit != emailList.constEnd()) {
942  email = *eit;
943  ++eit;
944  }
945 
946  personList.append(KAboutPerson((*nit).trimmed(), email.trimmed(), true));
947  }
948 
949  return personList;
950 }
951 
953 {
954  return d->_translatorList;
955 }
956 
958 {
959  return QCoreApplication::translate("KAboutData",
960  "<p>KDE is translated into many languages thanks to the work "
961  "of the translation teams all over the world.</p>"
962  "<p>For more information on KDE internationalization "
963  "visit <a href=\"https://l10n.kde.org\">https://l10n.kde.org</a></p>",
964  "replace this with information about your translation team");
965 }
966 
968 {
969  return d->_otherText;
970 }
971 
973 {
974  return d->_componentList;
975 }
976 
978 {
979  return d->_licenseList;
980 }
981 
983 {
984  return d->_copyrightStatement;
985 }
986 
988 {
989  return d->customAuthorPlainText;
990 }
991 
993 {
994  return d->customAuthorRichText;
995 }
996 
998 {
999  return d->customAuthorTextEnabled;
1000 }
1001 
1002 KAboutData &KAboutData::setCustomAuthorText(const QString &plainText, const QString &richText)
1003 {
1004  d->customAuthorPlainText = plainText;
1005  d->customAuthorRichText = richText;
1006 
1007  d->customAuthorTextEnabled = true;
1008 
1009  return *this;
1010 }
1011 
1013 {
1014  d->customAuthorPlainText = QString();
1015  d->customAuthorRichText = QString();
1016 
1017  d->customAuthorTextEnabled = false;
1018 
1019  return *this;
1020 }
1021 
1023 {
1024  d->desktopFileName = desktopFileName;
1025 
1026  return *this;
1027 }
1028 
1030 {
1031  return d->desktopFileName;
1032  // KF6: switch to this code and adapt API dox
1033 #if 0
1034  // if desktopFileName has been explicitly set, use that value
1035  if (!d->desktopFileName.isEmpty()) {
1036  return d->desktopFileName;
1037  }
1038 
1039  // return a string calculated on-the-fly from the current org domain & component name
1040  const QChar dotChar(QLatin1Char('.'));
1041  QStringList hostComponents = d->organizationDomain.split(dotChar);
1042 
1043  // desktop file name is reverse domain name
1044  std::reverse(hostComponents.begin(), hostComponents.end());
1045  hostComponents.append(componentName());
1046 
1047  return hostComponents.join(dotChar);
1048 #endif
1049 }
1050 
1051 class KAboutDataRegistry
1052 {
1053 public:
1054  KAboutDataRegistry()
1055  : m_appData(nullptr)
1056  {
1057  }
1058  ~KAboutDataRegistry()
1059  {
1060  delete m_appData;
1061 #if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 76)
1062  qDeleteAll(m_pluginData);
1063 #endif
1064  }
1065  KAboutDataRegistry(const KAboutDataRegistry &) = delete;
1066  KAboutDataRegistry &operator=(const KAboutDataRegistry &) = delete;
1067 
1068  KAboutData *m_appData;
1069 #if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 76)
1070  QHash<QString, KAboutData *> m_pluginData;
1071 #endif
1072 };
1073 
1074 Q_GLOBAL_STATIC(KAboutDataRegistry, s_registry)
1075 
1076 namespace
1077 {
1078 void warnIfOutOfSync(const char *aboutDataString, const QString &aboutDataValue, const char *appDataString, const QString &appDataValue)
1079 {
1080  if (aboutDataValue != appDataValue) {
1081  qCWarning(KABOUTDATA) << appDataString << appDataValue << "is out-of-sync with" << aboutDataString << aboutDataValue;
1082  }
1083 }
1084 
1085 }
1086 
1088 {
1090 
1091  KAboutData *aboutData = s_registry->m_appData;
1092 
1093  // not yet existing
1094  if (!aboutData) {
1095  // init from current Q*Application data
1097  // For applicationDisplayName & desktopFileName, which are only properties of QGuiApplication,
1098  // we have to try to get them via the property system, as the static getter methods are
1099  // part of QtGui only. Disadvantage: requires an app instance.
1100  // Either get all or none of the properties & warn about it
1101  if (app) {
1103  aboutData->setVersion(QCoreApplication::applicationVersion().toUtf8());
1104  aboutData->setDisplayName(app->property("applicationDisplayName").toString());
1105  aboutData->setDesktopFileName(app->property("desktopFileName").toString());
1106  } else {
1107  qCWarning(KABOUTDATA) << "Could not initialize the properties of KAboutData::applicationData by the equivalent properties from Q*Application: no "
1108  "app instance (yet) existing.";
1109  }
1110 
1111  s_registry->m_appData = aboutData;
1112  } else {
1113  // check if in-sync with Q*Application metadata, as their setters could have been called
1114  // after the last KAboutData::setApplicationData, with different values
1115  warnIfOutOfSync("KAboutData::applicationData().componentName",
1116  aboutData->componentName(),
1117  "QCoreApplication::applicationName",
1119  warnIfOutOfSync("KAboutData::applicationData().version",
1120  aboutData->version(),
1121  "QCoreApplication::applicationVersion",
1123  warnIfOutOfSync("KAboutData::applicationData().organizationDomain",
1124  aboutData->organizationDomain(),
1125  "QCoreApplication::organizationDomain",
1127  if (app) {
1128  warnIfOutOfSync("KAboutData::applicationData().displayName",
1129  aboutData->displayName(),
1130  "QGuiApplication::applicationDisplayName",
1131  app->property("applicationDisplayName").toString());
1132  warnIfOutOfSync("KAboutData::applicationData().desktopFileName",
1133  aboutData->desktopFileName(),
1134  "QGuiApplication::desktopFileName",
1135  app->property("desktopFileName").toString());
1136  }
1137  }
1138 
1139  return *aboutData;
1140 }
1141 
1143 {
1144  if (s_registry->m_appData) {
1145  *s_registry->m_appData = aboutData;
1146  } else {
1147  s_registry->m_appData = new KAboutData(aboutData);
1148  }
1149 
1150  // For applicationDisplayName & desktopFileName, which are only properties of QGuiApplication,
1151  // we have to try to set them via the property system, as the static getter methods are
1152  // part of QtGui only. Disadvantage: requires an app instance.
1153  // So set either all or none of the properties & warn about it
1155  if (app) {
1156  app->setApplicationVersion(aboutData.version());
1157  app->setApplicationName(aboutData.componentName());
1158  app->setOrganizationDomain(aboutData.organizationDomain());
1159  app->setProperty("applicationDisplayName", aboutData.displayName());
1160  app->setProperty("desktopFileName", aboutData.desktopFileName());
1161  } else {
1162  qCWarning(KABOUTDATA) << "Could not initialize the equivalent properties of Q*Application: no instance (yet) existing.";
1163  }
1164 
1165  // KF6: Rethink the current relation between KAboutData::applicationData and the Q*Application metadata
1166  // Always overwriting the Q*Application metadata here, but not updating back the KAboutData
1167  // in applicationData() is unbalanced and can result in out-of-sync data if the Q*Application
1168  // setters have been called meanwhile
1169  // Options are to remove the overlapping properties of KAboutData for cleancode, or making the
1170  // overlapping properties official shadow properties of their Q*Application countparts, though
1171  // that increases behavioural complexity a little.
1172 }
1173 
1174 #if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 76)
1176 {
1177  auto &data = s_registry->m_pluginData[aboutData.componentName()];
1178  if (data) {
1179  // silently ignore double registration, assuming it's for the same plugin
1180  // all of this is getting deprecated anyways, we just don't want to leak anything
1181  return;
1182  }
1183  data = new KAboutData(aboutData);
1184 }
1185 #endif
1186 
1187 #if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 76)
1189 {
1190  KAboutData *ad = s_registry->m_pluginData.value(componentName);
1191  return ad;
1192 }
1193 #endif
1194 
1195 // only for KCrash (no memory allocation allowed)
1196 const KAboutData *KAboutData::applicationDataPointer()
1197 {
1198  if (s_registry.exists()) {
1199  return s_registry->m_appData;
1200  }
1201  return nullptr;
1202 }
1203 
1205 {
1206  if (!d->_shortDescription.isEmpty()) {
1207  parser->setApplicationDescription(d->_shortDescription);
1208  }
1209 
1210  parser->addHelpOption();
1211 
1213  if (app && !app->applicationVersion().isEmpty()) {
1214  parser->addVersionOption();
1215  }
1216 
1217  return parser->addOption(QCommandLineOption(QStringLiteral("author"), QCoreApplication::translate("KAboutData CLI", "Show author information.")))
1218  && parser->addOption(QCommandLineOption(QStringLiteral("license"), QCoreApplication::translate("KAboutData CLI", "Show license information.")))
1219  && parser->addOption(QCommandLineOption(QStringLiteral("desktopfile"),
1220  QCoreApplication::translate("KAboutData CLI", "The base file name of the desktop entry for this application."),
1221  QCoreApplication::translate("KAboutData CLI", "file name")));
1222 }
1223 
1225 {
1226  bool foundArgument = false;
1227  if (parser->isSet(QStringLiteral("author"))) {
1228  foundArgument = true;
1229  if (d->_authorList.isEmpty()) {
1230  printf("%s\n",
1231  qPrintable(QCoreApplication::translate("KAboutData CLI", "This application was written by somebody who wants to remain anonymous.")));
1232  } else {
1233  printf("%s\n", qPrintable(QCoreApplication::translate("KAboutData CLI", "%1 was written by:").arg(qAppName())));
1234  for (const KAboutPerson &person : std::as_const(d->_authorList)) {
1235  QString authorData = QLatin1String(" ") + person.name();
1236  if (!person.emailAddress().isEmpty()) {
1237  authorData.append(QLatin1String(" <") + person.emailAddress() + QLatin1Char('>'));
1238  }
1239  printf("%s\n", qPrintable(authorData));
1240  }
1241  }
1242  if (!customAuthorTextEnabled()) {
1244  printf("%s\n", qPrintable(QCoreApplication::translate("KAboutData CLI", "Please use https://bugs.kde.org to report bugs.")));
1245  } else if (!bugAddress().isEmpty()) {
1246  printf("%s\n", qPrintable(QCoreApplication::translate("KAboutData CLI", "Please report bugs to %1.").arg(bugAddress())));
1247  }
1248  } else {
1249  printf("%s\n", qPrintable(customAuthorPlainText()));
1250  }
1251  } else if (parser->isSet(QStringLiteral("license"))) {
1252  foundArgument = true;
1253  for (const KAboutLicense &license : std::as_const(d->_licenseList)) {
1254  printf("%s\n", qPrintable(license.text()));
1255  }
1256  }
1257 
1258  const QString desktopFileName = parser->value(QStringLiteral("desktopfile"));
1259  if (!desktopFileName.isEmpty()) {
1260  d->desktopFileName = desktopFileName;
1261  }
1262 
1263  if (foundArgument) {
1264  ::exit(EXIT_SUCCESS);
1265  }
1266 }
1267 
1268 template<class T>
1269 QVariantList listToVariant(const QList<T> &values)
1270 {
1271  QVariantList ret;
1272  ret.reserve(values.count());
1273  for (const auto &value : values) {
1274  ret << QVariant::fromValue(value);
1275  }
1276  return ret;
1277 }
1278 
1279 QVariantList KAboutData::licensesVariant() const
1280 {
1281  return listToVariant(d->_licenseList);
1282 }
1283 
1284 QVariantList KAboutData::authorsVariant() const
1285 {
1286  return listToVariant(d->_authorList);
1287 }
1288 
1289 QVariantList KAboutData::creditsVariant() const
1290 {
1291  return listToVariant(d->_creditList);
1292 }
1293 
1294 QVariantList KAboutData::translatorsVariant() const
1295 {
1296  return listToVariant(d->_translatorList);
1297 }
1298 
1299 QVariantList KAboutData::componentsVariant() const
1300 {
1301  return listToVariant(d->_componentList);
1302 }
This class is used to store information about a license.
Definition: kaboutdata.h:180
KAboutData & setCopyrightStatement(const QString &copyrightStatement)
Defines the copyright statement to show when displaying the license.
Definition: kaboutdata.cpp:769
const char * internalVersion() const
Definition: kaboutdata.cpp:876
QString homepage() const
Returns the application homepage.
KAboutData & setBugAddress(const QByteArray &bugAddress)
Defines the address where bug reports should be sent.
Definition: kaboutdata.cpp:787
QString & append(QChar ch)
QString organizationDomain() const
Returns the domain name of the organization that wrote this application.
Definition: kaboutdata.cpp:896
KAboutLicense::LicenseKey key() const
Returns the license key.
void processCommandLine(QCommandLineParser *parser)
Reads the processed parser and sees if any of the arguments are the ones set up from setupCommandLine...
QString componentName() const
Returns the application&#39;s internal name.
static KAboutData applicationData()
Returns the KAboutData for the application.
KAboutData & setLicense(KAboutLicense::LicenseKey licenseKey)
Defines the license identifier.
Definition: kaboutdata.cpp:741
QString task() const
The person&#39;s task.
QString spdx() const
Returns the SPDX license expression of this license.
KAboutData & setOtherText(const QString &otherText)
Defines the additional text to show in the about dialog.
Definition: kaboutdata.cpp:775
QString webAddress() const
The website or a relevant link.
void removeFirst()
KAboutComponent & operator=(const KAboutComponent &other)
Assignment operator.
QString otherText() const
Returns a translated, free form text.
QString translate(const char *context, const char *sourceText, const char *disambiguation, int n)
QString host(QUrl::ComponentFormattingOptions options) const const
KAboutData & setDesktopFileName(const QString &desktopFileName)
Sets the base name of the desktop entry for this application.
QString ocsProviderUrl() const
Returns the chosen Open Collaboration Services provider URL.
Definition: kaboutdata.cpp:863
KAboutData & setDisplayName(const QString &displayName)
Defines the displayable component name string.
Definition: kaboutdata.cpp:716
const char * internalBugAddress() const
Definition: kaboutdata.cpp:904
QCommandLineOption addVersionOption()
QList< KAboutPerson > translators() const
Returns a list of translators.
KAboutData & setHomepage(const QString &homepage)
Defines the program homepage.
Definition: kaboutdata.cpp:781
QString desktopFileName() const
KAboutLicense & operator=(const KAboutLicense &other)
Assignment operator.
Definition: kaboutdata.cpp:361
This class is used to store information about a third party component.
Definition: kaboutdata.h:369
QString organizationDomain()
QString join(const QString &separator) const const
QString & remove(int position, int n)
static KAboutData * pluginData(const QString &componentName)
Return the KAboutData for the given plugin identified by componentName.
KAboutData & addAuthor(const QString &name, const QString &task=QString(), const QString &emailAddress=QString(), const QString &webAddress=QString(), const QString &ocsUsername=QString())
Defines an author.
Definition: kaboutdata.cpp:637
int size() const const
KAboutData & setVersion(const QByteArray &version)
Defines the program version string.
Definition: kaboutdata.cpp:729
QString bugAddress() const
Returns the email address or URL for bugs.
KAboutData & setLicenseText(const QString &license)
Defines a license text, which is translated.
Definition: kaboutdata.cpp:667
KAboutData & setOcsProvider(const QString &providerUrl)
Specifies an Open Collaboration Services provider by URL.
Definition: kaboutdata.cpp:723
QList< KAboutPerson > authors() const
Returns a list of authors.
static void registerPluginData(const KAboutData &aboutData)
Register the KAboutData information for a plugin.
KAboutPerson & operator=(const KAboutPerson &other)
Assignment operator.
QVector< V > values(const QMultiHash< K, V > &c)
KAboutData & setCustomAuthorText(const QString &plainText, const QString &richText)
Sets the custom text displayed around the list of authors instead of the default message telling user...
bool customAuthorTextEnabled() const
Returns whether custom text should be displayed around the list of authors.
Definition: kaboutdata.cpp:997
QList< KAboutLicense > licenses() const
Returns a list of licenses.
QString emailAddress() const
The person&#39;s email address.
int count(const T &value) const const
QString applicationVersion()
void append(const T &value)
QString fromUtf8(const char *str, int size)
QVariant property(const char *name) const const
KAboutData & addLicenseTextFile(const QString &file)
Adds a license text by pointing to a file where it resides.
Definition: kaboutdata.cpp:696
KAboutData & addCredit(const QString &name, const QString &task=QString(), const QString &emailAddress=QString(), const QString &webAddress=QString(), const QString &ocsUsername=QString())
Defines a person that deserves credit.
Definition: kaboutdata.cpp:643
QString version() const
The component&#39;s version.
void setUrl(const QString &url, QUrl::ParsingMode parsingMode)
KAboutData & addComponent(const QString &name, const QString &description=QString(), const QString &version=QString(), const QString &webAddress=QString(), KAboutLicense::LicenseKey licenseKey=KAboutLicense::Unknown)
Defines a component that is used by the application.
Definition: kaboutdata.cpp:655
bool isEmpty() const const
QString trimmed() const const
QStringList split(const QString &sep, QString::SplitBehavior behavior, Qt::CaseSensitivity cs) const const
QCommandLineOption addHelpOption()
QString description() const
The component&#39;s description.
QString text() const
Returns the full license text.
QList< KAboutComponent > components() const
Returns a list of components.
bool endsWith(const QString &s, Qt::CaseSensitivity cs) const const
This class is used to store information about a program or plugin.
Definition: kaboutdata.h:534
void setApplicationDescription(const QString &description)
QCoreApplication * instance()
KAboutData & setProductName(const QByteArray &name)
Defines the product name which will be used in the KBugReport dialog.
Definition: kaboutdata.cpp:799
KAboutData & addLicense(KAboutLicense::LicenseKey licenseKey)
Adds a license identifier.
Definition: kaboutdata.cpp:752
KAboutData & setShortDescription(const QString &shortDescription)
Defines a short description of what the program does.
Definition: kaboutdata.cpp:735
bool isSet(const QString &name) const const
virtual bool open(QIODevice::OpenMode mode) override
QString scheme() const const
QVariant programLogo() const
Returns the program logo image.
const char * internalProductName() const
Definition: kaboutdata.cpp:818
LicenseKey
Describes the license of the software.
Definition: kaboutdata.h:194
QList::iterator end()
QString toLower() const const
QList< KAboutPerson > credits() const
Returns a list of persons who contributed.
static void setApplicationData(const KAboutData &aboutData)
Sets the application data for this application.
KeepEmptyParts
KAboutData & setOrganizationDomain(const QByteArray &domain)
Defines the domain of the organization that wrote this application.
Definition: kaboutdata.cpp:793
QVariant fromValue(const T &value)
This class is used to store information about a person or developer.
Definition: kaboutdata.h:61
static KAboutData fromPluginMetaData(const KPluginMetaData &plugin)
Creates a KAboutData from the given plugin metadata.
Definition: kaboutdata.cpp:617
static KAboutPerson fromJSON(const QJsonObject &obj)
Creates a KAboutPerson from a JSON object with the following structure:
Definition: kaboutdata.cpp:95
QString ocsUsername() const
The person&#39;s Open Collaboration Services username.
KAboutData & addLicenseText(const QString &license)
Adds a license text, which is translated.
Definition: kaboutdata.cpp:674
QString customAuthorPlainText() const
Returns the plain text displayed around the list of authors instead of the default message telling us...
Definition: kaboutdata.cpp:987
bool isValid() const const
QString displayName() const
Returns the translated program name.
QByteArray toLatin1() const const
QString productName() const
Returns the application&#39;s product name, which will be used in KBugReport dialog.
KAboutData & unsetCustomAuthorText()
Clears any custom text displayed around the list of authors and falls back to the default message tel...
bool setupCommandLine(QCommandLineParser *parser)
Configures the parser command line parser to provide an authors entry with information about the deve...
NameFormat
Format of the license name.
Definition: kaboutdata.h:215
KAboutData & setLicenseTextFile(const QString &file)
Defines a license text by pointing to a file where it resides.
Definition: kaboutdata.cpp:689
static KAboutLicense byKeyword(const QString &keyword)
Fetch a known license by a keyword/spdx ID.
Definition: kaboutdata.cpp:372
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
static QString aboutTranslationTeam()
Returns a message about the translation team.
Definition: kaboutdata.cpp:957
This class allows easily accessing some standardized values from the JSON metadata that can be embedd...
KAboutPerson(const QString &name=QString(), const QString &task=QString(), const QString &emailAddress=QString(), const QString &webAddress=QString(), const QString &ocsUsername=QString())
Convenience constructor.
Definition: kaboutdata.cpp:47
QString copyrightStatement() const
Returns the copyright statement.
KAboutData & setComponentName(const QString &componentName)
Defines the component name used internally.
Definition: kaboutdata.cpp:710
QString webAddress() const
The home page or a relevant link.
bool addOption(const QCommandLineOption &option)
char * data()
KAboutData & setProgramLogo(const QVariant &image)
Defines the program logo.
Definition: kaboutdata.cpp:857
QString fromLatin1(const char *str, int size)
const char * internalProgramName() const
Definition: kaboutdata.cpp:834
KAboutData & setProgramIconName(const QString &iconName)
Obsolete method.
Definition: kaboutdata.cpp:845
QString version() const
Returns the program&#39;s version.
bool setProperty(const char *name, const QVariant &value)
KAboutData & operator=(const KAboutData &other)
Assignment operator.
Definition: kaboutdata.cpp:601
KAboutData(const QString &componentName, const QString &displayName, const QString &version, const QString &shortDescription, enum KAboutLicense::LicenseKey licenseType, const QString &copyrightStatement=QString(), const QString &otherText=QString(), const QString &homePageAddress=QString(), const QString &bugAddress=QStringLiteral("[email protected]"))
Constructor.
Definition: kaboutdata.cpp:507
QString customAuthorRichText() const
Returns the rich text displayed around the list of authors instead of the default message telling use...
Definition: kaboutdata.cpp:992
KAboutComponent(const QString &name=QString(), const QString &description=QString(), const QString &version=QString(), const QString &webAddress=QString(), enum KAboutLicense::LicenseKey licenseType=KAboutLicense::Unknown)
Convenience constructor.
Definition: kaboutdata.cpp:416
KAboutLicense license() const
The component&#39;s license.
Definition: kaboutdata.cpp:461
QString programIconName() const
Returns the program&#39;s icon name.
Definition: kaboutdata.cpp:840
QString readAll()
QString toString() const const
QString value(const QString &optionName) const const
QString shortDescription() const
Returns a short, translated description.
QString name() const
The person&#39;s name.
QList::iterator begin()
QString applicationName()
VersionRestriction
Whether later versions of the license are allowed.
Definition: kaboutdata.h:224
QString locate(QStandardPaths::StandardLocation type, const QString &fileName, QStandardPaths::LocateOptions options)
QString name() const
The component&#39;s name.
KAboutData & setTranslator(const QString &name, const QString &emailAddress)
Sets the name(s) of the translator(s) of the GUI.
Definition: kaboutdata.cpp:649
QByteArray toUtf8() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Fri Nov 26 2021 23:03:44 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.