diff --git a/.clang-format b/.clang-format deleted file mode 100644 index 91eec24e7..000000000 --- a/.clang-format +++ /dev/null @@ -1,50 +0,0 @@ -Language: Cpp -AccessModifierOffset: -4 -AlignEscapedNewlinesLeft: true -AlignTrailingComments: true -AllowAllParametersOfDeclarationOnNextLine: true -AllowShortBlocksOnASingleLine: false -AllowShortFunctionsOnASingleLine: None -AllowShortIfStatementsOnASingleLine: false -AllowShortLoopsOnASingleLine: false -AlwaysBreakBeforeMultilineStrings: true -AlwaysBreakTemplateDeclarations: true -BinPackParameters: false -BreakBeforeBinaryOperators: false -BreakBeforeBraces: Stroustrup -BreakBeforeTernaryOperators: true -BreakConstructorInitializersBeforeComma: false -ColumnLimit: 80 -CommentPragmas: '' -ConstructorInitializerAllOnOneLineOrOnePerLine: true -ConstructorInitializerIndentWidth: 4 -ContinuationIndentWidth: 4 -DerivePointerAlignment: false -DisableFormat: false -ExperimentalAutoDetectBinPacking: false -IndentCaseLabels: false -IndentWidth: 4 -IndentWrappedFunctionNames: false -IndentFunctionDeclarationAfterType: false -MaxEmptyLinesToKeep: 1 -KeepEmptyLinesAtTheStartOfBlocks: false -NamespaceIndentation: None -PenaltyBreakBeforeFirstCallParameter: 1 -PenaltyBreakComment: 300 -PenaltyBreakString: 1000 -PenaltyBreakFirstLessLess: 120 -PenaltyExcessCharacter: 1 -PenaltyReturnTypeOnItsOwnLine: 1000 -PointerAlignment: Left -SpaceBeforeAssignmentOperators: true -SpaceBeforeParens: ControlStatements -SpaceInEmptyParentheses: false -SpacesBeforeTrailingComments: 1 -SpacesInAngles: false -SpacesInCStyleCastParentheses: false -SpacesInContainerLiterals: true -SpacesInParentheses: false -Cpp11BracedListStyle: true -Standard: Cpp11 -TabWidth: 4 -UseTab: Never \ No newline at end of file diff --git a/binding.gyp b/binding.gyp index 0c24c34ea..4c69014cc 100644 --- a/binding.gyp +++ b/binding.gyp @@ -5,7 +5,15 @@ "cflags_cc!": ["-fno-exceptions"], "sources": [ "src/cpp/main.cpp", + # non-wrapped cpps + "src/cpp/Extras/Utils/utils.cpp", + # wrapped cpps "src/cpp/QtGui/QApplication/qapplication_wrap.cpp", + "src/cpp/QtGui/QWidget/qwidget_wrap.cpp", + "src/cpp/QtWidgets/QGridLayout/qgridlayout_wrap.cpp", + "src/cpp/QtWidgets/QLabel/qlabel_wrap.cpp", + "src/cpp/QtWidgets/QLayout/qlayout_wrap.cpp", + "src/cpp/QtWidgets/QMainWindow/qmainwindow_wrap.cpp", ], 'conditions': [ ['OS=="mac"', { diff --git a/demo.js b/demo.js index 641bc2139..536900487 100644 --- a/demo.js +++ b/demo.js @@ -1,3 +1,26 @@ -const nodeDesktop = require("./src/index"); +const nodeDesktop = require("./index"); +const {QWidget,QGridLayout,QLabel,QMainWindow} = nodeDesktop; -console.log(nodeDesktop); +const win = new QMainWindow(); + +const view = new QWidget(); +win.setCentralWidget(view); + +const gridLayout = new QGridLayout(); + +const label = new QLabel(); +label.setText('Testing1234'); + +const label2 = new QLabel(); +label2.setText('Hello12321'); +label2.setStyleSheet('background-color:blue; color:white;'); + +gridLayout.addWidget(label); +gridLayout.addWidget(label2); + +view.setLayout(gridLayout); + +win.show(); + +console.log("THIS RAN"); +setInterval(()=>console.log("SHOW OFF"), 1000); \ No newline at end of file diff --git a/index.js b/index.js new file mode 100644 index 000000000..3316d85e7 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +const addon = require("./build/Release/node_desktop.node"); + +module.exports = addon; diff --git a/package.json b/package.json index f95354b7f..edf345677 100644 --- a/package.json +++ b/package.json @@ -9,9 +9,10 @@ "devDependencies": { "node-gyp": "^4.0.0" }, + "types": "index.d.ts", "scripts": { "build": "node-gyp -j 8 rebuild", - "dev": "node demo.js" + "dev": "qode demo.js" }, "dependencies": { "node-addon-api": "^1.6.3" diff --git a/src/cpp/Extras/Utils/utils.cpp b/src/cpp/Extras/Utils/utils.cpp new file mode 100644 index 000000000..492e68344 --- /dev/null +++ b/src/cpp/Extras/Utils/utils.cpp @@ -0,0 +1,8 @@ +#include "utils.h" +#include + +void extrautils::noop(){} + +void extrautils::throwTypeError(Napi::Env env, std::string errorMessage){ + Napi::TypeError::New(env, errorMessage.c_str()).ThrowAsJavaScriptException(); +} diff --git a/src/cpp/Extras/Utils/utils.h b/src/cpp/Extras/Utils/utils.h new file mode 100644 index 000000000..554a5a10f --- /dev/null +++ b/src/cpp/Extras/Utils/utils.h @@ -0,0 +1,11 @@ +#ifndef EXTRAUTILS_WRAP_H +#define EXTRAUTILS_WRAP_H + +#include + +namespace extrautils { + void noop(); + void throwTypeError(Napi::Env env, std::string errorMessage); +} + +#endif \ No newline at end of file diff --git a/src/cpp/QtGui/QApplication/qapplication_wrap.h b/src/cpp/QtGui/QApplication/qapplication_wrap.h index e5f84701f..635789547 100644 --- a/src/cpp/QtGui/QApplication/qapplication_wrap.h +++ b/src/cpp/QtGui/QApplication/qapplication_wrap.h @@ -1,8 +1,9 @@ #ifndef QAPPLICATION_WRAP_H #define QAPPLICATION_WRAP_H -#include #include +#include + class QApplicationWrap : public Napi::ObjectWrap { private: diff --git a/src/cpp/QtGui/QWidget/qwidget_wrap.cpp b/src/cpp/QtGui/QWidget/qwidget_wrap.cpp new file mode 100644 index 000000000..36776c017 --- /dev/null +++ b/src/cpp/QtGui/QWidget/qwidget_wrap.cpp @@ -0,0 +1,99 @@ +#include "qwidget_wrap.h" +#include "../../QtWidgets/QLayout/qlayout_wrap.h" +#include "../../Extras/Utils/utils.h" + +Napi::FunctionReference QWidgetWrap::constructor; + +Napi::Object QWidgetWrap::init(Napi::Env env, Napi::Object exports) { + Napi::HandleScope scope(env); + char CLASSNAME[] = "QWidget"; + Napi::Function func = DefineClass(env, CLASSNAME, { + InstanceMethod("show", &QWidgetWrap::show), + InstanceMethod("resize",&QWidgetWrap::resize), + InstanceMethod("close",&QWidgetWrap::close), + InstanceMethod("setLayout",&QWidgetWrap::setLayout), + InstanceMethod("setStyleSheet",&QWidgetWrap::setStyleSheet), + }); + constructor = Napi::Persistent(func); + exports.Set(CLASSNAME, func); + return exports; +} + +QWidget* QWidgetWrap::getInternalInstance() { + return this->instance; +} + +QWidgetWrap::QWidgetWrap(const Napi::CallbackInfo& info): Napi::ObjectWrap(info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + + if(info.Length() == 1) { + if(info[0].IsObject()){ + Napi::Object object_parent = info[0].As(); + QWidgetWrap* w_parent = Napi::ObjectWrap::Unwrap(object_parent); + this->instance = new QWidget(w_parent->getInternalInstance()); //this sets the parent to current widget + }else{ + extrautils::throwTypeError(env, "Wrong type of arguments"); + } + }else if (info.Length() == 0){ + this->instance = new QWidget(); + }else { + extrautils::throwTypeError(env, "Wrong number of arguments"); + } +} + +QWidgetWrap::~QWidgetWrap() { + delete this->instance; +} + +Napi::Value QWidgetWrap::show(const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + + this->instance->show(); + + return env.Null(); +} + +Napi::Value QWidgetWrap::resize(const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + + Napi::Number width = info[0].As(); + Napi::Number height = info[1].As(); + this->instance->resize(width.Int32Value(), height.Int32Value()); + + return env.Null(); +} + +Napi::Value QWidgetWrap::close(const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + + this->instance->close(); + + return env.Null(); +} + +Napi::Value QWidgetWrap::setLayout(const Napi::CallbackInfo& info){ + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + + Napi::Object layoutObject = info[0].As(); + QLayoutWrap* layoutParent = Napi::ObjectWrap::Unwrap(layoutObject); + this->instance->setLayout(layoutParent->getInternalInstance()); + + return env.Null(); +} + + +Napi::Value QWidgetWrap::setStyleSheet(const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + + Napi::String text = info[0].As(); + std::string style = text.Utf8Value(); + this->instance->setStyleSheet(style.c_str()); + + return env.Null(); +} diff --git a/src/cpp/QtGui/QWidget/qwidget_wrap.h b/src/cpp/QtGui/QWidget/qwidget_wrap.h new file mode 100644 index 000000000..23f7ac774 --- /dev/null +++ b/src/cpp/QtGui/QWidget/qwidget_wrap.h @@ -0,0 +1,25 @@ +#ifndef QWIDGET_WRAP_H +#define QWIDGET_WRAP_H + +#include +#include + +class QWidgetWrap : public Napi::ObjectWrap{ + private: + QWidget* instance; + public: + static Napi::Object init(Napi::Env env, Napi::Object exports); + QWidgetWrap(const Napi::CallbackInfo& info); + ~QWidgetWrap(); + QWidget* getInternalInstance(); + //class constructor + static Napi::FunctionReference constructor; + //wrapped methods + Napi::Value show(const Napi::CallbackInfo& info); + Napi::Value resize(const Napi::CallbackInfo& info); + Napi::Value close(const Napi::CallbackInfo& info); + Napi::Value setLayout(const Napi::CallbackInfo& info); + Napi::Value setStyleSheet(const Napi::CallbackInfo& info); +}; + +#endif \ No newline at end of file diff --git a/src/cpp/QtWidgets/QGridLayout/qgridlayout_wrap.cpp b/src/cpp/QtWidgets/QGridLayout/qgridlayout_wrap.cpp new file mode 100644 index 000000000..c8a22dddb --- /dev/null +++ b/src/cpp/QtWidgets/QGridLayout/qgridlayout_wrap.cpp @@ -0,0 +1,55 @@ +#include "qgridlayout_wrap.h" +#include "../../QtGui/QWidget/qwidget_wrap.h" +#include "../../Extras/Utils/utils.h" + +Napi::FunctionReference QGridLayoutWrap::constructor; + +Napi::Object QGridLayoutWrap::init(Napi::Env env, Napi::Object exports) { + Napi::HandleScope scope(env); + char CLASSNAME[] = "QGridLayout"; + Napi::Function func = DefineClass(env, CLASSNAME, { + InstanceMethod("addWidget", &QGridLayoutWrap::addWidget) + }); + constructor = Napi::Persistent(func); + exports.Set(CLASSNAME, func); + return exports; +} + +QGridLayout* QGridLayoutWrap::getInternalInstance() { + return this->instance; +} + +QGridLayoutWrap::QGridLayoutWrap(const Napi::CallbackInfo& info): Napi::ObjectWrap(info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + + if(info.Length() == 1) { + if(info[0].IsObject()){ + Napi::Object object_parent = info[0].As(); + QWidgetWrap* w_parent = Napi::ObjectWrap::Unwrap(object_parent); + this->instance = new QGridLayout(w_parent->getInternalInstance()); //this sets the parent to current widget + }else{ + extrautils::throwTypeError(env, "Wrong type of arguments"); + } + }else if (info.Length() == 0){ + this->instance = new QGridLayout(); + }else { + extrautils::throwTypeError(env, "Wrong number of arguments"); + } +} + +QGridLayoutWrap::~QGridLayoutWrap() { + delete this->instance; +} + +Napi::Value QGridLayoutWrap::addWidget(const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + + Napi::Object qwidgetObject = info[0].As(); + QWidgetWrap* widget = Napi::ObjectWrap::Unwrap(qwidgetObject); + this->instance->addWidget(widget->getInternalInstance()); + + return env.Null(); +} + diff --git a/src/cpp/QtWidgets/QGridLayout/qgridlayout_wrap.h b/src/cpp/QtWidgets/QGridLayout/qgridlayout_wrap.h new file mode 100644 index 000000000..dad361d29 --- /dev/null +++ b/src/cpp/QtWidgets/QGridLayout/qgridlayout_wrap.h @@ -0,0 +1,22 @@ +#ifndef QGRIDLAYOUT_WRAP_H +#define QGRIDLAYOUT_WRAP_H + +#include +#include + +class QGridLayoutWrap : public Napi::ObjectWrap{ + private: + QGridLayout* instance; + + public: + static Napi::Object init(Napi::Env env, Napi::Object exports); + QGridLayoutWrap(const Napi::CallbackInfo& info); + ~QGridLayoutWrap(); + QGridLayout* getInternalInstance(); + //class constructor + static Napi::FunctionReference constructor; + //wrapped methods + Napi::Value addWidget(const Napi::CallbackInfo& info); +}; + +#endif \ No newline at end of file diff --git a/src/cpp/QtWidgets/QLabel/qlabel_wrap.cpp b/src/cpp/QtWidgets/QLabel/qlabel_wrap.cpp new file mode 100644 index 000000000..f831f09e0 --- /dev/null +++ b/src/cpp/QtWidgets/QLabel/qlabel_wrap.cpp @@ -0,0 +1,79 @@ +#include "qlabel_wrap.h" +#include "../../QtGui/QWidget/qwidget_wrap.h" +#include "../../Extras/Utils/utils.h" +#include + + +Napi::FunctionReference QLabelWrap::constructor; + +Napi::Object QLabelWrap::init(Napi::Env env, Napi::Object exports) { + Napi::HandleScope scope(env); + char CLASSNAME[] = "QLabel"; + Napi::Function func = DefineClass(env, CLASSNAME, { + InstanceMethod("setWordWrap", &QLabelWrap::setWordWrap), + InstanceMethod("setText", &QLabelWrap::setText), + InstanceMethod("setStyleSheet", &QLabelWrap::setStyleSheet) + }); + constructor = Napi::Persistent(func); + exports.Set(CLASSNAME, func); + return exports; +} + +QLabel* QLabelWrap::getInternalInstance() { + return this->instance; +} + +QLabelWrap::QLabelWrap(const Napi::CallbackInfo& info): Napi::ObjectWrap(info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + + if(info.Length() == 1) { + if(info[0].IsObject()){ + Napi::Object object_parent = info[0].As(); + QWidgetWrap* w_parent = Napi::ObjectWrap::Unwrap(object_parent); + this->instance = new QLabel(w_parent->getInternalInstance()); //this sets the parent to current widget + }else{ + extrautils::throwTypeError(env, "Wrong type of arguments"); + } + }else if (info.Length() == 0){ + this->instance = new QLabel(); + }else { + extrautils::throwTypeError(env, "Wrong number of arguments"); + } +} + +QLabelWrap::~QLabelWrap() { + delete this->instance; +} + +Napi::Value QLabelWrap::setWordWrap(const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + + Napi::Boolean On = info[0].As(); + this->instance->setWordWrap(On); + + return env.Null(); +} + +Napi::Value QLabelWrap::setText(const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + + Napi::String text = info[0].As(); + std::string label = text.Utf8Value(); + this->instance->setText(label.c_str()); + + return env.Null(); +} + +Napi::Value QLabelWrap::setStyleSheet(const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + + Napi::String text = info[0].As(); + std::string style = text.Utf8Value(); + this->instance->setStyleSheet(style.c_str()); + + return env.Null(); +} diff --git a/src/cpp/QtWidgets/QLabel/qlabel_wrap.h b/src/cpp/QtWidgets/QLabel/qlabel_wrap.h new file mode 100644 index 000000000..04f53918c --- /dev/null +++ b/src/cpp/QtWidgets/QLabel/qlabel_wrap.h @@ -0,0 +1,22 @@ +#ifndef QLABEL_WRAP_H +#define QLABEL_WRAP_H +#include +#include + +class QLabelWrap : public Napi::ObjectWrap{ + private: + QLabel* instance; + public: + static Napi::Object init(Napi::Env env, Napi::Object exports); + QLabelWrap(const Napi::CallbackInfo& info); + ~QLabelWrap(); + QLabel* getInternalInstance(); + //class constructor + static Napi::FunctionReference constructor; + //wrapped methods + Napi::Value setWordWrap(const Napi::CallbackInfo& info); + Napi::Value setText(const Napi::CallbackInfo& info); + Napi::Value setStyleSheet(const Napi::CallbackInfo& info); +}; + +#endif \ No newline at end of file diff --git a/src/cpp/QtWidgets/QLayout/qlayout_wrap.cpp b/src/cpp/QtWidgets/QLayout/qlayout_wrap.cpp new file mode 100644 index 000000000..c453439ef --- /dev/null +++ b/src/cpp/QtWidgets/QLayout/qlayout_wrap.cpp @@ -0,0 +1,22 @@ +#include "qlayout_wrap.h" + +Napi::FunctionReference QLayoutWrap::constructor; + +void QLayoutWrap::init(Napi::Env env) { + char CLASSNAME[] = "QLayout"; + Napi::Function func = DefineClass(env, CLASSNAME, {}); + constructor = Napi::Persistent(func); +} + +QLayout* QLayoutWrap::getInternalInstance() { + return this->instance; +} + +QLayoutWrap::QLayoutWrap(const Napi::CallbackInfo& info): Napi::ObjectWrap(info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); +} + +QLayoutWrap::~QLayoutWrap() { + delete this->instance; +} diff --git a/src/cpp/QtWidgets/QLayout/qlayout_wrap.h b/src/cpp/QtWidgets/QLayout/qlayout_wrap.h new file mode 100644 index 000000000..7ed0e1cbb --- /dev/null +++ b/src/cpp/QtWidgets/QLayout/qlayout_wrap.h @@ -0,0 +1,19 @@ +#ifndef QLAYOUT_WRAP_H +#define QLAYOUT_WRAP_H +#include +#include + +//ABSTRACT CLASS +class QLayoutWrap : public Napi::ObjectWrap{ + private: + QLayout* instance; + public: + static void init(Napi::Env env); + QLayoutWrap(const Napi::CallbackInfo& info); + ~QLayoutWrap(); + QLayout* getInternalInstance(); + //class constructor + static Napi::FunctionReference constructor; +}; + +#endif \ No newline at end of file diff --git a/src/cpp/QtWidgets/QMainWindow/qmainwindow_wrap.cpp b/src/cpp/QtWidgets/QMainWindow/qmainwindow_wrap.cpp new file mode 100644 index 000000000..1c17dec98 --- /dev/null +++ b/src/cpp/QtWidgets/QMainWindow/qmainwindow_wrap.cpp @@ -0,0 +1,101 @@ +#include "qmainwindow_wrap.h" +#include "../../QtGui/QWidget/qwidget_wrap.h" +#include "../../Extras/Utils/utils.h" + +Napi::FunctionReference QMainWindowWrap::constructor; + +Napi::Object QMainWindowWrap::init(Napi::Env env, Napi::Object exports) { + Napi::HandleScope scope(env); + char CLASSNAME[] = "QMainWindow"; + Napi::Function func = DefineClass(env, CLASSNAME, { + InstanceMethod("setStyleSheet", &QMainWindowWrap::setStyleSheet), + InstanceMethod("show", &QMainWindowWrap::show), + InstanceMethod("resize",&QMainWindowWrap::resize), + InstanceMethod("close",&QMainWindowWrap::close), + InstanceMethod("setCentralWidget",&QMainWindowWrap::setCentralWidget), + }); + constructor = Napi::Persistent(func); + exports.Set(CLASSNAME, func); + return exports; +} + +QMainWindow* QMainWindowWrap::getInternalInstance() { + return this->instance; +} + +QMainWindowWrap::QMainWindowWrap(const Napi::CallbackInfo& info): Napi::ObjectWrap(info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + + if(info.Length() == 1) { + if(info[0].IsObject()){ + Napi::Object object_parent = info[0].As(); + QWidgetWrap* w_parent = Napi::ObjectWrap::Unwrap(object_parent); + this->instance = new QMainWindow(w_parent->getInternalInstance()); //this sets the parent to current widget + }else{ + extrautils::throwTypeError(env, "Wrong type of arguments"); + } + }else if (info.Length() == 0){ + this->instance = new QMainWindow(); + }else { + extrautils::throwTypeError(env, "Wrong number of arguments"); + } +} + +QMainWindowWrap::~QMainWindowWrap() { + delete this->instance; +} + +Napi::Value QMainWindowWrap::setStyleSheet(const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + + Napi::String text = info[0].As(); + std::string style = text.Utf8Value(); + this->instance->setStyleSheet(style.c_str()); + + return env.Null(); +} + +Napi::Value QMainWindowWrap::show(const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + + this->instance->show(); + + return env.Null(); +} + +Napi::Value QMainWindowWrap::resize(const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + + Napi::Number width = info[0].As(); + Napi::Number height = info[1].As(); + this->instance->resize(width.Int32Value(), height.Int32Value()); + + return env.Null(); +} + +Napi::Value QMainWindowWrap::close(const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + + this->instance->close(); + + return env.Null(); +} + +Napi::Value QMainWindowWrap::setCentralWidget(const Napi::CallbackInfo& info){ + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + + Napi::Object widgetObject = info[0].As(); + QWidgetWrap* centralWidget = Napi::ObjectWrap::Unwrap(widgetObject); + this->instance->setCentralWidget(centralWidget->getInternalInstance()); + + return env.Null(); +} + + + diff --git a/src/cpp/QtWidgets/QMainWindow/qmainwindow_wrap.h b/src/cpp/QtWidgets/QMainWindow/qmainwindow_wrap.h new file mode 100644 index 000000000..19b609ee5 --- /dev/null +++ b/src/cpp/QtWidgets/QMainWindow/qmainwindow_wrap.h @@ -0,0 +1,26 @@ +#ifndef QMAINWINDOW_WRAP_H +#define QMAINWINDOW_WRAP_H + +#include +#include + +class QMainWindowWrap : public Napi::ObjectWrap{ +private: + QMainWindow* instance; + +public: + static Napi::Object init(Napi::Env env, Napi::Object exports); + QMainWindowWrap(const Napi::CallbackInfo& info); + ~QMainWindowWrap(); + QMainWindow* getInternalInstance(); + //class constructor + static Napi::FunctionReference constructor; + //wrapped methods + Napi::Value setStyleSheet(const Napi::CallbackInfo& info); + Napi::Value show(const Napi::CallbackInfo& info); + Napi::Value resize(const Napi::CallbackInfo& info); + Napi::Value close(const Napi::CallbackInfo& info); + Napi::Value setCentralWidget(const Napi::CallbackInfo& info); +}; + +#endif \ No newline at end of file diff --git a/src/cpp/main.cpp b/src/cpp/main.cpp index edfec7bc4..0635cb31f 100644 --- a/src/cpp/main.cpp +++ b/src/cpp/main.cpp @@ -1,10 +1,26 @@ -#include #include "QtGui/QApplication/qapplication_wrap.h" +#include "QtGui/QWidget/qwidget_wrap.h" +#include "QtWidgets/QGridLayout/qgridlayout_wrap.h" +#include "QtWidgets/QLayout/qlayout_wrap.h" +#include "QtWidgets/QLabel/qlabel_wrap.h" +#include "QtWidgets/QMainWindow/qmainwindow_wrap.h" +#include -Napi::Object Main(Napi::Env env, Napi::Object exports) -{ - QApplicationWrap::init(env, exports); - return exports; + + +//private : will not be accessibe in js +void InitPrivateHelpers(Napi::Env env){ + QLayoutWrap::init(env); //Abstact class wrapper for pointing to any layout } +Napi::Object Main(Napi::Env env, Napi::Object exports) { + InitPrivateHelpers(env); + QApplicationWrap::init(env, exports); + QWidgetWrap::init(env, exports); + QGridLayoutWrap::init(env, exports); + QMainWindowWrap::init(env,exports); + return QLabelWrap::init(env, exports); +} + + NODE_API_MODULE(NODE_GYP_MODULE_NAME, Main) diff --git a/src/index.js b/src/index.js deleted file mode 100644 index 7fb74cc1e..000000000 --- a/src/index.js +++ /dev/null @@ -1,3 +0,0 @@ -const addon = require("../build/Release/node_desktop.node"); - -module.exports = addon;