From 38b12759c68d5c8f1598c0c7d63b8ce568d97820 Mon Sep 17 00:00:00 2001 From: Simon Edwards Date: Fri, 29 Apr 2022 19:36:46 +0200 Subject: [PATCH] Remove `NodeWidget`, just use `QWidget` --- src/index.ts | 2 +- src/lib/QtGui/QStyle.ts | 6 +- src/lib/QtWidgets/QAbstractButton.ts | 6 +- src/lib/QtWidgets/QAbstractScrollArea.ts | 6 +- src/lib/QtWidgets/QAbstractSlider.ts | 6 +- src/lib/QtWidgets/QAbstractSpinBox.ts | 6 +- src/lib/QtWidgets/QAction.ts | 6 +- src/lib/QtWidgets/QBoxLayout.ts | 12 ++-- src/lib/QtWidgets/QButtonGroup.ts | 6 +- src/lib/QtWidgets/QCalendarWidget.ts | 8 +-- src/lib/QtWidgets/QCheckBox.ts | 10 +-- src/lib/QtWidgets/QColorDialog.ts | 6 +- src/lib/QtWidgets/QComboBox.ts | 8 +-- src/lib/QtWidgets/QDateEdit.ts | 8 +-- src/lib/QtWidgets/QDateTimeEdit.ts | 8 +-- src/lib/QtWidgets/QDial.ts | 8 +-- src/lib/QtWidgets/QDialog.ts | 6 +- src/lib/QtWidgets/QDoubleSpinBox.ts | 8 +-- src/lib/QtWidgets/QErrorMessage.ts | 8 +-- src/lib/QtWidgets/QFileDialog.ts | 6 +- src/lib/QtWidgets/QFontDialog.ts | 8 +-- src/lib/QtWidgets/QFrame.ts | 10 +-- src/lib/QtWidgets/QGridLayout.ts | 10 ++- src/lib/QtWidgets/QGroupBox.ts | 10 ++- src/lib/QtWidgets/QHeaderView.ts | 4 +- src/lib/QtWidgets/QInputDialog.ts | 4 +- src/lib/QtWidgets/QLCDNumber.ts | 6 +- src/lib/QtWidgets/QLabel.ts | 10 +-- src/lib/QtWidgets/QLayout.ts | 9 ++- src/lib/QtWidgets/QLineEdit.ts | 6 +- src/lib/QtWidgets/QListView.ts | 8 +-- src/lib/QtWidgets/QListWidget.ts | 6 +- src/lib/QtWidgets/QMainWindow.ts | 16 ++--- src/lib/QtWidgets/QMenu.ts | 6 +- src/lib/QtWidgets/QMenuBar.ts | 8 +-- src/lib/QtWidgets/QMessageBox.ts | 8 +-- src/lib/QtWidgets/QPlainTextEdit.ts | 6 +- src/lib/QtWidgets/QProgressBar.ts | 8 +-- src/lib/QtWidgets/QProgressDialog.ts | 4 +- src/lib/QtWidgets/QPushButton.ts | 6 +- src/lib/QtWidgets/QRadioButton.ts | 6 +- src/lib/QtWidgets/QScrollArea.ts | 14 ++-- src/lib/QtWidgets/QScrollBar.ts | 4 +- src/lib/QtWidgets/QShortcut.ts | 6 +- src/lib/QtWidgets/QSpinBox.ts | 4 +- src/lib/QtWidgets/QSplitter.ts | 10 +-- src/lib/QtWidgets/QStackedWidget.ts | 10 +-- src/lib/QtWidgets/QStandardItemModel.ts | 4 +- src/lib/QtWidgets/QStatusBar.ts | 6 +- src/lib/QtWidgets/QSvgWidget.ts | 10 ++- src/lib/QtWidgets/QSystemTrayIcon.ts | 4 +- src/lib/QtWidgets/QTabBar.ts | 8 +-- src/lib/QtWidgets/QTabWidget.ts | 14 ++-- src/lib/QtWidgets/QTableView.ts | 4 +- src/lib/QtWidgets/QTableWidget.ts | 6 +- src/lib/QtWidgets/QTextBrowser.ts | 8 +-- src/lib/QtWidgets/QTextEdit.ts | 4 +- src/lib/QtWidgets/QTimeEdit.ts | 4 +- src/lib/QtWidgets/QToolButton.ts | 6 +- src/lib/QtWidgets/QTreeWidget.ts | 4 +- src/lib/QtWidgets/QWidget.ts | 89 ++++++++---------------- src/lib/core/FlexLayout.ts | 18 ++--- src/lib/core/Style/StyleSheet.ts | 4 +- 63 files changed, 237 insertions(+), 303 deletions(-) diff --git a/src/index.ts b/src/index.ts index 135722327..0e989d741 100644 --- a/src/index.ts +++ b/src/index.ts @@ -39,7 +39,7 @@ export { QScreen } from './lib/QtGui/QScreen'; export { QWindow } from './lib/QtGui/QWindow'; export { WidgetEventTypes } from './lib/core/EventWidget'; // Abstract: -export { NodeWidget, QWidget, QWidgetSignals } from './lib/QtWidgets/QWidget'; +export { QWidget, QWidgetSignals } from './lib/QtWidgets/QWidget'; export { NodeLayout, QLayoutSignals, SizeConstraint } from './lib/QtWidgets/QLayout'; export { QAbstractScrollArea } from './lib/QtWidgets/QAbstractScrollArea'; export { QAbstractSlider, QAbstractSliderSignals, SliderAction } from './lib/QtWidgets/QAbstractSlider'; diff --git a/src/lib/QtGui/QStyle.ts b/src/lib/QtGui/QStyle.ts index 363d94940..df5080cd9 100644 --- a/src/lib/QtGui/QStyle.ts +++ b/src/lib/QtGui/QStyle.ts @@ -1,4 +1,4 @@ -import { NodeWidget } from '../..'; +import { QWidget } from '../..'; import { Component, NativeElement } from '../core/Component'; import { checkIfNativeElement } from '../utils/helpers'; @@ -13,10 +13,10 @@ export class QStyle extends Component { pixelMetric(metric: QStylePixelMetric): number { return this.native.pixelMetric(metric); } - polish(widget: NodeWidget): void { + polish(widget: QWidget): void { this.native.polish(widget.native); } - unpolish(widget: NodeWidget): void { + unpolish(widget: QWidget): void { this.native.unpolish(widget.native); } } diff --git a/src/lib/QtWidgets/QAbstractButton.ts b/src/lib/QtWidgets/QAbstractButton.ts index b2e61b295..f62b11e8a 100644 --- a/src/lib/QtWidgets/QAbstractButton.ts +++ b/src/lib/QtWidgets/QAbstractButton.ts @@ -1,10 +1,10 @@ -import { NodeWidget, QWidgetSignals } from './QWidget'; +import { QWidget, QWidgetSignals } from './QWidget'; import { QIcon } from '../QtGui/QIcon'; import { QSize } from '../QtCore/QSize'; import { QKeySequence } from '../QtGui/QKeySequence'; /** - + > This is the abstract base class of button widgets, providing their functionality. * **This class is a JS wrapper around Qt's [QAbstractButton class](https://doc.qt.io/qt-5/qabstractbutton.html)** @@ -13,7 +13,7 @@ The QAbstractButton class is an abstract class and therefore, technically, no fu It is inherited by QCheckBox, QPushButton, QRadioButton, and QToolButton. */ -export abstract class QAbstractButton extends NodeWidget { +export abstract class QAbstractButton extends QWidget { animateClick(msec: number): void { this.native.animateClick(msec); } diff --git a/src/lib/QtWidgets/QAbstractScrollArea.ts b/src/lib/QtWidgets/QAbstractScrollArea.ts index cff280855..e1a02471a 100644 --- a/src/lib/QtWidgets/QAbstractScrollArea.ts +++ b/src/lib/QtWidgets/QAbstractScrollArea.ts @@ -1,4 +1,4 @@ -import { NodeWidget, QWidget } from './QWidget'; +import { QWidget } from './QWidget'; import { NodeFrame, QFrameSignals } from './QFrame'; import { ScrollBarPolicy } from '../QtEnums/ScrollBarPolicy'; import { QSize } from '../QtCore/QSize'; @@ -18,8 +18,8 @@ QAbstractScrollArea will list all methods and properties that are common to all */ export abstract class QAbstractScrollArea extends NodeFrame { - viewportWidget?: NodeWidget; - setViewport(widget: NodeWidget): void { + viewportWidget?: QWidget; + setViewport(widget: QWidget): void { this.viewportWidget = widget; this.native.setViewport(widget.native); } diff --git a/src/lib/QtWidgets/QAbstractSlider.ts b/src/lib/QtWidgets/QAbstractSlider.ts index 17a89f19a..be8521482 100644 --- a/src/lib/QtWidgets/QAbstractSlider.ts +++ b/src/lib/QtWidgets/QAbstractSlider.ts @@ -1,8 +1,8 @@ -import { NodeWidget, QWidgetSignals } from './QWidget'; +import { QWidget, QWidgetSignals } from './QWidget'; import { Orientation } from '../QtEnums'; /** - + > Abstract class to add functionalities common to all slider based widgets. **This class implements all methods, properties of Qt's [QAbstractSlider class](https://doc.qt.io/qt-5/qabstractslider.html) so that it can be inherited by all slider based widgets** @@ -14,7 +14,7 @@ import { Orientation } from '../QtEnums'; QAbstractSlider will list all methods and properties that are common to all slider widgets in the NodeGui world. */ -export abstract class QAbstractSlider extends NodeWidget { +export abstract class QAbstractSlider extends QWidget { triggerAction(action: SliderAction): void { this.native.triggerAction(action); } diff --git a/src/lib/QtWidgets/QAbstractSpinBox.ts b/src/lib/QtWidgets/QAbstractSpinBox.ts index fdbd7fb40..6433c9ff9 100644 --- a/src/lib/QtWidgets/QAbstractSpinBox.ts +++ b/src/lib/QtWidgets/QAbstractSpinBox.ts @@ -1,8 +1,8 @@ -import { NodeWidget, QWidgetSignals } from './QWidget'; +import { QWidget, QWidgetSignals } from './QWidget'; import { AlignmentFlag } from '../QtEnums'; /** - + > This is the abstract base class of button widgets, providing their functionality. * **This class is a JS wrapper around Qt's [QAbstractSpinBox class](https://doc.qt.io/qt-5/qabstractspinbox.html)** @@ -11,7 +11,7 @@ The QAbstractSpinBox class is an abstract class and therefore, technically, no f It is inherited by QDateTimeEdit and QSpinBox. (n/a QDoubleSpinBox) */ -export abstract class QAbstractSpinBox extends NodeWidget { +export abstract class QAbstractSpinBox extends QWidget { selectAll(): void { this.native.selectAll(); } diff --git a/src/lib/QtWidgets/QAction.ts b/src/lib/QtWidgets/QAction.ts index 9c19f36d9..d79e8ef90 100644 --- a/src/lib/QtWidgets/QAction.ts +++ b/src/lib/QtWidgets/QAction.ts @@ -1,5 +1,5 @@ import addon from '../utils/addon'; -import { NodeWidget } from './QWidget'; +import { QWidget } from './QWidget'; import { NativeElement } from '../core/Component'; import { QMenu } from './QMenu'; import { QIcon } from '../QtGui/QIcon'; @@ -33,8 +33,8 @@ menu.addAction(menuAction); export class QAction extends QObject { constructor(); constructor(native: NativeElement); - constructor(parent: NodeWidget); - constructor(parent?: NativeElement | NodeWidget) { + constructor(parent: QWidget); + constructor(parent?: NativeElement | QWidget) { let native: NativeElement; if (checkIfNativeElement(parent)) { native = parent as NativeElement; diff --git a/src/lib/QtWidgets/QBoxLayout.ts b/src/lib/QtWidgets/QBoxLayout.ts index 03621edc4..daffb431f 100644 --- a/src/lib/QtWidgets/QBoxLayout.ts +++ b/src/lib/QtWidgets/QBoxLayout.ts @@ -1,5 +1,5 @@ import addon from '../utils/addon'; -import { NodeWidget } from './QWidget'; +import { QWidget } from './QWidget'; import { NodeLayout, QLayoutSignals } from './QLayout'; import { NativeElement } from '../core/Component'; import { AlignmentFlag, Direction } from '../QtEnums'; @@ -27,9 +27,7 @@ centralWidget.setLayout(boxLayout); */ export class QBoxLayout extends NodeLayout { childLayouts: Set>; - constructor(dir: Direction); - constructor(dir: Direction, parent: NodeWidget); - constructor(dir: Direction, parent?: NodeWidget) { + constructor(dir: Direction, parent?: QWidget) { let native: NativeElement; if (parent) { native = new addon.QBoxLayout(dir, parent.native); @@ -53,11 +51,11 @@ export class QBoxLayout extends NodeLayout { addStrut(size: number): void { this.native.addStrut(size); } - addWidget(widget: NodeWidget, stretch = 0, alignment: AlignmentFlag = 0): void { + addWidget(widget: QWidget, stretch = 0, alignment: AlignmentFlag = 0): void { this.native.addWidget(widget.native, stretch, alignment); this.nodeChildren.add(widget); } - insertWidget(index: number, widget: NodeWidget, stretch = 0): void { + insertWidget(index: number, widget: QWidget, stretch = 0): void { this.native.insertWidget(index, widget.native, stretch); this.nodeChildren.add(widget); } @@ -74,7 +72,7 @@ export class QBoxLayout extends NodeLayout { insertStretch(index: number, stretch = 0): void { this.native.insertStretch(index, stretch); } - removeWidget(widget: NodeWidget): void { + removeWidget(widget: QWidget): void { this.native.removeWidget(widget.native); this.nodeChildren.delete(widget); } diff --git a/src/lib/QtWidgets/QButtonGroup.ts b/src/lib/QtWidgets/QButtonGroup.ts index da7a16c68..acfccc633 100644 --- a/src/lib/QtWidgets/QButtonGroup.ts +++ b/src/lib/QtWidgets/QButtonGroup.ts @@ -1,5 +1,5 @@ import addon from '../utils/addon'; -import { NodeWidget } from './QWidget'; +import { QWidget } from './QWidget'; import { NativeRawPointer } from '../core/Component'; import { QObject, QObjectSignals } from '../QtCore/QObject'; import { QAbstractButton, QAbstractButtonSignals } from './QAbstractButton'; @@ -9,9 +9,7 @@ export interface QButtonGroupSignals extends QObjectSignals { } export class QButtonGroup extends QObject { - constructor(); - constructor(parent: NodeWidget); - constructor(parent?: NodeWidget) { + constructor(parent?: QWidget) { let native; if (parent) { native = new addon.QButtonGroup(parent.native); diff --git a/src/lib/QtWidgets/QCalendarWidget.ts b/src/lib/QtWidgets/QCalendarWidget.ts index 76b857096..82c4f026f 100644 --- a/src/lib/QtWidgets/QCalendarWidget.ts +++ b/src/lib/QtWidgets/QCalendarWidget.ts @@ -1,5 +1,5 @@ import addon from '../utils/addon'; -import { NodeWidget, QWidgetSignals } from './QWidget'; +import { QWidget, QWidgetSignals } from './QWidget'; import { NativeElement } from '../core/Component'; import { QDate } from '../QtCore/QDate'; import { DayOfWeek } from '../QtEnums'; @@ -21,10 +21,8 @@ const calendarWidget = new QCalendarWidget(); // more will follow when .selectedDate() et cetera are implemented ``` */ -export class QCalendarWidget extends NodeWidget { - constructor(); - constructor(parent: NodeWidget); - constructor(parent?: NodeWidget) { +export class QCalendarWidget extends QWidget { + constructor(parent?: QWidget) { let native: NativeElement; if (parent) { native = new addon.QCalendarWidget(parent.native); diff --git a/src/lib/QtWidgets/QCheckBox.ts b/src/lib/QtWidgets/QCheckBox.ts index 66e6a33be..8507ade5f 100644 --- a/src/lib/QtWidgets/QCheckBox.ts +++ b/src/lib/QtWidgets/QCheckBox.ts @@ -1,12 +1,12 @@ import addon from '../utils/addon'; -import { NodeWidget } from './QWidget'; +import { QWidget } from './QWidget'; import { NativeElement, NativeRawPointer, Component } from '../core/Component'; import { QAbstractButton, QAbstractButtonSignals } from './QAbstractButton'; import { checkIfNativeElement, checkIfNapiExternal } from '../utils/helpers'; import { CheckState } from '../QtEnums'; /** - + > Create and control checkbox. * **This class is a JS wrapper around Qt's [QCheckBox class](https://doc.qt.io/qt-5/qcheckbox.html)** @@ -24,9 +24,9 @@ checkbox.setText("Hello"); */ export class QCheckBox extends QAbstractButton { constructor(); - constructor(parent: NodeWidget); + constructor(parent: QWidget); constructor(rawPointer: NativeRawPointer, disableNativeDeletion?: boolean); - constructor(arg?: NodeWidget | NativeRawPointer | NativeElement, disableNativeDeletion = true) { + constructor(arg?: QWidget | NativeRawPointer | NativeElement, disableNativeDeletion = true) { let native; let parent: Component | undefined; if (checkIfNativeElement(arg)) { @@ -34,7 +34,7 @@ export class QCheckBox extends QAbstractButton { } else if (checkIfNapiExternal(arg)) { native = new addon.QCheckBox(arg, disableNativeDeletion); } else if (arg) { - const parentWidget = arg as NodeWidget; + const parentWidget = arg as QWidget; native = new addon.QCheckBox(parentWidget.native); parent = parentWidget; } else { diff --git a/src/lib/QtWidgets/QColorDialog.ts b/src/lib/QtWidgets/QColorDialog.ts index aa7c1637f..bf7bb9ee1 100644 --- a/src/lib/QtWidgets/QColorDialog.ts +++ b/src/lib/QtWidgets/QColorDialog.ts @@ -1,5 +1,5 @@ import addon from '../utils/addon'; -import { NodeWidget } from './QWidget'; +import { QWidget } from './QWidget'; import { NativeElement } from '../core/Component'; import { NodeDialog, QDialogSignals } from './QDialog'; import { QColor } from '../QtGui/QColor'; @@ -27,9 +27,7 @@ console.log(color.red(), color.green(), color.blue()); ``` */ export class QColorDialog extends NodeDialog { - constructor(); - constructor(parent: NodeWidget); - constructor(parent?: NodeWidget) { + constructor(parent?: QWidget) { let native: NativeElement; if (parent) { native = new addon.QColorDialog(parent.native); diff --git a/src/lib/QtWidgets/QComboBox.ts b/src/lib/QtWidgets/QComboBox.ts index 2b7788993..f25812da8 100644 --- a/src/lib/QtWidgets/QComboBox.ts +++ b/src/lib/QtWidgets/QComboBox.ts @@ -1,5 +1,5 @@ import addon from '../utils/addon'; -import { NodeWidget, QWidgetSignals } from './QWidget'; +import { QWidget, QWidgetSignals } from './QWidget'; import { NativeElement } from '../core/Component'; import { SizeAdjustPolicy } from '../QtEnums'; import { QIcon } from '../QtGui/QIcon'; @@ -36,10 +36,8 @@ comboBox.addEventListener('currentIndexChanged', (index) => { }); ``` */ -export class QComboBox extends NodeWidget { - constructor(); - constructor(parent: NodeWidget); - constructor(parent?: NodeWidget) { +export class QComboBox extends QWidget { + constructor(parent?: QWidget) { let native: NativeElement; if (parent) { native = new addon.QComboBox(parent.native); diff --git a/src/lib/QtWidgets/QDateEdit.ts b/src/lib/QtWidgets/QDateEdit.ts index 1b67f0d63..faf9b4766 100644 --- a/src/lib/QtWidgets/QDateEdit.ts +++ b/src/lib/QtWidgets/QDateEdit.ts @@ -1,10 +1,10 @@ import addon from '../utils/addon'; -import { NodeWidget } from './QWidget'; +import { QWidget } from './QWidget'; import { NativeElement } from '../core/Component'; import { NodeDateTimeEdit } from './QDateTimeEdit'; /** - + > Creates a widget to edit dates with spin box layout. WIP! * **This class is a JS wrapper around Qt's [QDateEdit class](https://doc.qt.io/qt-5/qdateedit.html)** @@ -21,9 +21,7 @@ const dateEdit = new QDateEdit(); ``` */ export class QDateEdit extends NodeDateTimeEdit { - constructor(); - constructor(parent: NodeWidget); - constructor(parent?: NodeWidget) { + constructor(parent?: QWidget) { let native: NativeElement; if (parent) { native = new addon.QDateEdit(parent.native); diff --git a/src/lib/QtWidgets/QDateTimeEdit.ts b/src/lib/QtWidgets/QDateTimeEdit.ts index 2183cec62..c93c40d79 100644 --- a/src/lib/QtWidgets/QDateTimeEdit.ts +++ b/src/lib/QtWidgets/QDateTimeEdit.ts @@ -1,5 +1,5 @@ import addon from '../utils/addon'; -import { NodeWidget } from './QWidget'; +import { QWidget } from './QWidget'; import { QAbstractSpinBox, QAbstractSpinBoxSignals } from './QAbstractSpinBox'; import { QCalendarWidget } from './QCalendarWidget'; import { QDate } from '../QtCore/QDate'; @@ -62,7 +62,7 @@ export abstract class NodeDateTimeEdit extends QAbstractSpinBox Creates and controls a widget for editing dates and times with spin box layout. * **This class is a JS wrapper around Qt's [QDateTimeEdit class](https://doc.qt.io/qt-5/qdatetimeedit.html)** @@ -85,9 +85,7 @@ dateTimeEdit.setTime(time); ``` */ export class QDateTimeEdit extends NodeDateTimeEdit { - constructor(); - constructor(parent: NodeWidget); - constructor(parent?: NodeWidget) { + constructor(parent?: QWidget) { let native; if (parent) { native = new addon.QDateTimeEdit(parent.native); diff --git a/src/lib/QtWidgets/QDial.ts b/src/lib/QtWidgets/QDial.ts index 6ba0112a0..5fa4c8abd 100644 --- a/src/lib/QtWidgets/QDial.ts +++ b/src/lib/QtWidgets/QDial.ts @@ -1,10 +1,10 @@ import addon from '../utils/addon'; -import { NodeWidget } from './QWidget'; +import { QWidget } from './QWidget'; import { NativeElement } from '../core/Component'; import { QAbstractSlider, QAbstractSliderSignals } from './QAbstractSlider'; /** - + > Create and control dial slider widgets. * **This class is a JS wrapper around Qt's [QDial class](https://doc.qt.io/qt-5/qdial.html)** @@ -21,8 +21,8 @@ const dial = new QDial(); */ export class QDial extends QAbstractSlider { constructor(); - constructor(parent: NodeWidget); - constructor(parent?: NodeWidget) { + constructor(parent: QWidget); + constructor(parent?: QWidget) { let native: NativeElement; if (parent) { native = new addon.QDial(parent.native); diff --git a/src/lib/QtWidgets/QDialog.ts b/src/lib/QtWidgets/QDialog.ts index dc6f41bf8..9ef4d2eaa 100644 --- a/src/lib/QtWidgets/QDialog.ts +++ b/src/lib/QtWidgets/QDialog.ts @@ -2,12 +2,12 @@ import addon from '../utils/addon'; import { NativeElement } from '../core/Component'; import { checkIfNativeElement } from '../utils/helpers'; -import { NodeWidget, QWidgetSignals } from './QWidget'; +import { QWidget, QWidgetSignals } from './QWidget'; import { DialogCode } from '../QtEnums'; // All Dialogs should extend from NodeDialog // Implement all native QDialog methods here so that all dialogs get access to those aswell -export abstract class NodeDialog extends NodeWidget { +export abstract class NodeDialog extends QWidget { setResult(i: number): void { this.native.setResult(i); } @@ -35,7 +35,7 @@ export abstract class NodeDialog extends NodeWid } /** - + > This is the base class of dialog windows. * **This class is a JS wrapper around Qt's [QDialog class](https://doc.qt.io/qt-5/qdialog.html)** diff --git a/src/lib/QtWidgets/QDoubleSpinBox.ts b/src/lib/QtWidgets/QDoubleSpinBox.ts index d3d194724..589c96805 100644 --- a/src/lib/QtWidgets/QDoubleSpinBox.ts +++ b/src/lib/QtWidgets/QDoubleSpinBox.ts @@ -1,10 +1,10 @@ import addon from '../utils/addon'; -import { NodeWidget } from './QWidget'; +import { QWidget } from './QWidget'; import { NativeElement } from '../core/Component'; import { QAbstractSpinBox, QAbstractSpinBoxSignals, StepType } from './QAbstractSpinBox'; /** - + > Create and control double spin box widgets. * **This class is a JS wrapper around Qt's [QDoubleSpinBox class](https://doc.qt.io/qt-5/qdoublespinbox.html)** @@ -20,9 +20,7 @@ const doublespinBox = new QDoubleSpinBox(); ``` */ export class QDoubleSpinBox extends QAbstractSpinBox { - constructor(); - constructor(parent: NodeWidget); - constructor(parent?: NodeWidget) { + constructor(parent?: QWidget) { let native: NativeElement; if (parent) { native = new addon.QDoubleSpinBox(parent.native); diff --git a/src/lib/QtWidgets/QErrorMessage.ts b/src/lib/QtWidgets/QErrorMessage.ts index 073df1e1d..1c2dcbe0e 100644 --- a/src/lib/QtWidgets/QErrorMessage.ts +++ b/src/lib/QtWidgets/QErrorMessage.ts @@ -1,10 +1,10 @@ import addon from '../utils/addon'; -import { NodeWidget } from './QWidget'; +import { QWidget } from './QWidget'; import { NativeElement } from '../core/Component'; import { NodeDialog, QDialogSignals } from './QDialog'; /** - + > Create and control error message dialogs. * **This class is a JS wrapper around Qt's [QErrorMessage class](https://doc.qt.io/qt-5/qerrormessage.html)** @@ -21,9 +21,7 @@ const errorMessage = new QErrorMessage(); ``` */ export class QErrorMessage extends NodeDialog { - constructor(); - constructor(parent: NodeWidget); - constructor(parent?: NodeWidget) { + constructor(parent?: QWidget) { let native: NativeElement; if (parent) { native = new addon.QErrorMessage(parent.native); diff --git a/src/lib/QtWidgets/QFileDialog.ts b/src/lib/QtWidgets/QFileDialog.ts index 7954a9b76..cfc77dbf7 100644 --- a/src/lib/QtWidgets/QFileDialog.ts +++ b/src/lib/QtWidgets/QFileDialog.ts @@ -1,5 +1,5 @@ import addon from '../utils/addon'; -import { NodeWidget } from './QWidget'; +import { QWidget } from './QWidget'; import { NativeElement } from '../core/Component'; import { AcceptMode, DialogLabel, FileMode, Option, ViewMode } from '../QtEnums'; import { NodeDialog, QDialogSignals } from './QDialog'; @@ -29,8 +29,8 @@ console.log(selectedFiles); */ export class QFileDialog extends NodeDialog { constructor(); - constructor(parent: NodeWidget, caption?: string, directory?: string, filter?: string); - constructor(parent?: NodeWidget, caption = 'Select File', directory = '', filter = '') { + constructor(parent: QWidget, caption?: string, directory?: string, filter?: string); + constructor(parent?: QWidget, caption = 'Select File', directory = '', filter = '') { let native: NativeElement; if (parent) { native = new addon.QFileDialog(parent.native, caption, directory, filter); diff --git a/src/lib/QtWidgets/QFontDialog.ts b/src/lib/QtWidgets/QFontDialog.ts index ad6ec76cd..9bc642adf 100644 --- a/src/lib/QtWidgets/QFontDialog.ts +++ b/src/lib/QtWidgets/QFontDialog.ts @@ -1,11 +1,11 @@ import addon from '../utils/addon'; -import { NodeWidget } from './QWidget'; +import { QWidget } from './QWidget'; import { NativeElement } from '../core/Component'; import { NodeDialog, QDialogSignals } from './QDialog'; import { QFont } from '../QtGui/QFont'; /** - + > Create and control font dialogs. * **This class is a JS wrapper around Qt's [QFontDialog class](https://doc.qt.io/qt-5/qfontdialog.html)** @@ -25,9 +25,7 @@ console.log(font); ``` */ export class QFontDialog extends NodeDialog { - constructor(); - constructor(parent: NodeWidget); - constructor(parent?: NodeWidget) { + constructor(parent?: QWidget) { let native: NativeElement; if (parent) { native = new addon.QFontDialog(parent.native); diff --git a/src/lib/QtWidgets/QFrame.ts b/src/lib/QtWidgets/QFrame.ts index 69a69dcbb..a292c2c7f 100644 --- a/src/lib/QtWidgets/QFrame.ts +++ b/src/lib/QtWidgets/QFrame.ts @@ -1,10 +1,10 @@ import addon from '../utils/addon'; -import { NodeWidget, QWidgetSignals } from './QWidget'; +import { QWidget, QWidgetSignals } from './QWidget'; import { NativeElement } from '../core/Component'; import { checkIfNativeElement } from '../utils/helpers'; import { QRect } from '../QtCore/QRect'; -export abstract class NodeFrame extends NodeWidget { +export abstract class NodeFrame extends QWidget { setFrameRect(r: QRect): void { this.setProperty('frameRect', r.native); } @@ -80,13 +80,13 @@ const frame = new QFrame(); ``` */ export class QFrame extends NodeFrame { - constructor(arg?: NodeWidget | NativeElement) { + constructor(arg?: QWidget | NativeElement) { let native: NativeElement; let parent; if (checkIfNativeElement(arg)) { native = arg as NativeElement; - } else if (arg as NodeWidget) { - parent = arg as NodeWidget; + } else if (arg as QWidget) { + parent = arg as QWidget; native = new addon.QFrame(parent.native); } else { native = new addon.QFrame(); diff --git a/src/lib/QtWidgets/QGridLayout.ts b/src/lib/QtWidgets/QGridLayout.ts index c5a6ca729..d2bbe1fd4 100644 --- a/src/lib/QtWidgets/QGridLayout.ts +++ b/src/lib/QtWidgets/QGridLayout.ts @@ -1,5 +1,5 @@ import addon from '../utils/addon'; -import { NodeWidget } from './QWidget'; +import { QWidget } from './QWidget'; import { NodeLayout, QLayoutSignals } from './QLayout'; import { NativeElement } from '../core/Component'; import { AlignmentFlag } from '../QtEnums'; @@ -30,9 +30,7 @@ layout.addWidget(label2); */ export class QGridLayout extends NodeLayout { - constructor(); - constructor(parent: NodeWidget); - constructor(parent?: NodeWidget) { + constructor(parent?: QWidget) { let native: NativeElement; if (parent) { native = new addon.QGridLayout(parent.native); @@ -54,11 +52,11 @@ export class QGridLayout extends NodeLayout { this.native.addLayout(layout.native, row, column, rowSpan, columnSpan, alignment); } - addWidget(widget: NodeWidget, row = 0, col = 0, rowSpan = 1, colSpan = 1, alignment: AlignmentFlag = 0): void { + addWidget(widget: QWidget, row = 0, col = 0, rowSpan = 1, colSpan = 1, alignment: AlignmentFlag = 0): void { this.native.addWidget(widget.native, row, col, rowSpan, colSpan, alignment); this.nodeChildren.add(widget); } - removeWidget(widget: NodeWidget): void { + removeWidget(widget: QWidget): void { this.native.removeWidget(widget.native); this.nodeChildren.delete(widget); } diff --git a/src/lib/QtWidgets/QGroupBox.ts b/src/lib/QtWidgets/QGroupBox.ts index 50f91e966..13f590a32 100644 --- a/src/lib/QtWidgets/QGroupBox.ts +++ b/src/lib/QtWidgets/QGroupBox.ts @@ -1,10 +1,10 @@ import addon from '../utils/addon'; -import { NodeWidget, QWidgetSignals } from './QWidget'; +import { QWidget, QWidgetSignals } from './QWidget'; import { NativeElement } from '../core/Component'; import { AlignmentFlag } from '../QtEnums/AlignmentFlag'; /** - + > Create and control a group of checkboxes including a title. * **This class is a JS wrapper around Qt's [QGroupBox class](https://doc.qt.io/qt-5/qgroupbox.html)** @@ -39,10 +39,8 @@ win.show(); (global as any).win = win; ``` */ -export class QGroupBox extends NodeWidget { - constructor(); - constructor(parent: NodeWidget); - constructor(parent?: NodeWidget) { +export class QGroupBox extends QWidget { + constructor(parent?: QWidget) { let native: NativeElement; if (parent) { native = new addon.QGroupBox(parent.native); diff --git a/src/lib/QtWidgets/QHeaderView.ts b/src/lib/QtWidgets/QHeaderView.ts index 3f8131688..28d7b662f 100644 --- a/src/lib/QtWidgets/QHeaderView.ts +++ b/src/lib/QtWidgets/QHeaderView.ts @@ -1,5 +1,5 @@ import addon from '../utils/addon'; -import { NodeWidget } from './QWidget'; +import { QWidget } from './QWidget'; import { NativeElement } from '../core/Component'; import { QAbstractItemView, QAbstractItemViewSignals } from './QAbstractItemView'; import { AlignmentFlag, checkIfNativeElement, Orientation, QPoint, SortOrder } from '../..'; @@ -205,7 +205,7 @@ export abstract class NodeHeaderView extends } export class QHeaderView extends NodeHeaderView { - constructor(orientationOrNative: Orientation | NativeElement, parent: NodeWidget | null = null) { + constructor(orientationOrNative: Orientation | NativeElement, parent: QWidget | null = null) { let native: NativeElement; if (checkIfNativeElement(orientationOrNative)) { native = orientationOrNative as NativeElement; diff --git a/src/lib/QtWidgets/QInputDialog.ts b/src/lib/QtWidgets/QInputDialog.ts index dc8207d30..b40620df4 100644 --- a/src/lib/QtWidgets/QInputDialog.ts +++ b/src/lib/QtWidgets/QInputDialog.ts @@ -1,5 +1,5 @@ import addon from '../utils/addon'; -import { NodeWidget } from './QWidget'; +import { QWidget } from './QWidget'; import { NodeDialog, QDialogSignals } from './QDialog'; import { EchoMode } from './QLineEdit'; @@ -22,7 +22,7 @@ dialog.exec(); ``` */ export class QInputDialog extends NodeDialog { - constructor(parent?: NodeWidget) { + constructor(parent?: QWidget) { let native; if (parent) { native = new addon.QInputDialog(parent.native); diff --git a/src/lib/QtWidgets/QLCDNumber.ts b/src/lib/QtWidgets/QLCDNumber.ts index 8e9d08a59..79ee70293 100644 --- a/src/lib/QtWidgets/QLCDNumber.ts +++ b/src/lib/QtWidgets/QLCDNumber.ts @@ -1,5 +1,5 @@ import addon from '../utils/addon'; -import { NodeWidget, QWidgetSignals } from './QWidget'; +import { QWidget, QWidgetSignals } from './QWidget'; /** @@ -19,8 +19,8 @@ const lcd = new QLCDNumber(); ``` */ -export class QLCDNumber extends NodeWidget { - constructor(parent?: NodeWidget) { +export class QLCDNumber extends QWidget { + constructor(parent?: QWidget) { let native; if (parent) { native = new addon.QLCDNumber(parent.native); diff --git a/src/lib/QtWidgets/QLabel.ts b/src/lib/QtWidgets/QLabel.ts index c15337288..66f10ff15 100644 --- a/src/lib/QtWidgets/QLabel.ts +++ b/src/lib/QtWidgets/QLabel.ts @@ -1,5 +1,5 @@ import addon from '../utils/addon'; -import { NodeWidget } from './QWidget'; +import { QWidget } from './QWidget'; import { NodeFrame, QFrameSignals } from './QFrame'; import { QPixmap } from '../QtGui/QPixmap'; import { QMovie } from '../QtGui/QMovie'; @@ -30,9 +30,9 @@ export class QLabel extends NodeFrame { private _picture?: QPicture; private _pixmap?: QPixmap; private _movie?: QMovie; - private _buddy?: NodeWidget | null; + private _buddy?: QWidget | null; - constructor(parent?: NodeWidget) { + constructor(parent?: QWidget) { let native; if (parent) { native = new addon.QLabel(parent.native); @@ -108,11 +108,11 @@ export class QLabel extends NodeFrame { selectionStart(): number { return this.native.selectionStart(); } - setBuddy(buddy: NodeWidget): void { + setBuddy(buddy: QWidget): void { this.native.setBuddy(buddy.native); this._buddy = buddy; } - buddy(): NodeWidget | null { + buddy(): QWidget | null { if (this._buddy) { return this._buddy; } diff --git a/src/lib/QtWidgets/QLayout.ts b/src/lib/QtWidgets/QLayout.ts index 734ffe13e..ec0879526 100644 --- a/src/lib/QtWidgets/QLayout.ts +++ b/src/lib/QtWidgets/QLayout.ts @@ -1,4 +1,4 @@ -import { NodeWidget } from './QWidget'; +import { QWidget } from './QWidget'; import { QObject, QObjectSignals } from '../QtCore/QObject'; // All Layouts should extend this abstract class. @@ -16,7 +16,6 @@ import { QObject, QObjectSignals } from '../QtCore/QObject'; ```javascript const { NodeLayout, - NodeWidget, FlexLayout, GridLayout, QPushButton, @@ -24,7 +23,7 @@ const { } = require("@nodegui/nodegui"); // addChildToLayout can accept any layout since it expects NodeLayout -const addChildToLayout = (layout: NodeLayout, widget: NodeWidget) => { +const addChildToLayout = (layout: NodeLayout, widget: QWidget) => { layout.addWidget(widget); }; @@ -34,8 +33,8 @@ addChildToLayout(new GridLayout(), new QWidget()); */ export abstract class NodeLayout extends QObject { type = 'layout'; - abstract addWidget(childWidget: NodeWidget, ...args: any[]): void; - abstract removeWidget(childWidget: NodeWidget): void; + abstract addWidget(childWidget: QWidget, ...args: any[]): void; + abstract removeWidget(childWidget: QWidget): void; setSizeConstraint(constraint: SizeConstraint): void { this.setProperty('sizeConstraint', constraint); } diff --git a/src/lib/QtWidgets/QLineEdit.ts b/src/lib/QtWidgets/QLineEdit.ts index ec49056f6..9fb2bc46d 100644 --- a/src/lib/QtWidgets/QLineEdit.ts +++ b/src/lib/QtWidgets/QLineEdit.ts @@ -1,5 +1,5 @@ import addon from '../utils/addon'; -import { NodeWidget, QWidgetSignals } from './QWidget'; +import { QWidget, QWidgetSignals } from './QWidget'; import { AlignmentFlag } from '../QtEnums/AlignmentFlag'; import { CursorMoveStyle } from '../QtEnums/CursorMoveStyle'; import { QPoint } from '../QtCore/QPoint'; @@ -21,8 +21,8 @@ const lineEdit = new QLineEdit(); ``` */ -export class QLineEdit extends NodeWidget { - constructor(parent?: NodeWidget) { +export class QLineEdit extends QWidget { + constructor(parent?: QWidget) { let native; if (parent) { native = new addon.QLineEdit(parent.native); diff --git a/src/lib/QtWidgets/QListView.ts b/src/lib/QtWidgets/QListView.ts index d0649d919..618d36848 100644 --- a/src/lib/QtWidgets/QListView.ts +++ b/src/lib/QtWidgets/QListView.ts @@ -1,12 +1,12 @@ import addon from '../utils/addon'; -import { NodeWidget } from './QWidget'; +import { QWidget } from './QWidget'; import { NativeElement } from '../core/Component'; import { QAbstractItemView, QAbstractItemViewSignals } from './QAbstractItemView'; import { QSize } from '../QtCore/QSize'; import { AlignmentFlag } from '../..'; /** - + > The QListView class provides a list or icon view onto a model. * **This class is a JS wrapper around Qt's [QListView class](https://doc.qt.io/qt-5/qlistview.html)** @@ -144,9 +144,7 @@ export enum ListViewMode { } export class QListView extends NodeListView { - constructor(); - constructor(parent: NodeWidget); - constructor(parent?: NodeWidget) { + constructor(parent?: QWidget) { let native: NativeElement; if (parent) { native = new addon.QListView(parent.native); diff --git a/src/lib/QtWidgets/QListWidget.ts b/src/lib/QtWidgets/QListWidget.ts index ed67a3015..858e299b5 100644 --- a/src/lib/QtWidgets/QListWidget.ts +++ b/src/lib/QtWidgets/QListWidget.ts @@ -1,5 +1,5 @@ import addon from '../utils/addon'; -import { NodeWidget, QWidget } from './QWidget'; +import { QWidget } from './QWidget'; import { NativeElement, Component } from '../core/Component'; import { QListWidgetItem } from './QListWidgetItem'; import { NodeListView, QListViewSignals } from './QListView'; @@ -35,7 +35,7 @@ for (let i = 0; i < 30; i++) { export class QListWidget extends NodeListView { items: Set; - constructor(parent?: NodeWidget) { + constructor(parent?: QWidget) { let native; if (parent) { native = new addon.QListWidget(parent.native); @@ -132,7 +132,7 @@ export class QListWidget extends NodeListView { setCurrentItem(item: QListWidgetItem): void { this.native.setCurrentItem(item.native); } - setItemWidget(item: QListWidgetItem, widget: NodeWidget): void { + setItemWidget(item: QListWidgetItem, widget: QWidget): void { this.native.setItemWidget(item.native, widget.native); } sortItems(order = SortOrder.AscendingOrder): void { diff --git a/src/lib/QtWidgets/QMainWindow.ts b/src/lib/QtWidgets/QMainWindow.ts index c5e1734ff..f782508c5 100644 --- a/src/lib/QtWidgets/QMainWindow.ts +++ b/src/lib/QtWidgets/QMainWindow.ts @@ -1,5 +1,5 @@ import addon from '../utils/addon'; -import { NodeWidget, QWidgetSignals } from './QWidget'; +import { QWidget, QWidgetSignals } from './QWidget'; import { NodeLayout } from './QLayout'; import { QMenuBar } from './QMenuBar'; import { QStatusBar } from './QStatusBar'; @@ -31,14 +31,12 @@ global.win = win; // prevent's gc of win QMainWindow needs to have a central widget set before other widgets can be added as a children/nested children. Once a central widget is set you can add children/layout to the central widget. */ -export class QMainWindow extends NodeWidget { - public centralWidget?: NodeWidget | null; +export class QMainWindow extends QWidget { + public centralWidget?: QWidget | null; private _menuBar?: QMenuBar; private _statusBar?: QStatusBar | null; - constructor(); - constructor(parent: NodeWidget); - constructor(parent?: NodeWidget) { + constructor(parent?: QWidget) { let native: NativeElement; if (parent) { native = new addon.QMainWindow(parent.native); @@ -57,12 +55,12 @@ export class QMainWindow extends NodeWidget { } }; } - setCentralWidget(widget: NodeWidget): void { + setCentralWidget(widget: QWidget): void { this.native.setCentralWidget(widget.native); this.centralWidget = widget; this.centralWidget.setFlexNodeSizeControlled(true); } - takeCentralWidget(): NodeWidget | null { + takeCentralWidget(): QWidget | null { const centralWidget = this.centralWidget; this.centralWidget = null; if (centralWidget) { @@ -79,7 +77,7 @@ export class QMainWindow extends NodeWidget { menuBar(): QMenuBar | undefined { return this._menuBar; } - setMenuWidget(menuWidget: NodeWidget): void { + setMenuWidget(menuWidget: QWidget): void { this.native.setMenuWidget(menuWidget.native); } get layout(): NodeLayout | undefined { diff --git a/src/lib/QtWidgets/QMenu.ts b/src/lib/QtWidgets/QMenu.ts index 9211708eb..c9569ed06 100644 --- a/src/lib/QtWidgets/QMenu.ts +++ b/src/lib/QtWidgets/QMenu.ts @@ -1,5 +1,5 @@ import { NativeElement } from '../core/Component'; -import { NodeWidget, QWidgetSignals } from './QWidget'; +import { QWidget, QWidgetSignals } from './QWidget'; import addon from '../utils/addon'; import { QAction } from './QAction'; import { QPoint } from '../QtCore/QPoint'; @@ -18,8 +18,8 @@ const { QMenu } = require("@nodegui/nodegui"); const menu = new QMenu(); ``` */ -export class QMenu extends NodeWidget { - constructor(parent?: NodeWidget) { +export class QMenu extends QWidget { + constructor(parent?: QWidget) { let native; if (parent) { native = new addon.QMenu(parent.native); diff --git a/src/lib/QtWidgets/QMenuBar.ts b/src/lib/QtWidgets/QMenuBar.ts index b82305c57..e74e0c779 100644 --- a/src/lib/QtWidgets/QMenuBar.ts +++ b/src/lib/QtWidgets/QMenuBar.ts @@ -1,6 +1,6 @@ import { QMenu } from './QMenu'; import { NativeElement } from '../core/Component'; -import { NodeWidget, QWidgetSignals } from './QWidget'; +import { QWidget, QWidgetSignals } from './QWidget'; import addon from '../utils/addon'; import { checkIfNativeElement } from '../utils/helpers'; import { QAction } from './QAction'; @@ -23,17 +23,17 @@ win.show(); global.win = win; ``` */ -export class QMenuBar extends NodeWidget { +export class QMenuBar extends QWidget { _menus: Set; - constructor(arg?: NodeWidget | NativeElement) { + constructor(arg?: QWidget | NativeElement) { let native; let parent; if (checkIfNativeElement(arg)) { native = arg as NativeElement; } else if (typeof arg === 'object') { native = new addon.QMenuBar(arg.native); - parent = arg as NodeWidget; + parent = arg as QWidget; } else { native = new addon.QMenuBar(); } diff --git a/src/lib/QtWidgets/QMessageBox.ts b/src/lib/QtWidgets/QMessageBox.ts index 4fb4cc5ee..7531842f4 100644 --- a/src/lib/QtWidgets/QMessageBox.ts +++ b/src/lib/QtWidgets/QMessageBox.ts @@ -1,5 +1,5 @@ import addon from '../utils/addon'; -import { NodeWidget } from './QWidget'; +import { QWidget } from './QWidget'; import { NativeRawPointer } from '../core/Component'; import { NodeDialog, QDialogSignals } from './QDialog'; import { QAbstractButton, QAbstractButtonSignals } from './QAbstractButton'; @@ -40,7 +40,7 @@ messageBox.exec(); ``` */ export class QMessageBox extends NodeDialog { - constructor(parent?: NodeWidget) { + constructor(parent?: QWidget) { let native; if (parent) { native = new addon.QMessageBox(parent.native); @@ -86,11 +86,11 @@ export class QMessageBox extends NodeDialog { this.nodeChildren.add(button); } - static about(parent: NodeWidget, title: string, text: string): void { + static about(parent: QWidget, title: string, text: string): void { addon.QMessageBox.about(parent.native, title, text); } - static aboutQt(parent: NodeWidget, title: string): void { + static aboutQt(parent: QWidget, title: string): void { addon.QMessageBox.aboutQt(parent.native, title); } } diff --git a/src/lib/QtWidgets/QPlainTextEdit.ts b/src/lib/QtWidgets/QPlainTextEdit.ts index dd024c846..a620ab5b0 100644 --- a/src/lib/QtWidgets/QPlainTextEdit.ts +++ b/src/lib/QtWidgets/QPlainTextEdit.ts @@ -1,5 +1,5 @@ import addon from '../utils/addon'; -import { NodeWidget } from './QWidget'; +import { QWidget } from './QWidget'; import { NativeElement } from '../core/Component'; import { QAbstractScrollArea, QAbstractScrollAreaSignals } from './QAbstractScrollArea'; import { QTextOptionWrapMode } from '../QtGui/QTextOption'; @@ -16,7 +16,7 @@ export interface QPlainTextEditSignals extends QAbstractScrollAreaSignals { } /** - + > Used to edit and display plain text. * **This class is a JS wrapper around Qt's [QPlainTextEdit class](https://doc.qt.io/qt-5/qplaintextedit.html)** @@ -33,7 +33,7 @@ const plainTextEdit = new QPlainTextEdit(); */ export class QPlainTextEdit extends QAbstractScrollArea { placeholderText?: string; - constructor(parent?: NodeWidget) { + constructor(parent?: QWidget) { let native: NativeElement; if (parent) { native = new addon.QPlainTextEdit(parent.native); diff --git a/src/lib/QtWidgets/QProgressBar.ts b/src/lib/QtWidgets/QProgressBar.ts index 0f60d9b14..c075e28a1 100644 --- a/src/lib/QtWidgets/QProgressBar.ts +++ b/src/lib/QtWidgets/QProgressBar.ts @@ -1,10 +1,10 @@ import addon from '../utils/addon'; -import { NodeWidget, QWidgetSignals } from './QWidget'; +import { QWidget, QWidgetSignals } from './QWidget'; import { NativeElement } from '../core/Component'; import { Orientation, AlignmentFlag } from '../QtEnums'; /** - + > Create and control progress bar widgets. * **This class is a JS wrapper around Qt's [QProgressBar class](https://doc.qt.io/qt-5/qprogressbar.html)** @@ -19,8 +19,8 @@ const { QProgressBar } = require("@nodegui/nodegui"); const progressBar = new QProgressBar(); ``` */ -export class QProgressBar extends NodeWidget { - constructor(parent?: NodeWidget) { +export class QProgressBar extends QWidget { + constructor(parent?: QWidget) { let native: NativeElement; if (parent) { native = new addon.QProgressBar(parent.native); diff --git a/src/lib/QtWidgets/QProgressDialog.ts b/src/lib/QtWidgets/QProgressDialog.ts index 9fd608f49..d21bc5274 100644 --- a/src/lib/QtWidgets/QProgressDialog.ts +++ b/src/lib/QtWidgets/QProgressDialog.ts @@ -1,5 +1,5 @@ import addon from '../utils/addon'; -import { NodeWidget } from './QWidget'; +import { QWidget } from './QWidget'; import { NodeDialog, QDialogSignals } from './QDialog'; /** @@ -20,7 +20,7 @@ const progressDialog = new QProgressDialog(); ``` */ export class QProgressDialog extends NodeDialog { - constructor(parent?: NodeWidget) { + constructor(parent?: QWidget) { let native; if (parent) { native = new addon.QProgressDialog(parent.native); diff --git a/src/lib/QtWidgets/QPushButton.ts b/src/lib/QtWidgets/QPushButton.ts index 8c591e030..dcdf7b724 100644 --- a/src/lib/QtWidgets/QPushButton.ts +++ b/src/lib/QtWidgets/QPushButton.ts @@ -1,5 +1,5 @@ import addon from '../utils/addon'; -import { NodeWidget } from './QWidget'; +import { QWidget } from './QWidget'; import { NativeElement, NativeRawPointer, Component } from '../core/Component'; import { QAbstractButton, QAbstractButtonSignals } from './QAbstractButton'; import { checkIfNativeElement, checkIfNapiExternal } from '../utils/helpers'; @@ -25,7 +25,7 @@ button.setText("Hello"); export class QPushButton extends QAbstractButton { private _menu?: QMenu | null; - constructor(arg?: NodeWidget | NativeRawPointer | NativeElement, disableNativeDeletion = true) { + constructor(arg?: QWidget | NativeRawPointer | NativeElement, disableNativeDeletion = true) { let native; let parent: Component | undefined; if (checkIfNativeElement(arg)) { @@ -33,7 +33,7 @@ export class QPushButton extends QAbstractButton { } else if (checkIfNapiExternal(arg)) { native = new addon.QPushButton(arg, disableNativeDeletion); } else if (arg) { - const parentWidget = arg as NodeWidget; + const parentWidget = arg as QWidget; native = new addon.QPushButton(parentWidget.native); parent = parentWidget; } else { diff --git a/src/lib/QtWidgets/QRadioButton.ts b/src/lib/QtWidgets/QRadioButton.ts index 6813c63ad..a274eac9c 100644 --- a/src/lib/QtWidgets/QRadioButton.ts +++ b/src/lib/QtWidgets/QRadioButton.ts @@ -1,5 +1,5 @@ import addon from '../utils/addon'; -import { NodeWidget } from './QWidget'; +import { QWidget } from './QWidget'; import { NativeElement, NativeRawPointer, Component } from '../core/Component'; import { QAbstractButton, QAbstractButtonSignals } from './QAbstractButton'; import { checkIfNativeElement, checkIfNapiExternal } from '../utils/helpers'; @@ -23,7 +23,7 @@ radioButton.setText("Hello"); */ export class QRadioButton extends QAbstractButton { - constructor(arg?: NodeWidget | NativeRawPointer | NativeElement, disableNativeDeletion = true) { + constructor(arg?: QWidget | NativeRawPointer | NativeElement, disableNativeDeletion = true) { let native; let parent: Component | undefined; if (checkIfNativeElement(arg)) { @@ -31,7 +31,7 @@ export class QRadioButton extends QAbstractButton { } else if (checkIfNapiExternal(arg)) { native = new addon.QRadioButton(arg, disableNativeDeletion); } else if (arg) { - const parentWidget = arg as NodeWidget; + const parentWidget = arg as QWidget; native = new addon.QRadioButton(parentWidget.native); parent = parentWidget; } else { diff --git a/src/lib/QtWidgets/QScrollArea.ts b/src/lib/QtWidgets/QScrollArea.ts index e91d2fdf7..c601bd83f 100644 --- a/src/lib/QtWidgets/QScrollArea.ts +++ b/src/lib/QtWidgets/QScrollArea.ts @@ -1,5 +1,5 @@ import addon from '../utils/addon'; -import { NodeWidget } from './QWidget'; +import { QWidget } from './QWidget'; import { NativeElement } from '../core/Component'; import { QAbstractScrollArea, QAbstractScrollAreaSignals } from './QAbstractScrollArea'; import { AlignmentFlag } from '../QtEnums'; @@ -29,8 +29,8 @@ scrollArea.setWidget(imageLabel); ``` */ export class QScrollArea extends QAbstractScrollArea { - contentWidget?: NodeWidget | null; - constructor(parent?: NodeWidget) { + contentWidget?: QWidget | null; + constructor(parent?: QWidget) { let native: NativeElement; if (parent) { native = new addon.QScrollArea(parent.native); @@ -55,20 +55,20 @@ export class QScrollArea extends QAbstractScrollArea { ensureVisible(x: number, y: number, xmargin = 50, ymargin = 50): void { this.native.ensureVisible(x, y, xmargin, ymargin); } - ensureWidgetVisible(childWidget: NodeWidget, xmargin = 50, ymargin = 50): void { + ensureWidgetVisible(childWidget: QWidget, xmargin = 50, ymargin = 50): void { this.native.ensureWidgetVisible(childWidget.native, xmargin, ymargin); } - setWidget(widget: NodeWidget): void { + setWidget(widget: QWidget): void { this.contentWidget = widget; this.native.setWidget(widget.native); } - widget(): NodeWidget | null { + widget(): QWidget | null { if (this.contentWidget) { return this.contentWidget; } return null; } - takeWidget(): NodeWidget | null { + takeWidget(): QWidget | null { // react:✓ const contentWidget = this.contentWidget; this.contentWidget = null; diff --git a/src/lib/QtWidgets/QScrollBar.ts b/src/lib/QtWidgets/QScrollBar.ts index d8b150503..36083d2f7 100644 --- a/src/lib/QtWidgets/QScrollBar.ts +++ b/src/lib/QtWidgets/QScrollBar.ts @@ -1,5 +1,5 @@ import addon from '../utils/addon'; -import { NodeWidget } from './QWidget'; +import { QWidget } from './QWidget'; import { NativeElement } from '../core/Component'; import { QAbstractSlider, QAbstractSliderSignals } from './QAbstractSlider'; @@ -20,7 +20,7 @@ const scrollbar = new QScrollBar(); ``` */ export class QScrollBar extends QAbstractSlider { - constructor(parent?: NodeWidget) { + constructor(parent?: QWidget) { let native: NativeElement; if (parent) { native = new addon.QScrollBar(parent.native); diff --git a/src/lib/QtWidgets/QShortcut.ts b/src/lib/QtWidgets/QShortcut.ts index 32e306ab0..c1d9581c2 100644 --- a/src/lib/QtWidgets/QShortcut.ts +++ b/src/lib/QtWidgets/QShortcut.ts @@ -1,11 +1,11 @@ import addon from '../utils/addon'; -import { NodeWidget } from './QWidget'; +import { QWidget } from './QWidget'; import { QKeySequence } from '../QtGui/QKeySequence'; import { ShortcutContext } from '../QtEnums'; import { QObject, QObjectSignals } from '../QtCore/QObject'; /** - + > The QShortcut class is used to create keyboard shortcuts. * **This class is a JS wrapper around Qt's [QShortcut class](https://doc.qt.io/qt-5/qshortcut.html)** @@ -29,7 +29,7 @@ global.shortcut = shortcut; ``` */ export class QShortcut extends QObject { - constructor(parent: NodeWidget) { + constructor(parent: QWidget) { super(new addon.QShortcut(parent.native)); } setEnabled(enabled: boolean): void { diff --git a/src/lib/QtWidgets/QSpinBox.ts b/src/lib/QtWidgets/QSpinBox.ts index 87bb300ca..899efa74b 100644 --- a/src/lib/QtWidgets/QSpinBox.ts +++ b/src/lib/QtWidgets/QSpinBox.ts @@ -1,5 +1,5 @@ import addon from '../utils/addon'; -import { NodeWidget } from './QWidget'; +import { QWidget } from './QWidget'; import { QAbstractSpinBox, QAbstractSpinBoxSignals, StepType } from './QAbstractSpinBox'; /** @@ -19,7 +19,7 @@ const spinBox = new QSpinBox(); ``` */ export class QSpinBox extends QAbstractSpinBox { - constructor(parent?: NodeWidget) { + constructor(parent?: QWidget) { let native; if (parent) { native = new addon.QSpinBox(parent.native); diff --git a/src/lib/QtWidgets/QSplitter.ts b/src/lib/QtWidgets/QSplitter.ts index 82dad87c2..e00ea5612 100644 --- a/src/lib/QtWidgets/QSplitter.ts +++ b/src/lib/QtWidgets/QSplitter.ts @@ -1,5 +1,5 @@ import addon from '../utils/addon'; -import { NodeWidget } from './QWidget'; +import { QWidget } from './QWidget'; import { NodeFrame, QFrameSignals } from './QFrame'; import { NativeElement } from '../core/Component'; import { Orientation } from '../QtEnums'; @@ -35,7 +35,7 @@ splitterHorizontal.addWidget(right); */ export class QSplitter extends NodeFrame { - constructor(parent?: NodeWidget) { + constructor(parent?: QWidget) { let native: NativeElement; if (parent) { native = new addon.QSplitter(parent.native); @@ -45,7 +45,7 @@ export class QSplitter extends NodeFrame { super(native); this.setNodeParent(parent); } - addWidget(widget: NodeWidget): void { + addWidget(widget: QWidget): void { this.native.addWidget(widget.native); } childrenCollapsible(): boolean { @@ -54,10 +54,10 @@ export class QSplitter extends NodeFrame { count(): number { return this.native.count(); } - indexOf(widget: NodeWidget): number { + indexOf(widget: QWidget): number { return this.native.indexOf(widget.native); } - insertWidget(index: number, widget: NodeWidget): void { + insertWidget(index: number, widget: QWidget): void { this.native.insertWidget(index, widget.native); } isCollapsible(index: number): boolean { diff --git a/src/lib/QtWidgets/QStackedWidget.ts b/src/lib/QtWidgets/QStackedWidget.ts index 46da1a545..dd7b0a639 100644 --- a/src/lib/QtWidgets/QStackedWidget.ts +++ b/src/lib/QtWidgets/QStackedWidget.ts @@ -1,5 +1,5 @@ import addon from '../utils/addon'; -import { NodeWidget } from './QWidget'; +import { QWidget } from './QWidget'; import { NodeFrame, QFrameSignals } from './QFrame'; /** @@ -44,7 +44,7 @@ win.show(); ``` */ export class QStackedWidget extends NodeFrame { - constructor(parent?: NodeWidget) { + constructor(parent?: QWidget) { let native; if (parent) { native = new addon.QStackedWidget(parent.native); @@ -56,7 +56,7 @@ export class QStackedWidget extends NodeFrame { } // *** Public Function *** - addWidget(widget: NodeWidget): void { + addWidget(widget: QWidget): void { this.native.addWidget(widget.native); this.nodeChildren.add(widget); widget.setFlexNodeSizeControlled(true); @@ -70,7 +70,7 @@ export class QStackedWidget extends NodeFrame { // TODO: QWidget * currentWidget() const // TODO: int indexOf(QWidget *widget) const // TODO: int insertWidget(int index, QWidget *widget) - removeWidget(widget: NodeWidget): void { + removeWidget(widget: QWidget): void { this.native.removeWidget(widget.native); this.nodeChildren.delete(widget); } @@ -80,7 +80,7 @@ export class QStackedWidget extends NodeFrame { setCurrentIndex(index: number): void { this.native.setCurrentIndex(index); } - setCurrentWidget(widget: NodeWidget): void { + setCurrentWidget(widget: QWidget): void { this.native.setCurrentWidget(widget.native); } } diff --git a/src/lib/QtWidgets/QStandardItemModel.ts b/src/lib/QtWidgets/QStandardItemModel.ts index 27b000d80..7928094f9 100644 --- a/src/lib/QtWidgets/QStandardItemModel.ts +++ b/src/lib/QtWidgets/QStandardItemModel.ts @@ -1,5 +1,5 @@ import addon from '../utils/addon'; -import { NodeWidget } from './QWidget'; +import { QWidget } from './QWidget'; import { QObject, QObjectSignals } from '../QtCore/QObject'; import { QStandardItem } from './QStandardItem'; @@ -8,7 +8,7 @@ export interface QStandardItemModelSignals extends QObjectSignals { } export class QStandardItemModel extends QObject { - constructor(parent?: NodeWidget) { + constructor(parent?: QWidget) { let native; if (parent) { native = new addon.QStandardItemModel(parent.native); diff --git a/src/lib/QtWidgets/QStatusBar.ts b/src/lib/QtWidgets/QStatusBar.ts index be36eb713..175b0ff91 100644 --- a/src/lib/QtWidgets/QStatusBar.ts +++ b/src/lib/QtWidgets/QStatusBar.ts @@ -1,5 +1,5 @@ import addon from '../utils/addon'; -import { NodeWidget, QWidgetSignals, QWidget } from './QWidget'; +import { QWidgetSignals, QWidget } from './QWidget'; import { NativeElement } from '../core/Component'; export interface QStatusBarSignals extends QWidgetSignals { @@ -22,11 +22,11 @@ const { QStatusBar } = require("@nodegui/nodegui"); const progressBar = new QStatusBar(); ``` */ -export class QStatusBar extends NodeWidget { +export class QStatusBar extends QWidget { permanentWidgets: Set; widgets: Set; - constructor(parent?: NodeWidget) { + constructor(parent?: QWidget) { let native; if (parent) { native = new addon.QStatusBar(parent.native); diff --git a/src/lib/QtWidgets/QSvgWidget.ts b/src/lib/QtWidgets/QSvgWidget.ts index acf5f258a..b4bb4a8b9 100644 --- a/src/lib/QtWidgets/QSvgWidget.ts +++ b/src/lib/QtWidgets/QSvgWidget.ts @@ -1,9 +1,9 @@ import addon from '../utils/addon'; -import { NodeWidget, QWidgetSignals } from './QWidget'; +import { QWidget, QWidgetSignals } from './QWidget'; import { NativeElement } from '../core/Component'; /** - + > Display SVG files in a widget. * **This class is a JS wrapper around Qt's [QSvgWidget class](https://doc.qt.io/qt-5/qsvgwidget.html)** @@ -26,10 +26,8 @@ fs.readFile("icon.svg", (err, buffer) => { ``` */ -export class QSvgWidget extends NodeWidget { - constructor(); - constructor(parent: NodeWidget); - constructor(parent?: NodeWidget) { +export class QSvgWidget extends QWidget { + constructor(parent?: QWidget) { let native: NativeElement; if (parent) { native = new addon.QSvgWidget(parent.native); diff --git a/src/lib/QtWidgets/QSystemTrayIcon.ts b/src/lib/QtWidgets/QSystemTrayIcon.ts index f9c5cf2ae..9d0d466b4 100644 --- a/src/lib/QtWidgets/QSystemTrayIcon.ts +++ b/src/lib/QtWidgets/QSystemTrayIcon.ts @@ -1,5 +1,5 @@ import addon from '../utils/addon'; -import { NodeWidget } from './QWidget'; +import { QWidget } from './QWidget'; import { QIcon } from '../QtGui/QIcon'; import { QMenu } from './QMenu'; import { QObject, QObjectSignals } from '../QtCore/QObject'; @@ -30,7 +30,7 @@ global.tray = tray; // prevents garbage collection of tray export class QSystemTrayIcon extends QObject { contextMenu?: QMenu; - constructor(parent?: NodeWidget) { + constructor(parent?: QWidget) { let native; if (parent) { native = new addon.QSystemTrayIcon(parent.native); diff --git a/src/lib/QtWidgets/QTabBar.ts b/src/lib/QtWidgets/QTabBar.ts index 797e68c38..944b87c1d 100644 --- a/src/lib/QtWidgets/QTabBar.ts +++ b/src/lib/QtWidgets/QTabBar.ts @@ -1,5 +1,5 @@ import addon from '../utils/addon'; -import { NodeWidget, QWidgetSignals } from './QWidget'; +import { QWidget, QWidgetSignals } from './QWidget'; import { QIcon } from '../QtGui/QIcon'; import { TextElideMode } from '../QtEnums'; import { QSize } from '../QtCore/QSize'; @@ -25,8 +25,8 @@ const tabBar = new QTabBar(); ``` */ -export class QTabBar extends NodeWidget { - constructor(parent?: NodeWidget) { +export class QTabBar extends QWidget { + constructor(parent?: QWidget) { let native; if (parent) { native = new addon.QTabBar(parent.native); @@ -150,7 +150,7 @@ export class QTabBar extends NodeWidget { removeTab(index: number): void { this.native.removeTab(index); } - setTabButton(index: number, position: ButtonPosition, widget: NodeWidget | undefined | null): void { + setTabButton(index: number, position: ButtonPosition, widget: QWidget | undefined | null): void { this.native.setTabButton(index, position, widget == null ? null : widget?.native); } setTabData(index: number, data: QVariant): void { diff --git a/src/lib/QtWidgets/QTabWidget.ts b/src/lib/QtWidgets/QTabWidget.ts index 44ef10d1d..247e0d284 100644 --- a/src/lib/QtWidgets/QTabWidget.ts +++ b/src/lib/QtWidgets/QTabWidget.ts @@ -1,5 +1,5 @@ import addon from '../utils/addon'; -import { NodeWidget, QWidgetSignals } from './QWidget'; +import { QWidget, QWidgetSignals } from './QWidget'; import { NativeElement } from '../core/Component'; import { QIcon } from '../QtGui/QIcon'; import { TabPosition } from '../QtEnums'; @@ -24,10 +24,10 @@ tabWidget.addTab(new QCalendarWidget(), new QIcon(), 'Tab 1'); tabWidget.addTab(new QCalendarWidget(), new QIcon(), 'Tab 2'); ``` */ -export class QTabWidget extends NodeWidget { - tabs: NodeWidget[]; +export class QTabWidget extends QWidget { + tabs: QWidget[]; - constructor(parent?: NodeWidget) { + constructor(parent?: QWidget) { let native: NativeElement; if (parent) { native = new addon.QTabWidget(parent.native); @@ -39,20 +39,20 @@ export class QTabWidget extends NodeWidget { this.tabs = []; } - addTab(page: NodeWidget, icon: QIcon, label: string): number { + addTab(page: QWidget, icon: QIcon, label: string): number { const index = this.native.addTab(page.native, icon.native, label); this.tabs.push(page); page.setFlexNodeSizeControlled(true); return index; } - insertTab(index: number, page: NodeWidget, icon: QIcon, label: string): number { + insertTab(index: number, page: QWidget, icon: QIcon, label: string): number { const newIndex = this.native.insertTab(index, page.native, icon.native, label); this.tabs.splice(index, 0, page); return newIndex; } - indexOf(widget: NodeWidget): number { + indexOf(widget: QWidget): number { return this.native.indexOf(widget.native); } diff --git a/src/lib/QtWidgets/QTableView.ts b/src/lib/QtWidgets/QTableView.ts index 8f80d4da4..b96ecc8b4 100644 --- a/src/lib/QtWidgets/QTableView.ts +++ b/src/lib/QtWidgets/QTableView.ts @@ -1,5 +1,5 @@ import addon from '../utils/addon'; -import { NodeWidget } from './QWidget'; +import { QWidget } from './QWidget'; import { SortOrder, PenStyle } from '../QtEnums'; import { QAbstractItemView, QAbstractItemViewSignals } from './QAbstractItemView'; import { QHeaderView } from './QHeaderView'; @@ -178,7 +178,7 @@ export abstract class NodeTableView extends Q } export class QTableView extends NodeTableView { - constructor(parent?: NodeWidget) { + constructor(parent?: QWidget) { let native; if (parent) { native = new addon.QTableView(parent.native); diff --git a/src/lib/QtWidgets/QTableWidget.ts b/src/lib/QtWidgets/QTableWidget.ts index 546cbac9f..63cf79260 100644 --- a/src/lib/QtWidgets/QTableWidget.ts +++ b/src/lib/QtWidgets/QTableWidget.ts @@ -1,5 +1,5 @@ import addon from '../utils/addon'; -import { NodeWidget, QWidget } from './QWidget'; +import { QWidget } from './QWidget'; import { NativeElement, Component } from '../core/Component'; import { MatchFlag, ScrollHint, SortOrder } from '../QtEnums'; import { QTableWidgetItem } from './QTableWidgetItem'; @@ -39,7 +39,7 @@ win.show(); */ export class QTableWidget extends QAbstractScrollArea { items: Set; - constructor(rows: number, columns: number, parent?: NodeWidget) { + constructor(rows: number, columns: number, parent?: QWidget) { let native; if (parent) { native = new addon.QTableWidget(rows, columns, parent.native); @@ -59,7 +59,7 @@ export class QTableWidget extends QAbstractScrollArea { editItem(item: Component): void { this.native.editItem(item.native); } - setCellWidget(row: number, column: number, widget: NodeWidget): void { + setCellWidget(row: number, column: number, widget: QWidget): void { this.native.setCellWidget(row, column, widget.native); this.items.add(widget); } diff --git a/src/lib/QtWidgets/QTextBrowser.ts b/src/lib/QtWidgets/QTextBrowser.ts index 906156c24..dc71e80e1 100644 --- a/src/lib/QtWidgets/QTextBrowser.ts +++ b/src/lib/QtWidgets/QTextBrowser.ts @@ -1,11 +1,11 @@ import addon from '../utils/addon'; -import { NodeWidget } from './QWidget'; +import { QWidget } from './QWidget'; import { NativeElement } from '../core/Component'; import { QUrl } from '../QtCore/QUrl'; import { NodeTextEdit, QTextEditSignals } from './QTextEdit'; /** - + > Create and control text browser. * **This class is a JS wrapper around Qt's [QTextBrowser class](https://doc.qt.io/qt-5/qtextbrowser.html)** @@ -22,9 +22,7 @@ const textBrowser = new QTextBrowser(); */ export class QTextBrowser extends NodeTextEdit { - constructor(); - constructor(parent: NodeWidget); - constructor(parent?: NodeWidget) { + constructor(parent?: QWidget) { let native: NativeElement; if (parent) { native = new addon.QTextBrowser(parent.native); diff --git a/src/lib/QtWidgets/QTextEdit.ts b/src/lib/QtWidgets/QTextEdit.ts index f7e9d2a20..1b2f1cb72 100644 --- a/src/lib/QtWidgets/QTextEdit.ts +++ b/src/lib/QtWidgets/QTextEdit.ts @@ -1,5 +1,5 @@ import addon from '../utils/addon'; -import { NodeWidget } from './QWidget'; +import { QWidget } from './QWidget'; import { QAbstractScrollArea, QAbstractScrollAreaSignals } from './QAbstractScrollArea'; import { AlignmentFlag, TextInteractionFlag } from '../QtEnums'; import { QFont } from '../QtGui/QFont'; @@ -239,7 +239,7 @@ export enum WrapMode { } export class QTextEdit extends NodeTextEdit { - constructor(parent?: NodeWidget) { + constructor(parent?: QWidget) { let native; if (parent) { native = new addon.QTextEdit(parent.native); diff --git a/src/lib/QtWidgets/QTimeEdit.ts b/src/lib/QtWidgets/QTimeEdit.ts index 7b38d39d3..46500db0f 100644 --- a/src/lib/QtWidgets/QTimeEdit.ts +++ b/src/lib/QtWidgets/QTimeEdit.ts @@ -1,5 +1,5 @@ import addon from '../utils/addon'; -import { NodeWidget } from './QWidget'; +import { QWidget } from './QWidget'; import { NodeDateTimeEdit } from './QDateTimeEdit'; /** @@ -20,7 +20,7 @@ const timeEdit = new QTimeEdit(); ``` */ export class QTimeEdit extends NodeDateTimeEdit { - constructor(parent?: NodeWidget) { + constructor(parent?: QWidget) { let native; if (parent) { native = new addon.QTimeEdit(parent.native); diff --git a/src/lib/QtWidgets/QToolButton.ts b/src/lib/QtWidgets/QToolButton.ts index 3a8cf9729..9fd78bbdd 100644 --- a/src/lib/QtWidgets/QToolButton.ts +++ b/src/lib/QtWidgets/QToolButton.ts @@ -1,5 +1,5 @@ import addon from '../utils/addon'; -import { NodeWidget } from './QWidget'; +import { QWidget } from './QWidget'; import { NativeElement, NativeRawPointer, Component } from '../core/Component'; import { QAbstractButton, QAbstractButtonSignals } from './QAbstractButton'; import { ToolButtonStyle } from '../QtEnums/ToolButtonStyle'; @@ -29,7 +29,7 @@ export class QToolButton extends QAbstractButton { private _defaultAction?: QAction | null; private _menu?: QMenu | null; - constructor(arg?: NodeWidget | NativeRawPointer | NativeElement, disableNativeDeletion = true) { + constructor(arg?: QWidget | NativeRawPointer | NativeElement, disableNativeDeletion = true) { let native; let parent: Component | undefined; if (checkIfNativeElement(arg)) { @@ -37,7 +37,7 @@ export class QToolButton extends QAbstractButton { } else if (checkIfNapiExternal(arg)) { native = new addon.QToolButton(arg, disableNativeDeletion); } else if (arg) { - const parentWidget = arg as NodeWidget; + const parentWidget = arg as QWidget; native = new addon.QToolButton(parentWidget.native); parent = parentWidget; } else { diff --git a/src/lib/QtWidgets/QTreeWidget.ts b/src/lib/QtWidgets/QTreeWidget.ts index 1e60d70eb..27b38a218 100644 --- a/src/lib/QtWidgets/QTreeWidget.ts +++ b/src/lib/QtWidgets/QTreeWidget.ts @@ -1,5 +1,5 @@ import addon from '../utils/addon'; -import { NodeWidget, QWidget } from './QWidget'; +import { QWidget } from './QWidget'; import { NativeElement } from '../core/Component'; import { QAbstractScrollArea, QAbstractScrollAreaSignals } from './QAbstractScrollArea'; import { QTreeWidgetItem } from './QTreeWidgetItem'; @@ -52,7 +52,7 @@ export class QTreeWidget extends QAbstractScrollArea { topLevelItems: Set; itemWidgets: Map; - constructor(parent?: NodeWidget) { + constructor(parent?: QWidget) { let native; if (parent) { native = new addon.QTreeWidget(parent.native); diff --git a/src/lib/QtWidgets/QWidget.ts b/src/lib/QtWidgets/QWidget.ts index 99f776552..2f0039ffb 100644 --- a/src/lib/QtWidgets/QWidget.ts +++ b/src/lib/QtWidgets/QWidget.ts @@ -23,49 +23,51 @@ import { QStyle } from '../QtGui/QStyle'; import { QWindow } from '../QtGui/QWindow'; /** + > Create and control views. -> Abstract class to add functionalities common to all Widgets. +* **This class is a JS wrapper around Qt's [QWidget class](https://doc.qt.io/qt-5/qwidget.html)** -**This class implements all methods, properties of Qt's [QWidget class](https://doc.qt.io/qt-5/qwidget.html) so that it can be inherited by all widgets** +A `QWidget` can be used to encapsulate other widgets and provide structure. It functions similar to a `div` in the web world. -`NodeWidget` is an abstract class and hence no instances of the same should be created. It exists so that we can add similar functionalities to all widget's easily. Additionally it helps in type checking process. If you wish to create a `div` like widget use [QWidget](QWidget.md) instead. - -**NodeWidget is the base class for all widgets.** ### Example ```javascript -const { - NodeWidget, - QPushButton, - QWidget, - QRadioButton -} = require("@nodegui/nodegui"); +const { QWidget } = require("@nodegui/nodegui"); -// showWidget can accept any widget since it expects NodeWidget -const showWidget = (widget: NodeWidget) => { - widget.show(); -}; - -showWidget(new QPushButton()); -showWidget(new QWidget()); -showWidget(new QRadioButton()); +const view = new QWidget(); +view.setObjectName("container"); //Similar to setting `id` on the web +view.setLayout(new FlexLayout()); ``` -All Widgets should extend from NodeWidget -Implement all native QWidget methods here so that all widgets get access to those aswell - */ -export abstract class NodeWidget extends YogaWidget { +export class QWidget extends YogaWidget { _layout?: NodeLayout; - _rawInlineStyle = ''; - type = 'widget'; + _rawInlineStyle: string; + type: string; private _effect?: QGraphicsEffect | null; - constructor(native: NativeElement) { + + constructor(arg?: QWidget | NativeElement) { + let native: NativeElement; + let parent: QWidget = null; + if (checkIfNativeElement(arg)) { + native = arg as NativeElement; + } else if (arg as QWidget) { + parent = arg as QWidget; + native = new addon.QWidget(parent.native); + } else { + native = new addon.QWidget(); + } super(native); + this._rawInlineStyle = ''; + this.type = 'widget'; + + this.setNodeParent(parent); + this.setStyleSheet = memoizeOne(this.setStyleSheet); this.setInlineStyle = memoizeOne(this.setInlineStyle); this.setObjectName = memoizeOne(this.setObjectName); } + get layout(): NodeLayout | undefined { return this._layout; } @@ -659,38 +661,3 @@ export interface QWidgetSignals extends QObjectSignals { windowIconChanged: (iconNative: NativeElement) => void; customContextMenuRequested: (pos: { x: number; y: number }) => void; } - -/** - > Create and control views. - -* **This class is a JS wrapper around Qt's [QWidget class](https://doc.qt.io/qt-5/qwidget.html)** - -A `QWidget` can be used to encapsulate other widgets and provide structure. It functions similar to a `div` in the web world. - - -### Example - -```javascript -const { QWidget } = require("@nodegui/nodegui"); - -const view = new QWidget(); -view.setObjectName("container"); //Similar to setting `id` on the web -view.setLayout(new FlexLayout()); -``` - */ -export class QWidget extends NodeWidget { - constructor(arg?: NodeWidget | NativeElement) { - let native; - let parent; - if (checkIfNativeElement(arg)) { - native = arg as NativeElement; - } else if (arg as NodeWidget) { - parent = arg as NodeWidget; - native = new addon.QWidget(parent.native); - } else { - native = new addon.QWidget(); - } - super(native); - this.setNodeParent(parent); - } -} diff --git a/src/lib/core/FlexLayout.ts b/src/lib/core/FlexLayout.ts index 580221a99..ec643d3fc 100644 --- a/src/lib/core/FlexLayout.ts +++ b/src/lib/core/FlexLayout.ts @@ -1,5 +1,5 @@ import addon from '../utils/addon'; -import { NodeWidget } from '../QtWidgets/QWidget'; +import { QWidget } from '../QtWidgets/QWidget'; import { NodeLayout, QLayoutSignals } from '../QtWidgets/QLayout'; import { FlexNode } from './YogaWidget'; @@ -34,7 +34,7 @@ layout.addWidget(label2); export class FlexLayout extends NodeLayout { protected flexNode?: FlexNode; - constructor(parent?: NodeWidget) { + constructor(parent?: QWidget) { let native; if (parent) { native = new addon.FlexLayout(parent.native); @@ -47,7 +47,7 @@ export class FlexLayout extends NodeLayout { } } - addWidget(childWidget: NodeWidget, childFlexNode?: FlexNode): void { + addWidget(childWidget: QWidget, childFlexNode?: FlexNode): void { const childYogaNode = childFlexNode || childWidget.getFlexNode(); if (this.nodeChildren.has(childWidget)) { this.removeWidget(childWidget, childYogaNode); @@ -57,8 +57,8 @@ export class FlexLayout extends NodeLayout { } insertChildBefore( - childWidget: NodeWidget, - beforeChildWidget: NodeWidget, + childWidget: QWidget, + beforeChildWidget: QWidget, childFlexNode?: FlexNode, beforeChildFlexNode?: FlexNode, ): void { @@ -77,7 +77,7 @@ export class FlexLayout extends NodeLayout { this.native.insertChildBefore(childWidget.native, beforeChildYogaNode, childYogaNode); } - removeWidget(childWidget: NodeWidget, childFlexNode?: FlexNode): void { + removeWidget(childWidget: QWidget, childFlexNode?: FlexNode): void { if (!this.nodeChildren.has(childWidget)) { return; } @@ -91,16 +91,16 @@ export class FlexLayout extends NodeLayout { this.native.setFlexNode(flexNode); } - getChildIndex(childWidget: NodeWidget): number { + getChildIndex(childWidget: QWidget): number { const widgetArr = Array.from(this.nodeChildren); return widgetArr.indexOf(childWidget); } - getNextSibling(childWidget: NodeWidget): NodeWidget | null { + getNextSibling(childWidget: QWidget): QWidget | null { const childIndex = this.getChildIndex(childWidget); const widgetArr = Array.from(this.nodeChildren); if (childIndex !== -1) { - return (widgetArr[childIndex + 1] as NodeWidget) || null; + return (widgetArr[childIndex + 1] as QWidget) || null; } return null; } diff --git a/src/lib/core/Style/StyleSheet.ts b/src/lib/core/Style/StyleSheet.ts index aba56315e..cd9fbb657 100644 --- a/src/lib/core/Style/StyleSheet.ts +++ b/src/lib/core/Style/StyleSheet.ts @@ -1,7 +1,7 @@ import postcss from 'postcss'; import cuid from 'cuid'; import nodeguiAutoPrefixer from 'postcss-nodegui-autoprefixer'; -import { NodeWidget, QWidgetSignals } from '../../QtWidgets/QWidget'; +import { QWidget, QWidgetSignals } from '../../QtWidgets/QWidget'; export class StyleSheet { static create(cssString: string): string { try { @@ -14,7 +14,7 @@ export class StyleSheet { } export function prepareInlineStyleSheet( - widget: NodeWidget, + widget: QWidget, rawStyle: string, ): string { const inlineStyle = StyleSheet.create(rawStyle);