Merge pull request #55 from Uriziel01/feature/SetWindowTitle

Added setWindowTitle widget method with docs
This commit is contained in:
Atul R 2019-08-24 00:34:17 +02:00 committed by GitHub
commit 6d3e436070
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 0 deletions

View File

@ -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).

View File

@ -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<Napi::String>(); \
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), \

View File

@ -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);