1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the Qt Designer of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT |
21 | ** included in the packaging of this file. Please review the following |
22 | ** information to ensure the GNU General Public License requirements will |
23 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
24 | ** |
25 | ** $QT_END_LICENSE$ |
26 | ** |
27 | ****************************************************************************/ |
28 | |
29 | // |
30 | // W A R N I N G |
31 | // ------------- |
32 | // |
33 | // This file is not part of the Qt API. It exists for the convenience |
34 | // of Qt Designer. This header |
35 | // file may change from version to version without notice, or even be removed. |
36 | // |
37 | // We mean it. |
38 | // Note: This is a copy of qtbase/src/tools/rcc/rcc.h. |
39 | |
40 | #ifndef RCC_H |
41 | #define RCC_H |
42 | |
43 | #include <QtCore/qstringlist.h> |
44 | #include <QtCore/qhash.h> |
45 | #include <QtCore/qstring.h> |
46 | |
47 | QT_BEGIN_NAMESPACE |
48 | |
49 | class RCCFileInfo; |
50 | class QIODevice; |
51 | class QTextStream; |
52 | |
53 | |
54 | class RCCResourceLibrary |
55 | { |
56 | RCCResourceLibrary(const RCCResourceLibrary &); |
57 | RCCResourceLibrary &operator=(const RCCResourceLibrary &); |
58 | |
59 | public: |
60 | RCCResourceLibrary(); |
61 | ~RCCResourceLibrary(); |
62 | |
63 | bool output(QIODevice &out, QIODevice &errorDevice); |
64 | |
65 | bool readFiles(bool ignoreErrors, QIODevice &errorDevice); |
66 | |
67 | enum Format { Binary, C_Code }; |
68 | void setFormat(Format f) { m_format = f; } |
69 | Format format() const { return m_format; } |
70 | |
71 | void setInputFiles(const QStringList &files) { m_fileNames = files; } |
72 | QStringList inputFiles() const { return m_fileNames; } |
73 | |
74 | QStringList dataFiles() const; |
75 | |
76 | // Return a map of resource identifier (':/newPrefix/images/p1.png') to file. |
77 | typedef QHash<QString, QString> ResourceDataFileMap; |
78 | ResourceDataFileMap resourceDataFileMap() const; |
79 | |
80 | void setVerbose(bool b) { m_verbose = b; } |
81 | bool verbose() const { return m_verbose; } |
82 | |
83 | void setInitName(const QString &name) { m_initName = name; } |
84 | QString initName() const { return m_initName; } |
85 | |
86 | void setCompressLevel(int c) { m_compressLevel = c; } |
87 | int compressLevel() const { return m_compressLevel; } |
88 | |
89 | void setCompressThreshold(int t) { m_compressThreshold = t; } |
90 | int compressThreshold() const { return m_compressThreshold; } |
91 | |
92 | void setResourceRoot(const QString &root) { m_resourceRoot = root; } |
93 | QString resourceRoot() const { return m_resourceRoot; } |
94 | |
95 | void setUseNameSpace(bool v) { m_useNameSpace = v; } |
96 | bool useNameSpace() const { return m_useNameSpace; } |
97 | |
98 | QStringList failedResources() const { return m_failedResources; } |
99 | |
100 | private: |
101 | struct Strings { |
102 | Strings(); |
103 | const QString TAG_RCC; |
104 | const QString TAG_RESOURCE; |
105 | const QString TAG_FILE; |
106 | const QString ATTRIBUTE_LANG; |
107 | const QString ATTRIBUTE_PREFIX; |
108 | const QString ATTRIBUTE_ALIAS; |
109 | const QString ATTRIBUTE_THRESHOLD; |
110 | const QString ATTRIBUTE_COMPRESS; |
111 | }; |
112 | friend class RCCFileInfo; |
113 | void reset(); |
114 | bool addFile(const QString &alias, const RCCFileInfo &file); |
115 | bool interpretResourceFile(QIODevice *inputDevice, const QString &file, |
116 | QString currentPath = QString(), bool ignoreErrors = false); |
117 | bool (); |
118 | bool writeDataBlobs(); |
119 | bool writeDataNames(); |
120 | bool writeDataStructure(); |
121 | bool writeInitializer(); |
122 | void writeMangleNamespaceFunction(const QByteArray &name); |
123 | void writeAddNamespaceFunction(const QByteArray &name); |
124 | void writeHex(quint8 number); |
125 | void writeNumber2(quint16 number); |
126 | void writeNumber4(quint32 number); |
127 | void writeChar(char c) { m_out.append(c); } |
128 | void writeByteArray(const QByteArray &); |
129 | void write(const char *, int len); |
130 | |
131 | const Strings m_strings; |
132 | RCCFileInfo *m_root; |
133 | QStringList m_fileNames; |
134 | QString m_resourceRoot; |
135 | QString m_initName; |
136 | Format m_format; |
137 | bool m_verbose; |
138 | int m_compressLevel; |
139 | int m_compressThreshold; |
140 | int m_treeOffset; |
141 | int m_namesOffset; |
142 | int m_dataOffset; |
143 | bool m_useNameSpace; |
144 | QStringList m_failedResources; |
145 | QIODevice *m_errorDevice; |
146 | QByteArray m_out; |
147 | }; |
148 | |
149 | QT_END_NAMESPACE |
150 | |
151 | #endif // RCC_H |
152 | |