2024-06-17 16:42:54 +08:00
|
|
|
#include <QApplication>
|
2023-02-24 18:44:29 +08:00
|
|
|
#include <QQmlApplicationEngine>
|
2023-03-03 18:19:48 +08:00
|
|
|
#include <QQmlContext>
|
2023-03-05 23:39:13 +08:00
|
|
|
#include <QDir>
|
2023-03-09 13:23:39 +08:00
|
|
|
#include <QQuickWindow>
|
2023-07-21 11:19:30 +08:00
|
|
|
#include <QNetworkProxy>
|
|
|
|
#include <QSslConfiguration>
|
2023-03-05 23:39:13 +08:00
|
|
|
#include <QProcess>
|
2023-09-09 20:09:20 +08:00
|
|
|
#include <QtQml/qqmlextensionplugin.h>
|
2023-09-27 18:10:20 +08:00
|
|
|
#include <QLoggingCategory>
|
2024-01-03 16:56:28 +08:00
|
|
|
#include "Version.h"
|
2023-04-11 23:12:31 +08:00
|
|
|
#include "AppInfo.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"
|
2023-09-17 20:36:33 +08:00
|
|
|
#include "src/helper/SettingsHelper.h"
|
2024-04-03 11:09:35 +08:00
|
|
|
#include "src/helper/InitializrHelper.h"
|
2024-03-09 15:35:48 +08:00
|
|
|
#include "src/helper/TranslateHelper.h"
|
2024-03-27 09:45:56 +08:00
|
|
|
#include "src/helper/Network.h"
|
2023-09-17 20:36:33 +08:00
|
|
|
|
2023-09-09 20:09:20 +08:00
|
|
|
#ifdef FLUENTUI_BUILD_STATIC_LIB
|
|
|
|
#if (QT_VERSION > QT_VERSION_CHECK(6, 2, 0))
|
|
|
|
Q_IMPORT_QML_PLUGIN(FluentUIPlugin)
|
|
|
|
#endif
|
|
|
|
#include <FluentUI.h>
|
|
|
|
#endif
|
2023-02-26 23:47:07 +08:00
|
|
|
|
2024-01-04 18:00:44 +08:00
|
|
|
#ifdef WIN32
|
|
|
|
#include "app_dmp.h"
|
|
|
|
#endif
|
|
|
|
|
2023-09-17 20:36:33 +08:00
|
|
|
int main(int argc, char *argv[])
|
2023-02-24 18:44:29 +08:00
|
|
|
{
|
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-01-04 14:28:51 +08:00
|
|
|
qputenv("QT_QPA_PLATFORM","windows:darkmode=2");
|
|
|
|
#endif
|
2024-01-09 21:57:02 +08:00
|
|
|
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
2024-01-04 18:00:44 +08:00
|
|
|
qputenv("QT_QUICK_CONTROLS_STYLE","Basic");
|
2024-01-09 21:57:02 +08:00
|
|
|
#else
|
|
|
|
qputenv("QT_QUICK_CONTROLS_STYLE","Default");
|
|
|
|
#endif
|
2023-12-14 21:16:09 +08:00
|
|
|
#ifdef Q_OS_LINUX
|
|
|
|
//fix bug UOSv20 does not print logs
|
2023-12-14 11:46:51 +08:00
|
|
|
qputenv("QT_LOGGING_RULES","");
|
2023-12-14 21:16:09 +08:00
|
|
|
//fix bug UOSv20 v-sync does not work
|
2023-12-14 14:43:49 +08:00
|
|
|
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-04-04 02:48:26 +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);
|
2023-08-24 16:02:41 +08:00
|
|
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
2024-06-17 16:42:54 +08:00
|
|
|
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
2023-08-24 16:02:41 +08:00
|
|
|
#endif
|
|
|
|
#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");
|
|
|
|
qmlRegisterType<NetworkCallable>(uri,major,minor,"NetworkCallable");
|
|
|
|
qmlRegisterType<NetworkParams>(uri,major,minor,"NetworkParams");
|
2024-04-11 14:51:43 +08:00
|
|
|
qmlRegisterType<OpenGLItem>(uri,major,minor,"OpenGLItem");
|
|
|
|
qmlRegisterUncreatableMetaObject(NetworkType::staticMetaObject, uri, major, minor, "NetworkType", "Access to enums & flags only");
|
|
|
|
|
2023-02-24 18:44:29 +08:00
|
|
|
QQmlApplicationEngine engine;
|
2024-03-09 15:35:48 +08:00
|
|
|
TranslateHelper::getInstance()->init(&engine);
|
2023-09-17 20:36:33 +08:00
|
|
|
engine.rootContext()->setContextProperty("AppInfo",AppInfo::getInstance());
|
|
|
|
engine.rootContext()->setContextProperty("SettingsHelper",SettingsHelper::getInstance());
|
2024-04-03 11:09:35 +08:00
|
|
|
engine.rootContext()->setContextProperty("InitializrHelper",InitializrHelper::getInstance());
|
2024-03-09 15:35:48 +08:00
|
|
|
engine.rootContext()->setContextProperty("TranslateHelper",TranslateHelper::getInstance());
|
2024-03-27 09:45:56 +08:00
|
|
|
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"));
|
2023-02-26 23:47:07 +08:00
|
|
|
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
|
2023-04-22 00:29:47 +08:00
|
|
|
&app, [url](QObject *obj, const QUrl &objUrl) {
|
|
|
|
if (!obj && url == objUrl)
|
|
|
|
QCoreApplication::exit(-1);
|
|
|
|
}, 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
|
|
|
}
|