From ac0a5445659905b3c0746963a59d0fe23759d7b2 Mon Sep 17 00:00:00 2001 From: Atul R Date: Sun, 9 Jun 2019 08:46:01 +0200 Subject: [PATCH] Adds size methods to qmainwindow and setText accepts number --- src/cpp/QtWidgets/QMainWindow/qmainwindow_wrap.cpp | 9 +++++++++ src/cpp/QtWidgets/QMainWindow/qmainwindow_wrap.h | 1 + src/lib/QtWidgets/QLabel/index.ts | 4 ++-- src/lib/QtWidgets/QMainWindow/index.ts | 3 +++ src/lib/QtWidgets/QPushButton/index.ts | 4 ++-- 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/cpp/QtWidgets/QMainWindow/qmainwindow_wrap.cpp b/src/cpp/QtWidgets/QMainWindow/qmainwindow_wrap.cpp index 65e5a5a9f..90006b31c 100644 --- a/src/cpp/QtWidgets/QMainWindow/qmainwindow_wrap.cpp +++ b/src/cpp/QtWidgets/QMainWindow/qmainwindow_wrap.cpp @@ -11,6 +11,7 @@ Napi::Object QMainWindowWrap::init(Napi::Env env, Napi::Object exports) { QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE(QMainWindowWrap) YOGAWIDGET_WRAPPED_METHODS_EXPORT_DEFINE(QMainWindowWrap) InstanceMethod("setCentralWidget",&QMainWindowWrap::setCentralWidget), + InstanceMethod("setFixedSize",&QMainWindowWrap::setFixedSize), }); constructor = Napi::Persistent(func); exports.Set(CLASSNAME, func); @@ -53,5 +54,13 @@ Napi::Value QMainWindowWrap::setCentralWidget(const Napi::CallbackInfo& info){ return env.Null(); } +Napi::Value QMainWindowWrap::setFixedSize(const Napi::CallbackInfo& info){ + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + int width = info[0].As().Int32Value(); + int height = info[1].As().Int32Value(); + this->instance->setFixedSize(width, height); + return env.Null(); +} diff --git a/src/cpp/QtWidgets/QMainWindow/qmainwindow_wrap.h b/src/cpp/QtWidgets/QMainWindow/qmainwindow_wrap.h index be6c176a8..c7e003e8d 100644 --- a/src/cpp/QtWidgets/QMainWindow/qmainwindow_wrap.h +++ b/src/cpp/QtWidgets/QMainWindow/qmainwindow_wrap.h @@ -18,6 +18,7 @@ public: static Napi::FunctionReference constructor; //wrapped methods Napi::Value setCentralWidget(const Napi::CallbackInfo& info); + Napi::Value setFixedSize(const Napi::CallbackInfo& info); QWIDGET_WRAPPED_METHODS_DECLARATION YOGAWIDGET_WRAPPED_METHODS_DECLARATION diff --git a/src/lib/QtWidgets/QLabel/index.ts b/src/lib/QtWidgets/QLabel/index.ts index 5fa4e0f4e..570aa94a1 100644 --- a/src/lib/QtWidgets/QLabel/index.ts +++ b/src/lib/QtWidgets/QLabel/index.ts @@ -16,8 +16,8 @@ export class QLabel extends NodeWidget { setWordWrap(on: boolean) { this.native.setWordWrap(on); } - setText(text: string) { - this.native.setText(text); + setText(text: string | number) { + this.native.setText(`${text}`); } text() { return this.native.text(); diff --git a/src/lib/QtWidgets/QMainWindow/index.ts b/src/lib/QtWidgets/QMainWindow/index.ts index c2b6836a5..916ef9524 100644 --- a/src/lib/QtWidgets/QMainWindow/index.ts +++ b/src/lib/QtWidgets/QMainWindow/index.ts @@ -15,4 +15,7 @@ export class QMainWindow extends NodeWidget { this.native.setCentralWidget(widget.native); this.children.add(widget); } + setFixedSize(width: number, height: number) { + this.native.setFixedSize(width, height); + } } diff --git a/src/lib/QtWidgets/QPushButton/index.ts b/src/lib/QtWidgets/QPushButton/index.ts index 934711031..900089f32 100644 --- a/src/lib/QtWidgets/QPushButton/index.ts +++ b/src/lib/QtWidgets/QPushButton/index.ts @@ -23,7 +23,7 @@ export class QPushButton extends SignalNodeWidget { this.native = native; } - setText(text: string) { - this.native.setText(text); + setText(text: string | number) { + this.native.setText(`${text}`); } }