KGameTheme Class
Describes the visual appearance of a game. More...
| Header: | #include <KGameTheme> |
| Inherits: | QObject |
Properties
|
|
Public Functions
| KGameTheme(const QByteArray &identifier, QObject *parent = nullptr) | |
| QString | author() const |
| QString | authorEmail() const |
| QString | bugReportUrl() const |
| QString | copyrightText() const |
| QMap<QString, QString> | customData() const |
| QString | customData(const QString &key, const QString &defaultValue = QString()) const |
| QString | description() const |
| QString | graphicsPath() const |
| QByteArray | identifier() const |
| QString | license() const |
| QString | name() const |
| QString | previewPath() const |
| virtual bool | readFromDesktopFile(const QString &path) |
| void | setAuthor(const QString &author) |
| void | setAuthorEmail(const QString &authorEmail) |
| void | setBugReportUrl(const QString &bugReportUrl) |
| void | setCopyrightText(const QString ©rightText) |
| void | setCustomData(const QMap<QString, QString> &customData) |
| void | setDescription(const QString &description) |
| void | setGraphicsPath(const QString &path) |
| void | setLicense(const QString &license) |
| void | setName(const QString &name) |
| void | setPreviewPath(const QString &path) |
| void | setVersion(const QString &version) |
| void | setWebsite(const QString &website) |
| QString | version() const |
| QString | website() const |
Signals
| void | readOnlyProperty() |
Detailed Description
A theme describes the visual appearance of a game. Themes in kdegames usually reference a SVGZ file which is loaded into a KGameRenderer to provide pixmaps for use on the game canvas.
Themes are usually managed (and discovered) by a KGameThemeProvider.
Default file format for theme descriptions
Although KGameTheme and KGameThemeProvider do not need special theme description files for most basic usage, there is a format for theme description files based on the XDG Desktop File Specification. The following example shows the recognized keys:
[KGameTheme]
VersionFormat=1
Name=Example
Description=This theme serves as an example.
License=CC-BY-SA-4.0
Copyright=1984 John Doe
Version=1.0
Website=https://theme.example
BugReportUrl=https://theme.example/newbugform
FileName=example.svgz
Author=John Doe
AuthorEmail=john.doe@example.com
Preview=example.png
All keys are considered optional, except perhaps for the "FileName" key: If that is not given, the theme cannot be used with KGameRenderer. The paths in "FileName" and "Preview" are resolved relative to the directory that contains the theme description file.
If the [KGameTheme] group contains any further keys, their values can be retrieved through the KGameTheme::customData() method.
Property Documentation
author : QString
This property holds the name of the theme author.
Access functions:
| QString | author() const |
| void | setAuthor(const QString &author) |
Notifier signal:
| void | readOnlyProperty() |
authorEmail : QString
This property holds the email address of the theme author
Access functions:
| QString | authorEmail() const |
| void | setAuthorEmail(const QString &authorEmail) |
Notifier signal:
| void | readOnlyProperty() |
bugReportUrl : QString
This property holds the website where people can report a bug found in this theme.
Access functions:
| QString | bugReportUrl() const |
| void | setBugReportUrl(const QString &bugReportUrl) |
Notifier signal:
| void | readOnlyProperty() |
copyrightText : QString
This property holds a short copyright statement.
Access functions:
| QString | copyrightText() const |
| void | setCopyrightText(const QString ©rightText) |
Notifier signal:
| void | readOnlyProperty() |
description : QString
This property holds an additional description beyond the name().
Access functions:
| QString | description() const |
| void | setDescription(const QString &description) |
Notifier signal:
| void | readOnlyProperty() |
graphicsPath : QString
This property holds the path of the SVG file which holds the theme contents.
Access functions:
| QString | graphicsPath() const |
| void | setGraphicsPath(const QString &path) |
Notifier signal:
| void | readOnlyProperty() |
[read-only] identifier : QByteArray
This property holds the internal identifier for this theme.
Used, for example, for finding a pixmap cache or storing a theme selection.
Access functions:
| QByteArray | identifier() const |
Notifier signal:
| void | readOnlyProperty() |
license : QString
This property holds the short license identifier, an SPDX expression.
Access functions:
| QString | license() const |
| void | setLicense(const QString &license) |
Notifier signal:
| void | readOnlyProperty() |
name : QString
This property holds the name of this theme.
Access functions:
| QString | name() const |
| void | setName(const QString &name) |
Notifier signal:
| void | readOnlyProperty() |
previewPath : QString
This property holds the path to an image file containing a preview, or an empty string if no preview file is known.
Access functions:
| QString | previewPath() const |
| void | setPreviewPath(const QString &path) |
Notifier signal:
| void | readOnlyProperty() |
version : QString
This property holds the version of the theme.
Access functions:
| QString | version() const |
| void | setVersion(const QString &version) |
Notifier signal:
| void | readOnlyProperty() |
website : QString
This property holds the website of the theme.
Access functions:
| QString | website() const |
| void | setWebsite(const QString &website) |
Notifier signal:
| void | readOnlyProperty() |
Member Function Documentation
[explicit] KGameTheme::KGameTheme(const QByteArray &identifier, QObject *parent = nullptr)
Constructs a KGameTheme with parent. The identifier must be application-unique.
QMap<QString, QString> KGameTheme::customData() const
Returns custom data.
This API is provided for theme description files which contain additional application-specific metadata.
See also setCustomData().
QString KGameTheme::customData(const QString &key, const QString &defaultValue = QString()) const
Returns the value associated with key from the customData() map, or defaultValue.
[virtual] bool KGameTheme::readFromDesktopFile(const QString &path)
Initializes a KGameTheme instance by reading a description file. Returns whether path is a valid theme description file (if not, the theme instance is not changed by this method call).
Note: A non-static member function has been chosen over the more common pattern of using a static member function like "KGameTheme::fromDesktopFile" to accommodate applications which want to subclass KGameTheme.
void KGameTheme::setCustomData(const QMap<QString, QString> &customData)
Sets the custom data to customData.
See also customData().