Subversion Repositories tpanel

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
22 andreas 1
/*
2
 * Copyright (C) 2021 by Andreas Theofilu <andreas@theosys.at>
3
 *
4
 * This program is free software; you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation; either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program; if not, write to the Free Software Foundation,
16
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
17
 */
18
 
19
#include <iostream>
20
#include <fstream>
21
 
22
#include <QFile>
23
 
24
#include "ttpinit.h"
25
#include "terror.h"
26
 
27
using std::string;
28
using std::ostream;
29
 
30
TTPInit::TTPInit(const string& path)
31
    : mPath(path)
32
{
33
    DECL_TRACER("TTPInit::TTPInit(const string& path)")
34
 
35
    createPanelConfigs();
36
}
37
 
38
bool TTPInit::createPanelConfigs()
39
{
40
    DECL_TRACER("TTPInit::createPanelConfigs()");
41
 
42
    bool err = false;
43
    QFile external(":ressources/external.xma");
44
 
45
    if (external.exists())
46
    {
47
        QString path = mPath.c_str();
48
        path += "/external.xma";
49
 
50
        if (!external.copy(path))
51
        {
52
            MSG_ERROR("Could not copy \"external.xma\" to " << path.data());
53
            err = true;
54
        }
55
    }
56
    else
57
    {
58
        MSG_ERROR("File " << external.fileName().data() << " doesn't exist!");
59
        err = true;
60
    }
61
 
62
    QFile fnt(":ressources/fnt.xma");
63
 
64
    if (fnt.exists())
65
    {
66
        QString path = mPath.c_str();
67
        path += "/fnt.xma";
68
 
69
        if (!fnt.copy(path))
70
        {
71
            MSG_ERROR("Could not copy \"fnt.xma\" to " << path.data());
72
            err = true;
73
        }
74
    }
75
    else
76
    {
77
        MSG_ERROR("File " << fnt.fileName().data() << " doesn't exist!");
78
        err = true;
79
    }
80
 
81
    QFile icon(":ressources/icon.xma");
82
 
83
    if (icon.exists())
84
    {
85
        QString path = mPath.c_str();
86
        path += "/icon.xma";
87
 
88
        if (!icon.copy(path))
89
        {
90
            MSG_ERROR("Could not copy \"icon.xma\" to " << path.data());
91
            err = true;
92
        }
93
    }
94
    else
95
    {
96
        MSG_ERROR("File " << icon.fileName().data() << " doesn't exist!");
97
        err = true;
98
    }
99
 
100
    QFile _main(":ressources/_main.xml");
101
 
102
    if (_main.exists())
103
    {
104
        QString path = mPath.c_str();
105
        path += "/_main.xml";
106
 
107
        if (!_main.copy(path))
108
        {
109
            MSG_ERROR("Could not copy \"_main.xml\" to " << path.data());
110
            err = true;
111
        }
112
    }
113
    else
114
    {
115
        MSG_ERROR("File " << _main.fileName().data() << " doesn't exist!");
116
        err = true;
117
    }
118
 
119
    QFile manifest(":ressources/manifest.xma");
120
 
121
    if (manifest.exists())
122
    {
123
        QString path = mPath.c_str();
124
        path += "/manifest.xma";
125
 
126
        if (!manifest.copy(path))
127
        {
128
            MSG_ERROR("Could not copy \"manifest.xma\" to " << path.data());
129
            err = true;
130
        }
131
    }
132
    else
133
    {
134
        MSG_ERROR("File " << manifest.fileName().data() << " doesn't exist!");
135
        err = true;
136
    }
137
 
138
    QFile map(":ressources/map.xma");
139
 
140
    if (map.exists())
141
    {
142
        QString path = mPath.c_str();
143
        path += "/map.xma";
144
 
145
        if (!map.copy(path))
146
        {
147
            MSG_ERROR("Could not copy \"map.xma\" to " << path.data());
148
            err = true;
149
        }
150
    }
151
    else
152
    {
153
        MSG_ERROR("File " << map.fileName().data() << " doesn't exist!");
154
        err = true;
155
    }
156
 
157
    QFile pal(":ressources/pal_001.xma");
158
 
159
    if (pal.exists())
160
    {
161
        QString path = mPath.c_str();
162
        path += "/pal_001.xma";
163
 
164
        if (!pal.copy(path))
165
        {
166
            MSG_ERROR("Could not copy \"pal_001.xma\" to " << path.data());
167
            err = true;
168
        }
169
    }
170
    else
171
    {
172
        MSG_ERROR("File " << pal.fileName().data() << " doesn't exist!");
173
        err = true;
174
    }
175
 
176
    QFile prj(":ressources/prj.xma");
177
 
178
    if (prj.exists())
179
    {
180
        QString path = mPath.c_str();
181
        path += "/prj.xma";
182
 
183
        if (!prj.copy(path))
184
        {
185
            MSG_ERROR("Could not copy \"prj.xma\" to " << path.data());
186
            err = true;
187
        }
188
    }
189
    else
190
    {
191
        MSG_ERROR("File " << prj.fileName().data() << " doesn't exist!");
192
        err = true;
193
    }
194
 
195
    QFile _setup(":ressources/_setup.xml");
196
 
197
    if (_setup.exists())
198
    {
199
        QString path = mPath.c_str();
200
        path += "/_setup.xml";
201
 
202
        if (!_setup.copy(path))
203
        {
204
            MSG_ERROR("Could not copy \"_setup.xml\" to " << path.data());
205
            err = true;
206
        }
207
    }
208
    else
209
    {
210
        MSG_ERROR("File " << _setup.fileName().data() << " doesn't exist!");
211
        err = true;
212
    }
213
 
214
    QFile table(":ressources/table.xma");
215
 
216
    if (table.exists())
217
    {
218
        QString path = mPath.c_str();
219
        path += "/table.xma";
220
 
221
        if (!table.copy(path))
222
        {
223
            MSG_ERROR("Could not copy \"table.xma\" to " << path.data());
224
            err = true;
225
        }
226
    }
227
    else
228
    {
229
        MSG_ERROR("File " << table.fileName().data() << " doesn't exist!");
230
        err = true;
231
    }
232
 
233
    QFile fonts(":ressources/fonts/arial.ttf");
234
 
235
    if (fonts.exists())
236
    {
237
        QString path = mPath.c_str();
238
        path += "/fonts/arial.ttf";
239
 
240
        if (!fonts.copy(path))
241
        {
242
            MSG_ERROR("Could not copy \"arial.ttf\" to " << path.data());
243
            err = true;
244
        }
245
    }
246
    else
247
    {
248
        MSG_ERROR("File " << fonts.fileName().data() << " doesn't exist!");
249
        err = true;
250
    }
251
 
252
    QFile images(":ressources/images/theosys_logo.png");
253
 
254
    if (images.exists())
255
    {
256
        QString path = mPath.c_str();
257
        path += "/images/theosys_logo.png";
258
 
259
        if (!images.copy(path))
260
        {
261
            MSG_ERROR("Could not copy \"theosys_logo.png\" to " << path.data());
262
            err = true;
263
        }
264
    }
265
    else
266
    {
267
        MSG_ERROR("File " << images.fileName().data() << " doesn't exist!");
268
        err = true;
269
    }
270
 
271
    return err;
272
}