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

KDE's Doxygen guidelines are available online.