| 1 |
|
| 2 |
|
| 3 |
om> |
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
#ifndef KIS_ABR_BRUSH_COLLECTION_H |
| 9 |
#define KIS_ABR_BRUSH_COLLECTION_H |
| 10 |
|
| 11 |
#include <QImage> |
| 12 |
#include <QDataStream> |
| 13 |
#include <QString> |
| 14 |
#include <kis_debug.h> |
| 15 |
|
| 16 |
#include <kis_scaling_size_brush.h> |
| 17 |
#include <kis_types.h> |
| 18 |
#include <kis_shared.h> |
| 19 |
#include <brushengine/kis_paint_information.h> |
| 20 |
#include <kis_abr_brush.h> |
| 21 |
|
| 22 |
|
| 23 |
class QString; |
| 24 |
class QIODevice; |
| 25 |
|
| 26 |
|
| 27 |
struct AbrInfo; |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
class BRUSH_EXPORT KisAbrBrushCollection |
| 33 |
{ |
| 34 |
|
| 35 |
protected: |
| 36 |
|
| 37 |
public: |
| 38 |
|
| 39 |
|
| 40 |
KisAbrBrushCollection(const QString& filename); |
| 41 |
|
| 42 |
~KisAbrBrushCollection() {} |
| 43 |
|
| 44 |
bool load(); |
| 45 |
|
| 46 |
bool loadFromDevice(QIODevice *dev); |
| 47 |
|
| 48 |
bool save(); |
| 49 |
|
| 50 |
bool saveToDevice(QIODevice* dev) const; |
| 51 |
|
| 52 |
bool isLoaded() const; |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
QImage image() const; |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
QString defaultFileExtension() const; |
| 63 |
|
| 64 |
QList<KisAbrBrushSP> brushes() const { |
| 65 |
return m_abrBrushes->values(); |
| 66 |
} |
| 67 |
|
| 68 |
QSharedPointer<QMap<QString, KisAbrBrushSP>> brushesMap() const { |
| 69 |
return m_abrBrushes; |
| 70 |
} |
| 71 |
|
| 72 |
KisAbrBrushSP brushByName(QString name) const { |
| 73 |
if (m_abrBrushes->contains(name)) { |
| 74 |
return m_abrBrushes.data()->operator[](name); |
| 75 |
} |
| 76 |
return KisAbrBrushSP(); |
| 77 |
} |
| 78 |
|
| 79 |
QDateTime lastModified() const { |
| 80 |
return m_lastModified; |
| 81 |
} |
| 82 |
|
| 83 |
QString filename() const { |
| 84 |
return m_filename; |
| 85 |
} |
| 86 |
|
| 87 |
protected: |
| 88 |
KisAbrBrushCollection(const KisAbrBrushCollection& rhs); |
| 89 |
|
| 90 |
void toXML(QDomDocument& d, QDomElement& e) const; |
| 91 |
|
| 92 |
private: |
| 93 |
|
| 94 |
qint32 abr_brush_load(QDataStream & abr, AbrInfo *abr_hdr, const QString filename, qint32 image_ID, qint32 id); |
| 95 |
qint32 abr_brush_load_v12(QDataStream & abr, AbrInfo *abr_hdr, const QString filename, qint32 image_ID, qint32 id); |
| 96 |
quint32 abr_brush_load_v6(QDataStream & abr, AbrInfo *abr_hdr, const QString filename, qint32 image_ID, qint32 id); |
| 97 |
|
| 98 |
bool m_isLoaded; |
| 99 |
QDateTime m_lastModified; |
| 100 |
QString m_filename; |
| 101 |
QSharedPointer<QMap<QString, KisAbrBrushSP>> m_abrBrushes; |
| 102 |
}; |
| 103 |
|
| 104 |
typedef QSharedPointer<KisAbrBrushCollection> KisAbrBrushCollectionSP; |
| 105 |
|
| 106 |
#endif |
| 107 |
|