KCoreAddons

kaboutdata.h
1/*
2 This file is part of the KDE Libraries
3
4 SPDX-FileCopyrightText: 2000 Espen Sand <espen@kde.org>
5 SPDX-FileCopyrightText: 2008 Friedrich W. H. Kossebau <kossebau@kde.org>
6 SPDX-FileCopyrightText: 2010 Teo Mrnjavac <teo@kde.org>
7 SPDX-FileCopyrightText: 2013 David Faure <faure+bluesystems@kde.org>
8 SPDX-FileCopyrightText: 2017 Harald Sitter <sitter@kde.org>
9 SPDX-FileCopyrightText: 2021 Julius Künzel <jk.kdedev@smartlab.uber.space>
10
11 SPDX-License-Identifier: LGPL-2.0-or-later
12*/
13
14#ifndef KABOUTDATA_H
15#define KABOUTDATA_H
16
17#include <QSharedDataPointer>
18#include <QString>
19#include <QUrl>
20#include <QVariant>
21#include <kcoreaddons_export.h>
22#include <memory>
23#include <qcontainerfwd.h>
24
26class QJsonObject;
27class KAboutData;
28namespace KCrash
29{
30#ifdef KCOREADDONS_STATIC
31void defaultCrashHandler(int sig);
32#else
33Q_DECL_IMPORT void defaultCrashHandler(int sig);
34#endif
35}
36
37/**
38 * @class KAboutPerson kaboutdata.h KAboutPerson
39 *
40 * This class is used to store information about a person or developer.
41 * It can store the person's name, a task, an email address and a
42 * link to a home page. This class is intended for use in the
43 * KAboutData class, but it can be used elsewhere as well.
44 * Normally you should at least define the person's name.
45 * Creating a KAboutPerson object by yourself is relatively useless,
46 * but the KAboutData methods KAboutData::authors() and KAboutData::credits()
47 * return lists of KAboutPerson data objects which you can examine.
48 *
49 * Example usage within a main(), retrieving the list of people involved
50 * with a program and re-using data from one of them:
51 *
52 * @code
53 * KAboutData about("khello", i18n("KHello"), "0.1",
54 * i18n("A KDE version of Hello, world!"),
55 * KAboutLicense::LGPL,
56 * i18n("Copyright (C) 2014 Developer"));
57 *
58 * about.addAuthor(i18n("Joe Developer"), i18n("developer"), "joe@host.com", 0);
59 * QList<KAboutPerson> people = about.authors();
60 * about.addCredit(people[0].name(), people[0].task());
61 * @endcode
62 */
63class KCOREADDONS_EXPORT KAboutPerson
64{
65 Q_GADGET
66 Q_PROPERTY(QString name READ name CONSTANT)
67 Q_PROPERTY(QString task READ task CONSTANT)
68 Q_PROPERTY(QString emailAddress READ emailAddress CONSTANT)
69 Q_PROPERTY(QString webAddress READ webAddress CONSTANT)
70 Q_PROPERTY(QUrl avatarUrl READ avatarUrl CONSTANT)
71 friend class KAboutData;
72 friend class KAboutDataPrivate;
73
74public:
75 /**
76 * Convenience constructor
77 *
78 * @param name The name of the person.
79 *
80 * @param task The task of this person.
81 *
82 * @param emailAddress The email address of the person.
83 *
84 * @param webAddress Home page of the person.
85 *
86 * @param avatarUrl URL to the avatar of the person, since 6.0
87 *
88 * @p name default argument @since 5.53
89 */
90 explicit KAboutPerson(const QString &name = QString(),
91 const QString &task = QString(),
92 const QString &emailAddress = QString(),
93 const QString &webAddress = QString(),
94 const QUrl &avatarUrl = QUrl());
95
96 /**
97 * Copy constructor. Performs a deep copy.
98 * @param other object to copy
99 */
101
103
104 /**
105 * Assignment operator. Performs a deep copy.
106 * @param other object to copy
107 */
109
110 /**
111 * The person's name
112 * @return the person's name (can be QString(), if it has been
113 * constructed with an empty name)
114 */
115 QString name() const;
116
117 /**
118 * The person's task
119 * @return the person's task (can be QString(), if it has been
120 * constructed with an empty task)
121 */
122 QString task() const;
123
124 /**
125 * The person's email address
126 * @return the person's email address (can be QString(), if it has been
127 * constructed with an empty email)
128 */
129 QString emailAddress() const;
130
131 /**
132 * The home page or a relevant link
133 * @return the persons home page (can be QString(), if it has been
134 * constructed with an empty home page)
135 */
136 QString webAddress() const;
137
138 /**
139 * @return an URL pointing to the user's avatar
140 * @since 6.0
141 */
142 QUrl avatarUrl() const;
143
144 /**
145 * Creates a @c KAboutPerson from a JSON object with the following structure:
146 *
147 * Key | Accessor
148 * -----------| ----------------------------
149 * Name | name()
150 * Email | emailAddress()
151 * Task | task()
152 * Website | webAddress()
153 * AvatarUrl | avatarUrl()
154 *
155 * The @c Name and @c Task key are translatable (by using e.g. a "Task[de_DE]" key)
156 * The AvatarUrl exists since version 6.0
157 *
158 * @since 5.18
159 */
160 static KAboutPerson fromJSON(const QJsonObject &obj);
161
162private:
163 /**
164 * @internal Used by KAboutData to construct translator data.
165 */
166 KCOREADDONS_NO_EXPORT explicit KAboutPerson(const QString &name, const QString &email, bool disambiguation);
167
168private:
170};
171
172Q_DECLARE_TYPEINFO(KAboutPerson, Q_RELOCATABLE_TYPE);
173
174/**
175 * @class KAboutLicense kaboutdata.h KAboutLicense
176 *
177 * This class is used to store information about a license.
178 * The license can be one of some predefined, one given as text or one
179 * that can be loaded from a file. This class is used in the KAboutData class.
180 * Explicitly creating a KAboutLicense object is not possible.
181 * If the license is wanted for a KDE component having KAboutData object,
182 * use KAboutData::licenses() to get the licenses for that component.
183 * If the license is for a non-code resource and given by a keyword
184 * (e.g. in .desktop files), try using KAboutLicense::byKeyword().
185 */
186class KCOREADDONS_EXPORT KAboutLicense
187{
188 Q_GADGET
189 Q_PROPERTY(QString name READ name CONSTANT)
190 Q_PROPERTY(QString text READ text CONSTANT)
191 Q_PROPERTY(KAboutLicense::LicenseKey key READ key CONSTANT)
192 Q_PROPERTY(QString spdx READ spdx CONSTANT)
193 friend class KAboutData;
194 friend class KAboutComponent;
195
196public:
197 /**
198 * Describes the license of the software; for more information see: https://spdx.org/licenses/
199 */
201 Custom = -2, ///< Custom license
202 File = -1, ///< License set from text file, see setLicenseFromPath()
203 Unknown = 0, ///< Unknown license
204 GPL = 1, ///< GPL
205 GPL_V2 = GPL, ///< GPL_V2, this has the same value as LicenseKey::GPL, see https://spdx.org/licenses/GPL-2.0.html
206 LGPL = 2, ///< LGPL
207 LGPL_V2 = LGPL, ///< LGPL_V2, this has the same value as LicenseKey::LGPL, see https://spdx.org/licenses/LGPL-2.0-only.html
208#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(6, 9)
209 BSDL KCOREADDONS_ENUMERATOR_DEPRECATED_VERSION(6, 9, "Use BSD_2_Clause") = 3, ///< BSDL, see https://spdx.org/licenses/BSD-2-Clause.html
210#endif
211 BSD_2_Clause = 3, ///< BSD_2_CLAUSE, see https://spdx.org/licenses/BSD-2-Clause.html
212 Artistic = 4, ///< Artistic, see https://spdx.org/licenses/Artistic-2.0.html
213 GPL_V3 = 5, ///< GPL_V3, see https://spdx.org/licenses/GPL-3.0.html
214 LGPL_V3 = 6, ///< LGPL_V3, see https://spdx.org/licenses/LGPL-3.0-only.html
215 LGPL_V2_1 = 7, ///< LGPL_V2_1 @since 5.25, see https://spdx.org/licenses/LGPL-2.1-only.html
216 MIT = 8, ///< MIT @since 6.0, see https://spdx.org/licenses/MIT.html
217 ODbL_V1 = 9, ///< ODbL_V1 @since 6.9, see https://spdx.org/licenses/ODbL-1.0.html
218 Apache_V2 = 10, ///< Apache_V2 @since 6.9, see https://spdx.org/licenses/Apache-2.0.html
219 FTL = 11, ///< FTL @since 6.9, see https://spdx.org/licenses/FTL.html
220 BSL_V1 = 12, ///< BSL_V1 @since 6.9, see https://spdx.org/licenses/BSL-1.0.html
221 BSD_3_Clause = 13, ///< BSD_3_CLAUSE @since 6.9, see https://spdx.org/licenses/BSD-3-Clause.html
222 CC0_V1 = 14, ///< CC0_V1 @since 6.9, see https://spdx.org/licenses/CC0-1.0.html
223 };
224 Q_ENUM(LicenseKey)
225
226 /**
227 * Format of the license name.
228 */
230 ShortName,
231 FullName,
232 };
233 Q_ENUM(NameFormat)
234
235 /**
236 * Whether later versions of the license are allowed.
237 */
239 OnlyThisVersion,
240 OrLaterVersions,
241 };
242 Q_ENUM(VersionRestriction)
243
244 /**
245 * @since 5.53
246 */
247 explicit KAboutLicense();
248
249 /**
250 * Copy constructor. Performs a deep copy.
251 * @param other object to copy
252 */
253 KAboutLicense(const KAboutLicense &other);
254
256
257 /**
258 * Assignment operator. Performs a deep copy.
259 * @param other object to copy
260 */
261 KAboutLicense &operator=(const KAboutLicense &other);
262
263 /**
264 * Returns the full license text. If the licenseType argument of the
265 * constructor has been used, any text defined by setLicenseText is ignored,
266 * and the standard text for the chosen license will be returned.
267 *
268 * @return The license text.
269 */
270 QString text() const;
271
272 /**
273 * Returns the license name.
274 *
275 * Default argument @since 5.53
276 *
277 * @return The license name as a string.
278 */
279 QString name(KAboutLicense::NameFormat formatName = ShortName) const;
280
281 /**
282 * Returns the license key.
283 *
284 * @return The license key as element of KAboutLicense::LicenseKey enum.
285 */
286 KAboutLicense::LicenseKey key() const;
287
288 /**
289 * Returns the SPDX license expression of this license.
290 * If the underlying license cannot be expressed as a SPDX expression a null string is returned.
291 *
292 * @note SPDX expression are expansive constructs. If you parse the return value, do it in a
293 * SPDX specification compliant manner by splitting on whitespaces to discard unwanted
294 * information or by using a complete SPDX license expression parser.
295 * @note SPDX identifiers are case-insensitive. Do not use case-sensitive checks on the return
296 * value.
297 * @see https://spdx.org/licenses
298 * @return SPDX license expression or QString() if the license has no identifier. Compliant
299 * with SPDX 2.1.
300 *
301 * @since 5.37
302 */
303 QString spdx() const;
304
305 /**
306 * Fetch a known license by a keyword/spdx ID
307 *
308 * Frequently the license data is provided by a terse keyword-like string,
309 * e.g. by a field in a .desktop file. Using this method, an application
310 * can get hold of a proper KAboutLicense object, providing that the
311 * license is one of the several known to KDE, and use it to present
312 * more human-readable information to the user.
313 *
314 * Keywords are matched by stripping all whitespace and lowercasing.
315 * The known keywords correspond to the KAboutLicense::LicenseKey enumeration,
316 * e.g. any of "LGPLV3", "LGPLv3", "LGPL v3" would match KAboutLicense::LGPL_V3.
317 * If there is no match for the keyword, a valid license object is still
318 * returned, with its name and text informing about a custom license,
319 * and its key equal to KAboutLicense::Custom.
320 *
321 * @param keyword The license keyword.
322 * @return The license object.
323 *
324 * @see KAboutLicense::LicenseKey
325 */
326 static KAboutLicense byKeyword(const QString &keyword);
327
328private:
329 /**
330 * @internal Used by KAboutData to construct a predefined license.
331 */
332 KCOREADDONS_NO_EXPORT explicit KAboutLicense(enum KAboutLicense::LicenseKey licenseType,
333 enum KAboutLicense::VersionRestriction versionRestriction,
334 const KAboutData *aboutData);
335 /**
336 * @internal Used by KAboutData to construct a predefined license.
337 */
338 KCOREADDONS_NO_EXPORT explicit KAboutLicense(enum KAboutLicense::LicenseKey licenseType, const KAboutData *aboutData);
339 /**
340 * @internal Used by KAboutData to construct a KAboutLicense
341 */
342 KCOREADDONS_NO_EXPORT explicit KAboutLicense(const KAboutData *aboutData);
343 /**
344 * @internal Used by KAboutData to construct license by given text
345 */
346 KCOREADDONS_NO_EXPORT void setLicenseFromPath(const QString &pathToFile);
347 /**
348 * @internal Used by KAboutData to construct license by given text
349 */
350 KCOREADDONS_NO_EXPORT void setLicenseFromText(const QString &licenseText);
351
352private:
354};
355
356Q_DECLARE_TYPEINFO(KAboutLicense, Q_RELOCATABLE_TYPE);
357
358/**
359 * @class KAboutComponent kaboutdata.h KAboutComponent
360 *
361 * This class is used to store information about a third party component.
362 * It can store the component's name, a description, a link to a website
363 * and the license of the libary. This class is intended for use in the
364 * KAboutData class, but it can be used elsewhere as well.
365 * Normally you should at least define the libary's name.
366 * Creating a KAboutComponent object by yourself is relatively useless,
367 * but the KAboutData method KAboutData::libaries() return lists of
368 * KAboutComponent data objects which you can examine.
369 *
370 * Example usage within a main(), retrieving the list of components used
371 * by a program and re-using data from one of them:
372 *
373 * @code
374 * KAboutData about("khello", i18n("KHello"), "0.1",
375 * i18n("A KDE version of Hello, world!"),
376 * KAboutLicense::LGPL,
377 * i18n("Copyright (C) 2014 Developer"));
378 *
379 * about.addComponent(i18n("Awsom Lib"),
380 * i18n("Does awesom stuff. Copyright (C) 2014"),
381 * i18n("1.02.3"),
382 * "http://example.com",
383 * KAboutLicense::LGPL);
384 * QList<KAboutComponent> components = about.components();
385 * @endcode
386 *
387 * @since 5.84
388 */
389class KCOREADDONS_EXPORT KAboutComponent
390{
391 Q_GADGET
392 Q_PROPERTY(QString name READ name CONSTANT)
393 Q_PROPERTY(QString description READ description CONSTANT)
394 Q_PROPERTY(QString webAddress READ webAddress CONSTANT)
395 Q_PROPERTY(KAboutLicense licenses READ license CONSTANT)
396 Q_PROPERTY(QString version READ version CONSTANT)
397 friend class KAboutData;
398 friend class KAboutDataPrivate;
399
400public:
401 /**
402 * Convenience constructor
403 *
404 * @param name The name of the component.
405 *
406 * @param description The description of this component.
407 *
408 * @param version The version of this component.
409 *
410 * @param webAddress Website of the component.
411 *
412 * @param licenseType The license identifier of the component.
413 *
414 * @p name default argument
415 */
416 explicit KAboutComponent(const QString &name = QString(),
417 const QString &description = QString(),
418 const QString &version = QString(),
419 const QString &webAddress = QString(),
421
422 /**
423 * Convenience constructor
424 *
425 * @param name The name of the component.
426 *
427 * @param description The description of this component.
428 *
429 * @param version The version of this component.
430 *
431 * @param webAddress Website of the component.
432 *
433 * @param pathToLicenseFile Path to the file in the local filesystem containing the license text.
434 * The file format has to be plain text in an encoding compatible to the local.
435 *
436 * @p name default argument
437 */
438 explicit KAboutComponent(const QString &name,
439 const QString &description,
440 const QString &version,
441 const QString &webAddress,
442 const QString &pathToLicenseFile);
443
444 /**
445 * Copy constructor. Performs a deep copy.
446 * @param other object to copy
447 */
449
451
452 /**
453 * Assignment operator. Performs a deep copy.
454 * @param other object to copy
455 */
457
458 /**
459 * The component's name
460 * @return the component's name (can be QString(), if it has been
461 * constructed with an empty name)
462 */
463 QString name() const;
464
465 /**
466 * The component's description
467 * @return the component's description (can be empty)
468 */
469 QString description() const;
470
471 /**
472 * The component's version
473 * @return the component's task (can be empty)
474 */
475 QString version() const;
476
477 /**
478 * The website or a relevant link
479 * @return the component's website (can be empty)
480 */
481 QString webAddress() const;
482
483 /**
484 * The component's license
485 * @return the component's KAboutLicense
486 */
487 KAboutLicense license() const;
488
489private:
491};
492
493Q_DECLARE_TYPEINFO(KAboutComponent, Q_RELOCATABLE_TYPE);
494
495/**
496 * @class KAboutData kaboutdata.h KAboutData
497 *
498 * This class is used to store information about a program or plugin.
499 * It can store such values as version number, program name, home page, address
500 * for bug reporting, multiple authors and contributors
501 * (using KAboutPerson), license and copyright information.
502 *
503 * Currently, the values set here are shown by the "About" box
504 * (see KAboutApplicationDialog), used by the bug report dialog (see KBugReport),
505 * and by the help shown on command line (see KAboutData::setupCommandLine()).
506 *
507 * Porting Notes: Since KDE Frameworks 5.0, the translation catalog mechanism
508 * must be provided by your translation framework to load the correct catalog
509 * instead (eg: KLocalizedString::setApplicationDomain() for KI18n, or
510 * QCoreApplication::installTranslator() for Qt's translation system). This
511 * applies to the old setCatalogName() and catalogName() members. But see also
512 * K4AboutData in kde4support as a compatibility class.
513 *
514 * Example:
515 * Setting the metadata of an application using KAboutData in code also relying
516 * on the KDE Framework modules KI18n and KDBusAddons:
517 * @code
518 * // create QApplication instance
519 * QApplication app(argc, argv);
520 * // setup translation string domain for the i18n calls
521 * KLocalizedString::setApplicationDomain("foo");
522 * // create a KAboutData object to use for setting the application metadata
523 * KAboutData aboutData("foo", i18n("Foo"), "0.1",
524 * i18n("To Foo or not To Foo"),
525 * KAboutLicense::LGPL,
526 * i18n("Copyright 2017 Bar Foundation"), QString(),
527 * "https://www.foo-the-app.net");
528 * // overwrite default-generated values of organizationDomain & desktopFileName
529 * aboutData.setOrganizationDomain("barfoundation.org");
530 * aboutData.setDesktopFileName("org.barfoundation.foo");
531 *
532 * // set the application metadata
533 * KAboutData::setApplicationData(aboutData);
534 * // in GUI apps set the window icon manually, not covered by KAboutData
535 * // needed for environments where the icon name is not extracted from
536 * // the information in the application's desktop file
537 * QApplication::setWindowIcon(QIcon::fromTheme(QStringLiteral("foo")));
538 *
539 * // integrate with commandline argument handling
540 * QCommandLineParser parser;
541 * aboutData.setupCommandLine(&parser);
542 * // setup of app specific commandline args
543 * [...]
544 * parser.process(app);
545 * aboutData.processCommandLine(&parser);
546 *
547 * // with the application metadata set, register to the D-Bus session
548 * KDBusService programDBusService(KDBusService::Multiple | KDBusService::NoExitOnFailure);
549 * @endcode
550 *
551 * @short Holds information needed by the "About" box and other
552 * classes.
553 * @author Espen Sand (espen@kde.org), David Faure (faure@kde.org)
554 *
555 */
556class KCOREADDONS_EXPORT KAboutData
557{
558 Q_GADGET
559 Q_PROPERTY(QString displayName READ displayName CONSTANT)
560 Q_PROPERTY(QString productName READ productName CONSTANT)
561 Q_PROPERTY(QString componentName READ componentName CONSTANT)
562 Q_PROPERTY(QVariant programLogo READ programLogo CONSTANT)
563 Q_PROPERTY(QString shortDescription READ shortDescription CONSTANT)
564 Q_PROPERTY(QString homepage READ homepage CONSTANT)
565 Q_PROPERTY(QString bugAddress READ bugAddress CONSTANT)
566 Q_PROPERTY(QString version READ version CONSTANT)
567 Q_PROPERTY(QString otherText READ otherText CONSTANT)
568 Q_PROPERTY(QList<KAboutPerson> authors READ authors CONSTANT) // constant in practice as addAuthor is not exposed to Q_GADGET
569 Q_PROPERTY(QList<KAboutPerson> credits READ credits CONSTANT)
570 Q_PROPERTY(QList<KAboutPerson> translators READ translators CONSTANT)
571 Q_PROPERTY(QList<KAboutComponent> components READ components CONSTANT)
572 Q_PROPERTY(QList<KAboutLicense> licenses READ licenses CONSTANT)
573 Q_PROPERTY(QString copyrightStatement READ copyrightStatement CONSTANT)
574 Q_PROPERTY(QString desktopFileName READ desktopFileName CONSTANT)
575public:
576 /**
577 * Returns the KAboutData for the application.
578 *
579 * This contains information such as authors, license, etc.,
580 * provided that setApplicationData has been called before.
581 * If not called before, the returned KAboutData will be initialized from the
582 * equivalent properties of QCoreApplication (and its subclasses),
583 * if an instance of that already exists.
584 * For the list of such properties see setApplicationData
585 * (before 5.22: limited to QCoreApplication::applicationName).
586 * @see setApplicationData
587 */
588 static KAboutData applicationData();
589
590 /**
591 * Sets the application data for this application.
592 *
593 * In addition to changing the result of applicationData(), this initializes
594 * the equivalent properties of QCoreApplication (and its subclasses) with
595 * information from @p aboutData, if an instance of that already exists.
596 * Those properties are:
597 <ul>
598 <li>QCoreApplication::applicationName</li>
599 <li>QCoreApplication::applicationVersion</li>
600 <li>QCoreApplication::organizationDomain</li>
601 <li>QGuiApplication::applicationDisplayName</li>
602 <li>QGuiApplication::desktopFileName (since 5.16)</li>
603 </ul>
604 * @see applicationData
605 */
606 static void setApplicationData(const KAboutData &aboutData);
607
608public:
609 /**
610 * Constructor.
611 *
612 * Porting Note: The @p catalogName parameter present in KDE4 was
613 * deprecated and removed. See also K4AboutData
614 * in kde4support if this feature is needed for compatibility purposes, or
615 * consider using componentName() instead.
616 *
617 * @param componentName The program name or plugin name used internally.
618 * Example: QStringLiteral("kwrite"). This should never be translated.
619 *
620 * @param displayName A displayable name for the program or plugin. This string
621 * should be translated. Example: i18n("KWrite")
622 *
623 * @param version The component version string. Example: QStringLiteral("1.0").
624 *
625 * @param shortDescription A short description of what the component does.
626 * This string should be translated.
627 * Example: i18n("A simple text editor.")
628 *
629 * @param licenseType The license identifier. Use setLicenseText or
630 setLicenseTextFile if you use a license not predefined here.
631 *
632 * @param copyrightStatement A copyright statement, that can look like this:
633 * i18n("Copyright (C) 1999-2000 Name"). The string specified here is
634 * taken verbatim; the author information from addAuthor is not used.
635 *
636 * @param otherText Some free form text, that can contain any kind of
637 * information. The text can contain newlines. This string
638 * should be translated.
639 *
640 * @param homePageAddress The URL to the component's homepage, including
641 * URL scheme. "http://some.domain" is correct, "some.domain" is
642 * not. Since KDE Frameworks 5.17, https and other valid URL schemes
643 * are also valid. See also the note below.
644 *
645 * @param bugAddress The bug report address string, an email address or a URL.
646 * This defaults to the kde.org bug system.
647 *
648 * @note The @p homePageAddress argument is used to derive a default organization
649 * domain for the application (which is used to register on the session D-Bus,
650 * locate the appropriate desktop file, etc.), by taking the host name and dropping
651 * the first component, unless there are less than three (e.g. "www.kde.org" -> "kde.org").
652 * Use both setOrganizationDomain(const QByteArray&) and setDesktopFileName() if their default values
653 * do not have proper values.
654 *
655 * @see setOrganizationDomain(const QByteArray&), setDesktopFileName(const QString&)
656 */
657 // KF6: remove constructor that includes catalogName, and put default
658 // values back in for shortDescription and licenseType
659 KAboutData(const QString &componentName,
660 const QString &displayName,
661 const QString &version,
662 const QString &shortDescription,
663 enum KAboutLicense::LicenseKey licenseType,
664 const QString &copyrightStatement = QString(),
665 const QString &otherText = QString(),
666 const QString &homePageAddress = QString(),
667 const QString &bugAddress = QStringLiteral("submit@bugs.kde.org"));
668
669 /**
670 * Constructor.
671 *
672 * @param componentName The program name or plugin name used internally.
673 * Example: "kwrite".
674 *
675 * @param displayName A displayable name for the program or plugin. This string
676 * should be translated. Example: i18n("KWrite")
677 *
678 * @param version The component version string.
679 *
680 * Sets the property desktopFileName to "org.kde."+componentName and
681 * the property organizationDomain to "kde.org".
682 *
683 * Default arguments @since 5.53
684 *
685 * @see setOrganizationDomain(const QByteArray&), setDesktopFileName(const QString&)
686 */
687 explicit KAboutData(const QString &componentName = {}, const QString &displayName = {}, const QString &version = {});
688
689 /**
690 * Copy constructor. Performs a deep copy.
691 * @param other object to copy
692 */
693 KAboutData(const KAboutData &other);
694
695 /**
696 * Assignment operator. Performs a deep copy.
697 * @param other object to copy
698 */
699 KAboutData &operator=(const KAboutData &other);
700
701 ~KAboutData();
702
703 /**
704 * Add an author.
705 *
706 * You can call this function as many times as you need. Each entry
707 * is appended to a list.
708 *
709 * @param author The author.
710 * @since 6.9
711 */
712 KAboutData &addAuthor(const KAboutPerson &author);
713
714 /**
715 * Defines an author.
716 *
717 * You can call this function as many times as you need. Each entry is
718 * appended to a list. The person in the first entry is assumed to be
719 * the leader of the project.
720 *
721 * @param name The developer's name. It should be translated.
722 *
723 * @param task What the person is responsible for. This text can contain
724 * newlines. It should be translated.
725 * Can be left empty.
726 *
727 * @param emailAddress An Email address where the person can be reached.
728 * Can be left empty.
729 *
730 * @param webAddress The person's homepage or a relevant link.
731 * Start the address with "http://". "http://some.domain" is
732 * correct, "some.domain" is not. Can be left empty.
733 *
734 * @param avatarUrl URL to the avatar of the person
735 */
736 KAboutData &addAuthor(const QString &name,
737 const QString &task = QString(),
738 const QString &emailAddress = QString(),
739 const QString &webAddress = QString(),
740 const QUrl &avatarUrl = QUrl());
741
742 /**
743 * @overload
744 * @since 6.0
745 */
746 KAboutData &addAuthor(const QString &name, const QString &task, const QString &emailAddress, const QString &webAddress, const QString &kdeStoreUsername)
747 {
748 return addAuthor(name, task, emailAddress, webAddress, QUrl(QStringLiteral("https://store.kde.org/avatar/") + kdeStoreUsername));
749 }
750
751 /**
752 * Add a person that deserves credit.
753 *
754 * You can call this function as many times as you need. Each entry
755 * is appended to a list.
756 *
757 * @param person The person.
758 * @since 6.9
759 */
760 KAboutData &addCredit(const KAboutPerson &person);
761
762 /**
763 * Defines a person that deserves credit.
764 *
765 * You can call this function as many times as you need. Each entry
766 * is appended to a list.
767 *
768 * @param name The person's name. It should be translated.
769 *
770 * @param task What the person has done to deserve the honor. The
771 * text can contain newlines. It should be translated.
772 * Can be left empty.
773 *
774 * @param emailAddress An email address when the person can be reached.
775 * Can be left empty.
776 *
777 * @param webAddress The person's homepage or a relevant link.
778 * Start the address with "http://". "http://some.domain" is
779 * is correct, "some.domain" is not. Can be left empty.
780 *
781 * @param avatarUrl URL to the avatar of the person
782 */
783 KAboutData &addCredit(const QString &name,
784 const QString &task = QString(),
785 const QString &emailAddress = QString(),
786 const QString &webAddress = QString(),
787 const QUrl &avatarUrl = QUrl());
788
789 /**
790 * @overload
791 * @since 6.0
792 */
793 KAboutData &addCredit(const QString &name, const QString &task, const QString &emailAddress, const QString &webAddress, const QString &kdeStoreUsername)
794 {
795 return addCredit(name, task, emailAddress, webAddress, QUrl(QStringLiteral("https://store.kde.org/avatar/") + kdeStoreUsername));
796 }
797
798 /**
799 * @brief Sets the name(s) of the translator(s) of the GUI.
800 *
801 * The canonical use with the ki18n framework is:
802 *
803 * \code
804 * setTranslator(i18nc("NAME OF TRANSLATORS", "Your names"),
805 * i18nc("EMAIL OF TRANSLATORS", "Your emails"));
806 * \endcode
807 *
808 * If you are using a KMainWindow this is done for you automatically.
809 *
810 * The name and emailAddress are treated as lists separated with ",".
811 *
812 * If the strings are empty or "Your names"/"Your emails"
813 * respectively they will be ignored.
814 *
815 * @param name the name(s) of the translator(s)
816 * @param emailAddress the email address(es) of the translator(s)
817 * @see KAboutTranslator
818 */
819 KAboutData &setTranslator(const QString &name, const QString &emailAddress);
820
821 /**
822 * Add a component that is used by the application.
823 *
824 * You can call this function as many times as you need. Each entry is
825 * appended to a list.
826 *
827 * @param component The component
828 *
829 * @since 6.9
830 */
831 KAboutData &addComponent(const KAboutComponent &component);
832
833 /**
834 * Defines a component that is used by the application.
835 *
836 * You can call this function as many times as you need. Each entry is
837 * appended to a list.
838 *
839 * @param name The component's name. It should be translated.
840 *
841 * @param description Short description of the component and maybe
842 * copyright info. This text can contain newlines. It should
843 * be translated. Can be left empty.
844 *
845 * @param version The version of the component. Can be left empty.
846 *
847 * @param webAddress The component's homepage or a relevant link.
848 * Start the address with "http://". "http://some.domain" is
849 * correct, "some.domain" is not. Can be left empty.
850 *
851 * @param licenseKey The component's license identifier. Can be left empty (i.e. KAboutLicense::Unknown)
852 *
853 * @since 5.84
854 */
855 KAboutData &addComponent(const QString &name,
856 const QString &description = QString(),
857 const QString &version = QString(),
858 const QString &webAddress = QString(),
860
861 /**
862 * Defines a component that is used by the application with a custom license text file.
863 *
864 * You can call this function as many times as you need. Each entry is
865 * appended to a list.
866 *
867 * @param name The component's name. It should be translated.
868 *
869 * @param description Short description of the component and maybe
870 * copyright info. This text can contain newlines. It should
871 * be translated. Can be left empty.
872 *
873 * @param version The version of the component. Can be left empty.
874 *
875 * @param webAddress The component's homepage or a relevant link.
876 * Start the address with "http://". "http://some.domain" is
877 * correct, "some.domain" is not. Can be left empty.
878 *
879 * @param pathToLicenseFile Path to the file in the local filesystem containing the license text.
880 * The file format has to be plain text in an encoding compatible to the local.
881 *
882 * @since 5.84
883 */
884 KAboutData &
885 addComponent(const QString &name, const QString &description, const QString &version, const QString &webAddress, const QString &pathToLicenseFile);
886
887 /**
888 * Defines a license text, which is translated.
889 *
890 * Example:
891 * \code
892 * setLicenseText( i18n("This is my license") );
893 * \endcode
894 *
895 * @param license The license text.
896 */
897 KAboutData &setLicenseText(const QString &license);
898
899 /**
900 * Adds a license text, which is translated.
901 *
902 * If there is only one unknown license set, e.g. by using the default
903 * parameter in the constructor, that one is replaced.
904 *
905 * Example:
906 * \code
907 * addLicenseText( i18n("This is my license") );
908 * \endcode
909 *
910 * @param license The license text.
911 * @see setLicenseText, addLicense, addLicenseTextFile
912 */
913 KAboutData &addLicenseText(const QString &license);
914
915 /**
916 * Defines a license text by pointing to a file where it resides.
917 * The file format has to be plain text in an encoding compatible to the locale.
918 *
919 * @param file Path to the file in the local filesystem containing the license text.
920 */
921 KAboutData &setLicenseTextFile(const QString &file);
922
923 /**
924 * Adds a license text by pointing to a file where it resides.
925 * The file format has to be plain text in an encoding compatible to the locale.
926 *
927 * If there is only one unknown license set, e.g. by using the default
928 * parameter in the constructor, that one is replaced.
929 *
930 * @param file Path to the file in the local filesystem containing the license text.
931 * @see addLicenseText, addLicense, setLicenseTextFile
932 */
933 KAboutData &addLicenseTextFile(const QString &file);
934
935 /**
936 * Defines the component name used internally.
937 *
938 * @param componentName The application or plugin name. Example: "kate".
939 */
940 KAboutData &setComponentName(const QString &componentName);
941
942 /**
943 * Defines the displayable component name string.
944 *
945 * @param displayName The display name. This string should be
946 * translated.
947 * Example: i18n("Advanced Text Editor").
948 */
949 KAboutData &setDisplayName(const QString &displayName);
950
951 /**
952 * Defines the program logo.
953 *
954 * Use this if you need to have an application logo
955 * in AboutData other than the application icon.
956 *
957 * Because KAboutData is a core class it cannot use QImage/QPixmap/QIcon directly,
958 * so this is a QVariant that should contain a QImage/QPixmap/QIcon.
959 *
960 * QIcon should be preferred, to be able to properly handle HiDPI scaling.
961 * If a QIcon is provided, it will be used at a typical size of 48x48.
962 *
963 * @param image logo image.
964 * @see programLogo()
965 */
966 KAboutData &setProgramLogo(const QVariant &image);
967
968 /**
969 * Defines the program version string.
970 *
971 * @param version The program version.
972 */
973 KAboutData &setVersion(const QByteArray &version);
974
975 /**
976 * Defines a short description of what the program does.
977 *
978 * @param shortDescription The program description. This string should
979 * be translated. Example: i18n("An advanced text
980 * editor with syntax highlighting support.").
981 */
982 KAboutData &setShortDescription(const QString &shortDescription);
983
984 /**
985 * Defines the license identifier.
986 *
987 * @param licenseKey The license identifier.
988 * @see addLicenseText, setLicenseText, setLicenseTextFile
989 */
990 KAboutData &setLicense(KAboutLicense::LicenseKey licenseKey);
991
992 /**
993 * Defines the license identifier.
994 *
995 * @param licenseKey The license identifier.
996 * @param versionRestriction Whether later versions of the license are also allowed.
997 * e.g. licensed under "GPL 2.0 or at your option later versions" would be OrLaterVersions.
998 * @see addLicenseText, setLicenseText, setLicenseTextFile
999 *
1000 * @since 5.37
1001 */
1002 KAboutData &setLicense(KAboutLicense::LicenseKey licenseKey, KAboutLicense::VersionRestriction versionRestriction);
1003
1004 /**
1005 * Adds a license identifier.
1006 *
1007 * If there is only one unknown license set, e.g. by using the default
1008 * parameter in the constructor, that one is replaced.
1009 *
1010 * @param licenseKey The license identifier.
1011 * @see setLicenseText, addLicenseText, addLicenseTextFile
1012 */
1013 KAboutData &addLicense(KAboutLicense::LicenseKey licenseKey);
1014
1015 /**
1016 * Adds a license identifier.
1017 *
1018 * If there is only one unknown license set, e.g. by using the default
1019 * parameter in the constructor, that one is replaced.
1020 *
1021 * @param licenseKey The license identifier.
1022 * @param versionRestriction Whether later versions of the license are also allowed.
1023 * e.g. licensed under "GPL 2.0 or at your option later versions" would be OrLaterVersions.
1024 * @see setLicenseText, addLicenseText, addLicenseTextFile
1025 *
1026 * @since 5.37
1027 */
1028 KAboutData &addLicense(KAboutLicense::LicenseKey licenseKey, KAboutLicense::VersionRestriction versionRestriction);
1029
1030 /**
1031 * Defines the copyright statement to show when displaying the license.
1032 *
1033 * @param copyrightStatement A copyright statement, that can look like
1034 * this: i18n("Copyright (C) 1999-2000 Name"). The string specified here is
1035 * taken verbatim; the author information from addAuthor is not used.
1036 */
1037 KAboutData &setCopyrightStatement(const QString &copyrightStatement);
1038
1039 /**
1040 * Defines the additional text to show in the about dialog.
1041 *
1042 * @param otherText Some free form text, that can contain any kind of
1043 * information. The text can contain newlines. This string
1044 * should be translated.
1045 */
1046 KAboutData &setOtherText(const QString &otherText);
1047
1048 /**
1049 * Defines the program homepage.
1050 *
1051 * @param homepage The program homepage string.
1052 * Start the address with "http://". "http://kate.kde.org"
1053 * is correct but "kate.kde.org" is not.
1054 */
1055 KAboutData &setHomepage(const QString &homepage);
1056
1057 /**
1058 * Defines the address where bug reports should be sent.
1059 *
1060 * @param bugAddress The bug report email address or URL.
1061 * This defaults to the kde.org bug system.
1062 */
1063 KAboutData &setBugAddress(const QByteArray &bugAddress);
1064
1065 /**
1066 * Defines the domain of the organization that wrote this application.
1067 * The domain is set to kde.org by default, or the domain of the homePageAddress constructor argument,
1068 * if set.
1069 *
1070 * Make sure to call setOrganizationDomain(const QByteArray&) if your product
1071 * is not developed inside the KDE community.
1072 *
1073 * Used e.g. for the registration to D-Bus done by KDBusService
1074 * from the KDE Frameworks KDBusAddons module.
1075 *
1076 * Calling this method has no effect on the value of the desktopFileName property.
1077 *
1078 * @note If your program should work as a D-Bus activatable service, the base name
1079 * of the D-Bus service description file or of the desktop file you install must match
1080 * the D-Bus "well-known name" for which the program will register.
1081 * For example, KDBusService will use a name created from the reversed organization domain
1082 * with the component name attached, so for an organization domain "bar.org" and a
1083 * component name "foo" the name of an installed D-Bus service file needs to be
1084 * "org.bar.foo.service" or the name of the installed desktop file "org.bar.foo.desktop"
1085 * (and the desktopFileName property accordingly set to "org.bar.foo").
1086 *
1087 * @param domain the domain name, for instance kde.org, koffice.org, etc.
1088 *
1089 * @see setDesktopFileName(const QString&)
1090 */
1091 KAboutData &setOrganizationDomain(const QByteArray &domain);
1092
1093 /**
1094 * Defines the product name which will be used in the KBugReport dialog.
1095 * By default it's the componentName, but you can overwrite it here to provide
1096 * support for special components e.g. in the form 'product/component',
1097 * such as 'kontact/summary'.
1098 *
1099 * @param name The name of product
1100 */
1101 KAboutData &setProductName(const QByteArray &name);
1102
1103 /**
1104 * Returns the application's internal name.
1105 * @return the internal program name.
1106 */
1107 QString componentName() const;
1108
1109 /**
1110 * Returns the application's product name, which will be used in KBugReport
1111 * dialog. By default it returns componentName(), otherwise the one which is set
1112 * with setProductName()
1113 *
1114 * @return the product name.
1115 */
1116 QString productName() const;
1117
1118 /**
1119 * @internal
1120 * Provided for use by KCrash
1121 */
1122 const char *internalProductName() const;
1123
1124 /**
1125 * Returns the translated program name.
1126 * @return the program name (translated).
1127 */
1128 QString displayName() const;
1129
1130 /**
1131 * Returns the domain name of the organization that wrote this application.
1132 *
1133 * @see setOrganizationDomain(const QByteArray&)
1134 */
1135 QString organizationDomain() const;
1136
1137 /**
1138 * @internal
1139 * Provided for use by KCrash
1140 */
1141 const char *internalProgramName() const;
1142
1143 /**
1144 * Returns the program logo image.
1145 *
1146 * Because KAboutData is a core class it cannot use QImage/QPixmap/QIcon directly,
1147 * so this is a QVariant containing a QImage/QPixmap/QIcon.
1148 *
1149 * @return the program logo data, or a null image if there is
1150 * no custom application logo defined.
1151 */
1152 QVariant programLogo() const;
1153
1154 /**
1155 * Returns the program's version.
1156 * @return the version string.
1157 */
1158 QString version() const;
1159
1160 /**
1161 * @internal
1162 * Provided for use by KCrash
1163 */
1164 const char *internalVersion() const;
1165
1166 /**
1167 * Returns a short, translated description.
1168 * @return the short description (translated). Can be
1169 * QString() if not set.
1170 */
1171 QString shortDescription() const;
1172
1173 /**
1174 * Returns the application homepage.
1175 * @return the application homepage URL. Can be QString() if
1176 * not set.
1177 */
1178 QString homepage() const;
1179
1180 /**
1181 * Returns the email address or URL for bugs.
1182 * @return the address where to report bugs.
1183 */
1184 QString bugAddress() const;
1185
1186 /**
1187 * @internal
1188 * Provided for use by KCrash
1189 */
1190 const char *internalBugAddress() const;
1191
1192 /**
1193 * Returns a list of authors.
1194 * @return author information (list of persons).
1195 */
1196 QList<KAboutPerson> authors() const;
1197
1198 /**
1199 * Returns a list of persons who contributed.
1200 * @return credit information (list of persons).
1201 */
1202 QList<KAboutPerson> credits() const;
1203
1204 /**
1205 * Returns a list of translators.
1206 * @return translators information (list of persons)
1207 */
1208 QList<KAboutPerson> translators() const;
1209
1210 /**
1211 * Returns a message about the translation team.
1212 * @return a message about the translation team
1213 */
1214 static QString aboutTranslationTeam();
1215
1216 /**
1217 * Returns a list of components.
1218 * @return component information (list of components).
1219 * @since 5.84
1220 */
1221 QList<KAboutComponent> components() const;
1222
1223 /**
1224 * Returns a translated, free form text.
1225 * @return the free form text (translated). Can be QString() if not set.
1226 */
1227 QString otherText() const;
1228
1229 /**
1230 * Returns a list of licenses.
1231 *
1232 * @return licenses information (list of licenses)
1233 */
1234 QList<KAboutLicense> licenses() const;
1235
1236 /**
1237 * Returns the copyright statement.
1238 * @return the copyright statement. Can be QString() if not set.
1239 */
1240 QString copyrightStatement() const;
1241
1242 /**
1243 * Returns the plain text displayed around the list of authors instead
1244 * of the default message telling users to send bug reports to bugAddress().
1245 *
1246 * @return the plain text displayed around the list of authors instead
1247 * of the default message. Can be QString().
1248 */
1249 QString customAuthorPlainText() const;
1250
1251 /**
1252 * Returns the rich text displayed around the list of authors instead
1253 * of the default message telling users to send bug reports to bugAddress().
1254 *
1255 * @return the rich text displayed around the list of authors instead
1256 * of the default message. Can be QString().
1257 */
1258 QString customAuthorRichText() const;
1259
1260 /**
1261 * Returns whether custom text should be displayed around the list of
1262 * authors.
1263 *
1264 * @return whether custom text should be displayed around the list of
1265 * authors.
1266 */
1267 bool customAuthorTextEnabled() const;
1268
1269 /**
1270 * Sets the custom text displayed around the list of authors instead
1271 * of the default message telling users to send bug reports to bugAddress().
1272 *
1273 * @param plainText The plain text.
1274 * @param richText The rich text.
1275 *
1276 * Setting both to parameters to QString() will cause no message to be
1277 * displayed at all. Call unsetCustomAuthorText() to revert to the default
1278 * message.
1279 */
1280 KAboutData &setCustomAuthorText(const QString &plainText, const QString &richText);
1281
1282 /**
1283 * Clears any custom text displayed around the list of authors and falls
1284 * back to the default message telling users to send bug reports to
1285 * bugAddress().
1286 */
1287 KAboutData &unsetCustomAuthorText();
1288
1289 /**
1290 * Configures the @p parser command line parser to provide an authors entry with
1291 * information about the developers of the application and an entry specifying the license.
1292 *
1293 * Additionally, it will set the description to the command line parser, will add the help
1294 * option and if the QApplication has a version set (e.g. via KAboutData::setApplicationData)
1295 * it will also add the version option.
1296 *
1297 * Since 5.16 it also adds an option to set the desktop file name.
1298 *
1299 * @returns true if adding the options was successful; otherwise returns false.
1300 *
1301 * @sa processCommandLine()
1302 */
1303 bool setupCommandLine(QCommandLineParser *parser);
1304
1305 /**
1306 * Reads the processed @p parser and sees if any of the arguments are the ones set
1307 * up from setupCommandLine().
1308 *
1309 * @sa setupCommandLine()
1310 */
1311 void processCommandLine(QCommandLineParser *parser);
1312
1313 /**
1314 * Sets the base name of the desktop entry for this application.
1315 *
1316 * This is the file name, without the full path and without extension,
1317 * of the desktop entry that represents this application according to
1318 * the freedesktop desktop entry specification (e.g. "org.kde.foo").
1319 *
1320 * A default desktop file name is constructed when the KAboutData
1321 * object is created, using the reverse domain name of the
1322 * organizationDomain() and the componentName() as they are at the time
1323 * of the KAboutData object creation.
1324 * Call this method to override that default name. Typically this is
1325 * done when also setOrganizationDomain(const QByteArray&) or setComponentName(const QString&)
1326 * need to be called to override the initial values.
1327 *
1328 * The desktop file name can also be passed to the application at runtime through
1329 * the @c desktopfile command line option which is added by setupCommandLine(QCommandLineParser*).
1330 * This is useful if an application supports multiple desktop files with different runtime
1331 * settings.
1332 *
1333 * @param desktopFileName The desktop file name of this application
1334 *
1335 * @sa desktopFileName()
1336 * @sa organizationDomain()
1337 * @sa componentName()
1338 * @sa setupCommandLine(QCommandLineParser*)
1339 * @since 5.16
1340 **/
1341 KAboutData &setDesktopFileName(const QString &desktopFileName);
1342
1343 /**
1344 * @returns The desktop file name of this application (e.g. "org.kde.foo")
1345 * @sa setDesktopFileName(const QString&)
1346 * @since 5.16
1347 **/
1348 QString desktopFileName() const;
1349
1350private:
1351 friend void KCrash::defaultCrashHandler(int sig);
1352 // exported for KCrash, no other users intended
1353 static const KAboutData *applicationDataPointer();
1354
1355private:
1356 std::unique_ptr<class KAboutDataPrivate> const d;
1357};
1358
1359#endif
This class is used to store information about a third party component.
Definition kaboutdata.h:390
KAboutComponent(const KAboutComponent &other)
Copy constructor.
KAboutComponent & operator=(const KAboutComponent &other)
Assignment operator.
This class is used to store information about a program or plugin.
Definition kaboutdata.h:557
KAboutData & addAuthor(const QString &name, const QString &task, const QString &emailAddress, const QString &webAddress, const QString &kdeStoreUsername)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition kaboutdata.h:746
KAboutData & addCredit(const QString &name, const QString &task, const QString &emailAddress, const QString &webAddress, const QString &kdeStoreUsername)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition kaboutdata.h:793
This class is used to store information about a license.
Definition kaboutdata.h:187
LicenseKey
Describes the license of the software; for more information see: https://spdx.org/licenses/.
Definition kaboutdata.h:200
@ KCOREADDONS_ENUMERATOR_DEPRECATED_VERSION
BSDL, see https://spdx.org/licenses/BSD-2-Clause.html.
Definition kaboutdata.h:209
@ Unknown
Unknown license.
Definition kaboutdata.h:203
VersionRestriction
Whether later versions of the license are allowed.
Definition kaboutdata.h:238
NameFormat
Format of the license name.
Definition kaboutdata.h:229
This class is used to store information about a person or developer.
Definition kaboutdata.h:64
KAboutPerson(const KAboutPerson &other)
Copy constructor.
KAboutPerson & operator=(const KAboutPerson &other)
Assignment operator.
KCRASH_EXPORT void defaultCrashHandler(int signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:24 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.