2022-10-04 20:25:14 +00:00
|
|
|
#include <QGuiApplication>
|
|
|
|
#include <QQmlApplicationEngine>
|
2022-10-25 13:57:04 +00:00
|
|
|
#include <QtWebEngine>
|
2022-10-04 20:25:14 +00:00
|
|
|
|
2022-10-18 18:47:41 +00:00
|
|
|
#include <cachecleaner.h>
|
|
|
|
#include <directorieswatcher.h>
|
2022-10-04 20:25:14 +00:00
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
|
|
|
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
|
|
|
#endif
|
2022-10-25 13:57:04 +00:00
|
|
|
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
|
|
|
QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
|
|
|
|
QtWebEngine::initialize();
|
2022-10-04 20:25:14 +00:00
|
|
|
QGuiApplication app(argc, argv);
|
2022-10-20 15:12:38 +00:00
|
|
|
QGuiApplication::setOrganizationName(QStringLiteral("Status"));
|
|
|
|
QGuiApplication::setOrganizationDomain(QStringLiteral("status.im"));
|
|
|
|
QGuiApplication::setApplicationName(QStringLiteral("Status Desktop Storybook"));
|
|
|
|
|
|
|
|
qputenv("QT_QUICK_CONTROLS_HOVER_ENABLED", QByteArrayLiteral("1"));
|
2022-10-04 20:25:14 +00:00
|
|
|
|
|
|
|
QQmlApplicationEngine engine;
|
|
|
|
|
2022-10-19 19:51:39 +00:00
|
|
|
const QStringList additionalImportPaths {
|
2022-10-18 18:47:41 +00:00
|
|
|
SRC_DIR + QStringLiteral("/../ui/StatusQ/src"),
|
|
|
|
SRC_DIR + QStringLiteral("/../ui/app"),
|
|
|
|
SRC_DIR + QStringLiteral("/../ui/imports"),
|
|
|
|
SRC_DIR + QStringLiteral("/src"),
|
|
|
|
SRC_DIR + QStringLiteral("/pages"),
|
|
|
|
SRC_DIR + QStringLiteral("/stubs"),
|
|
|
|
SRC_DIR + QStringLiteral("/mocks"),
|
|
|
|
};
|
2022-10-04 20:25:14 +00:00
|
|
|
|
2022-10-20 15:12:38 +00:00
|
|
|
for (const auto& path : additionalImportPaths)
|
2022-10-18 18:47:41 +00:00
|
|
|
engine.addImportPath(path);
|
|
|
|
|
|
|
|
auto watcherFactory = [additionalImportPaths](QQmlEngine*, QJSEngine*) {
|
|
|
|
auto watcher = new DirectoriesWatcher();
|
|
|
|
watcher->addPaths(additionalImportPaths);
|
|
|
|
return watcher;
|
|
|
|
};
|
|
|
|
|
|
|
|
qmlRegisterSingletonType<DirectoriesWatcher>(
|
|
|
|
"Storybook", 1, 0, "SourceWatcher", watcherFactory);
|
|
|
|
|
|
|
|
auto cleanerFactory = [](QQmlEngine* engine, QJSEngine*) {
|
|
|
|
return new CacheCleaner(engine);
|
|
|
|
};
|
|
|
|
|
|
|
|
qmlRegisterSingletonType<CacheCleaner>(
|
|
|
|
"Storybook", 1, 0, "CacheCleaner", cleanerFactory);
|
|
|
|
|
|
|
|
const QUrl url(SRC_DIR + QStringLiteral("/main.qml"));
|
2022-10-04 20:25:14 +00:00
|
|
|
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
|
|
|
|
&app, [url](QObject *obj, const QUrl &objUrl) {
|
|
|
|
if (!obj && url == objUrl)
|
|
|
|
QCoreApplication::exit(-1);
|
|
|
|
}, Qt::QueuedConnection);
|
|
|
|
engine.load(url);
|
|
|
|
|
2022-10-13 14:32:20 +00:00
|
|
|
return QGuiApplication::exec();
|
2022-10-04 20:25:14 +00:00
|
|
|
}
|