FluentUI/example/src/main.cpp

52 lines
2.1 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-03-05 23:39:13 +08:00
#include <QProcess>
2023-05-19 07:57:23 +08:00
#include <FramelessHelper/Quick/framelessquickmodule.h>
#include <FramelessHelper/Core/private/framelessconfig_p.h>
2023-06-29 23:36:36 +08:00
#include "src/component/CircularReveal.h"
2023-07-11 16:43:28 +08:00
#include "src/component/FileWatcher.h"
2023-04-11 23:12:31 +08:00
#include "AppInfo.h"
2023-02-26 23:47:07 +08:00
2023-05-19 07:57:23 +08:00
FRAMELESSHELPER_USE_NAMESPACE
2023-07-18 18:24:06 +08:00
int main(int argc, char *argv[])
2023-02-24 18:44:29 +08:00
{
2023-05-19 07:57:23 +08:00
//将样式设置为Basic不然会导致组件显示异常
qputenv("QT_QUICK_CONTROLS_STYLE","Basic");
FramelessHelper::Quick::initialize();
2023-04-20 09:15:28 +08:00
QGuiApplication::setOrganizationName("ZhuZiChu");
QGuiApplication::setOrganizationDomain("https://zhuzichu520.github.io");
QGuiApplication::setApplicationName("FluentUI");
2023-02-24 18:44:29 +08:00
QGuiApplication app(argc, argv);
#ifdef Q_OS_WIN // 此设置仅在Windows下生效
2023-05-19 09:19:52 +08:00
FramelessConfig::instance()->set(Global::Option::ForceHideWindowFrameBorder);
#endif
FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial);
FramelessConfig::instance()->set(Global::Option::CenterWindowBeforeShow);
2023-05-23 09:33:37 +08:00
FramelessConfig::instance()->set(Global::Option::ForceNonNativeBackgroundBlur);
2023-06-28 02:28:34 +08:00
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
2023-06-28 12:12:15 +08:00
#ifdef Q_OS_MACOS
2023-05-23 09:33:37 +08:00
FramelessConfig::instance()->set(Global::Option::ForceNonNativeBackgroundBlur,false);
2023-05-21 21:34:30 +08:00
#endif
2023-04-22 00:29:47 +08:00
AppInfo* appInfo = new AppInfo();
2023-02-24 18:44:29 +08:00
QQmlApplicationEngine engine;
2023-05-19 07:57:23 +08:00
FramelessHelper::Quick::registerTypes(&engine);
#ifdef FLUENTUI_BUILD_STATIC_LIB
engine.addImportPath("qrc:/"); // 让静态资源可以被QML引擎搜索到
#endif
2023-06-29 23:36:36 +08:00
qmlRegisterType<CircularReveal>("example", 1, 0, "CircularReveal");
2023-07-11 16:43:28 +08:00
qmlRegisterType<FileWatcher>("example", 1, 0, "FileWatcher");
2023-05-25 17:00:48 +08:00
appInfo->init(&engine);
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-02-24 18:44:29 +08:00
return app.exec();
}