#include "FluApp.h" #include #include #include #include #include #include #include #include #include FluApp::FluApp(QObject *parent):QObject{parent}{ useSystemAppBar(false); } FluApp::~FluApp(){ } void FluApp::init(QObject *target,QLocale locale){ _locale = locale; _engine = qmlEngine(target); _translator = new QTranslator(this); qApp->installTranslator(_translator); const QStringList uiLanguages = _locale.uiLanguages(); for (const QString &name : uiLanguages) { const QString baseName = "FluentUI_" + QLocale(name).name(); if (_translator->load(":/qt/qml/FluentUI/i18n/"+ baseName)) { _engine->retranslate(); break; } } } void FluApp::run(){ navigate(initialRoute()); } void FluApp::navigate(const QString& route,const QJsonObject& argument,FluWindowRegister* windowRegister){ if(!routes().contains(route)){ qCritical()<<"Not Found Route "<property("_route").toString(); if(r == route){ win = pair.second; break; } } if(win){ int launchMode = win->property("launchMode").toInt(); if(launchMode == 1){ win->setProperty("",argument); win->show(); win->raise(); win->requestActivate(); return; }else if(launchMode == 2){ win->close(); } } win = qobject_cast(component.createWithInitialProperties(properties)); if(windowRegister){ windowRegister->to(win); } } void FluApp::exit(int retCode){ for (const auto& pair : _windows.toStdMap()) { pair.second->close(); removeWindow(pair.second); } qApp->exit(retCode); } void FluApp::addWindow(QQuickWindow* window){ _windows.insert(window->winId(),window); } void FluApp::removeWindow(QQuickWindow* window){ if(window){ _windows.remove(window->winId()); window->deleteLater(); window = nullptr; } } QVariant FluApp::createWindowRegister(QQuickWindow* window,const QString& path){ FluWindowRegister *p = new FluWindowRegister(window); p->from(window); p->path(path); return QVariant::fromValue(p); }