KAboutData Class
Holds information needed by the "About" box and other classes. More...
Header: | #include <KAboutData> |
CMake: | find_package(KF6 REQUIRED COMPONENTS CoreAddons) target_link_libraries(mytarget PRIVATE KF6::CoreAddons) |
Public Functions
KAboutData(const QString &componentName = {}, const QString &displayName = {}, const QString &version = {}) | |
KAboutData(const KAboutData &other) | |
KAboutData & | addAuthor(const QString &name, const QString &task = QString(), const QString &emailAddress = QString(), const QString &webAddress = QString(), const QUrl &avatarUrl = QUrl()) |
(since 6.0) KAboutData & | addAuthor(const QString &name, const QString &task, const QString &emailAddress, const QString &webAddress, const QString &kdeStoreUsername) |
(since 5.84) KAboutData & | addComponent(const QString &name, const QString &description = QString(), const QString &version = QString(), const QString &webAddress = QString(), KAboutLicense::LicenseKey licenseKey = KAboutLicense::Unknown) |
(since 5.84) KAboutData & | addComponent(const QString &name, const QString &description, const QString &version, const QString &webAddress, const QString &pathToLicenseFile) |
KAboutData & | addCredit(const QString &name, const QString &task = QString(), const QString &emailAddress = QString(), const QString &webAddress = QString(), const QUrl &avatarUrl = QUrl()) |
(since 6.0) KAboutData & | addCredit(const QString &name, const QString &task, const QString &emailAddress, const QString &webAddress, const QString &kdeStoreUsername) |
KAboutData & | addLicense(KAboutLicense::LicenseKey licenseKey) |
(since 5.37) KAboutData & | addLicense(KAboutLicense::LicenseKey licenseKey, KAboutLicense::VersionRestriction versionRestriction) |
KAboutData & | addLicenseText(const QString &license) |
KAboutData & | addLicenseTextFile(const QString &file) |
QList<KAboutPerson> | authors() const |
QString | bugAddress() const |
QString | componentName() const |
(since 5.84) QList<KAboutComponent> | components() const |
QString | copyrightStatement() const |
QList<KAboutPerson> | credits() const |
QString | customAuthorPlainText() const |
QString | customAuthorRichText() const |
bool | customAuthorTextEnabled() const |
(since 5.16) QString | desktopFileName() const |
QString | displayName() const |
QString | homepage() const |
QList<KAboutLicense> | licenses() const |
QString | organizationDomain() const |
QString | otherText() const |
void | processCommandLine(QCommandLineParser *parser) |
QString | productName() const |
QVariant | programLogo() const |
KAboutData & | setBugAddress(const QByteArray &bugAddress) |
KAboutData & | setComponentName(const QString &componentName) |
KAboutData & | setCopyrightStatement(const QString ©rightStatement) |
KAboutData & | setCustomAuthorText(const QString &plainText, const QString &richText) |
(since 5.16) KAboutData & | setDesktopFileName(const QString &desktopFileName) |
KAboutData & | setDisplayName(const QString &displayName) |
KAboutData & | setHomepage(const QString &homepage) |
KAboutData & | setLicense(KAboutLicense::LicenseKey licenseKey) |
(since 5.37) KAboutData & | setLicense(KAboutLicense::LicenseKey licenseKey, KAboutLicense::VersionRestriction versionRestriction) |
KAboutData & | setLicenseText(const QString &license) |
KAboutData & | setLicenseTextFile(const QString &file) |
KAboutData & | setOrganizationDomain(const QByteArray &domain) |
KAboutData & | setOtherText(const QString &otherText) |
KAboutData & | setProductName(const QByteArray &name) |
KAboutData & | setProgramLogo(const QVariant &image) |
KAboutData & | setShortDescription(const QString &shortDescription) |
KAboutData & | setTranslator(const QString &name, const QString &emailAddress) |
KAboutData & | setVersion(const QByteArray &version) |
bool | setupCommandLine(QCommandLineParser *parser) |
QString | shortDescription() const |
QList<KAboutPerson> | translators() const |
KAboutData & | unsetCustomAuthorText() |
QString | version() const |
KAboutData & | operator=(const KAboutData &other) |
Static Public Members
QString | aboutTranslationTeam() |
KAboutData | applicationData() |
void | setApplicationData(const KAboutData &aboutData) |
Detailed Description
This class is used to store information about a program or plugin. It can store such values as version number, program name, home page, address for bug reporting, multiple authors and contributors (using KAboutPerson), license and copyright information.
Currently, the values set here are shown by the "About" box (see KAboutApplicationDialog), used by the bug report dialog (see KBugReport), and by the help shown on command line (see KAboutData::setupCommandLine()).
Porting Notes: Since KDE Frameworks 5.0, the translation catalog mechanism must be provided by your translation framework to load the correct catalog instead (eg: KLocalizedString::setApplicationDomain() for KI18n, or QCoreApplication::installTranslator() for Qt's translation system). This applies to the old setCatalogName() and catalogName() members. But see also K4AboutData in kde4support as a compatibility class.
Example: Setting the metadata of an application using KAboutData in code also relying on the KDE Framework modules KI18n and KDBusAddons:
// create QApplication instance QApplication app(argc, argv); // setup translation string domain for the i18n calls KLocalizedString::setApplicationDomain("foo"); // create a KAboutData object to use for setting the application metadata KAboutData aboutData("foo", i18n("Foo"), "0.1", i18n("To Foo or not To Foo"), KAboutLicense::LGPL, i18n("Copyright 2017 Bar Foundation"), QString(), "https://www.foo-the-app.net"); // overwrite default-generated values of organizationDomain & desktopFileName aboutData.setOrganizationDomain("barfoundation.org"); aboutData.setDesktopFileName("org.barfoundation.foo"); // set the application metadata KAboutData::setApplicationData(aboutData); // in GUI apps set the window icon manually, not covered by KAboutData // needed for environments where the icon name is not extracted from // the information in the application's desktop file QApplication::setWindowIcon(QIcon::fromTheme(QStringLiteral("foo"))); // integrate with commandline argument handling QCommandLineParser parser; aboutData.setupCommandLine(&parser); // setup of app specific commandline args [...] parser.process(app); aboutData.processCommandLine(&parser); // with the application metadata set, register to the D-Bus session KDBusService programDBusService(KDBusService::Multiple | KDBusService::NoExitOnFailure);
Member Function Documentation
[explicit]
KAboutData::KAboutData(const QString &componentName = {}, const QString &displayName = {}, const QString &version = {})
Constructor.
componentName The program name or plugin name used internally. Example: "kwrite".
displayName A displayable name for the program or plugin. This string should be translated. Example: i18n("KWrite")
version The component version string.
Sets the property desktopFileName to "org.kde."+componentName and the property organizationDomain to "kde.org".
Default arguments since KCoreAddons 5.53
See also setOrganizationDomain(const QByteArray&) and setDesktopFileName(const QString&).
KAboutData::KAboutData(const KAboutData &other)
Copy constructor. Performs a deep copy.
other object to copy
[static]
QString KAboutData::aboutTranslationTeam()
Returns a message about the translation team. Returns a message about the translation team
KAboutData &KAboutData::addAuthor(const QString &name, const QString &task = QString(), const QString &emailAddress = QString(), const QString &webAddress = QString(), const QUrl &avatarUrl = QUrl())
Defines an author.
You can call this function as many times as you need. Each entry is appended to a list. The person in the first entry is assumed to be the leader of the project.
name The developer's name. It should be translated.
task What the person is responsible for. This text can contain newlines. It should be translated. Can be left empty.
emailAddress An Email address where the person can be reached. Can be left empty.
webAddress The person's homepage or a relevant link. Start the address with "http://". "http://some.domain" is correct, "some.domain" is not. Can be left empty.
avatarUrl URL to the avatar of the person
[since 6.0]
KAboutData &KAboutData::addAuthor(const QString &name, const QString &task, const QString &emailAddress, const QString &webAddress, const QString &kdeStoreUsername)
This is an overloaded function.
This function was introduced in 6.0.
[since 5.84]
KAboutData &KAboutData::addComponent(const QString &name, const QString &description = QString(), const QString &version = QString(), const QString &webAddress = QString(), KAboutLicense::LicenseKey licenseKey = KAboutLicense::Unknown)
Defines a component that is used by the application.
You can call this function as many times as you need. Each entry is appended to a list.
name The component's name. It should be translated.
description Short description of the component and maybe copyright info. This text can contain newlines. It should be translated. Can be left empty.
version The version of the component. Can be left empty.
webAddress The component's homepage or a relevant link. Start the address with "http://". "http://some.domain" is correct, "some.domain" is not. Can be left empty.
licenseKey The component's license identifier. Can be left empty (i.e. KAboutLicense::Unknown)
This function was introduced in 5.84.
[since 5.84]
KAboutData &KAboutData::addComponent(const QString &name, const QString &description, const QString &version, const QString &webAddress, const QString &pathToLicenseFile)
Defines a component that is used by the application with a custom license text file.
You can call this function as many times as you need. Each entry is appended to a list.
name The component's name. It should be translated.
description Short description of the component and maybe copyright info. This text can contain newlines. It should be translated. Can be left empty.
version The version of the component. Can be left empty.
webAddress The component's homepage or a relevant link. Start the address with "http://". "http://some.domain" is correct, "some.domain" is not. Can be left empty.
pathToLicenseFile Path to the file in the local filesystem containing the license text. The file format has to be plain text in an encoding compatible to the local.
This function was introduced in 5.84.
KAboutData &KAboutData::addCredit(const QString &name, const QString &task = QString(), const QString &emailAddress = QString(), const QString &webAddress = QString(), const QUrl &avatarUrl = QUrl())
Defines a person that deserves credit.
You can call this function as many times as you need. Each entry is appended to a list.
name The person's name. It should be translated.
task What the person has done to deserve the honor. The text can contain newlines. It should be translated. Can be left empty.
emailAddress An email address when the person can be reached. Can be left empty.
webAddress The person's homepage or a relevant link. Start the address with "http://". "http://some.domain" is is correct, "some.domain" is not. Can be left empty.
avatarUrl URL to the avatar of the person
[since 6.0]
KAboutData &KAboutData::addCredit(const QString &name, const QString &task, const QString &emailAddress, const QString &webAddress, const QString &kdeStoreUsername)
This is an overloaded function.
This function was introduced in 6.0.
KAboutData &KAboutData::addLicense(KAboutLicense::LicenseKey licenseKey)
Adds a license identifier.
If there is only one unknown license set, e.g. by using the default parameter in the constructor, that one is replaced.
licenseKey The license identifier.
See also setLicenseText, addLicenseText, and addLicenseTextFile.
[since 5.37]
KAboutData &KAboutData::addLicense(KAboutLicense::LicenseKey licenseKey, KAboutLicense::VersionRestriction versionRestriction)
Adds a license identifier.
If there is only one unknown license set, e.g. by using the default parameter in the constructor, that one is replaced.
licenseKey The license identifier.
versionRestriction Whether later versions of the license are also allowed. e.g. licensed under "GPL 2.0 or at your option later versions" would be OrLaterVersions.
This function was introduced in 5.37.
See also setLicenseText, addLicenseText, and addLicenseTextFile.
KAboutData &KAboutData::addLicenseText(const QString &license)
Adds a license text, which is translated.
If there is only one unknown license set, e.g. by using the default parameter in the constructor, that one is replaced.
Example:
addLicenseText( i18n("This is my license") );
license The license text.
See also setLicenseText, addLicense, and addLicenseTextFile.
KAboutData &KAboutData::addLicenseTextFile(const QString &file)
Adds a license text by pointing to a file where it resides. The file format has to be plain text in an encoding compatible to the locale.
If there is only one unknown license set, e.g. by using the default parameter in the constructor, that one is replaced.
file Path to the file in the local filesystem containing the license text.
See also addLicenseText, addLicense, and setLicenseTextFile.
[static]
KAboutData KAboutData::applicationData()
Returns the KAboutData for the application.
This contains information such as authors, license, etc., provided that setApplicationData has been called before. If not called before, the returned KAboutData will be initialized from the equivalent properties of QCoreApplication (and its subclasses), if an instance of that already exists. For the list of such properties see setApplicationData (before 5.22: limited to QCoreApplication::applicationName).
See also setApplicationData.
QList<KAboutPerson> KAboutData::authors() const
Returns a list of authors. Returns author information (list of persons).
Note: Getter function for property authors.
QString KAboutData::bugAddress() const
Returns the email address or URL for bugs. Returns the address where to report bugs.
Note: Getter function for property bugAddress.
See also setBugAddress().
QString KAboutData::componentName() const
Returns the application's internal name. Returns the internal program name.
Note: Getter function for property componentName.
See also setComponentName().
[since 5.84]
QList<KAboutComponent> KAboutData::components() const
Returns a list of components. Returns component information (list of components).
Note: Getter function for property components.
This function was introduced in 5.84.
QString KAboutData::copyrightStatement() const
Returns the copyright statement. Returns the copyright statement. Can be QString() if not set.
Note: Getter function for property copyrightStatement.
See also setCopyrightStatement().
QList<KAboutPerson> KAboutData::credits() const
Returns a list of persons who contributed. Returns credit information (list of persons).
Note: Getter function for property credits.
QString KAboutData::customAuthorPlainText() const
Returns the plain text displayed around the list of authors instead of the default message telling users to send bug reports to bugAddress().
Returns the plain text displayed around the list of authors instead of the default message. Can be QString().
QString KAboutData::customAuthorRichText() const
Returns the rich text displayed around the list of authors instead of the default message telling users to send bug reports to bugAddress().
Returns the rich text displayed around the list of authors instead of the default message. Can be QString().
bool KAboutData::customAuthorTextEnabled() const
Returns whether custom text should be displayed around the list of authors.
Returns whether custom text should be displayed around the list of authors.
[since 5.16]
QString KAboutData::desktopFileName() const
Returns The desktop file name of this application (e.g. "org.kde.foo")
Note: Getter function for property desktopFileName.
This function was introduced in 5.16.
See also setDesktopFileName(const QString&).
QString KAboutData::displayName() const
Returns the translated program name. Returns the program name (translated).
Note: Getter function for property displayName.
See also setDisplayName().
QString KAboutData::homepage() const
Returns the application homepage. Returns the application homepage URL. Can be QString() if not set.
Note: Getter function for property homepage.
See also setHomepage().
QList<KAboutLicense> KAboutData::licenses() const
Returns a list of licenses.
Returns licenses information (list of licenses)
Note: Getter function for property licenses.
QString KAboutData::organizationDomain() const
Returns the domain name of the organization that wrote this application.
See also setOrganizationDomain(const QByteArray&).
QString KAboutData::otherText() const
Returns a translated, free form text. Returns the free form text (translated). Can be QString() if not set.
Note: Getter function for property otherText.
See also setOtherText().
void KAboutData::processCommandLine(QCommandLineParser *parser)
Reads the processed parser and sees if any of the arguments are the ones set up from setupCommandLine().
See also setupCommandLine().
QString KAboutData::productName() const
Returns the application's product name, which will be used in KBugReport dialog. By default it returns componentName(), otherwise the one which is set with setProductName()
Returns the product name.
Note: Getter function for property productName.
See also setProductName().
QVariant KAboutData::programLogo() const
Returns the program logo image.
Because KAboutData is a core class it cannot use QImage/QPixmap/QIcon directly, so this is a QVariant containing a QImage/QPixmap/QIcon.
Returns the program logo data, or a null image if there is no custom application logo defined.
Note: Getter function for property programLogo.
See also setProgramLogo().
[static]
void KAboutData::setApplicationData(const KAboutData &aboutData)
Sets the application data for this application.
In addition to changing the result of applicationData, this initializes the equivalent properties of QCoreApplication (and its subclasses) with information from aboutData, if an instance of that already exists. Those properties are:
- QCoreApplication::applicationName
- QCoreApplication::applicationVersion
- QCoreApplication::organizationDomain
- QGuiApplication::applicationDisplayName
- QGuiApplication::desktopFileName (since 5.16)
See also applicationData.
KAboutData &KAboutData::setBugAddress(const QByteArray &bugAddress)
Defines the address where bug reports should be sent.
bugAddress The bug report email address or URL. This defaults to the kde.org bug system.
See also bugAddress().
KAboutData &KAboutData::setComponentName(const QString &componentName)
Defines the component name used internally.
componentName The application or plugin name. Example: "kate".
See also componentName().
KAboutData &KAboutData::setCopyrightStatement(const QString ©rightStatement)
Defines the copyright statement to show when displaying the license.
copyrightStatement A copyright statement, that can look like this: i18n("Copyright (C) 1999-2000 Name"). The string specified here is taken verbatim; the author information from addAuthor is not used.
See also copyrightStatement().
KAboutData &KAboutData::setCustomAuthorText(const QString &plainText, const QString &richText)
Sets the custom text displayed around the list of authors instead of the default message telling users to send bug reports to bugAddress().
plainText The plain text.
richText The rich text.
Setting both to parameters to QString() will cause no message to be displayed at all. Call unsetCustomAuthorText() to revert to the default message.
[since 5.16]
KAboutData &KAboutData::setDesktopFileName(const QString &desktopFileName)
Sets the base name of the desktop entry for this application.
This is the file name, without the full path and without extension, of the desktop entry that represents this application according to the freedesktop desktop entry specification (e.g. "org.kde.foo").
A default desktop file name is constructed when the KAboutData object is created, using the reverse domain name of the organizationDomain and the componentName as they are at the time of the KAboutData object creation. Call this method to override that default name. Typically this is done when also setOrganizationDomain or setComponentName need to be called to override the initial values.
The desktop file name can also be passed to the application at runtime through the desktopfile
command line option which is added by setupCommandLine. This is useful if an application supports multiple desktop files with different runtime settings.
desktopFileName The desktop file name of this application
This function was introduced in 5.16.
See also desktopFileName, organizationDomain, componentName, and setupCommandLine.
KAboutData &KAboutData::setDisplayName(const QString &displayName)
Defines the displayable component name string.
displayName The display name. This string should be translated. Example: i18n("Advanced Text Editor").
See also displayName().
KAboutData &KAboutData::setHomepage(const QString &homepage)
Defines the program homepage.
homepage The program homepage string. Start the address with "http://". "http://kate.kde.org" is correct but "kate.kde.org" is not.
See also homepage().
KAboutData &KAboutData::setLicense(KAboutLicense::LicenseKey licenseKey)
Defines the license identifier.
licenseKey The license identifier.
See also addLicenseText, setLicenseText, and setLicenseTextFile.
[since 5.37]
KAboutData &KAboutData::setLicense(KAboutLicense::LicenseKey licenseKey, KAboutLicense::VersionRestriction versionRestriction)
Defines the license identifier.
licenseKey The license identifier.
versionRestriction Whether later versions of the license are also allowed. e.g. licensed under "GPL 2.0 or at your option later versions" would be OrLaterVersions.
This function was introduced in 5.37.
See also addLicenseText, setLicenseText, and setLicenseTextFile.
KAboutData &KAboutData::setLicenseText(const QString &license)
Defines a license text, which is translated.
Example:
setLicenseText( i18n("This is my license") );
license The license text.
KAboutData &KAboutData::setLicenseTextFile(const QString &file)
Defines a license text by pointing to a file where it resides. The file format has to be plain text in an encoding compatible to the locale.
file Path to the file in the local filesystem containing the license text.
KAboutData &KAboutData::setOrganizationDomain(const QByteArray &domain)
Defines the domain of the organization that wrote this application. The domain is set to kde.org by default, or the domain of the homePageAddress constructor argument, if set.
Make sure to call setOrganizationDomain(const QByteArray&) if your product is not developed inside the KDE community.
Used e.g. for the registration to D-Bus done by KDBusService from the KDE Frameworks KDBusAddons module.
Calling this method has no effect on the value of the desktopFileName property.
Note: If your program should work as a D-Bus activatable service, the base name of the D-Bus service description file or of the desktop file you install must match the D-Bus "well-known name" for which the program will register. For example, KDBusService will use a name created from the reversed organization domain with the component name attached, so for an organization domain "bar.org" and a component name "foo" the name of an installed D-Bus service file needs to be "org.bar.foo.service" or the name of the installed desktop file "org.bar.foo.desktop" (and the desktopFileName property accordingly set to "org.bar.foo").
domain the domain name, for instance kde.org, koffice.org, etc.
See also organizationDomain() and setDesktopFileName(const QString&).
KAboutData &KAboutData::setOtherText(const QString &otherText)
Defines the additional text to show in the about dialog.
otherText Some free form text, that can contain any kind of information. The text can contain newlines. This string should be translated.
See also otherText().
KAboutData &KAboutData::setProductName(const QByteArray &name)
Defines the product name which will be used in the KBugReport dialog. By default it's the componentName, but you can overwrite it here to provide support for special components e.g. in the form 'product/component', such as 'kontact/summary'.
name The name of product
See also productName().
KAboutData &KAboutData::setProgramLogo(const QVariant &image)
Defines the program logo.
Use this if you need to have an application logo in AboutData other than the application icon.
Because KAboutData is a core class it cannot use QImage/QPixmap/QIcon directly, so this is a QVariant that should contain a QImage/QPixmap/QIcon.
QIcon should be preferred, to be able to properly handle HiDPI scaling. If a QIcon is provided, it will be used at a typical size of 48x48.
image logo image.
See also programLogo().
KAboutData &KAboutData::setShortDescription(const QString &shortDescription)
Defines a short description of what the program does.
shortDescription The program description. This string should be translated. Example: i18n("An advanced text editor with syntax highlighting support.").
See also shortDescription().
KAboutData &KAboutData::setTranslator(const QString &name, const QString &emailAddress)
Sets the name(s) of the translator(s) of the GUI.
The canonical use with the ki18n framework is:
setTranslator(i18nc("NAME OF TRANSLATORS", "Your names"), i18nc("EMAIL OF TRANSLATORS", "Your emails"));
If you are using a KMainWindow this is done for you automatically.
The name and emailAddress are treated as lists separated with ",".
If the strings are empty or "Your names"/"Your emails" respectively they will be ignored.
name the name(s) of the translator(s)
emailAddress the email address(es) of the translator(s)
See also KAboutTranslator.
KAboutData &KAboutData::setVersion(const QByteArray &version)
Defines the program version string.
version The program version.
See also version().
bool KAboutData::setupCommandLine(QCommandLineParser *parser)
Configures the parser command line parser to provide an authors entry with information about the developers of the application and an entry specifying the license.
Additionally, it will set the description to the command line parser, will add the help option and if the QApplication has a version set (e.g. via KAboutData::setApplicationData) it will also add the version option.
Since 5.16 it also adds an option to set the desktop file name.
Returns true if adding the options was successful; otherwise returns false.
See also processCommandLine.
QString KAboutData::shortDescription() const
Returns a short, translated description. Returns the short description (translated). Can be QString() if not set.
Note: Getter function for property shortDescription.
See also setShortDescription().
QList<KAboutPerson> KAboutData::translators() const
Returns a list of translators. Returns translators information (list of persons)
Note: Getter function for property translators.
KAboutData &KAboutData::unsetCustomAuthorText()
Clears any custom text displayed around the list of authors and falls back to the default message telling users to send bug reports to bugAddress().
QString KAboutData::version() const
Returns the program's version. Returns the version string.
Note: Getter function for property version.
See also setVersion().
KAboutData &KAboutData::operator=(const KAboutData &other)
Assignment operator. Performs a deep copy.
other object to copy