From 9ee9dcd09a7309eef4535f0ae83782f3e62f586e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Borecki?= Date: Fri, 23 Aug 2019 23:55:34 +0200 Subject: [PATCH] Added setWindowTitle widget method with docs --- docs/api/NodeWidget.md | 6 ++++++ src/cpp/QtWidgets/QWidget/qwidget_macro.h | 9 +++++++++ src/lib/QtGui/QWidget/index.ts | 3 +++ 3 files changed, 18 insertions(+) diff --git a/docs/api/NodeWidget.md b/docs/api/NodeWidget.md index 7d0895b18..fc61f7d02 100644 --- a/docs/api/NodeWidget.md +++ b/docs/api/NodeWidget.md @@ -82,6 +82,12 @@ Sets the property that holds the widget's style sheet. It calls the native metho - `styleSheet` string - String which holds the widget's style sheet. Make sure you create this string using `StyleSheet.create()` +#### `widget.setWindowTitle(title)` + +Sets the window title property. It calls the native method [QWidget: setWindowTitle](https://doc.qt.io/qt-5/qwidget.html#windowTitle-prop). + +- `title` string - String which holds the windows title. + #### `widget.styleSheet()` Gets the property that holds the widget's style sheet. It calls the native method [QWidget: styleSheet](https://doc.qt.io/qt-5/qwidget.html#styleSheet-prop). diff --git a/src/cpp/QtWidgets/QWidget/qwidget_macro.h b/src/cpp/QtWidgets/QWidget/qwidget_macro.h index e993de2db..a2af0a199 100644 --- a/src/cpp/QtWidgets/QWidget/qwidget_macro.h +++ b/src/cpp/QtWidgets/QWidget/qwidget_macro.h @@ -57,6 +57,14 @@ Napi::Value setStyleSheet(const Napi::CallbackInfo& info){ \ this->instance->setStyleSheet(style.c_str()); \ return env.Null(); \ } \ +Napi::Value setWindowTitle(const Napi::CallbackInfo& info){ \ + Napi::Env env = info.Env(); \ + Napi::HandleScope scope(env); \ + Napi::String napiTitle = info[0].As(); \ + std::string title = napiTitle.Utf8Value(); \ + this->instance->setWindowTitle(title.c_str()); \ + return env.Null(); \ +} \ Napi::Value styleSheet(const Napi::CallbackInfo& info){ \ Napi::Env env = info.Env(); \ Napi::HandleScope scope(env); \ @@ -219,6 +227,7 @@ Napi::Value setWindowFlag(const Napi::CallbackInfo& info){ \ InstanceMethod("close",&WidgetWrapName::close), \ InstanceMethod("setLayout",&WidgetWrapName::setLayout), \ InstanceMethod("setStyleSheet",&WidgetWrapName::setStyleSheet), \ + InstanceMethod("setWindowTitle",&WidgetWrapName::setWindowTitle), \ InstanceMethod("styleSheet",&WidgetWrapName::styleSheet), \ InstanceMethod("hide",&WidgetWrapName::hide), \ InstanceMethod("move",&WidgetWrapName::move), \ diff --git a/src/lib/QtGui/QWidget/index.ts b/src/lib/QtGui/QWidget/index.ts index ad582039c..783071ddc 100644 --- a/src/lib/QtGui/QWidget/index.ts +++ b/src/lib/QtGui/QWidget/index.ts @@ -36,6 +36,9 @@ export abstract class NodeWidget extends EventWidget { const preparedSheet = await StyleSheet.create(styleSheet); await applyStyleSheet(this, preparedSheet); }; + setWindowTitle = async (title: string) => { + return this.native.setWindowTitle(title); + }; setInlineStyle = async (style: string) => { const preparedSheet = await prepareInlineStyleSheet(this, style); await applyStyleSheet(this, preparedSheet);