-
Notifications
You must be signed in to change notification settings - Fork 849
/
Copy pathfapplication.h
242 lines (201 loc) · 6.26 KB
/
fapplication.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
/*******************************************************************
Part of the Fritzing project - http://fritzing.org
Copyright (c) 2007-2019 Fritzing
Fritzing is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Fritzing is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fritzing. If not, see <http://www.gnu.org/licenses/>.
********************************************************************/
#ifndef FAPPLICATION_H
#define FAPPLICATION_H
#include <QApplication>
#include <QTranslator>
#include <QPixmap>
#include <QFileDialog>
#include <QPointer>
#include <QWidget>
#include <QTimer>
#include <QTcpServer>
#include <QTcpSocket>
#include <QMutex>
#include <QThread>
#include <QNetworkReply>
#include <QNetworkAccessManager>
#include "referencemodel/referencemodel.h"
class FileProgressDialog;
class FServer : public QTcpServer
{
Q_OBJECT
public:
FServer(QObject *parent = 0);
signals:
void newConnection(qintptr socketDescriptor);
protected:
void incomingConnection(qintptr socketDescriptor);
};
class FServerThread : public QThread
{
Q_OBJECT
public:
FServerThread(qintptr socketDescriptor, QObject *parent);
void run();
void setDone();
signals:
void error(QTcpSocket::SocketError socketError);
void doCommand(const QString & command, const QString & params, QString & result, int & status);
protected:
void writeResponse(QTcpSocket *, int code, const QString & codeString, const QString & mimeType, const QString & message);
protected:
int m_socketDescriptor = 0;
bool m_done = false;
protected:
static QMutex m_busy;
};
////////////////////////////////////////////////////
class RegenerateDatabaseThread : public QThread
{
Q_OBJECT
public:
RegenerateDatabaseThread(const QString & dbFileName, QDialog *progressDialog, ReferenceModel *referenceModel);
const QString error() const;
QDialog * progressDialog() const;
ReferenceModel * referenceModel() const;
protected:
void run() Q_DECL_OVERRIDE;
protected:
QString m_dbFileName;
QString m_error;
QDialog * m_progressDialog = nullptr;
ReferenceModel * m_referenceModel = nullptr;
};
////////////////////////////////////////////////////
class FApplication : public QApplication
{
Q_OBJECT
public:
FApplication(int & argc, char ** argv);
~FApplication(void);
public:
int init();
int startup();
int serviceStartup();
void finish();
bool loadReferenceModel(const QString & databaseName, bool fullLoad);
bool loadReferenceModel(const QString & databaseName, bool fullLoad, ReferenceModel * referenceModel);
void registerFonts();
class MainWindow * openWindowForService(bool lockFiles, int initialTab);
bool runAsService();
public:
static bool spaceBarIsPressed();
signals:
void spaceBarIsPressedSignal(bool);
public slots:
void preferences();
void preferencesAfter();
void checkForUpdates();
void checkForUpdates(bool atUserRequest);
void enableCheckUpdates(bool enabled);
void createUserDataStoreFolderStructures();
void changeActivation(bool activate, QWidget * originator);
void updateActivation();
void topLevelWidgetDestroyed(QObject *);
void closeAllWindows2();
void loadedPart(int loaded, int total);
void externalProcessSlot(QString & name, QString & path, QStringList & args);
void gotOrderFab(QNetworkReply *);
void newConnection(qintptr socketDescriptor);
void doCommand(const QString & command, const QString & params, QString & result, int & status);
void regeneratePartsDatabase();
void regenerateDatabaseFinished();
void installNewParts();
protected:
bool eventFilter(QObject *obj, QEvent *event);
bool event(QEvent *event);
bool findTranslator(const QString & translationsPath);
void loadNew(QString path);
void loadOne(class MainWindow *, QString path, int loaded);
void initSplash(class FSplashScreen & splash);
void registerFont(const QString &fontFile, bool reallyRegister);
void clearModels();
bool notify(QObject *receiver, QEvent *e);
void initService();
void runDRCService();
void runGedaService();
void runDatabaseService();
void runKicadFootprintService();
void runKicadSchematicService();
void runGerberService();
void runGerberServiceAux();
void runSvgService();
void runSvgServiceAux();
void runPanelizerService();
void runInscriptionService();
void runExampleService();
void runExampleService(QDir &);
QList<class MainWindow *> recoverBackups();
QList<MainWindow *> loadLastOpenSketch();
void doLoadPrevious(MainWindow *);
void loadSomething(const QString & previousVersion);
void initFilesToLoad();
void initBackups();
void cleanupBackups();
void updatePrefs(class PrefsDialog & prefsDialog);
QList<MainWindow *> orderedTopLevelMainWindows();
void cleanFzzs();
void initServer();
void regeneratePartsDatabaseAux(QDialog * progressDialog);
enum ServiceType {
PanelizerService = 1,
InscriptionService,
GerberService,
GedaService,
KicadSchematicService,
KicadFootprintService,
ExampleService,
DatabaseService,
SvgService,
PortService,
DRCService,
NoService
};
protected:
bool m_spaceBarIsPressed = false;
bool m_mousePressed = false;
QTranslator m_translator;
ReferenceModel * m_referenceModel = nullptr;
bool m_started = false;
QStringList m_filesToLoad;
QString m_libPath;
QString m_translationPath;
class UpdateDialog * m_updateDialog = nullptr;
QTimer m_activationTimer;
QPointer<class FritzingWindow> m_lastTopmostWindow;
QList<QWidget *> m_orderedTopLevelWidgets;
QStringList m_arguments;
QStringList m_externalProcessArgs;
QString m_externalProcessName;
QString m_externalProcessPath;
ServiceType m_serviceType = NoService;
int m_progressIndex = 0;
class FSplashScreen * m_splash = nullptr;
QString m_outputFolder;
QString m_portRootFolder;
QString m_panelFilename;
QHash<QString, struct LockedFile *> m_lockedFiles;
bool m_panelizerCustom = false;
int m_portNumber = 0;
FServer * m_fServer = nullptr;
QString m_buildType;
};
enum FInitResult {
FInitResultNormal,
FInitResultHelp,
FInitResultVersion
};
#endif