2022-10-04 20:25:14 +00:00
|
|
|
#include <QGuiApplication>
|
|
|
|
#include <QQmlApplicationEngine>
|
2022-11-17 06:17:03 +00:00
|
|
|
|
2022-11-16 13:40:29 +00:00
|
|
|
#include "cachecleaner.h"
|
|
|
|
#include "directorieswatcher.h"
|
2022-11-25 15:41:50 +00:00
|
|
|
#include "figmadecoratormodel.h"
|
|
|
|
#include "figmalinks.h"
|
|
|
|
#include "figmalinkssource.h"
|
2022-11-16 13:40:29 +00:00
|
|
|
#include "sectionsdecoratormodel.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_ShareOpenGLContexts);
|
2022-11-25 13:02:48 +00:00
|
|
|
|
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 {
|
2023-04-14 08:18:56 +00:00
|
|
|
STATUSQ_MODULE_IMPORT_PATH,
|
2022-11-17 06:17:03 +00:00
|
|
|
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 18:47:41 +00:00
|
|
|
};
|
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);
|
|
|
|
|
2022-11-16 13:40:29 +00:00
|
|
|
qmlRegisterType<SectionsDecoratorModel>("Storybook", 1, 0, "SectionsDecoratorModel");
|
2022-11-25 15:41:50 +00:00
|
|
|
qmlRegisterType<FigmaDecoratorModel>("Storybook", 1, 0, "FigmaDecoratorModel");
|
|
|
|
qmlRegisterType<FigmaLinksSource>("Storybook", 1, 0, "FigmaLinksSource");
|
2023-02-28 14:54:10 +00:00
|
|
|
qmlRegisterUncreatableType<FigmaLinks>("Storybook", 1, 0, "FigmaLinks", {});
|
2022-11-16 13:40:29 +00:00
|
|
|
|
2022-10-18 18:47:41 +00: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 06:17:03 +00:00
|
|
|
const QUrl url(QML_IMPORT_ROOT + 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
|
|
|
}
|