KCoreAddons

kaboutdata.h
1 /*
2  This file is part of the KDE Libraries
3 
4  SPDX-FileCopyrightText: 2000 Espen Sand <[email protected]>
5  SPDX-FileCopyrightText: 2008 Friedrich W. H. Kossebau <[email protected]>
6  SPDX-FileCopyrightText: 2010 Teo Mrnjavac <[email protected]>
7  SPDX-FileCopyrightText: 2013 David Faure <[email protected]>
8  SPDX-FileCopyrightText: 2017 Harald Sitter <si[email protected]>
9 
10  SPDX-License-Identifier: LGPL-2.0-or-later
11 */
12 
13 #ifndef KABOUTDATA_H
14 #define KABOUTDATA_H
15 
16 #include <kcoreaddons_export.h>
17 #include <QString>
18 #include <QSharedDataPointer>
19 #include <QVariant>
20 #include <qcontainerfwd.h>
21 
22 class QCommandLineParser;
23 class QJsonObject;
24 class KAboutData;
25 class KPluginMetaData;
26 namespace KCrash
27 {
28 Q_DECL_IMPORT void defaultCrashHandler(int sig);
29 }
30 
55 class KCOREADDONS_EXPORT KAboutPerson
56 {
57  Q_GADGET
58  Q_PROPERTY(QString name READ name CONSTANT)
59  Q_PROPERTY(QString task READ task CONSTANT)
60  Q_PROPERTY(QString emailAddress READ emailAddress CONSTANT)
61  Q_PROPERTY(QString webAddress READ webAddress CONSTANT)
62  Q_PROPERTY(QString ocsUsername READ ocsUsername CONSTANT)
63  friend class KAboutData;
64 public:
80  explicit KAboutPerson(const QString &name = QString(),
81  const QString &task = QString(),
82  const QString &emailAddress = QString(),
83  const QString &webAddress = QString(),
84  const QString &ocsUsername = QString());
85 
90  KAboutPerson(const KAboutPerson &other);
91 
92  ~KAboutPerson();
93 
98  KAboutPerson &operator=(const KAboutPerson &other);
99 
105  QString name() const;
106 
112  QString task() const;
113 
119  QString emailAddress() const;
120 
126  QString webAddress() const;
127 
133  QString ocsUsername() const;
134 
150  static KAboutPerson fromJSON(const QJsonObject &obj);
151 
152 private:
156  explicit KAboutPerson(const QString &name, const QString &email, bool disambiguation);
157 
158  class Private;
159  Private *const d;
160 };
161 
172 class KCOREADDONS_EXPORT KAboutLicense
173 {
174  Q_GADGET
175  Q_PROPERTY(QString name READ name CONSTANT)
176  Q_PROPERTY(QString text READ text CONSTANT)
177  Q_PROPERTY(KAboutLicense::LicenseKey key READ key CONSTANT)
178  Q_PROPERTY(QString spdx READ spdx CONSTANT)
179  friend class KAboutData;
180 public:
181 
185  enum LicenseKey {
186  Custom = -2,
187  File = -1,
188  Unknown = 0,
189  GPL = 1,
190  GPL_V2 = 1,
191  LGPL = 2,
192  LGPL_V2 = 2,
193  BSDL = 3,
194  Artistic = 4,
195  QPL = 5,
196  QPL_V1_0 = 5,
197  GPL_V3 = 6,
198  LGPL_V3 = 7,
199  LGPL_V2_1 = 8
200  };
201  Q_ENUM(LicenseKey)
202 
203 
206  enum NameFormat {
207  ShortName,
208  FullName
209  };
210  Q_ENUM(NameFormat)
211 
212 
216  OnlyThisVersion,
217  OrLaterVersions
218  };
219  Q_ENUM(VersionRestriction)
220 
221 
224  explicit KAboutLicense();
225 
230  KAboutLicense(const KAboutLicense &other);
231 
232  ~KAboutLicense();
233 
238  KAboutLicense &operator=(const KAboutLicense &other);
239 
247  QString text() const;
248 
256  QString name(KAboutLicense::NameFormat formatName = ShortName) const;
257 
263  KAboutLicense::LicenseKey key() const;
264 
280  QString spdx() const;
281 
303  static KAboutLicense byKeyword(const QString &keyword);
304 
305 private:
309  explicit KAboutLicense(enum KAboutLicense::LicenseKey licenseType,
310  enum KAboutLicense::VersionRestriction versionRestriction,
311  const KAboutData *aboutData);
315  explicit KAboutLicense(enum KAboutLicense::LicenseKey licenseType, const KAboutData *aboutData);
319  explicit KAboutLicense(const KAboutData *aboutData);
323  void setLicenseFromPath(const QString &pathToFile);
327  void setLicenseFromText(const QString &licenseText);
328 
329  class Private;
331 };
332 
394 class KCOREADDONS_EXPORT KAboutData
395 {
396  Q_GADGET
397  Q_PROPERTY(QString displayName READ displayName CONSTANT)
398  Q_PROPERTY(QString productName READ productName CONSTANT)
399  Q_PROPERTY(QString componentName READ componentName CONSTANT)
400  Q_PROPERTY(QVariant programLogo READ programLogo CONSTANT)
401  Q_PROPERTY(QString shortDescription READ shortDescription CONSTANT)
402  Q_PROPERTY(QString homepage READ homepage CONSTANT)
403  Q_PROPERTY(QString bugAddress READ bugAddress CONSTANT)
404  Q_PROPERTY(QString version READ version CONSTANT)
405  Q_PROPERTY(QString otherText READ otherText CONSTANT)
406  Q_PROPERTY(QVariantList authors READ authorsVariant CONSTANT) //constant in practice as addAuthor is not exposed to Q_GADGET
407  Q_PROPERTY(QVariantList credits READ creditsVariant CONSTANT)
408  Q_PROPERTY(QVariantList translators READ translatorsVariant CONSTANT)
409  Q_PROPERTY(QVariantList licenses READ licensesVariant CONSTANT)
410  Q_PROPERTY(QString copyrightStatement READ copyrightStatement CONSTANT)
411  Q_PROPERTY(QString desktopFileName READ desktopFileName CONSTANT)
412 public:
413 
426  static KAboutData applicationData();
427 
444  static void setApplicationData(const KAboutData &aboutData);
445 
452  static void registerPluginData(const KAboutData &aboutData);
453 
457  static KAboutData *pluginData(const QString &componentName);
458 
459 #if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 65)
460 
468  KCOREADDONS_DEPRECATED_VERSION(5, 65, "See API docs")
469  static KAboutData fromPluginMetaData(const KPluginMetaData &plugin);
470 #endif
471 
472 public:
521  // KF6: remove constructor that includes catalogName, and put default
522  // values back in for shortDescription and licenseType
523  KAboutData(const QString &componentName,
524  const QString &displayName,
525  const QString &version,
526  const QString &shortDescription,
527  enum KAboutLicense::LicenseKey licenseType,
528  const QString &copyrightStatement = QString(),
529  const QString &otherText = QString(),
530  const QString &homePageAddress = QString(),
531  const QString &bugAddress = QStringLiteral("[email protected]")
532  );
533 
552  explicit KAboutData(const QString &componentName = {},
553  const QString &displayName = {},
554  const QString &version = {}
555  );
556 
561  KAboutData(const KAboutData &other);
562 
567  KAboutData &operator=(const KAboutData &other);
568 
569  ~KAboutData();
570 
595  KAboutData &addAuthor(const QString &name,
596  const QString &task = QString(),
597  const QString &emailAddress = QString(),
598  const QString &webAddress = QString(),
599  const QString &ocsUsername = QString());
600 
624  KAboutData &addCredit(const QString &name,
625  const QString &task = QString(),
626  const QString &emailAddress = QString(),
627  const QString &webAddress = QString(),
628  const QString &ocsUsername = QString());
629 
651  KAboutData &setTranslator(const QString &name,
652  const QString &emailAddress);
653 
664  KAboutData &setLicenseText(const QString &license);
665 
680  KAboutData &addLicenseText(const QString &license);
681 
688  KAboutData &setLicenseTextFile(const QString &file);
689 
700  KAboutData &addLicenseTextFile(const QString &file);
701 
707  KAboutData &setComponentName(const QString &componentName);
708 
716  KAboutData &setDisplayName(const QString &displayName);
717 
718 #if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 2)
719 
731  KCOREADDONS_DEPRECATED_VERSION(5, 2, "Use QApplication::setWindowIcon")
732  KAboutData &setProgramIconName(const QString &iconName);
733 #endif
734 
749  KAboutData &setProgramLogo(const QVariant &image);
750 
763  KAboutData &setOcsProvider(const QString &providerUrl);
764 
770  KAboutData &setVersion(const QByteArray &version);
771 
779  KAboutData &setShortDescription(const QString &shortDescription);
780 
787  KAboutData &setLicense(KAboutLicense::LicenseKey licenseKey);
788 
799  KAboutData &setLicense(KAboutLicense::LicenseKey licenseKey,
800  KAboutLicense::VersionRestriction versionRestriction);
801 
811  KAboutData &addLicense(KAboutLicense::LicenseKey licenseKey);
812 
826  KAboutData &addLicense(KAboutLicense::LicenseKey licenseKey,
827  KAboutLicense::VersionRestriction versionRestriction);
828 
836  KAboutData &setCopyrightStatement(const QString &copyrightStatement);
837 
845  KAboutData &setOtherText(const QString &otherText);
846 
854  KAboutData &setHomepage(const QString &homepage);
855 
862  KAboutData &setBugAddress(const QByteArray &bugAddress);
863 
894  KAboutData &setOrganizationDomain(const QByteArray &domain);
895 
904  KAboutData &setProductName(const QByteArray &name);
905 
910  QString componentName() const;
911 
919  QString productName() const;
920 
925  QString displayName() const;
926 
932  QString organizationDomain() const;
933 
938  const char *internalProgramName() const;
939 
940 // Not using KCOREADDONS_ENABLE_DEPRECATED_SINCE because KXmlGui and KConfigWidgets need this, for compat
941 #if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 2)
942 
950  KCOREADDONS_DEPRECATED_VERSION(5, 2, "Use QApplication::windowIcon")
951  QString programIconName() const;
952 #endif
953 
963  QVariant programLogo() const;
964 
969  QString ocsProviderUrl() const;
970 
975  QString version() const;
976 
981  const char *internalVersion() const;
982 
988  QString shortDescription() const;
989 
995  QString homepage() const;
996 
1001  QString bugAddress() const;
1002 
1007  const char *internalBugAddress() const;
1008 
1013  QList<KAboutPerson> authors() const;
1014 
1019  QList<KAboutPerson> credits() const;
1020 
1025  QList<KAboutPerson> translators() const;
1026 
1031  static QString aboutTranslationTeam();
1032 
1037  QString otherText() const;
1038 
1044  QList<KAboutLicense> licenses() const;
1045 
1050  QString copyrightStatement() const;
1051 
1059  QString customAuthorPlainText() const;
1060 
1068  QString customAuthorRichText() const;
1069 
1077  bool customAuthorTextEnabled() const;
1078 
1090  KAboutData &setCustomAuthorText(const QString &plainText,
1091  const QString &richText);
1092 
1098  KAboutData &unsetCustomAuthorText();
1099 
1114  bool setupCommandLine(QCommandLineParser *parser);
1115 
1122  void processCommandLine(QCommandLineParser *parser);
1123 
1152  KAboutData &setDesktopFileName(const QString &desktopFileName);
1153 
1159  QString desktopFileName() const;
1160 
1161 private:
1162  QVariantList licensesVariant() const;
1163  QVariantList authorsVariant() const;
1164  QVariantList creditsVariant() const;
1165  QVariantList translatorsVariant() const;
1166 
1167  friend void KCrash::defaultCrashHandler(int sig);
1168  static const KAboutData *applicationDataPointer();
1169 
1170  class Private;
1171  Private *const d;
1172 };
1173 
1174 Q_DECLARE_METATYPE(KAboutData)
1175 Q_DECLARE_METATYPE(KAboutLicense)
1176 Q_DECLARE_METATYPE(KAboutPerson)
1177 
1178 #endif
1179 
This class is used to store information about a license.
Definition: kaboutdata.h:172
KCRASH_EXPORT void defaultCrashHandler(int signal)
This class is used to store information about a program or plugin.
Definition: kaboutdata.h:394
LicenseKey
Describes the license of the software.
Definition: kaboutdata.h:185
This class is used to store information about a person or developer.
Definition: kaboutdata.h:55
NameFormat
Format of the license name.
Definition: kaboutdata.h:206
This class allows easily accessing some standardized values from the JSON metadata that can be embedd...
KAboutData & operator=(const KAboutData &other)
Assignment operator.
Definition: kaboutdata.cpp:584
VersionRestriction
Whether later versions of the license are allowed.
Definition: kaboutdata.h:215
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Aug 14 2020 23:01:51 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.