This commit is contained in:
zhuzihcu 2023-05-18 14:55:28 +08:00
parent ab68770d63
commit 56681cb5a3
5 changed files with 49 additions and 6 deletions

View File

@ -90,12 +90,21 @@ set_target_properties(example PROPERTIES
WIN32_EXECUTABLE TRUE
)
#FluentUI
set(QML_PLUGIN_DIRECTORY ${CMAKE_PREFIX_PATH}/qml/FluentUI)
find_library(FluentUI fluentuiplugin ${QML_PLUGIN_DIRECTORY})
#
target_link_libraries(example PRIVATE
Qt6::Quick
fluentuiplugin
FramelessHelper::Core
FramelessHelper::Quick
${FluentUI}
)
target_include_directories(
example PRIVATE
${QML_PLUGIN_DIRECTORY}
)
#

View File

@ -6,6 +6,7 @@
#include <QProcess>
#include <FramelessHelper/Quick/framelessquickmodule.h>
#include <FramelessHelper/Core/private/framelessconfig_p.h>
#include <FluGlobal.h>
#include "lang/Lang.h"
#include "AppInfo.h"
#include "tool/IPC.h"
@ -14,6 +15,7 @@ FRAMELESSHELPER_USE_NAMESPACE
int main(int argc, char *argv[])
{
FluentUI::preInit();
FramelessHelper::Quick::initialize();
//将样式设置为Basic不然会导致组件显示异常
qputenv("QT_QUICK_CONTROLS_STYLE","Basic");
@ -22,6 +24,7 @@ int main(int argc, char *argv[])
QGuiApplication::setApplicationName("FluentUI");
// QQuickWindow::setGraphicsApi(QSGRendererInterface::Software);
QGuiApplication app(argc, argv);
FluentUI::postInit();
// FramelessHelper::Core::setApplicationOSThemeAware();
// FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
// FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial);
@ -41,6 +44,7 @@ int main(int argc, char *argv[])
}
app.setQuitOnLastWindowClosed(false);
QQmlApplicationEngine engine;
FluentUI::initEngine(&engine);
FramelessHelper::Quick::registerTypes(&engine);
QQmlContext * context = engine.rootContext();
Lang* lang = appInfo->lang();

View File

@ -54,7 +54,7 @@ qt_add_qml_module(fluentuiplugin
URI "FluentUI"
SOURCES ${sources_files} fluentui.rc
QML_FILES ${qml_files}
RESOURCES ${resource_files}
RESOURCES ${resource_files} FluGlobal.h
#designer
DESIGNER_SUPPORTED
)

17
src/FluGlobal.cpp Normal file
View File

@ -0,0 +1,17 @@
#include "FluGlobal.h"
#include<QDebug>
namespace FluentUI {
void preInit(){
qDebug()<<"preInit";
}
void postInit(){
qDebug()<<"postInit";
}
void initEngine(QQmlApplicationEngine* engine){
qDebug()<<"initEngine";
}
}

13
src/FluGlobal.h Normal file
View File

@ -0,0 +1,13 @@
#ifndef FLUGLOBAL_H
#define FLUGLOBAL_H
#include <QtGlobal>
#include <QQmlApplicationEngine>
namespace FluentUI {
Q_DECL_EXPORT void preInit();
Q_DECL_EXPORT void postInit();
Q_DECL_EXPORT void initEngine(QQmlApplicationEngine* engine);
}
#endif // FLUGLOBAL_H