Quarts/Quartz/main.cpp
Станислав Хозяенок ba7679097f Обновление
2025-06-10 13:04:08 +07:00

80 lines
2.0 KiB
C++

#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include "FigmaQmlInterface.hpp"
#include "figmaadapter.h"
#include "FigmaQmlInterface.hpp"
#include "UrlHelper.h"
#include "QQmlContext"
#include "DynamicQmlComponent.h"
#include "QQmlImageProviderBase"
QQmlApplicationEngine *engine=0;
extern void startHTTPServer();
int main(int argc, char *argv[])
{
// QString filePath = "/home/user/documents/report.txt";
// QFileInfo fileInfo(filePath);
// QString fileName = fileInfo.fileName(); // Extracts "report.txt"
// qDebug() << "File name:" << fileName;
QGuiApplication app(argc, argv);
// app.applicationFilePath()
app.setWindowIcon(QIcon(":/ico/Logo.ico"));
engine = new QQmlApplicationEngine();
// QApplication app(argc, argv);
QObject::connect(
engine,
&QQmlApplicationEngine::objectCreationFailed,
&app,
[]() { QCoreApplication::exit(-1); },
Qt::QueuedConnection);
FigmaQmlInterface::registerFigmaQmlSingleton(*engine);
engine->addImportPath("qrc:/");
engine->addImportPath(QCoreApplication::applicationDirPath() + "/QtQuckApp");
for (const auto &path : engine->importPathList()) {
qDebug() << " - " << path;
}
FigmaQmlSingleton * instance = FigmaQmlSingleton::instance(*engine);
FigmaAdapter * figmaAdapter = 0;
if (instance) {
figmaAdapter = new FigmaAdapter(instance, *engine);
}
UrlHelper urlHelper;
engine->rootContext()->setContextProperty("UrlHelper", &urlHelper);
qDebug() << "Before";
// QByteArray myComponentQml = R"(
// import QtQuick 2.15
// Rectangle {
// width: 100
// height: 100
// color: "red"
// }
// )";
// // Создаем компонент
// QQmlComponent component =
qmlRegisterType<DynamicQmlComponent>("QtQuckApp", 1, 0, "MyDynamicComponent");
engine->loadFromModule("QtQuckApp", "Main");
if (figmaAdapter) {
figmaAdapter->Init();
}
startHTTPServer();
return app.exec();
}