Fixes warnings in eslint (#179)
This commit is contained in:
parent
bd65329641
commit
f56bf965ee
51
.eslintrc.js
51
.eslintrc.js
@ -1,28 +1,29 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
extends: [
|
extends: [
|
||||||
"plugin:prettier/recommended" // Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
|
'plugin:prettier/recommended', // Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
|
||||||
],
|
],
|
||||||
parserOptions: {
|
parserOptions: {
|
||||||
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
|
|
||||||
sourceType: "module" // Allows for the use of imports
|
|
||||||
},
|
|
||||||
overrides: [
|
|
||||||
{
|
|
||||||
files: ["*.ts", "*.tsx"],
|
|
||||||
parser: "@typescript-eslint/parser", // Specifies the ESLint parser
|
|
||||||
extends: [
|
|
||||||
"plugin:@typescript-eslint/recommended", // Uses the recommended rules from the @typescript-eslint/eslint-plugin
|
|
||||||
"prettier/@typescript-eslint", // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
|
|
||||||
"plugin:prettier/recommended" // Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
|
|
||||||
],
|
|
||||||
parserOptions: {
|
|
||||||
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
|
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
|
||||||
sourceType: "module" // Allows for the use of imports
|
sourceType: 'module', // Allows for the use of imports
|
||||||
},
|
},
|
||||||
rules: {
|
overrides: [
|
||||||
"@typescript-eslint/camelcase": 0,
|
{
|
||||||
"@typescript-eslint/no-var-requires": 0
|
files: ['*.ts', '*.tsx'],
|
||||||
}
|
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
|
||||||
}
|
extends: [
|
||||||
]
|
'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin
|
||||||
|
'prettier/@typescript-eslint', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
|
||||||
|
'plugin:prettier/recommended', // Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
|
||||||
|
],
|
||||||
|
parserOptions: {
|
||||||
|
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
|
||||||
|
sourceType: 'module', // Allows for the use of imports
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
'@typescript-eslint/camelcase': 0,
|
||||||
|
'@typescript-eslint/no-var-requires': 0,
|
||||||
|
'@typescript-eslint/no-explicit-any': 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { EventWidget } from '../../core/EventWidget';
|
import { EventWidget } from '../../core/EventWidget';
|
||||||
|
|
||||||
export abstract class QObject extends EventWidget {
|
export abstract class QObject extends EventWidget {
|
||||||
inherits(className: string) {
|
inherits(className: string): boolean {
|
||||||
return this.native.inherits(className);
|
return this.native.inherits(className);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,29 +14,29 @@ export class QApplication extends Component {
|
|||||||
this.native = new addon.QApplication();
|
this.native = new addon.QApplication();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static clipboard = (): QClipboard => {
|
static clipboard(): QClipboard {
|
||||||
return new QClipboard(addon.QApplication.clipboard());
|
return new QClipboard(addon.QApplication.clipboard());
|
||||||
};
|
}
|
||||||
processEvents = () => {
|
processEvents(): void {
|
||||||
this.native.processEvents();
|
this.native.processEvents();
|
||||||
};
|
}
|
||||||
exec = (): number => {
|
exec(): number {
|
||||||
return this.native.exec();
|
return this.native.exec();
|
||||||
};
|
}
|
||||||
static instance = (): QApplication => {
|
static instance(): QApplication {
|
||||||
const nativeQApp = addon.QApplication.instance();
|
const nativeQApp = addon.QApplication.instance();
|
||||||
return new QApplication(nativeQApp);
|
return new QApplication(nativeQApp);
|
||||||
};
|
}
|
||||||
quit = () => {
|
quit(): number {
|
||||||
return this.native.quit();
|
return this.native.quit();
|
||||||
};
|
}
|
||||||
exit = (exitCode: number) => {
|
exit(exitCode: number): number {
|
||||||
return this.native.exit(exitCode);
|
return this.native.exit(exitCode);
|
||||||
};
|
}
|
||||||
setQuitOnLastWindowClosed = (quit: boolean) => {
|
setQuitOnLastWindowClosed(quit: boolean): void {
|
||||||
this.native.setQuitOnLastWindowClosed(quit);
|
this.native.setQuitOnLastWindowClosed(quit);
|
||||||
};
|
}
|
||||||
quitOnLastWindowClosed = () => {
|
quitOnLastWindowClosed(): boolean {
|
||||||
return this.native.quitOnLastWindowClosed();
|
return this.native.quitOnLastWindowClosed();
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,15 +11,15 @@ export class QClipboard extends Component {
|
|||||||
throw new Error('QClipboard cannot be initialised this way. Use QApplication::clipboard()');
|
throw new Error('QClipboard cannot be initialised this way. Use QApplication::clipboard()');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
clear = (mode: QClipboardMode) => {
|
clear(mode: QClipboardMode): void {
|
||||||
this.native.clear(mode);
|
this.native.clear(mode);
|
||||||
};
|
}
|
||||||
setText = (text: string, mode: QClipboardMode) => {
|
setText(text: string, mode: QClipboardMode): void {
|
||||||
this.native.setText(text, mode);
|
this.native.setText(text, mode);
|
||||||
};
|
}
|
||||||
text = (mode: QClipboardMode): string => {
|
text(mode: QClipboardMode): string {
|
||||||
return this.native.text(mode);
|
return this.native.text(mode);
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum QClipboardMode {
|
export enum QClipboardMode {
|
||||||
|
|||||||
@ -13,10 +13,10 @@ export class QCursor extends Component {
|
|||||||
this.native = new addon.QCursor();
|
this.native = new addon.QCursor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pos = (): { x: number; y: number } => {
|
pos(): { x: number; y: number } {
|
||||||
return this.native.pos();
|
return this.native.pos();
|
||||||
};
|
}
|
||||||
setPos = (x: number, y: number) => {
|
setPos(x: number, y: number): void {
|
||||||
return this.native.setPos(x, y);
|
return this.native.setPos(x, y);
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,7 +41,7 @@ export class QIcon extends Component {
|
|||||||
return this.native.isMask();
|
return this.native.isMask();
|
||||||
}
|
}
|
||||||
|
|
||||||
setIsMask(isMask: boolean) {
|
setIsMask(isMask: boolean): void {
|
||||||
this.native.setIsMask(isMask);
|
this.native.setIsMask(isMask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,14 +2,14 @@ import { NodeWidget, QWidget } from '../QWidget';
|
|||||||
|
|
||||||
export abstract class QAbstractScrollArea extends NodeWidget {
|
export abstract class QAbstractScrollArea extends NodeWidget {
|
||||||
viewportWidget?: NodeWidget;
|
viewportWidget?: NodeWidget;
|
||||||
setViewport = (widget: NodeWidget) => {
|
setViewport(widget: NodeWidget): void {
|
||||||
this.viewportWidget = widget;
|
this.viewportWidget = widget;
|
||||||
this.native.setViewport(widget.native);
|
this.native.setViewport(widget.native);
|
||||||
};
|
}
|
||||||
viewport = (): QWidget => {
|
viewport(): QWidget {
|
||||||
if (!this.viewportWidget) {
|
if (!this.viewportWidget) {
|
||||||
this.viewportWidget = new QWidget(this.native.viewport());
|
this.viewportWidget = new QWidget(this.native.viewport());
|
||||||
}
|
}
|
||||||
return this.viewportWidget;
|
return this.viewportWidget;
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,28 +2,28 @@ import { NodeWidget } from '../QWidget';
|
|||||||
import { Orientation } from '../../QtEnums';
|
import { Orientation } from '../../QtEnums';
|
||||||
|
|
||||||
export abstract class QAbstractSlider extends NodeWidget {
|
export abstract class QAbstractSlider extends NodeWidget {
|
||||||
setSingleStep = (step: number) => {
|
setSingleStep(step: number): void {
|
||||||
this.native.setSingleStep(step);
|
this.native.setSingleStep(step);
|
||||||
};
|
}
|
||||||
setMaximum(maximum: number) {
|
setMaximum(maximum: number): void {
|
||||||
this.native.setMaximum(maximum);
|
this.native.setMaximum(maximum);
|
||||||
}
|
}
|
||||||
maximum(): number {
|
maximum(): number {
|
||||||
return this.native.maximum();
|
return this.native.maximum();
|
||||||
}
|
}
|
||||||
setMinimum(minimum: number) {
|
setMinimum(minimum: number): void {
|
||||||
this.native.setMinimum(minimum);
|
this.native.setMinimum(minimum);
|
||||||
}
|
}
|
||||||
minimum(): number {
|
minimum(): number {
|
||||||
return this.native.minimum();
|
return this.native.minimum();
|
||||||
}
|
}
|
||||||
setValue(value: number) {
|
setValue(value: number): void {
|
||||||
this.native.setValue(value);
|
this.native.setValue(value);
|
||||||
}
|
}
|
||||||
value(): number {
|
value(): number {
|
||||||
return this.native.value();
|
return this.native.value();
|
||||||
}
|
}
|
||||||
setOrientation(orientation: Orientation) {
|
setOrientation(orientation: Orientation): void {
|
||||||
this.native.setOrientation(orientation);
|
this.native.setOrientation(orientation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,42 +27,42 @@ export class QAction extends QObject {
|
|||||||
super(native);
|
super(native);
|
||||||
this.native = native;
|
this.native = native;
|
||||||
}
|
}
|
||||||
setText(text: string) {
|
setText(text: string): void {
|
||||||
this.native.setText(text);
|
this.native.setText(text);
|
||||||
}
|
}
|
||||||
setEnabled(enabled: boolean) {
|
setEnabled(enabled: boolean): void {
|
||||||
this.native.setEnabled(enabled);
|
this.native.setEnabled(enabled);
|
||||||
}
|
}
|
||||||
setIcon(icon: QIcon) {
|
setIcon(icon: QIcon): void {
|
||||||
this.icon = icon;
|
this.icon = icon;
|
||||||
this.native.setIcon(icon.native);
|
this.native.setIcon(icon.native);
|
||||||
}
|
}
|
||||||
setMenu(menu: QMenu) {
|
setMenu(menu: QMenu): void {
|
||||||
this.menu = menu;
|
this.menu = menu;
|
||||||
this.native.setMenu(menu.native);
|
this.native.setMenu(menu.native);
|
||||||
}
|
}
|
||||||
setShortcut(keysequence: QKeySequence) {
|
setShortcut(keysequence: QKeySequence): void {
|
||||||
this.native.setShortcut(keysequence.native);
|
this.native.setShortcut(keysequence.native);
|
||||||
}
|
}
|
||||||
setShortcutContext(shortcutContext: ShortcutContext) {
|
setShortcutContext(shortcutContext: ShortcutContext): void {
|
||||||
this.native.setShortcutContext(shortcutContext);
|
this.native.setShortcutContext(shortcutContext);
|
||||||
}
|
}
|
||||||
isCheckable(): boolean {
|
isCheckable(): boolean {
|
||||||
return this.native.isCheckable();
|
return this.native.isCheckable();
|
||||||
}
|
}
|
||||||
setCheckable(isCheckable: boolean) {
|
setCheckable(isCheckable: boolean): void {
|
||||||
this.native.setCheckable(isCheckable);
|
this.native.setCheckable(isCheckable);
|
||||||
}
|
}
|
||||||
isChecked(): boolean {
|
isChecked(): boolean {
|
||||||
return this.native.isChecked();
|
return this.native.isChecked();
|
||||||
}
|
}
|
||||||
setChecked(isChecked: boolean) {
|
setChecked(isChecked: boolean): void {
|
||||||
this.native.setChecked(isChecked);
|
this.native.setChecked(isChecked);
|
||||||
}
|
}
|
||||||
isSeparator(): boolean {
|
isSeparator(): boolean {
|
||||||
return this.native.isSeparator();
|
return this.native.isSeparator();
|
||||||
}
|
}
|
||||||
setSeparator(isSeparator: boolean) {
|
setSeparator(isSeparator: boolean): void {
|
||||||
this.native.setSeparator(isSeparator);
|
this.native.setSeparator(isSeparator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,18 +19,14 @@ export class QCheckBox extends NodeWidget {
|
|||||||
super(native);
|
super(native);
|
||||||
this.native = native;
|
this.native = native;
|
||||||
this.nodeParent = parent;
|
this.nodeParent = parent;
|
||||||
// bind member functions
|
|
||||||
this.setText.bind(this);
|
|
||||||
this.setChecked.bind(this);
|
|
||||||
this.isChecked.bind(this);
|
|
||||||
}
|
}
|
||||||
setText(text: string) {
|
setText(text: string): void {
|
||||||
// react:✓ //TODO:getter
|
// react:✓ //TODO:getter
|
||||||
this.native.setText(text);
|
this.native.setText(text);
|
||||||
}
|
}
|
||||||
setChecked(check: boolean) {
|
setChecked(check: boolean): void {
|
||||||
// react:✓
|
// react:✓
|
||||||
return this.native.setChecked(check);
|
this.native.setChecked(check);
|
||||||
}
|
}
|
||||||
isChecked(): boolean {
|
isChecked(): boolean {
|
||||||
// react:✓
|
// react:✓
|
||||||
|
|||||||
@ -24,15 +24,8 @@ export class QDial extends QAbstractSlider {
|
|||||||
super(native);
|
super(native);
|
||||||
this.native = native;
|
this.native = native;
|
||||||
this.nodeParent = parent;
|
this.nodeParent = parent;
|
||||||
// bind member functions
|
|
||||||
this.setNotchesVisible.bind(this);
|
|
||||||
this.notchesVisible.bind(this);
|
|
||||||
this.setWrapping.bind(this);
|
|
||||||
this.wrapping.bind(this);
|
|
||||||
this.setNotchTarget.bind(this);
|
|
||||||
this.notchTarget.bind(this);
|
|
||||||
}
|
}
|
||||||
setNotchesVisible(visible: boolean) {
|
setNotchesVisible(visible: boolean): void {
|
||||||
// react:✓
|
// react:✓
|
||||||
this.native.setNotchesVisible(visible);
|
this.native.setNotchesVisible(visible);
|
||||||
}
|
}
|
||||||
@ -40,7 +33,7 @@ export class QDial extends QAbstractSlider {
|
|||||||
// react:✓
|
// react:✓
|
||||||
return this.native.notchesVisible();
|
return this.native.notchesVisible();
|
||||||
}
|
}
|
||||||
setWrapping(on: boolean) {
|
setWrapping(on: boolean): void {
|
||||||
// react:✓
|
// react:✓
|
||||||
this.native.setWrapping(on);
|
this.native.setWrapping(on);
|
||||||
}
|
}
|
||||||
@ -48,7 +41,7 @@ export class QDial extends QAbstractSlider {
|
|||||||
// react:✓
|
// react:✓
|
||||||
return this.native.wrapping();
|
return this.native.wrapping();
|
||||||
}
|
}
|
||||||
setNotchTarget(target: number) {
|
setNotchTarget(target: number): void {
|
||||||
// react:✓
|
// react:✓
|
||||||
this.native.setNotchTarget(target);
|
this.native.setNotchTarget(target);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,12 +14,12 @@ export class QGridLayout extends NodeLayout {
|
|||||||
this.native = new addon.QGridLayout();
|
this.native = new addon.QGridLayout();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addWidget = (widget: NodeWidget) => {
|
addWidget(widget: NodeWidget): void {
|
||||||
this.native.addWidget(widget.native);
|
this.native.addWidget(widget.native);
|
||||||
this.nodeChildren.add(widget);
|
this.nodeChildren.add(widget);
|
||||||
};
|
}
|
||||||
removeWidget = (widget: NodeWidget) => {
|
removeWidget(widget: NodeWidget): void {
|
||||||
this.native.removeWidget(widget.native);
|
this.native.removeWidget(widget.native);
|
||||||
this.nodeChildren.delete(widget);
|
this.nodeChildren.delete(widget);
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,26 +21,26 @@ export class QLabel extends NodeWidget {
|
|||||||
this.native = native;
|
this.native = native;
|
||||||
this.nodeParent = parent;
|
this.nodeParent = parent;
|
||||||
}
|
}
|
||||||
setWordWrap(on: boolean) {
|
setWordWrap(on: boolean): void {
|
||||||
this.native.setWordWrap(on);
|
this.native.setWordWrap(on);
|
||||||
}
|
}
|
||||||
wordWrap(): boolean {
|
wordWrap(): boolean {
|
||||||
return this.native.wordWrap();
|
return this.native.wordWrap();
|
||||||
}
|
}
|
||||||
setText(text: string | number) {
|
setText(text: string | number): void {
|
||||||
this.native.setText(`${text}`);
|
this.native.setText(`${text}`);
|
||||||
}
|
}
|
||||||
text() {
|
text(): string {
|
||||||
return this.native.text();
|
return this.native.text();
|
||||||
}
|
}
|
||||||
setPixmap(pixMap: QPixmap) {
|
setPixmap(pixMap: QPixmap): void {
|
||||||
this.native.setPixmap(pixMap.native);
|
this.native.setPixmap(pixMap.native);
|
||||||
this._pixmap = pixMap;
|
this._pixmap = pixMap;
|
||||||
}
|
}
|
||||||
pixmap() {
|
pixmap(): QPixmap | undefined {
|
||||||
return this._pixmap;
|
return this._pixmap;
|
||||||
}
|
}
|
||||||
setOpenExternalLinks(open: boolean) {
|
setOpenExternalLinks(open: boolean): void {
|
||||||
this.native.setOpenExternalLinks(open);
|
this.native.setOpenExternalLinks(open);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,16 +4,16 @@ import { NodeWidget } from '../QWidget';
|
|||||||
// All Layouts should extend this abstract class.
|
// All Layouts should extend this abstract class.
|
||||||
export abstract class NodeLayout extends Component {
|
export abstract class NodeLayout extends Component {
|
||||||
type = 'layout';
|
type = 'layout';
|
||||||
abstract addWidget: (childWidget: NodeWidget, ...args: any[]) => void;
|
abstract addWidget(childWidget: NodeWidget, ...args: any[]): void;
|
||||||
activate = (): boolean => {
|
activate = (): boolean => {
|
||||||
return this.native.activate();
|
return this.native.activate();
|
||||||
};
|
};
|
||||||
invalidate = () => {
|
invalidate(): void {
|
||||||
this.native.invalidate();
|
this.native.invalidate();
|
||||||
};
|
}
|
||||||
update = () => {
|
update(): void {
|
||||||
this.native.update();
|
this.native.update();
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// export class QLayout extends NodeLayout { //Dont need QLayout for now
|
// export class QLayout extends NodeLayout { //Dont need QLayout for now
|
||||||
|
|||||||
@ -26,14 +26,8 @@ export class QLineEdit extends NodeWidget {
|
|||||||
super(native);
|
super(native);
|
||||||
this.native = native;
|
this.native = native;
|
||||||
this.nodeParent = parent;
|
this.nodeParent = parent;
|
||||||
// bind member functions
|
|
||||||
this.setText.bind(this);
|
|
||||||
this.text.bind(this);
|
|
||||||
this.setPlaceholderText.bind(this);
|
|
||||||
this.setReadOnly.bind(this);
|
|
||||||
this.clear.bind(this);
|
|
||||||
}
|
}
|
||||||
setText(text: string) {
|
setText(text: string): void {
|
||||||
// react:✓
|
// react:✓
|
||||||
text && this.native.setText(text);
|
text && this.native.setText(text);
|
||||||
}
|
}
|
||||||
@ -41,16 +35,16 @@ export class QLineEdit extends NodeWidget {
|
|||||||
// react:✓
|
// react:✓
|
||||||
return this.native.text();
|
return this.native.text();
|
||||||
}
|
}
|
||||||
setPlaceholderText(text: string) {
|
setPlaceholderText(text: string): void {
|
||||||
// react:✓ TODO://getter
|
// react:✓ TODO://getter
|
||||||
this.placeholderText = text;
|
this.placeholderText = text;
|
||||||
this.native.setPlaceholderText(text);
|
this.native.setPlaceholderText(text);
|
||||||
}
|
}
|
||||||
setReadOnly(isReadOnly: boolean) {
|
setReadOnly(isReadOnly: boolean): void {
|
||||||
// react:✓ TODO://getter
|
// react:✓ TODO://getter
|
||||||
this.native.setReadOnly(isReadOnly);
|
this.native.setReadOnly(isReadOnly);
|
||||||
}
|
}
|
||||||
clear() {
|
clear(): void {
|
||||||
// react:✓
|
// react:✓
|
||||||
this.native.clear();
|
this.native.clear();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,7 +12,6 @@ export class QMainWindow extends NodeWidget {
|
|||||||
native: NativeElement;
|
native: NativeElement;
|
||||||
public centralWidget?: NodeWidget;
|
public centralWidget?: NodeWidget;
|
||||||
private _menuBar?: QMenuBar;
|
private _menuBar?: QMenuBar;
|
||||||
private _menuBarWidget?: NodeWidget;
|
|
||||||
constructor(parent?: NodeWidget) {
|
constructor(parent?: NodeWidget) {
|
||||||
let native;
|
let native;
|
||||||
if (parent) {
|
if (parent) {
|
||||||
@ -25,7 +24,7 @@ export class QMainWindow extends NodeWidget {
|
|||||||
this.nodeParent = parent;
|
this.nodeParent = parent;
|
||||||
// bind member functions
|
// bind member functions
|
||||||
this.setCentralWidget.bind(this);
|
this.setCentralWidget.bind(this);
|
||||||
this.setLayout = (parentLayout: NodeLayout) => {
|
this.setLayout = (parentLayout: NodeLayout): void => {
|
||||||
if (this.centralWidget) {
|
if (this.centralWidget) {
|
||||||
this.centralWidget.setLayout(parentLayout);
|
this.centralWidget.setLayout(parentLayout);
|
||||||
} else {
|
} else {
|
||||||
@ -34,29 +33,29 @@ export class QMainWindow extends NodeWidget {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
setCentralWidget(widget: NodeWidget) {
|
setCentralWidget(widget: NodeWidget): void {
|
||||||
// react:✓
|
// react:✓
|
||||||
this.native.setCentralWidget(widget.native, widget.getFlexNode());
|
this.native.setCentralWidget(widget.native, widget.getFlexNode());
|
||||||
this.centralWidget = widget;
|
this.centralWidget = widget;
|
||||||
}
|
}
|
||||||
setMenuBar(menuBar: QMenuBar) {
|
setMenuBar(menuBar: QMenuBar): void {
|
||||||
this.native.setMenuBar(menuBar.native);
|
this.native.setMenuBar(menuBar.native);
|
||||||
this._menuBar = menuBar;
|
this._menuBar = menuBar;
|
||||||
}
|
}
|
||||||
menuBar(): QMenuBar | undefined {
|
menuBar(): QMenuBar | undefined {
|
||||||
return this._menuBar;
|
return this._menuBar;
|
||||||
}
|
}
|
||||||
setMenuWidget(menuWidget: NodeWidget) {
|
setMenuWidget(menuWidget: NodeWidget): void {
|
||||||
this.native.setMenuWidget(menuWidget.native);
|
this.native.setMenuWidget(menuWidget.native);
|
||||||
}
|
}
|
||||||
get layout() {
|
get layout(): NodeLayout | undefined {
|
||||||
if (this.centralWidget) {
|
if (this.centralWidget) {
|
||||||
return this.centralWidget.layout;
|
return this.centralWidget.layout;
|
||||||
} else {
|
} else {
|
||||||
return super.layout;
|
return super.layout;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
center() {
|
center(): void {
|
||||||
this.native.center();
|
this.native.center();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,7 +22,7 @@ export class QMenu extends NodeWidget {
|
|||||||
this.nodeParent = parent;
|
this.nodeParent = parent;
|
||||||
this.actions = new Set();
|
this.actions = new Set();
|
||||||
}
|
}
|
||||||
setTitle(title: string) {
|
setTitle(title: string): void {
|
||||||
this.native.setTitle(title);
|
this.native.setTitle(title);
|
||||||
}
|
}
|
||||||
addAction(action: QAction): QAction {
|
addAction(action: QAction): QAction {
|
||||||
|
|||||||
@ -29,10 +29,10 @@ export class QMenuBar extends NodeWidget {
|
|||||||
this.nodeParent = parent;
|
this.nodeParent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
addMenu(menu: QMenu) {
|
addMenu(menu: QMenu): void {
|
||||||
this.native.addMenu(menu.native);
|
this.native.addMenu(menu.native);
|
||||||
}
|
}
|
||||||
setNativeMenuBar(nativeMenuBar: boolean) {
|
setNativeMenuBar(nativeMenuBar: boolean): void {
|
||||||
this.native.setNativeMenuBar(nativeMenuBar);
|
this.native.setNativeMenuBar(nativeMenuBar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,22 +34,12 @@ export class QPlainTextEdit extends QAbstractScrollArea {
|
|||||||
super(native);
|
super(native);
|
||||||
this.native = native;
|
this.native = native;
|
||||||
this.nodeParent = parent;
|
this.nodeParent = parent;
|
||||||
// bind member functions
|
|
||||||
this.setPlainText.bind(this);
|
|
||||||
this.setPlaceholderText.bind(this);
|
|
||||||
this.toPlainText.bind(this);
|
|
||||||
this.setReadOnly.bind(this);
|
|
||||||
this.clear.bind(this);
|
|
||||||
this.setWordWrapMode.bind(this);
|
|
||||||
this.wordWrapMode.bind(this);
|
|
||||||
this.setLineWrapMode.bind(this);
|
|
||||||
this.lineWrapMode.bind(this);
|
|
||||||
}
|
}
|
||||||
setPlainText(text: string | number) {
|
setPlainText(text: string | number): void {
|
||||||
// react:✓
|
// react:✓
|
||||||
this.native.setPlainText(`${text}`);
|
this.native.setPlainText(`${text}`);
|
||||||
}
|
}
|
||||||
setPlaceholderText(text: string) {
|
setPlaceholderText(text: string): void {
|
||||||
// react:✓, //TODO:getter
|
// react:✓, //TODO:getter
|
||||||
this.placeholderText = text;
|
this.placeholderText = text;
|
||||||
this.native.setPlaceholderText(text);
|
this.native.setPlaceholderText(text);
|
||||||
@ -58,21 +48,21 @@ export class QPlainTextEdit extends QAbstractScrollArea {
|
|||||||
// react:✓
|
// react:✓
|
||||||
return this.native.toPlainText();
|
return this.native.toPlainText();
|
||||||
}
|
}
|
||||||
setReadOnly(isReadOnly: boolean) {
|
setReadOnly(isReadOnly: boolean): void {
|
||||||
// react:✓
|
// react:✓
|
||||||
this.native.setReadOnly(isReadOnly);
|
this.native.setReadOnly(isReadOnly);
|
||||||
}
|
}
|
||||||
clear() {
|
clear(): void {
|
||||||
// react:✓
|
// react:✓
|
||||||
this.native.clear();
|
this.native.clear();
|
||||||
}
|
}
|
||||||
setWordWrapMode(mode: QTextOptionWrapMode) {
|
setWordWrapMode(mode: QTextOptionWrapMode): void {
|
||||||
this.native.setWordWrapMode(mode);
|
this.native.setWordWrapMode(mode);
|
||||||
}
|
}
|
||||||
wordWrapMode(): QTextOptionWrapMode {
|
wordWrapMode(): QTextOptionWrapMode {
|
||||||
return this.native.wordWrapMode();
|
return this.native.wordWrapMode();
|
||||||
}
|
}
|
||||||
setLineWrapMode(mode: LineWrapMode) {
|
setLineWrapMode(mode: LineWrapMode): void {
|
||||||
this.native.setLineWrapMode(mode);
|
this.native.setLineWrapMode(mode);
|
||||||
}
|
}
|
||||||
lineWrapMode(): LineWrapMode {
|
lineWrapMode(): LineWrapMode {
|
||||||
|
|||||||
@ -19,14 +19,8 @@ export class QProgressBar extends NodeWidget {
|
|||||||
super(native);
|
super(native);
|
||||||
this.native = native;
|
this.native = native;
|
||||||
this.nodeParent = parent;
|
this.nodeParent = parent;
|
||||||
// bind member functions
|
|
||||||
this.setValue.bind(this);
|
|
||||||
this.setMinimum.bind(this);
|
|
||||||
this.setMaximum.bind(this);
|
|
||||||
this.setOrientation.bind(this);
|
|
||||||
this.value.bind(this);
|
|
||||||
}
|
}
|
||||||
setValue(value: number) {
|
setValue(value: number): void {
|
||||||
// react:✓
|
// react:✓
|
||||||
this.native.setValue(value);
|
this.native.setValue(value);
|
||||||
}
|
}
|
||||||
@ -34,15 +28,15 @@ export class QProgressBar extends NodeWidget {
|
|||||||
// react:✓
|
// react:✓
|
||||||
return this.native.value();
|
return this.native.value();
|
||||||
}
|
}
|
||||||
setMinimum(min: number) {
|
setMinimum(min: number): void {
|
||||||
// react:✓ TODO://getter
|
// react:✓ TODO://getter
|
||||||
this.native.setMinimum(min);
|
this.native.setMinimum(min);
|
||||||
}
|
}
|
||||||
setMaximum(max: number) {
|
setMaximum(max: number): void {
|
||||||
// react:✓ TODO://getter
|
// react:✓ TODO://getter
|
||||||
this.native.setMaximum(max);
|
this.native.setMaximum(max);
|
||||||
}
|
}
|
||||||
setOrientation(orientation: Orientation) {
|
setOrientation(orientation: Orientation): void {
|
||||||
// react:✓ TODO://getter
|
// react:✓ TODO://getter
|
||||||
this.native.setOrientation(orientation);
|
this.native.setOrientation(orientation);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,19 +24,16 @@ export class QPushButton extends NodeWidget {
|
|||||||
super(native);
|
super(native);
|
||||||
this.nodeParent = parent;
|
this.nodeParent = parent;
|
||||||
this.native = native;
|
this.native = native;
|
||||||
// bind member functions
|
|
||||||
this.setText.bind(this);
|
|
||||||
this.setFlat.bind(this);
|
|
||||||
}
|
}
|
||||||
setText(text: string | number) {
|
setText(text: string | number): void {
|
||||||
// react:✓, //TODO:getter
|
// react:✓, //TODO:getter
|
||||||
this.native.setText(`${text}`);
|
this.native.setText(`${text}`);
|
||||||
}
|
}
|
||||||
setFlat(isFlat: boolean) {
|
setFlat(isFlat: boolean): void {
|
||||||
// react:✓, //TODO:getter
|
// react:✓, //TODO:getter
|
||||||
this.native.setFlat(isFlat);
|
this.native.setFlat(isFlat);
|
||||||
}
|
}
|
||||||
setIcon(icon: QIcon) {
|
setIcon(icon: QIcon): void {
|
||||||
// react:✓, //TODO:getter
|
// react:✓, //TODO:getter
|
||||||
this.native.setIcon(icon.native);
|
this.native.setIcon(icon.native);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,7 +21,7 @@ export class QRadioButton extends NodeWidget {
|
|||||||
// bind member functions
|
// bind member functions
|
||||||
this.setText.bind(this);
|
this.setText.bind(this);
|
||||||
}
|
}
|
||||||
setText(text: string | number) {
|
setText(text: string | number): void {
|
||||||
// react:✓ TODO://getter
|
// react:✓ TODO://getter
|
||||||
this.native.setText(`${text}`);
|
this.native.setText(`${text}`);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,11 +20,8 @@ export class QScrollArea extends QAbstractScrollArea {
|
|||||||
super(native);
|
super(native);
|
||||||
this.native = native;
|
this.native = native;
|
||||||
this.nodeParent = parent;
|
this.nodeParent = parent;
|
||||||
// bind member functions
|
|
||||||
this.setWidget.bind(this);
|
|
||||||
this.takeWidget.bind(this);
|
|
||||||
}
|
}
|
||||||
setWidget(widget: NodeWidget) {
|
setWidget(widget: NodeWidget): void {
|
||||||
// react:✓, //TODO:getter
|
// react:✓, //TODO:getter
|
||||||
this.contentWidget = widget;
|
this.contentWidget = widget;
|
||||||
this.native.setWidget(widget.native);
|
this.native.setWidget(widget.native);
|
||||||
@ -39,7 +36,7 @@ export class QScrollArea extends QAbstractScrollArea {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
setWidgetResizable(resizable: boolean) {
|
setWidgetResizable(resizable: boolean): void {
|
||||||
this.native.setWidgetResizable(resizable);
|
this.native.setWidgetResizable(resizable);
|
||||||
}
|
}
|
||||||
widgetResizable(): boolean {
|
widgetResizable(): boolean {
|
||||||
|
|||||||
@ -17,16 +17,16 @@ export class QShortcut extends QObject {
|
|||||||
super(native);
|
super(native);
|
||||||
this.native = native;
|
this.native = native;
|
||||||
}
|
}
|
||||||
setEnabled(enabled: boolean) {
|
setEnabled(enabled: boolean): void {
|
||||||
this.native.setEnabled(enabled);
|
this.native.setEnabled(enabled);
|
||||||
}
|
}
|
||||||
setAutoRepeat(on: boolean) {
|
setAutoRepeat(on: boolean): void {
|
||||||
this.native.setAutoRepeat(on);
|
this.native.setAutoRepeat(on);
|
||||||
}
|
}
|
||||||
setKey(keysequence: QKeySequence) {
|
setKey(keysequence: QKeySequence): void {
|
||||||
this.native.setKey(keysequence.native);
|
this.native.setKey(keysequence.native);
|
||||||
}
|
}
|
||||||
setContext(shortcutContext: ShortcutContext) {
|
setContext(shortcutContext: ShortcutContext): void {
|
||||||
this.native.setContext(shortcutContext);
|
this.native.setContext(shortcutContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,6 @@ import addon from '../../utils/addon';
|
|||||||
import { NodeWidget } from '../QWidget';
|
import { NodeWidget } from '../QWidget';
|
||||||
import { BaseWidgetEvents } from '../../core/EventWidget';
|
import { BaseWidgetEvents } from '../../core/EventWidget';
|
||||||
import { NativeElement } from '../../core/Component';
|
import { NativeElement } from '../../core/Component';
|
||||||
import { QIcon } from '../../QtGui/QIcon';
|
|
||||||
|
|
||||||
export const QSpinBoxEvents = Object.freeze({
|
export const QSpinBoxEvents = Object.freeze({
|
||||||
...BaseWidgetEvents,
|
...BaseWidgetEvents,
|
||||||
@ -21,22 +20,12 @@ export class QSpinBox extends NodeWidget {
|
|||||||
super(native);
|
super(native);
|
||||||
this.nodeParent = parent;
|
this.nodeParent = parent;
|
||||||
this.native = native;
|
this.native = native;
|
||||||
// bind member functions
|
|
||||||
this.setPrefix.bind(this);
|
|
||||||
this.setSuffix.bind(this);
|
|
||||||
this.cleanText.bind(this);
|
|
||||||
this.setSingleStep.bind(this);
|
|
||||||
this.setRange.bind(this);
|
|
||||||
this.maximum.bind(this);
|
|
||||||
this.minimum.bind(this);
|
|
||||||
this.setValue.bind(this);
|
|
||||||
this.value.bind(this);
|
|
||||||
}
|
}
|
||||||
setPrefix(prefix: string) {
|
setPrefix(prefix: string): void {
|
||||||
// react:✓
|
// react:✓
|
||||||
this.native.setPrefix(prefix);
|
this.native.setPrefix(prefix);
|
||||||
}
|
}
|
||||||
setSuffix(suffix: string) {
|
setSuffix(suffix: string): void {
|
||||||
// react:✓
|
// react:✓
|
||||||
this.native.setSuffix(suffix);
|
this.native.setSuffix(suffix);
|
||||||
}
|
}
|
||||||
@ -44,11 +33,11 @@ export class QSpinBox extends NodeWidget {
|
|||||||
// react:✓
|
// react:✓
|
||||||
return this.native.cleanText();
|
return this.native.cleanText();
|
||||||
}
|
}
|
||||||
setSingleStep(val: number) {
|
setSingleStep(val: number): void {
|
||||||
// react:✓
|
// react:✓
|
||||||
this.native.setSingleStep(val);
|
this.native.setSingleStep(val);
|
||||||
}
|
}
|
||||||
setRange(minimum: number, maximum: number) {
|
setRange(minimum: number, maximum: number): void {
|
||||||
// react:✓
|
// react:✓
|
||||||
this.native.setRange(minimum, maximum);
|
this.native.setRange(minimum, maximum);
|
||||||
}
|
}
|
||||||
@ -60,7 +49,7 @@ export class QSpinBox extends NodeWidget {
|
|||||||
// react:✓
|
// react:✓
|
||||||
return this.native.minimum();
|
return this.native.minimum();
|
||||||
}
|
}
|
||||||
setValue(val: number) {
|
setValue(val: number): void {
|
||||||
// react:✓
|
// react:✓
|
||||||
this.native.setValue(val);
|
this.native.setValue(val);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,22 +22,22 @@ export class QSystemTrayIcon extends QObject {
|
|||||||
super(native);
|
super(native);
|
||||||
this.native = native;
|
this.native = native;
|
||||||
}
|
}
|
||||||
show() {
|
show(): void {
|
||||||
this.native.show();
|
this.native.show();
|
||||||
}
|
}
|
||||||
hide() {
|
hide(): void {
|
||||||
this.native.hide();
|
this.native.hide();
|
||||||
}
|
}
|
||||||
setIcon(icon: QIcon) {
|
setIcon(icon: QIcon): void {
|
||||||
this.native.setIcon(icon.native);
|
this.native.setIcon(icon.native);
|
||||||
}
|
}
|
||||||
isVisible(): boolean {
|
isVisible(): boolean {
|
||||||
return this.native.isVisible();
|
return this.native.isVisible();
|
||||||
}
|
}
|
||||||
setToolTip(tooltip: string) {
|
setToolTip(tooltip: string): void {
|
||||||
this.native.setToolTip(tooltip);
|
this.native.setToolTip(tooltip);
|
||||||
}
|
}
|
||||||
setContextMenu(menu: QMenu) {
|
setContextMenu(menu: QMenu): void {
|
||||||
this.contextMenu = menu;
|
this.contextMenu = menu;
|
||||||
this.native.setContextMenu(this.contextMenu.native);
|
this.native.setContextMenu(this.contextMenu.native);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,16 +29,16 @@ export class QTabWidget extends NodeWidget {
|
|||||||
this.addTab.bind(this);
|
this.addTab.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
addTab(page: NodeWidget, icon: QIcon, label: string) {
|
addTab(page: NodeWidget, icon: QIcon, label: string): void {
|
||||||
this.nodeChildren.add(page);
|
this.nodeChildren.add(page);
|
||||||
this.native.addTab(page.native, icon.native, label);
|
this.native.addTab(page.native, icon.native, label);
|
||||||
}
|
}
|
||||||
|
|
||||||
setTabPosition(tabPosition: TabPosition) {
|
setTabPosition(tabPosition: TabPosition): void {
|
||||||
this.native.setTabPosition(tabPosition);
|
this.native.setTabPosition(tabPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
setCurrentIndex(index: number) {
|
setCurrentIndex(index: number): void {
|
||||||
this.native.setCurrentIndex(index);
|
this.native.setCurrentIndex(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,11 +46,11 @@ export class QTabWidget extends NodeWidget {
|
|||||||
return this.native.currentIndex();
|
return this.native.currentIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
removeTab(index: number) {
|
removeTab(index: number): void {
|
||||||
this.native.removeTab(index);
|
this.native.removeTab(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
setTabsClosable(closeable: boolean) {
|
setTabsClosable(closeable: boolean): void {
|
||||||
this.native.setTabsClosable(closeable);
|
this.native.setTabsClosable(closeable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,109 +15,109 @@ import { YogaWidget } from '../../core/YogaWidget';
|
|||||||
export abstract class NodeWidget extends YogaWidget {
|
export abstract class NodeWidget extends YogaWidget {
|
||||||
layout?: NodeLayout;
|
layout?: NodeLayout;
|
||||||
type = 'widget';
|
type = 'widget';
|
||||||
show() {
|
show(): void {
|
||||||
this.native.show();
|
this.native.show();
|
||||||
}
|
}
|
||||||
hide() {
|
hide(): void {
|
||||||
this.native.hide();
|
this.native.hide();
|
||||||
}
|
}
|
||||||
isVisible(): boolean {
|
isVisible(): boolean {
|
||||||
return this.native.isVisible();
|
return this.native.isVisible();
|
||||||
}
|
}
|
||||||
close() {
|
close(): boolean {
|
||||||
return this.native.close();
|
return this.native.close();
|
||||||
}
|
}
|
||||||
async setStyleSheet(styleSheet: string) {
|
async setStyleSheet(styleSheet: string): Promise<void> {
|
||||||
const preparedSheet = await StyleSheet.create(styleSheet);
|
const preparedSheet = await StyleSheet.create(styleSheet);
|
||||||
await applyStyleSheet(this, preparedSheet);
|
await applyStyleSheet(this, preparedSheet);
|
||||||
}
|
}
|
||||||
styleSheet(): string {
|
styleSheet(): string {
|
||||||
return this.native.styleSheet();
|
return this.native.styleSheet();
|
||||||
}
|
}
|
||||||
async setInlineStyle(style: string) {
|
async setInlineStyle(style: string): Promise<void> {
|
||||||
const preparedSheet = await prepareInlineStyleSheet(this, style);
|
const preparedSheet = await prepareInlineStyleSheet(this, style);
|
||||||
await applyStyleSheet(this, preparedSheet);
|
await applyStyleSheet(this, preparedSheet);
|
||||||
}
|
}
|
||||||
setGeometry(x: number, y: number, w: number, h: number) {
|
setGeometry(x: number, y: number, w: number, h: number): void {
|
||||||
this.native.setGeometry(x, y, w, h);
|
this.native.setGeometry(x, y, w, h);
|
||||||
}
|
}
|
||||||
geometry(): Rect {
|
geometry(): Rect {
|
||||||
return this.native.geometry();
|
return this.native.geometry();
|
||||||
}
|
}
|
||||||
setObjectName(objectName: string) {
|
setObjectName(objectName: string): void {
|
||||||
this.native.setObjectName(objectName);
|
this.native.setObjectName(objectName);
|
||||||
}
|
}
|
||||||
objectName(): string {
|
objectName(): string {
|
||||||
return this.native.objectName();
|
return this.native.objectName();
|
||||||
}
|
}
|
||||||
setMouseTracking(isMouseTracked: boolean) {
|
setMouseTracking(isMouseTracked: boolean): void {
|
||||||
this.native.setMouseTracking(isMouseTracked);
|
this.native.setMouseTracking(isMouseTracked);
|
||||||
}
|
}
|
||||||
hasMouseTracking(): boolean {
|
hasMouseTracking(): boolean {
|
||||||
return this.native.hasMouseTracking();
|
return this.native.hasMouseTracking();
|
||||||
}
|
}
|
||||||
setEnabled(enabled: boolean) {
|
setEnabled(enabled: boolean): void {
|
||||||
this.native.setEnabled(enabled);
|
this.native.setEnabled(enabled);
|
||||||
}
|
}
|
||||||
isEnabled(): boolean {
|
isEnabled(): boolean {
|
||||||
return this.native.isEnabled();
|
return this.native.isEnabled();
|
||||||
}
|
}
|
||||||
setWindowOpacity(opacity: number) {
|
setWindowOpacity(opacity: number): void {
|
||||||
this.native.setWindowOpacity(opacity);
|
this.native.setWindowOpacity(opacity);
|
||||||
}
|
}
|
||||||
windowOpacity() {
|
windowOpacity(): number {
|
||||||
return this.native.windowOpacity();
|
return this.native.windowOpacity();
|
||||||
}
|
}
|
||||||
setWindowTitle(title: string) {
|
setWindowTitle(title: string): void {
|
||||||
//TODO:getter
|
//TODO:getter
|
||||||
return this.native.setWindowTitle(title);
|
return this.native.setWindowTitle(title);
|
||||||
}
|
}
|
||||||
setWindowState(state: WindowState) {
|
setWindowState(state: WindowState): void {
|
||||||
//TODO:getter
|
//TODO:getter
|
||||||
return this.native.setWindowState(state);
|
return this.native.setWindowState(state);
|
||||||
}
|
}
|
||||||
setCursor(cursor: CursorShape | QCursor) {
|
setCursor(cursor: CursorShape | QCursor): void {
|
||||||
//TODO:getter
|
//TODO:getter
|
||||||
this.native.setCursor(cursor);
|
this.native.setCursor(cursor);
|
||||||
}
|
}
|
||||||
setWindowIcon(icon: QIcon) {
|
setWindowIcon(icon: QIcon): void {
|
||||||
//TODO:getter
|
//TODO:getter
|
||||||
this.native.setWindowIcon(icon.native);
|
this.native.setWindowIcon(icon.native);
|
||||||
}
|
}
|
||||||
setMinimumSize(minw: number, minh: number) {
|
setMinimumSize(minw: number, minh: number): void {
|
||||||
this.native.setMinimumSize(minw, minh);
|
this.native.setMinimumSize(minw, minh);
|
||||||
}
|
}
|
||||||
setMaximumSize(maxw: number, maxh: number) {
|
setMaximumSize(maxw: number, maxh: number): void {
|
||||||
this.native.setMaximumSize(maxw, maxh);
|
this.native.setMaximumSize(maxw, maxh);
|
||||||
}
|
}
|
||||||
setFixedSize(width: number, height: number) {
|
setFixedSize(width: number, height: number): void {
|
||||||
this.native.setFixedSize(width, height);
|
this.native.setFixedSize(width, height);
|
||||||
}
|
}
|
||||||
resize(width: number, height: number) {
|
resize(width: number, height: number): void {
|
||||||
this.native.resize(width, height);
|
this.native.resize(width, height);
|
||||||
}
|
}
|
||||||
size(): { width: number; height: number } {
|
size(): { width: number; height: number } {
|
||||||
return this.native.size();
|
return this.native.size();
|
||||||
}
|
}
|
||||||
move(x: number, y: number) {
|
move(x: number, y: number): void {
|
||||||
this.native.move(x, y);
|
this.native.move(x, y);
|
||||||
}
|
}
|
||||||
pos(): { x: number; y: number } {
|
pos(): { x: number; y: number } {
|
||||||
return this.native.pos();
|
return this.native.pos();
|
||||||
}
|
}
|
||||||
repaint() {
|
repaint(): void {
|
||||||
// react:⛔️
|
// react:⛔️
|
||||||
this.native.repaint();
|
this.native.repaint();
|
||||||
}
|
}
|
||||||
update() {
|
update(): void {
|
||||||
// react:⛔️
|
// react:⛔️
|
||||||
this.native.update();
|
this.native.update();
|
||||||
}
|
}
|
||||||
updateGeometry() {
|
updateGeometry(): void {
|
||||||
// react:⛔️
|
// react:⛔️
|
||||||
this.native.updateGeometry();
|
this.native.updateGeometry();
|
||||||
}
|
}
|
||||||
setAttribute(attribute: WidgetAttribute, switchOn: boolean) {
|
setAttribute(attribute: WidgetAttribute, switchOn: boolean): void {
|
||||||
// react:⛔️
|
// react:⛔️
|
||||||
return this.native.setAttribute(attribute, switchOn);
|
return this.native.setAttribute(attribute, switchOn);
|
||||||
}
|
}
|
||||||
@ -125,11 +125,11 @@ export abstract class NodeWidget extends YogaWidget {
|
|||||||
// react:⛔️
|
// react:⛔️
|
||||||
return this.native.testAttribute(attribute);
|
return this.native.testAttribute(attribute);
|
||||||
}
|
}
|
||||||
setWindowFlag(windowType: WindowType, switchOn: boolean) {
|
setWindowFlag(windowType: WindowType, switchOn: boolean): void {
|
||||||
// react:⛔️
|
// react:⛔️
|
||||||
return this.native.setWindowFlag(windowType, switchOn);
|
return this.native.setWindowFlag(windowType, switchOn);
|
||||||
}
|
}
|
||||||
setLayout(parentLayout: NodeLayout) {
|
setLayout(parentLayout: NodeLayout): void {
|
||||||
const flexLayout = parentLayout as FlexLayout;
|
const flexLayout = parentLayout as FlexLayout;
|
||||||
if (flexLayout.setFlexNode) {
|
if (flexLayout.setFlexNode) {
|
||||||
//if flex layout set the flexnode
|
//if flex layout set the flexnode
|
||||||
|
|||||||
@ -14,12 +14,12 @@ export abstract class EventWidget extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addEventListener = (eventType: string, callback: (payload?: NativeEvent | any) => void) => {
|
addEventListener(eventType: string, callback: (payload?: NativeEvent | any) => void): void {
|
||||||
this.native.subscribeToQtEvent(eventType);
|
this.native.subscribeToQtEvent(eventType);
|
||||||
this.emitter.addListener(eventType, callback);
|
this.emitter.addListener(eventType, callback);
|
||||||
};
|
}
|
||||||
|
|
||||||
removeEventListener = (eventType: string, callback?: (payload?: NativeEvent | any) => void) => {
|
removeEventListener(eventType: string, callback?: (payload?: NativeEvent | any) => void): void {
|
||||||
if (callback) {
|
if (callback) {
|
||||||
this.emitter.removeListener(eventType, callback);
|
this.emitter.removeListener(eventType, callback);
|
||||||
} else {
|
} else {
|
||||||
@ -28,7 +28,7 @@ export abstract class EventWidget extends Component {
|
|||||||
if (this.emitter.listenerCount(eventType) < 1) {
|
if (this.emitter.listenerCount(eventType) < 1) {
|
||||||
this.native.unSubscribeToQtEvent(eventType);
|
this.native.unSubscribeToQtEvent(eventType);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const BaseWidgetEvents = Object.freeze({
|
export const BaseWidgetEvents = Object.freeze({
|
||||||
|
|||||||
@ -8,35 +8,35 @@ export class FlexLayout extends NodeLayout {
|
|||||||
native: NativeElement = new addon.FlexLayout();
|
native: NativeElement = new addon.FlexLayout();
|
||||||
protected flexNode?: FlexNode;
|
protected flexNode?: FlexNode;
|
||||||
|
|
||||||
addWidget = (childWidget: NodeWidget, childFlexNode?: FlexNode) => {
|
addWidget(childWidget: NodeWidget, childFlexNode?: FlexNode): void {
|
||||||
const childYogaNode = childFlexNode || childWidget.getFlexNode();
|
const childYogaNode = childFlexNode || childWidget.getFlexNode();
|
||||||
this.nodeChildren.add(childWidget);
|
this.nodeChildren.add(childWidget);
|
||||||
this.native.addWidget(childWidget.native, childYogaNode);
|
this.native.addWidget(childWidget.native, childYogaNode);
|
||||||
};
|
}
|
||||||
|
|
||||||
insertChildBefore = (
|
insertChildBefore(
|
||||||
childWidget: NodeWidget,
|
childWidget: NodeWidget,
|
||||||
beforeChildWidget: NodeWidget,
|
beforeChildWidget: NodeWidget,
|
||||||
childFlexNode?: FlexNode,
|
childFlexNode?: FlexNode,
|
||||||
beforeChildFlexNode?: FlexNode,
|
beforeChildFlexNode?: FlexNode,
|
||||||
) => {
|
): void {
|
||||||
const childYogaNode = childFlexNode || childWidget.getFlexNode();
|
const childYogaNode = childFlexNode || childWidget.getFlexNode();
|
||||||
const beforeChildYogaNode = beforeChildFlexNode || beforeChildWidget.getFlexNode();
|
const beforeChildYogaNode = beforeChildFlexNode || beforeChildWidget.getFlexNode();
|
||||||
this.nodeChildren.add(childWidget); // No orderer required yet, so just inserting at the end.
|
this.nodeChildren.add(childWidget); // No orderer required yet, so just inserting at the end.
|
||||||
this.native.insertChildBefore(childWidget.native, beforeChildYogaNode, childYogaNode);
|
this.native.insertChildBefore(childWidget.native, beforeChildYogaNode, childYogaNode);
|
||||||
};
|
}
|
||||||
|
|
||||||
removeWidget = (childWidget: NodeWidget, childFlexNode?: FlexNode) => {
|
removeWidget(childWidget: NodeWidget, childFlexNode?: FlexNode): void {
|
||||||
if (!this.nodeChildren.has(childWidget)) {
|
if (!this.nodeChildren.has(childWidget)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const childYogaNode = childFlexNode || childWidget.getFlexNode();
|
const childYogaNode = childFlexNode || childWidget.getFlexNode();
|
||||||
this.nodeChildren.delete(childWidget);
|
this.nodeChildren.delete(childWidget);
|
||||||
this.native.removeWidget(childWidget.native, childYogaNode);
|
this.native.removeWidget(childWidget.native, childYogaNode);
|
||||||
};
|
}
|
||||||
|
|
||||||
setFlexNode = (flexNode: FlexNode) => {
|
setFlexNode(flexNode: FlexNode): void {
|
||||||
this.flexNode = flexNode;
|
this.flexNode = flexNode;
|
||||||
this.native.setFlexNode(flexNode);
|
this.native.setFlexNode(flexNode);
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,7 +14,7 @@ export class StyleSheet {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export const prepareInlineStyleSheet = async (widget: NodeWidget, rawStyle: string) => {
|
export async function prepareInlineStyleSheet(widget: NodeWidget, rawStyle: string): Promise<string> {
|
||||||
const inlineStyle = await StyleSheet.create(rawStyle);
|
const inlineStyle = await StyleSheet.create(rawStyle);
|
||||||
// Make sure to not calculate ObjectName in the same pass of event loop as other props (incase of react) since the order will matter in that case
|
// Make sure to not calculate ObjectName in the same pass of event loop as other props (incase of react) since the order will matter in that case
|
||||||
// So doing it in multiple passes of event loop allows objectName to be set before using it. The above await solves it.
|
// So doing it in multiple passes of event loop allows objectName to be set before using it. The above await solves it.
|
||||||
@ -28,9 +28,9 @@ export const prepareInlineStyleSheet = async (widget: NodeWidget, rawStyle: stri
|
|||||||
${inlineStyle}
|
${inlineStyle}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
};
|
}
|
||||||
|
|
||||||
export const applyStyleSheet = async (widget: NodeWidget, styleSheet: string) => {
|
export async function applyStyleSheet(widget: NodeWidget, styleSheet: string): Promise<void> {
|
||||||
widget.native.setStyleSheet(styleSheet);
|
widget.native.setStyleSheet(styleSheet);
|
||||||
widget.layout ? widget.layout.update() : widget.update();
|
widget.layout ? widget.layout.update() : widget.update();
|
||||||
};
|
}
|
||||||
|
|||||||
@ -9,21 +9,23 @@
|
|||||||
This is required inorder to make the timers work nicely due to merger of event loops
|
This is required inorder to make the timers work nicely due to merger of event loops
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const noop = () => {};
|
function noop(): void {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const wrapWithActivateUvLoop = (func: Function) => {
|
const wrapWithActivateUvLoop = (func: Function) => {
|
||||||
return (...args: any[]) => {
|
return (...args: any[]): any => {
|
||||||
const activateUvLoop = (process as any).activateUvLoop || noop;
|
const activateUvLoop = (process as any).activateUvLoop || noop;
|
||||||
activateUvLoop();
|
activateUvLoop();
|
||||||
return func(...args);
|
return func(...args);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const main = () => {
|
function main(): void {
|
||||||
process.nextTick = wrapWithActivateUvLoop(process.nextTick);
|
process.nextTick = wrapWithActivateUvLoop(process.nextTick);
|
||||||
global.setImmediate = wrapWithActivateUvLoop(global.setImmediate);
|
global.setImmediate = wrapWithActivateUvLoop(global.setImmediate);
|
||||||
global.setTimeout = wrapWithActivateUvLoop(global.setTimeout);
|
global.setTimeout = wrapWithActivateUvLoop(global.setTimeout);
|
||||||
global.setInterval = wrapWithActivateUvLoop(global.setInterval);
|
global.setInterval = wrapWithActivateUvLoop(global.setInterval);
|
||||||
};
|
}
|
||||||
|
|
||||||
main();
|
main();
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { NativeElement } from '../core/Component';
|
import { NativeElement } from '../core/Component';
|
||||||
|
|
||||||
export const checkIfNativeElement = (arg: any) => {
|
export function checkIfNativeElement(arg: any): boolean {
|
||||||
const nativeArg = arg as NativeElement;
|
const nativeArg = arg as NativeElement;
|
||||||
return typeof nativeArg === 'object' && nativeArg.type === 'native';
|
return typeof nativeArg === 'object' && nativeArg.type === 'native';
|
||||||
};
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user