Mainwindow takeCentralWidget (#225)
* Adds takeCentralWidget to qmainwindow * lint fix * bump version to 0.6.7
This commit is contained in:
parent
71c58db50e
commit
2b2d83d0a6
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nodegui/nodegui",
|
||||
"version": "0.6.6",
|
||||
"version": "0.6.7",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nodegui/nodegui",
|
||||
"version": "0.6.6",
|
||||
"version": "0.6.7",
|
||||
"description": "A cross platform library to build native desktop apps.",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
|
||||
@ -21,6 +21,7 @@ class QMainWindowWrap : public Napi::ObjectWrap<QMainWindowWrap> {
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
Napi::Value setCentralWidget(const Napi::CallbackInfo& info);
|
||||
Napi::Value takeCentralWidget(const Napi::CallbackInfo& info);
|
||||
Napi::Value setMenuBar(const Napi::CallbackInfo& info);
|
||||
Napi::Value menuBar(const Napi::CallbackInfo& info);
|
||||
Napi::Value setMenuWidget(const Napi::CallbackInfo& info);
|
||||
|
||||
@ -14,12 +14,13 @@ Napi::Object QMainWindowWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
char CLASSNAME[] = "QMainWindow";
|
||||
Napi::Function func = DefineClass(
|
||||
env, CLASSNAME,
|
||||
{
|
||||
QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE(QMainWindowWrap) InstanceMethod(
|
||||
"setCentralWidget", &QMainWindowWrap::setCentralWidget),
|
||||
InstanceMethod("setMenuBar", &QMainWindowWrap::setMenuBar),
|
||||
InstanceMethod("setMenuWidget", &QMainWindowWrap::setMenuWidget),
|
||||
InstanceMethod("center", &QMainWindowWrap::center),
|
||||
{InstanceMethod("setCentralWidget", &QMainWindowWrap::setCentralWidget),
|
||||
InstanceMethod("takeCentralWidget", &QMainWindowWrap::takeCentralWidget),
|
||||
InstanceMethod("setMenuBar", &QMainWindowWrap::setMenuBar),
|
||||
InstanceMethod("setMenuWidget", &QMainWindowWrap::setMenuWidget),
|
||||
InstanceMethod("center", &QMainWindowWrap::center),
|
||||
QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE(QMainWindowWrap)
|
||||
|
||||
});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
@ -61,6 +62,14 @@ Napi::Value QMainWindowWrap::setCentralWidget(const Napi::CallbackInfo& info) {
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QMainWindowWrap::takeCentralWidget(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
this->instance->takeCentralWidget();
|
||||
// We will not return the value here since we are doing it in js side anyway
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QMainWindowWrap::setMenuBar(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
@ -10,7 +10,7 @@ export const QMainWindowEvents = Object.freeze({
|
||||
});
|
||||
export class QMainWindow extends NodeWidget {
|
||||
native: NativeElement;
|
||||
public centralWidget?: NodeWidget;
|
||||
public centralWidget?: NodeWidget | null;
|
||||
private _menuBar?: QMenuBar;
|
||||
constructor(parent?: NodeWidget) {
|
||||
let native;
|
||||
@ -38,6 +38,16 @@ export class QMainWindow extends NodeWidget {
|
||||
this.centralWidget = widget;
|
||||
this.centralWidget.setFlexNodeSizeControlled(true);
|
||||
}
|
||||
takeCentralWidget(): NodeWidget | null {
|
||||
// react:✓
|
||||
const centralWidget = this.centralWidget;
|
||||
this.centralWidget = null;
|
||||
if (centralWidget) {
|
||||
this.native.takeCentralWidget();
|
||||
return centralWidget;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
setMenuBar(menuBar: QMenuBar): void {
|
||||
this.native.setMenuBar(menuBar.native);
|
||||
this._menuBar = menuBar;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user