mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2024-11-23 19:20:59 +08:00
51 lines
1.9 KiB
C++
51 lines
1.9 KiB
C++
#include <QGuiApplication>
|
||
#include <QQmlApplicationEngine>
|
||
#include <QQmlContext>
|
||
#include <QDir>
|
||
#include <QQuickWindow>
|
||
#include <QProcess>
|
||
#include <FramelessHelper/Quick/framelessquickmodule.h>
|
||
#include <FramelessHelper/Core/private/framelessconfig_p.h>
|
||
#include "AppInfo.h"
|
||
|
||
FRAMELESSHELPER_USE_NAMESPACE
|
||
|
||
int main(int argc, char *argv[])
|
||
{
|
||
//将样式设置为Basic,不然会导致组件显示异常
|
||
// qputenv("QT_FONT_DPI","1");
|
||
qputenv("QT_QUICK_CONTROLS_STYLE","Basic");
|
||
FramelessHelper::Quick::initialize();
|
||
QGuiApplication::setOrganizationName("ZhuZiChu");
|
||
QGuiApplication::setOrganizationDomain("https://zhuzichu520.github.io");
|
||
QGuiApplication::setApplicationName("FluentUI");
|
||
QGuiApplication app(argc, argv);
|
||
#ifdef Q_OS_WIN // 此设置仅在Windows下生效
|
||
FramelessConfig::instance()->set(Global::Option::ForceHideWindowFrameBorder);
|
||
#endif
|
||
FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial);
|
||
FramelessConfig::instance()->set(Global::Option::CenterWindowBeforeShow);
|
||
FramelessConfig::instance()->set(Global::Option::ForceNonNativeBackgroundBlur);
|
||
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
|
||
#ifdef Q_OS_MACOS
|
||
FramelessConfig::instance()->set(Global::Option::ForceNonNativeBackgroundBlur,false);
|
||
#endif
|
||
AppInfo* appInfo = new AppInfo();
|
||
IPC ipc(0);
|
||
if(!appInfo->isOwnerProcess(&ipc)){
|
||
return 0;
|
||
}
|
||
app.setQuitOnLastWindowClosed(false);
|
||
QQmlApplicationEngine engine;
|
||
FramelessHelper::Quick::registerTypes(&engine);
|
||
appInfo->init(&engine);
|
||
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);
|
||
return app.exec();
|
||
}
|