handle response
This commit is contained in:
parent
a0a6ebf50d
commit
80301837c3
@ -5,6 +5,7 @@
|
|||||||
#include "DoricDemoBridge.h"
|
#include "DoricDemoBridge.h"
|
||||||
#include "DoricPanel.h"
|
#include "DoricPanel.h"
|
||||||
#include "utils/DoricDialogBridge.h"
|
#include "utils/DoricDialogBridge.h"
|
||||||
|
#include "utils/DoricDraggableBridge.h"
|
||||||
#include "utils/DoricImageBridge.h"
|
#include "utils/DoricImageBridge.h"
|
||||||
#include "utils/DoricInputBridge.h"
|
#include "utils/DoricInputBridge.h"
|
||||||
#include "utils/DoricMouseAreaBridge.h"
|
#include "utils/DoricMouseAreaBridge.h"
|
||||||
@ -129,4 +130,6 @@ void DoricDemoBridge::navigate(QVariant route) {
|
|||||||
context->setContextProperty("slideItemBridge", slideItemBridge);
|
context->setContextProperty("slideItemBridge", slideItemBridge);
|
||||||
DoricSliderBridge *sliderBridge = new DoricSliderBridge();
|
DoricSliderBridge *sliderBridge = new DoricSliderBridge();
|
||||||
context->setContextProperty("sliderBridge", sliderBridge);
|
context->setContextProperty("sliderBridge", sliderBridge);
|
||||||
|
DoricDraggableBridge *draggableBridge = new DoricDraggableBridge();
|
||||||
|
context->setContextProperty("draggableBridge", draggableBridge);
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,7 @@ SOURCES += \
|
|||||||
utils/DoricConstant.cpp \
|
utils/DoricConstant.cpp \
|
||||||
utils/DoricContextHolder.cpp \
|
utils/DoricContextHolder.cpp \
|
||||||
utils/DoricDialogBridge.cpp \
|
utils/DoricDialogBridge.cpp \
|
||||||
|
utils/DoricDraggableBridge.cpp \
|
||||||
utils/DoricImageBridge.cpp \
|
utils/DoricImageBridge.cpp \
|
||||||
utils/DoricInputBridge.cpp \
|
utils/DoricInputBridge.cpp \
|
||||||
utils/DoricLayouts.cpp \
|
utils/DoricLayouts.cpp \
|
||||||
@ -145,6 +146,7 @@ HEADERS += \
|
|||||||
utils/DoricContextHolder.h \
|
utils/DoricContextHolder.h \
|
||||||
utils/DoricCountDownLatch.h \
|
utils/DoricCountDownLatch.h \
|
||||||
utils/DoricDialogBridge.h \
|
utils/DoricDialogBridge.h \
|
||||||
|
utils/DoricDraggableBridge.h \
|
||||||
utils/DoricImageBridge.h \
|
utils/DoricImageBridge.h \
|
||||||
utils/DoricInputBridge.h \
|
utils/DoricInputBridge.h \
|
||||||
utils/DoricLayouts.h \
|
utils/DoricLayouts.h \
|
||||||
|
@ -88,7 +88,8 @@ v8::Local<v8::Value> Variant2JS(QVariant variant) {
|
|||||||
result.ToChecked();
|
result.ToChecked();
|
||||||
}
|
}
|
||||||
jsValue = array;
|
jsValue = array;
|
||||||
} else if (variant.type() == QVariant::Int) {
|
} else if (variant.type() == QVariant::Int ||
|
||||||
|
variant.type() == QVariant::Double) {
|
||||||
jsValue = v8::Number::New(isolate, variant.toDouble());
|
jsValue = v8::Number::New(isolate, variant.toDouble());
|
||||||
} else if (variant.type() == QVariant::Bool) {
|
} else if (variant.type() == QVariant::Bool) {
|
||||||
jsValue = v8::Boolean::New(isolate, variant.toBool());
|
jsValue = v8::Boolean::New(isolate, variant.toBool());
|
||||||
|
@ -60,6 +60,8 @@ Rectangle {
|
|||||||
let yDiff = positionToRootParent.y - positionToRoot.y
|
let yDiff = positionToRootParent.y - positionToRoot.y
|
||||||
|
|
||||||
console.log(tag, uuid + " onPositionChanged: " + xDiff + ", " + yDiff)
|
console.log(tag, uuid + " onPositionChanged: " + xDiff + ", " + yDiff)
|
||||||
|
|
||||||
|
draggableBridge.onDrag(wrapper, xDiff, yDiff)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,8 +20,17 @@ QQuickItem *DoricDraggableNode::build() {
|
|||||||
void DoricDraggableNode::blend(QQuickItem *view, QString name,
|
void DoricDraggableNode::blend(QQuickItem *view, QString name,
|
||||||
QJsonValue prop) {
|
QJsonValue prop) {
|
||||||
if (name == "onDrag") {
|
if (name == "onDrag") {
|
||||||
onDrag = prop.toString();
|
onDragFunction = prop.toString();
|
||||||
} else {
|
} else {
|
||||||
DoricStackNode::blend(view, name, prop);
|
DoricStackNode::blend(view, name, prop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DoricDraggableNode::onDrag(double x, double y) {
|
||||||
|
getLayouts()->setMarginLeft(x);
|
||||||
|
getLayouts()->setMarginTop(y);
|
||||||
|
QVariantList args;
|
||||||
|
args.append(x);
|
||||||
|
args.append(y);
|
||||||
|
callJSResponse(onDragFunction, args);
|
||||||
|
}
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
class DORIC_EXPORT DoricDraggableNode : public DoricStackNode {
|
class DORIC_EXPORT DoricDraggableNode : public DoricStackNode {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString onDrag;
|
QString onDragFunction;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using DoricStackNode::DoricStackNode;
|
using DoricStackNode::DoricStackNode;
|
||||||
@ -16,6 +16,8 @@ public:
|
|||||||
QQuickItem *build() override;
|
QQuickItem *build() override;
|
||||||
|
|
||||||
virtual void blend(QQuickItem *view, QString name, QJsonValue prop) override;
|
virtual void blend(QQuickItem *view, QString name, QJsonValue prop) override;
|
||||||
|
|
||||||
|
void onDrag(double x, double y);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DORICDRAGGABLENODE_H
|
#endif // DORICDRAGGABLENODE_H
|
||||||
|
12
doric-Qt/example/doric/utils/DoricDraggableBridge.cpp
Normal file
12
doric-Qt/example/doric/utils/DoricDraggableBridge.cpp
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#include "DoricDraggableBridge.h"
|
||||||
|
#include "shader/DoricDraggableNode.h"
|
||||||
|
|
||||||
|
DoricDraggableBridge::DoricDraggableBridge(QObject *parent) : QObject(parent) {}
|
||||||
|
|
||||||
|
void DoricDraggableBridge::onDrag(QString pointer, double x, double y) {
|
||||||
|
QObject *object = (QObject *)(pointer.toULongLong());
|
||||||
|
DoricDraggableNode *draggableNode =
|
||||||
|
dynamic_cast<DoricDraggableNode *>(object);
|
||||||
|
|
||||||
|
draggableNode->onDrag(x, y);
|
||||||
|
}
|
18
doric-Qt/example/doric/utils/DoricDraggableBridge.h
Normal file
18
doric-Qt/example/doric/utils/DoricDraggableBridge.h
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#ifndef DORICDRAGGABLEBRIDGE_H
|
||||||
|
#define DORICDRAGGABLEBRIDGE_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QVariant>
|
||||||
|
|
||||||
|
#include "DoricExport.h"
|
||||||
|
|
||||||
|
class DORIC_EXPORT DoricDraggableBridge : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit DoricDraggableBridge(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
Q_INVOKABLE
|
||||||
|
void onDrag(QString pointer, double x, double y);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DORICDRAGGABLEBRIDGE_H
|
Reference in New Issue
Block a user