KSvg::ImageSet Class

class KSvg::ImageSet

Interface to the Svg image set. More...

Header: #include <KSvg/ImageSet>
CMake: find_package(KF6 REQUIRED COMPONENTS Svg)
target_link_libraries(mytarget PRIVATE KF6::Svg)
Inherits: QObject

Properties

Public Functions

ImageSet(QObject *parent = nullptr)
ImageSet(const QString &imageSetName, const QString &basePath = {}, QObject *parent = nullptr)
QString basePath() const
bool currentImageSetHasImage(const QString &name) const
QString filePath(const QString &name) const
QString imagePath(const QString &name) const
QString imageSetName() const
QStringList selectors() const
void setBasePath(const QString &basePath)
void setImageSetName(const QString &imageSetName)
void setSelectors(const QStringList &selectors)

Signals

void basePathChanged(const QString &basePath)
void imageSetChanged(const QString &basePath)

Detailed Description

KSvg::ImageSet provides access to a common and standardized set of graphic elements stored in SVG format. This allows artists to create single packages of SVGs that will affect the look and feel of all workspace components.

KSvg::Svg uses KSvg::ImageSet internally to locate and load the appropriate SVG data. Alternatively, KSvg::ImageSet can be used directly to retrieve file system paths to SVGs by name.

Property Documentation

basePath : QString

Access functions:

QString basePath() const
void setBasePath(const QString &basePath)

Notifier signal:

void imageSetChanged(const QString &basePath)

imageSetName : QString

Access functions:

QString imageSetName() const
void setImageSetName(const QString &imageSetName)

Notifier signal:

void imageSetChanged(const QString &basePath)

Member Function Documentation

[explicit] ImageSet::ImageSet(QObject *parent = nullptr)

Default constructor.

parent the parent object

[explicit] ImageSet::ImageSet(const QString &imageSetName, const QString &basePath = {}, QObject *parent = nullptr)

This method constructs a theme which will be a custom theme instance of imageSetName.

imageSetName the name of the theme to create basePath base path for the theme to look for svgs. if empty, the default will be used. parent the parent object

QString ImageSet::basePath() const

This method returns the base path of the theme where the SVGs will be looked for.

Note: Getter function for property basePath.

See also setBasePath().

[signal] void ImageSet::basePathChanged(const QString &basePath)

This signal is emitted when the user changes the base path of the image set.

bool ImageSet::currentImageSetHasImage(const QString &name) const

This method checks whether this theme contains an image with the given name.

name the name of the file in the theme directory (without the ".svg" part or a leading slash)

Returns true if the image exists for this theme

QString ImageSet::filePath(const QString &name) const

This method returns the path for a generic file in the current theme.

The theme can also ship any generic file, such as configuration files.

name the name of the file in the theme directory (without a leading slash)

Returns the full path to the requested file for the current theme

QString ImageSet::imagePath(const QString &name) const

This method returns the path for an SVG image in the current theme.

name the name of the file in the theme directory (without the ".svg" part or a leading slash).

Returns the full path to the requested file for the current theme

[signal] void ImageSet::imageSetChanged(const QString &basePath)

This signal is emitted when the user makes changes to the theme.

Rendered images, colors, etc. should be updated at this point. However, SVGs should *not* be repainted in response to this signal; connect to Svg::repaintNeeded() instead for that, as SVG objects need repainting not only when imageSetChanged() is emitted; moreover SVG objects connect to and respond appropriately to imageSetChanged() internally, emitting Svg::repaintNeeded() at an appropriate time.

Note: Notifier signal for properties basePath and imageSetName.

QString ImageSet::imageSetName() const

This method returns the name of the current theme.

Note: Getter function for property imageSetName.

See also setImageSetName().

QStringList ImageSet::selectors() const

This method returns the current selectors in order of preference.

See also setSelectors().

void ImageSet::setBasePath(const QString &basePath)

This method sets a base path for the theme to look for SVGs.

It can be a path relative to QStandardPaths::GenericDataLocation or an absolute path.

basePath the base path

Note: Setter function for property basePath.

See also basePath().

void ImageSet::setImageSetName(const QString &imageSetName)

This method sets the current theme.

Note: Setter function for property imageSetName.

See also imageSetName().

void ImageSet::setSelectors(const QStringList &selectors)

This method sets the file selectors.

The theme can have different svgs with the same name for different situations and platforms. The Plasma desktop for instance uses "opaque" or "translucent" based on presence of compositing and KWin blur effects. Other uses may be platform, like android-specific graphics.

selectors selectors in order of preference

See also selectors().