1 #pragma once
2 
3 #ifndef STYLEMANAGER_H
4 #define STYLEMANAGER_H
5 
6 #include "tfilepath.h"
7 #include "tthread.h"
8 
9 #include <QSize>
10 #include <QList>
11 #include <QString>
12 
13 #undef DVAPI
14 #undef DVVAR
15 #ifdef TOONZLIB_EXPORTS
16 #define DVAPI DV_EXPORT_API
17 #define DVVAR DV_EXPORT_VAR
18 #else
19 #define DVAPI DV_IMPORT_API
20 #define DVVAR DV_IMPORT_VAR
21 #endif
22 
23 //-------------------------------------------------------------------------
24 
25 //  Forward declarations
26 class QImage;
27 
28 //-------------------------------------------------------------------------
29 
30 //********************************************************************************
31 //    CustomStyleManager declaration
32 //********************************************************************************
33 
34 class DVAPI CustomStyleManager final : public QObject {
35   Q_OBJECT
36 
37 public:
38   struct DVAPI PatternData {
39     QImage *m_image;
40     std::string m_patternName;
41     bool m_isVector;
42 
PatternDataPatternData43     PatternData() : m_image(0), m_patternName(""), m_isVector(false) {}
44   };
45 
46   class StyleLoaderTask;
47   friend class CustomStyleManager::StyleLoaderTask;
48 
49 private:
50   QList<PatternData> m_patterns;
51   TFilePath m_rootPath;
52   TFilePath m_stylesFolder;
53   QString m_filters;
54   QSize m_chipSize;
55 
56   TThread::Executor m_executor;
57   bool m_started;
58 
59 public:
60   CustomStyleManager(const TFilePath &stylesFolder, QString filters = QString(),
61                      QSize chipSize = QSize(30, 30));
62 
stylesFolder()63   const TFilePath &stylesFolder() const { return m_stylesFolder; }
getChipSize()64   QSize getChipSize() const { return m_chipSize; }
65 
66   int getPatternCount();
67   PatternData getPattern(int index);
68 
69   static TFilePath getRootPath();
70   static void setRootPath(const TFilePath &rootPath);
71 
72   void loadItems();
73 
74 private:
75   void addPattern(const TFilePath &path);
76 
77 signals:
78 
79   void patternAdded();
80 };
81 
82 #endif  // STYLEMANAGER_H
83