mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2024-11-30 15:06:52 +08:00
38 lines
1.3 KiB
C++
38 lines
1.3 KiB
C++
#include <QGuiApplication>
|
|
#include <QQmlApplicationEngine>
|
|
#include <QQmlContext>
|
|
#include <QDir>
|
|
#include <QQuickWindow>
|
|
#include <QQuickStyle>
|
|
#include <QProcess>
|
|
#include "lang/Lang.h"
|
|
#include "AppInfo.h"
|
|
#include "ChatController.h"
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
QCoreApplication::setOrganizationName("ZhuZiChu");
|
|
QCoreApplication::setOrganizationDomain("https://zhuzichu520.github.io");
|
|
QCoreApplication::setApplicationName("FluentUI");
|
|
QQuickStyle::setStyle("Basic");
|
|
QGuiApplication app(argc, argv);
|
|
QQmlApplicationEngine engine;
|
|
qmlRegisterType<ChatController>("Controller",1,0,"ChatController");
|
|
AppInfo* appInfo = new AppInfo();
|
|
QQmlContext * context = engine.rootContext();
|
|
Lang* lang = appInfo->lang();
|
|
context->setContextProperty("lang",lang);
|
|
QObject::connect(appInfo,&AppInfo::langChanged,&app,[context,appInfo]{
|
|
context->setContextProperty("lang",appInfo->lang());
|
|
});
|
|
context->setContextProperty("appInfo",appInfo);
|
|
const QUrl url(QStringLiteral("qrc:/App.qml"));
|
|
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
|
|
&app, [url](QObject *obj, const QUrl &objUrl) {
|
|
if (!obj && url == objUrl)
|
|
QCoreApplication::exit(-1);
|
|
}, Qt::QueuedConnection);
|
|
engine.load(url);
|
|
return app.exec();
|
|
}
|