Export more class (#469)

* Add QDoubleSpinBox

* Add QBrush

* Add QListView and improve QListWidget

* Add QErrorMessage

* Add QFontDialog

* Add QProgressDialog

* Add QLCDNumber

Co-authored-by: wuxiaofeng <wuxiaofeng@erayt.com>
This commit is contained in:
feng8848 2020-03-29 01:15:23 +08:00 committed by GitHub
parent 5e241f43b0
commit 0ec2b3f2cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 1494 additions and 175 deletions

View File

@ -73,8 +73,11 @@ add_library(${CORE_WIDGETS_ADDON} SHARED
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QDateEdit/qdateedit_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QDateTimeEdit/qdatetimeedit_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QDoubleSpinBox/qdoublespinbox_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QErrorMessage/qerrormessage_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QFileDialog/qfiledialog_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QFontDialog/qfontdialog_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QFrame/qframe_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QListView/qlistview_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QListWidget/qlistwidget_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QListWidgetItem/qlistwidgetitem_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QTableView/qtableview_wrap.cpp"
@ -85,12 +88,14 @@ add_library(${CORE_WIDGETS_ADDON} SHARED
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QDial/qdial_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QLabel/qlabel_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QLayout/qlayout_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QLCDNumber/qlcdnumber_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QMainWindow/qmainwindow_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QPushButton/qpushbutton_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QToolButton/qtoolbutton_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QSpinBox/qspinbox_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QCheckBox/qcheckbox_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QProgressBar/qprogressbar_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QProgressDialog/qprogressdialog_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QRadioButton/qradiobutton_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QStackedWidget/qstackedwidget_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QTabBar/qtabbar_wrap.cpp"
@ -131,14 +136,19 @@ add_library(${CORE_WIDGETS_ADDON} SHARED
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QDateTimeEdit/ndatetimeedit.hpp"
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QDial/ndial.hpp"
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QDoubleSpinBox/ndoublespinbox.hpp"
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QErrorMessage/nerrormessage.hpp"
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QFileDialog/nfiledialog.hpp"
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QFontDialog/nfontdialog.hpp"
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QFrame/nframe.hpp"
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QLCDNumber/nlcdnumber.hpp"
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QListView/nlistview.hpp"
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QListWidget/nlistwidget.hpp"
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QTableView/ntableview.hpp"
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QTableWidget/ntablewidget.hpp"
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QLineEdit/nlineedit.hpp"
"${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/QProgressDialog/nprogressdialog.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/QInputDialog/ninputdialog.hpp"

View File

@ -0,0 +1,20 @@
#pragma once
#include <QErrorMessage>
#include "Extras/Export/export.h"
#include "QtWidgets/QDialog/qdialog_macro.h"
#include "core/NodeWidget/nodewidget.h"
#include "napi.h"
class DLL_EXPORT NErrorMessage : public QErrorMessage, public NodeWidget {
Q_OBJECT
NODEWIDGET_IMPLEMENTATIONS(QErrorMessage)
public:
using QErrorMessage::QErrorMessage;
void connectSignalsToEventEmitter() {
QDIALOG_SIGNALS
// Qt Connects: Implement all signal connects here
}
};

View File

@ -0,0 +1,26 @@
#pragma once
#include <napi.h>
#include <QPointer>
#include "Extras/Export/export.h"
#include "QtWidgets/QDialog/qdialog_macro.h"
#include "QtWidgets/QErrorMessage/nerrormessage.hpp"
class DLL_EXPORT QErrorMessageWrap
: public Napi::ObjectWrap<QErrorMessageWrap> {
QDIALOG_WRAPPED_METHODS_DECLARATION
private:
QPointer<NErrorMessage> instance;
public:
static Napi::Object init(Napi::Env env, Napi::Object exports);
QErrorMessageWrap(const Napi::CallbackInfo& info);
~QErrorMessageWrap();
NErrorMessage* getInternalInstance();
// class constructor
static Napi::FunctionReference constructor;
// wrapped methods
Napi::Value showMessage(const Napi::CallbackInfo& info);
};

View File

@ -0,0 +1,37 @@
#pragma once
#include <QFontDialog>
#include "Extras/Export/export.h"
#include "QtGui/QFont/qfont_wrap.h"
#include "QtWidgets/QDialog/qdialog_macro.h"
#include "core/NodeWidget/nodewidget.h"
#include "napi.h"
class DLL_EXPORT NFontDialog : public QFontDialog, public NodeWidget {
Q_OBJECT
NODEWIDGET_IMPLEMENTATIONS(QFontDialog)
public:
using QFontDialog::QFontDialog;
void connectSignalsToEventEmitter() {
QDIALOG_SIGNALS
// Qt Connects: Implement all signal connects here
QObject::connect(
this, &QFontDialog::currentFontChanged, [=](const QFont& font) {
Napi::Env env = this->emitOnNode.Env();
Napi::HandleScope scope(env);
auto instance = QFontWrap::constructor.New(
{Napi::External<QFont>::New(env, new QFont(font))});
this->emitOnNode.Call(
{Napi::String::New(env, "currentFontChanged"), instance});
});
QObject::connect(this, &QFontDialog::fontSelected, [=](const QFont& font) {
Napi::Env env = this->emitOnNode.Env();
Napi::HandleScope scope(env);
auto instance = QFontWrap::constructor.New(
{Napi::External<QFont>::New(env, new QFont(font))});
this->emitOnNode.Call({Napi::String::New(env, "fontSelected"), instance});
});
}
};

View File

@ -0,0 +1,27 @@
#pragma once
#include <napi.h>
#include <QPointer>
#include "Extras/Export/export.h"
#include "QtWidgets/QDialog/qdialog_macro.h"
#include "QtWidgets/QFontDialog/nfontdialog.hpp"
class DLL_EXPORT QFontDialogWrap : public Napi::ObjectWrap<QFontDialogWrap> {
QDIALOG_WRAPPED_METHODS_DECLARATION
private:
QPointer<NFontDialog> instance;
public:
static Napi::Object init(Napi::Env env, Napi::Object exports);
QFontDialogWrap(const Napi::CallbackInfo& info);
~QFontDialogWrap();
NFontDialog* getInternalInstance();
// class constructor
static Napi::FunctionReference constructor;
// wrapped methods
Napi::Value selectedFont(const Napi::CallbackInfo& info);
Napi::Value setOption(const Napi::CallbackInfo& info);
Napi::Value testOption(const Napi::CallbackInfo& info);
};

View File

@ -0,0 +1,23 @@
#pragma once
#include <QLCDNumber>
#include "Extras/Export/export.h"
#include "QtWidgets/QWidget/qwidget_macro.h"
#include "core/NodeWidget/nodewidget.h"
class DLL_EXPORT NLCDNumber : public QLCDNumber, public NodeWidget {
Q_OBJECT
NODEWIDGET_IMPLEMENTATIONS(QLCDNumber)
public:
using QLCDNumber::QLCDNumber; // inherit all constructors of QLCDNumber
void connectSignalsToEventEmitter() {
QWIDGET_SIGNALS
QObject::connect(this, &QLCDNumber::overflow, [=]() {
Napi::Env env = this->emitOnNode.Env();
Napi::HandleScope scope(env);
this->emitOnNode.Call({Napi::String::New(env, "overflow")});
});
}
};

View File

@ -0,0 +1,30 @@
#pragma once
#include <napi.h>
#include <QPointer>
#include "Extras/Export/export.h"
#include "QtWidgets/QWidget/qwidget_macro.h"
#include "nlcdnumber.hpp"
class DLL_EXPORT QLCDNumberWrap : public Napi::ObjectWrap<QLCDNumberWrap> {
QWIDGET_WRAPPED_METHODS_DECLARATION
private:
QPointer<NLCDNumber> instance;
public:
static Napi::Object init(Napi::Env env, Napi::Object exports);
QLCDNumberWrap(const Napi::CallbackInfo& info);
~QLCDNumberWrap();
NLCDNumber* getInternalInstance();
// class constructor
static Napi::FunctionReference constructor;
// wrapped methods
Napi::Value checkOverflow(const Napi::CallbackInfo& info);
Napi::Value display(const Napi::CallbackInfo& info);
Napi::Value setBinMode(const Napi::CallbackInfo& info);
Napi::Value setDecMode(const Napi::CallbackInfo& info);
Napi::Value setHexMode(const Napi::CallbackInfo& info);
Napi::Value setOctMode(const Napi::CallbackInfo& info);
};

View File

@ -0,0 +1,16 @@
#pragma once
#include <QListView>
#include "Extras/Export/export.h"
#include "QtWidgets/QListView/qlistview_macro.h"
#include "core/NodeWidget/nodewidget.h"
class DLL_EXPORT NListView : public QListView, public NodeWidget {
Q_OBJECT
NODEWIDGET_IMPLEMENTATIONS(QListView)
public:
using QListView::QListView;
void connectSignalsToEventEmitter() { QLISTVIEW_SIGNALS }
};

View File

@ -12,8 +12,8 @@
and every widget we export.
*/
#ifndef QListView_WRAPPED_METHODS_DECLARATION
#define QListView_WRAPPED_METHODS_DECLARATION \
#ifndef QLISTVIEW_WRAPPED_METHODS_DECLARATION
#define QLISTVIEW_WRAPPED_METHODS_DECLARATION \
QABSTRACTITEMVIEW_WRAPPED_METHODS_DECLARATION \
Napi::Value clearPropertyFlags(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
@ -36,18 +36,18 @@
return Napi::Boolean::New(env, this->instance->isRowHidden(row)); \
}
#endif // QListView_WRAPPED_METHODS_DECLARATION
#endif // QLISTVIEW_WRAPPED_METHODS_DECLARATION
#ifndef QListView_WRAPPED_METHODS_EXPORT_DEFINE
#define QListView_WRAPPED_METHODS_EXPORT_DEFINE(WidgetWrapName) \
#ifndef QLISTVIEW_WRAPPED_METHODS_EXPORT_DEFINE
#define QLISTVIEW_WRAPPED_METHODS_EXPORT_DEFINE(WidgetWrapName) \
QABSTRACTITEMVIEW_WRAPPED_METHODS_EXPORT_DEFINE(WidgetWrapName) \
InstanceMethod("clearPropertyFlags", &WidgetWrapName::clearPropertyFlags), \
InstanceMethod("setRowHidden", &WidgetWrapName::setRowHidden), \
InstanceMethod("isRowHidden", &WidgetWrapName::isRowHidden),
#endif // QListView_WRAPPED_METHODS_EXPORT_DEFINE
#endif // QLISTVIEW_WRAPPED_METHODS_EXPORT_DEFINE
#ifndef QListView_SIGNALS
#define QListView_SIGNALS QABSTRACTITEMVIEW_SIGNALS
#ifndef QLISTVIEW_SIGNALS
#define QLISTVIEW_SIGNALS QABSTRACTITEMVIEW_SIGNALS
#endif // QListView_SIGNALS
#endif // QLISTVIEW_SIGNALS

View File

@ -0,0 +1,25 @@
#pragma once
#include <napi.h>
#include <QPointer>
#include "Extras/Export/export.h"
#include "QtWidgets/QWidget/qwidget_macro.h"
#include "nlistview.hpp"
class DLL_EXPORT QListViewWrap : public Napi::ObjectWrap<QListViewWrap> {
QLISTVIEW_WRAPPED_METHODS_DECLARATION
private:
QPointer<NListView> instance;
bool disableDeletion;
public:
static Napi::Object init(Napi::Env env, Napi::Object exports);
QListViewWrap(const Napi::CallbackInfo& info);
~QListViewWrap();
NListView* getInternalInstance();
// class constructor
static Napi::FunctionReference constructor;
// wrapped methods
};

View File

@ -1,4 +1,5 @@
#pragma once
#include <napi.h>
#include <QListWidget>
@ -13,7 +14,24 @@ class DLL_EXPORT NListWidget : public QListWidget, public NodeWidget {
NODEWIDGET_IMPLEMENTATIONS(QListWidget)
public:
using QListWidget::QListWidget;
void connectSignalsToEventEmitter() {
QLISTVIEW_SIGNALS
// Qt Connects: Implement all signal connects here
QObject::connect(
this, &QListWidget::currentItemChanged,
[=](QListWidgetItem* current, QListWidgetItem* previous) {
Napi::Env env = this->emitOnNode.Env();
Napi::HandleScope scope(env);
auto curInstance = QListWidgetItemWrap::constructor.New(
{Napi::External<QListWidgetItem>::New(env, current),
Napi::Boolean::New(env, true)});
auto preInstance = QListWidgetItemWrap::constructor.New(
{Napi::External<QListWidgetItem>::New(env, previous),
Napi::Boolean::New(env, true)});
this->emitOnNode.Call({Napi::String::New(env, "currentItemChanged"),
curInstance, preInstance});
});
QObject::connect(
this, &QListWidget::currentRowChanged, [=](int currentRow) {
Napi::Env env = this->emitOnNode.Env();
@ -22,19 +40,77 @@ class DLL_EXPORT NListWidget : public QListWidget, public NodeWidget {
Napi::Number::New(env, currentRow)});
});
QObject::connect(this, &QListWidget::currentTextChanged,
[=](const QString &currentText) {
[=](const QString& currentText) {
Napi::Env env = this->emitOnNode.Env();
Napi::HandleScope scope(env);
this->emitOnNode.Call(
{Napi::String::New(env, "currentTextChanged"),
Napi::String::New(env, currentText.toStdString())});
});
QObject::connect(this, &QListWidget::itemActivated,
[=](QListWidgetItem* item) {
Napi::Env env = this->emitOnNode.Env();
Napi::HandleScope scope(env);
auto instance = QListWidgetItemWrap::constructor.New(
{Napi::External<QListWidgetItem>::New(env, item),
Napi::Boolean::New(env, true)});
this->emitOnNode.Call(
{Napi::String::New(env, "itemActivated"), instance});
});
QObject::connect(this, &QListWidget::itemChanged,
[=](QListWidgetItem* item) {
Napi::Env env = this->emitOnNode.Env();
Napi::HandleScope scope(env);
auto instance = QListWidgetItemWrap::constructor.New(
{Napi::External<QListWidgetItem>::New(env, item),
Napi::Boolean::New(env, true)});
this->emitOnNode.Call(
{Napi::String::New(env, "itemChanged"), instance});
});
QObject::connect(this, &QListWidget::itemClicked,
[=](QListWidgetItem* item) {
Napi::Env env = this->emitOnNode.Env();
Napi::HandleScope scope(env);
auto instance = QListWidgetItemWrap::constructor.New(
{Napi::External<QListWidgetItem>::New(env, item),
Napi::Boolean::New(env, true)});
this->emitOnNode.Call(
{Napi::String::New(env, "itemClicked"), instance});
});
QObject::connect(
this, &QListWidget::itemDoubleClicked, [=](QListWidgetItem* item) {
Napi::Env env = this->emitOnNode.Env();
Napi::HandleScope scope(env);
auto instance = QListWidgetItemWrap::constructor.New(
{Napi::External<QListWidgetItem>::New(env, item),
Napi::Boolean::New(env, true)});
this->emitOnNode.Call(
{Napi::String::New(env, "itemDoubleClicked"), instance});
});
QObject::connect(this, &QListWidget::itemEntered,
[=](QListWidgetItem* item) {
Napi::Env env = this->emitOnNode.Env();
Napi::HandleScope scope(env);
auto instance = QListWidgetItemWrap::constructor.New(
{Napi::External<QListWidgetItem>::New(env, item),
Napi::Boolean::New(env, true)});
this->emitOnNode.Call(
{Napi::String::New(env, "itemEntered"), instance});
});
QObject::connect(this, &QListWidget::itemPressed,
[=](QListWidgetItem* item) {
Napi::Env env = this->emitOnNode.Env();
Napi::HandleScope scope(env);
auto instance = QListWidgetItemWrap::constructor.New(
{Napi::External<QListWidgetItem>::New(env, item),
Napi::Boolean::New(env, true)});
this->emitOnNode.Call(
{Napi::String::New(env, "itemPressed"), instance});
});
QObject::connect(this, &QListWidget::itemSelectionChanged, [=]() {
Napi::Env env = this->emitOnNode.Env();
Napi::HandleScope scope(env);
this->emitOnNode.Call({Napi::String::New(env, "itemSelectionChanged")});
});
QListView_SIGNALS
}
};

View File

@ -10,8 +10,9 @@
#include "QtWidgets/QListWidget/nlistwidget.hpp"
class DLL_EXPORT QListWidgetWrap : public Napi::ObjectWrap<QListWidgetWrap> {
QListView_WRAPPED_METHODS_DECLARATION private : QPointer<NListWidget>
instance;
QLISTVIEW_WRAPPED_METHODS_DECLARATION
private:
QPointer<NListWidget> instance;
public:
static Napi::Object init(Napi::Env env, Napi::Object exports);
@ -26,6 +27,7 @@ class DLL_EXPORT QListWidgetWrap : public Napi::ObjectWrap<QListWidgetWrap> {
Napi::Value closePersistentEditor(const Napi::CallbackInfo& info);
Napi::Value currentItem(const Napi::CallbackInfo& info);
Napi::Value editItem(const Napi::CallbackInfo& info);
Napi::Value findItems(const Napi::CallbackInfo& info);
Napi::Value insertItem(const Napi::CallbackInfo& info);
Napi::Value insertItems(const Napi::CallbackInfo& info);
Napi::Value isPersistentEditorOpen(const Napi::CallbackInfo& info);
@ -35,6 +37,7 @@ class DLL_EXPORT QListWidgetWrap : public Napi::ObjectWrap<QListWidgetWrap> {
Napi::Value openPersistentEditor(const Napi::CallbackInfo& info);
Napi::Value removeItemWidget(const Napi::CallbackInfo& info);
Napi::Value row(const Napi::CallbackInfo& info);
Napi::Value selectedItems(const Napi::CallbackInfo& info);
Napi::Value setCurrentItem(const Napi::CallbackInfo& info);
Napi::Value setItemWidget(const Napi::CallbackInfo& info);
Napi::Value sortItems(const Napi::CallbackInfo& info);

View File

@ -4,10 +4,12 @@
#include <QListWidgetItem>
#include "Extras/Export/export.h"
#include "core/Component/component_wrap.h"
class DLL_EXPORT QListWidgetItemWrap
: public Napi::ObjectWrap<QListWidgetItemWrap> {
COMPONENT_WRAPPED_METHODS_DECLARATION
private:
QListWidgetItem* instance;
bool disableDeletion;
@ -20,11 +22,18 @@ class DLL_EXPORT QListWidgetItemWrap
// class constructor
static Napi::FunctionReference constructor;
// wrapped methods
Napi::Value setBackground(const Napi::CallbackInfo& info);
Napi::Value background(const Napi::CallbackInfo& info);
Napi::Value setCheckState(const Napi::CallbackInfo& info);
Napi::Value checkState(const Napi::CallbackInfo& info);
Napi::Value setData(const Napi::CallbackInfo& info);
Napi::Value data(const Napi::CallbackInfo& info);
Napi::Value setFlags(const Napi::CallbackInfo& info);
Napi::Value flags(const Napi::CallbackInfo& info);
Napi::Value setFont(const Napi::CallbackInfo& info);
Napi::Value font(const Napi::CallbackInfo& info);
Napi::Value setForeground(const Napi::CallbackInfo& info);
Napi::Value foreground(const Napi::CallbackInfo& info);
Napi::Value setIcon(const Napi::CallbackInfo& info);
Napi::Value icon(const Napi::CallbackInfo& info);
Napi::Value setHidden(const Napi::CallbackInfo& info);
@ -43,6 +52,5 @@ class DLL_EXPORT QListWidgetItemWrap
Napi::Value toolTip(const Napi::CallbackInfo& info);
Napi::Value setWhatsThis(const Napi::CallbackInfo& info);
Napi::Value whatsThis(const Napi::CallbackInfo& info);
COMPONENT_WRAPPED_METHODS_DECLARATION
Napi::Value type(const Napi::CallbackInfo& info);
};

View File

@ -0,0 +1,25 @@
#pragma once
#include <QProgressDialog>
#include "Extras/Export/export.h"
#include "QtWidgets/QDialog/qdialog_macro.h"
#include "core/NodeWidget/nodewidget.h"
#include "napi.h"
class DLL_EXPORT NProgressDialog : public QProgressDialog, public NodeWidget {
Q_OBJECT
NODEWIDGET_IMPLEMENTATIONS(QProgressDialog)
public:
using QProgressDialog::QProgressDialog;
void connectSignalsToEventEmitter() {
QDIALOG_SIGNALS
// Qt Connects: Implement all signal connects here
QObject::connect(this, &QProgressDialog::canceled, [=]() {
Napi::Env env = this->emitOnNode.Env();
Napi::HandleScope scope(env);
this->emitOnNode.Call({Napi::String::New(env, "canceled")});
});
}
};

View File

@ -0,0 +1,29 @@
#pragma once
#include <napi.h>
#include <QPointer>
#include "Extras/Export/export.h"
#include "QtWidgets/QDialog/qdialog_macro.h"
#include "QtWidgets/QProgressDialog/nprogressdialog.hpp"
class DLL_EXPORT QProgressDialogWrap
: public Napi::ObjectWrap<QProgressDialogWrap> {
QDIALOG_WRAPPED_METHODS_DECLARATION
private:
QPointer<NProgressDialog> instance;
public:
static Napi::Object init(Napi::Env env, Napi::Object exports);
QProgressDialogWrap(const Napi::CallbackInfo& info);
~QProgressDialogWrap();
NProgressDialog* getInternalInstance();
// class constructor
static Napi::FunctionReference constructor;
// wrapped methods
Napi::Value cancel(const Napi::CallbackInfo& info);
Napi::Value reset(const Napi::CallbackInfo& info);
Napi::Value setCancelButtonText(const Napi::CallbackInfo& info);
Napi::Value setRange(const Napi::CallbackInfo& info);
};

View File

@ -0,0 +1,60 @@
#include "QtWidgets/QErrorMessage/qerrormessage_wrap.h"
#include <QWidget>
#include "Extras/Utils/nutils.h"
#include "QtWidgets/QWidget/qwidget_wrap.h"
Napi::FunctionReference QErrorMessageWrap::constructor;
Napi::Object QErrorMessageWrap::init(Napi::Env env, Napi::Object exports) {
Napi::HandleScope scope(env);
char CLASSNAME[] = "QErrorMessage";
Napi::Function func = DefineClass(
env, CLASSNAME,
{InstanceMethod("showMessage", &QErrorMessageWrap::showMessage),
QDIALOG_WRAPPED_METHODS_EXPORT_DEFINE(QErrorMessageWrap)});
constructor = Napi::Persistent(func);
exports.Set(CLASSNAME, func);
return exports;
}
NErrorMessage* QErrorMessageWrap::getInternalInstance() {
return this->instance;
}
QErrorMessageWrap::~QErrorMessageWrap() {
extrautils::safeDelete(this->instance);
}
QErrorMessageWrap::QErrorMessageWrap(const Napi::CallbackInfo& info)
: Napi::ObjectWrap<QErrorMessageWrap>(info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
if (info.Length() == 1) {
Napi::Object parentObject = info[0].As<Napi::Object>();
NodeWidgetWrap* parentWidgetWrap =
Napi::ObjectWrap<NodeWidgetWrap>::Unwrap(parentObject);
QWidget* parent = parentWidgetWrap->getInternalInstance();
this->instance = new NErrorMessage(parent);
} else if (info.Length() == 0) {
this->instance = new NErrorMessage();
} else {
Napi::TypeError::New(env, "Wrong number of arguments")
.ThrowAsJavaScriptException();
}
this->rawData = extrautils::configureQWidget(
this->getInternalInstance(), this->getInternalInstance()->getFlexNode(),
false);
}
Napi::Value QErrorMessageWrap::showMessage(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
std::string napiMessage = info[0].As<Napi::String>().Utf8Value();
QString message = QString::fromUtf8(napiMessage.c_str());
this->instance->showMessage(message);
return env.Null();
}

View File

@ -0,0 +1,79 @@
#include "QtWidgets/QFontDialog/qfontdialog_wrap.h"
#include <QWidget>
#include "Extras/Utils/nutils.h"
#include "QtWidgets/QWidget/qwidget_wrap.h"
Napi::FunctionReference QFontDialogWrap::constructor;
Napi::Object QFontDialogWrap::init(Napi::Env env, Napi::Object exports) {
Napi::HandleScope scope(env);
char CLASSNAME[] = "QFontDialog";
Napi::Function func = DefineClass(
env, CLASSNAME,
{InstanceMethod("selectedFont", &QFontDialogWrap::selectedFont),
InstanceMethod("setOption", &QFontDialogWrap::setOption),
InstanceMethod("testOption", &QFontDialogWrap::testOption),
QDIALOG_WRAPPED_METHODS_EXPORT_DEFINE(QFontDialogWrap)});
constructor = Napi::Persistent(func);
exports.Set(CLASSNAME, func);
return exports;
}
NFontDialog* QFontDialogWrap::getInternalInstance() { return this->instance; }
QFontDialogWrap::~QFontDialogWrap() { extrautils::safeDelete(this->instance); }
QFontDialogWrap::QFontDialogWrap(const Napi::CallbackInfo& info)
: Napi::ObjectWrap<QFontDialogWrap>(info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
if (info.Length() == 1) {
Napi::Object parentObject = info[0].As<Napi::Object>();
NodeWidgetWrap* parentWidgetWrap =
Napi::ObjectWrap<NodeWidgetWrap>::Unwrap(parentObject);
QWidget* parent = parentWidgetWrap->getInternalInstance();
this->instance = new NFontDialog(parent);
} else if (info.Length() == 0) {
this->instance = new NFontDialog();
} else {
Napi::TypeError::New(env, "Wrong number of arguments")
.ThrowAsJavaScriptException();
}
this->rawData = extrautils::configureQWidget(
this->getInternalInstance(), this->getInternalInstance()->getFlexNode(),
false);
}
Napi::Value QFontDialogWrap::selectedFont(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QFont font = this->instance->selectedFont();
auto instance = QFontWrap::constructor.New(
{Napi::External<QFont>::New(env, new QFont(font))});
return instance;
}
Napi::Value QFontDialogWrap::setOption(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
int option = info[0].As<Napi::Number>().Int32Value();
bool on = info[1].As<Napi::Boolean>().Value();
this->instance->setOption(static_cast<QFontDialog::FontDialogOption>(option),
on);
return env.Null();
}
Napi::Value QFontDialogWrap::testOption(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
int option = info[0].As<Napi::Number>().Int32Value();
bool on = this->instance->testOption(
static_cast<QFontDialog::FontDialogOption>(option));
return Napi::Boolean::New(env, on);
}

View File

@ -0,0 +1,117 @@
#include "QtWidgets/QLCDNumber/qlcdnumber_wrap.h"
#include <QWidget>
#include "Extras/Utils/nutils.h"
#include "QtWidgets/QWidget/qwidget_wrap.h"
Napi::FunctionReference QLCDNumberWrap::constructor;
Napi::Object QLCDNumberWrap::init(Napi::Env env, Napi::Object exports) {
Napi::HandleScope scope(env);
char CLASSNAME[] = "QLCDNumber";
Napi::Function func = DefineClass(
env, CLASSNAME,
{InstanceMethod("checkOverflow", &QLCDNumberWrap::checkOverflow),
InstanceMethod("display", &QLCDNumberWrap::display),
InstanceMethod("setBinMode", &QLCDNumberWrap::setBinMode),
InstanceMethod("setDecMode", &QLCDNumberWrap::setDecMode),
InstanceMethod("setHexMode", &QLCDNumberWrap::setHexMode),
InstanceMethod("setOctMode", &QLCDNumberWrap::setOctMode),
QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE(QLCDNumberWrap)});
constructor = Napi::Persistent(func);
exports.Set(CLASSNAME, func);
return exports;
}
NLCDNumber* QLCDNumberWrap::getInternalInstance() { return this->instance; }
QLCDNumberWrap::~QLCDNumberWrap() { extrautils::safeDelete(this->instance); }
QLCDNumberWrap::QLCDNumberWrap(const Napi::CallbackInfo& info)
: Napi::ObjectWrap<QLCDNumberWrap>(info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
if (info.Length() == 1) {
Napi::Object parentObject = info[0].As<Napi::Object>();
NodeWidgetWrap* parentWidgetWrap =
Napi::ObjectWrap<NodeWidgetWrap>::Unwrap(parentObject);
this->instance = new NLCDNumber(parentWidgetWrap->getInternalInstance());
} else if (info.Length() == 0) {
this->instance = new NLCDNumber();
} else {
Napi::TypeError::New(env, "Wrong number of arguments")
.ThrowAsJavaScriptException();
}
this->rawData = extrautils::configureQWidget(
this->getInternalInstance(), this->getInternalInstance()->getFlexNode(),
true);
}
Napi::Value QLCDNumberWrap::checkOverflow(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Napi::Value value = info[0];
bool result;
if (extrautils::isNapiValueInt(env, value)) {
int num = value.As<Napi::Number>().Int32Value();
result = this->instance->checkOverflow(num);
} else {
double num = value.As<Napi::Number>().DoubleValue();
result = this->instance->checkOverflow(num);
}
return Napi::Boolean::New(env, result);
}
Napi::Value QLCDNumberWrap::display(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Napi::Value value = info[0];
if (value.IsString()) {
std::string napis = value.As<Napi::String>().Utf8Value();
QString s = QString::fromUtf8(napis.c_str());
this->instance->display(s);
} else if (extrautils::isNapiValueInt(env, value)) {
int num = value.As<Napi::Number>().Int32Value();
this->instance->display(num);
} else {
double num = value.As<Napi::Number>().DoubleValue();
this->instance->display(num);
}
return env.Null();
}
Napi::Value QLCDNumberWrap::setBinMode(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
this->instance->setBinMode();
return env.Null();
}
Napi::Value QLCDNumberWrap::setDecMode(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
this->instance->setDecMode();
return env.Null();
}
Napi::Value QLCDNumberWrap::setHexMode(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
this->instance->setHexMode();
return env.Null();
}
Napi::Value QLCDNumberWrap::setOctMode(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
this->instance->setOctMode();
return env.Null();
}

View File

@ -0,0 +1,53 @@
#include "QtWidgets/QListView/qlistview_wrap.h"
#include "Extras/Utils/nutils.h"
Napi::FunctionReference QListViewWrap::constructor;
Napi::Object QListViewWrap::init(Napi::Env env, Napi::Object exports) {
Napi::HandleScope scope(env);
char CLASSNAME[] = "QListView";
Napi::Function func = DefineClass(
env, CLASSNAME, {QLISTVIEW_WRAPPED_METHODS_EXPORT_DEFINE(QListViewWrap)});
constructor = Napi::Persistent(func);
exports.Set(CLASSNAME, func);
return exports;
}
NListView* QListViewWrap::getInternalInstance() { return this->instance; }
QListViewWrap::~QListViewWrap() {
if (!this->disableDeletion) {
extrautils::safeDelete(this->instance);
}
}
QListViewWrap::QListViewWrap(const Napi::CallbackInfo& info)
: Napi::ObjectWrap<QListViewWrap>(info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
if (info.Length() > 0 && info[0].IsExternal()) {
// --- if external ---
this->instance = info[0].As<Napi::External<NListView>>().Data();
if (info.Length() == 2) {
this->disableDeletion = info[1].As<Napi::Boolean>().Value();
}
} else {
// --- regular cases ---
if (info.Length() == 1) {
Napi::Object parentObject = info[0].As<Napi::Object>();
NodeWidgetWrap* parentWidgetWrap =
Napi::ObjectWrap<NodeWidgetWrap>::Unwrap(parentObject);
this->instance = new NListView(parentWidgetWrap->getInternalInstance());
} else if (info.Length() == 0) {
this->instance = new NListView();
} else {
Napi::TypeError::New(env, "Wrong number of arguments")
.ThrowAsJavaScriptException();
}
}
this->rawData = extrautils::configureQWidget(
this->getInternalInstance(), this->getInternalInstance()->getFlexNode(),
true);
}

View File

@ -18,6 +18,7 @@ Napi::Object QListWidgetWrap::init(Napi::Env env, Napi::Object exports) {
&QListWidgetWrap::closePersistentEditor),
InstanceMethod("currentItem", &QListWidgetWrap::currentItem),
InstanceMethod("editItem", &QListWidgetWrap::editItem),
InstanceMethod("findItems", &QListWidgetWrap::findItems),
InstanceMethod("insertItem", &QListWidgetWrap::insertItem),
InstanceMethod("insertItems", &QListWidgetWrap::insertItems),
InstanceMethod("isPersistentEditorOpen",
@ -29,6 +30,7 @@ Napi::Object QListWidgetWrap::init(Napi::Env env, Napi::Object exports) {
&QListWidgetWrap::openPersistentEditor),
InstanceMethod("removeItemWidget", &QListWidgetWrap::removeItemWidget),
InstanceMethod("row", &QListWidgetWrap::row),
InstanceMethod("selectedItems", &QListWidgetWrap::selectedItems),
InstanceMethod("setCurrentItem", &QListWidgetWrap::setCurrentItem),
InstanceMethod("setItemWidget", &QListWidgetWrap::setItemWidget),
InstanceMethod("sortItems", &QListWidgetWrap::sortItems),
@ -36,7 +38,7 @@ Napi::Object QListWidgetWrap::init(Napi::Env env, Napi::Object exports) {
InstanceMethod("visualItemRect", &QListWidgetWrap::visualItemRect),
InstanceMethod("clear", &QListWidgetWrap::clear),
InstanceMethod("scrollToItem", &QListWidgetWrap::scrollToItem),
QListView_WRAPPED_METHODS_EXPORT_DEFINE(QListWidgetWrap)});
QLISTVIEW_WRAPPED_METHODS_EXPORT_DEFINE(QListWidgetWrap)});
constructor = Napi::Persistent(func);
exports.Set(CLASSNAME, func);
return exports;
@ -127,6 +129,27 @@ Napi::Value QListWidgetWrap::editItem(const Napi::CallbackInfo& info) {
return env.Null();
}
Napi::Value QListWidgetWrap::findItems(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
std::string napiText = info[0].As<Napi::String>().Utf8Value();
QString text = QString::fromUtf8(napiText.c_str());
int flags = info[1].As<Napi::Number>().Int32Value();
QList<QListWidgetItem*> items =
this->instance->findItems(text, static_cast<Qt::MatchFlags>(flags));
Napi::Array napiItems = Napi::Array::New(env, items.size());
for (int i = 0; i < items.size(); i++) {
QListWidgetItem* item = items[i];
// disable deletion of the native instance for these by passing true
auto instance = QListWidgetItemWrap::constructor.New(
{Napi::External<QListWidgetItem>::New(env, item),
Napi::Boolean::New(env, true)});
napiItems[i] = instance;
}
return napiItems;
}
Napi::Value QListWidgetWrap::insertItem(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
@ -165,7 +188,7 @@ Napi::Value QListWidgetWrap::isPersistentEditorOpen(
Napi::ObjectWrap<QListWidgetItemWrap>::Unwrap(itemObject);
bool open =
this->instance->isPersistentEditorOpen(itemWrap->getInternalInstance());
return Napi::Value::From(env, open);
return Napi::Boolean::New(env, open);
}
Napi::Value QListWidgetWrap::item(const Napi::CallbackInfo& info) {
@ -238,7 +261,24 @@ Napi::Value QListWidgetWrap::row(const Napi::CallbackInfo& info) {
QListWidgetItemWrap* itemWrap =
Napi::ObjectWrap<QListWidgetItemWrap>::Unwrap(itemObject);
int row = this->instance->row(itemWrap->getInternalInstance());
return Napi::Value::From(env, row);
return Napi::Number::New(env, row);
}
Napi::Value QListWidgetWrap::selectedItems(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QList<QListWidgetItem*> items = this->instance->selectedItems();
Napi::Array napiItems = Napi::Array::New(env, items.size());
for (int i = 0; i < items.size(); i++) {
QListWidgetItem* item = items[i];
// disable deletion of the native instance for these by passing true
auto instance = QListWidgetItemWrap::constructor.New(
{Napi::External<QListWidgetItem>::New(env, item),
Napi::Boolean::New(env, true)});
napiItems[i] = instance;
}
return napiItems;
}
Napi::Value QListWidgetWrap::setCurrentItem(const Napi::CallbackInfo& info) {
@ -293,9 +333,9 @@ Napi::Value QListWidgetWrap::visualItemRect(const Napi::CallbackInfo& info) {
QListWidgetItemWrap* itemWrap =
Napi::ObjectWrap<QListWidgetItemWrap>::Unwrap(itemObject);
QRect rect = this->instance->visualItemRect(itemWrap->getInternalInstance());
auto rectWrap = QRectWrap::constructor.New(
auto instance = QRectWrap::constructor.New(
{Napi::External<QRect>::New(env, new QRect(rect))});
return rectWrap;
return instance;
}
Napi::Value QListWidgetWrap::clear(const Napi::CallbackInfo& info) {

View File

@ -3,6 +3,8 @@
#include "Extras/Utils/nutils.h"
#include "QtCore/QSize/qsize_wrap.h"
#include "QtCore/QVariant/qvariant_wrap.h"
#include "QtGui/QBrush/qbrush_wrap.h"
#include "QtGui/QFont/qfont_wrap.h"
#include "QtGui/QIcon/qicon_wrap.h"
#include "core/Component/component_wrap.h"
@ -13,11 +15,18 @@ Napi::Object QListWidgetItemWrap::init(Napi::Env env, Napi::Object exports) {
char CLASSNAME[] = "QListWidgetItem";
Napi::Function func = DefineClass(
env, CLASSNAME,
{InstanceMethod("setCheckState", &QListWidgetItemWrap::setCheckState),
{InstanceMethod("setBackground", &QListWidgetItemWrap::setBackground),
InstanceMethod("background", &QListWidgetItemWrap::background),
InstanceMethod("setCheckState", &QListWidgetItemWrap::setCheckState),
InstanceMethod("checkState", &QListWidgetItemWrap::checkState),
InstanceMethod("setData", &QListWidgetItemWrap::setData),
InstanceMethod("data", &QListWidgetItemWrap::data),
InstanceMethod("setFlags", &QListWidgetItemWrap::setFlags),
InstanceMethod("flags", &QListWidgetItemWrap::flags),
InstanceMethod("setFont", &QListWidgetItemWrap::setFont),
InstanceMethod("font", &QListWidgetItemWrap::font),
InstanceMethod("setForeground", &QListWidgetItemWrap::setForeground),
InstanceMethod("foreground", &QListWidgetItemWrap::foreground),
InstanceMethod("setIcon", &QListWidgetItemWrap::setIcon),
InstanceMethod("icon", &QListWidgetItemWrap::icon),
InstanceMethod("setHidden", &QListWidgetItemWrap::setHidden),
@ -37,6 +46,7 @@ Napi::Object QListWidgetItemWrap::init(Napi::Env env, Napi::Object exports) {
InstanceMethod("toolTip", &QListWidgetItemWrap::toolTip),
InstanceMethod("setWhatsThis", &QListWidgetItemWrap::setWhatsThis),
InstanceMethod("whatsThis", &QListWidgetItemWrap::whatsThis),
InstanceMethod("type$", &QListWidgetItemWrap::type),
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QListWidgetItemWrap)});
constructor = Napi::Persistent(func);
exports.Set(CLASSNAME, func);
@ -80,6 +90,26 @@ QListWidgetItemWrap::QListWidgetItemWrap(const Napi::CallbackInfo& info)
this->rawData = extrautils::configureComponent(this->getInternalInstance());
}
Napi::Value QListWidgetItemWrap::setBackground(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Napi::Object brushObject = info[0].As<Napi::Object>();
QBrushWrap* brushWrap = Napi::ObjectWrap<QBrushWrap>::Unwrap(brushObject);
this->instance->setBackground(*brushWrap->getInternalInstance());
return env.Null();
}
Napi::Value QListWidgetItemWrap::background(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QBrush brush = this->instance->background();
auto instance = QBrushWrap::constructor.New(
{Napi::External<QBrush>::New(env, new QBrush(brush))});
return instance;
}
Napi::Value QListWidgetItemWrap::setCheckState(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
@ -94,12 +124,25 @@ Napi::Value QListWidgetItemWrap::checkState(const Napi::CallbackInfo& info) {
Napi::HandleScope scope(env);
int state = static_cast<int>(this->instance->checkState());
return Napi::Value::From(env, state);
return Napi::Number::New(env, state);
}
Napi::Value QListWidgetItemWrap::setData(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
int role = info[0].As<Napi::Number>().Int32Value();
Napi::Object variantObject = info[1].As<Napi::Object>();
QVariantWrap* variantWrap =
Napi::ObjectWrap<QVariantWrap>::Unwrap(variantObject);
this->instance->setData(role, *variantWrap->getInternalInstance());
return env.Null();
}
Napi::Value QListWidgetItemWrap::data(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
int role = info[0].As<Napi::Number>().Int32Value();
QVariant data = this->instance->data(role);
auto instance = QVariantWrap::constructor.New(
@ -121,7 +164,47 @@ Napi::Value QListWidgetItemWrap::flags(const Napi::CallbackInfo& info) {
Napi::HandleScope scope(env);
int flags = static_cast<int>(this->instance->flags());
return Napi::Value::From(env, flags);
return Napi::Number::New(env, flags);
}
Napi::Value QListWidgetItemWrap::setFont(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Napi::Object fontObject = info[0].As<Napi::Object>();
QFontWrap* fontWrap = Napi::ObjectWrap<QFontWrap>::Unwrap(fontObject);
this->instance->setFont(*fontWrap->getInternalInstance());
return env.Null();
}
Napi::Value QListWidgetItemWrap::font(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QFont font = this->instance->font();
auto instance = QFontWrap::constructor.New(
{Napi::External<QFont>::New(env, new QFont(font))});
return instance;
}
Napi::Value QListWidgetItemWrap::setForeground(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Napi::Object brushObject = info[0].As<Napi::Object>();
QBrushWrap* brushWrap = Napi::ObjectWrap<QBrushWrap>::Unwrap(brushObject);
this->instance->setForeground(*brushWrap->getInternalInstance());
return env.Null();
}
Napi::Value QListWidgetItemWrap::foreground(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QBrush brush = this->instance->foreground();
auto instance = QBrushWrap::constructor.New(
{Napi::External<QBrush>::New(env, new QBrush(brush))});
return instance;
}
Napi::Value QListWidgetItemWrap::setIcon(const Napi::CallbackInfo& info) {
@ -157,7 +240,7 @@ Napi::Value QListWidgetItemWrap::isHidden(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
return Napi::Value::From(env, this->instance->isHidden());
return Napi::Boolean::New(env, this->instance->isHidden());
}
Napi::Value QListWidgetItemWrap::setSelected(const Napi::CallbackInfo& info) {
@ -173,7 +256,7 @@ Napi::Value QListWidgetItemWrap::isSelected(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
return Napi::Value::From(env, this->instance->isSelected());
return Napi::Boolean::New(env, this->instance->isSelected());
}
Napi::Value QListWidgetItemWrap::setSizeHint(const Napi::CallbackInfo& info) {
@ -281,3 +364,10 @@ Napi::Value QListWidgetItemWrap::whatsThis(const Napi::CallbackInfo& info) {
std::string whatsThis = this->instance->whatsThis().toStdString();
return Napi::String::New(env, whatsThis);
}
Napi::Value QListWidgetItemWrap::type(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
return Napi::Number::New(env, this->instance->type());
}

View File

@ -0,0 +1,91 @@
#include "QtWidgets/QProgressDialog/qprogressdialog_wrap.h"
#include <QWidget>
#include "Extras/Utils/nutils.h"
#include "QtWidgets/QWidget/qwidget_wrap.h"
Napi::FunctionReference QProgressDialogWrap::constructor;
Napi::Object QProgressDialogWrap::init(Napi::Env env, Napi::Object exports) {
Napi::HandleScope scope(env);
char CLASSNAME[] = "QProgressDialog";
Napi::Function func =
DefineClass(env, CLASSNAME,
{InstanceMethod("cancel", &QProgressDialogWrap::cancel),
InstanceMethod("reset", &QProgressDialogWrap::reset),
InstanceMethod("setCancelButtonText",
&QProgressDialogWrap::setCancelButtonText),
InstanceMethod("setRange", &QProgressDialogWrap::setRange),
QDIALOG_WRAPPED_METHODS_EXPORT_DEFINE(QProgressDialogWrap)});
constructor = Napi::Persistent(func);
exports.Set(CLASSNAME, func);
return exports;
}
NProgressDialog* QProgressDialogWrap::getInternalInstance() {
return this->instance;
}
QProgressDialogWrap::~QProgressDialogWrap() {
extrautils::safeDelete(this->instance);
}
QProgressDialogWrap::QProgressDialogWrap(const Napi::CallbackInfo& info)
: Napi::ObjectWrap<QProgressDialogWrap>(info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
if (info.Length() == 1) {
Napi::Object parentObject = info[0].As<Napi::Object>();
NodeWidgetWrap* parentWidgetWrap =
Napi::ObjectWrap<NodeWidgetWrap>::Unwrap(parentObject);
QWidget* parent = parentWidgetWrap->getInternalInstance();
this->instance = new NProgressDialog(parent);
} else if (info.Length() == 0) {
this->instance = new NProgressDialog();
} else {
Napi::TypeError::New(env, "Wrong number of arguments")
.ThrowAsJavaScriptException();
}
this->rawData = extrautils::configureQWidget(
this->getInternalInstance(), this->getInternalInstance()->getFlexNode(),
false);
}
Napi::Value QProgressDialogWrap::cancel(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
this->instance->cancel();
return env.Null();
}
Napi::Value QProgressDialogWrap::reset(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
this->instance->reset();
return env.Null();
}
Napi::Value QProgressDialogWrap::setCancelButtonText(
const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
std::string napiText = info[0].As<Napi::String>().Utf8Value();
QString text = QString::fromUtf8(napiText.c_str());
this->instance->setCancelButtonText(text);
return env.Null();
}
Napi::Value QProgressDialogWrap::setRange(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
int minimum = info[0].As<Napi::Number>().Int32Value();
int maximum = info[1].As<Napi::Number>().Int32Value();
this->instance->setRange(minimum, maximum);
return env.Null();
}

View File

@ -39,14 +39,18 @@
#include "QtWidgets/QDial/qdial_wrap.h"
#include "QtWidgets/QDialog/qdialog_wrap.h"
#include "QtWidgets/QDoubleSpinBox/qdoublespinbox_wrap.h"
#include "QtWidgets/QErrorMessage/qerrormessage_wrap.h"
#include "QtWidgets/QFileDialog/qfiledialog_wrap.h"
#include "QtWidgets/QFontDialog/qfontdialog_wrap.h"
#include "QtWidgets/QFrame/qframe_wrap.h"
#include "QtWidgets/QGridLayout/qgridlayout_wrap.h"
#include "QtWidgets/QGroupBox/qgroupbox_wrap.h"
#include "QtWidgets/QInputDialog/qinputdialog_wrap.h"
#include "QtWidgets/QLCDNumber/qlcdnumber_wrap.h"
#include "QtWidgets/QLabel/qlabel_wrap.h"
#include "QtWidgets/QLayout/qlayout_wrap.h"
#include "QtWidgets/QLineEdit/qlineedit_wrap.h"
#include "QtWidgets/QListView/qlistview_wrap.h"
#include "QtWidgets/QListWidget/qlistwidget_wrap.h"
#include "QtWidgets/QListWidgetItem/qlistwidgetitem_wrap.h"
#include "QtWidgets/QMainWindow/qmainwindow_wrap.h"
@ -56,6 +60,7 @@
#include "QtWidgets/QPainter/qpainter_wrap.h"
#include "QtWidgets/QPlainTextEdit/qplaintextedit_wrap.h"
#include "QtWidgets/QProgressBar/qprogressbar_wrap.h"
#include "QtWidgets/QProgressDialog/qprogressdialog_wrap.h"
#include "QtWidgets/QPushButton/qpushbutton_wrap.h"
#include "QtWidgets/QRadioButton/qradiobutton_wrap.h"
#include "QtWidgets/QScrollArea/qscrollarea_wrap.h"
@ -121,8 +126,11 @@ Napi::Object Main(Napi::Env env, Napi::Object exports) {
QBoxLayoutWrap::init(env, exports);
QDateEditWrap::init(env, exports);
QDateTimeEditWrap::init(env, exports);
QErrorMessageWrap::init(env, exports);
QFileDialogWrap::init(env, exports);
QFontDialogWrap::init(env, exports);
QFrameWrap::init(env, exports);
QListViewWrap::init(env, exports);
QListWidgetWrap::init(env, exports);
QListWidgetItemWrap::init(env, exports);
QTableViewWrap::init(env, exports);
@ -140,6 +148,7 @@ Napi::Object Main(Napi::Env env, Napi::Object exports) {
QSpinBoxWrap::init(env, exports);
QCheckBoxWrap::init(env, exports);
QProgressBarWrap::init(env, exports);
QProgressDialogWrap::init(env, exports);
QRadioButtonWrap::init(env, exports);
QStackedWidgetWrap::init(env, exports);
QTabBarWrap::init(env, exports);
@ -150,6 +159,7 @@ Napi::Object Main(Napi::Env env, Napi::Object exports) {
QPlainTextEditWrap::init(env, exports);
QDialWrap::init(env, exports);
QLabelWrap::init(env, exports);
QLCDNumberWrap::init(env, exports);
QScrollAreaWrap::init(env, exports);
QScrollBarWrap::init(env, exports);
QSystemTrayIconWrap::init(env, exports);

View File

@ -41,19 +41,32 @@ export { QColorDialog, QColorDialogSignals } from './lib/QtWidgets/QColorDialog'
export { QDateEdit } from './lib/QtWidgets/QDateEdit';
export { QDateTimeEdit, NodeDateTimeEdit, QDateTimeEditSignals } from './lib/QtWidgets/QDateTimeEdit';
export { QLabel, QLabelSignals } from './lib/QtWidgets/QLabel';
export { QLCDNumber, QLCDNumberSignals, Mode, SegmentStyle } from './lib/QtWidgets/QLCDNumber';
export { QDial, QDialSignals } from './lib/QtWidgets/QDial';
export { QDoubleSpinBox, QDoubleSpinBoxSignals } from './lib/QtWidgets/QDoubleSpinBox';
export { QErrorMessage, QErrorMessageSignals } from './lib/QtWidgets/QErrorMessage';
export { QFileDialog, QFileDialogSignals } from './lib/QtWidgets/QFileDialog';
export { QFontDialog, QFontDialogSignals, FontDialogOption } from './lib/QtWidgets/QFontDialog';
export { QFrame, QFrameSignals, Shadow, Shape } from './lib/QtWidgets/QFrame';
export { QLineEdit, QLineEditSignals, EchoMode } from './lib/QtWidgets/QLineEdit';
export { QMainWindow, QMainWindowSignals } from './lib/QtWidgets/QMainWindow';
export { QProgressBar, QProgressBarSignals, QProgressBarDirection } from './lib/QtWidgets/QProgressBar';
export { QProgressDialog, QProgressDialogSignals } from './lib/QtWidgets/QProgressDialog';
export { QComboBox, QComboBoxSignals, InsertPolicy } from './lib/QtWidgets/QComboBox';
export { QPushButton, QPushButtonSignals } from './lib/QtWidgets/QPushButton';
export { QToolButton, QToolButtonSignals, ToolButtonPopupMode } from './lib/QtWidgets/QToolButton';
export { QSpinBox, QSpinBoxSignals } from './lib/QtWidgets/QSpinBox';
export { QRadioButton, QRadioButtonSignals } from './lib/QtWidgets/QRadioButton';
export { QStackedWidget, QStackedWidgetSignals } from './lib/QtWidgets/QStackedWidget';
export {
QListView,
QListViewSignals,
Flow,
LayoutMode,
Movement,
ResizeMode,
ViewMode,
} from './lib/QtWidgets/QListView';
export { QListWidget, QListWidgetSignals } from './lib/QtWidgets/QListWidget';
export { QListWidgetItem } from './lib/QtWidgets/QListWidgetItem';
export { QTabBar, QTabBarSignals, ButtonPosition, SelectionBehavior, TabBarShape } from './lib/QtWidgets/QTabBar';

View File

@ -0,0 +1,43 @@
import addon from '../utils/addon';
import { NodeWidget } from './QWidget';
import { NativeElement } from '../core/Component';
import { NodeDialog, QDialogSignals } from './QDialog';
/**
> Create and control error message dialogs.
* **This class is a JS wrapper around Qt's [QErrorMessage class](https://doc.qt.io/qt-5/qerrormessage.html)**
The `QErrorMessage` class provides an error message display dialog.
### Example
```javascript
const { QErrorMessage } = require("@nodegui/nodegui");
const errorMessage = new QErrorMessage();
```
*/
export class QErrorMessage extends NodeDialog<QErrorMessageSignals> {
native: NativeElement;
constructor();
constructor(parent: NodeWidget<any>);
constructor(parent?: NodeWidget<any>) {
let native;
if (parent) {
native = new addon.QErrorMessage(parent.native);
} else {
native = new addon.QErrorMessage();
}
super(native);
this.native = native;
parent && this.setNodeParent(parent);
}
showMessage(message: string): void {
this.native.showMessage(message);
}
}
export type QErrorMessageSignals = QDialogSignals;

View File

@ -0,0 +1,77 @@
import addon from '../utils/addon';
import { NodeWidget } from './QWidget';
import { NativeElement } from '../core/Component';
import { NodeDialog, QDialogSignals } from './QDialog';
import { QFont } from '../QtGui/QFont';
/**
> Create and control font dialogs.
* **This class is a JS wrapper around Qt's [QFontDialog class](https://doc.qt.io/qt-5/qfontdialog.html)**
The `QFontDialog` class provides a dialog widget for selecting a font.
### Example
```javascript
const { QFontDialog } = require("@nodegui/nodegui");
const fontDialog = new QFontDialog();
fontDialog.exec();
const font = fontDialog.currentFont();
console.log(font);
```
*/
export class QFontDialog extends NodeDialog<QFontDialogSignals> {
native: NativeElement;
constructor();
constructor(parent: NodeWidget<any>);
constructor(parent?: NodeWidget<any>) {
let native;
if (parent) {
native = new addon.QFontDialog(parent.native);
} else {
native = new addon.QFontDialog();
}
super(native);
this.native = native;
parent && this.setNodeParent(parent);
}
setCurrentFont(font: QFont): void {
this.setProperty('currentFont', font.native);
}
currentFont(): QFont {
return QFont.fromQVariant(this.property('currentFont'));
}
setOptions(options: FontDialogOption): void {
this.setProperty('options', options);
}
options(): FontDialogOption {
return this.property('options').toInt();
}
selectedFont(): QFont {
return new QFont(this.native.selectedFont());
}
setOption(option: FontDialogOption, on = true): void {
this.native.setOption(option, on);
}
testOption(option: FontDialogOption): boolean {
return this.native.testOption(option);
}
}
export enum FontDialogOption {
NoButtons = 0x00000001,
DontUseNativeDialog = 0x00000002,
ScalableFonts = 0x00000004,
NonScalableFonts = 0x00000008,
MonospacedFonts = 0x00000010,
ProportionalFonts = 0x00000020,
}
export interface QFontDialogSignals extends QDialogSignals {
fontSelected: (font: QFont) => void;
currentFontChanged: (font: QFont) => void;
}

View File

@ -0,0 +1,103 @@
import addon from '../utils/addon';
import { NodeWidget, QWidgetSignals } from './QWidget';
import { NativeElement } from '../core/Component';
/**
> Create and control number.
* **This class is a JS wrapper around Qt's [QLCDNumber class](https://doc.qt.io/qt-5/qlcdnumber.html)**
The `QLCDNumber` widget displays a number with LCD-like digits.
### Example
```javascript
const { QLCDNumber } = require("@nodegui/nodegui");
const lcd = new QLCDNumber();
```
*/
export class QLCDNumber extends NodeWidget<QLCDNumberSignals> {
native: NativeElement;
constructor();
constructor(parent: NodeWidget<any>);
constructor(parent?: NodeWidget<any>) {
let native;
if (parent) {
native = new addon.QLCDNumber(parent.native);
} else {
native = new addon.QLCDNumber();
}
super(native);
this.native = native;
parent && this.setNodeParent(parent);
}
setDigitCount(numDigits: number): void {
this.setProperty('digitCount', numDigits);
}
digitCount(): number {
return this.property('digitCount').toInt();
}
intValue(): number {
return this.property('intValue').toInt();
}
setMode(mode: Mode): void {
this.setProperty('mode', mode);
}
mode(): Mode {
return this.property('mode').toInt();
}
setSegmentStyle(style: SegmentStyle): void {
this.setProperty('segmentStyle', style);
}
segmentStyle(): SegmentStyle {
return this.property('segmentStyle').toInt();
}
setSmallDecimalPoint(enabled: boolean): void {
this.setProperty('smallDecimalPoint', enabled);
}
smallDecimalPoint(): boolean {
return this.property('smallDecimalPoint').toBool();
}
value(): number {
return this.property('value').toDouble();
}
checkOverflow(num: number): boolean {
return this.native.checkOverflow(num);
}
display(value: string | number): void {
this.native.display(value);
}
setBinMode(): void {
this.native.setBinMode();
}
setDecMode(): void {
this.native.setDecMode();
}
setHexMode(): void {
this.native.setHexMode();
}
setOctMode(): void {
this.native.setOctMode();
}
}
export enum Mode {
Hex,
Dec,
Oct,
Bin,
}
export enum SegmentStyle {
Outline,
Filled,
Flat,
}
export interface QLCDNumberSignals extends QWidgetSignals {
overflow: () => void;
}

View File

@ -0,0 +1,163 @@
import addon from '../utils/addon';
import { NodeWidget } from './QWidget';
import { NativeElement } from '../core/Component';
import { QAbstractItemView, QAbstractItemViewSignals } from './QAbstractItemView';
import { QSize } from '../QtCore/QSize';
import { AlignmentFlag } from '../..';
/**
> The QListView class provides a list or icon view onto a model.
* **This class is a JS wrapper around Qt's [QListView class](https://doc.qt.io/qt-5/qlistview.html)**
### Example
```javascript
const { QListView } = require("@nodegui/nodegui");
const listview = new QListView();
```
*/
export abstract class NodeListView<Signals extends QListViewSignals> extends QAbstractItemView<Signals> {
setBatchSize(batchSize: number): void {
this.setProperty('batchSize', batchSize);
}
batchSize(): number {
return this.property('batchSize').toInt();
}
setFlow(flow: Flow): void {
this.setProperty('flow', flow);
}
flow(): Flow {
return this.property('flow').toInt();
}
setGridSize(size: QSize): void {
this.setProperty('gridSize', size.native);
}
gridSize(): QSize {
const gridSize = this.property('gridSize');
return QSize.fromQVariant(gridSize);
}
setWrapping(enable: boolean): void {
this.setProperty('isWrapping', enable);
}
isWrapping(): boolean {
return this.property('isWrapping').toBool();
}
setItemAlignment(alignment: AlignmentFlag): void {
this.setProperty('itemAlignment', alignment);
}
itemAlignment(): AlignmentFlag {
return this.property('itemAlignment').toInt();
}
setLayoutMode(mode: LayoutMode): void {
this.setProperty('layoutMode', mode);
}
layoutMode(): LayoutMode {
return this.property('layoutMode').toInt();
}
setModelColumn(column: number): void {
this.setProperty('modelColumn', column);
}
modelColumn(): number {
return this.property('modelColumn').toInt();
}
setMovement(movement: Movement): void {
this.setProperty('movement', movement);
}
movement(): Movement {
return this.property('movement').toInt();
}
setResizeMode(mode: ResizeMode): void {
this.setProperty('resizeMode', mode);
}
resizeMode(): ResizeMode {
return this.property('resizeMode').toInt();
}
setSelectionRectVisible(show: boolean): void {
this.setProperty('selectionRectVisible', show);
}
isSelectionRectVisible(): boolean {
return this.property('selectionRectVisible').toBool();
}
setSpacing(space: number): void {
this.setProperty('spacing', space);
}
spacing(): number {
return this.property('spacing').toInt();
}
setUniformItemSizes(enable: boolean): void {
this.setProperty('uniformItemSizes', enable);
}
uniformItemSizes(): boolean {
return this.property('uniformItemSizes').toBool();
}
setViewMode(mode: ViewMode): void {
this.setProperty('viewMode', mode);
}
viewMode(): ViewMode {
return this.property('viewMode').toInt();
}
setWordWrap(on: boolean): void {
this.setProperty('wordWrap', on);
}
wordWrap(): boolean {
return this.property('wordWrap').toBool();
}
clearPropertyFlags(): void {
this.native.clearPropertyFlags();
}
setRowHidden(row: number, hide: boolean): void {
this.native.setRowHidden(row, hide);
}
isRowHidden(row: number): boolean {
return this.native.isRowHidden(row);
}
}
export enum Flow {
LeftToRight,
TopToBottom,
}
export enum LayoutMode {
SinglePass,
Batched,
}
export enum Movement {
Static,
Free,
Snap,
}
export enum ResizeMode {
Fixed,
Adjust,
}
export enum ViewMode {
ListMode,
IconMode,
}
export class QListView extends NodeListView<QListViewSignals> {
native: NativeElement;
constructor();
constructor(parent: NodeWidget<any>);
constructor(parent?: NodeWidget<any>) {
let native;
if (parent) {
native = new addon.QListView(parent.native);
} else {
native = new addon.QListView();
}
super(native);
this.native = native;
parent && this.setNodeParent(parent);
}
}
export type QListViewSignals = QAbstractItemViewSignals;

View File

@ -2,10 +2,9 @@ import addon from '../utils/addon';
import { NodeWidget, QWidget } from './QWidget';
import { NativeElement, Component } from '../core/Component';
import { QListWidgetItem } from './QListWidgetItem';
import { QAbstractItemView, QAbstractItemViewSignals } from './QAbstractItemView';
import { QSize } from '../QtCore/QSize';
import { NodeListView, QListViewSignals } from './QListView';
import { QRect } from '../QtCore/QRect';
import { SortOrder, ScrollHint, AlignmentFlag } from '../QtEnums';
import { SortOrder, ScrollHint, MatchFlag } from '../QtEnums';
/**
@ -32,7 +31,7 @@ for (let i = 0; i < 30; i++) {
}
```
*/
export class QListWidget extends QAbstractItemView<QListWidgetSignals> {
export class QListWidget extends NodeListView<QListWidgetSignals> {
native: NativeElement;
items: Set<NativeElement | Component>;
constructor();
@ -46,9 +45,24 @@ export class QListWidget extends QAbstractItemView<QListWidgetSignals> {
}
super(native);
this.native = native;
this.setNodeParent(parent);
parent && this.setNodeParent(parent);
this.items = new Set();
}
count(): number {
return this.property('count').toInt();
}
setCurrentRow(row: number): void {
this.setProperty('currentRow', row);
}
currentRow(): number {
return this.property('currentRow').toInt();
}
setSortingEnabled(enable: boolean): void {
this.setProperty('sortingEnabled', enable);
}
isSortingEnabled(): boolean {
return this.property('sortingEnabled').toBool();
}
addItem(item: QListWidgetItem): void {
this.native.addItem(item.native);
this.items.add(item);
@ -65,6 +79,12 @@ export class QListWidget extends QAbstractItemView<QListWidgetSignals> {
editItem(item: Component): void {
this.native.editItem(item.native);
}
findItems(text: string, flags: MatchFlag): QListWidgetItem[] {
const nativeItems = this.native.findItems(text, flags);
return nativeItems.map(function(item: QListWidgetItem) {
return new QListWidgetItem(item);
});
}
insertItem(row: number, item: QListWidgetItem): void {
this.native.insertItem(row, item.native);
this.items.add(item);
@ -93,13 +113,19 @@ export class QListWidget extends QAbstractItemView<QListWidgetSignals> {
row(item: QListWidgetItem): number {
return this.native.row(item.native);
}
selectedItems(): QListWidgetItem[] {
const nativeItems = this.native.selectedItems();
return nativeItems.map(function(item: QListWidgetItem) {
return new QListWidgetItem(item);
});
}
setCurrentItem(item: QListWidgetItem): void {
this.native.setCurrentItem(item.native);
}
setItemWidget(item: QListWidgetItem, widget: QWidget): void {
setItemWidget(item: QListWidgetItem, widget: NodeWidget<any>): void {
this.native.setItemWidget(item.native, widget.native);
}
sortItems(order: SortOrder): void {
sortItems(order = SortOrder.AscendingOrder): void {
this.native.sortItems(order);
}
takeItem(row: number): void {
@ -111,148 +137,20 @@ export class QListWidget extends QAbstractItemView<QListWidgetSignals> {
clear(): void {
this.native.clear();
}
scrollToItem(item: QListWidgetItem, hint: ScrollHint): void {
scrollToItem(item: QListWidgetItem, hint = ScrollHint.EnsureVisible): void {
this.native.scrollToItem(item.native, hint);
}
clearPropertyFlags(): void {
this.native.clearPropertyFlags();
}
setRowHidden(row: number, hide: boolean): void {
this.native.setRowHidden(row, hide);
}
isRowHidden(row: number): boolean {
return this.native.isRowHidden(row);
}
count(): number {
return this.property('count').toInt();
}
setCurrentRow(row: number): void {
this.setProperty('currentRow', row);
}
currentRow(): number {
return this.property('currentRow').toInt();
}
setSortingEnabled(enable: boolean): void {
this.setProperty('sortingEnabled', enable);
}
isSortingEnabled(): boolean {
return this.property('sortingEnabled').toBool();
}
setBatchSize(batchSize: number): void {
this.setProperty('batchSize', batchSize);
}
batchSize(): number {
return this.property('batchSize').toInt();
}
setFlow(flow: Flow): void {
this.setProperty('flow', flow);
}
flow(): Flow {
return this.property('flow').toInt();
}
setGridSize(size: QSize): void {
this.setProperty('gridSize', size.native);
}
gridSize(): QSize {
const gridSize = this.property('gridSize');
return QSize.fromQVariant(gridSize);
}
setWrapping(enable: boolean): void {
this.setProperty('isWrapping', enable);
}
isWrapping(): boolean {
return this.property('isWrapping').toBool();
}
setItemAlignment(alignment: AlignmentFlag): void {
this.setProperty('itemAlignment', alignment);
}
itemAlignment(): AlignmentFlag {
return this.property('itemAlignment').toInt();
}
setLayoutMode(mode: LayoutMode): void {
this.setProperty('layoutMode', mode);
}
layoutMode(): LayoutMode {
return this.property('layoutMode').toInt();
}
setModelColumn(column: number): void {
this.setProperty('modelColumn', column);
}
modelColumn(): number {
return this.property('modelColumn').toInt();
}
setMovement(movement: Movement): void {
this.setProperty('movement', movement);
}
movement(): Movement {
return this.property('movement').toInt();
}
setResizeMode(mode: ResizeMode): void {
this.setProperty('resizeMode', mode);
}
resizeMode(): ResizeMode {
return this.property('resizeMode').toInt();
}
setSelectionRectVisible(show: boolean): void {
this.setProperty('selectionRectVisible', show);
}
isSelectionRectVisible(): boolean {
return this.property('selectionRectVisible').toBool();
}
setSpacing(space: number): void {
this.setProperty('spacing', space);
}
spacing(): number {
return this.property('spacing').toInt();
}
setUniformItemSizes(enable: boolean): void {
this.setProperty('uniformItemSizes', enable);
}
uniformItemSizes(): boolean {
return this.property('uniformItemSizes').toBool();
}
setViewMode(mode: ViewMode): void {
this.setProperty('viewMode', mode);
}
viewMode(): ViewMode {
return this.property('viewMode').toInt();
}
setWordWrap(on: boolean): void {
this.setProperty('wordWrap', on);
}
wordWrap(): boolean {
return this.property('wordWrap').toBool();
}
}
export enum Flow {
LeftToRight,
TopToBottom,
}
export enum LayoutMode {
SinglePass,
Batched,
}
export enum Movement {
Static,
Free,
Snap,
}
export enum ResizeMode {
Fixed,
Adjust,
}
export enum ViewMode {
ListMode,
IconMode,
}
export interface QListWidgetSignals extends QAbstractItemViewSignals {
export interface QListWidgetSignals extends QListViewSignals {
currentItemChanged: (current: QListWidgetItem, previous: QListWidgetItem) => void;
currentRowChanged: (currentRow: number) => void;
currentTextChanged: (currentText: string) => void;
itemActivated: (item: QListWidgetItem) => void;
itemChanged: (item: QListWidgetItem) => void;
itemClicked: (item: QListWidgetItem) => void;
itemDoubleClicked: (item: QListWidgetItem) => void;
itemEntered: (item: QListWidgetItem) => void;
itemPressed: (item: QListWidgetItem) => void;
itemSelectionChanged: () => void;
}

View File

@ -1,9 +1,11 @@
import addon from '../utils/addon';
import { checkIfNativeElement } from '../utils/helpers';
import { NativeElement, Component } from '../core/Component';
import { QBrush } from '../QtGui/QBrush';
import { QFont } from '../QtGui/QFont';
import { QIcon } from '../QtGui/QIcon';
import { QSize } from '../QtCore/QSize';
import { QVariant } from '../QtCore/QVariant';
import { checkIfNativeElement } from '../utils/helpers';
import { CheckState } from '../QtEnums';
import { ItemFlag } from '../QtEnums/ItemFlag';
@ -34,7 +36,11 @@ for (let i = 0; i < 30; i++) {
*/
export class QListWidgetItem extends Component {
native: NativeElement;
constructor(arg?: arg) {
constructor();
constructor(other: QListWidgetItem);
constructor(native: NativeElement);
constructor(text: string);
constructor(arg?: QListWidgetItem | NativeElement | string) {
let native;
if (typeof arg === 'string') {
native = new addon.QListWidgetItem(arg);
@ -46,12 +52,21 @@ export class QListWidgetItem extends Component {
super();
this.native = native;
}
setBackground(brush: QBrush): void {
this.native.setBackground(brush.native);
}
background(): QBrush {
return new QBrush(this.native.background());
}
setCheckState(state: CheckState): void {
this.native.setCheckState(state);
}
checkState(): CheckState {
return this.native.checkState();
}
setData(role: number, value: QVariant): void {
this.native.setData(role, value.native);
}
data(role: number): QVariant {
return new QVariant(this.native.data(role));
}
@ -61,6 +76,18 @@ export class QListWidgetItem extends Component {
flags(): ItemFlag {
return this.native.flags();
}
setFont(font: QFont): void {
this.native.setFont(font.native);
}
font(): QFont {
return new QFont(this.native.font());
}
setForeground(brush: QBrush): void {
this.native.setForeground(brush.native);
}
foreground(): QBrush {
return new QBrush(this.native.foreground());
}
setIcon(icon: QIcon): void {
this.native.setIcon(icon.native);
}
@ -98,7 +125,7 @@ export class QListWidgetItem extends Component {
return this.native.text();
}
setTextAlignment(alignment: number): void {
return this.native.setTextAlignment(alignment);
this.native.setTextAlignment(alignment);
}
textAlignment(): number {
return this.native.textAlignment();
@ -115,6 +142,7 @@ export class QListWidgetItem extends Component {
whatsThis(): string {
return this.native.whatsThis();
}
type(): number {
return this.native.type$();
}
}
type arg = string | NativeElement;

View File

@ -0,0 +1,99 @@
import addon from '../utils/addon';
import { NodeWidget } from './QWidget';
import { NativeElement } from '../core/Component';
import { NodeDialog, QDialogSignals } from './QDialog';
/**
> Create and control progress dialogs.
* **This class is a JS wrapper around Qt's [QProgressDialog class](https://doc.qt.io/qt-5/qprogressdialog.html)**
The `QProgressDialog` class provides feedback on the progress of a slow operation.
### Example
```javascript
const { QProgressDialog } = require("@nodegui/nodegui");
const progressDialog = new QProgressDialog();
```
*/
export class QProgressDialog extends NodeDialog<QProgressDialogSignals> {
native: NativeElement;
constructor();
constructor(parent: NodeWidget<any>);
constructor(parent?: NodeWidget<any>) {
let native;
if (parent) {
native = new addon.QProgressDialog(parent.native);
} else {
native = new addon.QProgressDialog();
}
super(native);
this.native = native;
parent && this.setNodeParent(parent);
}
setAutoClose(close: boolean): void {
this.setProperty('autoClose', close);
}
autoClose(): boolean {
return this.property('autoClose').toBool();
}
setAutoReset(reset: boolean): void {
this.setProperty('autoReset', reset);
}
autoReset(): boolean {
return this.property('autoReset').toBool();
}
setLabelText(text: string): void {
this.setProperty('labelText', text);
}
labelText(): string {
return this.property('labelText').toString();
}
setMaximum(maximum: number): void {
this.setProperty('maximum', maximum);
}
maximum(): number {
return this.property('maximum').toInt();
}
setMinimum(minimum: number): void {
this.setProperty('minimum', minimum);
}
minimum(): number {
return this.property('minimum').toInt();
}
setMinimumDuration(ms: number): void {
this.setProperty('minimumDuration', ms);
}
minimumDuration(): number {
return this.property('minimumDuration').toInt();
}
setValue(progress: number): void {
this.setProperty('value', progress);
}
value(): number {
return this.property('value').toInt();
}
wasCanceled(): boolean {
return this.property('wasCanceled').toBool();
}
cancel(): void {
this.native.cancel();
}
reset(): void {
this.native.reset();
}
setCancelButtonText(text: string): void {
this.native.setCancelButtonText(text);
}
setRange(minimum: number, maximum: number): void {
this.native.setRange(minimum, maximum);
}
}
export interface QProgressDialogSignals extends QDialogSignals {
canceled: () => void;
}