File indexing completed on 2024-04-28 03:53:52
0001 /* 0002 This file is part of the KDE Libraries 0003 0004 SPDX-FileCopyrightText: 2000 Espen Sand <espen@kde.org> 0005 SPDX-FileCopyrightText: 2008 Friedrich W. H. Kossebau <kossebau@kde.org> 0006 SPDX-FileCopyrightText: 2010 Teo Mrnjavac <teo@kde.org> 0007 SPDX-FileCopyrightText: 2013 David Faure <faure+bluesystems@kde.org> 0008 SPDX-FileCopyrightText: 2017 Harald Sitter <sitter@kde.org> 0009 SPDX-FileCopyrightText: 2021 Julius Künzel <jk.kdedev@smartlab.uber.space> 0010 0011 SPDX-License-Identifier: LGPL-2.0-or-later 0012 */ 0013 0014 #ifndef KABOUTDATA_H 0015 #define KABOUTDATA_H 0016 0017 #include <QSharedDataPointer> 0018 #include <QString> 0019 #include <QUrl> 0020 #include <QVariant> 0021 #include <kcoreaddons_export.h> 0022 #include <memory> 0023 #include <qcontainerfwd.h> 0024 0025 class QCommandLineParser; 0026 class QJsonObject; 0027 class KAboutData; 0028 namespace KCrash 0029 { 0030 #ifdef KCOREADDONS_STATIC 0031 void defaultCrashHandler(int sig); 0032 #else 0033 Q_DECL_IMPORT void defaultCrashHandler(int sig); 0034 #endif 0035 } 0036 0037 /** 0038 * @class KAboutPerson kaboutdata.h KAboutPerson 0039 * 0040 * This class is used to store information about a person or developer. 0041 * It can store the person's name, a task, an email address and a 0042 * link to a home page. This class is intended for use in the 0043 * KAboutData class, but it can be used elsewhere as well. 0044 * Normally you should at least define the person's name. 0045 * Creating a KAboutPerson object by yourself is relatively useless, 0046 * but the KAboutData methods KAboutData::authors() and KAboutData::credits() 0047 * return lists of KAboutPerson data objects which you can examine. 0048 * 0049 * Example usage within a main(), retrieving the list of people involved 0050 * with a program and re-using data from one of them: 0051 * 0052 * @code 0053 * KAboutData about("khello", i18n("KHello"), "0.1", 0054 * i18n("A KDE version of Hello, world!"), 0055 * KAboutLicense::LGPL, 0056 * i18n("Copyright (C) 2014 Developer")); 0057 * 0058 * about.addAuthor(i18n("Joe Developer"), i18n("developer"), "joe@host.com", 0); 0059 * QList<KAboutPerson> people = about.authors(); 0060 * about.addCredit(people[0].name(), people[0].task()); 0061 * @endcode 0062 */ 0063 class KCOREADDONS_EXPORT KAboutPerson 0064 { 0065 Q_GADGET 0066 Q_PROPERTY(QString name READ name CONSTANT) 0067 Q_PROPERTY(QString task READ task CONSTANT) 0068 Q_PROPERTY(QString emailAddress READ emailAddress CONSTANT) 0069 Q_PROPERTY(QString webAddress READ webAddress CONSTANT) 0070 Q_PROPERTY(QUrl avatarUrl READ avatarUrl CONSTANT) 0071 friend class KAboutData; 0072 friend class KAboutDataPrivate; 0073 0074 public: 0075 /** 0076 * Convenience constructor 0077 * 0078 * @param name The name of the person. 0079 * 0080 * @param task The task of this person. 0081 * 0082 * @param emailAddress The email address of the person. 0083 * 0084 * @param webAddress Home page of the person. 0085 * 0086 * @param avatarUrl URL to the avatar of the person, since 6.0 0087 * 0088 * @p name default argument @since 5.53 0089 */ 0090 explicit KAboutPerson(const QString &name = QString(), 0091 const QString &task = QString(), 0092 const QString &emailAddress = QString(), 0093 const QString &webAddress = QString(), 0094 const QUrl &avatarUrl = QUrl()); 0095 0096 /** 0097 * Copy constructor. Performs a deep copy. 0098 * @param other object to copy 0099 */ 0100 KAboutPerson(const KAboutPerson &other); 0101 0102 ~KAboutPerson(); 0103 0104 /** 0105 * Assignment operator. Performs a deep copy. 0106 * @param other object to copy 0107 */ 0108 KAboutPerson &operator=(const KAboutPerson &other); 0109 0110 /** 0111 * The person's name 0112 * @return the person's name (can be QString(), if it has been 0113 * constructed with an empty name) 0114 */ 0115 QString name() const; 0116 0117 /** 0118 * The person's task 0119 * @return the person's task (can be QString(), if it has been 0120 * constructed with an empty task) 0121 */ 0122 QString task() const; 0123 0124 /** 0125 * The person's email address 0126 * @return the person's email address (can be QString(), if it has been 0127 * constructed with an empty email) 0128 */ 0129 QString emailAddress() const; 0130 0131 /** 0132 * The home page or a relevant link 0133 * @return the persons home page (can be QString(), if it has been 0134 * constructed with an empty home page) 0135 */ 0136 QString webAddress() const; 0137 0138 /** 0139 * @return an URL pointing to the user's avatar 0140 * @since 6.0 0141 */ 0142 QUrl avatarUrl() const; 0143 0144 /** 0145 * Creates a @c KAboutPerson from a JSON object with the following structure: 0146 * 0147 * Key | Accessor 0148 * -----------| ---------------------------- 0149 * Name | name() 0150 * Email | emailAddress() 0151 * Task | task() 0152 * Website | webAddress() 0153 * AvatarUrl | avatarUrl() 0154 * 0155 * The @c Name and @c Task key are translatable (by using e.g. a "Task[de_DE]" key) 0156 * The AvatarUrl exists since version 6.0 0157 * 0158 * @since 5.18 0159 */ 0160 static KAboutPerson fromJSON(const QJsonObject &obj); 0161 0162 private: 0163 /** 0164 * @internal Used by KAboutData to construct translator data. 0165 */ 0166 KCOREADDONS_NO_EXPORT explicit KAboutPerson(const QString &name, const QString &email, bool disambiguation); 0167 0168 private: 0169 QSharedDataPointer<class KAboutPersonPrivate> d; 0170 }; 0171 0172 Q_DECLARE_TYPEINFO(KAboutPerson, Q_RELOCATABLE_TYPE); 0173 0174 /** 0175 * @class KAboutLicense kaboutdata.h KAboutLicense 0176 * 0177 * This class is used to store information about a license. 0178 * The license can be one of some predefined, one given as text or one 0179 * that can be loaded from a file. This class is used in the KAboutData class. 0180 * Explicitly creating a KAboutLicense object is not possible. 0181 * If the license is wanted for a KDE component having KAboutData object, 0182 * use KAboutData::licenses() to get the licenses for that component. 0183 * If the license is for a non-code resource and given by a keyword 0184 * (e.g. in .desktop files), try using KAboutLicense::byKeyword(). 0185 */ 0186 class KCOREADDONS_EXPORT KAboutLicense 0187 { 0188 Q_GADGET 0189 Q_PROPERTY(QString name READ name CONSTANT) 0190 Q_PROPERTY(QString text READ text CONSTANT) 0191 Q_PROPERTY(KAboutLicense::LicenseKey key READ key CONSTANT) 0192 Q_PROPERTY(QString spdx READ spdx CONSTANT) 0193 friend class KAboutData; 0194 friend class KAboutComponent; 0195 0196 public: 0197 /** 0198 * Describes the license of the software; for more information see: https://spdx.org/licenses/ 0199 */ 0200 enum LicenseKey { 0201 Custom = -2, ///< Custom license 0202 File = -1, ///< License set from text file, see setLicenseFromPath() 0203 Unknown = 0, ///< Unknown license 0204 GPL = 1, ///< GPL 0205 GPL_V2 = GPL, ///< GPL_V2, this has the same value as LicenseKey::GPL, see https://spdx.org/licenses/GPL-2.0.html 0206 LGPL = 2, ///< LGPL 0207 LGPL_V2 = LGPL, ///< LGPL_V2, this has the same value as LicenseKey::LGPL, see https://spdx.org/licenses/LGPL-2.0-only.html 0208 BSDL = 3, ///< BSDL, see https://spdx.org/licenses/BSD-2-Clause.html 0209 Artistic = 4, ///< Artistic, see https://spdx.org/licenses/Artistic-2.0.html 0210 GPL_V3 = 5, ///< GPL_V3, see https://spdx.org/licenses/GPL-3.0.html 0211 LGPL_V3 = 6, ///< LGPL_V3, see https://spdx.org/licenses/LGPL-3.0-only.html 0212 LGPL_V2_1 = 7, ///< LGPL_V2_1 @since 5.25, see https://spdx.org/licenses/LGPL-2.1-only.html 0213 MIT = 8, ///< MIT @since 6.0, see https://spdx.org/licenses/MIT.html 0214 }; 0215 Q_ENUM(LicenseKey) 0216 0217 /** 0218 * Format of the license name. 0219 */ 0220 enum NameFormat { 0221 ShortName, 0222 FullName, 0223 }; 0224 Q_ENUM(NameFormat) 0225 0226 /** 0227 * Whether later versions of the license are allowed. 0228 */ 0229 enum VersionRestriction { 0230 OnlyThisVersion, 0231 OrLaterVersions, 0232 }; 0233 Q_ENUM(VersionRestriction) 0234 0235 /** 0236 * @since 5.53 0237 */ 0238 explicit KAboutLicense(); 0239 0240 /** 0241 * Copy constructor. Performs a deep copy. 0242 * @param other object to copy 0243 */ 0244 KAboutLicense(const KAboutLicense &other); 0245 0246 ~KAboutLicense(); 0247 0248 /** 0249 * Assignment operator. Performs a deep copy. 0250 * @param other object to copy 0251 */ 0252 KAboutLicense &operator=(const KAboutLicense &other); 0253 0254 /** 0255 * Returns the full license text. If the licenseType argument of the 0256 * constructor has been used, any text defined by setLicenseText is ignored, 0257 * and the standard text for the chosen license will be returned. 0258 * 0259 * @return The license text. 0260 */ 0261 QString text() const; 0262 0263 /** 0264 * Returns the license name. 0265 * 0266 * Default argument @since 5.53 0267 * 0268 * @return The license name as a string. 0269 */ 0270 QString name(KAboutLicense::NameFormat formatName = ShortName) const; 0271 0272 /** 0273 * Returns the license key. 0274 * 0275 * @return The license key as element of KAboutLicense::LicenseKey enum. 0276 */ 0277 KAboutLicense::LicenseKey key() const; 0278 0279 /** 0280 * Returns the SPDX license expression of this license. 0281 * If the underlying license cannot be expressed as a SPDX expression a null string is returned. 0282 * 0283 * @note SPDX expression are expansive constructs. If you parse the return value, do it in a 0284 * SPDX specification compliant manner by splitting on whitespaces to discard unwanted 0285 * information or by using a complete SPDX license expression parser. 0286 * @note SPDX identifiers are case-insensitive. Do not use case-sensitive checks on the return 0287 * value. 0288 * @see https://spdx.org/licenses 0289 * @return SPDX license expression or QString() if the license has no identifier. Compliant 0290 * with SPDX 2.1. 0291 * 0292 * @since 5.37 0293 */ 0294 QString spdx() const; 0295 0296 /** 0297 * Fetch a known license by a keyword/spdx ID 0298 * 0299 * Frequently the license data is provided by a terse keyword-like string, 0300 * e.g. by a field in a .desktop file. Using this method, an application 0301 * can get hold of a proper KAboutLicense object, providing that the 0302 * license is one of the several known to KDE, and use it to present 0303 * more human-readable information to the user. 0304 * 0305 * Keywords are matched by stripping all whitespace and lowercasing. 0306 * The known keywords correspond to the KAboutLicense::LicenseKey enumeration, 0307 * e.g. any of "LGPLV3", "LGPLv3", "LGPL v3" would match KAboutLicense::LGPL_V3. 0308 * If there is no match for the keyword, a valid license object is still 0309 * returned, with its name and text informing about a custom license, 0310 * and its key equal to KAboutLicense::Custom. 0311 * 0312 * @param keyword The license keyword. 0313 * @return The license object. 0314 * 0315 * @see KAboutLicense::LicenseKey 0316 */ 0317 static KAboutLicense byKeyword(const QString &keyword); 0318 0319 private: 0320 /** 0321 * @internal Used by KAboutData to construct a predefined license. 0322 */ 0323 KCOREADDONS_NO_EXPORT explicit KAboutLicense(enum KAboutLicense::LicenseKey licenseType, 0324 enum KAboutLicense::VersionRestriction versionRestriction, 0325 const KAboutData *aboutData); 0326 /** 0327 * @internal Used by KAboutData to construct a predefined license. 0328 */ 0329 KCOREADDONS_NO_EXPORT explicit KAboutLicense(enum KAboutLicense::LicenseKey licenseType, const KAboutData *aboutData); 0330 /** 0331 * @internal Used by KAboutData to construct a KAboutLicense 0332 */ 0333 KCOREADDONS_NO_EXPORT explicit KAboutLicense(const KAboutData *aboutData); 0334 /** 0335 * @internal Used by KAboutData to construct license by given text 0336 */ 0337 KCOREADDONS_NO_EXPORT void setLicenseFromPath(const QString &pathToFile); 0338 /** 0339 * @internal Used by KAboutData to construct license by given text 0340 */ 0341 KCOREADDONS_NO_EXPORT void setLicenseFromText(const QString &licenseText); 0342 0343 private: 0344 QSharedDataPointer<class KAboutLicensePrivate> d; 0345 }; 0346 0347 Q_DECLARE_TYPEINFO(KAboutLicense, Q_RELOCATABLE_TYPE); 0348 0349 /** 0350 * @class KAboutComponent kaboutdata.h KAboutComponent 0351 * 0352 * This class is used to store information about a third party component. 0353 * It can store the component's name, a description, a link to a website 0354 * and the license of the libary. This class is intended for use in the 0355 * KAboutData class, but it can be used elsewhere as well. 0356 * Normally you should at least define the libary's name. 0357 * Creating a KAboutComponent object by yourself is relatively useless, 0358 * but the KAboutData method KAboutData::libaries() return lists of 0359 * KAboutComponent data objects which you can examine. 0360 * 0361 * Example usage within a main(), retrieving the list of components used 0362 * by a program and re-using data from one of them: 0363 * 0364 * @code 0365 * KAboutData about("khello", i18n("KHello"), "0.1", 0366 * i18n("A KDE version of Hello, world!"), 0367 * KAboutLicense::LGPL, 0368 * i18n("Copyright (C) 2014 Developer")); 0369 * 0370 * about.addComponent(i18n("Awsom Lib"), 0371 * i18n("Does awesom stuff. Copyright (C) 2014"), 0372 * i18n("1.02.3"), 0373 * "http://example.com", 0374 * KAboutLicense::LGPL); 0375 * QList<KAboutComponent> components = about.components(); 0376 * @endcode 0377 * 0378 * @since 5.84 0379 */ 0380 class KCOREADDONS_EXPORT KAboutComponent 0381 { 0382 Q_GADGET 0383 Q_PROPERTY(QString name READ name CONSTANT) 0384 Q_PROPERTY(QString description READ description CONSTANT) 0385 Q_PROPERTY(QString webAddress READ webAddress CONSTANT) 0386 Q_PROPERTY(KAboutLicense licenses READ license CONSTANT) 0387 Q_PROPERTY(QString version READ version CONSTANT) 0388 friend class KAboutData; 0389 friend class KAboutDataPrivate; 0390 0391 public: 0392 /** 0393 * Convenience constructor 0394 * 0395 * @param name The name of the component. 0396 * 0397 * @param description The description of this component. 0398 * 0399 * @param version The version of this component. 0400 * 0401 * @param webAddress Website of the component. 0402 * 0403 * @param licenseType The license identifier of the component. 0404 * 0405 * @p name default argument 0406 */ 0407 explicit KAboutComponent(const QString &name = QString(), 0408 const QString &description = QString(), 0409 const QString &version = QString(), 0410 const QString &webAddress = QString(), 0411 enum KAboutLicense::LicenseKey licenseType = KAboutLicense::Unknown); 0412 0413 /** 0414 * Convenience constructor 0415 * 0416 * @param name The name of the component. 0417 * 0418 * @param description The description of this component. 0419 * 0420 * @param version The version of this component. 0421 * 0422 * @param webAddress Website of the component. 0423 * 0424 * @param pathToLicenseFile Path to the file in the local filesystem containing the license text. 0425 * The file format has to be plain text in an encoding compatible to the local. 0426 * 0427 * @p name default argument 0428 */ 0429 explicit KAboutComponent(const QString &name, 0430 const QString &description, 0431 const QString &version, 0432 const QString &webAddress, 0433 const QString &pathToLicenseFile); 0434 0435 /** 0436 * Copy constructor. Performs a deep copy. 0437 * @param other object to copy 0438 */ 0439 KAboutComponent(const KAboutComponent &other); 0440 0441 ~KAboutComponent(); 0442 0443 /** 0444 * Assignment operator. Performs a deep copy. 0445 * @param other object to copy 0446 */ 0447 KAboutComponent &operator=(const KAboutComponent &other); 0448 0449 /** 0450 * The component's name 0451 * @return the component's name (can be QString(), if it has been 0452 * constructed with an empty name) 0453 */ 0454 QString name() const; 0455 0456 /** 0457 * The component's description 0458 * @return the component's description (can be empty) 0459 */ 0460 QString description() const; 0461 0462 /** 0463 * The component's version 0464 * @return the component's task (can be empty) 0465 */ 0466 QString version() const; 0467 0468 /** 0469 * The website or a relevant link 0470 * @return the component's website (can be empty) 0471 */ 0472 QString webAddress() const; 0473 0474 /** 0475 * The component's license 0476 * @return the component's KAboutLicense 0477 */ 0478 KAboutLicense license() const; 0479 0480 private: 0481 QSharedDataPointer<class KAboutComponentPrivate> d; 0482 }; 0483 0484 Q_DECLARE_TYPEINFO(KAboutComponent, Q_RELOCATABLE_TYPE); 0485 0486 /** 0487 * @class KAboutData kaboutdata.h KAboutData 0488 * 0489 * This class is used to store information about a program or plugin. 0490 * It can store such values as version number, program name, home page, address 0491 * for bug reporting, multiple authors and contributors 0492 * (using KAboutPerson), license and copyright information. 0493 * 0494 * Currently, the values set here are shown by the "About" box 0495 * (see KAboutDialog), used by the bug report dialog (see KBugReport), 0496 * and by the help shown on command line (see KAboutData::setupCommandLine()). 0497 * 0498 * Porting Notes: Since KDE Frameworks 5.0, the translation catalog mechanism 0499 * must be provided by your translation framework to load the correct catalog 0500 * instead (eg: KLocalizedString::setApplicationDomain() for KI18n, or 0501 * QCoreApplication::installTranslator() for Qt's translation system). This 0502 * applies to the old setCatalogName() and catalogName() members. But see also 0503 * K4AboutData in kde4support as a compatibility class. 0504 * 0505 * Example: 0506 * Setting the metadata of an application using KAboutData in code also relying 0507 * on the KDE Framework modules KI18n and KDBusAddons: 0508 * @code 0509 * // create QApplication instance 0510 * QApplication app(argc, argv); 0511 * // setup translation string domain for the i18n calls 0512 * KLocalizedString::setApplicationDomain("foo"); 0513 * // create a KAboutData object to use for setting the application metadata 0514 * KAboutData aboutData("foo", i18n("Foo"), "0.1", 0515 * i18n("To Foo or not To Foo"), 0516 * KAboutLicense::LGPL, 0517 * i18n("Copyright 2017 Bar Foundation"), QString(), 0518 * "https://www.foo-the-app.net"); 0519 * // overwrite default-generated values of organizationDomain & desktopFileName 0520 * aboutData.setOrganizationDomain("barfoundation.org"); 0521 * aboutData.setDesktopFileName("org.barfoundation.foo"); 0522 * 0523 * // set the application metadata 0524 * KAboutData::setApplicationData(aboutData); 0525 * // in GUI apps set the window icon manually, not covered by KAboutData 0526 * // needed for environments where the icon name is not extracted from 0527 * // the information in the application's desktop file 0528 * QApplication::setWindowIcon(QIcon::fromTheme(QStringLiteral("foo"))); 0529 * 0530 * // integrate with commandline argument handling 0531 * QCommandLineParser parser; 0532 * aboutData.setupCommandLine(&parser); 0533 * // setup of app specific commandline args 0534 * [...] 0535 * parser.process(app); 0536 * aboutData.processCommandLine(&parser); 0537 * 0538 * // with the application metadata set, register to the D-Bus session 0539 * KDBusService programDBusService(KDBusService::Multiple | KDBusService::NoExitOnFailure); 0540 * @endcode 0541 * 0542 * @short Holds information needed by the "About" box and other 0543 * classes. 0544 * @author Espen Sand (espen@kde.org), David Faure (faure@kde.org) 0545 * 0546 */ 0547 class KCOREADDONS_EXPORT KAboutData 0548 { 0549 Q_GADGET 0550 Q_PROPERTY(QString displayName READ displayName CONSTANT) 0551 Q_PROPERTY(QString productName READ productName CONSTANT) 0552 Q_PROPERTY(QString componentName READ componentName CONSTANT) 0553 Q_PROPERTY(QVariant programLogo READ programLogo CONSTANT) 0554 Q_PROPERTY(QString shortDescription READ shortDescription CONSTANT) 0555 Q_PROPERTY(QString homepage READ homepage CONSTANT) 0556 Q_PROPERTY(QString bugAddress READ bugAddress CONSTANT) 0557 Q_PROPERTY(QString version READ version CONSTANT) 0558 Q_PROPERTY(QString otherText READ otherText CONSTANT) 0559 Q_PROPERTY(QList<KAboutPerson> authors READ authors CONSTANT) // constant in practice as addAuthor is not exposed to Q_GADGET 0560 Q_PROPERTY(QList<KAboutPerson> credits READ credits CONSTANT) 0561 Q_PROPERTY(QList<KAboutPerson> translators READ translators CONSTANT) 0562 Q_PROPERTY(QList<KAboutComponent> components READ components CONSTANT) 0563 Q_PROPERTY(QList<KAboutLicense> licenses READ licenses CONSTANT) 0564 Q_PROPERTY(QString copyrightStatement READ copyrightStatement CONSTANT) 0565 Q_PROPERTY(QString desktopFileName READ desktopFileName CONSTANT) 0566 public: 0567 /** 0568 * Returns the KAboutData for the application. 0569 * 0570 * This contains information such as authors, license, etc., 0571 * provided that setApplicationData has been called before. 0572 * If not called before, the returned KAboutData will be initialized from the 0573 * equivalent properties of QCoreApplication (and its subclasses), 0574 * if an instance of that already exists. 0575 * For the list of such properties see setApplicationData 0576 * (before 5.22: limited to QCoreApplication::applicationName). 0577 * @see setApplicationData 0578 */ 0579 static KAboutData applicationData(); 0580 0581 /** 0582 * Sets the application data for this application. 0583 * 0584 * In addition to changing the result of applicationData(), this initializes 0585 * the equivalent properties of QCoreApplication (and its subclasses) with 0586 * information from @p aboutData, if an instance of that already exists. 0587 * Those properties are: 0588 <ul> 0589 <li>QCoreApplication::applicationName</li> 0590 <li>QCoreApplication::applicationVersion</li> 0591 <li>QCoreApplication::organizationDomain</li> 0592 <li>QGuiApplication::applicationDisplayName</li> 0593 <li>QGuiApplication::desktopFileName (since 5.16)</li> 0594 </ul> 0595 * @see applicationData 0596 */ 0597 static void setApplicationData(const KAboutData &aboutData); 0598 0599 public: 0600 /** 0601 * Constructor. 0602 * 0603 * Porting Note: The @p catalogName parameter present in KDE4 was 0604 * deprecated and removed. See also K4AboutData 0605 * in kde4support if this feature is needed for compatibility purposes, or 0606 * consider using componentName() instead. 0607 * 0608 * @param componentName The program name or plugin name used internally. 0609 * Example: QStringLiteral("kwrite"). This should never be translated. 0610 * 0611 * @param displayName A displayable name for the program or plugin. This string 0612 * should be translated. Example: i18n("KWrite") 0613 * 0614 * @param version The component version string. Example: QStringLiteral("1.0"). 0615 * 0616 * @param shortDescription A short description of what the component does. 0617 * This string should be translated. 0618 * Example: i18n("A simple text editor.") 0619 * 0620 * @param licenseType The license identifier. Use setLicenseText or 0621 setLicenseTextFile if you use a license not predefined here. 0622 * 0623 * @param copyrightStatement A copyright statement, that can look like this: 0624 * i18n("Copyright (C) 1999-2000 Name"). The string specified here is 0625 * taken verbatim; the author information from addAuthor is not used. 0626 * 0627 * @param otherText Some free form text, that can contain any kind of 0628 * information. The text can contain newlines. This string 0629 * should be translated. 0630 * 0631 * @param homePageAddress The URL to the component's homepage, including 0632 * URL scheme. "http://some.domain" is correct, "some.domain" is 0633 * not. Since KDE Frameworks 5.17, https and other valid URL schemes 0634 * are also valid. See also the note below. 0635 * 0636 * @param bugAddress The bug report address string, an email address or a URL. 0637 * This defaults to the kde.org bug system. 0638 * 0639 * @note The @p homePageAddress argument is used to derive a default organization 0640 * domain for the application (which is used to register on the session D-Bus, 0641 * locate the appropriate desktop file, etc.), by taking the host name and dropping 0642 * the first component, unless there are less than three (e.g. "www.kde.org" -> "kde.org"). 0643 * Use both setOrganizationDomain(const QByteArray&) and setDesktopFileName() if their default values 0644 * do not have proper values. 0645 * 0646 * @see setOrganizationDomain(const QByteArray&), setDesktopFileName(const QString&) 0647 */ 0648 // KF6: remove constructor that includes catalogName, and put default 0649 // values back in for shortDescription and licenseType 0650 KAboutData(const QString &componentName, 0651 const QString &displayName, 0652 const QString &version, 0653 const QString &shortDescription, 0654 enum KAboutLicense::LicenseKey licenseType, 0655 const QString ©rightStatement = QString(), 0656 const QString &otherText = QString(), 0657 const QString &homePageAddress = QString(), 0658 const QString &bugAddress = QStringLiteral("submit@bugs.kde.org")); 0659 0660 /** 0661 * Constructor. 0662 * 0663 * @param componentName The program name or plugin name used internally. 0664 * Example: "kwrite". 0665 * 0666 * @param displayName A displayable name for the program or plugin. This string 0667 * should be translated. Example: i18n("KWrite") 0668 * 0669 * @param version The component version string. 0670 * 0671 * Sets the property desktopFileName to "org.kde."+componentName and 0672 * the property organizationDomain to "kde.org". 0673 * 0674 * Default arguments @since 5.53 0675 * 0676 * @see setOrganizationDomain(const QByteArray&), setDesktopFileName(const QString&) 0677 */ 0678 explicit KAboutData(const QString &componentName = {}, const QString &displayName = {}, const QString &version = {}); 0679 0680 /** 0681 * Copy constructor. Performs a deep copy. 0682 * @param other object to copy 0683 */ 0684 KAboutData(const KAboutData &other); 0685 0686 /** 0687 * Assignment operator. Performs a deep copy. 0688 * @param other object to copy 0689 */ 0690 KAboutData &operator=(const KAboutData &other); 0691 0692 ~KAboutData(); 0693 0694 /** 0695 * Defines an author. 0696 * 0697 * You can call this function as many times as you need. Each entry is 0698 * appended to a list. The person in the first entry is assumed to be 0699 * the leader of the project. 0700 * 0701 * @param name The developer's name. It should be translated. 0702 * 0703 * @param task What the person is responsible for. This text can contain 0704 * newlines. It should be translated. 0705 * Can be left empty. 0706 * 0707 * @param emailAddress An Email address where the person can be reached. 0708 * Can be left empty. 0709 * 0710 * @param webAddress The person's homepage or a relevant link. 0711 * Start the address with "http://". "http://some.domain" is 0712 * correct, "some.domain" is not. Can be left empty. 0713 * 0714 * @param avatarUrl URL to the avatar of the person 0715 */ 0716 KAboutData &addAuthor(const QString &name, 0717 const QString &task = QString(), 0718 const QString &emailAddress = QString(), 0719 const QString &webAddress = QString(), 0720 const QUrl &avatarUrl = QUrl()); 0721 0722 /** 0723 * @overload 0724 * @since 6.0 0725 */ 0726 KAboutData &addAuthor(const QString &name, const QString &task, const QString &emailAddress, const QString &webAddress, const QString &kdeStoreUsername) 0727 { 0728 return addAuthor(name, task, emailAddress, webAddress, QUrl(QStringLiteral("https://store.kde.org/avatar/") + kdeStoreUsername)); 0729 } 0730 0731 /** 0732 * Defines a person that deserves credit. 0733 * 0734 * You can call this function as many times as you need. Each entry 0735 * is appended to a list. 0736 * 0737 * @param name The person's name. It should be translated. 0738 * 0739 * @param task What the person has done to deserve the honor. The 0740 * text can contain newlines. It should be translated. 0741 * Can be left empty. 0742 * 0743 * @param emailAddress An email address when the person can be reached. 0744 * Can be left empty. 0745 * 0746 * @param webAddress The person's homepage or a relevant link. 0747 * Start the address with "http://". "http://some.domain" is 0748 * is correct, "some.domain" is not. Can be left empty. 0749 * 0750 * @param avatarUrl URL to the avatar of the person 0751 */ 0752 KAboutData &addCredit(const QString &name, 0753 const QString &task = QString(), 0754 const QString &emailAddress = QString(), 0755 const QString &webAddress = QString(), 0756 const QUrl &avatarUrl = QUrl()); 0757 0758 /** 0759 * @overload 0760 * @since 6.0 0761 */ 0762 KAboutData &addCredit(const QString &name, const QString &task, const QString &emailAddress, const QString &webAddress, const QString &kdeStoreUsername) 0763 { 0764 return addCredit(name, task, emailAddress, webAddress, QUrl(QStringLiteral("https://store.kde.org/avatar/") + kdeStoreUsername)); 0765 } 0766 0767 /** 0768 * @brief Sets the name(s) of the translator(s) of the GUI. 0769 * 0770 * The canonical use with the ki18n framework is: 0771 * 0772 * \code 0773 * setTranslator(i18nc("NAME OF TRANSLATORS", "Your names"), 0774 * i18nc("EMAIL OF TRANSLATORS", "Your emails")); 0775 * \endcode 0776 * 0777 * If you are using a KMainWindow this is done for you automatically. 0778 * 0779 * The name and emailAddress are treated as lists separated with ",". 0780 * 0781 * If the strings are empty or "Your names"/"Your emails" 0782 * respectively they will be ignored. 0783 * 0784 * @param name the name(s) of the translator(s) 0785 * @param emailAddress the email address(es) of the translator(s) 0786 * @see KAboutTranslator 0787 */ 0788 KAboutData &setTranslator(const QString &name, const QString &emailAddress); 0789 0790 /** 0791 * Defines a component that is used by the application. 0792 * 0793 * You can call this function as many times as you need. Each entry is 0794 * appended to a list. 0795 * 0796 * @param name The component's name. It should be translated. 0797 * 0798 * @param description Short description of the component and maybe 0799 * copyright info. This text can contain newlines. It should 0800 * be translated. Can be left empty. 0801 * 0802 * @param version The version of the component. Can be left empty. 0803 * 0804 * @param webAddress The component's homepage or a relevant link. 0805 * Start the address with "http://". "http://some.domain" is 0806 * correct, "some.domain" is not. Can be left empty. 0807 * 0808 * @param licenseKey The component's license identifier. Can be left empty (i.e. KAboutLicense::Unknown) 0809 * 0810 * @since 5.84 0811 */ 0812 KAboutData &addComponent(const QString &name, 0813 const QString &description = QString(), 0814 const QString &version = QString(), 0815 const QString &webAddress = QString(), 0816 KAboutLicense::LicenseKey licenseKey = KAboutLicense::Unknown); 0817 0818 /** 0819 * Defines a component that is used by the application with a custom license text file. 0820 * 0821 * You can call this function as many times as you need. Each entry is 0822 * appended to a list. 0823 * 0824 * @param name The component's name. It should be translated. 0825 * 0826 * @param description Short description of the component and maybe 0827 * copyright info. This text can contain newlines. It should 0828 * be translated. Can be left empty. 0829 * 0830 * @param version The version of the component. Can be left empty. 0831 * 0832 * @param webAddress The component's homepage or a relevant link. 0833 * Start the address with "http://". "http://some.domain" is 0834 * correct, "some.domain" is not. Can be left empty. 0835 * 0836 * @param pathToLicenseFile Path to the file in the local filesystem containing the license text. 0837 * The file format has to be plain text in an encoding compatible to the local. 0838 * 0839 * @since 5.84 0840 */ 0841 KAboutData & 0842 addComponent(const QString &name, const QString &description, const QString &version, const QString &webAddress, const QString &pathToLicenseFile); 0843 0844 /** 0845 * Defines a license text, which is translated. 0846 * 0847 * Example: 0848 * \code 0849 * setLicenseText( i18n("This is my license") ); 0850 * \endcode 0851 * 0852 * @param license The license text. 0853 */ 0854 KAboutData &setLicenseText(const QString &license); 0855 0856 /** 0857 * Adds a license text, which is translated. 0858 * 0859 * If there is only one unknown license set, e.g. by using the default 0860 * parameter in the constructor, that one is replaced. 0861 * 0862 * Example: 0863 * \code 0864 * addLicenseText( i18n("This is my license") ); 0865 * \endcode 0866 * 0867 * @param license The license text. 0868 * @see setLicenseText, addLicense, addLicenseTextFile 0869 */ 0870 KAboutData &addLicenseText(const QString &license); 0871 0872 /** 0873 * Defines a license text by pointing to a file where it resides. 0874 * The file format has to be plain text in an encoding compatible to the locale. 0875 * 0876 * @param file Path to the file in the local filesystem containing the license text. 0877 */ 0878 KAboutData &setLicenseTextFile(const QString &file); 0879 0880 /** 0881 * Adds a license text by pointing to a file where it resides. 0882 * The file format has to be plain text in an encoding compatible to the locale. 0883 * 0884 * If there is only one unknown license set, e.g. by using the default 0885 * parameter in the constructor, that one is replaced. 0886 * 0887 * @param file Path to the file in the local filesystem containing the license text. 0888 * @see addLicenseText, addLicense, setLicenseTextFile 0889 */ 0890 KAboutData &addLicenseTextFile(const QString &file); 0891 0892 /** 0893 * Defines the component name used internally. 0894 * 0895 * @param componentName The application or plugin name. Example: "kate". 0896 */ 0897 KAboutData &setComponentName(const QString &componentName); 0898 0899 /** 0900 * Defines the displayable component name string. 0901 * 0902 * @param displayName The display name. This string should be 0903 * translated. 0904 * Example: i18n("Advanced Text Editor"). 0905 */ 0906 KAboutData &setDisplayName(const QString &displayName); 0907 0908 /** 0909 * Defines the program logo. 0910 * 0911 * Use this if you need to have an application logo 0912 * in AboutData other than the application icon. 0913 * 0914 * Because KAboutData is a core class it cannot use QImage/QPixmap/QIcon directly, 0915 * so this is a QVariant that should contain a QImage/QPixmap/QIcon. 0916 * 0917 * QIcon should be preferred, to be able to properly handle HiDPI scaling. 0918 * If a QIcon is provided, it will be used at a typical size of 48x48. 0919 * 0920 * @param image logo image. 0921 * @see programLogo() 0922 */ 0923 KAboutData &setProgramLogo(const QVariant &image); 0924 0925 /** 0926 * Defines the program version string. 0927 * 0928 * @param version The program version. 0929 */ 0930 KAboutData &setVersion(const QByteArray &version); 0931 0932 /** 0933 * Defines a short description of what the program does. 0934 * 0935 * @param shortDescription The program description. This string should 0936 * be translated. Example: i18n("An advanced text 0937 * editor with syntax highlighting support."). 0938 */ 0939 KAboutData &setShortDescription(const QString &shortDescription); 0940 0941 /** 0942 * Defines the license identifier. 0943 * 0944 * @param licenseKey The license identifier. 0945 * @see addLicenseText, setLicenseText, setLicenseTextFile 0946 */ 0947 KAboutData &setLicense(KAboutLicense::LicenseKey licenseKey); 0948 0949 /** 0950 * Defines the license identifier. 0951 * 0952 * @param licenseKey The license identifier. 0953 * @param versionRestriction Whether later versions of the license are also allowed. 0954 * e.g. licensed under "GPL 2.0 or at your option later versions" would be OrLaterVersions. 0955 * @see addLicenseText, setLicenseText, setLicenseTextFile 0956 * 0957 * @since 5.37 0958 */ 0959 KAboutData &setLicense(KAboutLicense::LicenseKey licenseKey, KAboutLicense::VersionRestriction versionRestriction); 0960 0961 /** 0962 * Adds a license identifier. 0963 * 0964 * If there is only one unknown license set, e.g. by using the default 0965 * parameter in the constructor, that one is replaced. 0966 * 0967 * @param licenseKey The license identifier. 0968 * @see setLicenseText, addLicenseText, addLicenseTextFile 0969 */ 0970 KAboutData &addLicense(KAboutLicense::LicenseKey licenseKey); 0971 0972 /** 0973 * Adds a license identifier. 0974 * 0975 * If there is only one unknown license set, e.g. by using the default 0976 * parameter in the constructor, that one is replaced. 0977 * 0978 * @param licenseKey The license identifier. 0979 * @param versionRestriction Whether later versions of the license are also allowed. 0980 * e.g. licensed under "GPL 2.0 or at your option later versions" would be OrLaterVersions. 0981 * @see setLicenseText, addLicenseText, addLicenseTextFile 0982 * 0983 * @since 5.37 0984 */ 0985 KAboutData &addLicense(KAboutLicense::LicenseKey licenseKey, KAboutLicense::VersionRestriction versionRestriction); 0986 0987 /** 0988 * Defines the copyright statement to show when displaying the license. 0989 * 0990 * @param copyrightStatement A copyright statement, that can look like 0991 * this: i18n("Copyright (C) 1999-2000 Name"). The string specified here is 0992 * taken verbatim; the author information from addAuthor is not used. 0993 */ 0994 KAboutData &setCopyrightStatement(const QString ©rightStatement); 0995 0996 /** 0997 * Defines the additional text to show in the about dialog. 0998 * 0999 * @param otherText Some free form text, that can contain any kind of 1000 * information. The text can contain newlines. This string 1001 * should be translated. 1002 */ 1003 KAboutData &setOtherText(const QString &otherText); 1004 1005 /** 1006 * Defines the program homepage. 1007 * 1008 * @param homepage The program homepage string. 1009 * Start the address with "http://". "http://kate.kde.org" 1010 * is correct but "kate.kde.org" is not. 1011 */ 1012 KAboutData &setHomepage(const QString &homepage); 1013 1014 /** 1015 * Defines the address where bug reports should be sent. 1016 * 1017 * @param bugAddress The bug report email address or URL. 1018 * This defaults to the kde.org bug system. 1019 */ 1020 KAboutData &setBugAddress(const QByteArray &bugAddress); 1021 1022 /** 1023 * Defines the domain of the organization that wrote this application. 1024 * The domain is set to kde.org by default, or the domain of the homePageAddress constructor argument, 1025 * if set. 1026 * 1027 * Make sure to call setOrganizationDomain(const QByteArray&) if your product 1028 * is not developed inside the KDE community. 1029 * 1030 * Used e.g. for the registration to D-Bus done by KDBusService 1031 * from the KDE Frameworks KDBusAddons module. 1032 * 1033 * Calling this method has no effect on the value of the desktopFileName property. 1034 * 1035 * @note If your program should work as a D-Bus activatable service, the base name 1036 * of the D-Bus service description file or of the desktop file you install must match 1037 * the D-Bus "well-known name" for which the program will register. 1038 * For example, KDBusService will use a name created from the reversed organization domain 1039 * with the component name attached, so for an organization domain "bar.org" and a 1040 * component name "foo" the name of an installed D-Bus service file needs to be 1041 * "org.bar.foo.service" or the name of the installed desktop file "org.bar.foo.desktop" 1042 * (and the desktopFileName property accordingly set to "org.bar.foo"). 1043 * 1044 * @param domain the domain name, for instance kde.org, koffice.org, etc. 1045 * 1046 * @see setDesktopFileName(const QString&) 1047 */ 1048 KAboutData &setOrganizationDomain(const QByteArray &domain); 1049 1050 /** 1051 * Defines the product name which will be used in the KBugReport dialog. 1052 * By default it's the componentName, but you can overwrite it here to provide 1053 * support for special components e.g. in the form 'product/component', 1054 * such as 'kontact/summary'. 1055 * 1056 * @param name The name of product 1057 */ 1058 KAboutData &setProductName(const QByteArray &name); 1059 1060 /** 1061 * Returns the application's internal name. 1062 * @return the internal program name. 1063 */ 1064 QString componentName() const; 1065 1066 /** 1067 * Returns the application's product name, which will be used in KBugReport 1068 * dialog. By default it returns componentName(), otherwise the one which is set 1069 * with setProductName() 1070 * 1071 * @return the product name. 1072 */ 1073 QString productName() const; 1074 1075 /** 1076 * @internal 1077 * Provided for use by KCrash 1078 */ 1079 const char *internalProductName() const; 1080 1081 /** 1082 * Returns the translated program name. 1083 * @return the program name (translated). 1084 */ 1085 QString displayName() const; 1086 1087 /** 1088 * Returns the domain name of the organization that wrote this application. 1089 * 1090 * @see setOrganizationDomain(const QByteArray&) 1091 */ 1092 QString organizationDomain() const; 1093 1094 /** 1095 * @internal 1096 * Provided for use by KCrash 1097 */ 1098 const char *internalProgramName() const; 1099 1100 /** 1101 * Returns the program logo image. 1102 * 1103 * Because KAboutData is a core class it cannot use QImage/QPixmap/QIcon directly, 1104 * so this is a QVariant containing a QImage/QPixmap/QIcon. 1105 * 1106 * @return the program logo data, or a null image if there is 1107 * no custom application logo defined. 1108 */ 1109 QVariant programLogo() const; 1110 1111 /** 1112 * Returns the program's version. 1113 * @return the version string. 1114 */ 1115 QString version() const; 1116 1117 /** 1118 * @internal 1119 * Provided for use by KCrash 1120 */ 1121 const char *internalVersion() const; 1122 1123 /** 1124 * Returns a short, translated description. 1125 * @return the short description (translated). Can be 1126 * QString() if not set. 1127 */ 1128 QString shortDescription() const; 1129 1130 /** 1131 * Returns the application homepage. 1132 * @return the application homepage URL. Can be QString() if 1133 * not set. 1134 */ 1135 QString homepage() const; 1136 1137 /** 1138 * Returns the email address or URL for bugs. 1139 * @return the address where to report bugs. 1140 */ 1141 QString bugAddress() const; 1142 1143 /** 1144 * @internal 1145 * Provided for use by KCrash 1146 */ 1147 const char *internalBugAddress() const; 1148 1149 /** 1150 * Returns a list of authors. 1151 * @return author information (list of persons). 1152 */ 1153 QList<KAboutPerson> authors() const; 1154 1155 /** 1156 * Returns a list of persons who contributed. 1157 * @return credit information (list of persons). 1158 */ 1159 QList<KAboutPerson> credits() const; 1160 1161 /** 1162 * Returns a list of translators. 1163 * @return translators information (list of persons) 1164 */ 1165 QList<KAboutPerson> translators() const; 1166 1167 /** 1168 * Returns a message about the translation team. 1169 * @return a message about the translation team 1170 */ 1171 static QString aboutTranslationTeam(); 1172 1173 /** 1174 * Returns a list of components. 1175 * @return component information (list of components). 1176 * @since 5.84 1177 */ 1178 QList<KAboutComponent> components() const; 1179 1180 /** 1181 * Returns a translated, free form text. 1182 * @return the free form text (translated). Can be QString() if not set. 1183 */ 1184 QString otherText() const; 1185 1186 /** 1187 * Returns a list of licenses. 1188 * 1189 * @return licenses information (list of licenses) 1190 */ 1191 QList<KAboutLicense> licenses() const; 1192 1193 /** 1194 * Returns the copyright statement. 1195 * @return the copyright statement. Can be QString() if not set. 1196 */ 1197 QString copyrightStatement() const; 1198 1199 /** 1200 * Returns the plain text displayed around the list of authors instead 1201 * of the default message telling users to send bug reports to bugAddress(). 1202 * 1203 * @return the plain text displayed around the list of authors instead 1204 * of the default message. Can be QString(). 1205 */ 1206 QString customAuthorPlainText() const; 1207 1208 /** 1209 * Returns the rich text displayed around the list of authors instead 1210 * of the default message telling users to send bug reports to bugAddress(). 1211 * 1212 * @return the rich text displayed around the list of authors instead 1213 * of the default message. Can be QString(). 1214 */ 1215 QString customAuthorRichText() const; 1216 1217 /** 1218 * Returns whether custom text should be displayed around the list of 1219 * authors. 1220 * 1221 * @return whether custom text should be displayed around the list of 1222 * authors. 1223 */ 1224 bool customAuthorTextEnabled() const; 1225 1226 /** 1227 * Sets the custom text displayed around the list of authors instead 1228 * of the default message telling users to send bug reports to bugAddress(). 1229 * 1230 * @param plainText The plain text. 1231 * @param richText The rich text. 1232 * 1233 * Setting both to parameters to QString() will cause no message to be 1234 * displayed at all. Call unsetCustomAuthorText() to revert to the default 1235 * message. 1236 */ 1237 KAboutData &setCustomAuthorText(const QString &plainText, const QString &richText); 1238 1239 /** 1240 * Clears any custom text displayed around the list of authors and falls 1241 * back to the default message telling users to send bug reports to 1242 * bugAddress(). 1243 */ 1244 KAboutData &unsetCustomAuthorText(); 1245 1246 /** 1247 * Configures the @p parser command line parser to provide an authors entry with 1248 * information about the developers of the application and an entry specifying the license. 1249 * 1250 * Additionally, it will set the description to the command line parser, will add the help 1251 * option and if the QApplication has a version set (e.g. via KAboutData::setApplicationData) 1252 * it will also add the version option. 1253 * 1254 * Since 5.16 it also adds an option to set the desktop file name. 1255 * 1256 * @returns true if adding the options was successful; otherwise returns false. 1257 * 1258 * @sa processCommandLine() 1259 */ 1260 bool setupCommandLine(QCommandLineParser *parser); 1261 1262 /** 1263 * Reads the processed @p parser and sees if any of the arguments are the ones set 1264 * up from setupCommandLine(). 1265 * 1266 * @sa setupCommandLine() 1267 */ 1268 void processCommandLine(QCommandLineParser *parser); 1269 1270 /** 1271 * Sets the base name of the desktop entry for this application. 1272 * 1273 * This is the file name, without the full path and without extension, 1274 * of the desktop entry that represents this application according to 1275 * the freedesktop desktop entry specification (e.g. "org.kde.foo"). 1276 * 1277 * A default desktop file name is constructed when the KAboutData 1278 * object is created, using the reverse domain name of the 1279 * organizationDomain() and the componentName() as they are at the time 1280 * of the KAboutData object creation. 1281 * Call this method to override that default name. Typically this is 1282 * done when also setOrganizationDomain(const QByteArray&) or setComponentName(const QString&) 1283 * need to be called to override the initial values. 1284 * 1285 * The desktop file name can also be passed to the application at runtime through 1286 * the @c desktopfile command line option which is added by setupCommandLine(QCommandLineParser*). 1287 * This is useful if an application supports multiple desktop files with different runtime 1288 * settings. 1289 * 1290 * @param desktopFileName The desktop file name of this application 1291 * 1292 * @sa desktopFileName() 1293 * @sa organizationDomain() 1294 * @sa componentName() 1295 * @sa setupCommandLine(QCommandLineParser*) 1296 * @since 5.16 1297 **/ 1298 KAboutData &setDesktopFileName(const QString &desktopFileName); 1299 1300 /** 1301 * @returns The desktop file name of this application (e.g. "org.kde.foo") 1302 * @sa setDesktopFileName(const QString&) 1303 * @since 5.16 1304 **/ 1305 QString desktopFileName() const; 1306 1307 private: 1308 friend void KCrash::defaultCrashHandler(int sig); 1309 // exported for KCrash, no other users intended 1310 static const KAboutData *applicationDataPointer(); 1311 1312 private: 1313 std::unique_ptr<class KAboutDataPrivate> const d; 1314 }; 1315 1316 #endif