add switch node
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#include "shader/DoricRootNode.h"
|
||||
#include "shader/DoricScrollerNode.h"
|
||||
#include "shader/DoricStackNode.h"
|
||||
#include "shader/DoricSwitchNode.h"
|
||||
#include "shader/DoricTextNode.h"
|
||||
#include "shader/DoricVLayoutNode.h"
|
||||
#include "shader/slider/DoricSlideItemNode.h"
|
||||
@@ -35,6 +36,7 @@ DoricRegistry::DoricRegistry() {
|
||||
registerViewNode<DoricSliderNode>("Slider");
|
||||
registerViewNode<DoricSlideItemNode>("SlideItem");
|
||||
registerViewNode<DoricInputNode>("Input");
|
||||
registerViewNode<DoricSwitchNode>("Switch");
|
||||
}
|
||||
|
||||
bool DoricRegistry::acquirePluginInfo(QString name) {
|
||||
|
@@ -50,6 +50,7 @@ SOURCES += \
|
||||
shader/DoricScrollerNode.cpp \
|
||||
shader/DoricStackNode.cpp \
|
||||
shader/DoricSuperNode.cpp \
|
||||
shader/DoricSwitchNode.cpp \
|
||||
shader/DoricTextNode.cpp \
|
||||
shader/DoricVLayoutNode.cpp \
|
||||
shader/DoricViewNode.cpp \
|
||||
@@ -130,6 +131,7 @@ HEADERS += \
|
||||
shader/DoricScrollerNode.h \
|
||||
shader/DoricStackNode.h \
|
||||
shader/DoricSuperNode.h \
|
||||
shader/DoricSwitchNode.h \
|
||||
shader/DoricTextNode.h \
|
||||
shader/DoricVLayoutNode.h \
|
||||
shader/DoricViewNode.h \
|
||||
|
6
doric-Qt/example/doric/resources/switch.qml
Normal file
6
doric-Qt/example/doric/resources/switch.qml
Normal file
@@ -0,0 +1,6 @@
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.5
|
||||
|
||||
Switch {
|
||||
|
||||
}
|
36
doric-Qt/example/doric/shader/DoricSwitchNode.cpp
Normal file
36
doric-Qt/example/doric/shader/DoricSwitchNode.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#include "DoricSwitchNode.h"
|
||||
|
||||
#include "../utils/DoricUtils.h"
|
||||
|
||||
QQuickItem *DoricSwitchNode::build() {
|
||||
QQmlComponent component(getContext()->getQmlEngine());
|
||||
|
||||
const QUrl url(QStringLiteral("qrc:/doric/qml/switch.qml"));
|
||||
component.loadUrl(url);
|
||||
|
||||
if (component.isError()) {
|
||||
qCritical() << component.errorString();
|
||||
}
|
||||
|
||||
QQuickItem *item = qobject_cast<QQuickItem *>(component.create());
|
||||
this->createLayouts(item);
|
||||
|
||||
item->setProperty("wrapper", QString::number((qint64)this));
|
||||
return item;
|
||||
}
|
||||
|
||||
void DoricSwitchNode::blend(QQuickItem *view, QString name, QJsonValue prop) {
|
||||
if (name == "state") {
|
||||
|
||||
} else if (name == "onSwitch") {
|
||||
|
||||
} else if (name == "offTintColor") {
|
||||
|
||||
} else if (name == "onTintColor") {
|
||||
|
||||
} else if (name == "thumbTintColor") {
|
||||
|
||||
} else {
|
||||
DoricViewNode::blend(view, name, prop);
|
||||
}
|
||||
}
|
17
doric-Qt/example/doric/shader/DoricSwitchNode.h
Normal file
17
doric-Qt/example/doric/shader/DoricSwitchNode.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef DORICSWITCHNODE_H
|
||||
#define DORICSWITCHNODE_H
|
||||
|
||||
#include "DoricExport.h"
|
||||
|
||||
#include "DoricViewNode.h"
|
||||
|
||||
class DORIC_EXPORT DoricSwitchNode : public DoricViewNode {
|
||||
public:
|
||||
using DoricViewNode::DoricViewNode;
|
||||
|
||||
QQuickItem *build() override;
|
||||
|
||||
virtual void blend(QQuickItem *view, QString name, QJsonValue prop) override;
|
||||
};
|
||||
|
||||
#endif // DORICSWITCHNODE_H
|
Reference in New Issue
Block a user