KAboutLicense Class
Header: | #include <KAboutData> |
CMake: | find_package(KF6 REQUIRED COMPONENTS CoreAddons) target_link_libraries(mytarget PRIVATE KF6::CoreAddons) |
Public Types
enum | LicenseKey { Custom, File, Unknown, GPL, GPL_V2, …, MIT } |
(since 6.0) enum | NameFormat { ShortFormat, FullName } |
(since 6.0) enum | VersionRestriction { OnlyThisVersion } |
Public Functions
(since 5.53) | KAboutLicense() |
KAboutLicense(const KAboutLicense &other) | |
KAboutLicense::LicenseKey | key() const |
(since 5.53) QString | name(KAboutLicense::NameFormat formatName = ShortName) const |
(since 5.37) QString | spdx() const |
QString | text() const |
KAboutLicense & | operator=(const KAboutLicense &other) |
Static Public Members
KAboutLicense | byKeyword(const QString &keyword) |
Detailed Description
This class is used to store information about a license. The license can be one of some predefined, one given as text or one that can be loaded from a file. This class is used in the KAboutData class. Explicitly creating a KAboutLicense object is not possible. If the license is wanted for a KDE component having KAboutData object, use KAboutData::licenses() to get the licenses for that component. If the license is for a non-code resource and given by a keyword (e.g. in .desktop files), try using KAboutLicense::byKeyword().
Member Type Documentation
enum KAboutLicense::LicenseKey
Describes the license of the software; for more information see: https://spdx.org/licenses/
Constant | Value | Description |
---|---|---|
KAboutLicense::Custom | -2 | Custom license |
KAboutLicense::File | -1 | License set from text file, see setLicenseFromPath() |
KAboutLicense::Unknown | 0 | Unknown license |
KAboutLicense::GPL | 1 | GPL |
KAboutLicense::GPL_V2 | GPL | GPL_V2, this has the same value as LicenseKey::GPL, see https://spdx.org/licenses/GPL-2.0.html |
KAboutLicense::LGPL | 2 | LGPL |
KAboutLicense::LGPL_V2 | LGPL | LGPL_V2, this has the same value as LicenseKey::LGPL, see https://spdx.org/licenses/LGPL-2.0-only.html |
KAboutLicense::BSDL | 3 | BSDL, see https://spdx.org/licenses/BSD-2-Clause.html |
KAboutLicense::Artistic | 4 | Artistic, see https://spdx.org/licenses/Artistic-2.0.html |
KAboutLicense::GPL_V3 | 5 | GPL_V3, see https://spdx.org/licenses/GPL-3.0.html |
KAboutLicense::LGPL_V3 | 6 | LGPL_V3, see https://spdx.org/licenses/LGPL-3.0-only.html |
KAboutLicense::LGPL_V2_1 (since Qt 5.25) | 7 | LGPL_V2_1, see https://spdx.org/licenses/LGPL-2.1-only.html |
KAboutLicense::MIT (since Qt 6.0) | 8 | , see https://spdx.org/licenses/MIT.html |
[since 6.0]
enum KAboutLicense::NameFormat
Format of the license name.
Constant | Value | Description |
---|---|---|
KAboutLicense::ShortFormat | ? | Short format |
KAboutLicense::FullName | 1 | Full name |
This enum was introduced in 6.0.
[since 6.0]
enum KAboutLicense::VersionRestriction
Whether later versions of the license are allowed.
Constant | Value | Description |
---|---|---|
KAboutLicense::OnlyThisVersion | 0 | Only this version of the license is allowed \valie OrLaterVersions Any later version of the license is allowed |
This enum was introduced in 6.0.
Member Function Documentation
[explicit, since 5.53]
KAboutLicense::KAboutLicense()
This function was introduced in 5.53.
KAboutLicense::KAboutLicense(const KAboutLicense &other)
Copy constructor. Performs a deep copy.
other object to copy
[static]
KAboutLicense KAboutLicense::byKeyword(const QString &keyword)
Fetch a known license by a keyword/spdx ID
Frequently the license data is provided by a terse keyword-like string, e.g. by a field in a .desktop file. Using this method, an application can get hold of a proper KAboutLicense object, providing that the license is one of the several known to KDE, and use it to present more human-readable information to the user.
Keywords are matched by stripping all whitespace and lowercasing. The known keywords correspond to the KAboutLicense::LicenseKey enumeration, e.g. any of "LGPLV3", "LGPLv3", "LGPL v3" would match KAboutLicense::LGPL_V3. If there is no match for the keyword, a valid license object is still returned, with its name and text informing about a custom license, and its key equal to KAboutLicense::Custom.
keyword The license keyword.
Returns The license object.
See also KAboutLicense::LicenseKey.
KAboutLicense::LicenseKey KAboutLicense::key() const
Returns the license key.
Returns The license key as element of KAboutLicense::LicenseKey enum.
Note: Getter function for property key.
[since 5.53]
QString KAboutLicense::name(KAboutLicense::NameFormat formatName = ShortName) const
Returns the license name.
Default argument
Returns The license name as a string.
Note: Getter function for property name.
This function was introduced in 5.53.
[since 5.37]
QString KAboutLicense::spdx() const
Returns the SPDX license expression of this license. If the underlying license cannot be expressed as a SPDX expression a null string is returned.
Note: SPDX expression are expansive constructs. If you parse the return value, do it in a SPDX specification compliant manner by splitting on whitespaces to discard unwanted information or by using a complete SPDX license expression parser.
Note: SPDX identifiers are case-insensitive. Do not use case-sensitive checks on the return value.
See https://spdx.org/licenses Returns SPDX license expression or QString() if the license has no identifier. Compliant with SPDX 2.1.
Note: Getter function for property spdx.
This function was introduced in 5.37.
QString KAboutLicense::text() const
Returns the full license text. If the licenseType argument of the constructor has been used, any text defined by setLicenseText is ignored, and the standard text for the chosen license will be returned.
Returns the license text.
Note: Getter function for property text.
KAboutLicense &KAboutLicense::operator=(const KAboutLicense &other)
Assignment operator. Performs a deep copy.
other object to copy