This commit is contained in:
朱子楚\zhuzi
2023-05-18 20:32:53 +08:00
parent edd1ea90b9
commit 1491abc614
13 changed files with 63 additions and 89 deletions

View File

@ -57,6 +57,8 @@ qt_add_qml_module(fluentuiplugin
RESOURCES ${resource_files} FluGlobal.h
#支持designer
DESIGNER_SUPPORTED
DEPENDENCIES
org.wangwenx190.FramelessHelper/auto
)
#链接库
@ -64,6 +66,8 @@ target_link_libraries(fluentuiplugin PUBLIC
Qt::CorePrivate
Qt::QuickPrivate
Qt::QmlPrivate
FramelessHelper::Core
FramelessHelper::Quick
)
#链接库 win32库 不然mingw会编译错误

View File

@ -1,17 +1,29 @@
#include "FluGlobal.h"
#include<QDebug>
#include <FramelessHelper/Quick/framelessquickmodule.h>
#include <FramelessHelper/Core/private/framelessconfig_p.h>
FRAMELESSHELPER_USE_NAMESPACE;
namespace FluentUI {
void preInit(){
qDebug()<<"preInit";
FramelessHelper::Quick::initialize();
//将样式设置为Basic不然会导致组件显示异常
qputenv("QT_QUICK_CONTROLS_STYLE","Basic");
}
void postInit(){
qDebug()<<"postInit";
FramelessHelper::Core::setApplicationOSThemeAware();
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial);
}
void initEngine(QQmlApplicationEngine* engine){
qDebug()<<"initEngine";
FramelessHelper::Quick::registerTypes(engine);
qDebug()<<"FramelessHelper::Quick::registerTypes(engine)";
}
}

View File

@ -3,6 +3,7 @@ import QtQuick.Window
import QtQuick.Controls
import QtQuick.Layouts
import FluentUI
import org.wangwenx190.FramelessHelper
Window {
enum LaunchMode {
@ -11,6 +12,9 @@ Window {
SingleInstance
}
default property alias content: container.data
property bool fixSize
property alias titleVisible: title_bar.titleVisible
property bool appBarVisible: true
property bool closeDestory: true
property int launchMode: FluWindow.Standard
property string route
@ -47,15 +51,43 @@ Window {
}
}
}
FluAppBar {
id: title_bar
title: window.title
visible: window.appBarVisible
anchors {
top: parent.top
left: parent.left
right: parent.right
}
}
Item{
id:container
anchors.fill: parent
anchors{
top: title_bar.bottom
left: parent.left
right: parent.right
bottom: parent.bottom
}
clip: true
}
FluInfoBar{
id:infoBar
root: window
}
FramelessHelper{
id:framless_helper
onReady: {
setTitleBarItem(title_bar)
framless_helper.moveWindowToDesktopCenter()
setHitTestVisible(title_bar.minimizeButton())
setHitTestVisible(title_bar.maximizeButton())
setHitTestVisible(title_bar.closeButton())
framless_helper.setWindowFixedSize(fixSize)
title_bar.maximizeButton.visible = !fixSize
window.visible = true
}
}
WindowHelper{
id:helper
}
@ -77,6 +109,12 @@ Window {
function deleteWindow(){
helper.deleteWindow()
}
function setHitTestVisible(com){
framless_helper.setHitTestVisible(com)
}
function setTitleBarItem(com){
framless_helper.setTitleBarItem(com)
}
function onResult(data){
if(pageRegister){
pageRegister.onResult(data)