Now all js widgets have access to all methods of nodewidget(qwidget)
This commit is contained in:
parent
36b6ddc19b
commit
82552a0fc8
2
demo.ts
2
demo.ts
@ -9,7 +9,6 @@ const view = new QWidget();
|
||||
win.setCentralWidget(view);
|
||||
|
||||
const gridLayout = new QGridLayout();
|
||||
|
||||
const label = new QLabel();
|
||||
label.setText("Testing1234");
|
||||
|
||||
@ -19,6 +18,7 @@ label2.setStyleSheet("background-color:blue; color:white;");
|
||||
|
||||
const button1 = new QPushButton();
|
||||
button1.setText("Yolo");
|
||||
|
||||
// button1.setEventListener("click", () => {
|
||||
// console.log("button clicked");
|
||||
// });
|
||||
|
||||
@ -2,18 +2,10 @@ import addon from "../../core/addon";
|
||||
import { QLayout } from "../../QtWidgets/QLayout";
|
||||
import { Component } from "../../core/Component";
|
||||
|
||||
export class QWidget extends Component {
|
||||
native: any;
|
||||
layout?: QLayout;
|
||||
constructor(parent?: QWidget) {
|
||||
super();
|
||||
if (parent) {
|
||||
this.native = new addon.QWidget(parent.native);
|
||||
this.parent = parent;
|
||||
} else {
|
||||
this.native = new addon.QWidget();
|
||||
}
|
||||
}
|
||||
// Implement all native QWidget methods here so that all widgets get access to those aswell
|
||||
export abstract class NodeWidget extends Component {
|
||||
abstract native: any;
|
||||
abstract layout?: QLayout;
|
||||
show() {
|
||||
this.native.show();
|
||||
}
|
||||
@ -31,3 +23,17 @@ export class QWidget extends Component {
|
||||
this.native.setStyleSheet(style);
|
||||
}
|
||||
}
|
||||
|
||||
export class QWidget extends NodeWidget {
|
||||
layout?: QLayout;
|
||||
native: any;
|
||||
constructor(parent?: QWidget) {
|
||||
super();
|
||||
if (parent) {
|
||||
this.native = new addon.QWidget(parent.native);
|
||||
this.parent = parent;
|
||||
} else {
|
||||
this.native = new addon.QWidget();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import addon from "../../core/addon";
|
||||
import { QWidget } from "../../QtGui/QWidget";
|
||||
import { NodeWidget } from "../../QtGui/QWidget";
|
||||
import { Component } from "../../core/Component";
|
||||
|
||||
export class QGridLayout extends Component {
|
||||
native: any;
|
||||
constructor(parent?: QWidget) {
|
||||
constructor(parent?: NodeWidget) {
|
||||
super();
|
||||
if (parent) {
|
||||
this.native = new addon.QGridLayout(parent.native);
|
||||
@ -13,7 +13,7 @@ export class QGridLayout extends Component {
|
||||
this.native = new addon.QGridLayout();
|
||||
}
|
||||
}
|
||||
addWidget(widget: Component) {
|
||||
addWidget(widget: NodeWidget) {
|
||||
this.native.addWidget(widget.native);
|
||||
this.children.add(widget);
|
||||
}
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
import addon from "../../core/addon";
|
||||
import { QWidget } from "../../QtGui/QWidget";
|
||||
import { Component } from "../../core/Component";
|
||||
import { NodeWidget } from "../../QtGui/QWidget";
|
||||
import { QLayout } from "../QLayout";
|
||||
|
||||
export class QLabel extends Component {
|
||||
export class QLabel extends NodeWidget {
|
||||
native: any;
|
||||
constructor(parent?: QWidget) {
|
||||
layout?: QLayout;
|
||||
constructor(parent?: NodeWidget) {
|
||||
super();
|
||||
if (parent) {
|
||||
this.native = new addon.QLabel(parent.native);
|
||||
@ -19,7 +20,4 @@ export class QLabel extends Component {
|
||||
setText(text: string) {
|
||||
this.native.setText(text);
|
||||
}
|
||||
setStyleSheet(style: string) {
|
||||
this.native.setStyleSheet(style);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import addon from "../../core/addon";
|
||||
import { QWidget } from "../../QtGui/QWidget";
|
||||
import { Component } from "../../core/Component";
|
||||
|
||||
export class QMainWindow extends Component {
|
||||
import { NodeWidget } from "../../QtGui/QWidget";
|
||||
import { QLayout } from "../QLayout";
|
||||
export class QMainWindow extends NodeWidget {
|
||||
layout?: QLayout;
|
||||
native: any;
|
||||
constructor(parent?: QWidget) {
|
||||
constructor(parent?: NodeWidget) {
|
||||
super();
|
||||
if (parent) {
|
||||
this.native = new addon.QMainWindow(parent.native);
|
||||
@ -13,19 +13,7 @@ export class QMainWindow extends Component {
|
||||
this.native = new addon.QMainWindow();
|
||||
}
|
||||
}
|
||||
setStyleSheet(style: string) {
|
||||
this.native.setStyleSheet(style);
|
||||
}
|
||||
show() {
|
||||
this.native.show();
|
||||
}
|
||||
resize(width: number, height: number) {
|
||||
this.native.resize(width, height);
|
||||
}
|
||||
close() {
|
||||
this.native.close();
|
||||
}
|
||||
setCentralWidget(widget: QWidget) {
|
||||
setCentralWidget(widget: NodeWidget) {
|
||||
this.native.setCentralWidget(widget.native);
|
||||
this.children.add(widget);
|
||||
}
|
||||
|
||||
@ -1,13 +1,10 @@
|
||||
import addon from "../../core/addon";
|
||||
import { QWidget } from "../../QtGui/QWidget";
|
||||
import { EventComponent } from "../../core/EventComponent";
|
||||
|
||||
export class QPushButton extends EventComponent {
|
||||
import { NodeWidget } from "../../QtGui/QWidget";
|
||||
import { QLayout } from "../QLayout";
|
||||
export class QPushButton extends NodeWidget {
|
||||
layout?: QLayout;
|
||||
native: any;
|
||||
setEventListener(event: string, callback: () => void): void {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
constructor(parent?: QWidget) {
|
||||
constructor(parent?: NodeWidget) {
|
||||
super();
|
||||
if (parent) {
|
||||
this.native = new addon.QPushButton(parent.native);
|
||||
@ -19,7 +16,4 @@ export class QPushButton extends EventComponent {
|
||||
setText(text: string) {
|
||||
this.native.setText(text);
|
||||
}
|
||||
setStyleSheet(style: string) {
|
||||
this.native.setStyleSheet(style);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user