2023-02-24 18:44:29 +08:00
|
|
|
|
#include <QGuiApplication>
|
|
|
|
|
#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-17 18:15:15 +08:00
|
|
|
|
#include <FramelessHelper/Quick/framelessquickmodule.h>
|
|
|
|
|
#include <FramelessHelper/Core/private/framelessconfig_p.h>
|
2023-05-18 14:55:28 +08:00
|
|
|
|
#include <FluGlobal.h>
|
2023-04-14 17:07:54 +08:00
|
|
|
|
#include "lang/Lang.h"
|
2023-04-11 23:12:31 +08:00
|
|
|
|
#include "AppInfo.h"
|
2023-04-22 16:02:52 +08:00
|
|
|
|
#include "tool/IPC.h"
|
2023-02-26 23:47:07 +08:00
|
|
|
|
|
2023-05-17 20:20:29 +08:00
|
|
|
|
FRAMELESSHELPER_USE_NAMESPACE
|
2023-05-17 18:15:15 +08:00
|
|
|
|
|
2023-05-18 14:55:28 +08:00
|
|
|
|
int main(int argc, char *argv[])
|
2023-02-24 18:44:29 +08:00
|
|
|
|
{
|
2023-05-18 14:55:28 +08:00
|
|
|
|
FluentUI::preInit();
|
2023-05-17 18:15:15 +08:00
|
|
|
|
FramelessHelper::Quick::initialize();
|
2023-04-19 23:04:56 +08:00
|
|
|
|
//将样式设置为Basic,不然会导致组件显示异常
|
2023-05-17 22:02:09 +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-04-22 00:29:47 +08:00
|
|
|
|
// QQuickWindow::setGraphicsApi(QSGRendererInterface::Software);
|
2023-02-24 18:44:29 +08:00
|
|
|
|
QGuiApplication app(argc, argv);
|
2023-05-18 14:55:28 +08:00
|
|
|
|
FluentUI::postInit();
|
|
|
|
|
// FramelessHelper::Core::setApplicationOSThemeAware();
|
|
|
|
|
// FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
|
|
|
|
|
// FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial);
|
2023-04-22 00:29:47 +08:00
|
|
|
|
AppInfo* appInfo = new AppInfo();
|
|
|
|
|
IPC ipc(0);
|
|
|
|
|
QString activeWindowEvent = "activeWindow";
|
|
|
|
|
if(!ipc.isCurrentOwner()){
|
|
|
|
|
ipc.postEvent(activeWindowEvent,QString().toUtf8(),0);
|
|
|
|
|
delete appInfo;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
if(ipc.isAttached()){
|
2023-04-23 18:08:20 +08:00
|
|
|
|
ipc.registerEventHandler(activeWindowEvent,[&appInfo](const QByteArray&){
|
2023-04-22 00:29:47 +08:00
|
|
|
|
Q_EMIT appInfo->activeWindow();
|
|
|
|
|
return true;
|
|
|
|
|
});
|
|
|
|
|
}
|
2023-04-16 02:28:58 +08:00
|
|
|
|
app.setQuitOnLastWindowClosed(false);
|
2023-02-24 18:44:29 +08:00
|
|
|
|
QQmlApplicationEngine engine;
|
2023-05-18 14:55:28 +08:00
|
|
|
|
FluentUI::initEngine(&engine);
|
2023-05-17 18:15:15 +08:00
|
|
|
|
FramelessHelper::Quick::registerTypes(&engine);
|
2023-04-14 17:07:54 +08:00
|
|
|
|
QQmlContext * context = engine.rootContext();
|
|
|
|
|
Lang* lang = appInfo->lang();
|
|
|
|
|
context->setContextProperty("lang",lang);
|
|
|
|
|
QObject::connect(appInfo,&AppInfo::langChanged,&app,[context,appInfo]{
|
|
|
|
|
context->setContextProperty("lang",appInfo->lang());
|
|
|
|
|
});
|
|
|
|
|
context->setContextProperty("appInfo",appInfo);
|
2023-04-27 09:38:57 +08:00
|
|
|
|
const QUrl url(QStringLiteral("qrc:/example/qml/App.qml"));
|
2023-05-17 12:49:41 +08:00
|
|
|
|
// const QUrl url(QStringLiteral("qrc:/example/qml/TestWindow.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();
|
|
|
|
|
}
|