File indexing completed on 2025-02-23 04:05:48
0001 /* This file is part of the KDE project 0002 SPDX-FileCopyrightText: 2017 Boudewijn Rempt <boud@valdyas.org> 0003 0004 SPDX-License-Identifier: LGPL-2.1-or-later 0005 0006 */ 0007 #ifndef KOSVGSYMBOLCOLLECTIONRESOURCE 0008 #define KOSVGSYMBOLCOLLECTIONRESOURCE 0009 0010 #include <QObject> 0011 #include <QColor> 0012 #include <QVector> 0013 #include <QScopedPointer> 0014 #include <QImage> 0015 #include <QPainter> 0016 0017 #include <KoResource.h> 0018 0019 #include <KoShape.h> 0020 #include <KoShapeGroup.h> 0021 #include <KoShapeManager.h> 0022 0023 0024 #include "kritaflake_export.h" 0025 0026 struct KRITAFLAKE_EXPORT KoSvgSymbol { 0027 KoSvgSymbol() {} 0028 KoSvgSymbol(const QString &_title) 0029 : title(_title) {} 0030 0031 KoSvgSymbol(const KoSvgSymbol &rhs) 0032 : id(rhs.id), 0033 title(rhs.title), 0034 shape(rhs.shape->cloneShape()) 0035 { 0036 } 0037 0038 ~KoSvgSymbol() 0039 { 0040 delete shape; 0041 } 0042 0043 QString id; 0044 QString title; 0045 KoShape *shape {0}; 0046 QImage icon(); 0047 0048 bool operator==(const KoSvgSymbol& rhs) const { 0049 return title == rhs.title; 0050 } 0051 }; 0052 0053 /** 0054 * Loads an svg file that contains "symbol" objects and creates a collection of those objects. 0055 */ 0056 class KRITAFLAKE_EXPORT KoSvgSymbolCollectionResource : public KoResource 0057 { 0058 public: 0059 0060 /** 0061 */ 0062 explicit KoSvgSymbolCollectionResource(const QString &filename); 0063 0064 /// Create an empty color set 0065 KoSvgSymbolCollectionResource(); 0066 ~KoSvgSymbolCollectionResource() override; 0067 0068 KoSvgSymbolCollectionResource(const KoSvgSymbolCollectionResource &rhs); 0069 KoSvgSymbolCollectionResource &operator=(const KoSvgSymbolCollectionResource &rhs) = delete; 0070 KoResourceSP clone() const override; 0071 0072 bool loadFromDevice(QIODevice *dev, KisResourcesInterfaceSP resourcesInterface) override; 0073 bool saveToDevice(QIODevice* dev) const override; 0074 0075 QString defaultFileExtension() const override; 0076 0077 QPair<QString, QString> resourceType() const override 0078 { 0079 return QPair<QString, QString>(ResourceType::Symbols, ""); 0080 } 0081 0082 QString title() const; 0083 QString description() const; 0084 QString creator() const; 0085 QString rights() const; 0086 QString language() const; 0087 QStringList subjects() const; 0088 QString license() const; 0089 QStringList permits() const; 0090 0091 QVector<KoSvgSymbol *> symbols() const; 0092 0093 0094 private: 0095 0096 struct Private; 0097 const QScopedPointer<Private> d; 0098 0099 }; 0100 #endif // KOSVGSYMBOLCOLLECTIONRESOURCE 0101