From 358f0f0589613a5e2e858fd2937f0eb402a44af1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8A=B2=E9=B9=8F?= Date: Tue, 27 Apr 2021 10:22:05 +0800 Subject: [PATCH] add fast blur for image --- doric-Qt/doric/resources/image.qml | 17 +++++++++++++++++ doric-Qt/doric/shader/DoricImageNode.cpp | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/doric-Qt/doric/resources/image.qml b/doric-Qt/doric/resources/image.qml index fdae00dd..14052317 100644 --- a/doric-Qt/doric/resources/image.qml +++ b/doric-Qt/doric/resources/image.qml @@ -2,6 +2,7 @@ import QtQuick 2.12 import QtQuick.Controls 2.5 import "util.mjs" as Util +import QtGraphicalEffects 1.12 AnimatedImage { property var wrapper @@ -83,4 +84,20 @@ AnimatedImage { mouseAreaBridge.onClick(wrapper) } } + + property var isBlur: false + onIsBlurChanged: { + console.log(tag, uuid + " onIsBlurChanged: " + this.isBlur) + if (isBlur) { + this.layer.enabled = true + } else { + this.layer.enabled = false + } + } + + layer.enabled: false + layer.effect: FastBlur { + radius: 50 + transparentBorder: true + } } diff --git a/doric-Qt/doric/shader/DoricImageNode.cpp b/doric-Qt/doric/shader/DoricImageNode.cpp index 4bcdd3cd..d4cc1bb8 100644 --- a/doric-Qt/doric/shader/DoricImageNode.cpp +++ b/doric-Qt/doric/shader/DoricImageNode.cpp @@ -43,6 +43,10 @@ void DoricImageNode::blend(QQuickItem *view, QString name, QJsonValue prop) { } else if (name == "imageBase64") { container->setProperty("fillMode", this->contentMode); container->setProperty("source", prop.toString()); + } else if (name == "isBlur") { + if (prop.toBool()) { + container->setProperty("isBlur", prop.toBool()); + } } else { DoricViewNode::blend(view, name, prop); }