Krita

Resource.h
1 /*
2  * SPDX-FileCopyrightText: 2016 Boudewijn Rempt <[email protected]>
3  *
4  * SPDX-License-Identifier: LGPL-2.0-or-later
5  */
6 #ifndef LIBKIS_RESOURCE_H
7 #define LIBKIS_RESOURCE_H
8 
9 #include <QObject>
10 #include <QScopedPointer>
11 #include <kis_types.h>
12 #include "kritalibkis_export.h"
13 #include "libkis.h"
14 #include <KoResource.h>
15 
16 /**
17  * A Resource represents a gradient, pattern, brush tip, brush preset, palette or
18  * workspace definition.
19  *
20  * @code
21  * allPresets = Application.resources("preset")
22  * for preset in allPresets:
23  * print(preset.name())
24  * @endcode
25  *
26  * Resources are identified by their type, name and filename. If you want to change
27  * the contents of a resource, you should read its data using data(), parse it and
28  * write the changed contents back.
29  */
30 class KRITALIBKIS_EXPORT Resource : public QObject
31 {
32  Q_OBJECT
33 
34 public:
35  Resource(int resourceId, const QString &type, const QString &name, const QString &filename, const QImage &image, QObject *parent = 0);
36  Resource(KoResourceSP resource, const QString &type, QObject *parent = 0);
37  ~Resource() override;
38  Resource(const Resource &rhs);
39 
40  bool operator==(const Resource &other) const;
41  bool operator!=(const Resource &other) const;
42  Resource operator=(const Resource &rhs);
43 
44 
45 public Q_SLOTS:
46 
47  /**
48  * Return the type of this resource. Valid types are:
49  * <ul>
50  * <li>pattern: a raster image representing a pattern
51  * <li>gradient: a gradient
52  * <li>brush: a brush tip
53  * <li>preset: a brush preset
54  * <li>palette: a color set
55  * <li>workspace: a workspace definition.
56  * </ul>
57  */
58  QString type() const;
59 
60  /**
61  * The user-visible name of the resource.
62  */
63  QString name() const;
64 
65  /**
66  * setName changes the user-visible name of the current resource.
67  */
68  void setName(QString value);
69 
70  /**
71  * The filename of the resource, if present. Not all resources
72  * are loaded from files.
73  */
74  QString filename() const;
75 
76  /**
77  * An image that can be used to represent the resource in the
78  * user interface. For some resources, like patterns, the
79  * image is identical to the resource, for others it's a mere
80  * icon.
81  */
82  QImage image() const;
83 
84  /**
85  * Change the image for this resource.
86  */
87  void setImage(QImage image);
88 
89 private:
90 
91  friend class PresetChooser;
92  friend class View;
93  friend class Palette;
94  friend class Preset;
95  KoResourceSP resource() const;
96 
97  struct Private;
99 
100 };
101 
102 #endif // LIBKIS_RESOURCE_H
Q_SLOTSQ_SLOTS
The Palette class Palette is a resource object that stores organised color data.
Definition: Palette.h:45
A Resource represents a gradient, pattern, brush tip, brush preset, palette or workspace definition.
Definition: Resource.h:30
The PresetChooser widget wraps the KisPresetChooser widget.
Definition: PresetChooser.h:25
View represents one view on a document.
Definition: View.h:24
The Preset class Preset is a resource object that stores brush preset data.
Definition: Preset.h:34
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sat Sep 30 2023 03:58:47 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.