cleaned up readme

This commit is contained in:
Atul R
2019-06-16 16:57:44 +02:00
parent 75cfa52836
commit 92a705b663
6 changed files with 75 additions and 109 deletions
@@ -15,15 +15,12 @@ class QPushButtonWrap : public Napi::ObjectWrap<QPushButtonWrap> {
QPushButtonWrap(const Napi::CallbackInfo& info);
~QPushButtonWrap();
NPushButton* getInternalInstance();
Napi::Value setupSignalListeners(const Napi::CallbackInfo& info);
//class constructor
static Napi::FunctionReference constructor;
//wrapped methods
Napi::Value setText(const Napi::CallbackInfo& info);
Napi::Value subscribeToEvent(const Napi::CallbackInfo& info);
QWIDGET_WRAPPED_METHODS_DECLARATION
};
+1 -1
View File
@@ -1,7 +1,7 @@
#include "eventwidget.h"
#include "deps/spdlog/spdlog.h"
void EventWidget::subscribeToEvent(std::string evtString){
void EventWidget::subscribeToQtEvent(std::string evtString){
try {
int evtType = EventsMap::events.at(evtString);
this->subscribedEvents.insert({static_cast<QEvent::Type>(evtType), evtString});
+1 -1
View File
@@ -9,7 +9,7 @@ public:
std::unique_ptr<ThreadSafeCallback> emitOnNode = nullptr;
std::unordered_map<QEvent::Type, std::string> subscribedEvents;
void subscribeToEvent(std::string evtString);
void subscribeToQtEvent(std::string evtString);
void event(QEvent* event);
+11 -1
View File
@@ -1,6 +1,7 @@
#pragma once
#include "eventwidget.h"
#include <QWidget>
/*
@@ -21,7 +22,7 @@ Napi::Value initNodeEventEmitter(const Napi::CallbackInfo& info) { \
Napi::Value subscribeToQtEvent(const Napi::CallbackInfo& info){ \
Napi::Env env = info.Env(); \
Napi::String eventString = info[0].As<Napi::String>(); \
this->instance->subscribeToEvent(eventString.Utf8Value()); \
this->instance->subscribeToQtEvent(eventString.Utf8Value()); \
return env.Null(); \
} \
@@ -36,3 +37,12 @@ Napi::Value subscribeToQtEvent(const Napi::CallbackInfo& info){ \
#endif // EVENTWIDGET_WRAPPED_METHODS_EXPORT_DEFINE
#ifndef EVENTWIDGET_IMPLEMENTATIONS
#define EVENTWIDGET_IMPLEMENTATIONS \
bool event(QEvent* event) { \
EventWidget::event(event); \
return QWidget::event(event); \
} \
#endif //EVENTWIDGET_IMPLEMENTATIONS
+2 -5
View File
@@ -1,6 +1,6 @@
#pragma once
#include "src/cpp/core/YogaWidget/yogawidget.h"
#include "src/cpp/core/Events/eventwidget.h"
#include "src/cpp/core/Events/eventwidget_macro.h"
// class to unify all the custom features + add extra features if needed
class NodeWidget : public YogaWidget, public EventWidget {
@@ -15,10 +15,7 @@ class NodeWidget : public YogaWidget, public EventWidget {
Q_OBJECT \
public: \
SET_YOGA_WIDGET_Q_PROPERTIES \
bool event(QEvent* event) { \
EventWidget::event(event); \
return QWidget::event(event); \
} \
EVENTWIDGET_IMPLEMENTATIONS \
#endif //NODEWIDGET_IMPLEMENTATIONS