Add QScrollBar and other improvements (#383)

* Add QScrollBar and other improvements

* Add Windows plugin export

* Fixes QDateEdit and QTimeEdit.

Co-authored-by: Atul R <atulanand94@gmail.com>
This commit is contained in:
feng8848 2020-02-08 03:22:49 +08:00 committed by GitHub
parent c97efce5f6
commit c47f788094
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 330 additions and 376 deletions

View File

@ -88,6 +88,7 @@ add_library(${CORE_WIDGETS_ADDON} SHARED
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QLineEdit/qlineedit_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QPlainTextEdit/qplaintextedit_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QScrollArea/qscrollarea_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QScrollBar/qscrollbar_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QSystemTrayIcon/qsystemtrayicon_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QAction/qaction_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QShortcut/qshortcut_wrap.cpp"
@ -129,6 +130,7 @@ add_library(${CORE_WIDGETS_ADDON} SHARED
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QRadioButton/nradiobutton.hpp"
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QPlainTextEdit/nplaintextedit.hpp"
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QScrollArea/nscrollarea.hpp"
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QScrollBar/nscrollbar.hpp"
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QStackedWidget/nstackedwidget.hpp"
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QTabWidget/ntabwidget.hpp"
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QSystemTrayIcon/nsystemtrayicon.hpp"

View File

@ -13,5 +13,13 @@ class DLL_EXPORT NCheckBox : public QCheckBox, public NodeWidget {
public:
using QCheckBox::QCheckBox; // inherit all constructors of QCheckBox
void connectSignalsToEventEmitter() { QABSTRACT_BUTTON_SIGNALS }
void connectSignalsToEventEmitter() {
QABSTRACT_BUTTON_SIGNALS
QObject::connect(this, &QCheckBox::stateChanged, [=](int state) {
Napi::Env env = this->emitOnNode.Env();
Napi::HandleScope scope(env);
this->emitOnNode.Call({Napi::String::New(env, "stateChanged"),
Napi::Value::From(env, state)});
});
}
};

View File

@ -23,6 +23,6 @@ class DLL_EXPORT QCheckBoxWrap : public Napi::ObjectWrap<QCheckBoxWrap> {
// class constructor
static Napi::FunctionReference constructor;
// wrapped methods
Napi::Value isChecked(const Napi::CallbackInfo& info);
Napi::Value setChecked(const Napi::CallbackInfo& info);
Napi::Value checkState(const Napi::CallbackInfo& info);
Napi::Value setCheckState(const Napi::CallbackInfo& info);
};

View File

@ -22,10 +22,4 @@ class DLL_EXPORT QDialWrap : public Napi::ObjectWrap<QDialWrap> {
// class constructor
static Napi::FunctionReference constructor;
// wrapped methods
Napi::Value setNotchesVisible(const Napi::CallbackInfo& info);
Napi::Value setWrapping(const Napi::CallbackInfo& info);
Napi::Value setNotchTarget(const Napi::CallbackInfo& info);
Napi::Value notchTarget(const Napi::CallbackInfo& info);
Napi::Value notchesVisible(const Napi::CallbackInfo& info);
Napi::Value wrapping(const Napi::CallbackInfo& info);
};

View File

@ -21,14 +21,4 @@ class DLL_EXPORT QGroupBoxWrap : public Napi::ObjectWrap<QGroupBoxWrap> {
// class constructor
static Napi::FunctionReference constructor;
// wrapped methods
Napi::Value alignment(const Napi::CallbackInfo& info);
Napi::Value isCheckable(const Napi::CallbackInfo& info);
Napi::Value isChecked(const Napi::CallbackInfo& info);
Napi::Value isFlat(const Napi::CallbackInfo& info);
Napi::Value setAlignment(const Napi::CallbackInfo& info);
Napi::Value setCheckable(const Napi::CallbackInfo& info);
Napi::Value setFlat(const Napi::CallbackInfo& info);
Napi::Value setTitle(const Napi::CallbackInfo& info);
Napi::Value title(const Napi::CallbackInfo& info);
Napi::Value setChecked(const Napi::CallbackInfo& info);
};

View File

@ -0,0 +1,19 @@
#pragma once
#include <QScrollBar>
#include "Extras/Utils/nutils.h"
#include "QtWidgets/QAbstractSlider/qabstractslider_macro.h"
#include "core/NodeWidget/nodewidget.h"
class DLL_EXPORT NScrollBar : public QScrollBar, public NodeWidget {
Q_OBJECT
NODEWIDGET_IMPLEMENTATIONS(QScrollBar)
public:
using QScrollBar::QScrollBar; // inherit all constructors of QScrollBar
void connectSignalsToEventEmitter() {
// Qt Connects: Implement all signal connects here
QABSTRACT_SLIDER_SIGNALS
}
};

View File

@ -0,0 +1,25 @@
#pragma once
#include <napi.h>
#include <QPointer>
#include "Extras/Utils/nutils.h"
#include "QtWidgets/QAbstractSlider/qabstractslider_macro.h"
#include "QtWidgets/QWidget/qwidget_macro.h"
#include "nscrollbar.hpp"
class DLL_EXPORT QScrollBarWrap : public Napi::ObjectWrap<QScrollBarWrap> {
QABSTRACTSLIDER_WRAPPED_METHODS_DECLARATION
private:
QPointer<NScrollBar> instance;
public:
static Napi::Object init(Napi::Env env, Napi::Object exports);
QScrollBarWrap(const Napi::CallbackInfo& info);
~QScrollBarWrap();
NScrollBar* getInternalInstance();
// class constructor
static Napi::FunctionReference constructor;
// wrapped methods
};

View File

@ -1,8 +1,9 @@
#pragma once
#include <QSpinBox>
#include "Extras/Utils/nutils.h"
#include "QtWidgets/QWidget/qwidget_macro.h"
#include "QtWidgets/QAbstractSpinBox/qabstractspinbox_macro.h"
#include "core/NodeWidget/nodewidget.h"
#include "napi.h"
@ -13,13 +14,14 @@ class DLL_EXPORT NSpinBox : public QSpinBox, public NodeWidget {
using QSpinBox::QSpinBox; // inherit all constructors of QSpinBox
void connectSignalsToEventEmitter() {
QWIDGET_SIGNALS
QABSTRACTSPINBOX_SIGNALS
// Qt Connects: Implement all signal connects here
QObject::connect(
this, QOverload<int>::of(&QSpinBox::valueChanged), [=](int val) {
Napi::Env env = this->emitOnNode.Env();
Napi::HandleScope scope(env);
this->emitOnNode.Call({Napi::String::New(env, "valueChanged")});
this->emitOnNode.Call({Napi::String::New(env, "valueChanged"),
Napi::Value::From(env, val)});
});
}
};

View File

@ -5,11 +5,11 @@
#include <QPointer>
#include "Extras/Utils/nutils.h"
#include "QtWidgets/QWidget/qwidget_macro.h"
#include "QtWidgets/QAbstractSpinBox/qabstractspinbox_macro.h"
#include "nspinbox.hpp"
class DLL_EXPORT QSpinBoxWrap : public Napi::ObjectWrap<QSpinBoxWrap> {
QWIDGET_WRAPPED_METHODS_DECLARATION
QABSTRACTSPINBOX_WRAPPED_METHODS_DECLARATION
private:
QPointer<NSpinBox> instance;
@ -21,13 +21,5 @@ class DLL_EXPORT QSpinBoxWrap : public Napi::ObjectWrap<QSpinBoxWrap> {
// class constructor
static Napi::FunctionReference constructor;
// wrapped methods
Napi::Value setPrefix(const Napi::CallbackInfo &info);
Napi::Value setSingleStep(const Napi::CallbackInfo &info);
Napi::Value setSuffix(const Napi::CallbackInfo &info);
Napi::Value setRange(const Napi::CallbackInfo &info);
Napi::Value setValue(const Napi::CallbackInfo &info);
Napi::Value cleanText(const Napi::CallbackInfo &info);
Napi::Value maximum(const Napi::CallbackInfo &info);
Napi::Value minimum(const Napi::CallbackInfo &info);
Napi::Value value(const Napi::CallbackInfo &info);
};

View File

@ -12,8 +12,8 @@ Napi::Object QCheckBoxWrap::init(Napi::Env env, Napi::Object exports) {
char CLASSNAME[] = "QCheckBox";
Napi::Function func = DefineClass(
env, CLASSNAME,
{InstanceMethod("setChecked", &QCheckBoxWrap::setChecked),
InstanceMethod("isChecked", &QCheckBoxWrap::isChecked),
{InstanceMethod("checkState", &QCheckBoxWrap::checkState),
InstanceMethod("setCheckState", &QCheckBoxWrap::setCheckState),
QABSTRACTBUTTON_WRAPPED_METHODS_EXPORT_DEFINE(QCheckBoxWrap)});
constructor = Napi::Persistent(func);
exports.Set(CLASSNAME, func);
@ -57,17 +57,19 @@ QCheckBoxWrap::~QCheckBoxWrap() {
}
}
Napi::Value QCheckBoxWrap::isChecked(const Napi::CallbackInfo& info) {
Napi::Value QCheckBoxWrap::checkState(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
bool isChecked = this->instance->isChecked();
return Napi::Value::From(env, isChecked);
Qt::CheckState state = this->instance->checkState();
return Napi::Value::From(env, static_cast<int>(state));
}
Napi::Value QCheckBoxWrap::setChecked(const Napi::CallbackInfo& info) {
Napi::Value QCheckBoxWrap::setCheckState(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Napi::Boolean check = info[0].As<Napi::Boolean>();
this->instance->setChecked(check.Value());
int state = info[0].As<Napi::Number>().Int32Value();
this->instance->setCheckState(static_cast<Qt::CheckState>(state));
return env.Null();
}

View File

@ -11,15 +11,9 @@ Napi::FunctionReference QDialWrap::constructor;
Napi::Object QDialWrap::init(Napi::Env env, Napi::Object exports) {
Napi::HandleScope scope(env);
char CLASSNAME[] = "QDial";
Napi::Function func = DefineClass(
env, CLASSNAME,
{InstanceMethod("setNotchesVisible", &QDialWrap::setNotchesVisible),
InstanceMethod("setWrapping", &QDialWrap::setWrapping),
InstanceMethod("setNotchTarget", &QDialWrap::setNotchTarget),
InstanceMethod("notchTarget", &QDialWrap::notchTarget),
InstanceMethod("notchesVisible", &QDialWrap::notchesVisible),
InstanceMethod("wrapping", &QDialWrap::wrapping),
QABSTRACTSLIDER_WRAPPED_METHODS_EXPORT_DEFINE(QDialWrap)});
Napi::Function func =
DefineClass(env, CLASSNAME,
{QABSTRACTSLIDER_WRAPPED_METHODS_EXPORT_DEFINE(QDialWrap)});
constructor = Napi::Persistent(func);
exports.Set(CLASSNAME, func);
return exports;
@ -50,48 +44,3 @@ QDialWrap::QDialWrap(const Napi::CallbackInfo& info)
}
QDialWrap::~QDialWrap() { extrautils::safeDelete(this->instance); }
Napi::Value QDialWrap::setNotchesVisible(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Napi::Boolean visible = info[0].As<Napi::Boolean>();
this->instance->setNotchesVisible(visible.Value());
return env.Null();
}
Napi::Value QDialWrap::setWrapping(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Napi::Boolean on = info[0].As<Napi::Boolean>();
this->instance->setWrapping(on.Value());
return env.Null();
}
Napi::Value QDialWrap::setNotchTarget(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Napi::Number target = info[0].As<Napi::Number>();
this->instance->setNotchTarget(target.FloatValue());
return env.Null();
}
Napi::Value QDialWrap::notchTarget(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
float target = this->instance->notchTarget();
return Napi::Value::From(env, target);
}
Napi::Value QDialWrap::notchesVisible(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
bool notchesVisible = this->instance->notchesVisible();
return Napi::Value::From(env, notchesVisible);
}
Napi::Value QDialWrap::wrapping(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
bool wrapping = this->instance->wrapping();
return Napi::Value::From(env, wrapping);
}

View File

@ -10,19 +10,8 @@ Napi::FunctionReference QGroupBoxWrap::constructor;
Napi::Object QGroupBoxWrap::init(Napi::Env env, Napi::Object exports) {
Napi::HandleScope scope(env);
char CLASSNAME[] = "QGroupBox";
Napi::Function func =
DefineClass(env, CLASSNAME,
{InstanceMethod("alignment", &QGroupBoxWrap::alignment),
InstanceMethod("isCheckable", &QGroupBoxWrap::isCheckable),
InstanceMethod("isChecked", &QGroupBoxWrap::isChecked),
InstanceMethod("isFlat", &QGroupBoxWrap::isFlat),
InstanceMethod("setAlignment", &QGroupBoxWrap::setAlignment),
InstanceMethod("setCheckable", &QGroupBoxWrap::setCheckable),
InstanceMethod("setFlat", &QGroupBoxWrap::setFlat),
InstanceMethod("setTitle", &QGroupBoxWrap::setTitle),
InstanceMethod("title", &QGroupBoxWrap::title),
InstanceMethod("setChecked", &QGroupBoxWrap::setChecked),
QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE(QGroupBoxWrap)});
Napi::Function func = DefineClass(
env, CLASSNAME, {QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE(QGroupBoxWrap)});
constructor = Napi::Persistent(func);
exports.Set(CLASSNAME, func);
return exports;
@ -52,78 +41,3 @@ QGroupBoxWrap::QGroupBoxWrap(const Napi::CallbackInfo& info)
}
QGroupBoxWrap::~QGroupBoxWrap() { extrautils::safeDelete(this->instance); }
Napi::Value QGroupBoxWrap::alignment(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
int alignment = static_cast<int>(this->instance->alignment());
return Napi::Value::From(env, alignment);
}
Napi::Value QGroupBoxWrap::isCheckable(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
bool checkable = this->instance->isCheckable();
return Napi::Value::From(env, checkable);
}
Napi::Value QGroupBoxWrap::isChecked(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
bool checked = this->instance->isChecked();
return Napi::Value::From(env, checked);
}
Napi::Value QGroupBoxWrap::isFlat(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
bool flat = this->instance->isFlat();
return Napi::Value::From(env, flat);
}
Napi::Value QGroupBoxWrap::setAlignment(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
int alignment = info[0].As<Napi::Number>().Int32Value();
this->instance->setAlignment(alignment);
return env.Null();
}
Napi::Value QGroupBoxWrap::setCheckable(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
bool checkable = info[0].As<Napi::Boolean>().Value();
this->instance->setCheckable(checkable);
return env.Null();
}
Napi::Value QGroupBoxWrap::setFlat(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
bool flat = info[0].As<Napi::Boolean>().Value();
this->instance->setFlat(flat);
return env.Null();
}
Napi::Value QGroupBoxWrap::setTitle(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
std::string text = info[0].As<Napi::String>().Utf8Value();
this->instance->setTitle(text.c_str());
return env.Null();
}
Napi::Value QGroupBoxWrap::title(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QString text = this->instance->title();
return Napi::String::New(env, text.toStdString().c_str());
}
Napi::Value QGroupBoxWrap::setChecked(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
bool checked = info[0].As<Napi::Boolean>().Value();
this->instance->setChecked(checked);
return env.Null();
}

View File

@ -0,0 +1,45 @@
#include "QtWidgets/QScrollBar/qscrollbar_wrap.h"
#include <QWidget>
#include "Extras/Utils/nutils.h"
#include "QtWidgets/QWidget/qwidget_wrap.h"
Napi::FunctionReference QScrollBarWrap::constructor;
Napi::Object QScrollBarWrap::init(Napi::Env env, Napi::Object exports) {
Napi::HandleScope scope(env);
char CLASSNAME[] = "QScrollBar";
Napi::Function func = DefineClass(
env, CLASSNAME,
{QABSTRACTSLIDER_WRAPPED_METHODS_EXPORT_DEFINE(QScrollBarWrap)});
constructor = Napi::Persistent(func);
exports.Set(CLASSNAME, func);
return exports;
}
NScrollBar* QScrollBarWrap::getInternalInstance() { return this->instance; }
QScrollBarWrap::QScrollBarWrap(const Napi::CallbackInfo& info)
: Napi::ObjectWrap<QScrollBarWrap>(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 NScrollBar(parentWidgetWrap->getInternalInstance());
} else if (info.Length() == 0) {
this->instance = new NScrollBar();
} else {
Napi::TypeError::New(env, "Wrong number of arguments")
.ThrowAsJavaScriptException();
}
this->rawData = extrautils::configureQWidget(
this->getInternalInstance(), this->getInternalInstance()->getFlexNode(),
true);
}
QScrollBarWrap::~QScrollBarWrap() { extrautils::safeDelete(this->instance); }

View File

@ -11,17 +11,8 @@ Napi::Object QSpinBoxWrap::init(Napi::Env env, Napi::Object exports) {
char CLASSNAME[] = "QSpinBox";
Napi::Function func = DefineClass(
env, CLASSNAME,
{InstanceMethod("setPrefix", &QSpinBoxWrap::setPrefix),
InstanceMethod("setSingleStep", &QSpinBoxWrap::setSingleStep),
InstanceMethod("setSuffix", &QSpinBoxWrap::setSuffix),
InstanceMethod("setRange", &QSpinBoxWrap::setRange),
InstanceMethod("setValue", &QSpinBoxWrap::setValue),
InstanceMethod("cleanText", &QSpinBoxWrap::cleanText),
InstanceMethod("maximum", &QSpinBoxWrap::maximum),
InstanceMethod("minimum", &QSpinBoxWrap::minimum),
InstanceMethod("value", &QSpinBoxWrap::value),
QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE(QSpinBoxWrap)});
{InstanceMethod("setRange", &QSpinBoxWrap::setRange),
QABSTRACTSPINBOX_WRAPPED_METHODS_EXPORT_DEFINE(QSpinBoxWrap)});
constructor = Napi::Persistent(func);
exports.Set(CLASSNAME, func);
return exports;
@ -52,35 +43,6 @@ QSpinBoxWrap::QSpinBoxWrap(const Napi::CallbackInfo& info)
QSpinBoxWrap::~QSpinBoxWrap() { extrautils::safeDelete(this->instance); }
Napi::Value QSpinBoxWrap::setPrefix(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Napi::String napiPrefix = info[0].As<Napi::String>();
std::string prefix = napiPrefix.Utf8Value();
this->instance->setPrefix(prefix.c_str());
return env.Null();
}
Napi::Value QSpinBoxWrap::setSingleStep(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Napi::Number val = info[0].As<Napi::Number>();
this->instance->setSingleStep(val.Int32Value());
return env.Null();
}
Napi::Value QSpinBoxWrap::setSuffix(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Napi::String napiSuffix = info[0].As<Napi::String>();
std::string suffix = napiSuffix.Utf8Value();
this->instance->setSuffix(suffix.c_str());
return env.Null();
}
Napi::Value QSpinBoxWrap::setRange(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
@ -90,40 +52,3 @@ Napi::Value QSpinBoxWrap::setRange(const Napi::CallbackInfo& info) {
this->instance->setRange(minimum.Int32Value(), maximum.Int32Value());
return env.Null();
}
Napi::Value QSpinBoxWrap::setValue(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Napi::Number val = info[0].As<Napi::Number>();
this->instance->setValue(val.Int32Value());
return env.Null();
}
Napi::Value QSpinBoxWrap::cleanText(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QString cleanText = this->instance->cleanText();
return Napi::String::New(env, cleanText.toStdString().c_str());
}
Napi::Value QSpinBoxWrap::maximum(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
int maximum = this->instance->maximum();
return Napi::Number::New(env, maximum);
}
Napi::Value QSpinBoxWrap::minimum(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
int minimum = this->instance->minimum();
return Napi::Number::New(env, minimum);
}
Napi::Value QSpinBoxWrap::value(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
int value = this->instance->value();
return Napi::Number::New(env, value);
}

View File

@ -53,6 +53,7 @@
#include "QtWidgets/QPushButton/qpushbutton_wrap.h"
#include "QtWidgets/QRadioButton/qradiobutton_wrap.h"
#include "QtWidgets/QScrollArea/qscrollarea_wrap.h"
#include "QtWidgets/QScrollBar/qscrollbar_wrap.h"
#include "QtWidgets/QShortcut/qshortcut_wrap.h"
#include "QtWidgets/QSlider/qslider_wrap.h"
#include "QtWidgets/QSpinBox/qspinbox_wrap.h"
@ -132,6 +133,7 @@ Napi::Object Main(Napi::Env env, Napi::Object exports) {
QDialWrap::init(env, exports);
QLabelWrap::init(env, exports);
QScrollAreaWrap::init(env, exports);
QScrollBarWrap::init(env, exports);
QSystemTrayIconWrap::init(env, exports);
QActionWrap::init(env, exports);
QShortcutWrap::init(env, exports);

View File

@ -1,7 +1,7 @@
import { QInputDialog } from './index';
import { QDateEdit } from './lib/QtWidgets/QDateEdit';
const dialog = new QInputDialog();
dialog.setLabelText('Click that Omg button');
dialog.exec();
const dateEdit = new QDateEdit();
// (global as any).win = win;
dateEdit.show();
(global as any).dateEdit = dateEdit;

View File

@ -25,12 +25,18 @@ export { QAbstractScrollArea } from './lib/QtWidgets/QAbstractScrollArea';
export { QAbstractSlider, QAbstractSliderSignals } from './lib/QtWidgets/QAbstractSlider';
export { QAbstractButton, QAbstractButtonSignals } from './lib/QtWidgets/QAbstractButton';
export { QAbstractItemView, QAbstractItemViewSignals } from './lib/QtWidgets/QAbstractItemView';
export { QAbstractSpinBox } from './lib/QtWidgets/QAbstractSpinBox';
export {
QAbstractSpinBox,
QAbstractSpinBoxSignals,
ButtonSymbols,
CorrectionMode,
StepType,
} from './lib/QtWidgets/QAbstractSpinBox';
// Widgets:
export { QCalendarWidget, QCalendarWidgetSignals } from './lib/QtWidgets/QCalendarWidget';
export { QCheckBox, QCheckBoxSignals } from './lib/QtWidgets/QCheckBox';
export { QDateEdit } from './lib/QtWidgets/QDateEdit';
export { QDateTimeEdit, QDateTimeEditSignals } from './lib/QtWidgets/QDateTimeEdit';
export { QDateTimeEdit, NodeDateTimeEdit, QDateTimeEditSignals } from './lib/QtWidgets/QDateTimeEdit';
export { QLabel, QLabelSignals } from './lib/QtWidgets/QLabel';
export { QDial, QDialSignals } from './lib/QtWidgets/QDial';
export { QFileDialog, QFileDialogSignals } from './lib/QtWidgets/QFileDialog';
@ -52,6 +58,7 @@ export { QMenu, QMenuSignals } from './lib/QtWidgets/QMenu';
export { QMenuBar, QMenuBarSignals } from './lib/QtWidgets/QMenuBar';
export { QPlainTextEdit, QPlainTextEditSignals, LineWrapMode } from './lib/QtWidgets/QPlainTextEdit';
export { QScrollArea, QScrollAreaSignals } from './lib/QtWidgets/QScrollArea';
export { QScrollBar, QScrollBarSignals } from './lib/QtWidgets/QScrollBar';
export { QSlider, QSliderSignals, TickPosition } from './lib/QtWidgets/QSlider';
export { QTimeEdit } from './lib/QtWidgets/QTimeEdit';
export { QTreeWidget, QTreeWidgetSignals } from './lib/QtWidgets/QTreeWidget';

View File

@ -100,6 +100,11 @@ export enum CorrectionMode {
CorrectToNearestValue,
}
export enum StepType {
DefaultStepType,
AdaptiveDecimalStepType,
}
export interface QAbstractSpinBoxSignals extends QWidgetSignals {
editingFinished: () => void;
}

View File

@ -3,6 +3,7 @@ import { NodeWidget } from './QWidget';
import { NativeElement, NativeRawPointer, Component } from '../core/Component';
import { QAbstractButton, QAbstractButtonSignals } from './QAbstractButton';
import { checkIfNativeElement, checkIfNapiExternal } from '../utils/helpers';
import { CheckState } from '../QtEnums';
/**
@ -44,12 +45,20 @@ export class QCheckBox extends QAbstractButton<QCheckBoxSignals> {
this.native = native;
parent && this.setNodeParent(parent);
}
setChecked(check: boolean): void {
this.native.setChecked(check);
setTristate(y = true): void {
this.setProperty('tristate', y);
}
isChecked(): boolean {
return this.native.isChecked();
isTristate(): boolean {
return this.property('tristate').toBool();
}
checkState(): CheckState {
return this.native.checkState();
}
setCheckState(state: CheckState): void {
this.native.setCheckState(state);
}
}
export type QCheckBoxSignals = QAbstractButtonSignals;
export interface QCheckBoxSignals extends QAbstractButtonSignals {
stateChanged: (state: number) => void;
}

View File

@ -1,7 +1,7 @@
import addon from '../utils/addon';
import { NodeWidget } from './QWidget';
import { NativeElement } from '../core/Component';
import { QDateTimeEdit } from './QDateTimeEdit';
import { NodeDateTimeEdit } from './QDateTimeEdit';
/**
@ -20,7 +20,7 @@ const dateEdit = new QDateEdit();
// must be implemented
```
*/
export class QDateEdit extends QDateTimeEdit {
export class QDateEdit extends NodeDateTimeEdit {
native: NativeElement;
constructor();
constructor(parent: NodeWidget<any>);

View File

@ -8,45 +8,8 @@ import { QDateTime } from '../QtCore/QDateTime';
import { QTime } from '../QtCore/QTime';
import { TimeSpec } from '../QtEnums';
/**
> Creates and controls a widget for editing dates and times with spin box layout.
* **This class is a JS wrapper around Qt's [QDateTimeEdit class](https://doc.qt.io/qt-5/qdatetimeedit.html)**
### Example
```javascript
const { QDateTimeEdit, QDate, QTime } = require("@nodegui/nodegui");
const dateTimeEdit = new QDateTimeEdit();
let date = new QDate();
date.setDate(2020, 1, 1);
let time = new QTime();
time.setHMS(16, 30, 0);
dateTimeEdit.setDate(date);
dateTimeEdit.setTime(time);
```
*/
export class QDateTimeEdit extends QAbstractSpinBox<QDateTimeEditSignals> {
native: NativeElement;
export abstract class NodeDateTimeEdit extends QAbstractSpinBox<QDateTimeEditSignals> {
calendar?: QCalendarWidget;
constructor();
constructor(parent: NodeWidget<any>);
constructor(parent?: NodeWidget<any>) {
let native;
if (parent) {
native = new addon.QDateTimeEdit(parent.native);
} else {
native = new addon.QDateTimeEdit();
}
super(native);
this.native = native;
this.setNodeParent(parent);
}
setCalendarWidget(calendarWidget: QCalendarWidget): void {
this.calendar = calendarWidget;
this.native.setCalendarWidget(calendarWidget.native);
@ -99,6 +62,46 @@ export class QDateTimeEdit extends QAbstractSpinBox<QDateTimeEditSignals> {
}
}
/**
> Creates and controls a widget for editing dates and times with spin box layout.
* **This class is a JS wrapper around Qt's [QDateTimeEdit class](https://doc.qt.io/qt-5/qdatetimeedit.html)**
### Example
```javascript
const { QDateTimeEdit, QDate, QTime } = require("@nodegui/nodegui");
const dateTimeEdit = new QDateTimeEdit();
let date = new QDate();
date.setDate(2020, 1, 1);
let time = new QTime();
time.setHMS(16, 30, 0);
dateTimeEdit.setDate(date);
dateTimeEdit.setTime(time);
```
*/
export class QDateTimeEdit extends NodeDateTimeEdit {
native: NativeElement;
constructor();
constructor(parent: NodeWidget<any>);
constructor(parent?: NodeWidget<any>) {
let native;
if (parent) {
native = new addon.QDateTimeEdit(parent.native);
} else {
native = new addon.QDateTimeEdit();
}
super(native);
this.native = native;
this.setNodeParent(parent);
}
}
export interface QDateTimeEditSignals extends QAbstractSpinBoxSignals {
dateChanged: (date: QDate) => void;
dateTimeChanged: (datetime: QDateTime) => void;

View File

@ -34,23 +34,26 @@ export class QDial extends QAbstractSlider<QDialSignals> {
this.native = native;
this.setNodeParent(parent);
}
setNotchesVisible(visible: boolean): void {
this.native.setNotchesVisible(visible);
}
notchesVisible(): boolean {
return this.native.notchesVisible();
}
setWrapping(on: boolean): void {
this.native.setWrapping(on);
}
wrapping(): boolean {
return this.native.wrapping();
notchSize(): number {
return this.property('notchSize').toInt();
}
setNotchTarget(target: number): void {
this.native.setNotchTarget(target);
this.setProperty('notchTarget', target);
}
notchTarget(): number {
return this.native.notchTarget();
return this.property('notchTarget').toDouble();
}
setNotchesVisible(visible: boolean): void {
this.setProperty('notchesVisible', visible);
}
notchesVisible(): boolean {
return this.property('notchesVisible').toBool();
}
setWrapping(on: boolean): void {
this.setProperty('wrapping', on);
}
wrapping(): boolean {
return this.property('wrapping').toBool();
}
}

View File

@ -54,35 +54,35 @@ export class QGroupBox extends NodeWidget<QGroupBoxSignals> {
this.native = native;
this.setNodeParent(parent);
}
setAlignment(alignment: AlignmentFlag): void {
this.setProperty('alignment', alignment);
}
alignment(): AlignmentFlag {
return this.native.alignment();
}
isCheckable(): boolean {
return this.native.isCheckable();
}
isChecked(): boolean {
return this.native.isChecked();
}
isFlat(): boolean {
return this.native.isFlat();
}
setAlignment(alignment: number): void {
this.native.setAlignment(alignment);
return this.property('alignment').toInt();
}
setCheckable(checkable: boolean): void {
this.native.setCheckable(checkable);
this.setProperty('checkable', checkable);
}
setFlat(flat: boolean): void {
this.native.setFlat(flat);
}
setTitle(title: string): void {
this.native.setTitle(title);
}
title(): string {
return this.native.title();
isCheckable(): boolean {
return this.property('checkable').toBool();
}
setChecked(checked: boolean): void {
this.native.setChecked(checked);
this.setProperty('checked', checked);
}
isChecked(): boolean {
return this.property('checked').toBool();
}
setFlat(flat: boolean): void {
this.setProperty('flat', flat);
}
isFlat(): boolean {
return this.property('flat').toBool();
}
setTitle(title: string): void {
this.setProperty('title', title);
}
title(): string {
return this.property('title').toString();
}
}

View File

@ -0,0 +1,39 @@
import addon from '../utils/addon';
import { NodeWidget } from './QWidget';
import { NativeElement } from '../core/Component';
import { QAbstractSlider, QAbstractSliderSignals } from './QAbstractSlider';
/**
> Create and control scollbar widgets.
* **This class is a JS wrapper around Qt's [QScrollBar class](https://doc.qt.io/qt-5/qscrollbar.html)**
A `QScrollBar` provides ability to add and manipulate native scrollbar widgets.
### Example
```javascript
const { QScrollBar } = require("@nodegui/nodegui");
const scrollbar = new QScrollBar();
```
*/
export class QScrollBar extends QAbstractSlider<QScrollBarSignals> {
native: NativeElement;
constructor();
constructor(parent: NodeWidget<any>);
constructor(parent?: NodeWidget<any>) {
let native;
if (parent) {
native = new addon.QScrollBar(parent.native);
} else {
native = new addon.QScrollBar();
}
super(native);
this.native = native;
this.setNodeParent(parent);
}
}
export type QScrollBarSignals = QAbstractSliderSignals;

View File

@ -1,6 +1,7 @@
import addon from '../utils/addon';
import { NodeWidget, QWidgetSignals } from './QWidget';
import { NodeWidget } from './QWidget';
import { NativeElement } from '../core/Component';
import { QAbstractSpinBox, QAbstractSpinBoxSignals, StepType } from './QAbstractSpinBox';
/**
@ -18,7 +19,7 @@ const { QSpinBox } = require("@nodegui/nodegui");
const spinBox = new QSpinBox();
```
*/
export class QSpinBox extends NodeWidget<QSpinBoxSignals> {
export class QSpinBox extends QAbstractSpinBox<QSpinBoxSignals> {
native: NativeElement;
constructor();
constructor(parent: NodeWidget<any>);
@ -33,44 +34,62 @@ export class QSpinBox extends NodeWidget<QSpinBoxSignals> {
this.setNodeParent(parent);
this.native = native;
}
setPrefix(prefix: string): void {
// react:✓
this.native.setPrefix(prefix);
}
setSuffix(suffix: string): void {
// react:✓
this.native.setSuffix(suffix);
}
cleanText(): string {
// react:✓
return this.native.cleanText();
return this.property('cleanText').toString();
}
setSingleStep(val: number): void {
// react:✓
this.native.setSingleStep(val);
setDisplayIntegerBase(base: number): void {
this.setProperty('displayIntegerBase', base);
}
setRange(minimum: number, maximum: number): void {
// react:✓
this.native.setRange(minimum, maximum);
displayIntegerBase(): number {
return this.property('displayIntegerBase').toInt();
}
setMaximum(max: number): void {
this.setProperty('maximum', max);
}
maximum(): number {
// react:✓
return this.native.maximum();
return this.property('maximum').toInt();
}
setMinimum(min: number): void {
this.setProperty('minimum', min);
}
minimum(): number {
// react:✓
return this.native.minimum();
return this.property('minimum').toInt();
}
setPrefix(prefix: string): void {
this.setProperty('prefix', prefix);
}
prefix(): string {
return this.property('prefix').toString();
}
setSingleStep(val: number): void {
this.setProperty('singleStep', val);
}
singleStep(): number {
return this.property('singleStep').toInt();
}
setStepType(stepType: StepType): void {
this.setProperty('stepType', stepType);
}
stepType(): StepType {
return this.property('stepType').toInt();
}
setSuffix(suffix: string): void {
this.setProperty('suffix', suffix);
}
suffix(): string {
return this.property('suffix').toString();
}
setValue(val: number): void {
// react:✓
this.native.setValue(val);
this.setProperty('value', val);
}
value(): number {
// react:✓
return this.native.value();
return this.property('value').toInt();
}
setRange(minimum: number, maximum: number): void {
this.native.setRange(minimum, maximum);
}
}
export interface QSpinBoxSignals extends QWidgetSignals {
export interface QSpinBoxSignals extends QAbstractSpinBoxSignals {
valueChanged: (value: number) => void;
}

View File

@ -1,7 +1,7 @@
import addon from '../utils/addon';
import { NodeWidget } from './QWidget';
import { NativeElement } from '../core/Component';
import { QDateTimeEdit } from './QDateTimeEdit';
import { NodeDateTimeEdit } from './QDateTimeEdit';
/**
@ -20,7 +20,7 @@ const timeEdit = new QTimeEdit();
// must be implemented
```
*/
export class QTimeEdit extends QDateTimeEdit {
export class QTimeEdit extends NodeDateTimeEdit {
native: NativeElement;
constructor();
constructor(parent: NodeWidget<any>);