mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2024-11-23 11:17:15 +08:00
92 lines
3.3 KiB
C++
92 lines
3.3 KiB
C++
#include <QGuiApplication>
|
|
#include <QQmlApplicationEngine>
|
|
#include <QQmlContext>
|
|
#include <QDir>
|
|
#include <QQuickWindow>
|
|
#include <QNetworkProxy>
|
|
#include <QSslConfiguration>
|
|
#include <QProcess>
|
|
#include <QtQml/qqmlextensionplugin.h>
|
|
#include <QLoggingCategory>
|
|
#include "Version.h"
|
|
#include "AppInfo.h"
|
|
#include "helper/Log.h"
|
|
#include "src/component/CircularReveal.h"
|
|
#include "src/component/FileWatcher.h"
|
|
#include "src/component/FpsItem.h"
|
|
#include "src/helper/SettingsHelper.h"
|
|
#include "src/helper/InitalizrHelper.h"
|
|
#include "src/helper/TranslateHelper.h"
|
|
|
|
#ifdef FLUENTUI_BUILD_STATIC_LIB
|
|
#if (QT_VERSION > QT_VERSION_CHECK(6, 2, 0))
|
|
Q_IMPORT_QML_PLUGIN(FluentUIPlugin)
|
|
#endif
|
|
#include <FluentUI.h>
|
|
#endif
|
|
|
|
#ifdef WIN32
|
|
#include "app_dmp.h"
|
|
#endif
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
#ifdef WIN32
|
|
::SetUnhandledExceptionFilter(MyUnhandledExceptionFilter);
|
|
qputenv("QT_QPA_PLATFORM","windows:darkmode=2");
|
|
#endif
|
|
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
|
qputenv("QT_QUICK_CONTROLS_STYLE","Basic");
|
|
#else
|
|
qputenv("QT_QUICK_CONTROLS_STYLE","Default");
|
|
#endif
|
|
#ifdef Q_OS_LINUX
|
|
//fix bug UOSv20 does not print logs
|
|
qputenv("QT_LOGGING_RULES","");
|
|
//fix bug UOSv20 v-sync does not work
|
|
qputenv("QSG_RENDER_LOOP","basic");
|
|
#endif
|
|
QGuiApplication::setOrganizationName("ZhuZiChu");
|
|
QGuiApplication::setOrganizationDomain("https://zhuzichu520.github.io");
|
|
QGuiApplication::setApplicationName("FluentUI");
|
|
QGuiApplication::setApplicationDisplayName("FluentUI Exmaple");
|
|
QGuiApplication::setApplicationVersion(APPLICATION_VERSION);
|
|
SettingsHelper::getInstance()->init(argv);
|
|
Log::setup(argv,"example");
|
|
#if (QT_VERSION >= QT_VERSION_CHECK(6, 5, 0))
|
|
QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGL);
|
|
#endif
|
|
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
|
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
|
QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
|
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
|
#endif
|
|
#endif
|
|
QGuiApplication app(argc, argv);
|
|
QQmlApplicationEngine engine;
|
|
TranslateHelper::getInstance()->init(&engine);
|
|
engine.rootContext()->setContextProperty("AppInfo",AppInfo::getInstance());
|
|
engine.rootContext()->setContextProperty("SettingsHelper",SettingsHelper::getInstance());
|
|
engine.rootContext()->setContextProperty("InitalizrHelper",InitalizrHelper::getInstance());
|
|
engine.rootContext()->setContextProperty("TranslateHelper",TranslateHelper::getInstance());
|
|
#ifdef FLUENTUI_BUILD_STATIC_LIB
|
|
FluentUI::getInstance()->registerTypes(&engine);
|
|
#endif
|
|
qmlRegisterType<CircularReveal>("example", 1, 0, "CircularReveal");
|
|
qmlRegisterType<FileWatcher>("example", 1, 0, "FileWatcher");
|
|
qmlRegisterType<FpsItem>("example", 1, 0, "FpsItem");
|
|
const QUrl url(QStringLiteral("qrc:/example/qml/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);
|
|
const int exec = QGuiApplication::exec();
|
|
if (exec == 931) {
|
|
QProcess::startDetached(qApp->applicationFilePath(), QStringList());
|
|
}
|
|
return exec;
|
|
}
|