Skip to content

Commit 742540a

Browse files
authored
upgrade module to work with latest nodegui (0.57.1) (#376)
* upgrade module to work with nodegui 0.57.1 * fix external docs links * fix layout function calls in conditions * fix layout get/set on RNView * fix centralWidget check on RNWindow
1 parent 2e6ac23 commit 742540a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+722
-699
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"docs": "typedoc && node ./website/docs/scripts/fixdocs.js"
2121
},
2222
"dependencies": {
23-
"@nodegui/nodegui": "^0.40.1",
23+
"@nodegui/nodegui": "^0.57.1",
2424
"@types/react-reconciler": "^0.18.0",
2525
"phin": "3.5.1",
2626
"react-deep-force-update": "^2.1.3",

src/components/AbstractComponents/RNAbstractButton.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { QAbstractButton } from "@nodegui/nodegui";
44

55
/**
66
* The Button component provides ability to add and manipulate native button widgets. It is based on
7-
* [NodeGui's QPushButton](https://docs.nodegui.org/docs/api/QPushButton).
7+
* [NodeGui's QPushButton](https://docs.nodegui.org/docs/api/generated/classes/QPushButton).
88
* ## Example
99
* ```javascript
1010
* import React from "react";
@@ -30,15 +30,15 @@ export interface AbstractButtonProps<Signals extends QAbstractButtonSignals>
3030
*/
3131
children?: string;
3232
/**
33-
* Sets the given text to the button. [QPushButton: setText](https://docs.nodegui.org/docs/api/QPushButton#buttonsettexttext)
33+
* Sets the given text to the button. [QPushButton: setText](https://docs.nodegui.org/docs/api/generated/classes/QPushButton#buttonsettexttext)
3434
*/
3535
text?: string;
3636
/**
37-
* Sets an icon in the button. [QPushButton: setIcon](https://docs.nodegui.org/docs/api/QPushButton#buttonseticonicon)
37+
* Sets an icon in the button. [QPushButton: setIcon](https://docs.nodegui.org/docs/api/generated/classes/QPushButton#buttonseticonicon)
3838
*/
3939
icon?: QIcon;
4040
/**
41-
* Sets an icon size in the button. [QPushButton: setIconSize](https://docs.nodegui.org/docs/api/QPushButton#buttonseticonsize)
41+
* Sets an icon size in the button. [QPushButton: setIconSize](https://docs.nodegui.org/docs/api/generated/classes/QPushButton#buttonseticonsize)
4242
*/
4343
iconSize?: QSize;
4444
}

