Remove NodeDialog, use QDialog instead
This commit is contained in:
parent
165bb820bc
commit
23759b1aaa
@ -1,7 +1,7 @@
|
||||
import addon from '../utils/addon';
|
||||
import { QWidget } from './QWidget';
|
||||
import { NativeElement } from '../core/Component';
|
||||
import { NodeDialog, QDialogSignals } from './QDialog';
|
||||
import { QDialog, QDialogSignals } from './QDialog';
|
||||
import { QColor } from '../QtGui/QColor';
|
||||
|
||||
/**
|
||||
@ -26,7 +26,7 @@ console.log(color.red(), color.green(), color.blue());
|
||||
|
||||
```
|
||||
*/
|
||||
export class QColorDialog extends NodeDialog<QColorDialogSignals> {
|
||||
export class QColorDialog extends QDialog<QColorDialogSignals> {
|
||||
constructor(parent?: QWidget) {
|
||||
let native: NativeElement;
|
||||
if (parent) {
|
||||
|
||||
@ -5,9 +5,30 @@ import { checkIfNativeElement } from '../utils/helpers';
|
||||
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 QWidget<Signals> {
|
||||
/**
|
||||
|
||||
> 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)**
|
||||
|
||||
It is inherited by QFileDialog and QMessageBox (n/a QColorDialog, QErrorMessage, QFontDialog, QInputDialog, QMessageBox, QProgressDialog, and QWizard)
|
||||
*/
|
||||
export class QDialog<Signals extends QDialogSignals = QDialogSignals> extends QWidget<Signals> {
|
||||
constructor(arg?: QDialog | NativeElement) {
|
||||
let native;
|
||||
let parent;
|
||||
if (checkIfNativeElement(arg)) {
|
||||
native = arg as NativeElement;
|
||||
} else if (arg as QDialog) {
|
||||
parent = arg as QDialog;
|
||||
native = new addon.QDialog(parent.native);
|
||||
} else {
|
||||
native = new addon.QDialog();
|
||||
}
|
||||
super(native);
|
||||
this.setNodeParent(parent);
|
||||
}
|
||||
|
||||
setResult(i: number): void {
|
||||
this.native.setResult(i);
|
||||
}
|
||||
@ -34,31 +55,6 @@ export abstract class NodeDialog<Signals extends QDialogSignals> extends QWidget
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
> 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)**
|
||||
|
||||
It is inherited by QFileDialog and QMessageBox (n/a QColorDialog, QErrorMessage, QFontDialog, QInputDialog, QMessageBox, QProgressDialog, and QWizard)
|
||||
*/
|
||||
export class QDialog extends NodeDialog<QDialogSignals> {
|
||||
constructor(arg?: NodeDialog<QDialogSignals> | NativeElement) {
|
||||
let native;
|
||||
let parent;
|
||||
if (checkIfNativeElement(arg)) {
|
||||
native = arg as NativeElement;
|
||||
} else if (arg as NodeDialog<QDialogSignals>) {
|
||||
parent = arg as NodeDialog<QDialogSignals>;
|
||||
native = new addon.QDialog(parent.native);
|
||||
} else {
|
||||
native = new addon.QDialog();
|
||||
}
|
||||
super(native);
|
||||
this.setNodeParent(parent);
|
||||
}
|
||||
}
|
||||
|
||||
export interface QDialogSignals extends QWidgetSignals {
|
||||
accepted: () => void;
|
||||
finished: (result: number) => void;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import addon from '../utils/addon';
|
||||
import { QWidget } from './QWidget';
|
||||
import { NativeElement } from '../core/Component';
|
||||
import { NodeDialog, QDialogSignals } from './QDialog';
|
||||
import { QDialog, QDialogSignals } from './QDialog';
|
||||
|
||||
/**
|
||||
|
||||
@ -20,7 +20,7 @@ const errorMessage = new QErrorMessage();
|
||||
|
||||
```
|
||||
*/
|
||||
export class QErrorMessage extends NodeDialog<QErrorMessageSignals> {
|
||||
export class QErrorMessage extends QDialog<QErrorMessageSignals> {
|
||||
constructor(parent?: QWidget) {
|
||||
let native: NativeElement;
|
||||
if (parent) {
|
||||
|
||||
@ -2,7 +2,7 @@ import addon from '../utils/addon';
|
||||
import { QWidget } from './QWidget';
|
||||
import { NativeElement } from '../core/Component';
|
||||
import { AcceptMode, DialogLabel, FileMode, Option, ViewMode } from '../QtEnums';
|
||||
import { NodeDialog, QDialogSignals } from './QDialog';
|
||||
import { QDialog, QDialogSignals } from './QDialog';
|
||||
|
||||
/**
|
||||
|
||||
@ -27,7 +27,7 @@ console.log(selectedFiles);
|
||||
|
||||
```
|
||||
*/
|
||||
export class QFileDialog extends NodeDialog<QFileDialogSignals> {
|
||||
export class QFileDialog extends QDialog<QFileDialogSignals> {
|
||||
constructor();
|
||||
constructor(parent: QWidget, caption?: string, directory?: string, filter?: string);
|
||||
constructor(parent?: QWidget, caption = 'Select File', directory = '', filter = '') {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import addon from '../utils/addon';
|
||||
import { QWidget } from './QWidget';
|
||||
import { NativeElement } from '../core/Component';
|
||||
import { NodeDialog, QDialogSignals } from './QDialog';
|
||||
import { QDialog, QDialogSignals } from './QDialog';
|
||||
import { QFont } from '../QtGui/QFont';
|
||||
|
||||
/**
|
||||
@ -24,7 +24,7 @@ console.log(font);
|
||||
|
||||
```
|
||||
*/
|
||||
export class QFontDialog extends NodeDialog<QFontDialogSignals> {
|
||||
export class QFontDialog extends QDialog<QFontDialogSignals> {
|
||||
constructor(parent?: QWidget) {
|
||||
let native: NativeElement;
|
||||
if (parent) {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import addon from '../utils/addon';
|
||||
import { QWidget } from './QWidget';
|
||||
import { NodeDialog, QDialogSignals } from './QDialog';
|
||||
import { QDialog, QDialogSignals } from './QDialog';
|
||||
import { EchoMode } from './QLineEdit';
|
||||
|
||||
/**
|
||||
@ -21,7 +21,7 @@ dialog.exec();
|
||||
|
||||
```
|
||||
*/
|
||||
export class QInputDialog extends NodeDialog<QInputDialogSignals> {
|
||||
export class QInputDialog extends QDialog<QInputDialogSignals> {
|
||||
constructor(parent?: QWidget) {
|
||||
let native;
|
||||
if (parent) {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import addon from '../utils/addon';
|
||||
import { QWidget } from './QWidget';
|
||||
import { NativeRawPointer } from '../core/Component';
|
||||
import { NodeDialog, QDialogSignals } from './QDialog';
|
||||
import { QDialog, QDialogSignals } from './QDialog';
|
||||
import { QAbstractButton, QAbstractButtonSignals } from './QAbstractButton';
|
||||
import { QPushButton } from './QPushButton';
|
||||
|
||||
@ -39,7 +39,7 @@ messageBox.exec();
|
||||
|
||||
```
|
||||
*/
|
||||
export class QMessageBox extends NodeDialog<QMessageBoxSignals> {
|
||||
export class QMessageBox extends QDialog<QMessageBoxSignals> {
|
||||
constructor(parent?: QWidget) {
|
||||
let native;
|
||||
if (parent) {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import addon from '../utils/addon';
|
||||
import { QWidget } from './QWidget';
|
||||
import { NodeDialog, QDialogSignals } from './QDialog';
|
||||
import { QDialog, QDialogSignals } from './QDialog';
|
||||
|
||||
/**
|
||||
|
||||
@ -19,7 +19,7 @@ const progressDialog = new QProgressDialog();
|
||||
|
||||
```
|
||||
*/
|
||||
export class QProgressDialog extends NodeDialog<QProgressDialogSignals> {
|
||||
export class QProgressDialog extends QDialog<QProgressDialogSignals> {
|
||||
constructor(parent?: QWidget) {
|
||||
let native;
|
||||
if (parent) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user