Skip to content

upgrade module to work with latest nodegui (0.57.1) #376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"docs": "typedoc && node ./website/docs/scripts/fixdocs.js"
},
"dependencies": {
"@nodegui/nodegui": "^0.40.1",
"@nodegui/nodegui": "^0.57.1",
"@types/react-reconciler": "^0.18.0",
"phin": "3.5.1",
"react-deep-force-update": "^2.1.3",
Expand Down
8 changes: 4 additions & 4 deletions src/components/AbstractComponents/RNAbstractButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { QAbstractButton } from "@nodegui/nodegui";

/**
* The Button component provides ability to add and manipulate native button widgets. It is based on
* [NodeGui's QPushButton](https://docs.nodegui.org/docs/api/QPushButton).
* [NodeGui's QPushButton](https://docs.nodegui.org/docs/api/generated/classes/QPushButton).
* ## Example
* ```javascript
* import React from "react";
Expand All @@ -30,15 +30,15 @@ export interface AbstractButtonProps<Signals extends QAbstractButtonSignals>
*/
children?: string;
/**
* Sets the given text to the button. [QPushButton: setText](https://docs.nodegui.org/docs/api/QPushButton#buttonsettexttext)
* Sets the given text to the button. [QPushButton: setText](https://docs.nodegui.org/docs/api/generated/classes/QPushButton#buttonsettexttext)
*/
text?: string;
/**
* Sets an icon in the button. [QPushButton: setIcon](https://docs.nodegui.org/docs/api/QPushButton#buttonseticonicon)
* Sets an icon in the button. [QPushButton: setIcon](https://docs.nodegui.org/docs/api/generated/classes/QPushButton#buttonseticonicon)
*/
icon?: QIcon;
/**
* Sets an icon size in the button. [QPushButton: setIconSize](https://docs.nodegui.org/docs/api/QPushButton#buttonseticonsize)
* Sets an icon size in the button. [QPushButton: setIconSize](https://docs.nodegui.org/docs/api/generated/classes/QPushButton#buttonseticonsize)
*/
iconSize?: QSize;
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Action/RNAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export interface ActionProps extends RNProps {
icon?: QIcon;

/**
* 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)
* 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)
*/
id?: string;

Expand Down
10 changes: 5 additions & 5 deletions src/components/AnimatedImage/RNAnimatedImage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { QLabel, NodeWidget, QMovie, QSize } from "@nodegui/nodegui";
import { QLabel, QWidget, QMovie, QSize } from "@nodegui/nodegui";
import { TextProps, setTextProps } from "../Text/RNText";
import { RNWidget } from "../config";
import { throwUnsupported, isValidUrl } from "../../utils/helpers";
Expand Down Expand Up @@ -44,16 +44,16 @@ export class RNAnimatedImage extends QLabel implements RNWidget {
setProps(newProps: AnimatedImageProps, oldProps: AnimatedImageProps): void {
setAnimatedImageProps(this, newProps, oldProps);
}
appendInitialChild(child: NodeWidget<any>): void {
appendInitialChild(child: QWidget<any>): void {
throwUnsupported(this);
}
appendChild(child: NodeWidget<any>): void {
appendChild(child: QWidget<any>): void {
throwUnsupported(this);
}
insertBefore(child: NodeWidget<any>, beforeChild: NodeWidget<any>): void {
insertBefore(child: QWidget<any>, beforeChild: QWidget<any>): void {
throwUnsupported(this);
}
removeChild(child: NodeWidget<any>): void {
removeChild(child: QWidget<any>): void {
throwUnsupported(this);
}
static tagName = "animatedimage";
Expand Down
51 changes: 27 additions & 24 deletions src/components/BoxView/RNBoxView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import {
QWidget,
QBoxLayoutSignals,
QBoxLayout,
NodeWidget,
Direction,
QLayout,
QObjectSignals,
} from "@nodegui/nodegui";
import { ViewProps, setViewProps } from "../View/RNView";
import { RNComponent } from "../config";
import { NodeDialog } from "@nodegui/nodegui/dist/lib/QtWidgets/QDialog";
import { QDialog } from "@nodegui/nodegui/dist/lib/QtWidgets/QDialog";

export interface BoxViewProps extends ViewProps<QBoxLayoutSignals> {
direction?: Direction;
Expand All @@ -20,7 +21,7 @@ const setBoxViewProps = (
) => {
const setter: BoxViewProps = {
set direction(direction: Direction) {
widget.layout?.setDirection(direction);
widget.layout()?.setDirection(direction);
},
};
Object.assign(setter, newProps);
Expand All @@ -33,41 +34,43 @@ const setBoxViewProps = (
export class RNBoxView extends QWidget implements RNComponent {
native: any;
initialProps?: BoxViewProps;
children: Array<NodeWidget<any>> = [];
get layout() {
return super.layout as QBoxLayout | undefined;
_children: Array<QWidget<any>> = [];

layout(): QBoxLayout | null {
return super.layout() as any;
}
set layout(l: QBoxLayout | undefined) {
super.layout = l;

setLayout(layout: QBoxLayout): void {
super.setLayout(layout);
}

setProps(newProps: BoxViewProps, oldProps: BoxViewProps): void {
if (this.layout) {
if (this.layout()) {
setBoxViewProps(this, newProps, oldProps);
} else {
this.initialProps = newProps;
}
}
appendInitialChild(child: NodeWidget<any>): void {
appendInitialChild(child: QWidget<any>): void {
this.appendChild(child);
}
appendChild(child: NodeWidget<any>): void {
if (child instanceof NodeDialog) {
appendChild(child: QWidget<any>): void {
if (child instanceof QDialog) {
return;
}
const updateChild = () => {
this.layout?.addWidget(child);
this.children.push(child);
this.layout()?.addWidget(child);
this._children.push(child);
};

if (this.layout) {
if (this.layout()) {
updateChild();

return;
}

const layout = new QBoxLayout(Direction.LeftToRight);
this.setLayout(layout);
this.layout = layout;

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

updateChild();
}
insertBefore(child: NodeWidget<any>, beforeChild: NodeWidget<any>): void {
if (child instanceof NodeDialog) {
insertBefore(child: QWidget<any>, beforeChild: QWidget<any>): void {
if (child instanceof QDialog) {
return;
}
const prevIndex = this.children.indexOf(beforeChild);
const prevIndex = this._children.indexOf(beforeChild);

if (prevIndex === -1) {
throw new Error(
"Attempted to insert child Node before nonexistent child"
);
}

this.children.splice(prevIndex, 0, child);
this.layout?.insertWidget(prevIndex, child);
this._children.splice(prevIndex, 0, child);
this.layout()?.insertWidget(prevIndex, child);
}
removeChild(child: NodeWidget<any>): void {
const prevIndex = this.children.indexOf(child);
removeChild(child: QWidget<any>): void {
const prevIndex = this._children.indexOf(child);

if (prevIndex !== -1) {
this.children.splice(prevIndex, 1);
this._children.splice(prevIndex, 1);
}

child.close();
Expand Down
14 changes: 7 additions & 7 deletions src/components/Button/RNButton.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { QPushButton, NodeWidget, QPushButtonSignals } from "@nodegui/nodegui";
import { QPushButton, QWidget, QPushButtonSignals } from "@nodegui/nodegui";
import {
AbstractButtonProps,
setAbstractButtonProps
Expand All @@ -8,7 +8,7 @@ import { throwUnsupported } from "../../utils/helpers";

/**
* The Button component provides ability to add and manipulate native button widgets. It is based on
* [NodeGui's QPushButton](https://docs.nodegui.org/docs/api/QPushButton).
* [NodeGui's QPushButton](https://docs.nodegui.org/docs/api/generated/classes/QPushButton).
* ## Example
* ```javascript
* import React from "react";
Expand All @@ -29,7 +29,7 @@ import { throwUnsupported } from "../../utils/helpers";
*/
export interface ButtonProps extends AbstractButtonProps<QPushButtonSignals> {
/**
* Sets whether the button border is raised. [QPushButton: setFlat](https://docs.nodegui.org/docs/api/QPushButton#buttonsetflatisflat)
* Sets whether the button border is raised. [QPushButton: setFlat](https://docs.nodegui.org/docs/api/generated/classes/QPushButton#buttonsetflatisflat)
*/
flat?: boolean;
}
Expand All @@ -52,16 +52,16 @@ const setButtonProps = (
* @ignore
*/
export class RNButton extends QPushButton implements RNWidget {
appendInitialChild(child: NodeWidget<any>): void {
appendInitialChild(child: QWidget<any>): void {
throwUnsupported(this);
}
appendChild(child: NodeWidget<any>): void {
appendChild(child: QWidget<any>): void {
throwUnsupported(this);
}
insertBefore(child: NodeWidget<any>, beforeChild: NodeWidget<any>): void {
insertBefore(child: QWidget<any>, beforeChild: QWidget<any>): void {
throwUnsupported(this);
}
removeChild(child: NodeWidget<any>): void {
removeChild(child: QWidget<any>): void {
throwUnsupported(this);
}
setProps(newProps: ButtonProps, oldProps: ButtonProps) {
Expand Down
14 changes: 7 additions & 7 deletions src/components/CheckBox/RNCheckBox.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { QCheckBox, NodeWidget, QCheckBoxSignals } from "@nodegui/nodegui";
import { QCheckBox, QWidget, QCheckBoxSignals } from "@nodegui/nodegui";
import { RNWidget } from "../config";
import { throwUnsupported } from "../../utils/helpers";
import {
Expand All @@ -8,7 +8,7 @@ import {

/**
* The CheckBox component provides ability to add and manipulate native button widgets. It is based on
* [NodeGui's QCheckBox](https://docs.nodegui.org/docs/api/QCheckBox).
* [NodeGui's QCheckBox](https://docs.nodegui.org/docs/api/generated/classes/QCheckBox).
* ## Example
* ```javascript
* import React from "react";
Expand All @@ -29,7 +29,7 @@ import {
*/
export interface CheckBoxProps extends AbstractButtonProps<QCheckBoxSignals> {
/**
* This property holds whether the button is checked. [QCheckBox: setChecked](https://docs.nodegui.org/docs/api/QCheckBox/#checkboxsetcheckedcheck)
* This property holds whether the button is checked. [QCheckBox: setChecked](https://docs.nodegui.org/docs/api/generated/classes/QCheckBox/#checkboxsetcheckedcheck)
*/
checked?: boolean;
}
Expand All @@ -55,16 +55,16 @@ export class RNCheckBox extends QCheckBox implements RNWidget {
setProps(newProps: CheckBoxProps, oldProps: CheckBoxProps): void {
setCheckBoxProps(this, newProps, oldProps);
}
appendInitialChild(child: NodeWidget<any>): void {
appendInitialChild(child: QWidget<any>): void {
throwUnsupported(this);
}
appendChild(child: NodeWidget<any>): void {
appendChild(child: QWidget<any>): void {
throwUnsupported(this);
}
insertBefore(child: NodeWidget<any>, beforeChild: NodeWidget<any>): void {
insertBefore(child: QWidget<any>, beforeChild: QWidget<any>): void {
throwUnsupported(this);
}
removeChild(child: NodeWidget<any>): void {
removeChild(child: QWidget<any>): void {
throwUnsupported(this);
}
static tagName = "checkbox";
Expand Down
10 changes: 5 additions & 5 deletions src/components/ColorDialog/RNColorDialog.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NodeWidget, QColor, QColorDialog, QColorDialogSignals } from "@nodegui/nodegui";
import { QWidget, QColor, QColorDialog, QColorDialogSignals } from "@nodegui/nodegui";
import { ColorDialogOption } from "@nodegui/nodegui/dist/lib/QtWidgets/QColorDialog";
import { throwUnsupported } from "../../utils/helpers";
import { RNWidget } from "../config";
Expand Down Expand Up @@ -31,16 +31,16 @@ export class RNColorDialog extends QColorDialog implements RNWidget {
setProps(newProps: ColorDialogProps, oldProps: ColorDialogProps): void {
setColorDialogProps(this, newProps, oldProps);
}
appendInitialChild(child: NodeWidget<any>): void {
appendInitialChild(child: QWidget<any>): void {
throwUnsupported(this);
}
appendChild(child: NodeWidget<any>): void {
appendChild(child: QWidget<any>): void {
throwUnsupported(this);
}
insertBefore(child: NodeWidget<any>, beforeChild: NodeWidget<any>): void {
insertBefore(child: QWidget<any>, beforeChild: QWidget<any>): void {
throwUnsupported(this);
}
removeChild(child: NodeWidget<any>): void {
removeChild(child: QWidget<any>): void {
throwUnsupported(this);
}
static tagName = "color-dialog";
Expand Down
14 changes: 7 additions & 7 deletions src/components/ComboBox/RNComboBox.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
QComboBox,
NodeWidget,
QWidget,
QSize,
QVariant,
SizeAdjustPolicy,
Expand Down Expand Up @@ -52,7 +52,7 @@ const setComboBoxProps = (
widget.setProperty("count", count);
},
set iconSize(iconSize: QSize) {
widget.setProperty("iconSize", iconSize.native);
widget.setProperty("iconSize", iconSize.native!);
},
set frame(frame: boolean) {
widget.setProperty("frame", frame);
Expand All @@ -61,7 +61,7 @@ const setComboBoxProps = (
widget.setProperty("currentIndex", currentIndex);
},
set currentData(value: QVariant) {
widget.setProperty("currentData", value.native);
widget.setProperty("currentData", value.native!);
},
set currentText(text: string) {
widget.setProperty("currentText", text);
Expand Down Expand Up @@ -102,16 +102,16 @@ export class RNComboBox extends QComboBox implements RNWidget {
setProps(newProps: ComboBoxProps, oldProps: ComboBoxProps): void {
setComboBoxProps(this, newProps, oldProps);
}
appendInitialChild(child: NodeWidget<any>): void {
appendInitialChild(child: QWidget<any>): void {
throwUnsupported(this);
}
appendChild(child: NodeWidget<any>): void {
appendChild(child: QWidget<any>): void {
throwUnsupported(this);
}
insertBefore(child: NodeWidget<any>, beforeChild: NodeWidget<any>): void {
insertBefore(child: QWidget<any>, beforeChild: QWidget<any>): void {
throwUnsupported(this);
}
removeChild(child: NodeWidget<any>): void {
removeChild(child: QWidget<any>): void {
throwUnsupported(this);
}
static tagName = "combobox";
Expand Down
10 changes: 5 additions & 5 deletions src/components/Dial/RNDial.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { QDial, NodeWidget, QDialSignals } from "@nodegui/nodegui";
import { QDial, QWidget, QDialSignals } from "@nodegui/nodegui";
import { ViewProps, setViewProps } from "../View/RNView";
import { RNWidget } from "../config";
import { throwUnsupported } from "../../utils/helpers";
Expand Down Expand Up @@ -53,16 +53,16 @@ export class RNDial extends QDial implements RNWidget {
setProps(newProps: DialProps, oldProps: DialProps): void {
setDialProps(this, newProps, oldProps);
}
appendInitialChild(child: NodeWidget<any>): void {
appendInitialChild(child: QWidget<any>): void {
throwUnsupported(this);
}
appendChild(child: NodeWidget<any>): void {
appendChild(child: QWidget<any>): void {
throwUnsupported(this);
}
insertBefore(child: NodeWidget<any>, beforeChild: NodeWidget<any>): void {
insertBefore(child: QWidget<any>, beforeChild: QWidget<any>): void {
throwUnsupported(this);
}
removeChild(child: NodeWidget<any>): void {
removeChild(child: QWidget<any>): void {
throwUnsupported(this);
}
static tagName = "dial";
Expand Down
Loading