src/components/Action/RNAction.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export interface ActionProps extends RNProps {
3838
icon?: QIcon;
3939

4040
/**
41-
* Sets the object name (id) of the widget in Qt. Object name can be analogous to id of an element in the web world. Using the objectName of the widget one can reference it in the Qt's stylesheet much like what we do with id in the web world. [QWidget: setObjectName](https://docs.nodegui.org/docs/api/NodeWidget#widgetsetobjectnameobjectname)
41+
* Sets the object name (id) of the widget in Qt. Object name can be analogous to id of an element in the web world. Using the objectName of the widget one can reference it in the Qt's stylesheet much like what we do with id in the web world. [QWidget: setObjectName](https://docs.nodegui.org/docs/api/generated/classes/QWidget#widgetsetobjectnameobjectname)
4242
*/
4343
id?: string;
4444

src/components/AnimatedImage/RNAnimatedImage.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { QLabel, NodeWidget, QMovie, QSize } from "@nodegui/nodegui";
1+
import { QLabel, QWidget, QMovie, QSize } from "@nodegui/nodegui";
22
import { TextProps, setTextProps } from "../Text/RNText";
33
import { RNWidget } from "../config";
44
import { throwUnsupported, isValidUrl } from "../../utils/helpers";
@@ -44,16 +44,16 @@ export class RNAnimatedImage extends QLabel implements RNWidget {
4444
setProps(newProps: AnimatedImageProps, oldProps: AnimatedImageProps): void {
4545
setAnimatedImageProps(this, newProps, oldProps);
4646
}
47-
appendInitialChild(child: NodeWidget<any>): void {
47+
appendInitialChild(child: QWidget<any>): void {
4848
throwUnsupported(this);
4949
}
50-
appendChild(child: NodeWidget<any>): void {
50+
appendChild(child: QWidget<any>): void {
5151
throwUnsupported(this);
5252
}
53-
insertBefore(child: NodeWidget<any>, beforeChild: NodeWidget<any>): void {
53+
insertBefore(child: QWidget<any>, beforeChild: QWidget<any>): void {
5454
throwUnsupported(this);
5555
}
56-
removeChild(child: NodeWidget<any>): void {
56+
removeChild(child: QWidget<any>): void {
5757
throwUnsupported(this);
5858
}
5959
static tagName = "animatedimage";

src/components/BoxView/RNBoxView.ts

+27-24
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ import {
22
QWidget,
33
QBoxLayoutSignals,
44
QBoxLayout,
5-
NodeWidget,
65
Direction,
6+
QLayout,
7+
QObjectSignals,
78
} from "@nodegui/nodegui";
89
import { ViewProps, setViewProps } from "../View/RNView";
910
import { RNComponent } from "../config";
10-
import { NodeDialog } from "@nodegui/nodegui/dist/lib/QtWidgets/QDialog";
11+
import { QDialog } from "@nodegui/nodegui/dist/lib/QtWidgets/QDialog";
1112

1213
export interface BoxViewProps extends ViewProps<QBoxLayoutSignals> {
1314
direction?: Direction;
@@ -20,7 +21,7 @@ const setBoxViewProps = (
2021
) => {
2122
const setter: BoxViewProps = {
2223
set direction(direction: Direction) {
23-
widget.layout?.setDirection(direction);
24+
widget.layout()?.setDirection(direction);
2425
},
2526
};
2627
Object.assign(setter, newProps);
@@ -33,41 +34,43 @@ const setBoxViewProps = (
3334
export class RNBoxView extends QWidget implements RNComponent {
3435
native: any;
3536
initialProps?: BoxViewProps;
36-
children: Array<NodeWidget<any>> = [];
37-
get layout() {
38-
return super.layout as QBoxLayout | undefined;
37+
_children: Array<QWidget<any>> = [];
38+
39+
layout(): QBoxLayout | null {
40+
return super.layout() as any;
3941
}
40-
set layout(l: QBoxLayout | undefined) {
41-
super.layout = l;
42+
43+
setLayout(layout: QBoxLayout): void {
44+
super.setLayout(layout);
4245
}
46+
4347
setProps(newProps: BoxViewProps, oldProps: BoxViewProps): void {
44-
if (this.layout) {
48+
if (this.layout()) {
4549
setBoxViewProps(this, newProps, oldProps);
4650
} else {
4751
this.initialProps = newProps;
4852
}
4953
}
50-
appendInitialChild(child: NodeWidget<any>): void {
54+
appendInitialChild(child: QWidget<any>): void {
5155
this.appendChild(child);
5256
}
53-
appendChild(child: NodeWidget<any>): void {
54-
if (child instanceof NodeDialog) {
57+
appendChild(child: QWidget<any>): void {
58+
if (child instanceof QDialog) {
5559
return;
5660
}
5761
const updateChild = () => {
58-
this.layout?.addWidget(child);
59-
this.children.push(child);
62+
this.layout()?.addWidget(child);
63+
this._children.push(child);
6064
};
6165

62-
if (this.layout) {
66+
if (this.layout()) {
6367
updateChild();
6468

6569
return;
6670
}
6771

6872
const layout = new QBoxLayout(Direction.LeftToRight);
6973
this.setLayout(layout);
70-
this.layout = layout;
7174

7275
// Newly created layout, so set initial props
7376
if (this.initialProps) {
@@ -76,26 +79,26 @@ export class RNBoxView extends QWidget implements RNComponent {
7679

7780
updateChild();
7881
}
79-
insertBefore(child: NodeWidget<any>, beforeChild: NodeWidget<any>): void {
80-
if (child instanceof NodeDialog) {
82+
insertBefore(child: QWidget<any>, beforeChild: QWidget<any>): void {
83+
if (child instanceof QDialog) {
8184
return;
8285
}
83-
const prevIndex = this.children.indexOf(beforeChild);
86+
const prevIndex = this._children.indexOf(beforeChild);
8487

8588
if (prevIndex === -1) {
8689
throw new Error(
8790
"Attempted to insert child Node before nonexistent child"
8891
);
8992
}
9093

91-
this.children.splice(prevIndex, 0, child);
92-
this.layout?.insertWidget(prevIndex, child);
94+
this._children.splice(prevIndex, 0, child);
95+
this.layout()?.insertWidget(prevIndex, child);
9396
}
94-
removeChild(child: NodeWidget<any>): void {
95-
const prevIndex = this.children.indexOf(child);
97+
removeChild(child: QWidget<any>): void {
98+
const prevIndex = this._children.indexOf(child);
9699

97100
if (prevIndex !== -1) {
98-
this.children.splice(prevIndex, 1);
101+
this._children.splice(prevIndex, 1);
99102
}
100103

101104
child.close();

src/components/Button/RNButton.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { QPushButton, NodeWidget, QPushButtonSignals } from "@nodegui/nodegui";
1+
import { QPushButton, QWidget, QPushButtonSignals } from "@nodegui/nodegui";
22
import {
33
AbstractButtonProps,
44
setAbstractButtonProps
@@ -8,7 +8,7 @@ import { throwUnsupported } from "../../utils/helpers";
88

99
/**
1010
* The Button component provides ability to add and manipulate native button widgets. It is based on
11-
* [NodeGui's QPushButton](https://docs.nodegui.org/docs/api/QPushButton).
11+
* [NodeGui's QPushButton](https://docs.nodegui.org/docs/api/generated/classes/QPushButton).
1212
* ## Example
1313
* ```javascript
1414
* import React from "react";
@@ -29,7 +29,7 @@ import { throwUnsupported } from "../../utils/helpers";
2929
*/
3030
export interface ButtonProps extends AbstractButtonProps<QPushButtonSignals> {
3131
/**
32-
* Sets whether the button border is raised. [QPushButton: setFlat](https://docs.nodegui.org/docs/api/QPushButton#buttonsetflatisflat)
32+
* Sets whether the button border is raised. [QPushButton: setFlat](https://docs.nodegui.org/docs/api/generated/classes/QPushButton#buttonsetflatisflat)
3333
*/
3434
flat?: boolean;
3535
}
@@ -52,16 +52,16 @@ const setButtonProps = (
5252
* @ignore
5353
*/
5454
export class RNButton extends QPushButton implements RNWidget {
55-
appendInitialChild(child: NodeWidget<any>): void {
55+
appendInitialChild(child: QWidget<any>): void {
5656
throwUnsupported(this);
5757
}
58-
appendChild(child: NodeWidget<any>): void {
58+
appendChild(child: QWidget<any>): void {
5959
throwUnsupported(this);
6060
}
61-
insertBefore(child: NodeWidget<any>, beforeChild: NodeWidget<any>): void {
61+
insertBefore(child: QWidget<any>, beforeChild: QWidget<any>): void {
6262
throwUnsupported(this);
6363
}
64-
removeChild(child: NodeWidget<any>): void {
64+
removeChild(child: QWidget<any>): void {
6565
throwUnsupported(this);
6666
}
6767
setProps(newProps: ButtonProps, oldProps: ButtonProps) {

src/components/CheckBox/RNCheckBox.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { QCheckBox, NodeWidget, QCheckBoxSignals } from "@nodegui/nodegui";
1+
import { QCheckBox, QWidget, QCheckBoxSignals } from "@nodegui/nodegui";
22
import { RNWidget } from "../config";
33
import { throwUnsupported } from "../../utils/helpers";
44
import {
@@ -8,7 +8,7 @@ import {
88

99
/**
1010
* The CheckBox component provides ability to add and manipulate native button widgets. It is based on
11-
* [NodeGui's QCheckBox](https://docs.nodegui.org/docs/api/QCheckBox).
11+
* [NodeGui's QCheckBox](https://docs.nodegui.org/docs/api/generated/classes/QCheckBox).
1212
* ## Example
1313
* ```javascript
1414
* import React from "react";
@@ -29,7 +29,7 @@ import {
2929
*/
3030
export interface CheckBoxProps extends AbstractButtonProps<QCheckBoxSignals> {
3131
/**
32-
* This property holds whether the button is checked. [QCheckBox: setChecked](https://docs.nodegui.org/docs/api/QCheckBox/#checkboxsetcheckedcheck)
32+
* This property holds whether the button is checked. [QCheckBox: setChecked](https://docs.nodegui.org/docs/api/generated/classes/QCheckBox/#checkboxsetcheckedcheck)
3333
*/
3434
checked?: boolean;
3535
}
@@ -55,16 +55,16 @@ export class RNCheckBox extends QCheckBox implements RNWidget {
5555
setProps(newProps: CheckBoxProps, oldProps: CheckBoxProps): void {
5656
setCheckBoxProps(this, newProps, oldProps);
5757
}
58-
appendInitialChild(child: NodeWidget<any>): void {
58+
appendInitialChild(child: QWidget<any>): void {
5959
throwUnsupported(this);
6060
}
61-
appendChild(child: NodeWidget<any>): void {
61+
appendChild(child: QWidget<any>): void {
6262
throwUnsupported(this);
6363
}
64-
insertBefore(child: NodeWidget<any>, beforeChild: NodeWidget<any>): void {
64+
insertBefore(child: QWidget<any>, beforeChild: QWidget<any>): void {
6565
throwUnsupported(this);
6666
}
67-
removeChild(child: NodeWidget<any>): void {
67+
removeChild(child: QWidget<any>): void {
6868
throwUnsupported(this);
6969
}
7070
static tagName = "checkbox";

src/components/ColorDialog/RNColorDialog.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { NodeWidget, QColor, QColorDialog, QColorDialogSignals } from "@nodegui/nodegui";
1+
import { QWidget, QColor, QColorDialog, QColorDialogSignals } from "@nodegui/nodegui";
22
import { ColorDialogOption } from "@nodegui/nodegui/dist/lib/QtWidgets/QColorDialog";
33
import { throwUnsupported } from "../../utils/helpers";
44
import { RNWidget } from "../config";
@@ -31,16 +31,16 @@ export class RNColorDialog extends QColorDialog implements RNWidget {
3131
setProps(newProps: ColorDialogProps, oldProps: ColorDialogProps): void {
3232
setColorDialogProps(this, newProps, oldProps);
3333
}
34-
appendInitialChild(child: NodeWidget<any>): void {
34+
appendInitialChild(child: QWidget<any>): void {
3535
throwUnsupported(this);
3636
}
37-
appendChild(child: NodeWidget<any>): void {
37+
appendChild(child: QWidget<any>): void {
3838
throwUnsupported(this);
3939
}
40-
insertBefore(child: NodeWidget<any>, beforeChild: NodeWidget<any>): void {
40+
insertBefore(child: QWidget<any>, beforeChild: QWidget<any>): void {
4141
throwUnsupported(this);
4242
}
43-
removeChild(child: NodeWidget<any>): void {
43+
removeChild(child: QWidget<any>): void {
4444
throwUnsupported(this);
4545
}
4646
static tagName = "color-dialog";

src/components/ComboBox/RNComboBox.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {
22
QComboBox,
3-
NodeWidget,
3+
QWidget,
44
QSize,
55
QVariant,
66
SizeAdjustPolicy,
@@ -52,7 +52,7 @@ const setComboBoxProps = (
5252
widget.setProperty("count", count);
5353
},
5454
set iconSize(iconSize: QSize) {
55-
widget.setProperty("iconSize", iconSize.native);
55+
widget.setProperty("iconSize", iconSize.native!);
5656
},
5757
set frame(frame: boolean) {
5858
widget.setProperty("frame", frame);
@@ -61,7 +61,7 @@ const setComboBoxProps = (
6161
widget.setProperty("currentIndex", currentIndex);
6262
},
6363
set currentData(value: QVariant) {
64-
widget.setProperty("currentData", value.native);
64+
widget.setProperty("currentData", value.native!);
6565
},
6666
set currentText(text: string) {
6767
widget.setProperty("currentText", text);
@@ -102,16 +102,16 @@ export class RNComboBox extends QComboBox implements RNWidget {
102102
setProps(newProps: ComboBoxProps, oldProps: ComboBoxProps): void {
103103
setComboBoxProps(this, newProps, oldProps);
104104
}
105-
appendInitialChild(child: NodeWidget<any>): void {
105+
appendInitialChild(child: QWidget<any>): void {
106106
throwUnsupported(this);
107107
}
108-
appendChild(child: NodeWidget<any>): void {
108+
appendChild(child: QWidget<any>): void {
109109
throwUnsupported(this);
110110
}
111-
insertBefore(child: NodeWidget<any>, beforeChild: NodeWidget<any>): void {
111+
insertBefore(child: QWidget<any>, beforeChild: QWidget<any>): void {
112112
throwUnsupported(this);
113113
}
114-
removeChild(child: NodeWidget<any>): void {
114+
removeChild(child: QWidget<any>): void {
115115
throwUnsupported(this);
116116
}
117117
static tagName = "combobox";

src/components/Dial/RNDial.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { QDial, NodeWidget, QDialSignals } from "@nodegui/nodegui";
1+
import { QDial, QWidget, QDialSignals } from "@nodegui/nodegui";
22
import { ViewProps, setViewProps } from "../View/RNView";
33
import { RNWidget } from "../config";
44
import { throwUnsupported } from "../../utils/helpers";
@@ -53,16 +53,16 @@ export class RNDial extends QDial implements RNWidget {
5353
setProps(newProps: DialProps, oldProps: DialProps): void {
5454
setDialProps(this, newProps, oldProps);
5555
}
56-
appendInitialChild(child: NodeWidget<any>): void {
56+
appendInitialChild(child: QWidget<any>): void {
5757
throwUnsupported(this);
5858
}
59-
appendChild(child: NodeWidget<any>): void {
59+
appendChild(child: QWidget<any>): void {
6060
throwUnsupported(this);
6161
}
62-
insertBefore(child: NodeWidget<any>, beforeChild: NodeWidget<any>): void {
62+
insertBefore(child: QWidget<any>, beforeChild: QWidget<any>): void {
6363
throwUnsupported(this);
6464
}
65-
removeChild(child: NodeWidget<any>): void {
65+
removeChild(child: QWidget<any>): void {
6666
throwUnsupported(this);
6767
}
6868
static tagName = "dial";

0 commit comments

Comments
 (0)