2022-10-04 22:25:14 +02:00
|
|
|
#include <QGuiApplication>
|
|
|
|
#include <QQmlApplicationEngine>
|
2022-11-17 08:17:03 +02:00
|
|
|
|
2022-11-16 14:40:29 +01:00
|
|
|
#include "cachecleaner.h"
|
|
|
|
#include "directorieswatcher.h"
|
2022-11-25 16:41:50 +01:00
|
|
|
#include "figmadecoratormodel.h"
|
|
|
|
#include "figmalinks.h"
|
|
|
|
#include "figmalinkssource.h"
|
2022-11-16 14:40:29 +01:00
|
|
|
#include "sectionsdecoratormodel.h"
|
2022-10-04 22:25:14 +02: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 09:57:04 -04:00
|
|
|
QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
|
2022-11-25 14:02:48 +01:00
|
|
|
|
2022-10-04 22:25:14 +02:00
|
|
|
QGuiApplication app(argc, argv);
|
2022-10-20 17:12:38 +02: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 22:25:14 +02:00
|
|
|
|
|
|
|
QQmlApplicationEngine engine;
|
|
|
|
|
2022-10-19 21:51:39 +02:00
|
|
|
const QStringList additionalImportPaths {
|
2022-11-17 08:17:03 +02:00
|
|
|
QML_IMPORT_ROOT + QStringLiteral("/../ui/StatusQ/src"),
|
|
|
|
QML_IMPORT_ROOT + QStringLiteral("/../ui/app"),
|
|
|
|
QML_IMPORT_ROOT + QStringLiteral("/../ui/imports"),
|
|
|
|
QML_IMPORT_ROOT + QStringLiteral("/src"),
|
|
|
|
QML_IMPORT_ROOT + QStringLiteral("/pages"),
|
|
|
|
QML_IMPORT_ROOT + QStringLiteral("/stubs"),
|
|
|
|
QML_IMPORT_ROOT + QStringLiteral("/mocks"),
|
2022-10-18 20:47:41 +02:00
|
|
|
};
|
2022-10-04 22:25:14 +02:00
|
|
|
|
2022-10-20 17:12:38 +02:00
|
|
|
for (const auto& path : additionalImportPaths)
|
2022-10-18 20:47:41 +02:00
|
|
|
engine.addImportPath(path);
|
|
|
|
|
2022-11-16 14:40:29 +01:00
|
|
|
qmlRegisterType<SectionsDecoratorModel>("Storybook", 1, 0, "SectionsDecoratorModel");
|
2022-11-25 16:41:50 +01:00
|
|
|
qmlRegisterType<FigmaDecoratorModel>("Storybook", 1, 0, "FigmaDecoratorModel");
|
|
|
|
qmlRegisterType<FigmaLinksSource>("Storybook", 1, 0, "FigmaLinksSource");
|
|
|
|
qmlRegisterUncreatableType<FigmaLinks>("Storybook", 1, 0, "FigmaLinks", "");
|
2022-11-16 14:40:29 +01:00
|
|
|
|
2022-10-18 20:47:41 +02:00
|
|
|
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);
|
|
|
|
|
2022-11-17 08:17:03 +02:00
|
|
|
const QUrl url(QML_IMPORT_ROOT + QStringLiteral("/main.qml"));
|
2022-10-04 22:25:14 +02: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 16:32:20 +02:00
|
|
|
return QGuiApplication::exec();
|
2022-10-04 22:25:14 +02:00
|
|
|
}
|