From 855305f197ed9e9b6f73b09674d8991a62e53026 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E5=AD=90=E6=A5=9A=5Czhuzi?= Date: Fri, 11 Aug 2023 22:47:36 +0800 Subject: [PATCH] update --- example/qml/component/CustomWindow.qml | 2 +- example/qml/page/T_Home.qml | 9 ++--- example/src/main.cpp | 6 ++-- src/FluApp.cpp | 6 ++-- src/imports/FluentUI/Controls/FluWindow.qml | 39 ++++++++++++--------- 5 files changed, 34 insertions(+), 28 deletions(-) diff --git a/example/qml/component/CustomWindow.qml b/example/qml/component/CustomWindow.qml index 47565905..aaa3482c 100644 --- a/example/qml/component/CustomWindow.qml +++ b/example/qml/component/CustomWindow.qml @@ -41,7 +41,7 @@ FluWindow { setWindowFixedSize(fixSize) title_bar.maximizeButton.visible = !fixSize if (blurBehindWindowEnabled) - window.backgroundVisible = false + window.background = undefined window.show() } } diff --git a/example/qml/page/T_Home.qml b/example/qml/page/T_Home.qml index c4dd4b81..205b6b0d 100644 --- a/example/qml/page/T_Home.qml +++ b/example/qml/page/T_Home.qml @@ -77,6 +77,7 @@ FluScrollablePage{ anchors.fill: parent tintColor: FluTheme.dark ? Qt.rgba(0,0,0,1) : Qt.rgba(1,1,1,1) target: bg + blurRadius : 40 targetRect: Qt.rect(list.x-list.contentX+10+(control.width)*index,list.y+10,width,height) } Rectangle{ @@ -85,14 +86,14 @@ FluScrollablePage{ color:{ if(FluTheme.dark){ if(item_mouse.containsMouse){ - return Qt.rgba(1,1,1,0.03) + return Qt.rgba(1,1,1,0.06) } - return Qt.rgba(0,0,0,0) + return Qt.rgba(0,0,0,0.03) }else{ if(item_mouse.containsMouse){ - return Qt.rgba(0,0,0,0.03) + return Qt.rgba(0,0,0,0.09) } - return Qt.rgba(0,0,0,0) + return Qt.rgba(0,0,0,0.06) } } } diff --git a/example/src/main.cpp b/example/src/main.cpp index 2d559034..79538078 100644 --- a/example/src/main.cpp +++ b/example/src/main.cpp @@ -21,13 +21,13 @@ FRAMELESSHELPER_USE_NAMESPACE 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_WIN // 此设置仅在Windows下生效 + FramelessConfig::instance()->set(Global::Option::ForceHideWindowFrameBorder); +#endif #ifdef Q_OS_MACOS FramelessConfig::instance()->set(Global::Option::ForceNonNativeBackgroundBlur,false); #endif diff --git a/src/FluApp.cpp b/src/FluApp.cpp index f5b2aaa8..8dece17a 100644 --- a/src/FluApp.cpp +++ b/src/FluApp.cpp @@ -49,14 +49,14 @@ void FluApp::navigate(const QString& route,const QJsonObject& argument,FluRegist return; } QVariantMap properties; - properties.insert("route",route); + properties.insert("_route",route); if(fluRegister){ - properties.insert("pageRegister",QVariant::fromValue(fluRegister)); + properties.insert("_pageRegister",QVariant::fromValue(fluRegister)); } properties.insert("argument",argument); QQuickWindow *view=nullptr; for (auto& pair : wnds) { - QString r = pair->property("route").toString(); + QString r = pair->property("_route").toString(); if(r == route){ view = pair; break; diff --git a/src/imports/FluentUI/Controls/FluWindow.qml b/src/imports/FluentUI/Controls/FluWindow.qml index 0502ad0d..5262bb1e 100644 --- a/src/imports/FluentUI/Controls/FluWindow.qml +++ b/src/imports/FluentUI/Controls/FluWindow.qml @@ -1,5 +1,4 @@ import QtQuick -import QtQuick.Window import QtQuick.Controls import QtQuick.Layouts import FluentUI @@ -8,10 +7,11 @@ Window { default property alias content: container.data property bool closeDestory: true property int launchMode: FluWindowType.Standard - property string route property var argument:({}) - property var pageRegister + property var background : com_background property Component loadingItem: com_loading + property var _pageRegister + property string _route property var closeFunc: function(event){ if(closeDestory){ deleteWindow() @@ -20,26 +20,31 @@ Window { event.accepted = false } } - property color backgroundColor: { - if(active){ - return FluTheme.dark ? Qt.rgba(26/255,34/255,40/255,1) : Qt.rgba(238/255,244/255,249/255,1) - } - return FluTheme.dark ? Qt.rgba(32/255,32/255,32/255,1) : Qt.rgba(243/255,243/255,243/255,1) - } - property alias backgroundOpacity: bg.opacity - property alias backgroundVisible: bg.visible signal initArgument(var argument) id:window color:"transparent" - onClosing:(event)=>closeFunc(event) Component.onCompleted: { helper.initWindow(window) initArgument(argument) } - Rectangle{ - id: bg + Connections{ + target: window + function onClosing(event){closeFunc(event)} + } + Component{ + id:com_background + Rectangle{ + color: { + if(active){ + return FluTheme.dark ? Qt.rgba(26/255,34/255,40/255,1) : Qt.rgba(238/255,244/255,249/255,1) + } + return FluTheme.dark ? Qt.rgba(32/255,32/255,32/255,1) : Qt.rgba(243/255,243/255,243/255,1) + } + } + } + Loader{ anchors.fill: parent - color: backgroundColor + sourceComponent: background } Item{ id:container @@ -124,8 +129,8 @@ Window { FluApp.deleteWindow(window) } function onResult(data){ - if(pageRegister){ - pageRegister.onResult(data) + if(_pageRegister){ + _pageRegister.onResult(data) } } }