main
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 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 target_link_libraries(example PRIVATE
Qt6::Quick Qt6::Quick
fluentuiplugin
FramelessHelper::Core FramelessHelper::Core
FramelessHelper::Quick FramelessHelper::Quick
${FluentUI}
)
target_include_directories(
example PRIVATE
${QML_PLUGIN_DIRECTORY}
) )
# #

View File

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

View File

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