2024-07-04 00:23:00 +08:00
|
|
|
#include <QtQml/qqmlextensionplugin.h>
|
|
|
|
|
2024-06-17 16:42:54 +08:00
|
|
|
#include <QApplication>
|
2024-07-04 00:23:00 +08:00
|
|
|
#include <QDir>
|
|
|
|
#include <QLoggingCategory>
|
|
|
|
#include <QNetworkProxy>
|
|
|
|
#include <QProcess>
|
2023-02-24 18:44:29 +08:00
|
|
|
#include <QQmlApplicationEngine>
|
2023-03-03 18:19:48 +08:00
|
|
|
#include <QQmlContext>
|
2023-03-09 13:23:39 +08:00
|
|
|
#include <QQuickWindow>
|
2023-07-21 11:19:30 +08:00
|
|
|
#include <QSslConfiguration>
|
2024-07-04 00:23:00 +08:00
|
|
|
|
2023-04-11 23:12:31 +08:00
|
|
|
#include "AppInfo.h"
|
2024-07-04 00:23:00 +08:00
|
|
|
#include "Version.h"
|
2023-12-04 21:18:19 +08:00
|
|
|
#include "helper/Log.h"
|
2023-08-24 15:50:37 +08:00
|
|
|
#include "src/component/CircularReveal.h"
|
|
|
|
#include "src/component/FileWatcher.h"
|
2023-08-28 17:14:21 +08:00
|
|
|
#include "src/component/FpsItem.h"
|
2024-04-11 14:51:43 +08:00
|
|
|
#include "src/component/OpenGLItem.h"
|
2024-04-03 11:09:35 +08:00
|
|
|
#include "src/helper/InitializrHelper.h"
|
2024-03-27 09:45:56 +08:00
|
|
|
#include "src/helper/Network.h"
|
2024-07-04 00:23:00 +08:00
|
|
|
#include "src/helper/SettingsHelper.h"
|
|
|
|
#include "src/helper/TranslateHelper.h"
|
2024-06-28 17:09:23 +08:00
|
|
|
|
2023-09-09 20:09:20 +08:00
|
|
|
#ifdef FLUENTUI_BUILD_STATIC_LIB
|
2024-06-28 17:09:23 +08:00
|
|
|
# if (QT_VERSION > QT_VERSION_CHECK(6, 2, 0))
|
2023-09-09 20:09:20 +08:00
|
|
|
Q_IMPORT_QML_PLUGIN(FluentUIPlugin)
|
2024-06-28 17:09:23 +08:00
|
|
|
# endif
|
|
|
|
# include <FluentUI.h>
|
2023-09-09 20:09:20 +08:00
|
|
|
#endif
|
2023-02-26 23:47:07 +08:00
|
|
|
|
2024-01-04 18:00:44 +08:00
|
|
|
#ifdef WIN32
|
2024-06-28 17:09:23 +08:00
|
|
|
# include "app_dmp.h"
|
2024-01-04 18:00:44 +08:00
|
|
|
#endif
|
|
|
|
|
2024-06-28 17:09:23 +08:00
|
|
|
int main(int argc, char *argv[]) {
|
2024-04-04 02:48:26 +08:00
|
|
|
const char *uri = "example";
|
|
|
|
int major = 1;
|
|
|
|
int minor = 0;
|
2024-01-04 18:00:44 +08:00
|
|
|
#ifdef WIN32
|
2024-04-04 02:48:26 +08:00
|
|
|
::SetUnhandledExceptionFilter(MyUnhandledExceptionFilter);
|
2024-06-28 17:09:23 +08:00
|
|
|
qputenv("QT_QPA_PLATFORM", "windows:darkmode=2");
|
2024-01-04 14:28:51 +08:00
|
|
|
#endif
|
2024-01-09 21:57:02 +08:00
|
|
|
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
2024-06-28 17:09:23 +08:00
|
|
|
qputenv("QT_QUICK_CONTROLS_STYLE", "Basic");
|
2024-01-09 21:57:02 +08:00
|
|
|
#else
|
2024-06-28 17:09:23 +08:00
|
|
|
qputenv("QT_QUICK_CONTROLS_STYLE", "Default");
|
2024-01-09 21:57:02 +08:00
|
|
|
#endif
|
2023-12-14 21:16:09 +08:00
|
|
|
#ifdef Q_OS_LINUX
|
2024-06-28 17:09:23 +08:00
|
|
|
// fix bug UOSv20 does not print logs
|
|
|
|
qputenv("QT_LOGGING_RULES", "");
|
|
|
|
// fix bug UOSv20 v-sync does not work
|
|
|
|
qputenv("QSG_RENDER_LOOP", "basic");
|
2023-12-14 21:16:09 +08:00
|
|
|
#endif
|
2024-06-17 16:42:54 +08:00
|
|
|
QApplication::setOrganizationName("ZhuZiChu");
|
|
|
|
QApplication::setOrganizationDomain("https://zhuzichu520.github.io");
|
|
|
|
QApplication::setApplicationName("FluentUI");
|
|
|
|
QApplication::setApplicationDisplayName("FluentUI Example");
|
|
|
|
QApplication::setApplicationVersion(APPLICATION_VERSION);
|
|
|
|
QApplication::setQuitOnLastWindowClosed(false);
|
2023-12-06 23:57:30 +08:00
|
|
|
SettingsHelper::getInstance()->init(argv);
|
2024-06-28 17:09:23 +08:00
|
|
|
Log::setup(argv, uri);
|
2024-06-15 10:11:24 +08:00
|
|
|
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
|
|
|
QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGL);
|
|
|
|
#endif
|
2023-08-24 16:02:41 +08:00
|
|
|
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
2024-06-17 16:42:54 +08:00
|
|
|
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
|
|
|
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
2024-06-28 17:09:23 +08:00
|
|
|
# if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
|
|
|
QApplication::setHighDpiScaleFactorRoundingPolicy(
|
|
|
|
Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
|
|
|
# endif
|
2023-08-24 16:02:41 +08:00
|
|
|
#endif
|
2024-06-17 16:42:54 +08:00
|
|
|
QApplication app(argc, argv);
|
2024-03-27 09:45:56 +08:00
|
|
|
//@uri example
|
|
|
|
qmlRegisterType<CircularReveal>(uri, major, minor, "CircularReveal");
|
|
|
|
qmlRegisterType<FileWatcher>(uri, major, minor, "FileWatcher");
|
|
|
|
qmlRegisterType<FpsItem>(uri, major, minor, "FpsItem");
|
2024-06-28 17:09:23 +08:00
|
|
|
qmlRegisterType<NetworkCallable>(uri, major, minor, "NetworkCallable");
|
|
|
|
qmlRegisterType<NetworkParams>(uri, major, minor, "NetworkParams");
|
|
|
|
qmlRegisterType<OpenGLItem>(uri, major, minor, "OpenGLItem");
|
|
|
|
qmlRegisterUncreatableMetaObject(NetworkType::staticMetaObject, uri, major, minor,
|
|
|
|
"NetworkType", "Access to enums & flags only");
|
2024-04-11 14:51:43 +08:00
|
|
|
|
2023-02-24 18:44:29 +08:00
|
|
|
QQmlApplicationEngine engine;
|
2024-03-09 15:35:48 +08:00
|
|
|
TranslateHelper::getInstance()->init(&engine);
|
2024-06-28 17:09:23 +08:00
|
|
|
engine.rootContext()->setContextProperty("AppInfo", AppInfo::getInstance());
|
|
|
|
engine.rootContext()->setContextProperty("SettingsHelper", SettingsHelper::getInstance());
|
|
|
|
engine.rootContext()->setContextProperty("InitializrHelper", InitializrHelper::getInstance());
|
|
|
|
engine.rootContext()->setContextProperty("TranslateHelper", TranslateHelper::getInstance());
|
|
|
|
engine.rootContext()->setContextProperty("Network", Network::getInstance());
|
2023-07-10 19:07:54 +08:00
|
|
|
#ifdef FLUENTUI_BUILD_STATIC_LIB
|
2023-09-09 20:09:20 +08:00
|
|
|
FluentUI::getInstance()->registerTypes(&engine);
|
2023-07-10 19:07:54 +08:00
|
|
|
#endif
|
2023-04-27 09:38:57 +08:00
|
|
|
const QUrl url(QStringLiteral("qrc:/example/qml/App.qml"));
|
2024-06-28 17:09:23 +08:00
|
|
|
QObject::connect(
|
|
|
|
&engine, &QQmlApplicationEngine::objectCreated, &app,
|
|
|
|
[url](QObject *obj, const QUrl &objUrl) {
|
2023-04-22 00:29:47 +08:00
|
|
|
if (!obj && url == objUrl)
|
|
|
|
QCoreApplication::exit(-1);
|
2024-06-28 17:09:23 +08:00
|
|
|
},
|
|
|
|
Qt::QueuedConnection);
|
2023-02-26 23:47:07 +08:00
|
|
|
engine.load(url);
|
2024-06-17 16:42:54 +08:00
|
|
|
const int exec = QApplication::exec();
|
2023-09-17 20:36:33 +08:00
|
|
|
if (exec == 931) {
|
2024-03-31 21:52:06 +08:00
|
|
|
QProcess::startDetached(qApp->applicationFilePath(), qApp->arguments());
|
2023-09-17 20:36:33 +08:00
|
|
|
}
|
|
|
|
return exec;
|
2023-02-24 18:44:29 +08:00
|
|
|
}
|