Remove NodeWidget, just use QWidget
This commit is contained in:
parent
c6d30f8f9f
commit
38b12759c6
@ -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';
|
||||
|
||||
@ -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<any>): void {
|
||||
polish(widget: QWidget): void {
|
||||
this.native.polish(widget.native);
|
||||
}
|
||||
unpolish(widget: NodeWidget<any>): void {
|
||||
unpolish(widget: QWidget): void {
|
||||
this.native.unpolish(widget.native);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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<Signals extends QAbstractButtonSignals> extends NodeWidget<Signals> {
|
||||
export abstract class QAbstractButton<Signals extends QAbstractButtonSignals> extends QWidget<Signals> {
|
||||
animateClick(msec: number): void {
|
||||
this.native.animateClick(msec);
|
||||
}
|
||||
|
||||
@ -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<Signals extends QAbstractScrollAreaSignals> extends NodeFrame<Signals> {
|
||||
viewportWidget?: NodeWidget<any>;
|
||||
setViewport(widget: NodeWidget<any>): void {
|
||||
viewportWidget?: QWidget;
|
||||
setViewport(widget: QWidget): void {
|
||||
this.viewportWidget = widget;
|
||||
this.native.setViewport(widget.native);
|
||||
}
|
||||
|
||||
@ -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<Signals extends QAbstractSliderSignals> extends NodeWidget<Signals> {
|
||||
export abstract class QAbstractSlider<Signals extends QAbstractSliderSignals> extends QWidget<Signals> {
|
||||
triggerAction(action: SliderAction): void {
|
||||
this.native.triggerAction(action);
|
||||
}
|
||||
|
||||
@ -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<Signals extends QAbstractSpinBoxSignals> extends NodeWidget<Signals> {
|
||||
export abstract class QAbstractSpinBox<Signals extends QAbstractSpinBoxSignals> extends QWidget<Signals> {
|
||||
selectAll(): void {
|
||||
this.native.selectAll();
|
||||
}
|
||||
|
||||
@ -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<QActionSignals> {
|
||||
constructor();
|
||||
constructor(native: NativeElement);
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(parent?: NativeElement | NodeWidget<any>) {
|
||||
constructor(parent: QWidget);
|
||||
constructor(parent?: NativeElement | QWidget) {
|
||||
let native: NativeElement;
|
||||
if (checkIfNativeElement(parent)) {
|
||||
native = parent as NativeElement;
|
||||
|
||||
@ -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<QBoxLayoutSignals> {
|
||||
childLayouts: Set<NodeLayout<any>>;
|
||||
constructor(dir: Direction);
|
||||
constructor(dir: Direction, parent: NodeWidget<any>);
|
||||
constructor(dir: Direction, parent?: NodeWidget<any>) {
|
||||
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<QBoxLayoutSignals> {
|
||||
addStrut(size: number): void {
|
||||
this.native.addStrut(size);
|
||||
}
|
||||
addWidget(widget: NodeWidget<any>, 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<any>, 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<QBoxLayoutSignals> {
|
||||
insertStretch(index: number, stretch = 0): void {
|
||||
this.native.insertStretch(index, stretch);
|
||||
}
|
||||
removeWidget(widget: NodeWidget<any>): void {
|
||||
removeWidget(widget: QWidget): void {
|
||||
this.native.removeWidget(widget.native);
|
||||
this.nodeChildren.delete(widget);
|
||||
}
|
||||
|
||||
@ -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<any> {
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
constructor(parent?: QWidget) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QButtonGroup(parent.native);
|
||||
|
||||
@ -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<QCalendarWidgetSignals> {
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
export class QCalendarWidget extends QWidget<QCalendarWidgetSignals> {
|
||||
constructor(parent?: QWidget) {
|
||||
let native: NativeElement;
|
||||
if (parent) {
|
||||
native = new addon.QCalendarWidget(parent.native);
|
||||
|
||||
@ -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<QCheckBoxSignals> {
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(parent: QWidget);
|
||||
constructor(rawPointer: NativeRawPointer<any>, disableNativeDeletion?: boolean);
|
||||
constructor(arg?: NodeWidget<any> | NativeRawPointer<any> | NativeElement, disableNativeDeletion = true) {
|
||||
constructor(arg?: QWidget | NativeRawPointer<any> | NativeElement, disableNativeDeletion = true) {
|
||||
let native;
|
||||
let parent: Component | undefined;
|
||||
if (checkIfNativeElement(arg)) {
|
||||
@ -34,7 +34,7 @@ export class QCheckBox extends QAbstractButton<QCheckBoxSignals> {
|
||||
} else if (checkIfNapiExternal(arg)) {
|
||||
native = new addon.QCheckBox(arg, disableNativeDeletion);
|
||||
} else if (arg) {
|
||||
const parentWidget = arg as NodeWidget<any>;
|
||||
const parentWidget = arg as QWidget;
|
||||
native = new addon.QCheckBox(parentWidget.native);
|
||||
parent = parentWidget;
|
||||
} else {
|
||||
|
||||
@ -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<QColorDialogSignals> {
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
constructor(parent?: QWidget) {
|
||||
let native: NativeElement;
|
||||
if (parent) {
|
||||
native = new addon.QColorDialog(parent.native);
|
||||
|
||||
@ -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<QComboBoxSignals> {
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
export class QComboBox extends QWidget<QComboBoxSignals> {
|
||||
constructor(parent?: QWidget) {
|
||||
let native: NativeElement;
|
||||
if (parent) {
|
||||
native = new addon.QComboBox(parent.native);
|
||||
|
||||
@ -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<any>);
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
constructor(parent?: QWidget) {
|
||||
let native: NativeElement;
|
||||
if (parent) {
|
||||
native = new addon.QDateEdit(parent.native);
|
||||
|
||||
@ -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<QDateTimeEditSig
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
|
||||
> 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<any>);
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
constructor(parent?: QWidget) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QDateTimeEdit(parent.native);
|
||||
|
||||
@ -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<QDialSignals> {
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
constructor(parent: QWidget);
|
||||
constructor(parent?: QWidget) {
|
||||
let native: NativeElement;
|
||||
if (parent) {
|
||||
native = new addon.QDial(parent.native);
|
||||
|
||||
@ -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<Signals extends QDialogSignals> extends NodeWidget<Signals> {
|
||||
export abstract class NodeDialog<Signals extends QDialogSignals> extends QWidget<Signals> {
|
||||
setResult(i: number): void {
|
||||
this.native.setResult(i);
|
||||
}
|
||||
@ -35,7 +35,7 @@ export abstract class NodeDialog<Signals extends QDialogSignals> 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)**
|
||||
|
||||
@ -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<QDoubleSpinBoxSignals> {
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
constructor(parent?: QWidget) {
|
||||
let native: NativeElement;
|
||||
if (parent) {
|
||||
native = new addon.QDoubleSpinBox(parent.native);
|
||||
|
||||
@ -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<QErrorMessageSignals> {
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
constructor(parent?: QWidget) {
|
||||
let native: NativeElement;
|
||||
if (parent) {
|
||||
native = new addon.QErrorMessage(parent.native);
|
||||
|
||||
@ -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<QFileDialogSignals> {
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>, caption?: string, directory?: string, filter?: string);
|
||||
constructor(parent?: NodeWidget<any>, 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);
|
||||
|
||||
@ -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<QFontDialogSignals> {
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
constructor(parent?: QWidget) {
|
||||
let native: NativeElement;
|
||||
if (parent) {
|
||||
native = new addon.QFontDialog(parent.native);
|
||||
|
||||
@ -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<Signals extends QFrameSignals> extends NodeWidget<Signals> {
|
||||
export abstract class NodeFrame<Signals extends QFrameSignals> extends QWidget<Signals> {
|
||||
setFrameRect(r: QRect): void {
|
||||
this.setProperty('frameRect', r.native);
|
||||
}
|
||||
@ -80,13 +80,13 @@ const frame = new QFrame();
|
||||
```
|
||||
*/
|
||||
export class QFrame extends NodeFrame<QFrameSignals> {
|
||||
constructor(arg?: NodeWidget<QWidgetSignals> | NativeElement) {
|
||||
constructor(arg?: QWidget | NativeElement) {
|
||||
let native: NativeElement;
|
||||
let parent;
|
||||
if (checkIfNativeElement(arg)) {
|
||||
native = arg as NativeElement;
|
||||
} else if (arg as NodeWidget<QWidgetSignals>) {
|
||||
parent = arg as NodeWidget<QWidgetSignals>;
|
||||
} else if (arg as QWidget) {
|
||||
parent = arg as QWidget;
|
||||
native = new addon.QFrame(parent.native);
|
||||
} else {
|
||||
native = new addon.QFrame();
|
||||
|
||||
@ -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<QGridLayoutSignals> {
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
constructor(parent?: QWidget) {
|
||||
let native: NativeElement;
|
||||
if (parent) {
|
||||
native = new addon.QGridLayout(parent.native);
|
||||
@ -54,11 +52,11 @@ export class QGridLayout extends NodeLayout<QGridLayoutSignals> {
|
||||
this.native.addLayout(layout.native, row, column, rowSpan, columnSpan, alignment);
|
||||
}
|
||||
|
||||
addWidget(widget: NodeWidget<any>, 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<any>): void {
|
||||
removeWidget(widget: QWidget): void {
|
||||
this.native.removeWidget(widget.native);
|
||||
this.nodeChildren.delete(widget);
|
||||
}
|
||||
|
||||
@ -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<QGroupBoxSignals> {
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
export class QGroupBox extends QWidget<QGroupBoxSignals> {
|
||||
constructor(parent?: QWidget) {
|
||||
let native: NativeElement;
|
||||
if (parent) {
|
||||
native = new addon.QGroupBox(parent.native);
|
||||
|
||||
@ -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<Signals extends QHeaderViewSignals> extends
|
||||
}
|
||||
|
||||
export class QHeaderView extends NodeHeaderView<QHeaderViewSignals> {
|
||||
constructor(orientationOrNative: Orientation | NativeElement, parent: NodeWidget<any> | null = null) {
|
||||
constructor(orientationOrNative: Orientation | NativeElement, parent: QWidget | null = null) {
|
||||
let native: NativeElement;
|
||||
if (checkIfNativeElement(orientationOrNative)) {
|
||||
native = orientationOrNative as NativeElement;
|
||||
|
||||
@ -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<QInputDialogSignals> {
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
constructor(parent?: QWidget) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QInputDialog(parent.native);
|
||||
|
||||
@ -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<QLCDNumberSignals> {
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
export class QLCDNumber extends QWidget<QLCDNumberSignals> {
|
||||
constructor(parent?: QWidget) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QLCDNumber(parent.native);
|
||||
|
||||
@ -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<QLabelSignals> {
|
||||
private _picture?: QPicture;
|
||||
private _pixmap?: QPixmap;
|
||||
private _movie?: QMovie;
|
||||
private _buddy?: NodeWidget<any> | null;
|
||||
private _buddy?: QWidget | null;
|
||||
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
constructor(parent?: QWidget) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QLabel(parent.native);
|
||||
@ -108,11 +108,11 @@ export class QLabel extends NodeFrame<QLabelSignals> {
|
||||
selectionStart(): number {
|
||||
return this.native.selectionStart();
|
||||
}
|
||||
setBuddy(buddy: NodeWidget<any>): void {
|
||||
setBuddy(buddy: QWidget): void {
|
||||
this.native.setBuddy(buddy.native);
|
||||
this._buddy = buddy;
|
||||
}
|
||||
buddy(): NodeWidget<any> | null {
|
||||
buddy(): QWidget | null {
|
||||
if (this._buddy) {
|
||||
return this._buddy;
|
||||
}
|
||||
|
||||
@ -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<Signals extends QLayoutSignals> extends QObject<Signals> {
|
||||
type = 'layout';
|
||||
abstract addWidget(childWidget: NodeWidget<any>, ...args: any[]): void;
|
||||
abstract removeWidget(childWidget: NodeWidget<any>): void;
|
||||
abstract addWidget(childWidget: QWidget, ...args: any[]): void;
|
||||
abstract removeWidget(childWidget: QWidget): void;
|
||||
setSizeConstraint(constraint: SizeConstraint): void {
|
||||
this.setProperty('sizeConstraint', constraint);
|
||||
}
|
||||
|
||||
@ -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<QLineEditSignals> {
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
export class QLineEdit extends QWidget<QLineEditSignals> {
|
||||
constructor(parent?: QWidget) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QLineEdit(parent.native);
|
||||
|
||||
@ -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<QListViewSignals> {
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
constructor(parent?: QWidget) {
|
||||
let native: NativeElement;
|
||||
if (parent) {
|
||||
native = new addon.QListView(parent.native);
|
||||
|
||||
@ -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<QListWidgetSignals> {
|
||||
items: Set<NativeElement | Component>;
|
||||
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
constructor(parent?: QWidget) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QListWidget(parent.native);
|
||||
@ -132,7 +132,7 @@ export class QListWidget extends NodeListView<QListWidgetSignals> {
|
||||
setCurrentItem(item: QListWidgetItem): void {
|
||||
this.native.setCurrentItem(item.native);
|
||||
}
|
||||
setItemWidget(item: QListWidgetItem, widget: NodeWidget<any>): void {
|
||||
setItemWidget(item: QListWidgetItem, widget: QWidget): void {
|
||||
this.native.setItemWidget(item.native, widget.native);
|
||||
}
|
||||
sortItems(order = SortOrder.AscendingOrder): void {
|
||||
|
||||
@ -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<QMainWindowSignals> {
|
||||
public centralWidget?: NodeWidget<any> | null;
|
||||
export class QMainWindow extends QWidget<QMainWindowSignals> {
|
||||
public centralWidget?: QWidget | null;
|
||||
private _menuBar?: QMenuBar;
|
||||
private _statusBar?: QStatusBar | null;
|
||||
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
constructor(parent?: QWidget) {
|
||||
let native: NativeElement;
|
||||
if (parent) {
|
||||
native = new addon.QMainWindow(parent.native);
|
||||
@ -57,12 +55,12 @@ export class QMainWindow extends NodeWidget<QMainWindowSignals> {
|
||||
}
|
||||
};
|
||||
}
|
||||
setCentralWidget(widget: NodeWidget<any>): void {
|
||||
setCentralWidget(widget: QWidget): void {
|
||||
this.native.setCentralWidget(widget.native);
|
||||
this.centralWidget = widget;
|
||||
this.centralWidget.setFlexNodeSizeControlled(true);
|
||||
}
|
||||
takeCentralWidget(): NodeWidget<any> | null {
|
||||
takeCentralWidget(): QWidget | null {
|
||||
const centralWidget = this.centralWidget;
|
||||
this.centralWidget = null;
|
||||
if (centralWidget) {
|
||||
@ -79,7 +77,7 @@ export class QMainWindow extends NodeWidget<QMainWindowSignals> {
|
||||
menuBar(): QMenuBar | undefined {
|
||||
return this._menuBar;
|
||||
}
|
||||
setMenuWidget(menuWidget: NodeWidget<any>): void {
|
||||
setMenuWidget(menuWidget: QWidget): void {
|
||||
this.native.setMenuWidget(menuWidget.native);
|
||||
}
|
||||
get layout(): NodeLayout<any> | undefined {
|
||||
|
||||
@ -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<QMenuSignals> {
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
export class QMenu extends QWidget<QMenuSignals> {
|
||||
constructor(parent?: QWidget) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QMenu(parent.native);
|
||||
|
||||
@ -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<QMenuBarSignals> {
|
||||
export class QMenuBar extends QWidget<QMenuBarSignals> {
|
||||
_menus: Set<QMenu>;
|
||||
|
||||
constructor(arg?: NodeWidget<any> | 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<any>;
|
||||
parent = arg as QWidget;
|
||||
} else {
|
||||
native = new addon.QMenuBar();
|
||||
}
|
||||
|
||||
@ -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<QMessageBoxSignals> {
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
constructor(parent?: QWidget) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QMessageBox(parent.native);
|
||||
@ -86,11 +86,11 @@ export class QMessageBox extends NodeDialog<QMessageBoxSignals> {
|
||||
this.nodeChildren.add(button);
|
||||
}
|
||||
|
||||
static about(parent: NodeWidget<any>, 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<any>, title: string): void {
|
||||
static aboutQt(parent: QWidget, title: string): void {
|
||||
addon.QMessageBox.aboutQt(parent.native, title);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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<QPlainTextEditSignals> {
|
||||
placeholderText?: string;
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
constructor(parent?: QWidget) {
|
||||
let native: NativeElement;
|
||||
if (parent) {
|
||||
native = new addon.QPlainTextEdit(parent.native);
|
||||
|
||||
@ -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<QProgressBarSignals> {
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
export class QProgressBar extends QWidget<QProgressBarSignals> {
|
||||
constructor(parent?: QWidget) {
|
||||
let native: NativeElement;
|
||||
if (parent) {
|
||||
native = new addon.QProgressBar(parent.native);
|
||||
|
||||
@ -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<QProgressDialogSignals> {
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
constructor(parent?: QWidget) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QProgressDialog(parent.native);
|
||||
|
||||
@ -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<QPushButtonSignals> {
|
||||
private _menu?: QMenu | null;
|
||||
|
||||
constructor(arg?: NodeWidget<any> | NativeRawPointer<any> | NativeElement, disableNativeDeletion = true) {
|
||||
constructor(arg?: QWidget | NativeRawPointer<any> | NativeElement, disableNativeDeletion = true) {
|
||||
let native;
|
||||
let parent: Component | undefined;
|
||||
if (checkIfNativeElement(arg)) {
|
||||
@ -33,7 +33,7 @@ export class QPushButton extends QAbstractButton<QPushButtonSignals> {
|
||||
} else if (checkIfNapiExternal(arg)) {
|
||||
native = new addon.QPushButton(arg, disableNativeDeletion);
|
||||
} else if (arg) {
|
||||
const parentWidget = arg as NodeWidget<any>;
|
||||
const parentWidget = arg as QWidget;
|
||||
native = new addon.QPushButton(parentWidget.native);
|
||||
parent = parentWidget;
|
||||
} else {
|
||||
|
||||
@ -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<QRadioButtonSignals> {
|
||||
constructor(arg?: NodeWidget<any> | NativeRawPointer<any> | NativeElement, disableNativeDeletion = true) {
|
||||
constructor(arg?: QWidget | NativeRawPointer<any> | NativeElement, disableNativeDeletion = true) {
|
||||
let native;
|
||||
let parent: Component | undefined;
|
||||
if (checkIfNativeElement(arg)) {
|
||||
@ -31,7 +31,7 @@ export class QRadioButton extends QAbstractButton<QRadioButtonSignals> {
|
||||
} else if (checkIfNapiExternal(arg)) {
|
||||
native = new addon.QRadioButton(arg, disableNativeDeletion);
|
||||
} else if (arg) {
|
||||
const parentWidget = arg as NodeWidget<any>;
|
||||
const parentWidget = arg as QWidget;
|
||||
native = new addon.QRadioButton(parentWidget.native);
|
||||
parent = parentWidget;
|
||||
} else {
|
||||
|
||||
@ -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<QScrollAreaSignals> {
|
||||
contentWidget?: NodeWidget<any> | null;
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
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<QScrollAreaSignals> {
|
||||
ensureVisible(x: number, y: number, xmargin = 50, ymargin = 50): void {
|
||||
this.native.ensureVisible(x, y, xmargin, ymargin);
|
||||
}
|
||||
ensureWidgetVisible(childWidget: NodeWidget<any>, xmargin = 50, ymargin = 50): void {
|
||||
ensureWidgetVisible(childWidget: QWidget, xmargin = 50, ymargin = 50): void {
|
||||
this.native.ensureWidgetVisible(childWidget.native, xmargin, ymargin);
|
||||
}
|
||||
setWidget(widget: NodeWidget<any>): void {
|
||||
setWidget(widget: QWidget): void {
|
||||
this.contentWidget = widget;
|
||||
this.native.setWidget(widget.native);
|
||||
}
|
||||
widget(): NodeWidget<any> | null {
|
||||
widget(): QWidget | null {
|
||||
if (this.contentWidget) {
|
||||
return this.contentWidget;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
takeWidget(): NodeWidget<any> | null {
|
||||
takeWidget(): QWidget | null {
|
||||
// react:✓
|
||||
const contentWidget = this.contentWidget;
|
||||
this.contentWidget = null;
|
||||
|
||||
@ -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<QScrollBarSignals> {
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
constructor(parent?: QWidget) {
|
||||
let native: NativeElement;
|
||||
if (parent) {
|
||||
native = new addon.QScrollBar(parent.native);
|
||||
|
||||
@ -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<QShortcutSignals> {
|
||||
constructor(parent: NodeWidget<any>) {
|
||||
constructor(parent: QWidget) {
|
||||
super(new addon.QShortcut(parent.native));
|
||||
}
|
||||
setEnabled(enabled: boolean): void {
|
||||
|
||||
@ -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<QSpinBoxSignals> {
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
constructor(parent?: QWidget) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QSpinBox(parent.native);
|
||||
|
||||
@ -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<QSplitterSignals> {
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
constructor(parent?: QWidget) {
|
||||
let native: NativeElement;
|
||||
if (parent) {
|
||||
native = new addon.QSplitter(parent.native);
|
||||
@ -45,7 +45,7 @@ export class QSplitter extends NodeFrame<QSplitterSignals> {
|
||||
super(native);
|
||||
this.setNodeParent(parent);
|
||||
}
|
||||
addWidget(widget: NodeWidget<any>): void {
|
||||
addWidget(widget: QWidget): void {
|
||||
this.native.addWidget(widget.native);
|
||||
}
|
||||
childrenCollapsible(): boolean {
|
||||
@ -54,10 +54,10 @@ export class QSplitter extends NodeFrame<QSplitterSignals> {
|
||||
count(): number {
|
||||
return this.native.count();
|
||||
}
|
||||
indexOf(widget: NodeWidget<any>): number {
|
||||
indexOf(widget: QWidget): number {
|
||||
return this.native.indexOf(widget.native);
|
||||
}
|
||||
insertWidget(index: number, widget: NodeWidget<any>): void {
|
||||
insertWidget(index: number, widget: QWidget): void {
|
||||
this.native.insertWidget(index, widget.native);
|
||||
}
|
||||
isCollapsible(index: number): boolean {
|
||||
|
||||
@ -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<QStackedWidgetSignals> {
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
constructor(parent?: QWidget) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QStackedWidget(parent.native);
|
||||
@ -56,7 +56,7 @@ export class QStackedWidget extends NodeFrame<QStackedWidgetSignals> {
|
||||
}
|
||||
|
||||
// *** Public Function ***
|
||||
addWidget(widget: NodeWidget<any>): 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<QStackedWidgetSignals> {
|
||||
// TODO: QWidget * currentWidget() const
|
||||
// TODO: int indexOf(QWidget *widget) const
|
||||
// TODO: int insertWidget(int index, QWidget *widget)
|
||||
removeWidget(widget: NodeWidget<any>): void {
|
||||
removeWidget(widget: QWidget): void {
|
||||
this.native.removeWidget(widget.native);
|
||||
this.nodeChildren.delete(widget);
|
||||
}
|
||||
@ -80,7 +80,7 @@ export class QStackedWidget extends NodeFrame<QStackedWidgetSignals> {
|
||||
setCurrentIndex(index: number): void {
|
||||
this.native.setCurrentIndex(index);
|
||||
}
|
||||
setCurrentWidget(widget: NodeWidget<any>): void {
|
||||
setCurrentWidget(widget: QWidget): void {
|
||||
this.native.setCurrentWidget(widget.native);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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<any>) {
|
||||
constructor(parent?: QWidget) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QStandardItemModel(parent.native);
|
||||
|
||||
@ -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<QStatusBarSignals> {
|
||||
export class QStatusBar extends QWidget<QStatusBarSignals> {
|
||||
permanentWidgets: Set<NativeElement>;
|
||||
widgets: Set<NativeElement>;
|
||||
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
constructor(parent?: QWidget) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QStatusBar(parent.native);
|
||||
|
||||
@ -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<QWidgetSignals> {
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
export class QSvgWidget extends QWidget<QWidgetSignals> {
|
||||
constructor(parent?: QWidget) {
|
||||
let native: NativeElement;
|
||||
if (parent) {
|
||||
native = new addon.QSvgWidget(parent.native);
|
||||
|
||||
@ -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<QSystemTrayIconSignals> {
|
||||
contextMenu?: QMenu;
|
||||
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
constructor(parent?: QWidget) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QSystemTrayIcon(parent.native);
|
||||
|
||||
@ -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<QTabBarSignals> {
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
export class QTabBar extends QWidget<QTabBarSignals> {
|
||||
constructor(parent?: QWidget) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QTabBar(parent.native);
|
||||
@ -150,7 +150,7 @@ export class QTabBar extends NodeWidget<QTabBarSignals> {
|
||||
removeTab(index: number): void {
|
||||
this.native.removeTab(index);
|
||||
}
|
||||
setTabButton(index: number, position: ButtonPosition, widget: NodeWidget<any> | 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 {
|
||||
|
||||
@ -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<QTabWidgetSignals> {
|
||||
tabs: NodeWidget<any>[];
|
||||
export class QTabWidget extends QWidget<QTabWidgetSignals> {
|
||||
tabs: QWidget[];
|
||||
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
constructor(parent?: QWidget) {
|
||||
let native: NativeElement;
|
||||
if (parent) {
|
||||
native = new addon.QTabWidget(parent.native);
|
||||
@ -39,20 +39,20 @@ export class QTabWidget extends NodeWidget<QTabWidgetSignals> {
|
||||
this.tabs = [];
|
||||
}
|
||||
|
||||
addTab(page: NodeWidget<any>, 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<any>, 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<any>): number {
|
||||
indexOf(widget: QWidget): number {
|
||||
return this.native.indexOf(widget.native);
|
||||
}
|
||||
|
||||
|
||||
@ -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<Signals extends QTableViewSignals> extends Q
|
||||
}
|
||||
|
||||
export class QTableView extends NodeTableView<QTableViewSignals> {
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
constructor(parent?: QWidget) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QTableView(parent.native);
|
||||
|
||||
@ -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<QTableWidgetSignals> {
|
||||
items: Set<NativeElement | Component>;
|
||||
constructor(rows: number, columns: number, parent?: NodeWidget<any>) {
|
||||
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<QTableWidgetSignals> {
|
||||
editItem(item: Component): void {
|
||||
this.native.editItem(item.native);
|
||||
}
|
||||
setCellWidget(row: number, column: number, widget: NodeWidget<any>): void {
|
||||
setCellWidget(row: number, column: number, widget: QWidget): void {
|
||||
this.native.setCellWidget(row, column, widget.native);
|
||||
this.items.add(widget);
|
||||
}
|
||||
|
||||
@ -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<QTextBrowserSignals> {
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
constructor(parent?: QWidget) {
|
||||
let native: NativeElement;
|
||||
if (parent) {
|
||||
native = new addon.QTextBrowser(parent.native);
|
||||
|
||||
@ -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<QTextEditSignals> {
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
constructor(parent?: QWidget) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QTextEdit(parent.native);
|
||||
|
||||
@ -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<any>) {
|
||||
constructor(parent?: QWidget) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QTimeEdit(parent.native);
|
||||
|
||||
@ -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<QToolButtonSignals> {
|
||||
private _defaultAction?: QAction | null;
|
||||
private _menu?: QMenu | null;
|
||||
|
||||
constructor(arg?: NodeWidget<any> | NativeRawPointer<any> | NativeElement, disableNativeDeletion = true) {
|
||||
constructor(arg?: QWidget | NativeRawPointer<any> | NativeElement, disableNativeDeletion = true) {
|
||||
let native;
|
||||
let parent: Component | undefined;
|
||||
if (checkIfNativeElement(arg)) {
|
||||
@ -37,7 +37,7 @@ export class QToolButton extends QAbstractButton<QToolButtonSignals> {
|
||||
} else if (checkIfNapiExternal(arg)) {
|
||||
native = new addon.QToolButton(arg, disableNativeDeletion);
|
||||
} else if (arg) {
|
||||
const parentWidget = arg as NodeWidget<any>;
|
||||
const parentWidget = arg as QWidget;
|
||||
native = new addon.QToolButton(parentWidget.native);
|
||||
parent = parentWidget;
|
||||
} else {
|
||||
|
||||
@ -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<QTreeWidgetSignals> {
|
||||
topLevelItems: Set<QTreeWidgetItem>;
|
||||
itemWidgets: Map<QTreeWidgetItem, QWidget>;
|
||||
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
constructor(parent?: QWidget) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QTreeWidget(parent.native);
|
||||
|
||||
@ -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<Signals extends QWidgetSignals> extends YogaWidget<Signals> {
|
||||
export class QWidget<Signals extends QWidgetSignals = QWidgetSignals> extends YogaWidget<Signals> {
|
||||
_layout?: NodeLayout<Signals>;
|
||||
_rawInlineStyle = '';
|
||||
type = 'widget';
|
||||
_rawInlineStyle: string;
|
||||
type: string;
|
||||
private _effect?: QGraphicsEffect<any> | null;
|
||||
constructor(native: NativeElement) {
|
||||
|
||||
constructor(arg?: QWidget<QWidgetSignals> | 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<Signals> | 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<QWidgetSignals> {
|
||||
constructor(arg?: NodeWidget<QWidgetSignals> | NativeElement) {
|
||||
let native;
|
||||
let parent;
|
||||
if (checkIfNativeElement(arg)) {
|
||||
native = arg as NativeElement;
|
||||
} else if (arg as NodeWidget<QWidgetSignals>) {
|
||||
parent = arg as NodeWidget<QWidgetSignals>;
|
||||
native = new addon.QWidget(parent.native);
|
||||
} else {
|
||||
native = new addon.QWidget();
|
||||
}
|
||||
super(native);
|
||||
this.setNodeParent(parent);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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<FlexLayoutSignals> {
|
||||
protected flexNode?: FlexNode;
|
||||
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
constructor(parent?: QWidget) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.FlexLayout(parent.native);
|
||||
@ -47,7 +47,7 @@ export class FlexLayout extends NodeLayout<FlexLayoutSignals> {
|
||||
}
|
||||
}
|
||||
|
||||
addWidget(childWidget: NodeWidget<any>, 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<FlexLayoutSignals> {
|
||||
}
|
||||
|
||||
insertChildBefore(
|
||||
childWidget: NodeWidget<any>,
|
||||
beforeChildWidget: NodeWidget<any>,
|
||||
childWidget: QWidget,
|
||||
beforeChildWidget: QWidget,
|
||||
childFlexNode?: FlexNode,
|
||||
beforeChildFlexNode?: FlexNode,
|
||||
): void {
|
||||
@ -77,7 +77,7 @@ export class FlexLayout extends NodeLayout<FlexLayoutSignals> {
|
||||
this.native.insertChildBefore(childWidget.native, beforeChildYogaNode, childYogaNode);
|
||||
}
|
||||
|
||||
removeWidget(childWidget: NodeWidget<any>, childFlexNode?: FlexNode): void {
|
||||
removeWidget(childWidget: QWidget, childFlexNode?: FlexNode): void {
|
||||
if (!this.nodeChildren.has(childWidget)) {
|
||||
return;
|
||||
}
|
||||
@ -91,16 +91,16 @@ export class FlexLayout extends NodeLayout<FlexLayoutSignals> {
|
||||
this.native.setFlexNode(flexNode);
|
||||
}
|
||||
|
||||
getChildIndex(childWidget: NodeWidget<any>): number {
|
||||
getChildIndex(childWidget: QWidget): number {
|
||||
const widgetArr = Array.from(this.nodeChildren);
|
||||
return widgetArr.indexOf(childWidget);
|
||||
}
|
||||
|
||||
getNextSibling(childWidget: NodeWidget<any>): NodeWidget<any> | 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<any>) || null;
|
||||
return (widgetArr[childIndex + 1] as QWidget) || null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -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<Signals extends QWidgetSignals>(
|
||||
widget: NodeWidget<Signals>,
|
||||
widget: QWidget<Signals>,
|
||||
rawStyle: string,
|
||||
): string {
|
||||
const inlineStyle = StyleSheet.create(rawStyle);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user