From f998b58d88e2a48236ab8252f30f8940a14a1111 Mon Sep 17 00:00:00 2001 From: Mentalflow <312902918@qq.com> Date: Sun, 21 May 2023 19:35:01 +0800 Subject: [PATCH] Improve acrylic effect for example and FluNavigationview. --- example/qml/component/CustomWindow.qml | 11 +++++++++++ example/qml/page/T_Home.qml | 4 ++-- example/src/main.cpp | 3 +++ .../FluentUI/Controls/FluNavigationView.qml | 19 +++++++++++++++++-- src/imports/FluentUI/Controls/FluWindow.qml | 2 ++ 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/example/qml/component/CustomWindow.qml b/example/qml/component/CustomWindow.qml index 8eb2114c..4f684e03 100644 --- a/example/qml/component/CustomWindow.qml +++ b/example/qml/component/CustomWindow.qml @@ -45,9 +45,20 @@ FluWindow { setHitTestVisible(title_bar.closeButton()) framless_helper.setWindowFixedSize(fixSize) title_bar.maximizeButton.visible = !fixSize + if (blurBehindWindowEnabled) + window.backgroundOpacity = 0.8 window.visible = true } } + Connections{ + target: FluTheme + function onDarkChanged(){ + if (FluTheme.dark) + FramelessUtils.systemTheme = FramelessHelperConstants.Dark + else + FramelessUtils.systemTheme = FramelessHelperConstants.Light + } + } function setHitTestVisible(com){ framless_helper.setHitTestVisible(com) diff --git a/example/qml/page/T_Home.qml b/example/qml/page/T_Home.qml index 5a2906ce..706743ee 100644 --- a/example/qml/page/T_Home.qml +++ b/example/qml/page/T_Home.qml @@ -75,10 +75,10 @@ FluScrollablePage{ FluAcrylic { sourceItem:bg anchors.fill: parent - color: FluTheme.dark ? 'black' : 'white' + color: FluTheme.dark ? Window.active ? Qt.rgba(38/255,44/255,54/255,1) : Qt.rgba(39/255,39/255,39/255,1) : Qt.rgba(251/255,251/255,253/255,1) rectX: list.x-list.contentX+10+(control.width)*index rectY: list.y+10 - acrylicOpacity:0.5 + acrylicOpacity:0.8 } Rectangle{ anchors.fill: parent diff --git a/example/src/main.cpp b/example/src/main.cpp index cd3ce8c1..9eeb61ea 100644 --- a/example/src/main.cpp +++ b/example/src/main.cpp @@ -22,6 +22,9 @@ FRAMELESSHELPER_USE_NAMESPACE QGuiApplication::setApplicationName("FluentUI"); QGuiApplication app(argc, argv); FramelessConfig::instance()->set(Global::Option::ForceHideWindowFrameBorder); + FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow); + FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial); + FramelessConfig::instance()->set(Global::Option::CenterWindowBeforeShow); AppInfo* appInfo = new AppInfo(); IPC ipc(0); QString activeWindowEvent = "activeWindow"; diff --git a/src/imports/FluentUI/Controls/FluNavigationView.qml b/src/imports/FluentUI/Controls/FluNavigationView.qml index a1185731..e1c62558 100644 --- a/src/imports/FluentUI/Controls/FluNavigationView.qml +++ b/src/imports/FluentUI/Controls/FluNavigationView.qml @@ -590,6 +590,7 @@ Item { d.enableNavigationPanel = false } } + Rectangle{ id:layout_list width: { @@ -620,10 +621,10 @@ Item { border.color: FluTheme.dark ? Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(226/255,230/255,234/255,1) border.width: d.isMinimal || d.isCompactAndPanel ? 1 : 0 color: { - if(d.isMinimal || d.isCompactAndPanel){ + if(d.isMinimal){ return FluTheme.dark ? Qt.rgba(61/255,61/255,61/255,1) : Qt.rgba(243/255,243/255,243/255,1) } - return "#00000000" + return "transparent" } x: { @@ -631,6 +632,20 @@ Item { return 0 return d.isMinimalAndPanel ? 0 : -width } + FluAcrylic { + sourceItem:nav_swipe + anchors.fill: layout_list + color: { + if(d.isMinimal){ + return FluTheme.dark ? Qt.rgba(61/255,61/255,61/255,1) : Qt.rgba(243/255,243/255,243/255,1) + } + return "transparent" + } + visible: d.isMinimal + rectX: layout_list.x + rectY: layout_list.y - 60 + acrylicOpacity:0.9 + } Item{ id:layout_header width: layout_list.width diff --git a/src/imports/FluentUI/Controls/FluWindow.qml b/src/imports/FluentUI/Controls/FluWindow.qml index 2c468ef4..284507bf 100644 --- a/src/imports/FluentUI/Controls/FluWindow.qml +++ b/src/imports/FluentUI/Controls/FluWindow.qml @@ -30,6 +30,7 @@ Window { } 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 signal initArgument(var argument) id:window color:"transparent" @@ -39,6 +40,7 @@ Window { initArgument(argument) } Rectangle{ + id: bg anchors.fill: parent color: backgroundColor Behavior on color{