Add QToolButton Mainly (#265)

This commit is contained in:
feng8848 2019-12-15 23:49:01 +08:00 committed by Atul R
parent fb6244de69
commit 6c92f02edd
14 changed files with 531 additions and 14 deletions

View File

@ -64,6 +64,7 @@ add_library(${CORE_WIDGETS_ADDON} SHARED
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QLayout/qlayout_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"
@ -93,6 +94,7 @@ add_library(${CORE_WIDGETS_ADDON} SHARED
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QMainWindow/nmainwindow.hpp"
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QProgressBar/nprogressbar.hpp"
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QPushButton/npushbutton.hpp"
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QToolButton/ntoolbutton.hpp"
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QSpinBox/nspinbox.hpp"
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QRadioButton/nradiobutton.hpp"
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QPlainTextEdit/nplaintextedit.hpp"

View File

@ -9,4 +9,20 @@ class NLabel : public QLabel, public NodeWidget {
NODEWIDGET_IMPLEMENTATIONS(QLabel)
public:
using QLabel::QLabel; // inherit all constructors of QLabel
void connectWidgetSignalsToEventEmitter() {
// Qt Connects: Implement all signal connects here
QObject::connect(this, &QLabel::linkActivated, [=](const QString &link) {
Napi::Env env = this->emitOnNode.Env();
Napi::HandleScope scope(env);
this->emitOnNode.Call({Napi::String::New(env, "linkActivated"),
Napi::String::New(env, link.toStdString())});
});
QObject::connect(this, &QLabel::linkHovered, [=](const QString &link) {
Napi::Env env = this->emitOnNode.Env();
Napi::HandleScope scope(env);
this->emitOnNode.Call({Napi::String::New(env, "linkHovered"),
Napi::String::New(env, link.toStdString())});
});
}
};

View File

@ -20,6 +20,14 @@ class QLabelWrap : public Napi::ObjectWrap<QLabelWrap> {
// class constructor
static Napi::FunctionReference constructor;
// wrapped methods
Napi::Value setAlignment(const Napi::CallbackInfo& info);
Napi::Value alignment(const Napi::CallbackInfo& info);
Napi::Value setIndent(const Napi::CallbackInfo& info);
Napi::Value indent(const Napi::CallbackInfo& info);
Napi::Value setMargin(const Napi::CallbackInfo& info);
Napi::Value margin(const Napi::CallbackInfo& info);
Napi::Value setTextFormat(const Napi::CallbackInfo& info);
Napi::Value textFormat(const Napi::CallbackInfo& info);
Napi::Value setWordWrap(const Napi::CallbackInfo& info);
Napi::Value wordWrap(const Napi::CallbackInfo& info);
Napi::Value setText(const Napi::CallbackInfo& info);
@ -27,4 +35,6 @@ class QLabelWrap : public Napi::ObjectWrap<QLabelWrap> {
Napi::Value setPixmap(const Napi::CallbackInfo& info);
Napi::Value setMovie(const Napi::CallbackInfo& info);
Napi::Value setOpenExternalLinks(const Napi::CallbackInfo& info);
Napi::Value openExternalLinks(const Napi::CallbackInfo& info);
Napi::Value clear(const Napi::CallbackInfo& info);
};

View File

@ -0,0 +1,49 @@
#pragma once
#include <QAction>
#include <QToolButton>
#include "QtWidgets/QAction/qaction_wrap.h"
#include "core/NodeWidget/nodewidget.h"
#include "napi.h"
class NToolButton : public QToolButton, public NodeWidget {
Q_OBJECT
NODEWIDGET_IMPLEMENTATIONS(QToolButton)
public:
using QToolButton::QToolButton; // inherit all constructors of QToolButton
void connectWidgetSignalsToEventEmitter() {
// Qt Connects: Implement all signal connects here
QObject::connect(this, &QToolButton::clicked, [=](bool checked) {
Napi::Env env = this->emitOnNode.Env();
Napi::HandleScope scope(env);
this->emitOnNode.Call(
{Napi::String::New(env, "clicked"), Napi::Value::From(env, checked)});
});
QObject::connect(this, &QToolButton::released, [=]() {
Napi::Env env = this->emitOnNode.Env();
Napi::HandleScope scope(env);
this->emitOnNode.Call({Napi::String::New(env, "released")});
});
QObject::connect(this, &QToolButton::pressed, [=]() {
Napi::Env env = this->emitOnNode.Env();
Napi::HandleScope scope(env);
this->emitOnNode.Call({Napi::String::New(env, "pressed")});
});
QObject::connect(this, &QToolButton::toggled, [=](bool checked) {
Napi::Env env = this->emitOnNode.Env();
Napi::HandleScope scope(env);
this->emitOnNode.Call(
{Napi::String::New(env, "toggled"), Napi::Value::From(env, checked)});
});
QObject::connect(this, &QToolButton::triggered, [=](QAction *action) {
Napi::Env env = this->emitOnNode.Env();
Napi::HandleScope scope(env);
auto instance = QActionWrap::constructor.New(
{Napi::External<QAction>::New(env, action)});
this->emitOnNode.Call({Napi::String::New(env, "triggered"), instance});
});
}
};

View File

@ -0,0 +1,38 @@
#pragma once
#include <napi.h>
#include <stdlib.h>
#include <QPointer>
#include "Extras/Utils/nutils.h"
#include "QtWidgets/QAbstractButton/qabstractbutton_macro.h"
#include "QtWidgets/QWidget/qwidget_macro.h"
#include "ntoolbutton.hpp"
class QToolButtonWrap : public Napi::ObjectWrap<QToolButtonWrap> {
private:
QPointer<NToolButton> instance;
public:
static Napi::Object init(Napi::Env env, Napi::Object exports);
QToolButtonWrap(const Napi::CallbackInfo &info);
~QToolButtonWrap();
NToolButton *getInternalInstance();
// class constructor
static Napi::FunctionReference constructor;
// wrapped methods
Napi::Value setArrowType(const Napi::CallbackInfo &info);
Napi::Value arrowType(const Napi::CallbackInfo &info);
Napi::Value setAutoRaise(const Napi::CallbackInfo &info);
Napi::Value autoRaise(const Napi::CallbackInfo &info);
Napi::Value setPopupMode(const Napi::CallbackInfo &info);
Napi::Value popupMode(const Napi::CallbackInfo &info);
Napi::Value setToolButtonStyle(const Napi::CallbackInfo &info);
Napi::Value toolButtonStyle(const Napi::CallbackInfo &info);
Napi::Value setMenu(const Napi::CallbackInfo &info);
Napi::Value setDefaultAction(const Napi::CallbackInfo &info);
Napi::Value showMenu(const Napi::CallbackInfo &info);
QABSTRACTBUTTON_WRAPPED_METHODS_DECLARATION
};

View File

@ -89,6 +89,12 @@
static_cast<Qt::WindowState>(state.Int32Value())); \
return env.Null(); \
} \
Napi::Value windowState(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
Napi::HandleScope scope(env); \
int state = static_cast<int>(this->instance->windowState()); \
return Napi::Value::From(env, state); \
} \
Napi::Value setWindowTitle(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
Napi::HandleScope scope(env); \
@ -97,6 +103,12 @@
this->instance->setWindowTitle(title.c_str()); \
return env.Null(); \
} \
Napi::Value windowTitle(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
Napi::HandleScope scope(env); \
QString title = this->instance->windowTitle(); \
return Napi::String::New(env, title.toStdString()); \
} \
Napi::Value styleSheet(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
Napi::HandleScope scope(env); \
@ -286,6 +298,30 @@
Napi::HandleScope scope(env); \
this->instance->lower(); \
return env.Null(); \
} \
Napi::Value showFullScreen(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
Napi::HandleScope scope(env); \
this->instance->showFullScreen(); \
return env.Null(); \
} \
Napi::Value showMaximized(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
Napi::HandleScope scope(env); \
this->instance->showMaximized(); \
return env.Null(); \
} \
Napi::Value showMinimized(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
Napi::HandleScope scope(env); \
this->instance->showMinimized(); \
return env.Null(); \
} \
Napi::Value showNormal(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
Napi::HandleScope scope(env); \
this->instance->showNormal(); \
return env.Null(); \
}
#endif // QWIDGET_WRAPPED_METHODS_DECLARATION
@ -304,7 +340,9 @@
InstanceMethod("setCursor", &WidgetWrapName::setCursor), \
InstanceMethod("setWindowIcon", &WidgetWrapName::setWindowIcon), \
InstanceMethod("setWindowState", &WidgetWrapName::setWindowState), \
InstanceMethod("windowState", &WidgetWrapName::windowState), \
InstanceMethod("setWindowTitle", &WidgetWrapName::setWindowTitle), \
InstanceMethod("windowTitle", &WidgetWrapName::windowTitle), \
InstanceMethod("styleSheet", &WidgetWrapName::styleSheet), \
InstanceMethod("hide", &WidgetWrapName::hide), \
InstanceMethod("move", &WidgetWrapName::move), \
@ -330,6 +368,10 @@
InstanceMethod("adjustSize", &WidgetWrapName::adjustSize), \
InstanceMethod("activateWindow", &WidgetWrapName::activateWindow), \
InstanceMethod("raise", &WidgetWrapName::raise), \
InstanceMethod("lower", &WidgetWrapName::lower),
InstanceMethod("lower", &WidgetWrapName::lower), \
InstanceMethod("showFullScreen", &WidgetWrapName::showFullScreen), \
InstanceMethod("showMaximized", &WidgetWrapName::showMaximized), \
InstanceMethod("showMinimized", &WidgetWrapName::showMinimized), \
InstanceMethod("showNormal", &WidgetWrapName::showNormal),
#endif // QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE

View File

@ -11,17 +11,27 @@ Napi::FunctionReference QLabelWrap::constructor;
Napi::Object QLabelWrap::init(Napi::Env env, Napi::Object exports) {
Napi::HandleScope scope(env);
char CLASSNAME[] = "QLabel";
Napi::Function func =
DefineClass(env, CLASSNAME,
{InstanceMethod("setWordWrap", &QLabelWrap::setWordWrap),
InstanceMethod("wordWrap", &QLabelWrap::wordWrap),
InstanceMethod("setText", &QLabelWrap::setText),
InstanceMethod("text", &QLabelWrap::text),
InstanceMethod("setPixmap", &QLabelWrap::setPixmap),
InstanceMethod("setMovie", &QLabelWrap::setMovie),
InstanceMethod("setOpenExternalLinks",
&QLabelWrap::setOpenExternalLinks),
QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE(QLabelWrap)});
Napi::Function func = DefineClass(
env, CLASSNAME,
{InstanceMethod("setAlignment", &QLabelWrap::setAlignment),
InstanceMethod("alignment", &QLabelWrap::alignment),
InstanceMethod("setIndent", &QLabelWrap::setIndent),
InstanceMethod("indent", &QLabelWrap::indent),
InstanceMethod("setMargin", &QLabelWrap::setMargin),
InstanceMethod("margin", &QLabelWrap::margin),
InstanceMethod("setTextFormat", &QLabelWrap::setTextFormat),
InstanceMethod("textFormat", &QLabelWrap::textFormat),
InstanceMethod("setWordWrap", &QLabelWrap::setWordWrap),
InstanceMethod("wordWrap", &QLabelWrap::wordWrap),
InstanceMethod("setText", &QLabelWrap::setText),
InstanceMethod("text", &QLabelWrap::text),
InstanceMethod("setPixmap", &QLabelWrap::setPixmap),
InstanceMethod("setMovie", &QLabelWrap::setMovie),
InstanceMethod("setOpenExternalLinks",
&QLabelWrap::setOpenExternalLinks),
InstanceMethod("openExternalLinks", &QLabelWrap::openExternalLinks),
InstanceMethod("clear", &QLabelWrap::clear),
QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE(QLabelWrap)});
constructor = Napi::Persistent(func);
exports.Set(CLASSNAME, func);
return exports;
@ -53,6 +63,72 @@ QLabelWrap::QLabelWrap(const Napi::CallbackInfo& info)
extrautils::configureQWidget(this->getInternalInstance(), flexNode, true);
}
Napi::Value QLabelWrap::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(static_cast<Qt::Alignment>(alignment));
return env.Null();
}
Napi::Value QLabelWrap::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 QLabelWrap::setIndent(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
int indent = info[0].As<Napi::Number>().Int32Value();
this->instance->setIndent(indent);
return env.Null();
}
Napi::Value QLabelWrap::indent(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
return Napi::Value::From(env, this->instance->indent());
}
Napi::Value QLabelWrap::setMargin(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
int margin = info[0].As<Napi::Number>().Int32Value();
this->instance->setMargin(margin);
return env.Null();
}
Napi::Value QLabelWrap::margin(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
return Napi::Value::From(env, this->instance->margin());
}
Napi::Value QLabelWrap::setTextFormat(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
int format = info[0].As<Napi::Number>().Int32Value();
this->instance->setTextFormat(static_cast<Qt::TextFormat>(format));
return env.Null();
}
Napi::Value QLabelWrap::textFormat(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
int format = static_cast<int>(this->instance->textFormat());
return Napi::Value::From(env, format);
}
Napi::Value QLabelWrap::setWordWrap(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
@ -115,4 +191,19 @@ Napi::Value QLabelWrap::setOpenExternalLinks(const Napi::CallbackInfo& info) {
Napi::Boolean open = info[0].As<Napi::Boolean>();
this->instance->setOpenExternalLinks(open.Value());
return env.Null();
}
Napi::Value QLabelWrap::openExternalLinks(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
return Napi::Value::From(env, this->instance->openExternalLinks());
}
Napi::Value QLabelWrap::clear(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
this->instance->clear();
return env.Null();
}

View File

@ -0,0 +1,145 @@
#include "QtWidgets/QToolButton/qtoolbutton_wrap.h"
#include "Extras/Utils/nutils.h"
#include "QtWidgets/QAction/qaction_wrap.h"
#include "QtWidgets/QMenu/qmenu_wrap.h"
#include "QtWidgets/QWidget/qwidget_wrap.h"
Napi::FunctionReference QToolButtonWrap::constructor;
Napi::Object QToolButtonWrap::init(Napi::Env env, Napi::Object exports) {
Napi::HandleScope scope(env);
char CLASSNAME[] = "QToolButton";
Napi::Function func = DefineClass(
env, CLASSNAME,
{InstanceMethod("setArrowType", &QToolButtonWrap::setArrowType),
InstanceMethod("arrowType", &QToolButtonWrap::arrowType),
InstanceMethod("setAutoRaise", &QToolButtonWrap::setAutoRaise),
InstanceMethod("autoRaise", &QToolButtonWrap::autoRaise),
InstanceMethod("setPopupMode", &QToolButtonWrap::setPopupMode),
InstanceMethod("popupMode", &QToolButtonWrap::popupMode),
InstanceMethod("setToolButtonStyle",
&QToolButtonWrap::setToolButtonStyle),
InstanceMethod("toolButtonStyle", &QToolButtonWrap::toolButtonStyle),
InstanceMethod("setMenu", &QToolButtonWrap::setMenu),
InstanceMethod("setDefaultAction", &QToolButtonWrap::setDefaultAction),
InstanceMethod("showMenu", &QToolButtonWrap::showMenu),
QABSTRACTBUTTON_WRAPPED_METHODS_EXPORT_DEFINE(QToolButtonWrap)});
constructor = Napi::Persistent(func);
exports.Set(CLASSNAME, func);
return exports;
}
NToolButton *QToolButtonWrap::getInternalInstance() { return this->instance; }
QToolButtonWrap::QToolButtonWrap(const Napi::CallbackInfo &info)
: Napi::ObjectWrap<QToolButtonWrap>(info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
if (info.Length() == 1) {
Napi::Object parentObject = info[0].As<Napi::Object>();
QWidgetWrap *parentWidgetWrap =
Napi::ObjectWrap<QWidgetWrap>::Unwrap(parentObject);
this->instance = new NToolButton(parentWidgetWrap->getInternalInstance());
} else if (info.Length() == 0) {
this->instance = new NToolButton();
} else {
Napi::TypeError::New(env, "Wrong number of arguments")
.ThrowAsJavaScriptException();
}
this->rawData = extrautils::configureQWidget(
this->getInternalInstance(), this->getInternalInstance()->getFlexNode(),
true);
}
QToolButtonWrap::~QToolButtonWrap() { extrautils::safeDelete(this->instance); }
Napi::Value QToolButtonWrap::setArrowType(const Napi::CallbackInfo &info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
int type = info[0].As<Napi::Number>().Int32Value();
this->instance->setArrowType(static_cast<Qt::ArrowType>(type));
return env.Null();
}
Napi::Value QToolButtonWrap::arrowType(const Napi::CallbackInfo &info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
int type = static_cast<int>(this->instance->arrowType());
return Napi::Value::From(env, type);
}
Napi::Value QToolButtonWrap::setAutoRaise(const Napi::CallbackInfo &info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
bool enable = info[0].As<Napi::Boolean>().Value();
this->instance->setAutoRaise(enable);
return env.Null();
}
Napi::Value QToolButtonWrap::autoRaise(const Napi::CallbackInfo &info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
bool enable = this->instance->autoRaise();
return Napi::Value::From(env, enable);
}
Napi::Value QToolButtonWrap::setPopupMode(const Napi::CallbackInfo &info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
int mode = info[0].As<Napi::Number>().Int32Value();
this->instance->setPopupMode(
static_cast<QToolButton::ToolButtonPopupMode>(mode));
return env.Null();
}
Napi::Value QToolButtonWrap::popupMode(const Napi::CallbackInfo &info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
int mode = static_cast<int>(this->instance->popupMode());
return Napi::Value::From(env, mode);
}
Napi::Value QToolButtonWrap::setToolButtonStyle(
const Napi::CallbackInfo &info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
int style = info[0].As<Napi::Number>().Int32Value();
this->instance->setToolButtonStyle(static_cast<Qt::ToolButtonStyle>(style));
return env.Null();
}
Napi::Value QToolButtonWrap::toolButtonStyle(const Napi::CallbackInfo &info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
int style = static_cast<int>(this->instance->toolButtonStyle());
return Napi::Value::From(env, style);
}
Napi::Value QToolButtonWrap::setMenu(const Napi::CallbackInfo &info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Napi::Object menuObject = info[0].As<Napi::Object>();
QMenuWrap *menuWrap = Napi::ObjectWrap<QMenuWrap>::Unwrap(menuObject);
this->instance->setMenu(menuWrap->getInternalInstance());
return env.Null();
}
Napi::Value QToolButtonWrap::setDefaultAction(const Napi::CallbackInfo &info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Napi::Object actionObject = info[0].As<Napi::Object>();
QActionWrap *actionWrap = Napi::ObjectWrap<QActionWrap>::Unwrap(actionObject);
this->instance->setDefaultAction(actionWrap->getInternalInstance());
return env.Null();
}
Napi::Value QToolButtonWrap::showMenu(const Napi::CallbackInfo &info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
this->instance->showMenu();
return env.Null();
}

View File

@ -42,6 +42,7 @@
#include "QtWidgets/QTabWidget/qtabwidget_wrap.h"
#include "QtWidgets/QTableWidget/qtablewidget_wrap.h"
#include "QtWidgets/QTableWidgetItem/qtablewidgetitem_wrap.h"
#include "QtWidgets/QToolButton/qtoolbutton_wrap.h"
#include "QtWidgets/QWidget/qwidget_wrap.h"
#include "core/FlexLayout/flexlayout_wrap.h"
// These cant be instantiated in JS Side
@ -77,6 +78,7 @@ Napi::Object Main(Napi::Env env, Napi::Object exports) {
FlexLayoutWrap::init(env, exports);
QMainWindowWrap::init(env, exports);
QPushButtonWrap::init(env, exports);
QToolButtonWrap::init(env, exports);
QSpinBoxWrap::init(env, exports);
QCheckBoxWrap::init(env, exports);
QProgressBarWrap::init(env, exports);

View File

@ -34,6 +34,7 @@ export { QMainWindow, QMainWindowEvents } from './lib/QtWidgets/QMainWindow';
export { QProgressBar, QProgressBarEvents } from './lib/QtWidgets/QProgressBar';
export { QComboBox, QComboBoxEvents } from './lib/QtWidgets/QComboBox';
export { QPushButton, QPushButtonEvents } from './lib/QtWidgets/QPushButton';
export { QToolButton, QToolButtonEvents, ToolButtonPopupMode } from './lib/QtWidgets/QToolButton';
export { QSpinBox, QSpinBoxEvents } from './lib/QtWidgets/QSpinBox';
export { QRadioButton, QRadioButtonEvents } from './lib/QtWidgets/QRadioButton';
export { QStackedWidget, QStackedWidgetEvents } from './lib/QtWidgets/QStackedWidget';

View File

@ -4,6 +4,8 @@ import { BaseWidgetEvents } from '../core/EventWidget';
import { NativeElement } from '../core/Component';
import { QPixmap } from '../QtGui/QPixmap';
import { QMovie } from '../QtGui/QMovie';
import { AlignmentFlag } from '../QtEnums/AlignmentFlag';
import { TextFormat } from '../QtEnums/TextFormat';
export const QLabelEvents = Object.freeze({
...BaseWidgetEvents,
@ -23,6 +25,30 @@ export class QLabel extends NodeWidget {
this.native = native;
this.nodeParent = parent;
}
setAlignment(alignment: AlignmentFlag): void {
this.native.setAlignment(alignment);
}
alignment(): AlignmentFlag {
return this.native.alignment();
}
setIndent(indent: number): void {
this.native.setIndent(indent);
}
indent(): number {
return this.native.indent();
}
setMargin(margin: number): void {
this.native.setMargin(margin);
}
margin(): number {
return this.native.margin();
}
setTextFormat(format: TextFormat): void {
this.native.setTextFormat(format);
}
textFormat(): TextFormat {
return this.native.textFormat();
}
setWordWrap(on: boolean): void {
this.native.setWordWrap(on);
}
@ -52,4 +78,10 @@ export class QLabel extends NodeWidget {
setOpenExternalLinks(open: boolean): void {
this.native.setOpenExternalLinks(open);
}
openExternalLinks(): boolean {
return this.native.openExternalLinks();
}
clear(): void {
this.native.clear();
}
}

View File

@ -25,6 +25,7 @@ export class QStackedWidget extends NodeWidget {
addWidget(widget: NodeWidget): void {
this.native.addWidget(widget.native);
this.nodeChildren.add(widget);
widget.setFlexNodeSizeControlled(true);
}
removeWidget(widget: NodeWidget): void {

View File

@ -0,0 +1,72 @@
import addon from '../utils/addon';
import { NodeWidget } from './QWidget';
import { BaseWidgetEvents } from '../core/EventWidget';
import { NativeElement } from '../core/Component';
import { QAbstractButton } from './QAbstractButton';
import { ToolButtonStyle } from '../QtEnums/ToolButtonStyle';
import { ArrowType } from '../QtEnums/ArrowType';
import { QAction } from '../QtWidgets/QAction';
import { QMenu } from './QMenu';
export enum ToolButtonPopupMode {
DelayedPopup,
MenuButtonPopup,
InstantPopup,
}
export const QToolButtonEvents = Object.freeze({
...BaseWidgetEvents,
clicked: 'clicked',
pressed: 'pressed',
released: 'released',
toggled: 'toggled',
triggered: 'triggered',
});
export class QToolButton extends QAbstractButton {
native: NativeElement;
constructor(parent?: NodeWidget) {
let native;
if (parent) {
native = new addon.QToolButton(parent.native);
} else {
native = new addon.QToolButton();
}
super(native);
this.nodeParent = parent;
this.native = native;
}
setArrowType(type: ArrowType): void {
this.native.setArrowType(type);
}
arrowType(): ArrowType {
return this.property('arrowType').toInt();
}
setAutoRaise(enable: boolean): void {
this.native.setAutoRaise(enable);
}
autoRaise(): boolean {
return this.property('autoRaise').toBool();
}
setPopupMode(mode: ToolButtonPopupMode): void {
this.native.setPopupMode(mode);
}
popupMode(): ToolButtonPopupMode {
return this.property('popupMode').toInt();
}
setToolButtonStyle(style: ToolButtonStyle): void {
this.native.setToolButtonStyle(style);
}
toolButtonStyle(): ToolButtonStyle {
return this.native.toolButtonStyle();
}
setMenu(menu: QMenu): void {
this.native.setMenu(menu.native);
}
setDefaultAction(action: QAction): void {
this.native.setDefaultAction(action.native);
}
showMenu(): void {
this.native.showMenu();
}
}

View File

@ -66,13 +66,17 @@ export abstract class NodeWidget extends YogaWidget {
return this.native.windowOpacity();
}
setWindowTitle(title: string): void {
//TODO:getter
return this.native.setWindowTitle(title);
}
windowTitle(): string {
return this.native.windowTitle();
}
setWindowState(state: WindowState): void {
//TODO:getter
return this.native.setWindowState(state);
}
windowState(): number {
return this.native.windowState();
}
setCursor(cursor: CursorShape | QCursor): void {
//TODO:getter
this.native.setCursor(cursor);
@ -153,6 +157,18 @@ export abstract class NodeWidget extends YogaWidget {
this.setInlineStyle(this._rawInlineStyle);
}
}
showFullScreen(): void {
this.native.showFullScreen();
}
showMinimized(): void {
this.native.showMinimized();
}
showMaximized(): void {
this.native.showMaximized();
}
showNormal(): void {
this.native.showNormal();
}
}
type Rect = {