From 94045f11bfcc555ca393e73a75b56dca624a5a9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8A=B2=E9=B9=8F?= Date: Mon, 31 May 2021 19:28:45 +0800 Subject: [PATCH] apply slide item --- doric-Qt/example/app/demo/DoricDemoBridge.cpp | 3 +++ doric-Qt/example/doric/doric.pro | 2 ++ .../example/doric/resources/slide-item.qml | 4 ++++ .../shader/slider/DoricSlideItemNode.cpp | 2 ++ .../doric/shader/slider/DoricSlideItemNode.h | 2 ++ .../doric/utils/DoricSlideItemBridge.cpp | 13 +++++++++++++ .../doric/utils/DoricSlideItemBridge.h | 19 +++++++++++++++++++ 7 files changed, 45 insertions(+) create mode 100644 doric-Qt/example/doric/utils/DoricSlideItemBridge.cpp create mode 100644 doric-Qt/example/doric/utils/DoricSlideItemBridge.h diff --git a/doric-Qt/example/app/demo/DoricDemoBridge.cpp b/doric-Qt/example/app/demo/DoricDemoBridge.cpp index 1ce8fc05..92d3f03c 100644 --- a/doric-Qt/example/app/demo/DoricDemoBridge.cpp +++ b/doric-Qt/example/app/demo/DoricDemoBridge.cpp @@ -8,6 +8,7 @@ #include "utils/DoricImageBridge.h" #include "utils/DoricInputBridge.h" #include "utils/DoricMouseAreaBridge.h" +#include "utils/DoricSlideItemBridge.h" #include "utils/DoricSwitchBridge.h" #include "utils/DoricUtils.h" @@ -120,4 +121,6 @@ void DoricDemoBridge::navigate(QVariant route) { context->setContextProperty("inputBridge", inputBridge); DoricSwitchBridge *switchBridge = new DoricSwitchBridge(); context->setContextProperty("switchBridge", switchBridge); + DoricSlideItemBridge *slideItemBridge = new DoricSlideItemBridge(); + context->setContextProperty("slideItemBridge", slideItemBridge); } diff --git a/doric-Qt/example/doric/doric.pro b/doric-Qt/example/doric/doric.pro index f15d0efb..43aa88e1 100644 --- a/doric-Qt/example/doric/doric.pro +++ b/doric-Qt/example/doric/doric.pro @@ -62,6 +62,7 @@ SOURCES += \ utils/DoricInputBridge.cpp \ utils/DoricLayouts.cpp \ utils/DoricMouseAreaBridge.cpp \ + utils/DoricSlideItemBridge.cpp \ utils/DoricSwitchBridge.cpp \ widget/flex/FlexLayout.cpp \ widget/flex/FlexLayoutConfig.cpp \ @@ -147,6 +148,7 @@ HEADERS += \ utils/DoricMouseAreaBridge.h \ utils/DoricNetworkService.h \ utils/DoricObjectFactory.h \ + utils/DoricSlideItemBridge.h \ utils/DoricSwitchBridge.h \ utils/DoricThreadMode.h \ utils/DoricUtils.h \ diff --git a/doric-Qt/example/doric/resources/slide-item.qml b/doric-Qt/example/doric/resources/slide-item.qml index cd6581e2..c117d3fe 100644 --- a/doric-Qt/example/doric/resources/slide-item.qml +++ b/doric-Qt/example/doric/resources/slide-item.qml @@ -19,12 +19,16 @@ Rectangle { console.log(tag, uuid + " onWidthChanged: " + this.width) updateGradient() + + slideItemBridge.apply(wrapper) } onHeightChanged: { console.log(tag, uuid + " onHeightChanged: " + this.height) updateGradient() + + slideItemBridge.apply(wrapper) } color: 'transparent' diff --git a/doric-Qt/example/doric/shader/slider/DoricSlideItemNode.cpp b/doric-Qt/example/doric/shader/slider/DoricSlideItemNode.cpp index b1a1764c..61093134 100644 --- a/doric-Qt/example/doric/shader/slider/DoricSlideItemNode.cpp +++ b/doric-Qt/example/doric/shader/slider/DoricSlideItemNode.cpp @@ -18,3 +18,5 @@ QQuickItem *DoricSlideItemNode::build() { item->setProperty("wrapper", QString::number((qint64)this)); return item; } + +void DoricSlideItemNode::apply() { getLayouts()->apply(); } diff --git a/doric-Qt/example/doric/shader/slider/DoricSlideItemNode.h b/doric-Qt/example/doric/shader/slider/DoricSlideItemNode.h index 628fe41f..e32b5e2e 100644 --- a/doric-Qt/example/doric/shader/slider/DoricSlideItemNode.h +++ b/doric-Qt/example/doric/shader/slider/DoricSlideItemNode.h @@ -10,6 +10,8 @@ public: using DoricStackNode::DoricStackNode; QQuickItem *build() override; + + void apply(); }; #endif // DORICSLIDEITEMNODE_H diff --git a/doric-Qt/example/doric/utils/DoricSlideItemBridge.cpp b/doric-Qt/example/doric/utils/DoricSlideItemBridge.cpp new file mode 100644 index 00000000..5126924c --- /dev/null +++ b/doric-Qt/example/doric/utils/DoricSlideItemBridge.cpp @@ -0,0 +1,13 @@ +#include "DoricSlideItemBridge.h" + +#include "shader/slider/DoricSlideItemNode.h" + +DoricSlideItemBridge::DoricSlideItemBridge(QObject *parent) : QObject(parent) {} + +void DoricSlideItemBridge::apply(QString pointer) { + QObject *object = (QObject *)(pointer.toULongLong()); + DoricSlideItemNode *slideItemNode = + dynamic_cast(object); + + slideItemNode->apply(); +} diff --git a/doric-Qt/example/doric/utils/DoricSlideItemBridge.h b/doric-Qt/example/doric/utils/DoricSlideItemBridge.h new file mode 100644 index 00000000..ed541c46 --- /dev/null +++ b/doric-Qt/example/doric/utils/DoricSlideItemBridge.h @@ -0,0 +1,19 @@ +#ifndef DORICSLIDEITEMBRIDGE_H +#define DORICSLIDEITEMBRIDGE_H + +#include +#include + +#include "DoricExport.h" + +class DORIC_EXPORT DoricSlideItemBridge : public QObject { + Q_OBJECT +public: + explicit DoricSlideItemBridge(QObject *parent = nullptr); + + Q_INVOKABLE + void apply(QString pointer); +signals: +}; + +#endif // DORICSLIDEITEMBRIDGE_H