FluentUI/example/src/main.cpp

73 lines
2.8 KiB
C++
Raw Normal View History

2023-05-22 16:17:51 +08:00
#include <QGuiApplication>
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>
2023-04-11 23:12:31 +08:00
#include "AppInfo.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"
2023-09-17 20:36:33 +08:00
#include "src/helper/SettingsHelper.h"
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
2023-09-17 20:36:33 +08:00
int main(int argc, char *argv[])
2023-02-24 18:44:29 +08:00
{
2023-10-04 21:13:38 +08:00
QNetworkProxy::setApplicationProxy(QNetworkProxy::NoProxy);
2023-08-24 16:02:41 +08:00
#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
2023-05-19 07:57:23 +08:00
qputenv("QT_QUICK_CONTROLS_STYLE","Basic");
2023-04-20 09:15:28 +08:00
QGuiApplication::setOrganizationName("ZhuZiChu");
QGuiApplication::setOrganizationDomain("https://zhuzichu520.github.io");
QGuiApplication::setApplicationName("FluentUI");
2023-09-29 19:30:22 +08:00
SettingsHelper::getInstance()->init(argv);
2023-09-17 20:36:33 +08:00
if(SettingsHelper::getInstance()->getReander()=="software"){
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
QQuickWindow::setGraphicsApi(QSGRendererInterface::Software);
#elif (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QQuickWindow::setSceneGraphBackend(QSGRendererInterface::Software);
#endif
}
2023-02-24 18:44:29 +08:00
QGuiApplication app(argc, argv);
2023-10-04 21:13:38 +08:00
// QLoggingCategory::setFilterRules(QStringLiteral("qt.scenegraph.general=true"));
// qSetMessagePattern("%{category}: %{message}");
2023-02-24 18:44:29 +08:00
QQmlApplicationEngine engine;
2023-09-17 20:36:33 +08:00
AppInfo::getInstance()->init(&engine);
engine.rootContext()->setContextProperty("AppInfo",AppInfo::getInstance());
engine.rootContext()->setContextProperty("SettingsHelper",SettingsHelper::getInstance());
#ifdef FLUENTUI_BUILD_STATIC_LIB
2023-09-09 20:09:20 +08:00
FluentUI::getInstance()->registerTypes(&engine);
#endif
2023-09-09 20:09:20 +08:00
qDebug()<<engine.importPathList();
2023-08-24 15:50:37 +08:00
qmlRegisterType<CircularReveal>("example", 1, 0, "CircularReveal");
qmlRegisterType<FileWatcher>("example", 1, 0, "FileWatcher");
2023-08-28 17:14:21 +08:00
qmlRegisterType<FpsItem>("example", 1, 0, "FpsItem");
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);
2023-09-17 20:36:33 +08:00
const int exec = QGuiApplication::exec();
if (exec == 931) {
QProcess::startDetached(qApp->applicationFilePath(), QStringList());
}
return exec;
2023-02-24 18:44:29 +08:00
}