-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
59 lines (51 loc) · 2.17 KB
/
Copy pathmain.cpp
File metadata and controls
59 lines (51 loc) · 2.17 KB
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
#include "app/appcontroller.h"
#include <QCommandLineParser>
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQuickStyle>
#include <QTimer>
#ifndef LOGANALYZER_VERSION
#define LOGANALYZER_VERSION "0.0.0"
#endif
int main(int argc, char *argv[])
{
QGuiApplication application(argc, argv);
QCoreApplication::setApplicationName(QStringLiteral("LogAnalyzer"));
QCoreApplication::setApplicationVersion(QStringLiteral(LOGANALYZER_VERSION));
QCoreApplication::setOrganizationName(QStringLiteral("LogAnalyzer"));
QGuiApplication::setApplicationDisplayName(QStringLiteral("LogAnalyzer"));
QCommandLineParser parser;
parser.setApplicationDescription(QStringLiteral(
"Fast, portable explorer for very large text log files."));
parser.addHelpOption();
parser.addVersionOption();
const QCommandLineOption smokeTestOption(
QStringLiteral("smoke-test"),
QStringLiteral("Create the application and exit immediately."));
parser.addOption(smokeTestOption);
parser.addPositionalArgument(QStringLiteral("file"),
QStringLiteral("Local log file to open."),
QStringLiteral("[file]"));
parser.process(application);
QQuickStyle::setStyle(QStringLiteral("Basic"));
loganalyzer::AppController controller;
QQmlApplicationEngine engine;
engine.setInitialProperties({
{QStringLiteral("appController"), QVariant::fromValue(&controller)},
});
QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed,
&application, [] { QCoreApplication::exit(EXIT_FAILURE); },
Qt::QueuedConnection);
engine.loadFromModule(QStringLiteral("LogAnalyzer"), QStringLiteral("Main"));
if (engine.rootObjects().isEmpty()) {
return EXIT_FAILURE;
}
const QStringList positionalArguments = parser.positionalArguments();
if (!positionalArguments.isEmpty()) {
controller.openFile(QUrl::fromLocalFile(positionalArguments.first()));
}
if (parser.isSet(smokeTestOption)) {
QTimer::singleShot(0, &application, &QCoreApplication::quit);
}
return application.exec();
}