1// Copyright (C) 2018 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4#ifndef QMLPREVIEWAPPLICATION_H
5#define QMLPREVIEWAPPLICATION_H
6
7#include "qmlpreviewfilesystemwatcher.h"
8
9#include <private/qqmlpreviewclient_p.h>
10#include <private/qqmldebugconnection_p.h>
11
12#include <QtCore/qcoreapplication.h>
13#include <QtCore/qprocess.h>
14#include <QtCore/qtimer.h>
15
16#include <QtNetwork/qabstractsocket.h>
17
18class QmlPreviewApplication : public QCoreApplication
19{
20 Q_OBJECT
21public:
22 QmlPreviewApplication(int &argc, char **argv);
23 ~QmlPreviewApplication();
24
25 void parseArguments();
26 int exec();
27
28private:
29 void run();
30 void tryToConnect();
31 void processHasOutput();
32 void processFinished();
33
34 void logError(const QString &error);
35 void logStatus(const QString &status);
36
37 void serveRequest(const QString &request);
38 bool sendFile(const QString &path);
39 void sendDirectory(const QString &path);
40
41 QString m_executablePath;
42 QStringList m_arguments;
43 QScopedPointer<QProcess> m_process;
44 bool m_verbose;
45
46 QString m_socketFile;
47
48 QScopedPointer<QQmlDebugConnection> m_connection;
49 QScopedPointer<QQmlPreviewClient> m_qmlPreviewClient;
50 QmlPreviewFileSystemWatcher m_watcher;
51
52 QTimer m_loadTimer;
53 QTimer m_connectTimer;
54 uint m_connectionAttempts;
55};
56
57#endif // QMLPREVIEWAPPLICATION_H
58

source code of qtdeclarative/tools/qmlpreview/qmlpreviewapplication.h