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 = {
|
||||
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.
|
||||
],
|
||||
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: {
|
||||
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.
|
||||
],
|
||||
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
|
||||
}
|
||||
}
|
||||
]
|
||||
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
|
||||
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';
|
||||
|
||||
export abstract class QObject extends EventWidget {
|
||||
inherits(className: string) {
|
||||
inherits(className: string): boolean {
|
||||
return this.native.inherits(className);
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,29 +14,29 @@ export class QApplication extends Component {
|
||||
this.native = new addon.QApplication();
|
||||
}
|
||||
}
|
||||
static clipboard = (): QClipboard => {
|
||||
static clipboard(): QClipboard {
|
||||
return new QClipboard(addon.QApplication.clipboard());
|
||||
};
|
||||
processEvents = () => {
|
||||
}
|
||||
processEvents(): void {
|
||||
this.native.processEvents();
|
||||
};
|
||||
exec = (): number => {
|
||||
}
|
||||
exec(): number {
|
||||
return this.native.exec();
|
||||
};
|
||||
static instance = (): QApplication => {
|
||||
}
|
||||
static instance(): QApplication {
|
||||
const nativeQApp = addon.QApplication.instance();
|
||||
return new QApplication(nativeQApp);
|
||||
};
|
||||
quit = () => {
|
||||
}
|
||||
quit(): number {
|
||||
return this.native.quit();
|
||||
};
|
||||
exit = (exitCode: number) => {
|
||||
}
|
||||
exit(exitCode: number): number {
|
||||
return this.native.exit(exitCode);
|
||||
};
|
||||
setQuitOnLastWindowClosed = (quit: boolean) => {
|
||||
}
|
||||
setQuitOnLastWindowClosed(quit: boolean): void {
|
||||
this.native.setQuitOnLastWindowClosed(quit);
|
||||
};
|
||||
quitOnLastWindowClosed = () => {
|
||||
}
|
||||
quitOnLastWindowClosed(): boolean {
|
||||
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()');
|
||||
}
|
||||
}
|
||||
clear = (mode: QClipboardMode) => {
|
||||
clear(mode: QClipboardMode): void {
|
||||
this.native.clear(mode);
|
||||
};
|
||||
setText = (text: string, mode: QClipboardMode) => {
|
||||
}
|
||||
setText(text: string, mode: QClipboardMode): void {
|
||||
this.native.setText(text, mode);
|
||||
};
|
||||
text = (mode: QClipboardMode): string => {
|
||||
}
|
||||
text(mode: QClipboardMode): string {
|
||||
return this.native.text(mode);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export enum QClipboardMode {
|
||||
|
||||
@ -13,10 +13,10 @@ export class QCursor extends Component {
|
||||
this.native = new addon.QCursor();
|
||||
}
|
||||
}
|
||||
pos = (): { x: number; y: number } => {
|
||||
pos(): { x: number; y: number } {
|
||||
return this.native.pos();
|
||||
};
|
||||
setPos = (x: number, y: number) => {
|
||||
}
|
||||
setPos(x: number, y: number): void {
|
||||
return this.native.setPos(x, y);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ export class QIcon extends Component {
|
||||
return this.native.isMask();
|
||||
}
|
||||
|
||||
setIsMask(isMask: boolean) {
|
||||
setIsMask(isMask: boolean): void {
|
||||
this.native.setIsMask(isMask);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,14 +2,14 @@ import { NodeWidget, QWidget } from '../QWidget';
|
||||
|
||||
export abstract class QAbstractScrollArea extends NodeWidget {
|
||||
viewportWidget?: NodeWidget;
|
||||
setViewport = (widget: NodeWidget) => {
|
||||
setViewport(widget: NodeWidget): void {
|
||||
this.viewportWidget = widget;
|
||||
this.native.setViewport(widget.native);
|
||||
};
|
||||
viewport = (): QWidget => {
|
||||
}
|
||||
viewport(): QWidget {
|
||||
if (!this.viewportWidget) {
|
||||
this.viewportWidget = new QWidget(this.native.viewport());
|
||||
}
|
||||
return this.viewportWidget;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,28 +2,28 @@ import { NodeWidget } from '../QWidget';
|
||||
import { Orientation } from '../../QtEnums';
|
||||
|
||||
export abstract class QAbstractSlider extends NodeWidget {
|
||||
setSingleStep = (step: number) => {
|
||||
setSingleStep(step: number): void {
|
||||
this.native.setSingleStep(step);
|
||||
};
|
||||
setMaximum(maximum: number) {
|
||||
}
|
||||
setMaximum(maximum: number): void {
|
||||
this.native.setMaximum(maximum);
|
||||
}
|
||||
maximum(): number {
|
||||
return this.native.maximum();
|
||||
}
|
||||
setMinimum(minimum: number) {
|
||||
setMinimum(minimum: number): void {
|
||||
this.native.setMinimum(minimum);
|
||||
}
|
||||
minimum(): number {
|
||||
return this.native.minimum();
|
||||
}
|
||||
setValue(value: number) {
|
||||
setValue(value: number): void {
|
||||
this.native.setValue(value);
|
||||
}
|
||||
value(): number {
|
||||
return this.native.value();
|
||||
}
|
||||
setOrientation(orientation: Orientation) {
|
||||
setOrientation(orientation: Orientation): void {
|
||||
this.native.setOrientation(orientation);
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,42 +27,42 @@ export class QAction extends QObject {
|
||||
super(native);
|
||||
this.native = native;
|
||||
}
|
||||
setText(text: string) {
|
||||
setText(text: string): void {
|
||||
this.native.setText(text);
|
||||
}
|
||||
setEnabled(enabled: boolean) {
|
||||
setEnabled(enabled: boolean): void {
|
||||
this.native.setEnabled(enabled);
|
||||
}
|
||||
setIcon(icon: QIcon) {
|
||||
setIcon(icon: QIcon): void {
|
||||
this.icon = icon;
|
||||
this.native.setIcon(icon.native);
|
||||
}
|
||||
setMenu(menu: QMenu) {
|
||||
setMenu(menu: QMenu): void {
|
||||
this.menu = menu;
|
||||
this.native.setMenu(menu.native);
|
||||
}
|
||||
setShortcut(keysequence: QKeySequence) {
|
||||
setShortcut(keysequence: QKeySequence): void {
|
||||
this.native.setShortcut(keysequence.native);
|
||||
}
|
||||
setShortcutContext(shortcutContext: ShortcutContext) {
|
||||
setShortcutContext(shortcutContext: ShortcutContext): void {
|
||||
this.native.setShortcutContext(shortcutContext);
|
||||
}
|
||||
isCheckable(): boolean {
|
||||
return this.native.isCheckable();
|
||||
}
|
||||
setCheckable(isCheckable: boolean) {
|
||||
setCheckable(isCheckable: boolean): void {
|
||||
this.native.setCheckable(isCheckable);
|
||||
}
|
||||
isChecked(): boolean {
|
||||
return this.native.isChecked();
|
||||
}
|
||||
setChecked(isChecked: boolean) {
|
||||
setChecked(isChecked: boolean): void {
|
||||
this.native.setChecked(isChecked);
|
||||
}
|
||||
isSeparator(): boolean {
|
||||
return this.native.isSeparator();
|
||||
}
|
||||
setSeparator(isSeparator: boolean) {
|
||||
setSeparator(isSeparator: boolean): void {
|
||||
this.native.setSeparator(isSeparator);
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,18 +19,14 @@ export class QCheckBox extends NodeWidget {
|
||||
super(native);
|
||||
this.native = native;
|
||||
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
|
||||
this.native.setText(text);
|
||||
}
|
||||
setChecked(check: boolean) {
|
||||
setChecked(check: boolean): void {
|
||||
// react:✓
|
||||
return this.native.setChecked(check);
|
||||
this.native.setChecked(check);
|
||||
}
|
||||
isChecked(): boolean {
|
||||
// react:✓
|
||||
|
||||
@ -24,15 +24,8 @@ export class QDial extends QAbstractSlider {
|
||||
super(native);
|
||||
this.native = native;
|
||||
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:✓
|
||||
this.native.setNotchesVisible(visible);
|
||||
}
|
||||
@ -40,7 +33,7 @@ export class QDial extends QAbstractSlider {
|
||||
// react:✓
|
||||
return this.native.notchesVisible();
|
||||
}
|
||||
setWrapping(on: boolean) {
|
||||
setWrapping(on: boolean): void {
|
||||
// react:✓
|
||||
this.native.setWrapping(on);
|
||||
}
|
||||
@ -48,7 +41,7 @@ export class QDial extends QAbstractSlider {
|
||||
// react:✓
|
||||
return this.native.wrapping();
|
||||
}
|
||||
setNotchTarget(target: number) {
|
||||
setNotchTarget(target: number): void {
|
||||
// react:✓
|
||||
this.native.setNotchTarget(target);
|
||||
}
|
||||
|
||||
@ -14,12 +14,12 @@ export class QGridLayout extends NodeLayout {
|
||||
this.native = new addon.QGridLayout();
|
||||
}
|
||||
}
|
||||
addWidget = (widget: NodeWidget) => {
|
||||
addWidget(widget: NodeWidget): void {
|
||||
this.native.addWidget(widget.native);
|
||||
this.nodeChildren.add(widget);
|
||||
};
|
||||
removeWidget = (widget: NodeWidget) => {
|
||||
}
|
||||
removeWidget(widget: NodeWidget): void {
|
||||
this.native.removeWidget(widget.native);
|
||||
this.nodeChildren.delete(widget);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,26 +21,26 @@ export class QLabel extends NodeWidget {
|
||||
this.native = native;
|
||||
this.nodeParent = parent;
|
||||
}
|
||||
setWordWrap(on: boolean) {
|
||||
setWordWrap(on: boolean): void {
|
||||
this.native.setWordWrap(on);
|
||||
}
|
||||
wordWrap(): boolean {
|
||||
return this.native.wordWrap();
|
||||
}
|
||||
setText(text: string | number) {
|
||||
setText(text: string | number): void {
|
||||
this.native.setText(`${text}`);
|
||||
}
|
||||
text() {
|
||||
text(): string {
|
||||
return this.native.text();
|
||||
}
|
||||
setPixmap(pixMap: QPixmap) {
|
||||
setPixmap(pixMap: QPixmap): void {
|
||||
this.native.setPixmap(pixMap.native);
|
||||
this._pixmap = pixMap;
|
||||
}
|
||||
pixmap() {
|
||||
pixmap(): QPixmap | undefined {
|
||||
return this._pixmap;
|
||||
}
|
||||
setOpenExternalLinks(open: boolean) {
|
||||
setOpenExternalLinks(open: boolean): void {
|
||||
this.native.setOpenExternalLinks(open);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,16 +4,16 @@ import { NodeWidget } from '../QWidget';
|
||||
// All Layouts should extend this abstract class.
|
||||
export abstract class NodeLayout extends Component {
|
||||
type = 'layout';
|
||||
abstract addWidget: (childWidget: NodeWidget, ...args: any[]) => void;
|
||||
abstract addWidget(childWidget: NodeWidget, ...args: any[]): void;
|
||||
activate = (): boolean => {
|
||||
return this.native.activate();
|
||||
};
|
||||
invalidate = () => {
|
||||
invalidate(): void {
|
||||
this.native.invalidate();
|
||||
};
|
||||
update = () => {
|
||||
}
|
||||
update(): void {
|
||||
this.native.update();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// export class QLayout extends NodeLayout { //Dont need QLayout for now
|
||||
|
||||
@ -26,14 +26,8 @@ export class QLineEdit extends NodeWidget {
|
||||
super(native);
|
||||
this.native = native;
|
||||
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:✓
|
||||
text && this.native.setText(text);
|
||||
}
|
||||
@ -41,16 +35,16 @@ export class QLineEdit extends NodeWidget {
|
||||
// react:✓
|
||||
return this.native.text();
|
||||
}
|
||||
setPlaceholderText(text: string) {
|
||||
setPlaceholderText(text: string): void {
|
||||
// react:✓ TODO://getter
|
||||
this.placeholderText = text;
|
||||
this.native.setPlaceholderText(text);
|
||||
}
|
||||
setReadOnly(isReadOnly: boolean) {
|
||||
setReadOnly(isReadOnly: boolean): void {
|
||||
// react:✓ TODO://getter
|
||||
this.native.setReadOnly(isReadOnly);
|
||||
}
|
||||
clear() {
|
||||
clear(): void {
|
||||
// react:✓
|
||||
this.native.clear();
|
||||
}
|
||||
|
||||
@ -12,7 +12,6 @@ export class QMainWindow extends NodeWidget {
|
||||
native: NativeElement;
|
||||
public centralWidget?: NodeWidget;
|
||||
private _menuBar?: QMenuBar;
|
||||
private _menuBarWidget?: NodeWidget;
|
||||
constructor(parent?: NodeWidget) {
|
||||
let native;
|
||||
if (parent) {
|
||||
@ -25,7 +24,7 @@ export class QMainWindow extends NodeWidget {
|
||||
this.nodeParent = parent;
|
||||
// bind member functions
|
||||
this.setCentralWidget.bind(this);
|
||||
this.setLayout = (parentLayout: NodeLayout) => {
|
||||
this.setLayout = (parentLayout: NodeLayout): void => {
|
||||
if (this.centralWidget) {
|
||||
this.centralWidget.setLayout(parentLayout);
|
||||
} else {
|
||||
@ -34,29 +33,29 @@ export class QMainWindow extends NodeWidget {
|
||||
}
|
||||
};
|
||||
}
|
||||
setCentralWidget(widget: NodeWidget) {
|
||||
setCentralWidget(widget: NodeWidget): void {
|
||||
// react:✓
|
||||
this.native.setCentralWidget(widget.native, widget.getFlexNode());
|
||||
this.centralWidget = widget;
|
||||
}
|
||||
setMenuBar(menuBar: QMenuBar) {
|
||||
setMenuBar(menuBar: QMenuBar): void {
|
||||
this.native.setMenuBar(menuBar.native);
|
||||
this._menuBar = menuBar;
|
||||
}
|
||||
menuBar(): QMenuBar | undefined {
|
||||
return this._menuBar;
|
||||
}
|
||||
setMenuWidget(menuWidget: NodeWidget) {
|
||||
setMenuWidget(menuWidget: NodeWidget): void {
|
||||
this.native.setMenuWidget(menuWidget.native);
|
||||
}
|
||||
get layout() {
|
||||
get layout(): NodeLayout | undefined {
|
||||
if (this.centralWidget) {
|
||||
return this.centralWidget.layout;
|
||||
} else {
|
||||
return super.layout;
|
||||
}
|
||||
}
|
||||
center() {
|
||||
center(): void {
|
||||
this.native.center();
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@ export class QMenu extends NodeWidget {
|
||||
this.nodeParent = parent;
|
||||
this.actions = new Set();
|
||||
}
|
||||
setTitle(title: string) {
|
||||
setTitle(title: string): void {
|
||||
this.native.setTitle(title);
|
||||
}
|
||||
addAction(action: QAction): QAction {
|
||||
|
||||
@ -29,10 +29,10 @@ export class QMenuBar extends NodeWidget {
|
||||
this.nodeParent = parent;
|
||||
}
|
||||
|
||||
addMenu(menu: QMenu) {
|
||||
addMenu(menu: QMenu): void {
|
||||
this.native.addMenu(menu.native);
|
||||
}
|
||||
setNativeMenuBar(nativeMenuBar: boolean) {
|
||||
setNativeMenuBar(nativeMenuBar: boolean): void {
|
||||
this.native.setNativeMenuBar(nativeMenuBar);
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,22 +34,12 @@ export class QPlainTextEdit extends QAbstractScrollArea {
|
||||
super(native);
|
||||
this.native = native;
|
||||
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:✓
|
||||
this.native.setPlainText(`${text}`);
|
||||
}
|
||||
setPlaceholderText(text: string) {
|
||||
setPlaceholderText(text: string): void {
|
||||
// react:✓, //TODO:getter
|
||||
this.placeholderText = text;
|
||||
this.native.setPlaceholderText(text);
|
||||
@ -58,21 +48,21 @@ export class QPlainTextEdit extends QAbstractScrollArea {
|
||||
// react:✓
|
||||
return this.native.toPlainText();
|
||||
}
|
||||
setReadOnly(isReadOnly: boolean) {
|
||||
setReadOnly(isReadOnly: boolean): void {
|
||||
// react:✓
|
||||
this.native.setReadOnly(isReadOnly);
|
||||
}
|
||||
clear() {
|
||||
clear(): void {
|
||||
// react:✓
|
||||
this.native.clear();
|
||||
}
|
||||
setWordWrapMode(mode: QTextOptionWrapMode) {
|
||||
setWordWrapMode(mode: QTextOptionWrapMode): void {
|
||||
this.native.setWordWrapMode(mode);
|
||||
}
|
||||
wordWrapMode(): QTextOptionWrapMode {
|
||||
return this.native.wordWrapMode();
|
||||
}
|
||||
setLineWrapMode(mode: LineWrapMode) {
|
||||
setLineWrapMode(mode: LineWrapMode): void {
|
||||
this.native.setLineWrapMode(mode);
|
||||
}
|
||||
lineWrapMode(): LineWrapMode {
|
||||
|
||||
@ -19,14 +19,8 @@ export class QProgressBar extends NodeWidget {
|
||||
super(native);
|
||||
this.native = native;
|
||||
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:✓
|
||||
this.native.setValue(value);
|
||||
}
|
||||
@ -34,15 +28,15 @@ export class QProgressBar extends NodeWidget {
|
||||
// react:✓
|
||||
return this.native.value();
|
||||
}
|
||||
setMinimum(min: number) {
|
||||
setMinimum(min: number): void {
|
||||
// react:✓ TODO://getter
|
||||
this.native.setMinimum(min);
|
||||
}
|
||||
setMaximum(max: number) {
|
||||
setMaximum(max: number): void {
|
||||
// react:✓ TODO://getter
|
||||
this.native.setMaximum(max);
|
||||
}
|
||||
setOrientation(orientation: Orientation) {
|
||||
setOrientation(orientation: Orientation): void {
|
||||
// react:✓ TODO://getter
|
||||
this.native.setOrientation(orientation);
|
||||
}
|
||||
|
||||
@ -24,19 +24,16 @@ export class QPushButton extends NodeWidget {
|
||||
super(native);
|
||||
this.nodeParent = parent;
|
||||
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
|
||||
this.native.setText(`${text}`);
|
||||
}
|
||||
setFlat(isFlat: boolean) {
|
||||
setFlat(isFlat: boolean): void {
|
||||
// react:✓, //TODO:getter
|
||||
this.native.setFlat(isFlat);
|
||||
}
|
||||
setIcon(icon: QIcon) {
|
||||
setIcon(icon: QIcon): void {
|
||||
// react:✓, //TODO:getter
|
||||
this.native.setIcon(icon.native);
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ export class QRadioButton extends NodeWidget {
|
||||
// bind member functions
|
||||
this.setText.bind(this);
|
||||
}
|
||||
setText(text: string | number) {
|
||||
setText(text: string | number): void {
|
||||
// react:✓ TODO://getter
|
||||
this.native.setText(`${text}`);
|
||||
}
|
||||
|
||||
@ -20,11 +20,8 @@ export class QScrollArea extends QAbstractScrollArea {
|
||||
super(native);
|
||||
this.native = native;
|
||||
this.nodeParent = parent;
|
||||
// bind member functions
|
||||
this.setWidget.bind(this);
|
||||
this.takeWidget.bind(this);
|
||||
}
|
||||
setWidget(widget: NodeWidget) {
|
||||
setWidget(widget: NodeWidget): void {
|
||||
// react:✓, //TODO:getter
|
||||
this.contentWidget = widget;
|
||||
this.native.setWidget(widget.native);
|
||||
@ -39,7 +36,7 @@ export class QScrollArea extends QAbstractScrollArea {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
setWidgetResizable(resizable: boolean) {
|
||||
setWidgetResizable(resizable: boolean): void {
|
||||
this.native.setWidgetResizable(resizable);
|
||||
}
|
||||
widgetResizable(): boolean {
|
||||
|
||||
@ -17,16 +17,16 @@ export class QShortcut extends QObject {
|
||||
super(native);
|
||||
this.native = native;
|
||||
}
|
||||
setEnabled(enabled: boolean) {
|
||||
setEnabled(enabled: boolean): void {
|
||||
this.native.setEnabled(enabled);
|
||||
}
|
||||
setAutoRepeat(on: boolean) {
|
||||
setAutoRepeat(on: boolean): void {
|
||||
this.native.setAutoRepeat(on);
|
||||
}
|
||||
setKey(keysequence: QKeySequence) {
|
||||
setKey(keysequence: QKeySequence): void {
|
||||
this.native.setKey(keysequence.native);
|
||||
}
|
||||
setContext(shortcutContext: ShortcutContext) {
|
||||
setContext(shortcutContext: ShortcutContext): void {
|
||||
this.native.setContext(shortcutContext);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,6 @@ import addon from '../../utils/addon';
|
||||
import { NodeWidget } from '../QWidget';
|
||||
import { BaseWidgetEvents } from '../../core/EventWidget';
|
||||
import { NativeElement } from '../../core/Component';
|
||||
import { QIcon } from '../../QtGui/QIcon';
|
||||
|
||||
export const QSpinBoxEvents = Object.freeze({
|
||||
...BaseWidgetEvents,
|
||||
@ -21,22 +20,12 @@ export class QSpinBox extends NodeWidget {
|
||||
super(native);
|
||||
this.nodeParent = parent;
|
||||
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:✓
|
||||
this.native.setPrefix(prefix);
|
||||
}
|
||||
setSuffix(suffix: string) {
|
||||
setSuffix(suffix: string): void {
|
||||
// react:✓
|
||||
this.native.setSuffix(suffix);
|
||||
}
|
||||
@ -44,11 +33,11 @@ export class QSpinBox extends NodeWidget {
|
||||
// react:✓
|
||||
return this.native.cleanText();
|
||||
}
|
||||
setSingleStep(val: number) {
|
||||
setSingleStep(val: number): void {
|
||||
// react:✓
|
||||
this.native.setSingleStep(val);
|
||||
}
|
||||
setRange(minimum: number, maximum: number) {
|
||||
setRange(minimum: number, maximum: number): void {
|
||||
// react:✓
|
||||
this.native.setRange(minimum, maximum);
|
||||
}
|
||||
@ -60,7 +49,7 @@ export class QSpinBox extends NodeWidget {
|
||||
// react:✓
|
||||
return this.native.minimum();
|
||||
}
|
||||
setValue(val: number) {
|
||||
setValue(val: number): void {
|
||||
// react:✓
|
||||
this.native.setValue(val);
|
||||
}
|
||||
|
||||
@ -22,22 +22,22 @@ export class QSystemTrayIcon extends QObject {
|
||||
super(native);
|
||||
this.native = native;
|
||||
}
|
||||
show() {
|
||||
show(): void {
|
||||
this.native.show();
|
||||
}
|
||||
hide() {
|
||||
hide(): void {
|
||||
this.native.hide();
|
||||
}
|
||||
setIcon(icon: QIcon) {
|
||||
setIcon(icon: QIcon): void {
|
||||
this.native.setIcon(icon.native);
|
||||
}
|
||||
isVisible(): boolean {
|
||||
return this.native.isVisible();
|
||||
}
|
||||
setToolTip(tooltip: string) {
|
||||
setToolTip(tooltip: string): void {
|
||||
this.native.setToolTip(tooltip);
|
||||
}
|
||||
setContextMenu(menu: QMenu) {
|
||||
setContextMenu(menu: QMenu): void {
|
||||
this.contextMenu = menu;
|
||||
this.native.setContextMenu(this.contextMenu.native);
|
||||
}
|
||||
|
||||
@ -29,16 +29,16 @@ export class QTabWidget extends NodeWidget {
|
||||
this.addTab.bind(this);
|
||||
}
|
||||
|
||||
addTab(page: NodeWidget, icon: QIcon, label: string) {
|
||||
addTab(page: NodeWidget, icon: QIcon, label: string): void {
|
||||
this.nodeChildren.add(page);
|
||||
this.native.addTab(page.native, icon.native, label);
|
||||
}
|
||||
|
||||
setTabPosition(tabPosition: TabPosition) {
|
||||
setTabPosition(tabPosition: TabPosition): void {
|
||||
this.native.setTabPosition(tabPosition);
|
||||
}
|
||||
|
||||
setCurrentIndex(index: number) {
|
||||
setCurrentIndex(index: number): void {
|
||||
this.native.setCurrentIndex(index);
|
||||
}
|
||||
|
||||
@ -46,11 +46,11 @@ export class QTabWidget extends NodeWidget {
|
||||
return this.native.currentIndex();
|
||||
}
|
||||
|
||||
removeTab(index: number) {
|
||||
removeTab(index: number): void {
|
||||
this.native.removeTab(index);
|
||||
}
|
||||
|
||||
setTabsClosable(closeable: boolean) {
|
||||
setTabsClosable(closeable: boolean): void {
|
||||
this.native.setTabsClosable(closeable);
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,109 +15,109 @@ import { YogaWidget } from '../../core/YogaWidget';
|
||||
export abstract class NodeWidget extends YogaWidget {
|
||||
layout?: NodeLayout;
|
||||
type = 'widget';
|
||||
show() {
|
||||
show(): void {
|
||||
this.native.show();
|
||||
}
|
||||
hide() {
|
||||
hide(): void {
|
||||
this.native.hide();
|
||||
}
|
||||
isVisible(): boolean {
|
||||
return this.native.isVisible();
|
||||
}
|
||||
close() {
|
||||
close(): boolean {
|
||||
return this.native.close();
|
||||
}
|
||||
async setStyleSheet(styleSheet: string) {
|
||||
async setStyleSheet(styleSheet: string): Promise<void> {
|
||||
const preparedSheet = await StyleSheet.create(styleSheet);
|
||||
await applyStyleSheet(this, preparedSheet);
|
||||
}
|
||||
styleSheet(): string {
|
||||
return this.native.styleSheet();
|
||||
}
|
||||
async setInlineStyle(style: string) {
|
||||
async setInlineStyle(style: string): Promise<void> {
|
||||
const preparedSheet = await prepareInlineStyleSheet(this, style);
|
||||
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);
|
||||
}
|
||||
geometry(): Rect {
|
||||
return this.native.geometry();
|
||||
}
|
||||
setObjectName(objectName: string) {
|
||||
setObjectName(objectName: string): void {
|
||||
this.native.setObjectName(objectName);
|
||||
}
|
||||
objectName(): string {
|
||||
return this.native.objectName();
|
||||
}
|
||||
setMouseTracking(isMouseTracked: boolean) {
|
||||
setMouseTracking(isMouseTracked: boolean): void {
|
||||
this.native.setMouseTracking(isMouseTracked);
|
||||
}
|
||||
hasMouseTracking(): boolean {
|
||||
return this.native.hasMouseTracking();
|
||||
}
|
||||
setEnabled(enabled: boolean) {
|
||||
setEnabled(enabled: boolean): void {
|
||||
this.native.setEnabled(enabled);
|
||||
}
|
||||
isEnabled(): boolean {
|
||||
return this.native.isEnabled();
|
||||
}
|
||||
setWindowOpacity(opacity: number) {
|
||||
setWindowOpacity(opacity: number): void {
|
||||
this.native.setWindowOpacity(opacity);
|
||||
}
|
||||
windowOpacity() {
|
||||
windowOpacity(): number {
|
||||
return this.native.windowOpacity();
|
||||
}
|
||||
setWindowTitle(title: string) {
|
||||
setWindowTitle(title: string): void {
|
||||
//TODO:getter
|
||||
return this.native.setWindowTitle(title);
|
||||
}
|
||||
setWindowState(state: WindowState) {
|
||||
setWindowState(state: WindowState): void {
|
||||
//TODO:getter
|
||||
return this.native.setWindowState(state);
|
||||
}
|
||||
setCursor(cursor: CursorShape | QCursor) {
|
||||
setCursor(cursor: CursorShape | QCursor): void {
|
||||
//TODO:getter
|
||||
this.native.setCursor(cursor);
|
||||
}
|
||||
setWindowIcon(icon: QIcon) {
|
||||
setWindowIcon(icon: QIcon): void {
|
||||
//TODO:getter
|
||||
this.native.setWindowIcon(icon.native);
|
||||
}
|
||||
setMinimumSize(minw: number, minh: number) {
|
||||
setMinimumSize(minw: number, minh: number): void {
|
||||
this.native.setMinimumSize(minw, minh);
|
||||
}
|
||||
setMaximumSize(maxw: number, maxh: number) {
|
||||
setMaximumSize(maxw: number, maxh: number): void {
|
||||
this.native.setMaximumSize(maxw, maxh);
|
||||
}
|
||||
setFixedSize(width: number, height: number) {
|
||||
setFixedSize(width: number, height: number): void {
|
||||
this.native.setFixedSize(width, height);
|
||||
}
|
||||
resize(width: number, height: number) {
|
||||
resize(width: number, height: number): void {
|
||||
this.native.resize(width, height);
|
||||
}
|
||||
size(): { width: number; height: number } {
|
||||
return this.native.size();
|
||||
}
|
||||
move(x: number, y: number) {
|
||||
move(x: number, y: number): void {
|
||||
this.native.move(x, y);
|
||||
}
|
||||
pos(): { x: number; y: number } {
|
||||
return this.native.pos();
|
||||
}
|
||||
repaint() {
|
||||
repaint(): void {
|
||||
// react:⛔️
|
||||
this.native.repaint();
|
||||
}
|
||||
update() {
|
||||
update(): void {
|
||||
// react:⛔️
|
||||
this.native.update();
|
||||
}
|
||||
updateGeometry() {
|
||||
updateGeometry(): void {
|
||||
// react:⛔️
|
||||
this.native.updateGeometry();
|
||||
}
|
||||
setAttribute(attribute: WidgetAttribute, switchOn: boolean) {
|
||||
setAttribute(attribute: WidgetAttribute, switchOn: boolean): void {
|
||||
// react:⛔️
|
||||
return this.native.setAttribute(attribute, switchOn);
|
||||
}
|
||||
@ -125,11 +125,11 @@ export abstract class NodeWidget extends YogaWidget {
|
||||
// react:⛔️
|
||||
return this.native.testAttribute(attribute);
|
||||
}
|
||||
setWindowFlag(windowType: WindowType, switchOn: boolean) {
|
||||
setWindowFlag(windowType: WindowType, switchOn: boolean): void {
|
||||
// react:⛔️
|
||||
return this.native.setWindowFlag(windowType, switchOn);
|
||||
}
|
||||
setLayout(parentLayout: NodeLayout) {
|
||||
setLayout(parentLayout: NodeLayout): void {
|
||||
const flexLayout = parentLayout as FlexLayout;
|
||||
if (flexLayout.setFlexNode) {
|
||||
//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.emitter.addListener(eventType, callback);
|
||||
};
|
||||
}
|
||||
|
||||
removeEventListener = (eventType: string, callback?: (payload?: NativeEvent | any) => void) => {
|
||||
removeEventListener(eventType: string, callback?: (payload?: NativeEvent | any) => void): void {
|
||||
if (callback) {
|
||||
this.emitter.removeListener(eventType, callback);
|
||||
} else {
|
||||
@ -28,7 +28,7 @@ export abstract class EventWidget extends Component {
|
||||
if (this.emitter.listenerCount(eventType) < 1) {
|
||||
this.native.unSubscribeToQtEvent(eventType);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export const BaseWidgetEvents = Object.freeze({
|
||||
|
||||
@ -8,35 +8,35 @@ export class FlexLayout extends NodeLayout {
|
||||
native: NativeElement = new addon.FlexLayout();
|
||||
protected flexNode?: FlexNode;
|
||||
|
||||
addWidget = (childWidget: NodeWidget, childFlexNode?: FlexNode) => {
|
||||
addWidget(childWidget: NodeWidget, childFlexNode?: FlexNode): void {
|
||||
const childYogaNode = childFlexNode || childWidget.getFlexNode();
|
||||
this.nodeChildren.add(childWidget);
|
||||
this.native.addWidget(childWidget.native, childYogaNode);
|
||||
};
|
||||
}
|
||||
|
||||
insertChildBefore = (
|
||||
insertChildBefore(
|
||||
childWidget: NodeWidget,
|
||||
beforeChildWidget: NodeWidget,
|
||||
childFlexNode?: FlexNode,
|
||||
beforeChildFlexNode?: FlexNode,
|
||||
) => {
|
||||
): void {
|
||||
const childYogaNode = childFlexNode || childWidget.getFlexNode();
|
||||
const beforeChildYogaNode = beforeChildFlexNode || beforeChildWidget.getFlexNode();
|
||||
this.nodeChildren.add(childWidget); // No orderer required yet, so just inserting at the end.
|
||||
this.native.insertChildBefore(childWidget.native, beforeChildYogaNode, childYogaNode);
|
||||
};
|
||||
}
|
||||
|
||||
removeWidget = (childWidget: NodeWidget, childFlexNode?: FlexNode) => {
|
||||
removeWidget(childWidget: NodeWidget, childFlexNode?: FlexNode): void {
|
||||
if (!this.nodeChildren.has(childWidget)) {
|
||||
return;
|
||||
}
|
||||
const childYogaNode = childFlexNode || childWidget.getFlexNode();
|
||||
this.nodeChildren.delete(childWidget);
|
||||
this.native.removeWidget(childWidget.native, childYogaNode);
|
||||
};
|
||||
}
|
||||
|
||||
setFlexNode = (flexNode: FlexNode) => {
|
||||
setFlexNode(flexNode: FlexNode): void {
|
||||
this.flexNode = 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);
|
||||
// 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.
|
||||
@ -28,9 +28,9 @@ export const prepareInlineStyleSheet = async (widget: NodeWidget, rawStyle: stri
|
||||
${inlineStyle}
|
||||
}
|
||||
`;
|
||||
};
|
||||
}
|
||||
|
||||
export const applyStyleSheet = async (widget: NodeWidget, styleSheet: string) => {
|
||||
export async function applyStyleSheet(widget: NodeWidget, styleSheet: string): Promise<void> {
|
||||
widget.native.setStyleSheet(styleSheet);
|
||||
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
|
||||
*/
|
||||
|
||||
const noop = () => {};
|
||||
function noop(): void {
|
||||
return;
|
||||
}
|
||||
|
||||
const wrapWithActivateUvLoop = (func: Function) => {
|
||||
return (...args: any[]) => {
|
||||
return (...args: any[]): any => {
|
||||
const activateUvLoop = (process as any).activateUvLoop || noop;
|
||||
activateUvLoop();
|
||||
return func(...args);
|
||||
};
|
||||
};
|
||||
|
||||
const main = () => {
|
||||
function main(): void {
|
||||
process.nextTick = wrapWithActivateUvLoop(process.nextTick);
|
||||
global.setImmediate = wrapWithActivateUvLoop(global.setImmediate);
|
||||
global.setTimeout = wrapWithActivateUvLoop(global.setTimeout);
|
||||
global.setInterval = wrapWithActivateUvLoop(global.setInterval);
|
||||
};
|
||||
}
|
||||
|
||||
main();
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { NativeElement } from '../core/Component';
|
||||
|
||||
export const checkIfNativeElement = (arg: any) => {
|
||||
export function checkIfNativeElement(arg: any): boolean {
|
||||
const nativeArg = arg as NativeElement;
|
||||
return typeof nativeArg === 'object' && nativeArg.type === 'native';
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user