* Added QMessageBox * Adds Qdialog * Fixes inheritance and adds pointer based event listener * Cleans up Qmessagebox so that we create all buttons * change to abstract button * fix rawData fetching from the template * formatting fixes * change to Objectwrap for better type casting * Adds Native element part in qpushbutton * Adds NapiExternal check and use ptr for initialization * Adds all button classes * fix c * fix merge conflicts * lint fix Co-authored-by: Atul R <atulanand94@gmail.com>
45 lines
1.5 KiB
C++
45 lines
1.5 KiB
C++
#include "QtWidgets/QDialog/qdialog_wrap.h"
|
|
|
|
#include "Extras/Utils/nutils.h"
|
|
|
|
Napi::FunctionReference QDialogWrap::constructor;
|
|
|
|
Napi::Object QDialogWrap::init(Napi::Env env, Napi::Object exports) {
|
|
Napi::HandleScope scope(env);
|
|
char CLASSNAME[] = "QDialog";
|
|
Napi::Function func = DefineClass(
|
|
env, CLASSNAME, {QDIALOG_WRAPPED_METHODS_EXPORT_DEFINE(QDialogWrap)});
|
|
constructor = Napi::Persistent(func);
|
|
exports.Set(CLASSNAME, func);
|
|
return exports;
|
|
}
|
|
|
|
NDialog *QDialogWrap::getInternalInstance() { return this->instance; }
|
|
|
|
QDialogWrap::~QDialogWrap() { extrautils::safeDelete(this->instance); }
|
|
|
|
QDialogWrap::QDialogWrap(const Napi::CallbackInfo &info)
|
|
: Napi::ObjectWrap<QDialogWrap>(info) {
|
|
Napi::Env env = info.Env();
|
|
Napi::HandleScope scope(env);
|
|
if (info.Length() == 1) {
|
|
if (info[0].IsExternal()) {
|
|
this->instance =
|
|
new NDialog(info[0].As<Napi::External<NDialog>>().Data());
|
|
} else {
|
|
Napi::Object parentObject = info[0].As<Napi::Object>();
|
|
QDialogWrap *parentWidgetWrap =
|
|
Napi::ObjectWrap<QDialogWrap>::Unwrap(parentObject);
|
|
this->instance = new NDialog(parentWidgetWrap->getInternalInstance());
|
|
}
|
|
} else if (info.Length() == 0) {
|
|
this->instance = new NDialog();
|
|
} else {
|
|
Napi::TypeError::New(env, "Wrong number of arguments")
|
|
.ThrowAsJavaScriptException();
|
|
}
|
|
this->rawData = extrautils::configureQWidget(
|
|
this->getInternalInstance(), this->getInternalInstance()->getFlexNode(),
|
|
false);
|
|
}
|