KSvg::ImageSet Class
class KSvg::ImageSetInterface to the Svg image set. More...
Header: | #include <ImageSet> |
CMake: | find_package(KF6 REQUIRED COMPONENTS Svg) target_link_libraries(mytarget PRIVATE KF6::Svg) |
Inherits: | QObject |
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 |
KPluginMetaData | metadata() const |
QStringList | selectors() const |
void | setBasePath(const QString &basePath) |
void | setCacheLimit(int kbytes) |
void | setImageSetName(const QString &imageSetName) |
void | setSelectors(const QStringList &selectors) |
void | setUseGlobalSettings(bool useGlobal) |
bool | useGlobalSettings() const |
Signals
void | basePathChanged(const QString &basePath) |
void | imageSetChanged(const QString &basePath) |
Related Non-Members
Svg(QObject *parent = nullptr) |
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.
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 property basePath. Notifier signal for property imageSetName. Notifier signal for property useGlobalSettings.
QString ImageSet::imageSetName() const
This method returns the name of the current theme.
Note: Getter function for property imageSetName.
See also setImageSetName().
KPluginMetaData ImageSet::metadata() const
This method returns the plugin metadata for this theme.
Metadata contains information such as name, description, author, website, and url.
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::setCacheLimit(int kbytes)
This method sets the maximum size of the cache (in kilobytes).
If cache gets bigger than the limit, then some entries are removed. Setting cache limit to 0 disables automatic cache size limiting.
Note that the cleanup might not be done immediately, so the cache might temporarily (for a few seconds) grow bigger than the limit.
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().
void ImageSet::setUseGlobalSettings(bool useGlobal)
This method sets whether the theme should follow the global settings or use application-specific settings.
useGlobal pass in true to follow the global settings
See also useGlobalSettings().
bool ImageSet::useGlobalSettings() const
This method returns whether the global settings are followed.
If application-specific settings are being used, it returns false
.
Note: Getter function for property useGlobalSettings.
See also setUseGlobalSettings().
Related Non-Members
[explicit]
Svg(QObject *parent = nullptr)
This method constructs an SVG object that implicitly shares and caches rendering.
Unlike QSvgRenderer, which this class uses internally, KSvg::Svg represents an image generated from an SVG. As such, it has a related size and transform matrix (the latter being provided by the painter used to paint the image).
The size is initialized to be the SVG's native size.
parent options QObject to parent this to