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 
68 QString KAboutPerson::name() const
69 {
70  return d->_name;
71 }
72 
73 QString KAboutPerson::task() const
74 {
75  return d->_task;
76 }
77 
78 QString KAboutPerson::emailAddress() const
79 {
80  return d->_emailAddress;
81 }
82 
83 QString KAboutPerson::webAddress() const
84 {
85  return d->_webAddress;
86 }
87 
88 QString KAboutPerson::ocsUsername() const
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) {
145  return QStringLiteral("GPL-2.0");
147  return QStringLiteral("LGPL-2.0");
148  case KAboutLicense::BSDL:
149  return QStringLiteral("BSD-2-Clause");
151  return QStringLiteral("Artistic-1.0");
153  return QStringLiteral("QPL-1.0");
155  return QStringLiteral("GPL-3.0");
157  return QStringLiteral("LGPL-3.0");
159  return QStringLiteral("LGPL-2.1");
161  case KAboutLicense::File:
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 
209 QString KAboutLicense::text() const
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;
226  knownLicense = true;
227  pathToFile = QStringLiteral("GPL_V2");
228  break;
230  knownLicense = true;
231  pathToFile = QStringLiteral("LGPL_V2");
232  break;
233  case KAboutLicense::BSDL:
234  knownLicense = true;
235  pathToFile = QStringLiteral("BSD");
236  break;
238  knownLicense = true;
239  pathToFile = QStringLiteral("ARTISTIC");
240  break;
242  knownLicense = true;
243  pathToFile = QStringLiteral("QPL_V1.0");
244  break;
246  knownLicense = true;
247  pathToFile = QStringLiteral("GPL_V3");
248  break;
250  knownLicense = true;
251  pathToFile = QStringLiteral("LGPL_V3");
252  break;
254  knownLicense = true;
255  pathToFile = QStringLiteral("LGPL_V21");
256  break;
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, QStringLiteral("kf" QT_STRINGIFY(QT_VERSION_MAJOR) "/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 
290 QString KAboutLicense::spdx() const
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) {
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;
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;
329  licenseShort = QCoreApplication::translate("KAboutLicense", "Artistic License", "@item license (short name)");
330  licenseFull = QCoreApplication::translate("KAboutLicense", "Artistic License", "@item license");
331  break;
333  licenseShort = QCoreApplication::translate("KAboutLicense", "QPL v1.0", "@item license (short name)");
334  licenseFull = QCoreApplication::translate("KAboutLicense", "Q Public License", "@item license");
335  break;
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;
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;
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 
367 KAboutLicense::LicenseKey KAboutLicense::key() const
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 
417  const QString &_description,
418  const QString &_version,
419  const QString &_webAddress,
420  enum KAboutLicense::LicenseKey licenseType)
421  : d(new KAboutComponentPrivate)
422 {
423  d->_name = _name;
424  d->_description = _description;
425  d->_version = _version;
426  d->_webAddress = _webAddress;
427  d->_license = KAboutLicense(licenseType, nullptr);
428 }
429 
431  const QString &_description,
432  const QString &_version,
433  const QString &_webAddress,
434  const QString &pathToLicenseFile)
435  : d(new KAboutComponentPrivate)
436 {
437  d->_name = _name;
438  d->_description = _description;
439  d->_version = _version;
440  d->_webAddress = _webAddress;
441  d->_license = KAboutLicense();
442  d->_license.setLicenseFromPath(pathToLicenseFile);
443 }
444 
445 KAboutComponent::KAboutComponent(const KAboutComponent &other) = default;
446 
447 KAboutComponent::~KAboutComponent() = default;
448 
449 QString KAboutComponent::name() const
450 {
451  return d->_name;
452 }
453 
454 QString KAboutComponent::description() const
455 {
456  return d->_description;
457 }
458 
459 QString KAboutComponent::version() const
460 {
461  return d->_version;
462 }
463 
464 QString KAboutComponent::webAddress() const
465 {
466  return d->_webAddress;
467 }
468 
470 {
471  return d->_license;
472 }
473 
475 
476 class KAboutDataPrivate
477 {
478 public:
479  KAboutDataPrivate()
480  : customAuthorTextEnabled(false)
481  {
482  }
483  QString _componentName;
484  QString _displayName;
485  QString _shortDescription;
486  QString _copyrightStatement;
487  QString _otherText;
488  QString _homepageAddress;
489  QList<KAboutPerson> _authorList;
490  QList<KAboutPerson> _creditList;
491  QList<KAboutPerson> _translatorList;
492  QList<KAboutComponent> _componentList;
493  QList<KAboutLicense> _licenseList;
494 #if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 2)
495  QString programIconName;
496 #endif
497  QVariant programLogo;
498  QString customAuthorPlainText, customAuthorRichText;
499  bool customAuthorTextEnabled;
500 
501  QString organizationDomain;
502  QString _ocsProviderUrl;
503  QString desktopFileName;
504 
505  // Everything dr.konqi needs, we store as utf-8, so we
506  // can just give it a pointer, w/o any allocations.
507  QByteArray _internalProgramName;
508  QByteArray _version;
509  QByteArray _bugAddress;
510  QByteArray productName;
511 
512  static QList<KAboutPerson> parseTranslators(const QString &translatorName, const QString &translatorEmail);
513 };
514 
515 KAboutData::KAboutData(const QString &_componentName,
516  const QString &_displayName,
517  const QString &_version,
518  const QString &_shortDescription,
519  enum KAboutLicense::LicenseKey licenseType,
520  const QString &_copyrightStatement,
521  const QString &text,
522  const QString &homePageAddress,
523  const QString &bugAddress)
524  : d(new KAboutDataPrivate)
525 {
526  d->_componentName = _componentName;
527  int p = d->_componentName.indexOf(QLatin1Char('/'));
528  if (p >= 0) {
529  d->_componentName = d->_componentName.mid(p + 1);
530  }
531 
532  d->_displayName = _displayName;
533  if (!d->_displayName.isEmpty()) { // KComponentData("klauncher") gives empty program name
534  d->_internalProgramName = _displayName.toUtf8();
535  }
536  d->_version = _version.toUtf8();
537  d->_shortDescription = _shortDescription;
538  d->_licenseList.append(KAboutLicense(licenseType, this));
539  d->_copyrightStatement = _copyrightStatement;
540  d->_otherText = text;
541  d->_homepageAddress = homePageAddress;
542  d->_bugAddress = bugAddress.toUtf8();
543 
544  QUrl homePageUrl(homePageAddress);
545  if (!homePageUrl.isValid() || homePageUrl.scheme().isEmpty()) {
546  // Default domain if nothing else is better
547  homePageUrl.setUrl(QStringLiteral("https://kde.org/"));
548  }
549 
550  const QChar dotChar(QLatin1Char('.'));
551  QStringList hostComponents = homePageUrl.host().split(dotChar);
552 
553  // Remove leading component unless 2 (or less) components are present
554  if (hostComponents.size() > 2) {
555  hostComponents.removeFirst();
556  }
557 
558  d->organizationDomain = hostComponents.join(dotChar);
559 
560  // KF6: do not set a default desktopFileName value here, but remove this code and leave it empty
561  // see KAboutData::desktopFileName() for details
562 
563  // desktop file name is reverse domain name
564  std::reverse(hostComponents.begin(), hostComponents.end());
565  hostComponents.append(_componentName);
566 
567  d->desktopFileName = hostComponents.join(dotChar);
568 }
569 
570 KAboutData::KAboutData(const QString &_componentName, const QString &_displayName, const QString &_version)
571  : d(new KAboutDataPrivate)
572 {
573  d->_componentName = _componentName;
574  int p = d->_componentName.indexOf(QLatin1Char('/'));
575  if (p >= 0) {
576  d->_componentName = d->_componentName.mid(p + 1);
577  }
578 
579  d->_displayName = _displayName;
580  if (!d->_displayName.isEmpty()) { // KComponentData("klauncher") gives empty program name
581  d->_internalProgramName = _displayName.toUtf8();
582  }
583  d->_version = _version.toUtf8();
584 
585  // match behaviour of other constructors
586  d->_licenseList.append(KAboutLicense(KAboutLicense::Unknown, this));
587  d->_bugAddress = "[email protected]";
588  d->organizationDomain = QStringLiteral("kde.org");
589  // KF6: do not set a default desktopFileName value here, but remove this code and leave it empty
590  // see KAboutData::desktopFileName() for details
591  d->desktopFileName = QLatin1String("org.kde.") + d->_componentName;
592 }
593 
594 KAboutData::~KAboutData() = default;
595 
597  : d(new KAboutDataPrivate)
598 {
599  *d = *other.d;
600  for (KAboutLicense &al : d->_licenseList) {
601  al.d.detach();
602  al.d->_aboutData = this;
603  }
604 }
605 
607 {
608  if (this != &other) {
609  *d = *other.d;
610  for (KAboutLicense &al : d->_licenseList) {
611  al.d.detach();
612  al.d->_aboutData = this;
613  }
614  }
615  return *this;
616 }
617 
618 #if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 65)
620 {
621  KAboutData ret(plugin.pluginId(),
622  plugin.name(),
623  plugin.version(),
624  plugin.description(),
625  KAboutLicense::byKeyword(plugin.license()).key(),
626  plugin.copyrightText(),
627  plugin.extraInformation(),
628  plugin.website());
629 #if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 2)
630  ret.d->programIconName = plugin.iconName();
631 #endif
632  ret.d->_authorList = plugin.authors();
633  ret.d->_translatorList = plugin.translators();
634  ret.d->_creditList = plugin.otherContributors();
635  return ret;
636 }
637 #endif
638 
639 KAboutData &KAboutData::addAuthor(const QString &name, const QString &task, const QString &emailAddress, const QString &webAddress, const QString &ocsUsername)
640 {
641  d->_authorList.append(KAboutPerson(name, task, emailAddress, webAddress, ocsUsername));
642  return *this;
643 }
644 
645 KAboutData &KAboutData::addCredit(const QString &name, const QString &task, const QString &emailAddress, const QString &webAddress, const QString &ocsUsername)
646 {
647  d->_creditList.append(KAboutPerson(name, task, emailAddress, webAddress, ocsUsername));
648  return *this;
649 }
650 
651 KAboutData &KAboutData::setTranslator(const QString &name, const QString &emailAddress)
652 {
653  d->_translatorList = KAboutDataPrivate::parseTranslators(name, emailAddress);
654  return *this;
655 }
656 
658  const QString &description,
659  const QString &version,
660  const QString &webAddress,
661  KAboutLicense::LicenseKey licenseKey)
662 {
663  d->_componentList.append(KAboutComponent(name, description, version, webAddress, licenseKey));
664  return *this;
665 }
666 
667 KAboutData &
668 KAboutData::addComponent(const QString &name, const QString &description, const QString &version, const QString &webAddress, const QString &pathToLicenseFile)
669 {
670  d->_componentList.append(KAboutComponent(name, description, version, webAddress, pathToLicenseFile));
671  return *this;
672 }
673 
675 {
676  d->_licenseList[0] = KAboutLicense(this);
677  d->_licenseList[0].setLicenseFromText(licenseText);
678  return *this;
679 }
680 
682 {
683  // if the default license is unknown, overwrite instead of append
684  KAboutLicense &firstLicense = d->_licenseList[0];
685  KAboutLicense newLicense(this);
686  newLicense.setLicenseFromText(licenseText);
687  if (d->_licenseList.count() == 1 && firstLicense.d->_licenseKey == KAboutLicense::Unknown) {
688  firstLicense = newLicense;
689  } else {
690  d->_licenseList.append(newLicense);
691  }
692 
693  return *this;
694 }
695 
697 {
698  d->_licenseList[0] = KAboutLicense(this);
699  d->_licenseList[0].setLicenseFromPath(pathToFile);
700  return *this;
701 }
702 
704 {
705  // if the default license is unknown, overwrite instead of append
706  KAboutLicense &firstLicense = d->_licenseList[0];
707  KAboutLicense newLicense(this);
708  newLicense.setLicenseFromPath(pathToFile);
709  if (d->_licenseList.count() == 1 && firstLicense.d->_licenseKey == KAboutLicense::Unknown) {
710  firstLicense = newLicense;
711  } else {
712  d->_licenseList.append(newLicense);
713  }
714  return *this;
715 }
716 
718 {
719  d->_componentName = componentName;
720  return *this;
721 }
722 
724 {
725  d->_displayName = _displayName;
726  d->_internalProgramName = _displayName.toUtf8();
727  return *this;
728 }
729 
731 {
732  d->_ocsProviderUrl = _ocsProviderUrl;
733  return *this;
734 }
735 
737 {
738  d->_version = _version;
739  return *this;
740 }
741 
743 {
744  d->_shortDescription = _shortDescription;
745  return *this;
746 }
747 
749 {
750  return setLicense(licenseKey, KAboutLicense::OnlyThisVersion);
751 }
752 
754 {
755  d->_licenseList[0] = KAboutLicense(licenseKey, versionRestriction, this);
756  return *this;
757 }
758 
760 {
761  return addLicense(licenseKey, KAboutLicense::OnlyThisVersion);
762 }
763 
765 {
766  // if the default license is unknown, overwrite instead of append
767  KAboutLicense &firstLicense = d->_licenseList[0];
768  if (d->_licenseList.count() == 1 && firstLicense.d->_licenseKey == KAboutLicense::Unknown) {
769  firstLicense = KAboutLicense(licenseKey, versionRestriction, this);
770  } else {
771  d->_licenseList.append(KAboutLicense(licenseKey, versionRestriction, this));
772  }
773  return *this;
774 }
775 
777 {
778  d->_copyrightStatement = _copyrightStatement;
779  return *this;
780 }
781 
783 {
784  d->_otherText = _otherText;
785  return *this;
786 }
787 
789 {
790  d->_homepageAddress = homepage;
791  return *this;
792 }
793 
795 {
796  d->_bugAddress = _bugAddress;
797  return *this;
798 }
799 
801 {
802  d->organizationDomain = QString::fromLatin1(domain.data());
803  return *this;
804 }
805 
807 {
808  d->productName = _productName;
809  return *this;
810 }
811 
812 QString KAboutData::componentName() const
813 {
814  return d->_componentName;
815 }
816 
817 QString KAboutData::productName() const
818 {
819  if (!d->productName.isEmpty()) {
820  return QString::fromUtf8(d->productName);
821  }
822  return componentName();
823 }
824 
826 {
827  return d->productName.isEmpty() ? nullptr : d->productName.constData();
828 }
829 
830 QString KAboutData::displayName() const
831 {
832  if (!d->_displayName.isEmpty()) {
833  return d->_displayName;
834  }
835  return componentName();
836 }
837 
838 /// @internal
839 /// Return the program name. It is always pre-allocated.
840 /// Needed for KCrash in particular.
842 {
843  return d->_internalProgramName.constData();
844 }
845 
846 #if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 2)
848 {
849  return d->programIconName.isEmpty() ? componentName() : d->programIconName;
850 }
851 
853 {
854  d->programIconName = iconName;
855  return *this;
856 }
857 #endif
858 
859 QVariant KAboutData::programLogo() const
860 {
861  return d->programLogo;
862 }
863 
865 {
866  d->programLogo = image;
867  return *this;
868 }
869 
871 {
872  return d->_ocsProviderUrl;
873 }
874 
875 QString KAboutData::version() const
876 {
877  return QString::fromUtf8(d->_version.data());
878 }
879 
880 /// @internal
881 /// Return the untranslated and uninterpreted (to UTF8) string
882 /// for the version information. Used in particular for KCrash.
883 const char *KAboutData::internalVersion() const
884 {
885  return d->_version.constData();
886 }
887 
888 QString KAboutData::shortDescription() const
889 {
890  return d->_shortDescription;
891 }
892 
893 QString KAboutData::homepage() const
894 {
895  return d->_homepageAddress;
896 }
897 
898 QString KAboutData::bugAddress() const
899 {
900  return QString::fromUtf8(d->_bugAddress.constData());
901 }
902 
904 {
905  return d->organizationDomain;
906 }
907 
908 /// @internal
909 /// Return the untranslated and uninterpreted (to UTF8) string
910 /// for the bug mail address. Used in particular for KCrash.
912 {
913  if (d->_bugAddress.isEmpty()) {
914  return nullptr;
915  }
916  return d->_bugAddress.constData();
917 }
918 
919 QList<KAboutPerson> KAboutData::authors() const
920 {
921  return d->_authorList;
922 }
923 
924 QList<KAboutPerson> KAboutData::credits() const
925 {
926  return d->_creditList;
927 }
928 
929 QList<KAboutPerson> KAboutDataPrivate::parseTranslators(const QString &translatorName, const QString &translatorEmail)
930 {
931  if (translatorName.isEmpty() || translatorName == QLatin1String("Your names")) {
932  return {};
933  }
934 
935  const QStringList nameList(translatorName.split(QLatin1Char(',')));
936 
937  QStringList emailList;
938  if (!translatorEmail.isEmpty() && translatorEmail != QLatin1String("Your emails")) {
939  emailList = translatorEmail.split(QLatin1Char(','), Qt::KeepEmptyParts);
940  }
941 
942  QList<KAboutPerson> personList;
943  personList.reserve(nameList.size());
944 
945  auto eit = emailList.constBegin();
946 
947  for (const QString &name : nameList) {
948  QString email;
949  if (eit != emailList.constEnd()) {
950  email = *eit;
951  ++eit;
952  }
953 
954  personList.append(KAboutPerson(name.trimmed(), email.trimmed(), true));
955  }
956 
957  return personList;
958 }
959 
960 QList<KAboutPerson> KAboutData::translators() const
961 {
962  return d->_translatorList;
963 }
964 
966 {
967  return QCoreApplication::translate("KAboutData",
968  "<p>KDE is translated into many languages thanks to the work "
969  "of the translation teams all over the world.</p>"
970  "<p>For more information on KDE internationalization "
971  "visit <a href=\"https://l10n.kde.org\">https://l10n.kde.org</a></p>",
972  "replace this with information about your translation team");
973 }
974 
975 QString KAboutData::otherText() const
976 {
977  return d->_otherText;
978 }
979 
980 QList<KAboutComponent> KAboutData::components() const
981 {
982  return d->_componentList;
983 }
984 
985 QList<KAboutLicense> KAboutData::licenses() const
986 {
987  return d->_licenseList;
988 }
989 
990 QString KAboutData::copyrightStatement() const
991 {
992  return d->_copyrightStatement;
993 }
994 
996 {
997  return d->customAuthorPlainText;
998 }
999 
1001 {
1002  return d->customAuthorRichText;
1003 }
1004 
1006 {
1007  return d->customAuthorTextEnabled;
1008 }
1009 
1010 KAboutData &KAboutData::setCustomAuthorText(const QString &plainText, const QString &richText)
1011 {
1012  d->customAuthorPlainText = plainText;
1013  d->customAuthorRichText = richText;
1014 
1015  d->customAuthorTextEnabled = true;
1016 
1017  return *this;
1018 }
1019 
1021 {
1022  d->customAuthorPlainText = QString();
1023  d->customAuthorRichText = QString();
1024 
1025  d->customAuthorTextEnabled = false;
1026 
1027  return *this;
1028 }
1029 
1031 {
1032  d->desktopFileName = desktopFileName;
1033 
1034  return *this;
1035 }
1036 
1037 QString KAboutData::desktopFileName() const
1038 {
1039  return d->desktopFileName;
1040  // KF6: switch to this code and adapt API dox
1041 #if 0
1042  // if desktopFileName has been explicitly set, use that value
1043  if (!d->desktopFileName.isEmpty()) {
1044  return d->desktopFileName;
1045  }
1046 
1047  // return a string calculated on-the-fly from the current org domain & component name
1048  const QChar dotChar(QLatin1Char('.'));
1049  QStringList hostComponents = d->organizationDomain.split(dotChar);
1050 
1051  // desktop file name is reverse domain name
1052  std::reverse(hostComponents.begin(), hostComponents.end());
1053  hostComponents.append(componentName());
1054 
1055  return hostComponents.join(dotChar);
1056 #endif
1057 }
1058 
1059 class KAboutDataRegistry
1060 {
1061 public:
1062  KAboutDataRegistry()
1063  : m_appData(nullptr)
1064  {
1065  }
1066  ~KAboutDataRegistry()
1067  {
1068  delete m_appData;
1069 #if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 76)
1070  qDeleteAll(m_pluginData);
1071 #endif
1072  }
1073  KAboutDataRegistry(const KAboutDataRegistry &) = delete;
1074  KAboutDataRegistry &operator=(const KAboutDataRegistry &) = delete;
1075 
1076  KAboutData *m_appData;
1077 #if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 76)
1078  QHash<QString, KAboutData *> m_pluginData;
1079 #endif
1080 };
1081 
1082 Q_GLOBAL_STATIC(KAboutDataRegistry, s_registry)
1083 
1084 namespace
1085 {
1086 void warnIfOutOfSync(const char *aboutDataString, const QString &aboutDataValue, const char *appDataString, const QString &appDataValue)
1087 {
1088  if (aboutDataValue != appDataValue) {
1089  qCWarning(KABOUTDATA) << appDataString << appDataValue << "is out-of-sync with" << aboutDataString << aboutDataValue;
1090  }
1091 }
1092 
1093 }
1094 
1096 {
1098 
1099  KAboutData *aboutData = s_registry->m_appData;
1100 
1101  // not yet existing
1102  if (!aboutData) {
1103  // init from current Q*Application data
1105  // For applicationDisplayName & desktopFileName, which are only properties of QGuiApplication,
1106  // we have to try to get them via the property system, as the static getter methods are
1107  // part of QtGui only. Disadvantage: requires an app instance.
1108  // Either get all or none of the properties & warn about it
1109  if (app) {
1111  aboutData->setVersion(QCoreApplication::applicationVersion().toUtf8());
1112  aboutData->setDisplayName(app->property("applicationDisplayName").toString());
1113  aboutData->setDesktopFileName(app->property("desktopFileName").toString());
1114  } else {
1115  qCWarning(KABOUTDATA) << "Could not initialize the properties of KAboutData::applicationData by the equivalent properties from Q*Application: no "
1116  "app instance (yet) existing.";
1117  }
1118 
1119  s_registry->m_appData = aboutData;
1120  } else {
1121  // check if in-sync with Q*Application metadata, as their setters could have been called
1122  // after the last KAboutData::setApplicationData, with different values
1123  warnIfOutOfSync("KAboutData::applicationData().componentName",
1124  aboutData->componentName(),
1125  "QCoreApplication::applicationName",
1127  warnIfOutOfSync("KAboutData::applicationData().version",
1128  aboutData->version(),
1129  "QCoreApplication::applicationVersion",
1131  warnIfOutOfSync("KAboutData::applicationData().organizationDomain",
1132  aboutData->organizationDomain(),
1133  "QCoreApplication::organizationDomain",
1135  if (app) {
1136  warnIfOutOfSync("KAboutData::applicationData().displayName",
1137  aboutData->displayName(),
1138  "QGuiApplication::applicationDisplayName",
1139  app->property("applicationDisplayName").toString());
1140  warnIfOutOfSync("KAboutData::applicationData().desktopFileName",
1141  aboutData->desktopFileName(),
1142  "QGuiApplication::desktopFileName",
1143  app->property("desktopFileName").toString());
1144  }
1145  }
1146 
1147  return *aboutData;
1148 }
1149 
1151 {
1152  if (s_registry->m_appData) {
1153  *s_registry->m_appData = aboutData;
1154  } else {
1155  s_registry->m_appData = new KAboutData(aboutData);
1156  }
1157 
1158  // For applicationDisplayName & desktopFileName, which are only properties of QGuiApplication,
1159  // we have to try to set them via the property system, as the static getter methods are
1160  // part of QtGui only. Disadvantage: requires an app instance.
1161  // So set either all or none of the properties & warn about it
1163  if (app) {
1164  app->setApplicationVersion(aboutData.version());
1165  app->setApplicationName(aboutData.componentName());
1166  app->setOrganizationDomain(aboutData.organizationDomain());
1167  app->setProperty("applicationDisplayName", aboutData.displayName());
1168  app->setProperty("desktopFileName", aboutData.desktopFileName());
1169  } else {
1170  qCWarning(KABOUTDATA) << "Could not initialize the equivalent properties of Q*Application: no instance (yet) existing.";
1171  }
1172 
1173  // KF6: Rethink the current relation between KAboutData::applicationData and the Q*Application metadata
1174  // Always overwriting the Q*Application metadata here, but not updating back the KAboutData
1175  // in applicationData() is unbalanced and can result in out-of-sync data if the Q*Application
1176  // setters have been called meanwhile
1177  // Options are to remove the overlapping properties of KAboutData for cleancode, or making the
1178  // overlapping properties official shadow properties of their Q*Application countparts, though
1179  // that increases behavioural complexity a little.
1180 }
1181 
1182 #if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 76)
1184 {
1185  auto &data = s_registry->m_pluginData[aboutData.componentName()];
1186  if (data) {
1187  // silently ignore double registration, assuming it's for the same plugin
1188  // all of this is getting deprecated anyways, we just don't want to leak anything
1189  return;
1190  }
1191  data = new KAboutData(aboutData);
1192 }
1193 #endif
1194 
1195 #if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 76)
1197 {
1198  KAboutData *ad = s_registry->m_pluginData.value(componentName);
1199  return ad;
1200 }
1201 #endif
1202 
1203 // only for KCrash (no memory allocation allowed)
1204 const KAboutData *KAboutData::applicationDataPointer()
1205 {
1206  if (s_registry.exists()) {
1207  return s_registry->m_appData;
1208  }
1209  return nullptr;
1210 }
1211 
1213 {
1214  if (!d->_shortDescription.isEmpty()) {
1215  parser->setApplicationDescription(d->_shortDescription);
1216  }
1217 
1218  parser->addHelpOption();
1219 
1221  if (app && !app->applicationVersion().isEmpty()) {
1222  parser->addVersionOption();
1223  }
1224 
1225  return parser->addOption(QCommandLineOption(QStringLiteral("author"), QCoreApplication::translate("KAboutData CLI", "Show author information.")))
1226  && parser->addOption(QCommandLineOption(QStringLiteral("license"), QCoreApplication::translate("KAboutData CLI", "Show license information.")))
1227  && parser->addOption(QCommandLineOption(QStringLiteral("desktopfile"),
1228  QCoreApplication::translate("KAboutData CLI", "The base file name of the desktop entry for this application."),
1229  QCoreApplication::translate("KAboutData CLI", "file name")));
1230 }
1231 
1233 {
1234  bool foundArgument = false;
1235  if (parser->isSet(QStringLiteral("author"))) {
1236  foundArgument = true;
1237  if (d->_authorList.isEmpty()) {
1238  printf("%s\n",
1239  qPrintable(QCoreApplication::translate("KAboutData CLI", "This application was written by somebody who wants to remain anonymous.")));
1240  } else {
1241  printf("%s\n", qPrintable(QCoreApplication::translate("KAboutData CLI", "%1 was written by:").arg(qAppName())));
1242  for (const KAboutPerson &person : std::as_const(d->_authorList)) {
1243  QString authorData = QLatin1String(" ") + person.name();
1244  if (!person.emailAddress().isEmpty()) {
1245  authorData.append(QLatin1String(" <") + person.emailAddress() + QLatin1Char('>'));
1246  }
1247  printf("%s\n", qPrintable(authorData));
1248  }
1249  }
1250  if (!customAuthorTextEnabled()) {
1251  if (bugAddress() == QLatin1String("[email protected]")) {
1252  printf("%s\n", qPrintable(QCoreApplication::translate("KAboutData CLI", "Please use https://bugs.kde.org to report bugs.")));
1253  } else if (!bugAddress().isEmpty()) {
1254  printf("%s\n", qPrintable(QCoreApplication::translate("KAboutData CLI", "Please report bugs to %1.").arg(bugAddress())));
1255  }
1256  } else {
1257  printf("%s\n", qPrintable(customAuthorPlainText()));
1258  }
1259  } else if (parser->isSet(QStringLiteral("license"))) {
1260  foundArgument = true;
1261  for (const KAboutLicense &license : std::as_const(d->_licenseList)) {
1262  printf("%s\n", qPrintable(license.text()));
1263  }
1264  }
1265 
1266  const QString desktopFileName = parser->value(QStringLiteral("desktopfile"));
1267  if (!desktopFileName.isEmpty()) {
1268  d->desktopFileName = desktopFileName;
1269  }
1270 
1271  if (foundArgument) {
1272  ::exit(EXIT_SUCCESS);
1273  }
1274 }
1275 
1276 template<class T>
1277 QVariantList listToVariant(const QList<T> &values)
1278 {
1279  QVariantList ret;
1280  ret.reserve(values.count());
1281  for (const auto &value : values) {
1282  ret << QVariant::fromValue(value);
1283  }
1284  return ret;
1285 }
1286 
1287 QVariantList KAboutData::licensesVariant() const
1288 {
1289  return listToVariant(d->_licenseList);
1290 }
1291 
1292 QVariantList KAboutData::authorsVariant() const
1293 {
1294  return listToVariant(d->_authorList);
1295 }
1296 
1297 QVariantList KAboutData::creditsVariant() const
1298 {
1299  return listToVariant(d->_creditList);
1300 }
1301 
1302 QVariantList KAboutData::translatorsVariant() const
1303 {
1304  return listToVariant(d->_translatorList);
1305 }
1306 
1307 QVariantList KAboutData::componentsVariant() const
1308 {
1309  return listToVariant(d->_componentList);
1310 }
void append(const T &value)
QString organizationDomain() const
Returns the domain name of the organization that wrote this application.
Definition: kaboutdata.cpp:903
const char * internalVersion() const
Definition: kaboutdata.cpp:883
bool endsWith(const QString &s, Qt::CaseSensitivity cs) const const
NameFormat
Format of the license name.
Definition: kaboutdata.h:215
KAboutComponent & operator=(const KAboutComponent &other)
Assignment operator.
QString fromUtf8(const char *str, int size)
KAboutData & setLicenseTextFile(const QString &file)
Defines a license text by pointing to a file where it resides.
Definition: kaboutdata.cpp:696
KAboutData & addLicense(KAboutLicense::LicenseKey licenseKey)
Adds a license identifier.
Definition: kaboutdata.cpp:759
QVariant fromValue(const T &value)
void setApplicationDescription(const QString &description)
QString translate(const char *context, const char *sourceText, const char *disambiguation, int n)
KAboutData & addLicenseText(const QString &license)
Adds a license text, which is translated.
Definition: kaboutdata.cpp:681
QString scheme() const const
@ File
License set from text file, see setLicenseFromPath()
Definition: kaboutdata.h:196
KAboutPerson & operator=(const KAboutPerson &other)
Assignment operator.
static void setApplicationData(const KAboutData &aboutData)
Sets the application data for this application.
QStringList split(const QString &sep, QString::SplitBehavior behavior, Qt::CaseSensitivity cs) const const
QString ocsProviderUrl() const
Returns the chosen Open Collaboration Services provider URL.
Definition: kaboutdata.cpp:870
KAboutData & unsetCustomAuthorText()
Clears any custom text displayed around the list of authors and falls back to the default message tel...
QString trimmed() const const
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:515
LicenseKey
Describes the license of the software; for more information see: https://spdx.org/licenses/.
Definition: kaboutdata.h:194
QByteArray toLatin1() const const
QList::const_iterator constBegin() const const
static KAboutLicense byKeyword(const QString &keyword)
Fetch a known license by a keyword/spdx ID.
Definition: kaboutdata.cpp:372
bool setupCommandLine(QCommandLineParser *parser)
Configures the parser command line parser to provide an authors entry with information about the deve...
KAboutData & setOrganizationDomain(const QByteArray &domain)
Defines the domain of the organization that wrote this application.
Definition: kaboutdata.cpp:800
const char * internalProgramName() const
Definition: kaboutdata.cpp:841
QString locate(QStandardPaths::StandardLocation type, const QString &fileName, QStandardPaths::LocateOptions options)
bool customAuthorTextEnabled() const
Returns whether custom text should be displayed around the list of authors.
QString customAuthorPlainText() const
Returns the plain text displayed around the list of authors instead of the default message telling us...
Definition: kaboutdata.cpp:995
static QString aboutTranslationTeam()
Returns a message about the translation team.
Definition: kaboutdata.cpp:965
Q_GLOBAL_STATIC(Internal::StaticControl, s_instance) class ControlPrivate
void reserve(int alloc)
bool isValid() const const
KAboutData & setProgramLogo(const QVariant &image)
Defines the program logo.
Definition: kaboutdata.cpp:864
KAboutData & setProgramIconName(const QString &iconName)
Obsolete method.
Definition: kaboutdata.cpp:852
This class is used to store information about a third party component.
Definition: kaboutdata.h:369
QString customAuthorRichText() const
Returns the rich text displayed around the list of authors instead of the default message telling use...
int size() const const
@ Artistic
Artistic, see https://spdx.org/licenses/Artistic-2.0.html.
Definition: kaboutdata.h:203
const char * internalBugAddress() const
Definition: kaboutdata.cpp:911
KAboutData & setComponentName(const QString &componentName)
Defines the component name used internally.
Definition: kaboutdata.cpp:717
const char * internalProductName() const
Definition: kaboutdata.cpp:825
void processCommandLine(QCommandLineParser *parser)
Reads the processed parser and sees if any of the arguments are the ones set up from setupCommandLine...
QCommandLineOption addVersionOption()
KeepEmptyParts
KAboutData & operator=(const KAboutData &other)
Assignment operator.
Definition: kaboutdata.cpp:606
bool isEmpty() const const
void removeFirst()
QByteArray toUtf8() const const
KAboutData & setBugAddress(const QByteArray &bugAddress)
Defines the address where bug reports should be sent.
Definition: kaboutdata.cpp:794
QCoreApplication * instance()
QString value(const QString &optionName) const const
KAboutData & setTranslator(const QString &name, const QString &emailAddress)
Sets the name(s) of the translator(s) of the GUI.
Definition: kaboutdata.cpp:651
static KAboutData applicationData()
Returns the KAboutData for the application.
KAboutData & setDesktopFileName(const QString &desktopFileName)
Sets the base name of the desktop entry for this application.
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
KAboutData & setHomepage(const QString &homepage)
Defines the program homepage.
Definition: kaboutdata.cpp:788
QString join(const QString &separator) const const
bool isSet(const QString &name) const const
This class is used to store information about a person or developer.
Definition: kaboutdata.h:61
@ QPL_V1_0
QPL_V1_0, this has the same value as LicenseKey::QPL, see https://spdx.org/licenses/QPL-1....
Definition: kaboutdata.h:205
QString & remove(int position, int n)
@ Custom
Custom license.
Definition: kaboutdata.h:195
KAboutData & setCopyrightStatement(const QString &copyrightStatement)
Defines the copyright statement to show when displaying the license.
Definition: kaboutdata.cpp:776
KAboutData & setDisplayName(const QString &displayName)
Defines the displayable component name string.
Definition: kaboutdata.cpp:723
KAboutData & setLicense(KAboutLicense::LicenseKey licenseKey)
Defines the license identifier.
Definition: kaboutdata.cpp:748
bool setProperty(const char *name, const QVariant &value)
QString toLower() const const
QString host(QUrl::ComponentFormattingOptions options) const const
@ GPL_V2
GPL_V2, this has the same value as LicenseKey::GPL, see https://spdx.org/licenses/GPL-2....
Definition: kaboutdata.h:199
static void registerPluginData(const KAboutData &aboutData)
Register the KAboutData information for a plugin.
void setUrl(const QString &url, QUrl::ParsingMode parsingMode)
QList::const_iterator constEnd() const const
@ LGPL_V2_1
LGPL_V2_1.
Definition: kaboutdata.h:208
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
unsigned int version()
Returns a numerical version number of KCoreAddons at run-time in the form 0xMMNNPP (MM = major,...
Definition: kcoreaddons.cpp:18
KAboutLicense & operator=(const KAboutLicense &other)
Assignment operator.
Definition: kaboutdata.cpp:361
static KAboutData * pluginData(const QString &componentName)
Return the KAboutData for the given plugin identified by componentName.
QString fromLatin1(const char *str, int size)
QString name(StandardShortcut id)
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:645
@ LGPL_V2
LGPL_V2, this has the same value as LicenseKey::LGPL, see https://spdx.org/licenses/LGPL-2....
Definition: kaboutdata.h:201
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:639
@ LGPL_V3
LGPL_V3, see https://spdx.org/licenses/LGPL-3.0-only.html.
Definition: kaboutdata.h:207
VersionRestriction
Whether later versions of the license are allowed.
Definition: kaboutdata.h:224
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:657
QList::iterator begin()
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
KAboutData & setOtherText(const QString &otherText)
Defines the additional text to show in the about dialog.
Definition: kaboutdata.cpp:782
bool addOption(const QCommandLineOption &option)
static KAboutPerson fromJSON(const QJsonObject &obj)
Creates a KAboutPerson from a JSON object with the following structure:
Definition: kaboutdata.cpp:95
KAboutLicense license() const
The component's license.
Definition: kaboutdata.cpp:469
KAboutData & setVersion(const QByteArray &version)
Defines the program version string.
Definition: kaboutdata.cpp:736
@ BSDL
BSDL, see https://spdx.org/licenses/BSD-2-Clause.html.
Definition: kaboutdata.h:202
QList::iterator end()
@ GPL_V3
GPL_V3, see https://spdx.org/licenses/GPL-3.0.html.
Definition: kaboutdata.h:206
KAboutData & setProductName(const QByteArray &name)
Defines the product name which will be used in the KBugReport dialog.
Definition: kaboutdata.cpp:806
QCommandLineOption addHelpOption()
KAboutData & setShortDescription(const QString &shortDescription)
Defines a short description of what the program does.
Definition: kaboutdata.cpp:742
This class is used to store information about a license.
Definition: kaboutdata.h:180
@ Unknown
Unknown license.
Definition: kaboutdata.h:197
QVector< V > values(const QMultiHash< K, V > &c)
QString & append(QChar ch)
Holds information needed by the "About" box and other classes.
Definition: kaboutdata.h:534
KAboutData & addLicenseTextFile(const QString &file)
Adds a license text by pointing to a file where it resides.
Definition: kaboutdata.cpp:703
char * data()
QString programIconName() const
Returns the program's icon name.
Definition: kaboutdata.cpp:847
QString toString() const const
QVariant property(const char *name) const const
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...
KAboutData & setLicenseText(const QString &license)
Defines a license text, which is translated.
Definition: kaboutdata.cpp:674
KAboutData & setOcsProvider(const QString &providerUrl)
Specifies an Open Collaboration Services provider by URL.
Definition: kaboutdata.cpp:730
static KAboutData fromPluginMetaData(const KPluginMetaData &plugin)
Creates a KAboutData from the given plugin metadata.
Definition: kaboutdata.cpp:619
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Fri Aug 19 2022 04:05:20 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.