Merge pull request #176 from nodegui/feature/scroll-push
Adds few methods to scroll area and qlabel
This commit is contained in:
commit
ca1ef6540b
@ -21,6 +21,7 @@ class QLabelWrap : public Napi::ObjectWrap<QLabelWrap>{
|
||||
Napi::Value setText(const Napi::CallbackInfo& info);
|
||||
Napi::Value text(const Napi::CallbackInfo &info);
|
||||
Napi::Value setPixmap(const Napi::CallbackInfo &info);
|
||||
Napi::Value setOpenExternalLinks(const Napi::CallbackInfo &info);
|
||||
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
|
||||
|
||||
@ -18,6 +18,8 @@ class QScrollAreaWrap : public Napi::ObjectWrap<QScrollAreaWrap>{
|
||||
//wrapped methods
|
||||
Napi::Value setWidget(const Napi::CallbackInfo &info);
|
||||
Napi::Value takeWidget(const Napi::CallbackInfo &info);
|
||||
Napi::Value setWidgetResizable(const Napi::CallbackInfo &info);
|
||||
Napi::Value widgetResizable(const Napi::CallbackInfo &info);
|
||||
|
||||
QABSTRACTSCROLLAREA_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
@ -15,6 +15,7 @@ Napi::Object QLabelWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
InstanceMethod("setText", &QLabelWrap::setText),
|
||||
InstanceMethod("text", &QLabelWrap::text),
|
||||
InstanceMethod("setPixmap", &QLabelWrap::setPixmap),
|
||||
InstanceMethod("setOpenExternalLinks",&QLabelWrap::setOpenExternalLinks),
|
||||
QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE(QLabelWrap)
|
||||
});
|
||||
constructor = Napi::Persistent(func);
|
||||
@ -95,3 +96,11 @@ Napi::Value QLabelWrap::setPixmap(const Napi::CallbackInfo &info)
|
||||
this->instance->setPixmap(*pixmapWrap->getInternalInstance());
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QLabelWrap::setOpenExternalLinks(const Napi::CallbackInfo &info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
Napi::Boolean open = info[0].As<Napi::Boolean>();
|
||||
this->instance->setOpenExternalLinks(open.Value());
|
||||
return env.Null();
|
||||
}
|
||||
@ -9,6 +9,10 @@ Napi::Object QScrollAreaWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
char CLASSNAME[] = "QScrollArea";
|
||||
Napi::Function func = DefineClass(env, CLASSNAME, {
|
||||
InstanceMethod("setWidget", &QScrollAreaWrap::setWidget),
|
||||
InstanceMethod("takeWidget", &QScrollAreaWrap::takeWidget),
|
||||
InstanceMethod("setWidgetResizable", &QScrollAreaWrap::setWidgetResizable),
|
||||
InstanceMethod("widgetResizable", &QScrollAreaWrap::widgetResizable),
|
||||
|
||||
QABSTRACTSCROLLAREA_WRAPPED_METHODS_EXPORT_DEFINE(QScrollAreaWrap)
|
||||
});
|
||||
constructor = Napi::Persistent(func);
|
||||
@ -54,4 +58,20 @@ Napi::Value QScrollAreaWrap::takeWidget(const Napi::CallbackInfo& info) {
|
||||
this->instance->takeWidget();
|
||||
// We will not return the value here since we are doing it in js side anyway
|
||||
return env.Null();
|
||||
}
|
||||
}
|
||||
|
||||
Napi::Value QScrollAreaWrap::setWidgetResizable(const Napi::CallbackInfo &info){
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
Napi::Boolean resizable = info[0].As<Napi::Boolean>();
|
||||
this->instance->setWidgetResizable(resizable.Value());
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QScrollAreaWrap::widgetResizable(const Napi::CallbackInfo &info){
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
Napi::Boolean resizable = info[0].As<Napi::Boolean>();
|
||||
bool value = this->instance->widgetResizable();
|
||||
return Napi::Value::From(env, value);
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ import { QMainWindow } from "./index";
|
||||
import { QMenu } from "./lib/QtWidgets/QMenu";
|
||||
import path from "path";
|
||||
import { QIcon } from "./lib/QtGui/QIcon";
|
||||
import { QLabel } from "./lib/QtWidgets/QLabel";
|
||||
import { QSystemTrayIcon } from "./lib/QtWidgets/QSystemTrayIcon";
|
||||
import { QAction } from "./lib/QtWidgets/QAction";
|
||||
import { QApplication } from "./lib/QtGui/QApplication";
|
||||
@ -92,6 +93,11 @@ quitAction.addEventListener("triggered", () => {
|
||||
menu.addAction(quitAction);
|
||||
|
||||
menu.setTitle("TestMenu");
|
||||
const label = new QLabel();
|
||||
label.setOpenExternalLinks(true);
|
||||
label.setText(`<a href="https://www.google.com">Google</a>`);
|
||||
label.show();
|
||||
(global as any).label = label;
|
||||
win.setWindowTitle("NodeGUI Demo");
|
||||
win.resize(400, 700);
|
||||
win.show();
|
||||
|
||||
@ -40,4 +40,7 @@ export class QLabel extends NodeWidget {
|
||||
pixmap() {
|
||||
return this._pixmap;
|
||||
}
|
||||
setOpenExternalLinks(open: boolean) {
|
||||
this.native.setOpenExternalLinks(open);
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,4 +39,10 @@ export class QScrollArea extends QAbstractScrollArea {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
setWidgetResizable(resizable: boolean) {
|
||||
this.native.setWidgetResizable(resizable);
|
||||
}
|
||||
widgetResizable(): boolean {
|
||||
return this.native.widgetResizable();
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user