Added QMessageBox (#326)
* 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>
This commit is contained in:
parent
f409eeb7b0
commit
fd270c18ac
@ -57,6 +57,7 @@ add_library(${CORE_WIDGETS_ADDON} SHARED
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtCore/QPoint/qpoint_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtCore/QUrl/qurl_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QWidget/qwidget_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QDialog/qdialog_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QBoxLayout/qboxlayout_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QComboBox/qcombobox_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QFileDialog/qfiledialog_wrap.cpp"
|
||||
@ -89,12 +90,14 @@ add_library(${CORE_WIDGETS_ADDON} SHARED
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QGroupBox/qgroupbox_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QTreeWidget/qtreewidget_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QTreeWidgetItem/qtreewidgetitem_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QMessageBox/qmessagebox_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/core/FlexLayout/flexlayout_wrap.cpp"
|
||||
# Custom widgets (include them for automoc since they contain Q_OBJECT)
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtCore/QObject/nobject.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/core/FlexLayout/flexlayout.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtGui/QMovie/nmovie.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QWidget/nwidget.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QDialog/ndialog.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QLabel/nlabel.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QCheckBox/ncheckbox.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QDial/ndial.hpp"
|
||||
@ -105,6 +108,7 @@ add_library(${CORE_WIDGETS_ADDON} SHARED
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QMainWindow/nmainwindow.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QProgressBar/nprogressbar.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QPushButton/npushbutton.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QMessageBox/nmessagebox.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QToolButton/ntoolbutton.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QSpinBox/nspinbox.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QRadioButton/nradiobutton.hpp"
|
||||
|
||||
@ -25,3 +25,14 @@ void safeDelete(QPointer<T>& component) {
|
||||
}
|
||||
void initAppSettings();
|
||||
} // namespace extrautils
|
||||
|
||||
class NUtilsWrap : public Napi::ObjectWrap<NUtilsWrap> {
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
NUtilsWrap(const Napi::CallbackInfo& info);
|
||||
static Napi::FunctionReference constructor;
|
||||
};
|
||||
|
||||
namespace StaticNUtilsWrapMethods {
|
||||
Napi::Value isNapiExternal(const Napi::CallbackInfo& info);
|
||||
} // namespace StaticNUtilsWrapMethods
|
||||
@ -8,6 +8,7 @@
|
||||
#include "QtCore/QObject/qobject_macro.h"
|
||||
|
||||
class QObjectWrap : public Napi::ObjectWrap<QObjectWrap> {
|
||||
QOBJECT_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NObject> instance;
|
||||
|
||||
@ -19,5 +20,4 @@ class QObjectWrap : public Napi::ObjectWrap<QObjectWrap> {
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
QOBJECT_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
#include "core/Component/component_macro.h"
|
||||
|
||||
class QPointWrap : public Napi::ObjectWrap<QPointWrap> {
|
||||
COMPONENT_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
std::unique_ptr<QPoint> instance;
|
||||
|
||||
@ -21,7 +22,6 @@ class QPointWrap : public Napi::ObjectWrap<QPointWrap> {
|
||||
Napi::Value setY(const Napi::CallbackInfo& info);
|
||||
Napi::Value x(const Napi::CallbackInfo& info);
|
||||
Napi::Value y(const Napi::CallbackInfo& info);
|
||||
COMPONENT_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
namespace StaticQPointWrapMethods {
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
#include "core/Component/component_macro.h"
|
||||
|
||||
class QRectWrap : public Napi::ObjectWrap<QRectWrap> {
|
||||
COMPONENT_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
std::unique_ptr<QRect> instance;
|
||||
|
||||
@ -25,8 +26,6 @@ class QRectWrap : public Napi::ObjectWrap<QRectWrap> {
|
||||
Napi::Value width(const Napi::CallbackInfo& info);
|
||||
Napi::Value left(const Napi::CallbackInfo& info);
|
||||
Napi::Value top(const Napi::CallbackInfo& info);
|
||||
|
||||
COMPONENT_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
namespace StaticQRectWrapMethods {
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
#include "core/Component/component_macro.h"
|
||||
|
||||
class QSizeWrap : public Napi::ObjectWrap<QSizeWrap> {
|
||||
COMPONENT_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
std::unique_ptr<QSize> instance;
|
||||
|
||||
@ -21,8 +22,6 @@ class QSizeWrap : public Napi::ObjectWrap<QSizeWrap> {
|
||||
Napi::Value setWidth(const Napi::CallbackInfo& info);
|
||||
Napi::Value height(const Napi::CallbackInfo& info);
|
||||
Napi::Value width(const Napi::CallbackInfo& info);
|
||||
|
||||
COMPONENT_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
namespace StaticQSizeWrapMethods {
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
#include "core/Component/component_macro.h"
|
||||
|
||||
class QUrlWrap : public Napi::ObjectWrap<QUrlWrap> {
|
||||
COMPONENT_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
std::unique_ptr<QUrl> instance;
|
||||
|
||||
@ -19,8 +20,6 @@ class QUrlWrap : public Napi::ObjectWrap<QUrlWrap> {
|
||||
// Wrapped methods
|
||||
Napi::Value setUrl(const Napi::CallbackInfo& info);
|
||||
Napi::Value toString(const Napi::CallbackInfo& info);
|
||||
|
||||
COMPONENT_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
namespace StaticQUrlWrapMethods {
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
#include "core/Component/component_macro.h"
|
||||
|
||||
class QVariantWrap : public Napi::ObjectWrap<QVariantWrap> {
|
||||
COMPONENT_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QSharedPointer<QVariant> instance;
|
||||
|
||||
@ -21,7 +22,6 @@ class QVariantWrap : public Napi::ObjectWrap<QVariantWrap> {
|
||||
Napi::Value toDouble(const Napi::CallbackInfo& info);
|
||||
Napi::Value toBool(const Napi::CallbackInfo& info);
|
||||
// wrapped methods
|
||||
COMPONENT_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
namespace StaticQVariantWrapMethods {
|
||||
|
||||
@ -8,6 +8,8 @@
|
||||
#include "core/Component/component_macro.h"
|
||||
|
||||
class QApplicationWrap : public Napi::ObjectWrap<QApplicationWrap> {
|
||||
COMPONENT_WRAPPED_METHODS_DECLARATION
|
||||
|
||||
private:
|
||||
QPointer<QApplication> instance;
|
||||
static int argc;
|
||||
@ -27,8 +29,6 @@ class QApplicationWrap : public Napi::ObjectWrap<QApplicationWrap> {
|
||||
Napi::Value exit(const Napi::CallbackInfo& info);
|
||||
Napi::Value setQuitOnLastWindowClosed(const Napi::CallbackInfo& info);
|
||||
Napi::Value quitOnLastWindowClosed(const Napi::CallbackInfo& info);
|
||||
|
||||
COMPONENT_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
namespace StaticQApplicationWrapMethods {
|
||||
|
||||
@ -7,6 +7,8 @@
|
||||
#include "core/Component/component_macro.h"
|
||||
|
||||
class QClipboardWrap : public Napi::ObjectWrap<QClipboardWrap> {
|
||||
COMPONENT_WRAPPED_METHODS_DECLARATION
|
||||
|
||||
private:
|
||||
QClipboard* instance;
|
||||
|
||||
@ -19,6 +21,4 @@ class QClipboardWrap : public Napi::ObjectWrap<QClipboardWrap> {
|
||||
Napi::Value clear(const Napi::CallbackInfo& info);
|
||||
Napi::Value setText(const Napi::CallbackInfo& info);
|
||||
Napi::Value text(const Napi::CallbackInfo& info);
|
||||
|
||||
COMPONENT_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
#include "core/Component/component_macro.h"
|
||||
|
||||
class QColorWrap : public Napi::ObjectWrap<QColorWrap> {
|
||||
COMPONENT_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
std::unique_ptr<QColor> instance;
|
||||
|
||||
@ -25,7 +26,6 @@ class QColorWrap : public Napi::ObjectWrap<QColorWrap> {
|
||||
Napi::Value blue(const Napi::CallbackInfo& info);
|
||||
Napi::Value setAlpha(const Napi::CallbackInfo& info);
|
||||
Napi::Value alpha(const Napi::CallbackInfo& info);
|
||||
COMPONENT_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
namespace StaticQColorWrapMethods {
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
#include "core/Component/component_macro.h"
|
||||
|
||||
class QCursorWrap : public Napi::ObjectWrap<QCursorWrap> {
|
||||
COMPONENT_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
std::unique_ptr<QCursor> instance;
|
||||
|
||||
@ -19,6 +20,4 @@ class QCursorWrap : public Napi::ObjectWrap<QCursorWrap> {
|
||||
// Wrapped methods
|
||||
Napi::Value pos(const Napi::CallbackInfo& info);
|
||||
Napi::Value setPos(const Napi::CallbackInfo& info);
|
||||
|
||||
COMPONENT_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
@ -7,6 +7,8 @@
|
||||
#include "core/Component/component_macro.h"
|
||||
|
||||
class QKeyEventWrap : public Napi::ObjectWrap<QKeyEventWrap> {
|
||||
COMPONENT_WRAPPED_METHODS_DECLARATION
|
||||
|
||||
private:
|
||||
QKeyEvent* instance;
|
||||
|
||||
@ -23,6 +25,4 @@ class QKeyEventWrap : public Napi::ObjectWrap<QKeyEventWrap> {
|
||||
Napi::Value modifiers(const Napi::CallbackInfo& info);
|
||||
Napi::Value count(const Napi::CallbackInfo& info);
|
||||
Napi::Value isAutoRepeat(const Napi::CallbackInfo& info);
|
||||
|
||||
COMPONENT_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
@ -7,6 +7,8 @@
|
||||
#include "core/Component/component_macro.h"
|
||||
|
||||
class QMouseEventWrap : public Napi::ObjectWrap<QMouseEventWrap> {
|
||||
COMPONENT_WRAPPED_METHODS_DECLARATION
|
||||
|
||||
private:
|
||||
QMouseEvent* instance;
|
||||
|
||||
@ -23,6 +25,4 @@ class QMouseEventWrap : public Napi::ObjectWrap<QMouseEventWrap> {
|
||||
Napi::Value y(const Napi::CallbackInfo& info);
|
||||
Napi::Value globalX(const Napi::CallbackInfo& info);
|
||||
Napi::Value globalY(const Napi::CallbackInfo& info);
|
||||
|
||||
COMPONENT_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
@ -7,6 +7,8 @@
|
||||
#include "core/Component/component_macro.h"
|
||||
|
||||
class QFontDatabaseWrap : public Napi::ObjectWrap<QFontDatabaseWrap> {
|
||||
COMPONENT_WRAPPED_METHODS_DECLARATION
|
||||
|
||||
private:
|
||||
std::unique_ptr<QFontDatabase> instance;
|
||||
|
||||
@ -19,8 +21,6 @@ class QFontDatabaseWrap : public Napi::ObjectWrap<QFontDatabaseWrap> {
|
||||
Napi::Value bold(const Napi::CallbackInfo& info);
|
||||
Napi::Value italic(const Napi::CallbackInfo& info);
|
||||
Napi::Value weight(const Napi::CallbackInfo& info);
|
||||
|
||||
COMPONENT_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
namespace StaticQFontDatabaseWrapMethods {
|
||||
|
||||
@ -7,6 +7,8 @@
|
||||
#include "core/Component/component_macro.h"
|
||||
|
||||
class QIconWrap : public Napi::ObjectWrap<QIconWrap> {
|
||||
COMPONENT_WRAPPED_METHODS_DECLARATION
|
||||
|
||||
private:
|
||||
std::unique_ptr<QIcon> instance;
|
||||
|
||||
@ -21,8 +23,6 @@ class QIconWrap : public Napi::ObjectWrap<QIconWrap> {
|
||||
Napi::Value isMask(const Napi::CallbackInfo& info);
|
||||
Napi::Value setIsMask(const Napi::CallbackInfo& info);
|
||||
Napi::Value cacheKey(const Napi::CallbackInfo& info);
|
||||
|
||||
COMPONENT_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
namespace StaticQIconWrapMethods {
|
||||
|
||||
@ -7,6 +7,8 @@
|
||||
#include "core/Component/component_macro.h"
|
||||
|
||||
class QKeySequenceWrap : public Napi::ObjectWrap<QKeySequenceWrap> {
|
||||
COMPONENT_WRAPPED_METHODS_DECLARATION
|
||||
|
||||
private:
|
||||
std::unique_ptr<QKeySequence> instance;
|
||||
|
||||
@ -18,6 +20,4 @@ class QKeySequenceWrap : public Napi::ObjectWrap<QKeySequenceWrap> {
|
||||
QKeySequence *getInternalInstance();
|
||||
// Wrapped methods
|
||||
Napi::Value count(const Napi::CallbackInfo &info);
|
||||
|
||||
COMPONENT_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
@ -8,6 +8,8 @@
|
||||
#include "nmovie.hpp"
|
||||
|
||||
class QMovieWrap : public Napi::ObjectWrap<QMovieWrap> {
|
||||
QOBJECT_WRAPPED_METHODS_DECLARATION
|
||||
|
||||
private:
|
||||
QPointer<NMovie> instance;
|
||||
|
||||
@ -33,5 +35,4 @@ class QMovieWrap : public Napi::ObjectWrap<QMovieWrap> {
|
||||
Napi::Value currentFrameNumber(const Napi::CallbackInfo& info);
|
||||
Napi::Value currentPixmap(const Napi::CallbackInfo& info);
|
||||
Napi::Value loadFromData(const Napi::CallbackInfo& info);
|
||||
QOBJECT_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
@ -7,6 +7,8 @@
|
||||
#include "core/Component/component_macro.h"
|
||||
|
||||
class QPixmapWrap : public Napi::ObjectWrap<QPixmapWrap> {
|
||||
COMPONENT_WRAPPED_METHODS_DECLARATION
|
||||
|
||||
private:
|
||||
std::unique_ptr<QPixmap> instance;
|
||||
|
||||
@ -23,8 +25,6 @@ class QPixmapWrap : public Napi::ObjectWrap<QPixmapWrap> {
|
||||
Napi::Value scaled(const Napi::CallbackInfo& info);
|
||||
Napi::Value height(const Napi::CallbackInfo& info);
|
||||
Napi::Value width(const Napi::CallbackInfo& info);
|
||||
|
||||
COMPONENT_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
namespace StaticQPixmapWrapMethods {
|
||||
|
||||
@ -7,6 +7,8 @@
|
||||
#include "core/Component/component_macro.h"
|
||||
|
||||
class QStyleWrap : public Napi::ObjectWrap<QStyleWrap> {
|
||||
COMPONENT_WRAPPED_METHODS_DECLARATION
|
||||
|
||||
private:
|
||||
QStyle* instance;
|
||||
|
||||
@ -17,6 +19,4 @@ class QStyleWrap : public Napi::ObjectWrap<QStyleWrap> {
|
||||
QStyle* getInternalInstance();
|
||||
// Wrapped methods
|
||||
Napi::Value pixelMetric(const Napi::CallbackInfo& info);
|
||||
|
||||
COMPONENT_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
@ -7,6 +7,8 @@
|
||||
#include "QtCore/QObject/qobject_macro.h"
|
||||
#include "naction.hpp"
|
||||
class QActionWrap : public Napi::ObjectWrap<QActionWrap> {
|
||||
QOBJECT_WRAPPED_METHODS_DECLARATION
|
||||
|
||||
private:
|
||||
QPointer<NAction> instance;
|
||||
bool disableDeletion;
|
||||
@ -32,6 +34,4 @@ class QActionWrap : public Napi::ObjectWrap<QActionWrap> {
|
||||
Napi::Value isSeparator(const Napi::CallbackInfo& info);
|
||||
Napi::Value setSeparator(const Napi::CallbackInfo& info);
|
||||
Napi::Value setFont(const Napi::CallbackInfo& info);
|
||||
|
||||
QOBJECT_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
#include "QtWidgets/QLayout/qlayout_macro.h"
|
||||
|
||||
class QBoxLayoutWrap : public Napi::ObjectWrap<QBoxLayoutWrap> {
|
||||
QLAYOUT_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NBoxLayout> instance;
|
||||
|
||||
@ -30,5 +31,4 @@ class QBoxLayoutWrap : public Napi::ObjectWrap<QBoxLayoutWrap> {
|
||||
Napi::Value insertLayout(const Napi::CallbackInfo& info);
|
||||
Napi::Value removeWidget(const Napi::CallbackInfo& info);
|
||||
Napi::Value setDirection(const Napi::CallbackInfo& info);
|
||||
QLAYOUT_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
@ -9,8 +9,10 @@
|
||||
#include "ncheckbox.hpp"
|
||||
|
||||
class QCheckBoxWrap : public Napi::ObjectWrap<QCheckBoxWrap> {
|
||||
QABSTRACTBUTTON_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NCheckBox> instance;
|
||||
bool disableDeletion;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
@ -22,6 +24,4 @@ class QCheckBoxWrap : public Napi::ObjectWrap<QCheckBoxWrap> {
|
||||
// wrapped methods
|
||||
Napi::Value isChecked(const Napi::CallbackInfo& info);
|
||||
Napi::Value setChecked(const Napi::CallbackInfo& info);
|
||||
|
||||
QABSTRACTBUTTON_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
#include "QtWidgets/QWidget/qwidget_macro.h"
|
||||
|
||||
class QComboBoxWrap : public Napi::ObjectWrap<QComboBoxWrap> {
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NComboBox> instance;
|
||||
|
||||
@ -37,6 +38,4 @@ class QComboBoxWrap : public Napi::ObjectWrap<QComboBoxWrap> {
|
||||
Napi::Value isEditable(const Napi::CallbackInfo& info);
|
||||
Napi::Value setEditable(const Napi::CallbackInfo& info);
|
||||
Napi::Value clear(const Napi::CallbackInfo& info);
|
||||
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
#include "ndial.hpp"
|
||||
|
||||
class QDialWrap : public Napi::ObjectWrap<QDialWrap> {
|
||||
QABSTRACTSLIDER_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NDial> instance;
|
||||
|
||||
@ -26,6 +27,4 @@ class QDialWrap : public Napi::ObjectWrap<QDialWrap> {
|
||||
Napi::Value notchTarget(const Napi::CallbackInfo& info);
|
||||
Napi::Value notchesVisible(const Napi::CallbackInfo& info);
|
||||
Napi::Value wrapping(const Napi::CallbackInfo& info);
|
||||
|
||||
QABSTRACTSLIDER_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
15
src/cpp/include/nodegui/QtWidgets/QDialog/ndialog.hpp
Normal file
15
src/cpp/include/nodegui/QtWidgets/QDialog/ndialog.hpp
Normal file
@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#include "QtWidgets/QDialog/qdialog_macro.h"
|
||||
#include "core/NodeWidget/nodewidget.h"
|
||||
|
||||
class NDialog : public QDialog, public NodeWidget {
|
||||
Q_OBJECT
|
||||
NODEWIDGET_IMPLEMENTATIONS(QDialog)
|
||||
public:
|
||||
using QDialog::QDialog;
|
||||
|
||||
void connectSignalsToEventEmitter() { QDIALOG_SIGNALS }
|
||||
};
|
||||
75
src/cpp/include/nodegui/QtWidgets/QDialog/qdialog_macro.h
Normal file
75
src/cpp/include/nodegui/QtWidgets/QDialog/qdialog_macro.h
Normal file
@ -0,0 +1,75 @@
|
||||
#pragma once
|
||||
|
||||
#include <QSize>
|
||||
|
||||
#include "QtCore/QSize/qsize_wrap.h"
|
||||
#include "QtGui/QIcon/qicon_wrap.h"
|
||||
#include "QtWidgets/QLayout/qlayout_wrap.h"
|
||||
#include "QtWidgets/QWidget/qwidget_macro.h"
|
||||
/*
|
||||
|
||||
This macro adds common QDialog exported methods
|
||||
The exported methods are taken into this macro to avoid writing them in each
|
||||
and every widget we export.
|
||||
*/
|
||||
|
||||
#ifndef QDIALOG_WRAPPED_METHODS_DECLARATION
|
||||
#define QDIALOG_WRAPPED_METHODS_DECLARATION \
|
||||
\
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION \
|
||||
\
|
||||
Napi::Value setResult(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
Napi::Number result = info[0].As<Napi::Number>(); \
|
||||
this->instance->setResult(result.Int32Value()); \
|
||||
return env.Null(); \
|
||||
} \
|
||||
Napi::Value result(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
int value = this->instance->result(); \
|
||||
return Napi::Value::From(env, value); \
|
||||
} \
|
||||
Napi::Value exec(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
this->instance->exec(); \
|
||||
return env.Null(); \
|
||||
} \
|
||||
Napi::Value open(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
this->instance->open(); \
|
||||
return env.Null(); \
|
||||
} \
|
||||
Napi::Value reject(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
this->instance->reject(); \
|
||||
return env.Null(); \
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef QDIALOG_WRAPPED_METHODS_EXPORT_DEFINE
|
||||
#define QDIALOG_WRAPPED_METHODS_EXPORT_DEFINE(DialogWrapName) \
|
||||
\
|
||||
QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE(DialogWrapName) \
|
||||
InstanceMethod("result", &DialogWrapName::result), \
|
||||
InstanceMethod("setResult", &DialogWrapName::setResult), \
|
||||
InstanceMethod("exec", &DialogWrapName::exec), \
|
||||
InstanceMethod("open", &DialogWrapName::open), \
|
||||
InstanceMethod("reject", &DialogWrapName::reject),
|
||||
|
||||
#endif // QDIALOG_WRAPPED_METHODS_EXPORT_DEFINE
|
||||
|
||||
#ifndef QDIALOG_SIGNALS
|
||||
#define QDIALOG_SIGNALS \
|
||||
QWIDGET_SIGNALS \
|
||||
QObject::connect(this, &QDialog::accepted, [=]() { \
|
||||
Napi::Env env = this->emitOnNode.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
this->emitOnNode.Call({Napi::String::New(env, "accepted")}); \
|
||||
});
|
||||
|
||||
#endif // QDIALOG_SIGNALS
|
||||
23
src/cpp/include/nodegui/QtWidgets/QDialog/qdialog_wrap.h
Normal file
23
src/cpp/include/nodegui/QtWidgets/QDialog/qdialog_wrap.h
Normal file
@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
#include "QtWidgets/QDialog/qdialog_macro.h"
|
||||
#include "ndialog.hpp"
|
||||
|
||||
class QDialogWrap : public Napi::ObjectWrap<QDialogWrap> {
|
||||
QDIALOG_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NDialog> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QDialogWrap(const Napi::CallbackInfo& info);
|
||||
~QDialogWrap();
|
||||
NDialog* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
};
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
#include <QFileDialog>
|
||||
|
||||
#include "QtWidgets/QWidget/qwidget_macro.h"
|
||||
#include "QtWidgets/QDialog/qdialog_macro.h"
|
||||
#include "core/NodeWidget/nodewidget.h"
|
||||
#include "napi.h"
|
||||
|
||||
@ -13,7 +13,7 @@ class NFileDialog : public QFileDialog, public NodeWidget {
|
||||
using QFileDialog::QFileDialog;
|
||||
|
||||
void connectSignalsToEventEmitter() {
|
||||
QWIDGET_SIGNALS
|
||||
QDIALOG_SIGNALS
|
||||
// Qt Connects: Implement all signal connects here
|
||||
QObject::connect(
|
||||
this, &QFileDialog::currentChanged, [=](const QString &path) {
|
||||
|
||||
@ -5,10 +5,11 @@
|
||||
#include <QPointer>
|
||||
|
||||
#include "Extras/Utils/nutils.h"
|
||||
#include "QtWidgets/QDialog/qdialog_macro.h"
|
||||
#include "QtWidgets/QFileDialog/nfiledialog.hpp"
|
||||
#include "QtWidgets/QWidget/qwidget_macro.h"
|
||||
|
||||
class QFileDialogWrap : public Napi::ObjectWrap<QFileDialogWrap> {
|
||||
QDIALOG_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NFileDialog> instance;
|
||||
|
||||
@ -20,12 +21,9 @@ class QFileDialogWrap : public Napi::ObjectWrap<QFileDialogWrap> {
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
Napi::Value open(const Napi::CallbackInfo& info);
|
||||
Napi::Value supportedSchemes(const Napi::CallbackInfo& info);
|
||||
Napi::Value setSupportedSchemes(const Napi::CallbackInfo& info);
|
||||
Napi::Value labelText(const Napi::CallbackInfo& info);
|
||||
Napi::Value setLabelText(const Napi::CallbackInfo& info);
|
||||
Napi::Value setOption(const Napi::CallbackInfo& info);
|
||||
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
#include "QtWidgets/QLayout/qlayout_macro.h"
|
||||
|
||||
class QGridLayoutWrap : public Napi::ObjectWrap<QGridLayoutWrap> {
|
||||
QLAYOUT_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NGridLayout> instance;
|
||||
|
||||
@ -22,5 +23,4 @@ class QGridLayoutWrap : public Napi::ObjectWrap<QGridLayoutWrap> {
|
||||
// wrapped methods
|
||||
Napi::Value addWidget(const Napi::CallbackInfo& info);
|
||||
Napi::Value removeWidget(const Napi::CallbackInfo& info);
|
||||
QLAYOUT_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
#include "ngroupbox.hpp"
|
||||
|
||||
class QGroupBoxWrap : public Napi::ObjectWrap<QGroupBoxWrap> {
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NGroupBox> instance;
|
||||
|
||||
@ -29,6 +30,4 @@ class QGroupBoxWrap : public Napi::ObjectWrap<QGroupBoxWrap> {
|
||||
Napi::Value setTitle(const Napi::CallbackInfo& info);
|
||||
Napi::Value title(const Napi::CallbackInfo& info);
|
||||
Napi::Value setChecked(const Napi::CallbackInfo& info);
|
||||
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
@ -8,11 +8,11 @@
|
||||
#include "nlabel.hpp"
|
||||
|
||||
class QLabelWrap : public Napi::ObjectWrap<QLabelWrap> {
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NLabel> instance;
|
||||
|
||||
public:
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QLabelWrap(const Napi::CallbackInfo& info);
|
||||
~QLabelWrap();
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
|
||||
// ABSTRACT CLASS
|
||||
class QLayoutWrap : public Napi::ObjectWrap<QLayoutWrap> {
|
||||
QLAYOUT_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NLayout> instance;
|
||||
|
||||
@ -21,5 +22,4 @@ class QLayoutWrap : public Napi::ObjectWrap<QLayoutWrap> {
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
QLAYOUT_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
#include "nlineedit.hpp"
|
||||
|
||||
class QLineEditWrap : public Napi::ObjectWrap<QLineEditWrap> {
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NLineEdit> instance;
|
||||
|
||||
@ -25,6 +26,4 @@ class QLineEditWrap : public Napi::ObjectWrap<QLineEditWrap> {
|
||||
Napi::Value setReadOnly(const Napi::CallbackInfo& info);
|
||||
Napi::Value clear(const Napi::CallbackInfo& info);
|
||||
Napi::Value setEchoMode(const Napi::CallbackInfo& info);
|
||||
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
@ -8,6 +8,8 @@
|
||||
#include "nmainwindow.hpp"
|
||||
|
||||
class QMainWindowWrap : public Napi::ObjectWrap<QMainWindowWrap> {
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
|
||||
private:
|
||||
QPointer<NMainWindow> instance;
|
||||
|
||||
@ -25,6 +27,4 @@ class QMainWindowWrap : public Napi::ObjectWrap<QMainWindowWrap> {
|
||||
Napi::Value menuBar(const Napi::CallbackInfo& info);
|
||||
Napi::Value setMenuWidget(const Napi::CallbackInfo& info);
|
||||
Napi::Value center(const Napi::CallbackInfo& info);
|
||||
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
#include "nmenu.hpp"
|
||||
|
||||
class QMenuWrap : public Napi::ObjectWrap<QMenuWrap> {
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NMenu> instance;
|
||||
|
||||
@ -19,6 +20,4 @@ class QMenuWrap : public Napi::ObjectWrap<QMenuWrap> {
|
||||
// wrapped methods
|
||||
Napi::Value setTitle(const Napi::CallbackInfo& info);
|
||||
Napi::Value addAction(const Napi::CallbackInfo& info);
|
||||
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
#include "nmenubar.hpp"
|
||||
|
||||
class QMenuBarWrap : public Napi::ObjectWrap<QMenuBarWrap> {
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NMenuBar> instance;
|
||||
|
||||
@ -19,6 +20,4 @@ class QMenuBarWrap : public Napi::ObjectWrap<QMenuBarWrap> {
|
||||
// wrapped methods
|
||||
Napi::Value addMenu(const Napi::CallbackInfo& info);
|
||||
Napi::Value setNativeMenuBar(const Napi::CallbackInfo& info);
|
||||
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include <QAbstractButton>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "QtWidgets/QDialog/qdialog_macro.h"
|
||||
#include "QtWidgets/QPushButton/qpushbutton_wrap.h"
|
||||
#include "core/NodeWidget/nodewidget.h"
|
||||
#include "napi.h"
|
||||
|
||||
class NMessageBox : public QMessageBox, public NodeWidget {
|
||||
public:
|
||||
Q_OBJECT
|
||||
NODEWIDGET_IMPLEMENTATIONS(QMessageBox)
|
||||
using QMessageBox::QMessageBox;
|
||||
|
||||
void connectSignalsToEventEmitter() {
|
||||
QDIALOG_SIGNALS
|
||||
QObject::connect(
|
||||
this, &QMessageBox::buttonClicked, [=](QAbstractButton* button) {
|
||||
Napi::Env env = this->emitOnNode.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
auto value = Napi::External<QAbstractButton>::New(env, button);
|
||||
this->emitOnNode.Call(
|
||||
{Napi::String::New(env, "buttonClicked"), value});
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
#include "Extras/Utils/nutils.h"
|
||||
#include "QtWidgets/QMessageBox/nmessagebox.hpp"
|
||||
#include "QtWidgets/QWidget/qwidget_macro.h"
|
||||
|
||||
class QMessageBoxWrap : public Napi::ObjectWrap<QMessageBoxWrap> {
|
||||
QDIALOG_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NMessageBox> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QMessageBoxWrap(const Napi::CallbackInfo& info);
|
||||
~QMessageBoxWrap();
|
||||
NMessageBox* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
Napi::Value setDefaultButton(const Napi::CallbackInfo& info);
|
||||
Napi::Value addButton(const Napi::CallbackInfo& info);
|
||||
Napi::Value accept(const Napi::CallbackInfo& info);
|
||||
Napi::Value done(const Napi::CallbackInfo& info);
|
||||
};
|
||||
namespace StaticQMessageBoxWrapMethods {
|
||||
Napi::Value about(const Napi::CallbackInfo& info);
|
||||
Napi::Value aboutQt(const Napi::CallbackInfo& info);
|
||||
}; // namespace StaticQMessageBoxWrapMethods
|
||||
@ -8,6 +8,7 @@
|
||||
#include "core/Component/component_wrap.h"
|
||||
|
||||
class QPainterWrap : public Napi::ObjectWrap<QPainterWrap> {
|
||||
COMPONENT_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPainter* instance;
|
||||
|
||||
@ -32,5 +33,4 @@ class QPainterWrap : public Napi::ObjectWrap<QPainterWrap> {
|
||||
Napi::Value drawConvexPolygon(const Napi::CallbackInfo& info);
|
||||
Napi::Value save(const Napi::CallbackInfo& info);
|
||||
Napi::Value restore(const Napi::CallbackInfo& info);
|
||||
COMPONENT_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
#include "nplaintextedit.hpp"
|
||||
|
||||
class QPlainTextEditWrap : public Napi::ObjectWrap<QPlainTextEditWrap> {
|
||||
QABSTRACTSCROLLAREA_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NPlainTextEdit> instance;
|
||||
|
||||
@ -21,7 +22,6 @@ class QPlainTextEditWrap : public Napi::ObjectWrap<QPlainTextEditWrap> {
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
QABSTRACTSCROLLAREA_WRAPPED_METHODS_DECLARATION
|
||||
Napi::Value setPlainText(const Napi::CallbackInfo &info);
|
||||
Napi::Value setPlaceholderText(const Napi::CallbackInfo &info);
|
||||
Napi::Value toPlainText(const Napi::CallbackInfo &info);
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
#include "nprogressbar.hpp"
|
||||
|
||||
class QProgressBarWrap : public Napi::ObjectWrap<QProgressBarWrap> {
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NProgressBar> instance;
|
||||
|
||||
@ -24,6 +25,4 @@ class QProgressBarWrap : public Napi::ObjectWrap<QProgressBarWrap> {
|
||||
Napi::Value setMinimum(const Napi::CallbackInfo& info);
|
||||
Napi::Value setOrientation(const Napi::CallbackInfo& info);
|
||||
Napi::Value value(const Napi::CallbackInfo& info);
|
||||
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
@ -9,8 +9,10 @@
|
||||
#include "QtWidgets/QWidget/qwidget_macro.h"
|
||||
#include "npushbutton.hpp"
|
||||
class QPushButtonWrap : public Napi::ObjectWrap<QPushButtonWrap> {
|
||||
QABSTRACTBUTTON_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NPushButton> instance;
|
||||
bool disableDeletion;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
@ -21,6 +23,4 @@ class QPushButtonWrap : public Napi::ObjectWrap<QPushButtonWrap> {
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
Napi::Value setFlat(const Napi::CallbackInfo &info);
|
||||
|
||||
QABSTRACTBUTTON_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
@ -9,8 +9,11 @@
|
||||
#include "nradiobutton.hpp"
|
||||
|
||||
class QRadioButtonWrap : public Napi::ObjectWrap<QRadioButtonWrap> {
|
||||
QABSTRACTBUTTON_WRAPPED_METHODS_DECLARATION
|
||||
|
||||
private:
|
||||
QPointer<NRadioButton> instance;
|
||||
bool disableDeletion;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
@ -20,6 +23,4 @@ class QRadioButtonWrap : public Napi::ObjectWrap<QRadioButtonWrap> {
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
QABSTRACTBUTTON_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
#include "nscrollarea.hpp"
|
||||
|
||||
class QScrollAreaWrap : public Napi::ObjectWrap<QScrollAreaWrap> {
|
||||
QABSTRACTSCROLLAREA_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NScrollArea> instance;
|
||||
YGNodeRef scrollNode;
|
||||
@ -24,6 +25,4 @@ class QScrollAreaWrap : public Napi::ObjectWrap<QScrollAreaWrap> {
|
||||
Napi::Value takeWidget(const Napi::CallbackInfo &info);
|
||||
Napi::Value setWidgetResizable(const Napi::CallbackInfo &info);
|
||||
Napi::Value widgetResizable(const Napi::CallbackInfo &info);
|
||||
|
||||
QABSTRACTSCROLLAREA_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
#include "nshortcut.hpp"
|
||||
|
||||
class QShortcutWrap : public Napi::ObjectWrap<QShortcutWrap> {
|
||||
QOBJECT_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NShortcut> instance;
|
||||
|
||||
@ -23,6 +24,4 @@ class QShortcutWrap : public Napi::ObjectWrap<QShortcutWrap> {
|
||||
Napi::Value setAutoRepeat(const Napi::CallbackInfo& info);
|
||||
Napi::Value setKey(const Napi::CallbackInfo& info);
|
||||
Napi::Value setContext(const Napi::CallbackInfo& info);
|
||||
|
||||
QOBJECT_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
#include "nspinbox.hpp"
|
||||
|
||||
class QSpinBoxWrap : public Napi::ObjectWrap<QSpinBoxWrap> {
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NSpinBox> instance;
|
||||
|
||||
@ -29,6 +30,4 @@ class QSpinBoxWrap : public Napi::ObjectWrap<QSpinBoxWrap> {
|
||||
Napi::Value maximum(const Napi::CallbackInfo &info);
|
||||
Napi::Value minimum(const Napi::CallbackInfo &info);
|
||||
Napi::Value value(const Napi::CallbackInfo &info);
|
||||
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
#include "QtWidgets/QWidget/qwidget_macro.h"
|
||||
|
||||
class QStackedWidgetWrap : public Napi::ObjectWrap<QStackedWidgetWrap> {
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NStackedWidget> instance;
|
||||
|
||||
@ -25,6 +26,4 @@ class QStackedWidgetWrap : public Napi::ObjectWrap<QStackedWidgetWrap> {
|
||||
Napi::Value setCurrentIndex(const Napi::CallbackInfo &info);
|
||||
Napi::Value currentIndex(const Napi::CallbackInfo &info);
|
||||
Napi::Value setCurrentWidget(const Napi::CallbackInfo &info);
|
||||
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
#include "QtCore/QObject/qobject_macro.h"
|
||||
#include "nsystemtrayicon.hpp"
|
||||
class QSystemTrayIconWrap : public Napi::ObjectWrap<QSystemTrayIconWrap> {
|
||||
QOBJECT_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NSystemTrayIcon> instance;
|
||||
|
||||
@ -25,6 +26,4 @@ class QSystemTrayIconWrap : public Napi::ObjectWrap<QSystemTrayIconWrap> {
|
||||
Napi::Value setToolTip(const Napi::CallbackInfo& info);
|
||||
Napi::Value setContextMenu(const Napi::CallbackInfo& info);
|
||||
Napi::Value showMessage(const Napi::CallbackInfo& info);
|
||||
|
||||
QOBJECT_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
#include "QtWidgets/QWidget/qwidget_macro.h"
|
||||
|
||||
class QTabWidgetWrap : public Napi::ObjectWrap<QTabWidgetWrap> {
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NTabWidget> instance;
|
||||
|
||||
@ -26,6 +27,4 @@ class QTabWidgetWrap : public Napi::ObjectWrap<QTabWidgetWrap> {
|
||||
Napi::Value currentIndex(const Napi::CallbackInfo &info);
|
||||
Napi::Value removeTab(const Napi::CallbackInfo &info);
|
||||
Napi::Value setTabsClosable(const Napi::CallbackInfo &info);
|
||||
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
#include "QtWidgets/QTableWidget/ntablewidget.hpp"
|
||||
|
||||
class QTableWidgetWrap : public Napi::ObjectWrap<QTableWidgetWrap> {
|
||||
QABSTRACTSCROLLAREA_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NTableWidget> instance;
|
||||
|
||||
@ -54,6 +55,4 @@ class QTableWidgetWrap : public Napi::ObjectWrap<QTableWidgetWrap> {
|
||||
Napi::Value setRowHeight(const Napi::CallbackInfo& info);
|
||||
Napi::Value setSortingEnabled(const Napi::CallbackInfo& info);
|
||||
Napi::Value isSortingEnabled(const Napi::CallbackInfo& info);
|
||||
|
||||
QABSTRACTSCROLLAREA_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
#include "core/Component/component_wrap.h"
|
||||
|
||||
class QTableWidgetItemWrap : public Napi::ObjectWrap<QTableWidgetItemWrap> {
|
||||
COMPONENT_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QTableWidgetItem* instance;
|
||||
|
||||
@ -25,6 +26,4 @@ class QTableWidgetItemWrap : public Napi::ObjectWrap<QTableWidgetItemWrap> {
|
||||
Napi::Value textAlignment(const Napi::CallbackInfo& info);
|
||||
Napi::Value text(const Napi::CallbackInfo& info);
|
||||
Napi::Value toolTip(const Napi::CallbackInfo& info);
|
||||
|
||||
COMPONENT_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
@ -10,8 +10,10 @@
|
||||
#include "ntoolbutton.hpp"
|
||||
|
||||
class QToolButtonWrap : public Napi::ObjectWrap<QToolButtonWrap> {
|
||||
QABSTRACTBUTTON_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NToolButton> instance;
|
||||
bool disableDeletion;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
@ -32,6 +34,4 @@ class QToolButtonWrap : public Napi::ObjectWrap<QToolButtonWrap> {
|
||||
Napi::Value setMenu(const Napi::CallbackInfo &info);
|
||||
Napi::Value setDefaultAction(const Napi::CallbackInfo &info);
|
||||
Napi::Value showMenu(const Napi::CallbackInfo &info);
|
||||
|
||||
QABSTRACTBUTTON_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
#include "ntreewidget.hpp"
|
||||
|
||||
class QTreeWidgetWrap : public Napi::ObjectWrap<QTreeWidgetWrap> {
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NTreeWidget> instance;
|
||||
|
||||
@ -31,5 +32,4 @@ class QTreeWidgetWrap : public Napi::ObjectWrap<QTreeWidgetWrap> {
|
||||
// Napi::Value setVerticalScrollBarPolicy(const Napi::CallbackInfo& info);
|
||||
// Napi::Value takeTopLevelItem(const Napi::CallbackInfo& info);
|
||||
// Napi::Value findItems(const Napi::CallbackInfo& info);
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
#include "core/Component/component_wrap.h"
|
||||
|
||||
class QTreeWidgetItemWrap : public Napi::ObjectWrap<QTreeWidgetItemWrap> {
|
||||
COMPONENT_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QTreeWidgetItem *instance;
|
||||
bool disableDeletion;
|
||||
@ -32,5 +33,4 @@ class QTreeWidgetItemWrap : public Napi::ObjectWrap<QTreeWidgetItemWrap> {
|
||||
Napi::Value text(const Napi::CallbackInfo &info);
|
||||
Napi::Value setSelected(const Napi::CallbackInfo &info);
|
||||
Napi::Value setExpanded(const Napi::CallbackInfo &info);
|
||||
COMPONENT_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
@ -17,8 +17,8 @@
|
||||
#ifndef QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
#define QWIDGET_WRAPPED_METHODS_DECLARATION \
|
||||
\
|
||||
YOGAWIDGET_WRAPPED_METHODS_DECLARATION \
|
||||
QOBJECT_WRAPPED_METHODS_DECLARATION \
|
||||
YOGAWIDGET_WRAPPED_METHODS_DECLARATION \
|
||||
\
|
||||
Napi::Value show(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
#include "nwidget.hpp"
|
||||
|
||||
class QWidgetWrap : public Napi::ObjectWrap<QWidgetWrap> {
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NWidget> instance;
|
||||
|
||||
@ -19,5 +20,4 @@ class QWidgetWrap : public Napi::ObjectWrap<QWidgetWrap> {
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE
|
||||
#define COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE \
|
||||
\
|
||||
#define COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(ComponentWrapName) \
|
||||
\
|
||||
InstanceValue("type", Napi::String::New(env, "native")),
|
||||
#endif
|
||||
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
|
||||
#ifndef EVENTWIDGET_WRAPPED_METHODS_EXPORT_DEFINE
|
||||
#define EVENTWIDGET_WRAPPED_METHODS_EXPORT_DEFINE(WidgetWrapName) \
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE \
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(WidgetWrapName) \
|
||||
InstanceMethod("initNodeEventEmitter", \
|
||||
&WidgetWrapName::initNodeEventEmitter), \
|
||||
InstanceMethod("subscribeToQtEvent", \
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
#include "flexlayout.hpp"
|
||||
|
||||
class FlexLayoutWrap : public Napi::ObjectWrap<FlexLayoutWrap> {
|
||||
QLAYOUT_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<FlexLayout> instance;
|
||||
|
||||
@ -23,5 +24,4 @@ class FlexLayoutWrap : public Napi::ObjectWrap<FlexLayoutWrap> {
|
||||
Napi::Value insertChildBefore(const Napi::CallbackInfo& info);
|
||||
Napi::Value removeWidget(const Napi::CallbackInfo& info);
|
||||
Napi::Value setFlexNode(const Napi::CallbackInfo& info);
|
||||
QLAYOUT_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
@ -94,4 +94,33 @@ void extrautils::initAppSettings() {
|
||||
f.setFamily("Sans-Serif");
|
||||
QApplication::setFont(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Napi::FunctionReference NUtilsWrap::constructor;
|
||||
|
||||
Napi::Object NUtilsWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
Napi::HandleScope scope(env);
|
||||
char CLASSNAME[] = "NUtils";
|
||||
Napi::Function func =
|
||||
DefineClass(env, CLASSNAME,
|
||||
{
|
||||
StaticMethod("isNapiExternal",
|
||||
&StaticNUtilsWrapMethods::isNapiExternal),
|
||||
});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
return exports;
|
||||
}
|
||||
|
||||
NUtilsWrap::NUtilsWrap(const Napi::CallbackInfo& info)
|
||||
: Napi::ObjectWrap<NUtilsWrap>(info) {}
|
||||
|
||||
Napi::Value StaticNUtilsWrapMethods::isNapiExternal(
|
||||
const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
if (info.Length() > 0 && info[0].IsExternal()) {
|
||||
return Napi::Boolean::New(env, true);
|
||||
}
|
||||
return Napi::Boolean::New(env, false);
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
#include "Extras/Utils/nutils.h"
|
||||
#include "QtCore/QVariant/qvariant_wrap.h"
|
||||
#include "core/Component/component_wrap.h"
|
||||
|
||||
Napi::FunctionReference QModelIndexWrap::constructor;
|
||||
|
||||
@ -21,7 +22,7 @@ Napi::Object QModelIndexWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
InstanceMethod("siblingAtRow", &QModelIndexWrap::siblingAtRow),
|
||||
StaticMethod("fromQVariant",
|
||||
&StaticQModelIndexWrapMethods::fromQVariant),
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE});
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QModelIndexWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
return exports;
|
||||
|
||||
@ -15,7 +15,7 @@ Napi::Object QPointWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
InstanceMethod("setY", &QPointWrap::setY),
|
||||
InstanceMethod("y", &QPointWrap::y),
|
||||
StaticMethod("fromQVariant", &StaticQPointWrapMethods::fromQVariant),
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE});
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QPointWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
return exports;
|
||||
|
||||
@ -19,7 +19,7 @@ Napi::Object QRectWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
InstanceMethod("left", &QRectWrap::left),
|
||||
InstanceMethod("top", &QRectWrap::top),
|
||||
StaticMethod("fromQVariant", &StaticQRectWrapMethods::fromQVariant),
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE});
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QRectWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
return exports;
|
||||
|
||||
@ -15,7 +15,7 @@ Napi::Object QSizeWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
InstanceMethod("height", &QSizeWrap::height),
|
||||
InstanceMethod("width", &QSizeWrap::width),
|
||||
StaticMethod("fromQVariant", &StaticQSizeWrapMethods::fromQVariant),
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE});
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QSizeWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
return exports;
|
||||
|
||||
@ -13,7 +13,7 @@ Napi::Object QUrlWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
{InstanceMethod("setUrl", &QUrlWrap::setUrl),
|
||||
InstanceMethod("toString", &QUrlWrap::toString),
|
||||
StaticMethod("fromQVariant", &StaticQUrlWrapMethods::fromQVariant),
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE});
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QUrlWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
return exports;
|
||||
|
||||
@ -15,7 +15,7 @@ Napi::Object QVariantWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
InstanceMethod("toBool", &QVariantWrap::toBool),
|
||||
StaticMethod("converToQVariant",
|
||||
&StaticQVariantWrapMethods::converToQVariant),
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE});
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QVariantWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
return exports;
|
||||
|
||||
@ -24,7 +24,7 @@ Napi::Object QApplicationWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
StaticMethod("instance", &StaticQApplicationWrapMethods::instance),
|
||||
StaticMethod("clipboard", &StaticQApplicationWrapMethods::clipboard),
|
||||
StaticMethod("style", &StaticQApplicationWrapMethods::style),
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE});
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QApplicationWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
return exports;
|
||||
|
||||
@ -12,7 +12,7 @@ Napi::Object QClipboardWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
{InstanceMethod("clear", &QClipboardWrap::clear),
|
||||
InstanceMethod("setText", &QClipboardWrap::setText),
|
||||
InstanceMethod("text", &QClipboardWrap::text),
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE});
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QClipboardWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
return exports;
|
||||
|
||||
@ -19,7 +19,7 @@ Napi::Object QColorWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
InstanceMethod("setAlpha", &QColorWrap::setAlpha),
|
||||
InstanceMethod("alpha", &QColorWrap::alpha),
|
||||
StaticMethod("fromQVariant", &StaticQColorWrapMethods::fromQVariant),
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE});
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QColorWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
return exports;
|
||||
|
||||
@ -12,7 +12,7 @@ Napi::Object QCursorWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
DefineClass(env, CLASSNAME,
|
||||
{InstanceMethod("pos", &QCursorWrap::pos),
|
||||
InstanceMethod("setPos", &QCursorWrap::setPos),
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE});
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QCursorWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
return exports;
|
||||
|
||||
@ -16,7 +16,7 @@ Napi::Object QKeyEventWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
InstanceMethod("modifiers", &QKeyEventWrap::modifiers),
|
||||
InstanceMethod("count", &QKeyEventWrap::count),
|
||||
InstanceMethod("isAutoRepeat", &QKeyEventWrap::isAutoRepeat),
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE});
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QKeyEventWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
return exports;
|
||||
|
||||
@ -17,7 +17,7 @@ Napi::Object QMouseEventWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
InstanceMethod("globalX", &QMouseEventWrap::globalX),
|
||||
InstanceMethod("globalY", &QMouseEventWrap::globalY),
|
||||
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE});
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QMouseEventWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
return exports;
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
#include "Extras/Utils/nutils.h"
|
||||
#include "QtCore/QVariant/qvariant_wrap.h"
|
||||
#include "core/Component/component_wrap.h"
|
||||
|
||||
Napi::FunctionReference QFontWrap::constructor;
|
||||
|
||||
@ -24,7 +25,7 @@ Napi::Object QFontWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
InstanceMethod("italic", &QFontWrap::italic),
|
||||
InstanceMethod("toString", &QFontWrap::toString),
|
||||
StaticMethod("fromQVariant", &StaticQFontWrapMethods::fromQVariant),
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE});
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QFontWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
return exports;
|
||||
|
||||
@ -16,7 +16,7 @@ Napi::Object QFontDatabaseWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
&StaticQFontDatabaseWrapMethods::addApplicationFont),
|
||||
StaticMethod("removeApplicationFont",
|
||||
&StaticQFontDatabaseWrapMethods::removeApplicationFont),
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE});
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QFontDatabaseWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
return exports;
|
||||
|
||||
@ -16,7 +16,7 @@ Napi::Object QIconWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
InstanceMethod("setIsMask", &QIconWrap::setIsMask),
|
||||
InstanceMethod("cacheKey", &QIconWrap::cacheKey),
|
||||
StaticMethod("fromQVariant", &StaticQIconWrapMethods::fromQVariant),
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE});
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QIconWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
return exports;
|
||||
|
||||
@ -11,7 +11,7 @@ Napi::Object QKeySequenceWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
Napi::Function func =
|
||||
DefineClass(env, CLASSNAME,
|
||||
{InstanceMethod("count", &QKeySequenceWrap::count),
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE});
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QKeySequenceWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
return exports;
|
||||
|
||||
@ -17,7 +17,7 @@ Napi::Object QPixmapWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
InstanceMethod("height", &QPixmapWrap::height),
|
||||
InstanceMethod("width", &QPixmapWrap::width),
|
||||
StaticMethod("fromQVariant", &StaticQPixmapWrapMethods::fromQVariant),
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE});
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QPixmapWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
return exports;
|
||||
|
||||
@ -10,7 +10,7 @@ Napi::Object QStyleWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
Napi::Function func =
|
||||
DefineClass(env, CLASSNAME,
|
||||
{InstanceMethod("pixelMetric", &QStyleWrap::pixelMetric),
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE});
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QStyleWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
return exports;
|
||||
|
||||
@ -27,23 +27,35 @@ QCheckBoxWrap::QCheckBoxWrap(const Napi::CallbackInfo& info)
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
if (info.Length() == 1) {
|
||||
Napi::Object parentObject = info[0].As<Napi::Object>();
|
||||
QWidgetWrap* parentWidgetWrap =
|
||||
Napi::ObjectWrap<QWidgetWrap>::Unwrap(parentObject);
|
||||
this->instance = new NCheckBox(parentWidgetWrap->getInternalInstance());
|
||||
} else if (info.Length() == 0) {
|
||||
this->instance = new NCheckBox();
|
||||
if (info.Length() > 0 && info[0].IsExternal()) {
|
||||
// --- if external ---
|
||||
this->instance = info[0].As<Napi::External<NCheckBox>>().Data();
|
||||
if (info.Length() == 2) {
|
||||
this->disableDeletion = info[1].As<Napi::Boolean>().Value();
|
||||
}
|
||||
} else {
|
||||
Napi::TypeError::New(env, "Wrong number of arguments")
|
||||
.ThrowAsJavaScriptException();
|
||||
if (info.Length() == 1) {
|
||||
Napi::Object parentObject = info[0].As<Napi::Object>();
|
||||
QWidgetWrap* parentWidgetWrap =
|
||||
Napi::ObjectWrap<QWidgetWrap>::Unwrap(parentObject);
|
||||
this->instance = new NCheckBox(parentWidgetWrap->getInternalInstance());
|
||||
} else if (info.Length() == 0) {
|
||||
this->instance = new NCheckBox();
|
||||
} else {
|
||||
Napi::TypeError::New(env, "Wrong number of arguments")
|
||||
.ThrowAsJavaScriptException();
|
||||
}
|
||||
}
|
||||
this->rawData = extrautils::configureQWidget(
|
||||
this->getInternalInstance(), this->getInternalInstance()->getFlexNode(),
|
||||
true);
|
||||
}
|
||||
|
||||
QCheckBoxWrap::~QCheckBoxWrap() { extrautils::safeDelete(this->instance); }
|
||||
QCheckBoxWrap::~QCheckBoxWrap() {
|
||||
if (!this->disableDeletion) {
|
||||
extrautils::safeDelete(this->instance);
|
||||
}
|
||||
}
|
||||
|
||||
Napi::Value QCheckBoxWrap::isChecked(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
|
||||
44
src/cpp/lib/QtWidgets/QDialog/qdialog_wrap.cpp
Normal file
44
src/cpp/lib/QtWidgets/QDialog/qdialog_wrap.cpp
Normal file
@ -0,0 +1,44 @@
|
||||
#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);
|
||||
}
|
||||
@ -12,14 +12,13 @@ Napi::Object QFileDialogWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
char CLASSNAME[] = "QFileDialog";
|
||||
Napi::Function func = DefineClass(
|
||||
env, CLASSNAME,
|
||||
{InstanceMethod("open", &QFileDialogWrap::open),
|
||||
InstanceMethod("supportedSchemes", &QFileDialogWrap::supportedSchemes),
|
||||
{InstanceMethod("supportedSchemes", &QFileDialogWrap::supportedSchemes),
|
||||
InstanceMethod("setSupportedSchemes",
|
||||
&QFileDialogWrap::setSupportedSchemes),
|
||||
InstanceMethod("labelText", &QFileDialogWrap::labelText),
|
||||
InstanceMethod("setLabelText", &QFileDialogWrap::setLabelText),
|
||||
InstanceMethod("setOption", &QFileDialogWrap::setOption),
|
||||
QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE(QFileDialogWrap)});
|
||||
QDIALOG_WRAPPED_METHODS_EXPORT_DEFINE(QFileDialogWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
return exports;
|
||||
@ -55,13 +54,6 @@ QFileDialogWrap::QFileDialogWrap(const Napi::CallbackInfo& info)
|
||||
this->getInternalInstance(), this->getInternalInstance()->getFlexNode(),
|
||||
false);
|
||||
}
|
||||
Napi::Value QFileDialogWrap::open(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
this->instance->open();
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QFileDialogWrap::supportedSchemes(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
|
||||
@ -36,7 +36,7 @@ Napi::Object QListWidgetItemWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
InstanceMethod("toolTip", &QListWidgetItemWrap::toolTip),
|
||||
InstanceMethod("setWhatsThis", &QListWidgetItemWrap::setWhatsThis),
|
||||
InstanceMethod("whatsThis", &QListWidgetItemWrap::whatsThis),
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE});
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QListWidgetItemWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
return exports;
|
||||
|
||||
121
src/cpp/lib/QtWidgets/QMessageBox/qmessagebox_wrap.cpp
Normal file
121
src/cpp/lib/QtWidgets/QMessageBox/qmessagebox_wrap.cpp
Normal file
@ -0,0 +1,121 @@
|
||||
#include "QtWidgets/QMessageBox/qmessagebox_wrap.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QWidget>
|
||||
|
||||
#include "Extras/Utils/nutils.h"
|
||||
#include "QtCore/QObject/qobject_wrap.h"
|
||||
#include "QtWidgets/QWidget/qwidget_wrap.h"
|
||||
|
||||
Napi::FunctionReference QMessageBoxWrap::constructor;
|
||||
|
||||
Napi::Object QMessageBoxWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
Napi::HandleScope scope(env);
|
||||
char CLASSNAME[] = "QMessageBox";
|
||||
Napi::Function func = DefineClass(
|
||||
env, CLASSNAME,
|
||||
{InstanceMethod("setDefaultButton", &QMessageBoxWrap::setDefaultButton),
|
||||
InstanceMethod("addButton", &QMessageBoxWrap::addButton),
|
||||
InstanceMethod("accept", &QMessageBoxWrap::accept),
|
||||
InstanceMethod("done", &QMessageBoxWrap::done),
|
||||
StaticMethod("about", &StaticQMessageBoxWrapMethods::about),
|
||||
StaticMethod("aboutQt", &StaticQMessageBoxWrapMethods::aboutQt),
|
||||
QDIALOG_WRAPPED_METHODS_EXPORT_DEFINE(QMessageBoxWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
return exports;
|
||||
}
|
||||
|
||||
NMessageBox* QMessageBoxWrap::getInternalInstance() { return this->instance; }
|
||||
QMessageBoxWrap::~QMessageBoxWrap() { extrautils::safeDelete(this->instance); }
|
||||
|
||||
QMessageBoxWrap::QMessageBoxWrap(const Napi::CallbackInfo& info)
|
||||
: Napi::ObjectWrap<QMessageBoxWrap>(info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
if (info.Length() == 1) {
|
||||
Napi::Object parentObject = info[0].As<Napi::Object>();
|
||||
QWidgetWrap* parentWidgetWrap =
|
||||
Napi::ObjectWrap<QWidgetWrap>::Unwrap(parentObject);
|
||||
this->instance = new NMessageBox(parentWidgetWrap->getInternalInstance());
|
||||
} else if (info.Length() == 0) {
|
||||
this->instance = new NMessageBox();
|
||||
} else {
|
||||
Napi::TypeError::New(env, "Wrong number of arguments")
|
||||
.ThrowAsJavaScriptException();
|
||||
}
|
||||
this->instance->setStandardButtons(QMessageBox::NoButton);
|
||||
this->rawData = extrautils::configureQWidget(
|
||||
this->getInternalInstance(), this->getInternalInstance()->getFlexNode(),
|
||||
false);
|
||||
}
|
||||
|
||||
Napi::Value QMessageBoxWrap::setDefaultButton(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
Napi::Object buttonObject = info[0].As<Napi::Object>();
|
||||
QPushButtonWrap* buttonWrap =
|
||||
Napi::ObjectWrap<QPushButtonWrap>::Unwrap(buttonObject);
|
||||
this->instance->setDefaultButton(buttonWrap->getInternalInstance());
|
||||
return env.Null();
|
||||
}
|
||||
Napi::Value QMessageBoxWrap::addButton(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
Napi::Object buttonObject = info[0].As<Napi::Object>();
|
||||
QObjectWrap* qobjWrap = Napi::ObjectWrap<QObjectWrap>::Unwrap(buttonObject);
|
||||
QAbstractButton* btn =
|
||||
qobject_cast<QAbstractButton*>(qobjWrap->getInternalInstance());
|
||||
|
||||
int role = info[1].As<Napi::Number>().Int32Value();
|
||||
this->instance->addButton(btn, QMessageBox::ButtonRole(role));
|
||||
return env.Null();
|
||||
}
|
||||
Napi::Value QMessageBoxWrap::accept(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
this->instance->accept();
|
||||
return env.Null();
|
||||
}
|
||||
Napi::Value QMessageBoxWrap::done(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
Napi::Number r = info[0].As<Napi::Number>();
|
||||
this->instance->done(r.Int32Value());
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value StaticQMessageBoxWrapMethods::about(
|
||||
const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
Napi::Object parentObject = info[0].As<Napi::Object>();
|
||||
QWidgetWrap* parentWidgetWrap =
|
||||
Napi::ObjectWrap<QWidgetWrap>::Unwrap(parentObject);
|
||||
Napi::String napiTitle = info[1].As<Napi::String>();
|
||||
std::string title = napiTitle.Utf8Value();
|
||||
Napi::String napiText = info[2].As<Napi::String>();
|
||||
std::string text = napiText.Utf8Value();
|
||||
QMessageBox::about(parentWidgetWrap->getInternalInstance(),
|
||||
QString::fromUtf8(title.c_str()),
|
||||
QString::fromUtf8(text.c_str()));
|
||||
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value StaticQMessageBoxWrapMethods::aboutQt(
|
||||
const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
Napi::Object parentObject = info[0].As<Napi::Object>();
|
||||
QWidgetWrap* parentWidgetWrap =
|
||||
Napi::ObjectWrap<QWidgetWrap>::Unwrap(parentObject);
|
||||
Napi::String napiTitle = info[1].As<Napi::String>();
|
||||
std::string title = napiTitle.Utf8Value();
|
||||
QMessageBox::aboutQt(parentWidgetWrap->getInternalInstance(),
|
||||
QString::fromUtf8(title.c_str()));
|
||||
|
||||
return env.Null();
|
||||
}
|
||||
@ -26,7 +26,7 @@ Napi::Object QPainterWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
InstanceMethod("drawConvexPolygon", &QPainterWrap::drawConvexPolygon),
|
||||
InstanceMethod("save", &QPainterWrap::save),
|
||||
InstanceMethod("restore", &QPainterWrap::restore),
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE});
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QPainterWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
return exports;
|
||||
|
||||
@ -23,24 +23,36 @@ QPushButtonWrap::QPushButtonWrap(const Napi::CallbackInfo& info)
|
||||
: Napi::ObjectWrap<QPushButtonWrap>(info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
if (info.Length() == 1) {
|
||||
Napi::Object parentObject = info[0].As<Napi::Object>();
|
||||
QWidgetWrap* parentWidgetWrap =
|
||||
Napi::ObjectWrap<QWidgetWrap>::Unwrap(parentObject);
|
||||
this->instance = new NPushButton(parentWidgetWrap->getInternalInstance());
|
||||
} else if (info.Length() == 0) {
|
||||
this->instance = new NPushButton();
|
||||
if (info.Length() > 0 && info[0].IsExternal()) {
|
||||
// --- if external ---
|
||||
this->instance = info[0].As<Napi::External<NPushButton>>().Data();
|
||||
if (info.Length() == 2) {
|
||||
this->disableDeletion = info[1].As<Napi::Boolean>().Value();
|
||||
}
|
||||
} else {
|
||||
Napi::TypeError::New(env, "Wrong number of arguments")
|
||||
.ThrowAsJavaScriptException();
|
||||
if (info.Length() == 1) {
|
||||
Napi::Object parentObject = info[0].As<Napi::Object>();
|
||||
QWidgetWrap* parentWidgetWrap =
|
||||
Napi::ObjectWrap<QWidgetWrap>::Unwrap(parentObject);
|
||||
this->instance = new NPushButton(parentWidgetWrap->getInternalInstance());
|
||||
} else if (info.Length() == 0) {
|
||||
this->instance = new NPushButton();
|
||||
} else {
|
||||
Napi::TypeError::New(env, "Wrong number of arguments")
|
||||
.ThrowAsJavaScriptException();
|
||||
}
|
||||
}
|
||||
|
||||
this->rawData = extrautils::configureQWidget(
|
||||
this->getInternalInstance(), this->getInternalInstance()->getFlexNode(),
|
||||
true);
|
||||
}
|
||||
|
||||
QPushButtonWrap::~QPushButtonWrap() { extrautils::safeDelete(this->instance); }
|
||||
QPushButtonWrap::~QPushButtonWrap() {
|
||||
if (!this->disableDeletion) {
|
||||
extrautils::safeDelete(this->instance);
|
||||
}
|
||||
}
|
||||
|
||||
Napi::Value QPushButtonWrap::setFlat(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
|
||||
@ -25,17 +25,25 @@ QRadioButtonWrap::QRadioButtonWrap(const Napi::CallbackInfo& info)
|
||||
: Napi::ObjectWrap<QRadioButtonWrap>(info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
if (info.Length() == 1) {
|
||||
Napi::Object parentObject = info[0].As<Napi::Object>();
|
||||
QWidgetWrap* parentWidgetWrap =
|
||||
Napi::ObjectWrap<QWidgetWrap>::Unwrap(parentObject);
|
||||
this->instance = new NRadioButton(parentWidgetWrap->getInternalInstance());
|
||||
} else if (info.Length() == 0) {
|
||||
this->instance = new NRadioButton();
|
||||
if (info.Length() > 0 && info[0].IsExternal()) {
|
||||
// --- if external ---
|
||||
this->instance = info[0].As<Napi::External<NRadioButton>>().Data();
|
||||
if (info.Length() == 2) {
|
||||
this->disableDeletion = info[1].As<Napi::Boolean>().Value();
|
||||
}
|
||||
} else {
|
||||
Napi::TypeError::New(env, "Wrong number of arguments")
|
||||
.ThrowAsJavaScriptException();
|
||||
if (info.Length() == 1) {
|
||||
Napi::Object parentObject = info[0].As<Napi::Object>();
|
||||
QWidgetWrap* parentWidgetWrap =
|
||||
Napi::ObjectWrap<QWidgetWrap>::Unwrap(parentObject);
|
||||
this->instance =
|
||||
new NRadioButton(parentWidgetWrap->getInternalInstance());
|
||||
} else if (info.Length() == 0) {
|
||||
this->instance = new NRadioButton();
|
||||
} else {
|
||||
Napi::TypeError::New(env, "Wrong number of arguments")
|
||||
.ThrowAsJavaScriptException();
|
||||
}
|
||||
}
|
||||
this->rawData = extrautils::configureQWidget(
|
||||
this->getInternalInstance(), this->getInternalInstance()->getFlexNode(),
|
||||
@ -43,5 +51,7 @@ QRadioButtonWrap::QRadioButtonWrap(const Napi::CallbackInfo& info)
|
||||
}
|
||||
|
||||
QRadioButtonWrap::~QRadioButtonWrap() {
|
||||
extrautils::safeDelete(this->instance);
|
||||
if (!this->disableDeletion) {
|
||||
extrautils::safeDelete(this->instance);
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,7 +18,7 @@ Napi::Object QTableWidgetItemWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
InstanceMethod("text", &QTableWidgetItemWrap::text),
|
||||
InstanceMethod("toolTip", &QTableWidgetItemWrap::toolTip),
|
||||
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE});
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QTableWidgetItemWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
return exports;
|
||||
|
||||
@ -37,23 +37,35 @@ QToolButtonWrap::QToolButtonWrap(const Napi::CallbackInfo &info)
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
if (info.Length() == 1) {
|
||||
Napi::Object parentObject = info[0].As<Napi::Object>();
|
||||
QWidgetWrap *parentWidgetWrap =
|
||||
Napi::ObjectWrap<QWidgetWrap>::Unwrap(parentObject);
|
||||
this->instance = new NToolButton(parentWidgetWrap->getInternalInstance());
|
||||
} else if (info.Length() == 0) {
|
||||
this->instance = new NToolButton();
|
||||
if (info.Length() > 0 && info[0].IsExternal()) {
|
||||
// --- if external ---
|
||||
this->instance = info[0].As<Napi::External<NToolButton>>().Data();
|
||||
if (info.Length() == 2) {
|
||||
this->disableDeletion = info[1].As<Napi::Boolean>().Value();
|
||||
}
|
||||
} else {
|
||||
Napi::TypeError::New(env, "Wrong number of arguments")
|
||||
.ThrowAsJavaScriptException();
|
||||
if (info.Length() == 1) {
|
||||
Napi::Object parentObject = info[0].As<Napi::Object>();
|
||||
QWidgetWrap *parentWidgetWrap =
|
||||
Napi::ObjectWrap<QWidgetWrap>::Unwrap(parentObject);
|
||||
this->instance = new NToolButton(parentWidgetWrap->getInternalInstance());
|
||||
} else if (info.Length() == 0) {
|
||||
this->instance = new NToolButton();
|
||||
} else {
|
||||
Napi::TypeError::New(env, "Wrong number of arguments")
|
||||
.ThrowAsJavaScriptException();
|
||||
}
|
||||
}
|
||||
this->rawData = extrautils::configureQWidget(
|
||||
this->getInternalInstance(), this->getInternalInstance()->getFlexNode(),
|
||||
true);
|
||||
}
|
||||
|
||||
QToolButtonWrap::~QToolButtonWrap() { extrautils::safeDelete(this->instance); }
|
||||
QToolButtonWrap::~QToolButtonWrap() {
|
||||
if (!this->disableDeletion) {
|
||||
extrautils::safeDelete(this->instance);
|
||||
}
|
||||
}
|
||||
|
||||
Napi::Value QToolButtonWrap::setArrowType(const Napi::CallbackInfo &info) {
|
||||
Napi::Env env = info.Env();
|
||||
|
||||
@ -21,7 +21,7 @@ Napi::Object QTreeWidgetItemWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
InstanceMethod("childCount", &QTreeWidgetItemWrap::childCount),
|
||||
InstanceMethod("setSelected", &QTreeWidgetItemWrap::setSelected),
|
||||
InstanceMethod("setExpanded", &QTreeWidgetItemWrap::setExpanded),
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE});
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QTreeWidgetItemWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
return exports;
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
#include <napi.h>
|
||||
|
||||
#include "Extras/Utils/nutils.h"
|
||||
#include "QtCore/QModelIndex/qmodelindex_wrap.h"
|
||||
#include "QtCore/QObject/qobject_wrap.h"
|
||||
#include "QtCore/QPoint/qpoint_wrap.h"
|
||||
@ -25,6 +26,7 @@
|
||||
#include "QtWidgets/QCheckBox/qcheckbox_wrap.h"
|
||||
#include "QtWidgets/QComboBox/qcombobox_wrap.h"
|
||||
#include "QtWidgets/QDial/qdial_wrap.h"
|
||||
#include "QtWidgets/QDialog/qdialog_wrap.h"
|
||||
#include "QtWidgets/QFileDialog/qfiledialog_wrap.h"
|
||||
#include "QtWidgets/QGridLayout/qgridlayout_wrap.h"
|
||||
#include "QtWidgets/QGroupBox/qgroupbox_wrap.h"
|
||||
@ -36,6 +38,7 @@
|
||||
#include "QtWidgets/QMainWindow/qmainwindow_wrap.h"
|
||||
#include "QtWidgets/QMenu/qmenu_wrap.h"
|
||||
#include "QtWidgets/QMenuBar/qmenubar_wrap.h"
|
||||
#include "QtWidgets/QMessageBox/qmessagebox_wrap.h"
|
||||
#include "QtWidgets/QPainter/qpainter_wrap.h"
|
||||
#include "QtWidgets/QPlainTextEdit/qplaintextedit_wrap.h"
|
||||
#include "QtWidgets/QProgressBar/qprogressbar_wrap.h"
|
||||
@ -62,6 +65,7 @@ void InitPrivateHelpers(Napi::Env env) {
|
||||
|
||||
Napi::Object Main(Napi::Env env, Napi::Object exports) {
|
||||
InitPrivateHelpers(env);
|
||||
NUtilsWrap::init(env, exports);
|
||||
QApplicationWrap::init(env, exports);
|
||||
QModelIndexWrap::init(env, exports);
|
||||
QObjectWrap::init(env, exports);
|
||||
@ -72,6 +76,7 @@ Napi::Object Main(Napi::Env env, Napi::Object exports) {
|
||||
QColorWrap::init(env, exports);
|
||||
QUrlWrap::init(env, exports);
|
||||
QClipboardWrap::init(env, exports);
|
||||
QDialogWrap::init(env, exports);
|
||||
QWidgetWrap::init(env, exports);
|
||||
QPixmapWrap::init(env, exports);
|
||||
QKeySequenceWrap::init(env, exports);
|
||||
@ -115,6 +120,7 @@ Napi::Object Main(Napi::Env env, Napi::Object exports) {
|
||||
QShortcutWrap::init(env, exports);
|
||||
QMenuWrap::init(env, exports);
|
||||
QMenuBarWrap::init(env, exports);
|
||||
QMessageBoxWrap::init(env, exports);
|
||||
return exports;
|
||||
}
|
||||
|
||||
|
||||
100
src/demo.ts
100
src/demo.ts
@ -1,87 +1,23 @@
|
||||
import {
|
||||
FlexLayout,
|
||||
PenStyle,
|
||||
WidgetEventTypes,
|
||||
QColor,
|
||||
QMainWindow,
|
||||
QPainter,
|
||||
QPoint,
|
||||
QWidget,
|
||||
RenderHint,
|
||||
} from './index';
|
||||
import { QMessageBox } from './index';
|
||||
import { QToolButton } from './lib/QtWidgets/QToolButton';
|
||||
|
||||
const win = new QMainWindow();
|
||||
const center = new QWidget();
|
||||
const layout = new FlexLayout();
|
||||
const hourHand = [new QPoint(7, 8), new QPoint(-7, 8), new QPoint(0, -40)];
|
||||
const minuteHand = [new QPoint(7, 8), new QPoint(-7, 8), new QPoint(0, -70)];
|
||||
const secondHand = [new QPoint(4, 8), new QPoint(-4, 8), new QPoint(0, -70)];
|
||||
const hourColor = new QColor(127, 0, 127);
|
||||
const minuteColor = new QColor(0, 127, 127, 191);
|
||||
const secondColor = new QColor(0, 0, 0);
|
||||
const msgBox = new QMessageBox();
|
||||
// const msgBoxButton = msgBox.addButton('Another button');
|
||||
// console.log(msgBoxButton);
|
||||
msgBox.setText('hellllooo');
|
||||
|
||||
center.setLayout(layout);
|
||||
win.setWindowTitle('Analog Clock');
|
||||
|
||||
const side = Math.min(win.geometry().width(), win.geometry().height());
|
||||
|
||||
function repaint(): void {
|
||||
win.repaint();
|
||||
setTimeout(repaint, 1000);
|
||||
}
|
||||
|
||||
setTimeout(repaint, 1000);
|
||||
win.addEventListener(WidgetEventTypes.Paint, () => {
|
||||
const time = new Date();
|
||||
|
||||
const painter = new QPainter(win);
|
||||
painter.setRenderHint(RenderHint.Antialiasing);
|
||||
painter.translate(win.geometry().width() / 2, win.geometry().height() / 2);
|
||||
painter.scale(side / 200.0, side / 200.0);
|
||||
|
||||
painter.setPen(PenStyle.NoPen);
|
||||
painter.setBrush(hourColor);
|
||||
|
||||
painter.save();
|
||||
painter.rotate(30.0 * (time.getHours() + time.getMinutes() / 60.0));
|
||||
painter.drawConvexPolygon(hourHand);
|
||||
painter.restore();
|
||||
|
||||
painter.setPen(hourColor);
|
||||
|
||||
for (let i = 0; i < 12; ++i) {
|
||||
painter.drawLine(88, 0, 96, 0);
|
||||
painter.rotate(30.0);
|
||||
}
|
||||
|
||||
painter.setPen(PenStyle.NoPen);
|
||||
painter.setBrush(minuteColor);
|
||||
|
||||
painter.save();
|
||||
painter.rotate(6.0 * (time.getMinutes() + time.getSeconds() / 60.0));
|
||||
painter.drawConvexPolygon(minuteHand);
|
||||
painter.restore();
|
||||
|
||||
painter.setBrush(secondColor);
|
||||
painter.setPen(PenStyle.NoPen);
|
||||
|
||||
painter.save();
|
||||
painter.rotate(360 * (time.getSeconds() / 60.0));
|
||||
painter.drawConvexPolygon(secondHand);
|
||||
painter.restore();
|
||||
|
||||
painter.setPen(minuteColor);
|
||||
for (let j = 0; j < 60; ++j) {
|
||||
if (j % 5 != 0) {
|
||||
painter.drawLine(92, 0, 96, 0);
|
||||
}
|
||||
painter.rotate(6.0);
|
||||
}
|
||||
painter.end();
|
||||
const btn = new QToolButton();
|
||||
btn.setText('yolo');
|
||||
msgBox.addButton(btn);
|
||||
msgBox.addEventListener('buttonClicked', rawButtonPtr => {
|
||||
console.log(rawButtonPtr);
|
||||
const btn2 = new QToolButton(rawButtonPtr);
|
||||
btn2.setText('Helloooo');
|
||||
const newMsg = new QMessageBox();
|
||||
newMsg.exec();
|
||||
});
|
||||
msgBox.exec();
|
||||
|
||||
win.setCentralWidget(center);
|
||||
win.resize(400, 400);
|
||||
(global as any).msg = msgBox;
|
||||
|
||||
win.show();
|
||||
(global as any).win = win;
|
||||
setInterval(() => null, 1000);
|
||||
|
||||
@ -51,6 +51,8 @@ export { QScrollArea, QScrollAreaSignals } from './lib/QtWidgets/QScrollArea';
|
||||
export { QTreeWidget, QTreeWidgetSignals } from './lib/QtWidgets/QTreeWidget';
|
||||
export { QTreeWidgetItem } from './lib/QtWidgets/QTreeWidgetItem';
|
||||
export { QPainter, RenderHint } from './lib/QtWidgets/QPainter';
|
||||
export { QDialog, QDialogSignals } from './lib/QtWidgets/QDialog';
|
||||
export { QMessageBox, StandardButton, Icon, ButtonRole } from './lib/QtWidgets/QMessageBox';
|
||||
|
||||
export {
|
||||
QSystemTrayIcon,
|
||||
@ -76,4 +78,4 @@ export { FlexLayout, FlexLayoutSignals } from './lib/core/FlexLayout';
|
||||
// Others:
|
||||
export { StyleSheet } from './lib/core/Style/StyleSheet';
|
||||
export { NativeElement, Component } from './lib/core/Component';
|
||||
export { checkIfNativeElement } from './lib/utils/helpers';
|
||||
export { checkIfNativeElement, checkIfNapiExternal } from './lib/utils/helpers';
|
||||
|
||||
@ -37,7 +37,7 @@ export class QObject extends NodeObject<QObjectSignals> {
|
||||
let parent;
|
||||
if (checkIfNativeElement(arg)) {
|
||||
native = arg as NativeElement;
|
||||
} else if (arg as NodeObject<any>) {
|
||||
} else if (arg) {
|
||||
parent = arg as NodeObject<any>;
|
||||
native = new addon.QObject(parent.native);
|
||||
} else {
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import addon from '../utils/addon';
|
||||
import { NodeWidget } from './QWidget';
|
||||
import { NativeElement } from '../core/Component';
|
||||
import { NativeElement, NativeRawPointer, Component } from '../core/Component';
|
||||
import { QAbstractButton, QAbstractButtonSignals } from './QAbstractButton';
|
||||
import { checkIfNativeElement, checkIfNapiExternal } from '../utils/helpers';
|
||||
|
||||
export type QCheckBoxSignals = QAbstractButtonSignals;
|
||||
|
||||
@ -26,16 +27,24 @@ export class QCheckBox extends QAbstractButton<QCheckBoxSignals> {
|
||||
native: NativeElement;
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
constructor(rawPointer: NativeRawPointer<any>, disableNativeDeletion?: boolean);
|
||||
constructor(arg?: NodeWidget<any> | NativeRawPointer<any> | NativeElement, disableNativeDeletion = true) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QCheckBox(parent.native);
|
||||
let parent: Component | undefined;
|
||||
if (checkIfNativeElement(arg)) {
|
||||
native = arg as NativeElement;
|
||||
} else if (checkIfNapiExternal(arg)) {
|
||||
native = new addon.QCheckBox(arg, disableNativeDeletion);
|
||||
} else if (arg) {
|
||||
const parentWidget = arg as NodeWidget<any>;
|
||||
native = new addon.QCheckBox(parentWidget.native);
|
||||
parent = parentWidget;
|
||||
} else {
|
||||
native = new addon.QCheckBox();
|
||||
}
|
||||
super(native);
|
||||
this.native = native;
|
||||
this.setNodeParent(parent);
|
||||
parent && this.setNodeParent(parent);
|
||||
}
|
||||
setChecked(check: boolean): void {
|
||||
this.native.setChecked(check);
|
||||
|
||||
58
src/lib/QtWidgets/QDialog.ts
Normal file
58
src/lib/QtWidgets/QDialog.ts
Normal file
@ -0,0 +1,58 @@
|
||||
import addon from '../utils/addon';
|
||||
import { NativeElement } from '../core/Component';
|
||||
|
||||
import { checkIfNativeElement } from '../utils/helpers';
|
||||
import { NodeWidget, QWidgetSignals } from './QWidget';
|
||||
// All Dialogs should extend from NodeDialog
|
||||
// Implement all native QDialog methods here so that all dialogs get access to those aswell
|
||||
export abstract class NodeDialog<Signals extends QDialogSignals> extends NodeWidget<Signals> {
|
||||
setResult(i: number): void {
|
||||
this.native.setResult(i);
|
||||
}
|
||||
result(): number {
|
||||
return this.native.result();
|
||||
}
|
||||
setModal(modal: boolean): void {
|
||||
this.setProperty('modal', modal);
|
||||
}
|
||||
setSizeGripEnabled(enabled: boolean): void {
|
||||
this.setProperty('sizeGripEnabled', enabled);
|
||||
}
|
||||
isSizeGripEnabled(): boolean {
|
||||
return this.property('sizeGripEnabled').toBool();
|
||||
}
|
||||
exec(): number {
|
||||
return this.native.exec();
|
||||
}
|
||||
open(): void {
|
||||
this.native.open();
|
||||
}
|
||||
reject(): void {
|
||||
this.native.reject();
|
||||
}
|
||||
}
|
||||
|
||||
export interface QDialogSignals extends QWidgetSignals {
|
||||
accepted: () => void;
|
||||
finished: (result: number) => void;
|
||||
rejected: () => void;
|
||||
}
|
||||
|
||||
export class QDialog extends NodeDialog<QDialogSignals> {
|
||||
native: NativeElement;
|
||||
constructor(arg?: NodeDialog<QDialogSignals> | NativeElement) {
|
||||
let native;
|
||||
let parent;
|
||||
if (checkIfNativeElement(arg)) {
|
||||
native = arg as NativeElement;
|
||||
} else if (arg as NodeDialog<QDialogSignals>) {
|
||||
parent = arg as NodeDialog<QDialogSignals>;
|
||||
native = new addon.QDialog(parent.native);
|
||||
} else {
|
||||
native = new addon.QDialog();
|
||||
}
|
||||
super(native);
|
||||
this.setNodeParent(parent);
|
||||
this.native = native;
|
||||
}
|
||||
}
|
||||
@ -1,9 +1,10 @@
|
||||
import addon from '../utils/addon';
|
||||
import { NodeWidget, QWidgetSignals } from './QWidget';
|
||||
import { NodeWidget } from './QWidget';
|
||||
import { NativeElement } from '../core/Component';
|
||||
import { AcceptMode, DialogLabel, FileMode, Option, ViewMode } from '../QtEnums';
|
||||
import { NodeDialog, QDialogSignals } from './QDialog';
|
||||
|
||||
export interface QFileDialogSignals extends QWidgetSignals {
|
||||
export interface QFileDialogSignals extends QDialogSignals {
|
||||
currentChanged: (path: string) => void;
|
||||
currentUrlChanged: (url: string) => void;
|
||||
directoryEntered: (directory: string) => void;
|
||||
@ -15,7 +16,7 @@ export interface QFileDialogSignals extends QWidgetSignals {
|
||||
urlsSelected: (urls: string[]) => void;
|
||||
}
|
||||
|
||||
export class QFileDialog extends NodeWidget<QFileDialogSignals> {
|
||||
export class QFileDialog extends NodeDialog<QFileDialogSignals> {
|
||||
native: NativeElement;
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>, caption?: string, directory?: string, filter?: string);
|
||||
@ -30,9 +31,6 @@ export class QFileDialog extends NodeWidget<QFileDialogSignals> {
|
||||
this.native = native;
|
||||
this.setNodeParent(parent);
|
||||
}
|
||||
open(): void {
|
||||
this.native.open();
|
||||
}
|
||||
supportedSchemes(): string[] {
|
||||
return this.native.supportedSchemes();
|
||||
}
|
||||
|
||||
111
src/lib/QtWidgets/QMessageBox.ts
Normal file
111
src/lib/QtWidgets/QMessageBox.ts
Normal file
@ -0,0 +1,111 @@
|
||||
import addon from '../utils/addon';
|
||||
import { NodeWidget } from './QWidget';
|
||||
import { NativeElement, NativeRawPointer } from '../core/Component';
|
||||
import { NodeDialog, QDialogSignals } from './QDialog';
|
||||
import { QAbstractButton, QAbstractButtonSignals } from './QAbstractButton';
|
||||
import { QPushButton } from './QPushButton';
|
||||
|
||||
export interface QMessageBoxSignals extends QDialogSignals {
|
||||
buttonClicked: (buttonRawPointer: NativeRawPointer<'QAbstractButton*'>) => void;
|
||||
}
|
||||
|
||||
export enum StandardButton {
|
||||
Ok = 0x00000400,
|
||||
Open = 0x00002000,
|
||||
Save = 0x00000800,
|
||||
Cancel = 0x00400000,
|
||||
Close = 0x00200000,
|
||||
Discard = 0x00800000,
|
||||
Apply = 0x02000000,
|
||||
Reset = 0x04000000,
|
||||
RestoreDefaults = 0x08000000,
|
||||
Help = 0x01000000,
|
||||
SaveAll = 0x00001000,
|
||||
Yes = 0x00004000,
|
||||
YesToAll = 0x00008000,
|
||||
No = 0x00010000,
|
||||
NoToAll = 0x00020000,
|
||||
Abort = 0x00040000,
|
||||
Retry = 0x00080000,
|
||||
Ignore = 0x00100000,
|
||||
NoButton = 0x00000000,
|
||||
}
|
||||
export enum Icon {
|
||||
NoIcon = 0,
|
||||
Question = 4,
|
||||
Information = 1,
|
||||
Warning = 2,
|
||||
Critical = 3,
|
||||
}
|
||||
|
||||
export enum ButtonRole {
|
||||
InvalidRole,
|
||||
AcceptRole,
|
||||
RejectRole,
|
||||
DestructiveRole,
|
||||
ActionRole,
|
||||
HelpRole,
|
||||
YesRole,
|
||||
NoRole,
|
||||
ApplyRole,
|
||||
ResetRole,
|
||||
}
|
||||
export class QMessageBox extends NodeDialog<QMessageBoxSignals> {
|
||||
native: NativeElement;
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QMessageBox(parent.native);
|
||||
} else {
|
||||
native = new addon.QMessageBox();
|
||||
}
|
||||
super(native);
|
||||
this.native = native;
|
||||
this.setNodeParent(parent);
|
||||
}
|
||||
accept(): void {
|
||||
this.native.accept();
|
||||
}
|
||||
done(r: number): void {
|
||||
this.native.done(r);
|
||||
}
|
||||
setText(text: string): void {
|
||||
this.native.setProperty('text', text);
|
||||
}
|
||||
|
||||
text(): string {
|
||||
return this.property('text').toString();
|
||||
}
|
||||
|
||||
setInformativeText(informativeText: string): void {
|
||||
this.native.setProperty('informativeText', informativeText);
|
||||
}
|
||||
|
||||
setDetailedText(detailedText: string): void {
|
||||
this.native.setProperty('detailedText', detailedText);
|
||||
}
|
||||
|
||||
detailedText(): string {
|
||||
return this.property('detailedText').toString();
|
||||
}
|
||||
|
||||
setDefaultButton(button: QPushButton): void {
|
||||
this.native.setDefaultButton(button);
|
||||
this.nodeChildren.add(button);
|
||||
}
|
||||
|
||||
addButton(button: QAbstractButton<QAbstractButtonSignals>, role: ButtonRole = ButtonRole.NoRole): void {
|
||||
this.native.addButton(button.native, role);
|
||||
this.nodeChildren.add(button);
|
||||
}
|
||||
|
||||
static about(parent: NodeWidget<any>, title: string, text: string): void {
|
||||
addon.QMessageBox.about(parent.native, title, text);
|
||||
}
|
||||
|
||||
static aboutQt(parent: NodeWidget<any>, title: string): void {
|
||||
addon.QMessageBox.aboutQt(parent.native, title);
|
||||
}
|
||||
}
|
||||
@ -1,7 +1,8 @@
|
||||
import addon from '../utils/addon';
|
||||
import { NodeWidget } from './QWidget';
|
||||
import { NativeElement } from '../core/Component';
|
||||
import { NativeElement, NativeRawPointer, Component } from '../core/Component';
|
||||
import { QAbstractButton, QAbstractButtonSignals } from './QAbstractButton';
|
||||
import { checkIfNativeElement, checkIfNapiExternal } from '../utils/helpers';
|
||||
|
||||
export type QPushButtonSignals = QAbstractButtonSignals;
|
||||
/**
|
||||
@ -25,16 +26,25 @@ export class QPushButton extends QAbstractButton<QPushButtonSignals> {
|
||||
native: NativeElement;
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
constructor(native: NativeElement);
|
||||
constructor(rawPointer: NativeRawPointer<any>, disableNativeDeletion?: boolean);
|
||||
constructor(arg?: NodeWidget<any> | NativeRawPointer<any> | NativeElement, disableNativeDeletion = true) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QPushButton(parent.native);
|
||||
let parent: Component | undefined;
|
||||
if (checkIfNativeElement(arg)) {
|
||||
native = arg as NativeElement;
|
||||
} else if (checkIfNapiExternal(arg)) {
|
||||
native = new addon.QPushButton(arg, disableNativeDeletion);
|
||||
} else if (arg) {
|
||||
const parentWidget = arg as NodeWidget<any>;
|
||||
native = new addon.QPushButton(parentWidget.native);
|
||||
parent = parentWidget;
|
||||
} else {
|
||||
native = new addon.QPushButton();
|
||||
}
|
||||
super(native);
|
||||
this.setNodeParent(parent);
|
||||
this.native = native;
|
||||
parent && this.setNodeParent(parent);
|
||||
}
|
||||
setFlat(isFlat: boolean): void {
|
||||
this.native.setFlat(isFlat);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user