Separate events and signals (#287)
* Wip * Improve constructor typings * Fixes types for Gui and Core * QtGui * Remove unnecessary imports and fix types on abstract classes * Adds half of qwidgets * Add all widgets * cleans up * fix failing test * lint fix * fix demo
This commit is contained in:
parent
d238f4f3e8
commit
01a6476f9c
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QRect>
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QSize>
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QUrl>
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QCursor>
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QKeyEvent>
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QMouseEvent>
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QFontDatabase>
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QIcon>
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QKeySequence>
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QPixmap>
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QBoxLayout>
|
||||
#include <QPointer>
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
|
||||
@ -12,20 +12,24 @@ class NDial : public QDial, public NodeWidget {
|
||||
|
||||
void connectWidgetSignalsToEventEmitter() {
|
||||
// Qt Connects: Implement all signal connects here
|
||||
QObject::connect(this, &QDial::valueChanged, [=]() {
|
||||
QObject::connect(this, &QDial::valueChanged, [=](int value) {
|
||||
Napi::Env env = this->emitOnNode.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
this->emitOnNode.Call({Napi::String::New(env, "valueChanged")});
|
||||
this->emitOnNode.Call({Napi::String::New(env, "valueChanged"),
|
||||
Napi::Number::New(env, value)});
|
||||
});
|
||||
QObject::connect(this, &QDial::rangeChanged, [=]() {
|
||||
QObject::connect(this, &QDial::rangeChanged, [=](int min, int max) {
|
||||
Napi::Env env = this->emitOnNode.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
this->emitOnNode.Call({Napi::String::New(env, "rangeChanged")});
|
||||
this->emitOnNode.Call({Napi::String::New(env, "rangeChanged"),
|
||||
Napi::Number::New(env, min),
|
||||
Napi::Number::New(env, max)});
|
||||
});
|
||||
QObject::connect(this, &QDial::sliderMoved, [=]() {
|
||||
QObject::connect(this, &QDial::sliderMoved, [=](int value) {
|
||||
Napi::Env env = this->emitOnNode.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
this->emitOnNode.Call({Napi::String::New(env, "sliderMoved")});
|
||||
this->emitOnNode.Call({Napi::String::New(env, "sliderMoved"),
|
||||
Napi::Number::New(env, value)});
|
||||
});
|
||||
QObject::connect(this, &QDial::sliderPressed, [=]() {
|
||||
Napi::Env env = this->emitOnNode.Env();
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QGridLayout>
|
||||
#include <QPointer>
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QLayout>
|
||||
#include <QPointer>
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
#include <napi.h>
|
||||
#include <nodegui/QtWidgets/QWidget/qwidget_macro.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
#include <napi.h>
|
||||
#include <nodegui/QtWidgets/QWidget/qwidget_macro.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QPainter>
|
||||
|
||||
|
||||
@ -37,11 +37,11 @@ class NPlainTextEdit : public QPlainTextEdit, public NodeWidget {
|
||||
this->emitOnNode.Call({Napi::String::New(env, "cursorPositionChanged")});
|
||||
});
|
||||
QObject::connect(
|
||||
this, &QPlainTextEdit::modificationChanged, [=](bool charged) {
|
||||
this, &QPlainTextEdit::modificationChanged, [=](bool changed) {
|
||||
Napi::Env env = this->emitOnNode.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
this->emitOnNode.Call({Napi::String::New(env, "modificationChanged"),
|
||||
Napi::Value::From(env, charged)});
|
||||
Napi::Value::From(env, changed)});
|
||||
});
|
||||
QObject::connect(this, &QPlainTextEdit::redoAvailable, [=](bool available) {
|
||||
Napi::Env env = this->emitOnNode.Env();
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QTableWidgetItem>
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QTreeWidgetItem>
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
|
||||
93
src/demo.ts
93
src/demo.ts
@ -1,24 +1,87 @@
|
||||
import { Direction, QMainWindow, QBoxLayout, QWidget, QLabel } from './index';
|
||||
import {
|
||||
FlexLayout,
|
||||
PenStyle,
|
||||
WidgetEventTypes,
|
||||
QColor,
|
||||
QMainWindow,
|
||||
QPainter,
|
||||
QPoint,
|
||||
QWidget,
|
||||
RenderHint,
|
||||
} from './index';
|
||||
|
||||
const win = new QMainWindow();
|
||||
const center = new QWidget();
|
||||
const box = new QBoxLayout(Direction.TopToBottom);
|
||||
center.setLayout(box);
|
||||
const layout = new FlexLayout();
|
||||
const hourHand = [new QPoint(7, 8), new QPoint(-7, 8), new QPoint(0, -40)];
|
||||
const minuteHand = [new QPoint(7, 8), new QPoint(-7, 8), new QPoint(0, -70)];
|
||||
const secondHand = [new QPoint(4, 8), new QPoint(-4, 8), new QPoint(0, -70)];
|
||||
const hourColor = new QColor(127, 0, 127);
|
||||
const minuteColor = new QColor(0, 127, 127, 191);
|
||||
const secondColor = new QColor(0, 0, 0);
|
||||
|
||||
[1, 2, 3, 4].forEach(num => {
|
||||
const label = new QLabel();
|
||||
label.setText(`Hello Label ${num}`);
|
||||
const color = `#${(2 * num).toString().repeat(6)}`;
|
||||
label.setInlineStyle(`border: 2px solid ${color}`);
|
||||
box.addWidget(label, num);
|
||||
return label;
|
||||
center.setLayout(layout);
|
||||
win.setWindowTitle('Analog Clock');
|
||||
|
||||
const side = Math.min(win.geometry().width(), win.geometry().height());
|
||||
|
||||
function repaint(): void {
|
||||
win.repaint();
|
||||
setTimeout(repaint, 1000);
|
||||
}
|
||||
|
||||
setTimeout(repaint, 1000);
|
||||
win.addEventListener(WidgetEventTypes.Paint, () => {
|
||||
const time = new Date();
|
||||
|
||||
const painter = new QPainter(win);
|
||||
painter.setRenderHint(RenderHint.Antialiasing);
|
||||
painter.translate(win.geometry().width() / 2, win.geometry().height() / 2);
|
||||
painter.scale(side / 200.0, side / 200.0);
|
||||
|
||||
painter.setPen(PenStyle.NoPen);
|
||||
painter.setBrush(hourColor);
|
||||
|
||||
painter.save();
|
||||
painter.rotate(30.0 * (time.getHours() + time.getMinutes() / 60.0));
|
||||
painter.drawConvexPolygon(hourHand);
|
||||
painter.restore();
|
||||
|
||||
painter.setPen(hourColor);
|
||||
|
||||
for (let i = 0; i < 12; ++i) {
|
||||
painter.drawLine(88, 0, 96, 0);
|
||||
painter.rotate(30.0);
|
||||
}
|
||||
|
||||
painter.setPen(PenStyle.NoPen);
|
||||
painter.setBrush(minuteColor);
|
||||
|
||||
painter.save();
|
||||
painter.rotate(6.0 * (time.getMinutes() + time.getSeconds() / 60.0));
|
||||
painter.drawConvexPolygon(minuteHand);
|
||||
painter.restore();
|
||||
|
||||
painter.setBrush(secondColor);
|
||||
painter.setPen(PenStyle.NoPen);
|
||||
|
||||
painter.save();
|
||||
painter.rotate(360 * (time.getSeconds() / 60.0));
|
||||
painter.drawConvexPolygon(secondHand);
|
||||
painter.restore();
|
||||
|
||||
painter.setPen(minuteColor);
|
||||
for (let j = 0; j < 60; ++j) {
|
||||
if (j % 5 != 0) {
|
||||
painter.drawLine(92, 0, 96, 0);
|
||||
}
|
||||
painter.rotate(6.0);
|
||||
}
|
||||
painter.end();
|
||||
});
|
||||
const label = new QLabel();
|
||||
label.setText('Inserted label');
|
||||
box.insertWidget(2, label, 5);
|
||||
|
||||
win.setCentralWidget(center);
|
||||
win.resize(200, 400);
|
||||
win.setWindowTitle('box stretch');
|
||||
win.resize(400, 400);
|
||||
|
||||
win.show();
|
||||
(global as any).win = win;
|
||||
|
||||
58
src/index.ts
58
src/index.ts
@ -7,7 +7,7 @@ export { QApplication } from './lib/QtGui/QApplication';
|
||||
export { QKeySequence } from './lib/QtGui/QKeySequence';
|
||||
export { QPixmap, ImageFormats } from './lib/QtGui/QPixmap';
|
||||
export { QIcon, QIconMode, QIconState } from './lib/QtGui/QIcon';
|
||||
export { QMovie, CacheMode, MovieState, QMovieEvents } from './lib/QtGui/QMovie';
|
||||
export { QMovie, CacheMode, MovieState } from './lib/QtGui/QMovie';
|
||||
export { QCursor } from './lib/QtGui/QCursor';
|
||||
export { QTextOptionWrapMode } from './lib/QtGui/QTextOption';
|
||||
export { QClipboard, QClipboardMode } from './lib/QtGui/QClipboard';
|
||||
@ -16,7 +16,7 @@ export { QFontDatabase, SystemFont, WritingSystem } from './lib/QtGui/QFontDatab
|
||||
// Events: Maybe a separate module ?
|
||||
export { QKeyEvent } from './lib/QtGui/QEvent/QKeyEvent';
|
||||
export { QMouseEvent } from './lib/QtGui/QEvent/QMouseEvent';
|
||||
export { NativeEvent, BaseWidgetEvents } from './lib/core/EventWidget';
|
||||
export { WidgetEventTypes } from './lib/core/EventWidget';
|
||||
// Abstract:
|
||||
export { NodeWidget } from './lib/QtWidgets/QWidget';
|
||||
export { NodeLayout } from './lib/QtWidgets/QLayout';
|
||||
@ -24,39 +24,35 @@ export { QAbstractScrollArea } from './lib/QtWidgets/QAbstractScrollArea';
|
||||
export { QAbstractSlider } from './lib/QtWidgets/QAbstractSlider';
|
||||
export { QAbstractButton } from './lib/QtWidgets/QAbstractButton';
|
||||
// Widgets:
|
||||
export { QWidget, QWidgetEvents } from './lib/QtWidgets/QWidget';
|
||||
export { QCheckBox, QCheckBoxEvents } from './lib/QtWidgets/QCheckBox';
|
||||
export { QLabel, QLabelEvents } from './lib/QtWidgets/QLabel';
|
||||
export { QDial, QDialEvents } from './lib/QtWidgets/QDial';
|
||||
export { QFileDialog, QFileDialogEvents } from './lib/QtWidgets/QFileDialog';
|
||||
export { QLineEdit, QLineEditEvents, EchoMode } from './lib/QtWidgets/QLineEdit';
|
||||
export { QMainWindow, QMainWindowEvents } from './lib/QtWidgets/QMainWindow';
|
||||
export { QProgressBar, QProgressBarEvents } from './lib/QtWidgets/QProgressBar';
|
||||
export { QComboBox, QComboBoxEvents, InsertPolicy } from './lib/QtWidgets/QComboBox';
|
||||
export { QPushButton, QPushButtonEvents } from './lib/QtWidgets/QPushButton';
|
||||
export { QToolButton, QToolButtonEvents, ToolButtonPopupMode } from './lib/QtWidgets/QToolButton';
|
||||
export { QSpinBox, QSpinBoxEvents } from './lib/QtWidgets/QSpinBox';
|
||||
export { QRadioButton, QRadioButtonEvents } from './lib/QtWidgets/QRadioButton';
|
||||
export { QStackedWidget, QStackedWidgetEvents } from './lib/QtWidgets/QStackedWidget';
|
||||
export { QTabWidget, QTabWidgetEvents } from './lib/QtWidgets/QTabWidget';
|
||||
export { QTableWidget, QTableWidgetEvents } from './lib/QtWidgets/QTableWidget';
|
||||
export { QWidget } from './lib/QtWidgets/QWidget';
|
||||
export { QCheckBox } from './lib/QtWidgets/QCheckBox';
|
||||
export { QLabel } from './lib/QtWidgets/QLabel';
|
||||
export { QDial } from './lib/QtWidgets/QDial';
|
||||
export { QFileDialog } from './lib/QtWidgets/QFileDialog';
|
||||
export { QLineEdit, EchoMode } from './lib/QtWidgets/QLineEdit';
|
||||
export { QMainWindow } from './lib/QtWidgets/QMainWindow';
|
||||
export { QProgressBar } from './lib/QtWidgets/QProgressBar';
|
||||
export { QComboBox, InsertPolicy } from './lib/QtWidgets/QComboBox';
|
||||
export { QPushButton } from './lib/QtWidgets/QPushButton';
|
||||
export { QToolButton, ToolButtonPopupMode } from './lib/QtWidgets/QToolButton';
|
||||
export { QSpinBox } from './lib/QtWidgets/QSpinBox';
|
||||
export { QRadioButton } from './lib/QtWidgets/QRadioButton';
|
||||
export { QStackedWidget } from './lib/QtWidgets/QStackedWidget';
|
||||
export { QTabWidget } from './lib/QtWidgets/QTabWidget';
|
||||
export { QTableWidget } from './lib/QtWidgets/QTableWidget';
|
||||
export { QTableWidgetItem } from './lib/QtWidgets/QTableWidgetItem';
|
||||
export { QMenu, QMenuEvents } from './lib/QtWidgets/QMenu';
|
||||
export { QMenuBar, QMenuBarEvents } from './lib/QtWidgets/QMenuBar';
|
||||
export { QPlainTextEdit, QPlainTextEditEvents, LineWrapMode } from './lib/QtWidgets/QPlainTextEdit';
|
||||
export { QScrollArea, QScrollAreaEvents } from './lib/QtWidgets/QScrollArea';
|
||||
export { QTreeWidget, QTreeWidgetEvents } from './lib/QtWidgets/QTreeWidget';
|
||||
export { QMenu } from './lib/QtWidgets/QMenu';
|
||||
export { QMenuBar } from './lib/QtWidgets/QMenuBar';
|
||||
export { QPlainTextEdit, LineWrapMode } from './lib/QtWidgets/QPlainTextEdit';
|
||||
export { QScrollArea } from './lib/QtWidgets/QScrollArea';
|
||||
export { QTreeWidget } from './lib/QtWidgets/QTreeWidget';
|
||||
export { QTreeWidgetItem } from './lib/QtWidgets/QTreeWidgetItem';
|
||||
export { QPainter, RenderHint } from './lib/QtWidgets/QPainter';
|
||||
|
||||
export {
|
||||
QSystemTrayIcon,
|
||||
QSystemTrayIconEvents,
|
||||
QSystemTrayIconActivationReason,
|
||||
} from './lib/QtWidgets/QSystemTrayIcon';
|
||||
export { QAction, QActionEvents } from './lib/QtWidgets/QAction';
|
||||
export { QShortcut, QShortcutEvents } from './lib/QtWidgets/QShortcut';
|
||||
export { QGroupBox, QGroupBoxEvents } from './lib/QtWidgets/QGroupBox';
|
||||
export { QSystemTrayIcon, QSystemTrayIconActivationReason } from './lib/QtWidgets/QSystemTrayIcon';
|
||||
export { QAction } from './lib/QtWidgets/QAction';
|
||||
export { QShortcut } from './lib/QtWidgets/QShortcut';
|
||||
export { QGroupBox } from './lib/QtWidgets/QGroupBox';
|
||||
// Core
|
||||
export { QObject, NodeObject } from './lib/QtCore/QObject';
|
||||
export { QVariant } from './lib/QtCore/QVariant';
|
||||
|
||||
@ -2,9 +2,15 @@ import { Component, NativeElement } from '../core/Component';
|
||||
import addon from '../utils/addon';
|
||||
import { checkIfNativeElement } from '../utils/helpers';
|
||||
import { QVariant } from './QVariant';
|
||||
import { GlobalColor } from '../QtEnums';
|
||||
|
||||
export class QColor extends Component {
|
||||
native: NativeElement;
|
||||
constructor();
|
||||
constructor(nativeElement: NativeElement);
|
||||
constructor(colorString: string);
|
||||
constructor(color: GlobalColor);
|
||||
constructor(r?: number, g?: number, b?: number, a?: number);
|
||||
constructor(arg?: NativeElement | number | string, g = 0, b = 0, a = 255) {
|
||||
super();
|
||||
if (checkIfNativeElement(arg)) {
|
||||
|
||||
@ -4,7 +4,7 @@ import { checkIfNativeElement } from '../utils/helpers';
|
||||
import addon from '../utils/addon';
|
||||
import { QVariant } from './QVariant';
|
||||
|
||||
export abstract class NodeObject extends EventWidget {
|
||||
export abstract class NodeObject<Signals> extends EventWidget<Signals> {
|
||||
inherits(className: string): boolean {
|
||||
return this.native.inherits(className);
|
||||
}
|
||||
@ -24,15 +24,18 @@ export abstract class NodeObject extends EventWidget {
|
||||
}
|
||||
}
|
||||
|
||||
export class QObject extends NodeObject {
|
||||
export class QObject extends NodeObject<QObjectSignals> {
|
||||
native: NativeElement;
|
||||
constructor(arg?: NodeObject | NativeElement) {
|
||||
constructor();
|
||||
constructor(nativeElement: NativeElement);
|
||||
constructor(parent: NodeObject<any>);
|
||||
constructor(arg?: NodeObject<any> | NativeElement) {
|
||||
let native;
|
||||
let parent;
|
||||
if (checkIfNativeElement(arg)) {
|
||||
native = arg as NativeElement;
|
||||
} else if (arg as NodeObject) {
|
||||
parent = arg as NodeObject;
|
||||
} else if (arg as NodeObject<any>) {
|
||||
parent = arg as NodeObject<any>;
|
||||
native = new addon.QObject(parent.native);
|
||||
} else {
|
||||
native = new addon.QObject();
|
||||
@ -42,3 +45,5 @@ export class QObject extends NodeObject {
|
||||
this.native = native;
|
||||
}
|
||||
}
|
||||
|
||||
type QObjectSignals = {};
|
||||
|
||||
@ -4,6 +4,9 @@ import { checkIfNativeElement } from '../utils/helpers';
|
||||
import { QVariant } from './QVariant';
|
||||
export class QPoint extends Component {
|
||||
native: NativeElement;
|
||||
constructor();
|
||||
constructor(nativeElement: NativeElement);
|
||||
constructor(x?: number, y?: number);
|
||||
constructor(arg?: NativeElement | number, y = 0) {
|
||||
super();
|
||||
if (checkIfNativeElement(arg)) {
|
||||
|
||||
@ -5,6 +5,9 @@ import { QVariant } from './QVariant';
|
||||
|
||||
export class QRect extends Component {
|
||||
native: NativeElement;
|
||||
constructor();
|
||||
constructor(nativeElement: NativeElement);
|
||||
constructor(x?: number, y?: number, width?: number, height?: number);
|
||||
constructor(arg?: NativeElement | number, y = 0, width = 0, height = 0) {
|
||||
super();
|
||||
const count = arguments.length;
|
||||
|
||||
@ -3,11 +3,12 @@ import addon from '../utils/addon';
|
||||
import { checkIfNativeElement } from '../utils/helpers';
|
||||
import { QVariant } from './QVariant';
|
||||
|
||||
type argument = number | NativeElement;
|
||||
|
||||
export class QSize extends Component {
|
||||
native: NativeElement;
|
||||
constructor(arg?: argument, height?: number) {
|
||||
constructor();
|
||||
constructor(nativeElement: NativeElement);
|
||||
constructor(width?: number, height?: number);
|
||||
constructor(arg?: number | NativeElement, height?: number) {
|
||||
super();
|
||||
if (!arg) {
|
||||
this.native = new addon.QSize();
|
||||
|
||||
@ -9,11 +9,12 @@ export enum ParsingMode {
|
||||
DecodedMode,
|
||||
}
|
||||
|
||||
type argument = string | NativeElement;
|
||||
|
||||
export class QUrl extends Component {
|
||||
native: NativeElement;
|
||||
constructor(arg?: argument, parsingMode: ParsingMode = ParsingMode.TolerantMode) {
|
||||
constructor();
|
||||
constructor(nativeElement: NativeElement);
|
||||
constructor(url: string, parsingMode?: ParsingMode);
|
||||
constructor(arg?: string | NativeElement, parsingMode: ParsingMode = ParsingMode.TolerantMode) {
|
||||
super();
|
||||
if (!arg) {
|
||||
this.native = new addon.QUrl();
|
||||
|
||||
@ -2,11 +2,14 @@ import { NativeElement, Component } from '../core/Component';
|
||||
import addon from '../utils/addon';
|
||||
import { checkIfNativeElement } from '../utils/helpers';
|
||||
|
||||
type QVariantType = NativeElement | Component | string | number | boolean;
|
||||
type QVariantType = Component | string | number | boolean;
|
||||
|
||||
export class QVariant extends Component {
|
||||
native: NativeElement;
|
||||
constructor(arg?: QVariantType) {
|
||||
constructor();
|
||||
constructor(nativeElement: NativeElement);
|
||||
constructor(variant: QVariantType);
|
||||
constructor(arg?: QVariantType | NativeElement) {
|
||||
super();
|
||||
if (checkIfNativeElement(arg)) {
|
||||
this.native = arg as NativeElement;
|
||||
|
||||
@ -4,10 +4,11 @@ import { checkIfNativeElement } from '../utils/helpers';
|
||||
import { QClipboard } from './QClipboard';
|
||||
import { QStyle } from './QStyle';
|
||||
|
||||
type arg = NativeElement;
|
||||
export class QApplication extends Component {
|
||||
native: NativeElement;
|
||||
constructor(arg?: arg) {
|
||||
constructor();
|
||||
constructor(native: NativeElement);
|
||||
constructor(arg?: NativeElement) {
|
||||
super();
|
||||
if (checkIfNativeElement(arg)) {
|
||||
this.native = arg as NativeElement;
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
import addon from '../utils/addon';
|
||||
import { Component, NativeElement } from '../core/Component';
|
||||
import { QPixmap } from './QPixmap';
|
||||
|
||||
type arg = NativeElement | number | QPixmap;
|
||||
import { CursorShape } from '../QtEnums';
|
||||
export class QCursor extends Component {
|
||||
native: NativeElement;
|
||||
constructor(arg?: arg) {
|
||||
constructor();
|
||||
constructor(native: NativeElement);
|
||||
constructor(shape: CursorShape);
|
||||
constructor(arg?: NativeElement | CursorShape) {
|
||||
super();
|
||||
if (arg) {
|
||||
this.native = new addon.QCursor(arg);
|
||||
|
||||
@ -1,10 +1,9 @@
|
||||
import addon from '../../utils/addon';
|
||||
import { NativeElement } from '../../core/Component';
|
||||
import { NativeEvent } from '../../core/EventWidget';
|
||||
|
||||
export class QKeyEvent {
|
||||
native: NativeElement;
|
||||
constructor(event: NativeEvent) {
|
||||
constructor(event: NativeElement) {
|
||||
this.native = new addon.QKeyEvent(event);
|
||||
}
|
||||
text(): string {
|
||||
|
||||
@ -1,10 +1,9 @@
|
||||
import addon from '../../utils/addon';
|
||||
import { NativeElement } from '../../core/Component';
|
||||
import { NativeEvent } from '../../core/EventWidget';
|
||||
|
||||
export class QMouseEvent {
|
||||
native: NativeElement;
|
||||
constructor(event: NativeEvent) {
|
||||
constructor(event: NativeElement) {
|
||||
this.native = new addon.QMouseEvent(event);
|
||||
}
|
||||
button(): string {
|
||||
|
||||
@ -1,6 +1,29 @@
|
||||
import addon from '../utils/addon';
|
||||
import { Component, NativeElement } from '../core/Component';
|
||||
|
||||
export class QFontDatabase extends Component {
|
||||
native: NativeElement;
|
||||
constructor() {
|
||||
super();
|
||||
this.native = new addon.QFontDatabase();
|
||||
}
|
||||
bold(family: string, style: string): boolean {
|
||||
return this.native.bold(family, style);
|
||||
}
|
||||
italic(family: string, style: string): boolean {
|
||||
return this.native.italic(family, style);
|
||||
}
|
||||
weight(family: string, style: string): number {
|
||||
return this.native.weight(family, style);
|
||||
}
|
||||
static addApplicationFont(fileName: string): number {
|
||||
return addon.QFontDatabase.addApplicationFont(fileName);
|
||||
}
|
||||
static removeApplicationFont(id: number): boolean {
|
||||
return addon.QFontDatabase.removeApplicationFont(id);
|
||||
}
|
||||
}
|
||||
|
||||
export enum SystemFont {
|
||||
GeneralFont,
|
||||
FixedFont,
|
||||
@ -45,26 +68,3 @@ export enum WritingSystem {
|
||||
Runic = 32,
|
||||
Nko = 33,
|
||||
}
|
||||
|
||||
export class QFontDatabase extends Component {
|
||||
native: NativeElement;
|
||||
constructor() {
|
||||
super();
|
||||
this.native = new addon.QFontDatabase();
|
||||
}
|
||||
bold(family: string, style: string): boolean {
|
||||
return this.native.bold(family, style);
|
||||
}
|
||||
italic(family: string, style: string): boolean {
|
||||
return this.native.italic(family, style);
|
||||
}
|
||||
weight(family: string, style: string): number {
|
||||
return this.native.weight(family, style);
|
||||
}
|
||||
static addApplicationFont(fileName: string): number {
|
||||
return addon.QFontDatabase.addApplicationFont(fileName);
|
||||
}
|
||||
static removeApplicationFont(id: number): boolean {
|
||||
return addon.QFontDatabase.removeApplicationFont(id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,14 +15,16 @@ export enum QIconState {
|
||||
On,
|
||||
}
|
||||
|
||||
type arg = string | NativeElement;
|
||||
export class QIcon extends Component {
|
||||
native: NativeElement;
|
||||
constructor(arg?: arg) {
|
||||
constructor();
|
||||
constructor(native: NativeElement);
|
||||
constructor(filePath: string);
|
||||
constructor(arg?: string | NativeElement) {
|
||||
super();
|
||||
if (typeof arg === 'string') {
|
||||
const imageUrl = arg;
|
||||
this.native = new addon.QIcon(imageUrl);
|
||||
const imagePath = arg;
|
||||
this.native = new addon.QIcon(imagePath);
|
||||
} else if (checkIfNativeElement(arg)) {
|
||||
this.native = arg as NativeElement;
|
||||
} else {
|
||||
|
||||
@ -3,6 +3,8 @@ import { Component, NativeElement } from '../core/Component';
|
||||
|
||||
export class QKeySequence extends Component {
|
||||
native: NativeElement;
|
||||
constructor();
|
||||
constructor(keySequence: string);
|
||||
constructor(keySequence?: string) {
|
||||
super();
|
||||
if (typeof keySequence === 'string') {
|
||||
|
||||
@ -1,37 +1,29 @@
|
||||
import addon from '../utils/addon';
|
||||
import { NativeElement } from '../core/Component';
|
||||
import { checkIfNativeElement } from '../utils/helpers';
|
||||
import { QObject } from '../QtCore/QObject';
|
||||
import { NodeObject } from '../QtCore/QObject';
|
||||
import { QSize } from '../QtCore/QSize';
|
||||
import { BaseWidgetEvents } from '../core/EventWidget';
|
||||
import { QPixmap } from './QPixmap';
|
||||
|
||||
export const QMovieEvents = Object.freeze({
|
||||
...BaseWidgetEvents,
|
||||
error: 'error',
|
||||
finished: 'finished',
|
||||
frameChanged: 'frameChanged',
|
||||
resized: 'resized',
|
||||
started: 'started',
|
||||
stateChanged: 'stateChanged',
|
||||
updated: 'updated',
|
||||
});
|
||||
|
||||
type supportedFormats = 'gif' | 'webp';
|
||||
export class QMovie extends QObject {
|
||||
export class QMovie extends NodeObject<QMovieSignals> {
|
||||
native: NativeElement;
|
||||
constructor(arg?: QObject | NativeElement) {
|
||||
super();
|
||||
constructor();
|
||||
constructor(native: NativeElement);
|
||||
constructor(parent: NodeObject<any>);
|
||||
constructor(arg?: NodeObject<any> | NativeElement) {
|
||||
let native: NativeElement;
|
||||
if (arg) {
|
||||
if (checkIfNativeElement(arg)) {
|
||||
this.native = arg as NativeElement;
|
||||
native = arg as NativeElement;
|
||||
} else {
|
||||
this.native = new addon.QMovie(arg);
|
||||
native = new addon.QMovie(arg);
|
||||
}
|
||||
} else {
|
||||
this.native = new addon.QMovie();
|
||||
native = new addon.QMovie();
|
||||
}
|
||||
super(native);
|
||||
this.native = native;
|
||||
}
|
||||
//Methods
|
||||
setFileName(fileName: string): void {
|
||||
this.native.setFileName(fileName);
|
||||
this.jumpToFrame(0);
|
||||
@ -42,13 +34,12 @@ export class QMovie extends QObject {
|
||||
fileName(): string {
|
||||
return this.native.fileName();
|
||||
}
|
||||
setFormat(formatName: supportedFormats): void {
|
||||
setFormat(formatName: SupportedFormats): void {
|
||||
this.native.setFormat(formatName);
|
||||
}
|
||||
format(): string {
|
||||
return this.native.format();
|
||||
}
|
||||
|
||||
setScaledSize(size: QSize): void {
|
||||
this.native.setScaledSize(size.native);
|
||||
}
|
||||
@ -84,6 +75,16 @@ export class QMovie extends QObject {
|
||||
}
|
||||
}
|
||||
|
||||
interface QMovieSignals {
|
||||
error: (error: ImageReaderError) => void;
|
||||
finished: () => void;
|
||||
frameChanged: (frameNumber?: number) => void;
|
||||
resized: (qSizeNative?: NativeElement) => void;
|
||||
started: () => void;
|
||||
stateChanged: (state: MovieState) => void;
|
||||
updated: (qRectNative: NativeElement) => void;
|
||||
}
|
||||
|
||||
export enum CacheMode {
|
||||
CacheNone,
|
||||
CacheAll,
|
||||
@ -94,3 +95,13 @@ export enum MovieState {
|
||||
Paused,
|
||||
Running,
|
||||
}
|
||||
|
||||
export enum ImageReaderError {
|
||||
FileNotFoundError = 1,
|
||||
DeviceError = 2,
|
||||
UnsupportedFormatError = 3,
|
||||
InvalidDataError = 4,
|
||||
UnknownError = 0,
|
||||
}
|
||||
|
||||
type SupportedFormats = 'gif' | 'webp';
|
||||
|
||||
@ -6,22 +6,24 @@ import { QVariant } from '../QtCore/QVariant';
|
||||
|
||||
export type ImageFormats = 'BMP' | 'GIF' | 'JPG' | 'JPEG' | 'PNG' | 'PBM' | 'PGM' | 'PPM' | 'XBM' | 'XPM' | 'SVG';
|
||||
|
||||
type arg = string | NativeElement;
|
||||
export class QPixmap extends Component {
|
||||
native: NativeElement;
|
||||
constructor(arg?: arg) {
|
||||
constructor();
|
||||
constructor(native: NativeElement);
|
||||
constructor(filePath: string);
|
||||
constructor(arg?: string | NativeElement) {
|
||||
super();
|
||||
if (typeof arg === 'string') {
|
||||
const imageUrl = arg;
|
||||
this.native = new addon.QPixmap(imageUrl);
|
||||
const imagePath = arg;
|
||||
this.native = new addon.QPixmap(imagePath);
|
||||
} else if (checkIfNativeElement(arg)) {
|
||||
this.native = arg as NativeElement;
|
||||
} else {
|
||||
this.native = new addon.QPixmap();
|
||||
}
|
||||
}
|
||||
load(imageUrl: string): boolean {
|
||||
return this.native.load(imageUrl);
|
||||
load(imagePath: string): boolean {
|
||||
return this.native.load(imagePath);
|
||||
}
|
||||
loadFromData(buffer: Buffer, format?: ImageFormats): boolean {
|
||||
return format ? this.native.loadFromData(buffer, format) : this.native.loadFromData(buffer);
|
||||
|
||||
@ -81,7 +81,7 @@ describe('QMovie', () => {
|
||||
movie.loadFromData(Buffer.from(arrayBuffer));
|
||||
movie.start();
|
||||
movie.stop();
|
||||
movie.jumpToFrame(2);
|
||||
movie.jumpToNextFrame();
|
||||
const pixmap = movie.currentPixmap();
|
||||
expect(pixmap).toBeInstanceOf(QPixmap);
|
||||
expect(pixmap.height()).toBe(270);
|
||||
|
||||
@ -2,7 +2,7 @@ import { NodeWidget } from './QWidget';
|
||||
import { QIcon } from '../QtGui/QIcon';
|
||||
import { QSize } from '../QtCore/QSize';
|
||||
|
||||
export abstract class QAbstractButton extends NodeWidget {
|
||||
export abstract class QAbstractButton<Signals> extends NodeWidget<Signals> {
|
||||
setText(text: string): void {
|
||||
this.native.setText(text);
|
||||
}
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import { NodeWidget, QWidget } from './QWidget';
|
||||
import { ScrollBarPolicy } from '../QtEnums/ScrollBarPolicy';
|
||||
|
||||
export abstract class QAbstractScrollArea extends NodeWidget {
|
||||
viewportWidget?: NodeWidget;
|
||||
setViewport(widget: NodeWidget): void {
|
||||
export abstract class QAbstractScrollArea<Signals> extends NodeWidget<Signals> {
|
||||
viewportWidget?: NodeWidget<any>;
|
||||
setViewport(widget: NodeWidget<any>): void {
|
||||
this.viewportWidget = widget;
|
||||
this.native.setViewport(widget.native);
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { NodeWidget } from './QWidget';
|
||||
import { Orientation } from '../QtEnums';
|
||||
|
||||
export abstract class QAbstractSlider extends NodeWidget {
|
||||
export abstract class QAbstractSlider<Signals> extends NodeWidget<Signals> {
|
||||
setSingleStep(step: number): void {
|
||||
this.native.setSingleStep(step);
|
||||
}
|
||||
|
||||
@ -7,17 +7,20 @@ import { QKeySequence } from '../QtGui/QKeySequence';
|
||||
import { ShortcutContext } from '../QtEnums';
|
||||
import { NodeObject } from '../QtCore/QObject';
|
||||
|
||||
export const QActionEvents = Object.freeze({
|
||||
triggered: 'triggered',
|
||||
changed: 'changed',
|
||||
hovered: 'hovered',
|
||||
toggled: 'toggled',
|
||||
});
|
||||
export class QAction extends NodeObject {
|
||||
interface QActionSignals {
|
||||
triggered: (checked: boolean) => void;
|
||||
changed: () => void;
|
||||
hovered: () => void;
|
||||
toggled: (checked: boolean) => void;
|
||||
}
|
||||
|
||||
export class QAction extends NodeObject<QActionSignals> {
|
||||
native: NativeElement;
|
||||
icon?: QIcon;
|
||||
menu?: QMenu;
|
||||
constructor(parent?: NodeWidget) {
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QAction(parent.native);
|
||||
|
||||
@ -4,10 +4,13 @@ import { NodeLayout } from './QLayout';
|
||||
import { NativeElement } from '../core/Component';
|
||||
import { Direction } from '../QtEnums';
|
||||
|
||||
export class QBoxLayout extends NodeLayout {
|
||||
type QBoxLayoutSignals = {};
|
||||
export class QBoxLayout extends NodeLayout<QBoxLayoutSignals> {
|
||||
native: NativeElement;
|
||||
childLayouts: Set<NodeLayout>;
|
||||
constructor(dir: Direction, parent?: NodeWidget) {
|
||||
childLayouts: Set<NodeLayout<any>>;
|
||||
constructor(dir: Direction);
|
||||
constructor(dir: Direction, parent: NodeWidget<any>);
|
||||
constructor(dir: Direction, parent?: NodeWidget<any>) {
|
||||
let native: NativeElement;
|
||||
if (parent) {
|
||||
native = new addon.QBoxLayout(dir, parent.native);
|
||||
@ -19,7 +22,7 @@ export class QBoxLayout extends NodeLayout {
|
||||
this.native = native;
|
||||
this.childLayouts = new Set();
|
||||
}
|
||||
addLayout(layout: NodeLayout, stretch = 0): void {
|
||||
addLayout(layout: NodeLayout<any>, stretch = 0): void {
|
||||
this.native.addLayout(layout.native, stretch);
|
||||
this.childLayouts.add(layout);
|
||||
}
|
||||
@ -32,22 +35,22 @@ export class QBoxLayout extends NodeLayout {
|
||||
addStrut(size: number): void {
|
||||
this.native.addStrut(size);
|
||||
}
|
||||
addWidget(widget: NodeWidget, stretch = 0): void {
|
||||
addWidget(widget: NodeWidget<any>, stretch = 0): void {
|
||||
this.native.addWidget(widget.native, stretch);
|
||||
this.nodeChildren.add(widget);
|
||||
}
|
||||
insertWidget(index: number, widget: NodeWidget, stretch = 0): void {
|
||||
insertWidget(index: number, widget: NodeWidget<any>, stretch = 0): void {
|
||||
this.native.insertWidget(index, widget.native, stretch);
|
||||
this.nodeChildren.add(widget);
|
||||
}
|
||||
direction(): Direction {
|
||||
return this.native.direction();
|
||||
}
|
||||
insertLayout(index: number, layout: NodeLayout, stretch = 0): void {
|
||||
insertLayout(index: number, layout: NodeLayout<any>, stretch = 0): void {
|
||||
this.native.insertLayout(index, layout.native, stretch);
|
||||
this.childLayouts.add(layout);
|
||||
}
|
||||
removeWidget(widget: NodeWidget): void {
|
||||
removeWidget(widget: NodeWidget<any>): void {
|
||||
this.native.removeWidget(widget.native);
|
||||
this.nodeChildren.delete(widget);
|
||||
}
|
||||
|
||||
@ -1,16 +1,18 @@
|
||||
import addon from '../utils/addon';
|
||||
import { NodeWidget } from './QWidget';
|
||||
import { BaseWidgetEvents } from '../core/EventWidget';
|
||||
import { NativeElement } from '../core/Component';
|
||||
import { QAbstractButton } from './QAbstractButton';
|
||||
|
||||
export const QCheckBoxEvents = Object.freeze({
|
||||
...BaseWidgetEvents,
|
||||
toggled: 'toggled',
|
||||
});
|
||||
export class QCheckBox extends QAbstractButton {
|
||||
interface QCheckBoxSignals {
|
||||
//List all Signals below
|
||||
toggled: (checked: boolean) => void;
|
||||
}
|
||||
|
||||
export class QCheckBox extends QAbstractButton<QCheckBoxSignals> {
|
||||
native: NativeElement;
|
||||
constructor(parent?: NodeWidget) {
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QCheckBox(parent.native);
|
||||
|
||||
@ -1,20 +1,21 @@
|
||||
import addon from '../utils/addon';
|
||||
import { NodeWidget } from './QWidget';
|
||||
import { BaseWidgetEvents } from '../core/EventWidget';
|
||||
import { NativeElement } from '../core/Component';
|
||||
import { SizeAdjustPolicy } from '../QtEnums';
|
||||
import { QIcon } from '../QtGui/QIcon';
|
||||
import { QVariant } from '../QtCore/QVariant';
|
||||
|
||||
export const QComboBoxEvents = Object.freeze({
|
||||
currentIndexChanged: 'currentIndexChanged',
|
||||
currentTextChanged: 'currentTextChanged',
|
||||
editTextChanged: 'editTextChanged',
|
||||
...BaseWidgetEvents,
|
||||
});
|
||||
export class QComboBox extends NodeWidget {
|
||||
interface QComboBoxSignals {
|
||||
//List all Signals below
|
||||
currentIndexChanged: (index: number) => void;
|
||||
currentTextChanged: (text: string) => void;
|
||||
editTextChanged: (text: string) => void;
|
||||
}
|
||||
export class QComboBox extends NodeWidget<QComboBoxSignals> {
|
||||
native: NativeElement;
|
||||
constructor(parent?: NodeWidget) {
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QComboBox(parent.native);
|
||||
|
||||
@ -1,20 +1,20 @@
|
||||
import addon from '../utils/addon';
|
||||
import { NodeWidget } from './QWidget';
|
||||
import { BaseWidgetEvents } from '../core/EventWidget';
|
||||
import { NativeElement } from '../core/Component';
|
||||
import { QAbstractSlider } from './QAbstractSlider';
|
||||
|
||||
export const QDialEvents = Object.freeze({
|
||||
...BaseWidgetEvents,
|
||||
valueChanged: 'valueChanged',
|
||||
rangeChanged: 'rangeChanged',
|
||||
sliderMoved: 'sliderMoved',
|
||||
sliderPressed: 'sliderPressed',
|
||||
sliderReleased: 'sliderReleased',
|
||||
});
|
||||
export class QDial extends QAbstractSlider {
|
||||
interface QDialSignals {
|
||||
valueChanged: (value: number) => void;
|
||||
rangeChanged: (min: number, max: number) => void;
|
||||
sliderMoved: (value: number) => void;
|
||||
sliderPressed: () => void;
|
||||
sliderReleased: () => void;
|
||||
}
|
||||
export class QDial extends QAbstractSlider<QDialSignals> {
|
||||
native: NativeElement;
|
||||
constructor(parent?: NodeWidget) {
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QDial(parent.native);
|
||||
@ -26,27 +26,21 @@ export class QDial extends QAbstractSlider {
|
||||
this.setNodeParent(parent);
|
||||
}
|
||||
setNotchesVisible(visible: boolean): void {
|
||||
// react:✓
|
||||
this.native.setNotchesVisible(visible);
|
||||
}
|
||||
notchesVisible(): boolean {
|
||||
// react:✓
|
||||
return this.native.notchesVisible();
|
||||
}
|
||||
setWrapping(on: boolean): void {
|
||||
// react:✓
|
||||
this.native.setWrapping(on);
|
||||
}
|
||||
wrapping(): boolean {
|
||||
// react:✓
|
||||
return this.native.wrapping();
|
||||
}
|
||||
setNotchTarget(target: number): void {
|
||||
// react:✓
|
||||
this.native.setNotchTarget(target);
|
||||
}
|
||||
notchTarget(): number {
|
||||
// react:✓
|
||||
return this.native.notchTarget();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,24 +1,25 @@
|
||||
import addon from '../utils/addon';
|
||||
import { NodeWidget } from './QWidget';
|
||||
import { BaseWidgetEvents } from '../core/EventWidget';
|
||||
import { NativeElement } from '../core/Component';
|
||||
import { AcceptMode, DialogLabel, FileMode, Option, ViewMode } from '../QtEnums';
|
||||
export const QFileDialogEvents = Object.freeze({
|
||||
currentChanged: 'currentChanged',
|
||||
currentUrlChanged: 'currentUrlChanged',
|
||||
directoryEntered: 'directoryEntered',
|
||||
directoryUrlEntered: 'directoryUrlEntered',
|
||||
fileSelected: 'fileSelected',
|
||||
filesSelected: 'filesSelected',
|
||||
filterSelected: 'filterSelected',
|
||||
urlSelected: 'urlSelected',
|
||||
urlsSelected: 'urlsSelected',
|
||||
...BaseWidgetEvents,
|
||||
});
|
||||
|
||||
export class QFileDialog extends NodeWidget {
|
||||
interface QFileDialogSignals {
|
||||
currentChanged: (path: string) => void;
|
||||
currentUrlChanged: (url: string) => void;
|
||||
directoryEntered: (directory: string) => void;
|
||||
directoryUrlEntered: (url: string) => void;
|
||||
fileSelected: (file: string) => void;
|
||||
filesSelected: (selected: string[]) => void;
|
||||
filterSelected: (filter: string) => void;
|
||||
urlSelected: (url: string) => void;
|
||||
urlsSelected: (urls: string[]) => void;
|
||||
}
|
||||
|
||||
export class QFileDialog extends NodeWidget<QFileDialogSignals> {
|
||||
native: NativeElement;
|
||||
constructor(parent: NodeWidget | undefined = undefined, caption = 'Select File', directory = '', filter = '') {
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>, caption?: string, directory?: string, filter?: string);
|
||||
constructor(parent?: NodeWidget<any>, caption = 'Select File', directory = '', filter = '') {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QFileDialog(parent.native, caption, directory, filter);
|
||||
|
||||
@ -3,9 +3,13 @@ import { NodeWidget } from './QWidget';
|
||||
import { NodeLayout } from './QLayout';
|
||||
import { NativeElement } from '../core/Component';
|
||||
|
||||
export class QGridLayout extends NodeLayout {
|
||||
type QGridLayoutSignals = {};
|
||||
|
||||
export class QGridLayout extends NodeLayout<QGridLayoutSignals> {
|
||||
native: NativeElement;
|
||||
constructor(parent?: NodeWidget) {
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
let native: NativeElement;
|
||||
if (parent) {
|
||||
native = new addon.QGridLayout(parent.native);
|
||||
@ -16,11 +20,11 @@ export class QGridLayout extends NodeLayout {
|
||||
this.setNodeParent(parent);
|
||||
this.native = native;
|
||||
}
|
||||
addWidget(widget: NodeWidget, row = 0, col = 0, rowSpan = 1, colSpan = 1): void {
|
||||
addWidget(widget: NodeWidget<any>, row = 0, col = 0, rowSpan = 1, colSpan = 1): void {
|
||||
this.native.addWidget(widget.native, row, col, rowSpan, colSpan);
|
||||
this.nodeChildren.add(widget);
|
||||
}
|
||||
removeWidget(widget: NodeWidget): void {
|
||||
removeWidget(widget: NodeWidget<any>): void {
|
||||
this.native.removeWidget(widget.native);
|
||||
this.nodeChildren.delete(widget);
|
||||
}
|
||||
|
||||
@ -1,17 +1,17 @@
|
||||
import addon from '../utils/addon';
|
||||
import { NodeWidget } from './QWidget';
|
||||
import { BaseWidgetEvents } from '../core/EventWidget';
|
||||
import { NativeElement } from '../core/Component';
|
||||
import { AlignmentFlag } from '../QtEnums/AlignmentFlag';
|
||||
|
||||
export const QGroupBoxEvents = Object.freeze({
|
||||
...BaseWidgetEvents,
|
||||
clicked: 'clicked',
|
||||
toggled: 'toggled',
|
||||
});
|
||||
export class QGroupBox extends NodeWidget {
|
||||
interface QGroupBoxSignals {
|
||||
clicked: (checked: boolean) => void;
|
||||
toggled: (on: boolean) => void;
|
||||
}
|
||||
export class QGroupBox extends NodeWidget<QGroupBoxSignals> {
|
||||
native: NativeElement;
|
||||
constructor(parent?: NodeWidget) {
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QGroupBox(parent.native);
|
||||
|
||||
@ -1,20 +1,19 @@
|
||||
import addon from '../utils/addon';
|
||||
import { NodeWidget } from './QWidget';
|
||||
import { BaseWidgetEvents } from '../core/EventWidget';
|
||||
import { NativeElement } from '../core/Component';
|
||||
import { QPixmap } from '../QtGui/QPixmap';
|
||||
import { QMovie } from '../QtGui/QMovie';
|
||||
import { AlignmentFlag } from '../QtEnums/AlignmentFlag';
|
||||
import { TextFormat } from '../QtEnums/TextFormat';
|
||||
|
||||
export const QLabelEvents = Object.freeze({
|
||||
...BaseWidgetEvents,
|
||||
});
|
||||
export class QLabel extends NodeWidget {
|
||||
type QLabelSignals = {};
|
||||
export class QLabel extends NodeWidget<QLabelSignals> {
|
||||
native: NativeElement;
|
||||
private _pixmap?: QPixmap;
|
||||
private _movie?: QMovie;
|
||||
constructor(parent?: NodeWidget) {
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QLabel(parent.native);
|
||||
|
||||
@ -2,10 +2,10 @@ import { NodeWidget } from './QWidget';
|
||||
import { NodeObject } from '../QtCore/QObject';
|
||||
|
||||
// All Layouts should extend this abstract class.
|
||||
export abstract class NodeLayout extends NodeObject {
|
||||
export abstract class NodeLayout<Signals> extends NodeObject<Signals> {
|
||||
type = 'layout';
|
||||
abstract addWidget(childWidget: NodeWidget, ...args: any[]): void;
|
||||
abstract removeWidget(childWidget: NodeWidget): void;
|
||||
abstract addWidget(childWidget: NodeWidget<any>, ...args: any[]): void;
|
||||
abstract removeWidget(childWidget: NodeWidget<any>): void;
|
||||
activate(): boolean {
|
||||
return this.native.activate();
|
||||
}
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import addon from '../utils/addon';
|
||||
import { NodeWidget } from './QWidget';
|
||||
import { BaseWidgetEvents } from '../core/EventWidget';
|
||||
import { NativeElement } from '../core/Component';
|
||||
|
||||
export enum EchoMode {
|
||||
@ -9,20 +8,21 @@ export enum EchoMode {
|
||||
Password,
|
||||
PasswordEchoOnEdit,
|
||||
}
|
||||
export const QLineEditEvents = Object.freeze({
|
||||
...BaseWidgetEvents,
|
||||
cursorPositionChanged: 'cursorPositionChanged',
|
||||
editingFinished: 'editingFinished',
|
||||
inputRejected: 'inputRejected',
|
||||
returnPressed: 'returnPressed',
|
||||
selectionChanged: 'selectionChanged',
|
||||
textChanged: 'textChanged',
|
||||
textEdited: 'textEdited',
|
||||
});
|
||||
export class QLineEdit extends NodeWidget {
|
||||
interface QLineEditSignals {
|
||||
cursorPositionChanged: (oldPos: number, newPos: number) => void;
|
||||
editingFinished: () => void;
|
||||
inputRejected: () => void;
|
||||
returnPressed: () => void;
|
||||
selectionChanged: () => void;
|
||||
textChanged: (text: string) => void;
|
||||
textEdited: (text: string) => void;
|
||||
}
|
||||
export class QLineEdit extends NodeWidget<QLineEditSignals> {
|
||||
native: NativeElement;
|
||||
placeholderText?: string;
|
||||
constructor(parent?: NodeWidget) {
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QLineEdit(parent.native);
|
||||
|
||||
@ -1,18 +1,17 @@
|
||||
import addon from '../utils/addon';
|
||||
import { NodeWidget } from './QWidget';
|
||||
import { BaseWidgetEvents } from '../core/EventWidget';
|
||||
import { NativeElement } from '../core/Component';
|
||||
import { NodeLayout } from './QLayout';
|
||||
import { QMenuBar } from './QMenuBar';
|
||||
|
||||
export const QMainWindowEvents = Object.freeze({
|
||||
...BaseWidgetEvents,
|
||||
});
|
||||
export class QMainWindow extends NodeWidget {
|
||||
type QMainWindowSignals = {};
|
||||
export class QMainWindow extends NodeWidget<QMainWindowSignals> {
|
||||
native: NativeElement;
|
||||
public centralWidget?: NodeWidget | null;
|
||||
public centralWidget?: NodeWidget<any> | null;
|
||||
private _menuBar?: QMenuBar;
|
||||
constructor(parent?: NodeWidget) {
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QMainWindow(parent.native);
|
||||
@ -23,7 +22,7 @@ export class QMainWindow extends NodeWidget {
|
||||
this.native = native;
|
||||
this.setNodeParent(parent);
|
||||
|
||||
this.setLayout = (parentLayout: NodeLayout): void => {
|
||||
this.setLayout = (parentLayout: NodeLayout<any>): void => {
|
||||
if (this.centralWidget) {
|
||||
this.centralWidget.setLayout(parentLayout);
|
||||
} else {
|
||||
@ -32,13 +31,13 @@ export class QMainWindow extends NodeWidget {
|
||||
}
|
||||
};
|
||||
}
|
||||
setCentralWidget(widget: NodeWidget): void {
|
||||
setCentralWidget(widget: NodeWidget<any>): void {
|
||||
// react:✓
|
||||
this.native.setCentralWidget(widget.native);
|
||||
this.centralWidget = widget;
|
||||
this.centralWidget.setFlexNodeSizeControlled(true);
|
||||
}
|
||||
takeCentralWidget(): NodeWidget | null {
|
||||
takeCentralWidget(): NodeWidget<any> | null {
|
||||
// react:✓
|
||||
const centralWidget = this.centralWidget;
|
||||
this.centralWidget = null;
|
||||
@ -55,10 +54,10 @@ export class QMainWindow extends NodeWidget {
|
||||
menuBar(): QMenuBar | undefined {
|
||||
return this._menuBar;
|
||||
}
|
||||
setMenuWidget(menuWidget: NodeWidget): void {
|
||||
setMenuWidget(menuWidget: NodeWidget<any>): void {
|
||||
this.native.setMenuWidget(menuWidget.native);
|
||||
}
|
||||
get layout(): NodeLayout | undefined {
|
||||
get layout(): NodeLayout<any> | undefined {
|
||||
if (this.centralWidget) {
|
||||
return this.centralWidget.layout;
|
||||
}
|
||||
|
||||
@ -1,16 +1,15 @@
|
||||
import { BaseWidgetEvents } from '../core/EventWidget';
|
||||
import { NativeElement } from '../core/Component';
|
||||
import { NodeWidget } from './QWidget';
|
||||
import addon from '../utils/addon';
|
||||
import { QAction } from './QAction';
|
||||
export const QMenuEvents = Object.freeze({
|
||||
...BaseWidgetEvents,
|
||||
});
|
||||
|
||||
export class QMenu extends NodeWidget {
|
||||
type QMenuSignals = {};
|
||||
export class QMenu extends NodeWidget<QMenuSignals> {
|
||||
native: NativeElement;
|
||||
actions: Set<QAction>;
|
||||
constructor(parent?: NodeWidget) {
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QMenu(parent.native);
|
||||
|
||||
@ -1,26 +1,24 @@
|
||||
import { QMenu } from './QMenu';
|
||||
import { BaseWidgetEvents } from '../core/EventWidget';
|
||||
import { NativeElement } from '../core/Component';
|
||||
import { NodeWidget } from './QWidget';
|
||||
import addon from '../utils/addon';
|
||||
import { checkIfNativeElement } from '../utils/helpers';
|
||||
|
||||
export const QMenuBarEvents = Object.freeze({
|
||||
...BaseWidgetEvents,
|
||||
});
|
||||
type QMenuBarSignals = {};
|
||||
|
||||
type arg = NodeWidget | NativeElement;
|
||||
|
||||
export class QMenuBar extends NodeWidget {
|
||||
export class QMenuBar extends NodeWidget<QMenuBarSignals> {
|
||||
native: NativeElement;
|
||||
constructor(arg?: arg) {
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(native: NativeElement);
|
||||
constructor(arg?: NodeWidget<any> | NativeElement) {
|
||||
let native;
|
||||
let parent;
|
||||
if (checkIfNativeElement(arg)) {
|
||||
native = arg as NativeElement;
|
||||
} else if (typeof arg === 'object') {
|
||||
native = new addon.QMenuBar(arg.native);
|
||||
parent = arg as NodeWidget;
|
||||
parent = arg as NodeWidget<any>;
|
||||
} else {
|
||||
native = new addon.QMenuBar();
|
||||
}
|
||||
|
||||
@ -16,7 +16,8 @@ export enum RenderHint {
|
||||
|
||||
export class QPainter extends Component {
|
||||
native: NativeElement;
|
||||
|
||||
constructor();
|
||||
constructor(device: Component);
|
||||
constructor(device?: Component) {
|
||||
let native;
|
||||
if (device) {
|
||||
|
||||
@ -1,30 +1,30 @@
|
||||
import addon from '../utils/addon';
|
||||
import { NodeWidget } from './QWidget';
|
||||
import { BaseWidgetEvents } from '../core/EventWidget';
|
||||
import { NativeElement } from '../core/Component';
|
||||
import { QAbstractScrollArea } from './QAbstractScrollArea';
|
||||
import { QTextOptionWrapMode } from '../QtGui/QTextOption';
|
||||
|
||||
export const QPlainTextEditEvents = Object.freeze({
|
||||
...BaseWidgetEvents,
|
||||
textChanged: 'textChanged',
|
||||
blockCountChanged: 'blockCountChanged',
|
||||
copyAvailable: 'copyAvailable',
|
||||
cursorPositionChanged: 'cursorPositionChanged',
|
||||
modificationChanged: 'modificationChanged',
|
||||
redoAvailable: 'redoAvailable',
|
||||
selectionChanged: 'selectionChanged',
|
||||
undoAvailable: 'undoAvailable',
|
||||
});
|
||||
interface QPlainTextEditSignals {
|
||||
textChanged: () => void;
|
||||
blockCountChanged: (blockCount: number) => void;
|
||||
copyAvailable: (yes: boolean) => void;
|
||||
cursorPositionChanged: () => void;
|
||||
modificationChanged: (changed: boolean) => void;
|
||||
redoAvailable: (available: boolean) => void;
|
||||
selectionChanged: () => void;
|
||||
undoAvailable: (available: boolean) => void;
|
||||
}
|
||||
|
||||
export enum LineWrapMode {
|
||||
NoWrap,
|
||||
WidgetWidth,
|
||||
}
|
||||
export class QPlainTextEdit extends QAbstractScrollArea {
|
||||
export class QPlainTextEdit extends QAbstractScrollArea<QPlainTextEditSignals> {
|
||||
native: NativeElement;
|
||||
placeholderText?: string;
|
||||
constructor(parent?: NodeWidget) {
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QPlainTextEdit(parent.native);
|
||||
|
||||
@ -1,15 +1,14 @@
|
||||
import addon from '../utils/addon';
|
||||
import { NodeWidget } from './QWidget';
|
||||
import { BaseWidgetEvents } from '../core/EventWidget';
|
||||
import { NativeElement } from '../core/Component';
|
||||
import { Orientation } from '../QtEnums';
|
||||
|
||||
export const QProgressBarEvents = Object.freeze({
|
||||
...BaseWidgetEvents,
|
||||
});
|
||||
export class QProgressBar extends NodeWidget {
|
||||
type QProgressBarSignals = {};
|
||||
export class QProgressBar extends NodeWidget<QProgressBarSignals> {
|
||||
native: NativeElement;
|
||||
constructor(parent?: NodeWidget) {
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QProgressBar(parent.native);
|
||||
|
||||
@ -1,20 +1,20 @@
|
||||
import addon from '../utils/addon';
|
||||
import { NodeWidget } from './QWidget';
|
||||
import { BaseWidgetEvents } from '../core/EventWidget';
|
||||
import { NativeElement } from '../core/Component';
|
||||
import { QAbstractButton } from './QAbstractButton';
|
||||
|
||||
export const QPushButtonEvents = Object.freeze({
|
||||
...BaseWidgetEvents,
|
||||
clicked: 'clicked',
|
||||
pressed: 'pressed',
|
||||
released: 'released',
|
||||
toggled: 'toggled',
|
||||
});
|
||||
interface QPushButtonSignals {
|
||||
clicked: (checked: boolean) => void;
|
||||
pressed: () => void;
|
||||
released: () => void;
|
||||
toggled: (checked: boolean) => void;
|
||||
}
|
||||
|
||||
export class QPushButton extends QAbstractButton {
|
||||
export class QPushButton extends QAbstractButton<QPushButtonSignals> {
|
||||
native: NativeElement;
|
||||
constructor(parent?: NodeWidget) {
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QPushButton(parent.native);
|
||||
|
||||
@ -1,15 +1,14 @@
|
||||
import addon from '../utils/addon';
|
||||
import { NodeWidget } from './QWidget';
|
||||
import { BaseWidgetEvents } from '../core/EventWidget';
|
||||
import { NativeElement } from '../core/Component';
|
||||
import { QAbstractButton } from './QAbstractButton';
|
||||
|
||||
export const QRadioButtonEvents = Object.freeze({
|
||||
...BaseWidgetEvents,
|
||||
});
|
||||
export class QRadioButton extends QAbstractButton {
|
||||
type QRadioButtonSignals = {};
|
||||
export class QRadioButton extends QAbstractButton<QRadioButtonSignals> {
|
||||
native: NativeElement;
|
||||
constructor(parent?: NodeWidget) {
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QRadioButton(parent.native);
|
||||
|
||||
@ -1,16 +1,15 @@
|
||||
import addon from '../utils/addon';
|
||||
import { NodeWidget } from './QWidget';
|
||||
import { BaseWidgetEvents } from '../core/EventWidget';
|
||||
import { NativeElement } from '../core/Component';
|
||||
import { QAbstractScrollArea } from './QAbstractScrollArea';
|
||||
|
||||
export const QScrollAreaEvents = Object.freeze({
|
||||
...BaseWidgetEvents,
|
||||
});
|
||||
export class QScrollArea extends QAbstractScrollArea {
|
||||
type QScrollAreaSignals = {};
|
||||
export class QScrollArea extends QAbstractScrollArea<QScrollAreaSignals> {
|
||||
native: NativeElement;
|
||||
contentWidget?: NodeWidget | null;
|
||||
constructor(parent?: NodeWidget) {
|
||||
contentWidget?: NodeWidget<any> | null;
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QScrollArea(parent.native);
|
||||
@ -22,13 +21,13 @@ export class QScrollArea extends QAbstractScrollArea {
|
||||
this.setNodeParent(parent);
|
||||
this.setWidgetResizable(true);
|
||||
}
|
||||
setWidget(widget: NodeWidget): void {
|
||||
setWidget(widget: NodeWidget<any>): void {
|
||||
// react:✓, //TODO:getter
|
||||
this.contentWidget = widget;
|
||||
this.native.setWidget(widget.native);
|
||||
this.contentWidget.setFlexNodeSizeControlled(this.widgetResizable());
|
||||
}
|
||||
takeWidget(): NodeWidget | null {
|
||||
takeWidget(): NodeWidget<any> | null {
|
||||
// react:✓
|
||||
const contentWidget = this.contentWidget;
|
||||
this.contentWidget = null;
|
||||
|
||||
@ -5,14 +5,14 @@ import { QKeySequence } from '../QtGui/QKeySequence';
|
||||
import { ShortcutContext } from '../QtEnums';
|
||||
import { NodeObject } from '../QtCore/QObject';
|
||||
|
||||
export const QShortcutEvents = Object.freeze({
|
||||
activated: 'activated',
|
||||
activatedAmbiguously: 'activatedAmbiguously',
|
||||
});
|
||||
interface QShortcutSignals {
|
||||
activated: () => void;
|
||||
activatedAmbiguously: () => void;
|
||||
}
|
||||
|
||||
export class QShortcut extends NodeObject {
|
||||
export class QShortcut extends NodeObject<QShortcutSignals> {
|
||||
native: NativeElement;
|
||||
constructor(parent: NodeWidget) {
|
||||
constructor(parent: NodeWidget<any>) {
|
||||
const native = new addon.QShortcut(parent.native);
|
||||
super(native);
|
||||
this.native = native;
|
||||
|
||||
@ -1,16 +1,16 @@
|
||||
import addon from '../utils/addon';
|
||||
import { NodeWidget } from './QWidget';
|
||||
import { BaseWidgetEvents } from '../core/EventWidget';
|
||||
import { NativeElement } from '../core/Component';
|
||||
|
||||
export const QSpinBoxEvents = Object.freeze({
|
||||
...BaseWidgetEvents,
|
||||
valueChanged: 'valueChanged',
|
||||
});
|
||||
interface QSpinBoxSignals {
|
||||
valueChanged: (value: number) => void;
|
||||
}
|
||||
|
||||
export class QSpinBox extends NodeWidget {
|
||||
export class QSpinBox extends NodeWidget<QSpinBoxSignals> {
|
||||
native: NativeElement;
|
||||
constructor(parent?: NodeWidget) {
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QSpinBox(parent.native);
|
||||
|
||||
@ -1,16 +1,16 @@
|
||||
import addon from '../utils/addon';
|
||||
import { NodeWidget } from './QWidget';
|
||||
import { BaseWidgetEvents } from '../core/EventWidget';
|
||||
import { NativeElement } from '../core/Component';
|
||||
|
||||
export const QStackedWidgetEvents = Object.freeze({
|
||||
...BaseWidgetEvents,
|
||||
currentChanged: 'currentChanged',
|
||||
});
|
||||
interface QStackedWidgetSignals {
|
||||
currentChanged: (index: number) => void;
|
||||
}
|
||||
|
||||
export class QStackedWidget extends NodeWidget {
|
||||
export class QStackedWidget extends NodeWidget<QStackedWidgetSignals> {
|
||||
native: NativeElement;
|
||||
constructor(parent?: NodeWidget) {
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QStackedWidget(parent.native);
|
||||
@ -22,13 +22,13 @@ export class QStackedWidget extends NodeWidget {
|
||||
this.native = native;
|
||||
}
|
||||
|
||||
addWidget(widget: NodeWidget): void {
|
||||
addWidget(widget: NodeWidget<any>): void {
|
||||
this.native.addWidget(widget.native);
|
||||
this.nodeChildren.add(widget);
|
||||
widget.setFlexNodeSizeControlled(true);
|
||||
}
|
||||
|
||||
removeWidget(widget: NodeWidget): void {
|
||||
removeWidget(widget: NodeWidget<any>): void {
|
||||
this.native.removeWidget(widget.native);
|
||||
this.nodeChildren.delete(widget);
|
||||
}
|
||||
@ -41,7 +41,7 @@ export class QStackedWidget extends NodeWidget {
|
||||
return this.native.currentIndex();
|
||||
}
|
||||
|
||||
setCurrentWidget(widget: NodeWidget): void {
|
||||
setCurrentWidget(widget: NodeWidget<any>): void {
|
||||
this.native.setCurrentWidget(widget.native);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,27 +1,21 @@
|
||||
import addon from '../utils/addon';
|
||||
import { NodeWidget } from './QWidget';
|
||||
import { BaseWidgetEvents } from '../core/EventWidget';
|
||||
import { NativeElement } from '../core/Component';
|
||||
import { QIcon } from '../QtGui/QIcon';
|
||||
import { QMenu } from './QMenu';
|
||||
import { NodeObject } from '../QtCore/QObject';
|
||||
|
||||
export const QSystemTrayIconEvents = Object.freeze({
|
||||
...BaseWidgetEvents,
|
||||
activated: 'activated',
|
||||
messageClicked: 'messageClicked',
|
||||
});
|
||||
export const QSystemTrayIconActivationReason = Object.freeze({
|
||||
Unknown: 0,
|
||||
Context: 1,
|
||||
DoubleClick: 2,
|
||||
Trigger: 3,
|
||||
MiddleClick: 4,
|
||||
});
|
||||
export class QSystemTrayIcon extends NodeObject {
|
||||
interface QSystemTrayIconSignals {
|
||||
activated: (reason: QSystemTrayIconActivationReason) => void;
|
||||
messageClicked: () => void;
|
||||
}
|
||||
|
||||
export class QSystemTrayIcon extends NodeObject<QSystemTrayIconSignals> {
|
||||
native: NativeElement;
|
||||
contextMenu?: QMenu;
|
||||
constructor(parent?: NodeWidget) {
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QSystemTrayIcon(parent.native);
|
||||
@ -54,3 +48,11 @@ export class QSystemTrayIcon extends NodeObject {
|
||||
this.native.setContextMenu(this.contextMenu.native);
|
||||
}
|
||||
}
|
||||
|
||||
export enum QSystemTrayIconActivationReason {
|
||||
Unknown = 0,
|
||||
Context = 1,
|
||||
DoubleClick = 2,
|
||||
Trigger = 3,
|
||||
MiddleClick = 4,
|
||||
}
|
||||
|
||||
@ -1,22 +1,22 @@
|
||||
import addon from '../utils/addon';
|
||||
import { NodeWidget } from './QWidget';
|
||||
import { BaseWidgetEvents } from '../core/EventWidget';
|
||||
import { NativeElement } from '../core/Component';
|
||||
import { QIcon } from '../QtGui/QIcon';
|
||||
import { TabPosition } from '../QtEnums';
|
||||
|
||||
export const QTabWidgetEvents = Object.freeze({
|
||||
...BaseWidgetEvents,
|
||||
currentChanged: 'currentChanged',
|
||||
tabBarClicked: 'tabBarClicked',
|
||||
tabBarDoubleClicked: 'tabBarDoubleClicked',
|
||||
tabCloseRequested: 'tabCloseRequested',
|
||||
});
|
||||
interface QTabWidgetSignals {
|
||||
currentChanged: (index: number) => void;
|
||||
tabBarClicked: (index: number) => void;
|
||||
tabBarDoubleClicked: (index: number) => void;
|
||||
tabCloseRequested: (index: number) => void;
|
||||
}
|
||||
|
||||
export class QTabWidget extends NodeWidget {
|
||||
export class QTabWidget extends NodeWidget<QTabWidgetSignals> {
|
||||
native: NativeElement;
|
||||
tabs: NodeWidget[];
|
||||
constructor(parent?: NodeWidget) {
|
||||
tabs: NodeWidget<any>[];
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QTabWidget(parent.native);
|
||||
@ -29,7 +29,7 @@ export class QTabWidget extends NodeWidget {
|
||||
this.native = native;
|
||||
}
|
||||
|
||||
addTab(page: NodeWidget, icon: QIcon, label: string): void {
|
||||
addTab(page: NodeWidget<any>, icon: QIcon, label: string): void {
|
||||
this.native.addTab(page.native, icon.native, label);
|
||||
this.tabs.push(page);
|
||||
page.setFlexNodeSizeControlled(true);
|
||||
|
||||
@ -1,35 +1,31 @@
|
||||
import addon from '../utils/addon';
|
||||
import { NodeWidget } from './QWidget';
|
||||
import { BaseWidgetEvents } from '../core/EventWidget';
|
||||
import { NativeElement, Component } from '../core/Component';
|
||||
import { ScrollHint, SortOrder } from '../QtEnums';
|
||||
import { QTableWidgetItem } from './QTableWidgetItem';
|
||||
import { QAbstractScrollArea } from './QAbstractScrollArea';
|
||||
|
||||
export const QTableWidgetEvents = Object.freeze({
|
||||
...BaseWidgetEvents,
|
||||
cellActivated: 'cellActivated',
|
||||
cellChanged: 'cellChanged',
|
||||
cellClicked: 'cellClicked',
|
||||
cellDoubleClicked: 'cellDoubleClicked',
|
||||
cellEntered: 'cellEntered',
|
||||
cellPressed: 'cellPressed',
|
||||
currentCellChanged: 'currentCellChanged',
|
||||
});
|
||||
|
||||
interface Range {
|
||||
topRow: number;
|
||||
rightColumn: number;
|
||||
bottomRow: number;
|
||||
leftColumn: number;
|
||||
columnCount: number;
|
||||
rowCount: number;
|
||||
interface QTableWidgetSignals {
|
||||
cellActivated: (row: number, col: number) => void;
|
||||
cellChanged: (row: number, col: number) => void;
|
||||
cellClicked: (row: number, col: number) => void;
|
||||
cellDoubleClicked: (row: number, col: number) => void;
|
||||
cellEntered: (row: number, col: number) => void;
|
||||
cellPressed: (row: number, col: number) => void;
|
||||
currentCellChanged: (
|
||||
currentRow: number,
|
||||
currentColumn: number,
|
||||
previousRow: number,
|
||||
previousColumn: number,
|
||||
) => void;
|
||||
}
|
||||
|
||||
export class QTableWidget extends QAbstractScrollArea {
|
||||
export class QTableWidget extends QAbstractScrollArea<QTableWidgetSignals> {
|
||||
native: NativeElement;
|
||||
items: Set<NativeElement | Component>;
|
||||
constructor(rows: number, columns: number, parent?: NodeWidget) {
|
||||
constructor(rows: number, columns: number);
|
||||
constructor(rows: number, columns: number, parent: NodeWidget<any>);
|
||||
constructor(rows: number, columns: number, parent?: NodeWidget<any>) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QTableWidget(rows, columns, parent);
|
||||
@ -50,7 +46,7 @@ export class QTableWidget extends QAbstractScrollArea {
|
||||
editItem(item: Component): void {
|
||||
this.native.editItem(item.native);
|
||||
}
|
||||
setCellWidget(row: number, column: number, widget: NodeWidget): void {
|
||||
setCellWidget(row: number, column: number, widget: NodeWidget<any>): void {
|
||||
this.native.setCellWidget(row, column, widget.native);
|
||||
this.items.add(widget);
|
||||
}
|
||||
@ -148,3 +144,12 @@ export class QTableWidget extends QAbstractScrollArea {
|
||||
return this.native.isSortingEnabled();
|
||||
}
|
||||
}
|
||||
|
||||
interface Range {
|
||||
topRow: number;
|
||||
rightColumn: number;
|
||||
bottomRow: number;
|
||||
leftColumn: number;
|
||||
columnCount: number;
|
||||
rowCount: number;
|
||||
}
|
||||
|
||||
@ -4,6 +4,8 @@ import { AlignmentFlag } from '../QtEnums';
|
||||
|
||||
export class QTableWidgetItem extends Component {
|
||||
native: NativeElement;
|
||||
constructor();
|
||||
constructor(text: string);
|
||||
constructor(text?: string) {
|
||||
let native;
|
||||
if (text) {
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import addon from '../utils/addon';
|
||||
import { NodeWidget } from './QWidget';
|
||||
import { BaseWidgetEvents } from '../core/EventWidget';
|
||||
import { NativeElement } from '../core/Component';
|
||||
import { QAbstractButton } from './QAbstractButton';
|
||||
import { ToolButtonStyle } from '../QtEnums/ToolButtonStyle';
|
||||
@ -14,18 +13,18 @@ export enum ToolButtonPopupMode {
|
||||
InstantPopup,
|
||||
}
|
||||
|
||||
export const QToolButtonEvents = Object.freeze({
|
||||
...BaseWidgetEvents,
|
||||
clicked: 'clicked',
|
||||
pressed: 'pressed',
|
||||
released: 'released',
|
||||
toggled: 'toggled',
|
||||
triggered: 'triggered',
|
||||
});
|
||||
|
||||
export class QToolButton extends QAbstractButton {
|
||||
interface QToolButtonSignals {
|
||||
clicked: (checked: boolean) => void;
|
||||
pressed: () => void;
|
||||
released: () => void;
|
||||
toggled: (checked: boolean) => void;
|
||||
triggered: (nativeAction: NativeElement) => void;
|
||||
}
|
||||
export class QToolButton extends QAbstractButton<QToolButtonSignals> {
|
||||
native: NativeElement;
|
||||
constructor(parent?: NodeWidget) {
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QToolButton(parent.native);
|
||||
|
||||
@ -1,19 +1,19 @@
|
||||
import addon from '../utils/addon';
|
||||
import { NodeWidget } from './QWidget';
|
||||
import { BaseWidgetEvents } from '../core/EventWidget';
|
||||
import { NativeElement } from '../core/Component';
|
||||
import { QAbstractScrollArea } from './QAbstractScrollArea';
|
||||
import { QTreeWidgetItem } from './QTreeWidgetItem';
|
||||
|
||||
export const QTreeWidgetEvents = Object.freeze({
|
||||
...BaseWidgetEvents,
|
||||
itemSelectionChanged: 'itemSelectionChanged',
|
||||
});
|
||||
interface QTreeWidgetSignals {
|
||||
itemSelectionChanged: () => void;
|
||||
}
|
||||
|
||||
export class QTreeWidget extends QAbstractScrollArea {
|
||||
export class QTreeWidget extends QAbstractScrollArea<QTreeWidgetSignals> {
|
||||
native: NativeElement;
|
||||
topLevelItems: Set<QTreeWidgetItem>;
|
||||
constructor(parent?: NodeWidget) {
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QTreeWidget(parent.native);
|
||||
|
||||
@ -5,7 +5,11 @@ import { QTreeWidget } from './QTreeWidget';
|
||||
|
||||
export class QTreeWidgetItem extends Component {
|
||||
native: NativeElement;
|
||||
|
||||
constructor();
|
||||
constructor(parent: QTreeWidgetItem, strings?: string[]);
|
||||
constructor(parent: QTreeWidget, strings?: string[]);
|
||||
constructor(native: NativeElement);
|
||||
constructor(strings: string[]);
|
||||
constructor(parent?: NativeElement | QTreeWidgetItem | QTreeWidget | string[], strings?: string[]) {
|
||||
super();
|
||||
if (checkIfNativeElement(parent)) {
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import addon from '../utils/addon';
|
||||
import { NodeLayout } from './QLayout';
|
||||
import { BaseWidgetEvents } from '../core/EventWidget';
|
||||
import { NativeElement } from '../core/Component';
|
||||
import { FlexLayout } from '../core/FlexLayout';
|
||||
import { WidgetAttribute, WindowType } from '../QtEnums';
|
||||
@ -14,8 +13,8 @@ import { QSize } from '../QtCore/QSize';
|
||||
import { QRect } from '../QtCore/QRect';
|
||||
// All Widgets should extend from NodeWidget
|
||||
// Implement all native QWidget methods here so that all widgets get access to those aswell
|
||||
export abstract class NodeWidget extends YogaWidget {
|
||||
layout?: NodeLayout;
|
||||
export abstract class NodeWidget<Signals> extends YogaWidget<Signals> {
|
||||
layout?: NodeLayout<Signals>;
|
||||
_rawInlineStyle = '';
|
||||
type = 'widget';
|
||||
show(): void {
|
||||
@ -131,7 +130,7 @@ export abstract class NodeWidget extends YogaWidget {
|
||||
// react:⛔️
|
||||
return this.native.setWindowFlag(windowType, switchOn);
|
||||
}
|
||||
setLayout(parentLayout: NodeLayout): void {
|
||||
setLayout(parentLayout: NodeLayout<Signals>): void {
|
||||
const flexLayout = parentLayout as FlexLayout;
|
||||
this.native.setLayout(parentLayout.native);
|
||||
if (flexLayout.setFlexNode) {
|
||||
@ -172,15 +171,16 @@ export abstract class NodeWidget extends YogaWidget {
|
||||
}
|
||||
}
|
||||
|
||||
export class QWidget extends NodeWidget {
|
||||
type QWidgetSignals = {};
|
||||
export class QWidget extends NodeWidget<QWidgetSignals> {
|
||||
native: NativeElement;
|
||||
constructor(arg?: NodeWidget | NativeElement) {
|
||||
constructor(arg?: NodeWidget<QWidgetSignals> | NativeElement) {
|
||||
let native;
|
||||
let parent;
|
||||
if (checkIfNativeElement(arg)) {
|
||||
native = arg as NativeElement;
|
||||
} else if (arg as NodeWidget) {
|
||||
parent = arg as NodeWidget;
|
||||
} else if (arg as NodeWidget<QWidgetSignals>) {
|
||||
parent = arg as NodeWidget<QWidgetSignals>;
|
||||
native = new addon.QWidget(parent.native);
|
||||
} else {
|
||||
native = new addon.QWidget();
|
||||
@ -190,5 +190,3 @@ export class QWidget extends NodeWidget {
|
||||
this.native = native;
|
||||
}
|
||||
}
|
||||
|
||||
export const QWidgetEvents = BaseWidgetEvents;
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
import { EventEmitter } from 'events';
|
||||
import { NativeElement, Component } from './Component';
|
||||
|
||||
export type NativeEvent = {};
|
||||
export abstract class EventWidget extends Component {
|
||||
export abstract class EventWidget<Signals extends {}> extends Component {
|
||||
private emitter: EventEmitter;
|
||||
constructor(native: NativeElement) {
|
||||
super();
|
||||
@ -14,167 +12,171 @@ export abstract class EventWidget extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
addEventListener(eventType: string, callback: (payload?: NativeEvent | any) => void): void {
|
||||
this.native.subscribeToQtEvent(eventType);
|
||||
this.emitter.addListener(eventType, callback);
|
||||
addEventListener<SignalType extends keyof Signals>(signalType: SignalType, callback: Signals[SignalType]): void;
|
||||
addEventListener(eventType: WidgetEventTypes, callback: (event?: NativeElement) => void): void;
|
||||
addEventListener(eventOrSignalType: string, callback: (...payloads: any[]) => void): void {
|
||||
this.native.subscribeToQtEvent(eventOrSignalType);
|
||||
this.emitter.addListener(eventOrSignalType, callback);
|
||||
}
|
||||
|
||||
removeEventListener(eventType: string, callback?: (payload?: NativeEvent | any) => void): void {
|
||||
removeEventListener<SignalType extends keyof Signals>(signalType: SignalType, callback: Signals[SignalType]): void;
|
||||
removeEventListener(eventType: WidgetEventTypes, callback: (event?: NativeElement) => void): void;
|
||||
removeEventListener(eventOrSignalType: string, callback?: (...payloads: any[]) => void): void {
|
||||
if (callback) {
|
||||
this.emitter.removeListener(eventType, callback);
|
||||
this.emitter.removeListener(eventOrSignalType, callback);
|
||||
} else {
|
||||
this.emitter.removeAllListeners(eventType);
|
||||
this.emitter.removeAllListeners(eventOrSignalType);
|
||||
}
|
||||
if (this.emitter.listenerCount(eventType) < 1) {
|
||||
this.native.unSubscribeToQtEvent(eventType);
|
||||
if (this.emitter.listenerCount(eventOrSignalType) < 1) {
|
||||
this.native.unSubscribeToQtEvent(eventOrSignalType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const BaseWidgetEvents = Object.freeze({
|
||||
None: 'None',
|
||||
ActionAdded: 'ActionAdded',
|
||||
ActionChanged: 'ActionChanged',
|
||||
ActionRemoved: 'ActionRemoved',
|
||||
ActivationChange: 'ActivationChange',
|
||||
ApplicationActivate: 'ApplicationActivate',
|
||||
ApplicationActivated: 'ApplicationActivated',
|
||||
ApplicationDeactivate: 'ApplicationDeactivate',
|
||||
ApplicationFontChange: 'ApplicationFontChange',
|
||||
ApplicationLayoutDirectionChange: 'ApplicationLayoutDirectionChange',
|
||||
ApplicationPaletteChange: 'ApplicationPaletteChange',
|
||||
ApplicationStateChange: 'ApplicationStateChange',
|
||||
ApplicationWindowIconChange: 'ApplicationWindowIconChange',
|
||||
ChildAdded: 'ChildAdded',
|
||||
ChildPolished: 'ChildPolished',
|
||||
ChildRemoved: 'ChildRemoved',
|
||||
Clipboard: 'Clipboard',
|
||||
Close: 'Close',
|
||||
CloseSoftwareInputPanel: 'CloseSoftwareInputPanel',
|
||||
ContentsRectChange: 'ContentsRectChange',
|
||||
ContextMenu: 'ContextMenu',
|
||||
CursorChange: 'CursorChange',
|
||||
DeferredDelete: 'DeferredDelete',
|
||||
DragEnter: 'DragEnter',
|
||||
DragLeave: 'DragLeave',
|
||||
DragMove: 'DragMove',
|
||||
Drop: 'Drop',
|
||||
DynamicPropertyChange: 'DynamicPropertyChange',
|
||||
EnabledChange: 'EnabledChange',
|
||||
Enter: 'Enter',
|
||||
EnterWhatsThisMode: 'EnterWhatsThisMode',
|
||||
Expose: 'Expose',
|
||||
FileOpen: 'FileOpen',
|
||||
FocusIn: 'FocusIn',
|
||||
FocusOut: 'FocusOut',
|
||||
FocusAboutToChange: 'FocusAboutToChange',
|
||||
FontChange: 'FontChange',
|
||||
Gesture: 'Gesture',
|
||||
GestureOverride: 'GestureOverride',
|
||||
GrabKeyboard: 'GrabKeyboard',
|
||||
GrabMouse: 'GrabMouse',
|
||||
GraphicsSceneContextMenu: 'GraphicsSceneContextMenu',
|
||||
GraphicsSceneDragEnter: 'GraphicsSceneDragEnter',
|
||||
GraphicsSceneDragLeave: 'GraphicsSceneDragLeave',
|
||||
GraphicsSceneDragMove: 'GraphicsSceneDragMove',
|
||||
GraphicsSceneDrop: 'GraphicsSceneDrop',
|
||||
GraphicsSceneHelp: 'GraphicsSceneHelp',
|
||||
GraphicsSceneHoverEnter: 'GraphicsSceneHoverEnter',
|
||||
GraphicsSceneHoverLeave: 'GraphicsSceneHoverLeave',
|
||||
GraphicsSceneHoverMove: 'GraphicsSceneHoverMove',
|
||||
GraphicsSceneMouseDoubleClick: 'GraphicsSceneMouseDoubleClick',
|
||||
GraphicsSceneMouseMove: 'GraphicsSceneMouseMove',
|
||||
GraphicsSceneMousePress: 'GraphicsSceneMousePress',
|
||||
GraphicsSceneMouseRelease: 'GraphicsSceneMouseRelease',
|
||||
GraphicsSceneMove: 'GraphicsSceneMove',
|
||||
GraphicsSceneResize: 'GraphicsSceneResize',
|
||||
GraphicsSceneWheel: 'GraphicsSceneWheel',
|
||||
Hide: 'Hide',
|
||||
HideToParent: 'HideToParent',
|
||||
HoverEnter: 'HoverEnter',
|
||||
HoverLeave: 'HoverLeave',
|
||||
HoverMove: 'HoverMove',
|
||||
IconDrag: 'IconDrag',
|
||||
IconTextChange: 'IconTextChange',
|
||||
InputMethod: 'InputMethod',
|
||||
InputMethodQuery: 'InputMethodQuery',
|
||||
KeyboardLayoutChange: 'KeyboardLayoutChange',
|
||||
KeyPress: 'KeyPress',
|
||||
KeyRelease: 'KeyRelease',
|
||||
LanguageChange: 'LanguageChange',
|
||||
LayoutDirectionChange: 'LayoutDirectionChange',
|
||||
LayoutRequest: 'LayoutRequest',
|
||||
Leave: 'Leave',
|
||||
LeaveWhatsThisMode: 'LeaveWhatsThisMode',
|
||||
LocaleChange: 'LocaleChange',
|
||||
NonClientAreaMouseButtonDblClick: 'NonClientAreaMouseButtonDblClick',
|
||||
NonClientAreaMouseButtonPress: 'NonClientAreaMouseButtonPress',
|
||||
NonClientAreaMouseButtonRelease: 'NonClientAreaMouseButtonRelease',
|
||||
NonClientAreaMouseMove: 'NonClientAreaMouseMove',
|
||||
MacSizeChange: 'MacSizeChange',
|
||||
MetaCall: 'MetaCall',
|
||||
ModifiedChange: 'ModifiedChange',
|
||||
MouseButtonDblClick: 'MouseButtonDblClick',
|
||||
MouseButtonPress: 'MouseButtonPress',
|
||||
MouseButtonRelease: 'MouseButtonRelease',
|
||||
MouseMove: 'MouseMove',
|
||||
MouseTrackingChange: 'MouseTrackingChange',
|
||||
Move: 'Move',
|
||||
NativeGesture: 'NativeGesture',
|
||||
OrientationChange: 'OrientationChange',
|
||||
Paint: 'Paint',
|
||||
PaletteChange: 'PaletteChange',
|
||||
ParentAboutToChange: 'ParentAboutToChange',
|
||||
ParentChange: 'ParentChange',
|
||||
PlatformPanel: 'PlatformPanel',
|
||||
PlatformSurface: 'PlatformSurface',
|
||||
Polish: 'Polish',
|
||||
PolishRequest: 'PolishRequest',
|
||||
QueryWhatsThis: 'QueryWhatsThis',
|
||||
ReadOnlyChange: 'ReadOnlyChange',
|
||||
RequestSoftwareInputPanel: 'RequestSoftwareInputPanel',
|
||||
Resize: 'Resize',
|
||||
ScrollPrepare: 'ScrollPrepare',
|
||||
Scroll: 'Scroll',
|
||||
Shortcut: 'Shortcut',
|
||||
ShortcutOverride: 'ShortcutOverride',
|
||||
Show: 'Show',
|
||||
ShowToParent: 'ShowToParent',
|
||||
SockAct: 'SockAct',
|
||||
StateMachineSignal: 'StateMachineSignal',
|
||||
StateMachineWrapped: 'StateMachineWrapped',
|
||||
StatusTip: 'StatusTip',
|
||||
StyleChange: 'StyleChange',
|
||||
TabletMove: 'TabletMove',
|
||||
TabletPress: 'TabletPress',
|
||||
TabletRelease: 'TabletRelease',
|
||||
TabletEnterProximity: 'TabletEnterProximity',
|
||||
TabletLeaveProximity: 'TabletLeaveProximity',
|
||||
TabletTrackingChange: 'TabletTrackingChange',
|
||||
ThreadChange: 'ThreadChange',
|
||||
Timer: 'Timer',
|
||||
ToolBarChange: 'ToolBarChange',
|
||||
ToolTip: 'ToolTip',
|
||||
ToolTipChange: 'ToolTipChange',
|
||||
TouchBegin: 'TouchBegin',
|
||||
TouchCancel: 'TouchCancel',
|
||||
TouchEnd: 'TouchEnd',
|
||||
TouchUpdate: 'TouchUpdate',
|
||||
UngrabKeyboard: 'UngrabKeyboard',
|
||||
UngrabMouse: 'UngrabMouse',
|
||||
UpdateLater: 'UpdateLater',
|
||||
UpdateRequest: 'UpdateRequest',
|
||||
WhatsThis: 'WhatsThis',
|
||||
WhatsThisClicked: 'WhatsThisClicked',
|
||||
Wheel: 'Wheel',
|
||||
WinEventAct: 'WinEventAct',
|
||||
WindowActivate: 'WindowActivate',
|
||||
WindowBlocked: 'WindowBlocked',
|
||||
WindowDeactivate: 'WindowDeactivate',
|
||||
WindowIconChange: 'WindowIconChange',
|
||||
WindowStateChange: 'WindowStateChange',
|
||||
WindowTitleChange: 'WindowTitleChange',
|
||||
WindowUnblocked: 'WindowUnblocked',
|
||||
WinIdChange: 'WinIdChange',
|
||||
ZOrderChange: 'ZOrderChange',
|
||||
});
|
||||
export enum WidgetEventTypes {
|
||||
'None' = 'None',
|
||||
'ActionAdded' = 'ActionAdded',
|
||||
'ActionChanged' = 'ActionChanged',
|
||||
'ActionRemoved' = 'ActionRemoved',
|
||||
'ActivationChange' = 'ActivationChange',
|
||||
'ApplicationActivate' = 'ApplicationActivate',
|
||||
'ApplicationActivated' = 'ApplicationActivated',
|
||||
'ApplicationDeactivate' = 'ApplicationDeactivate',
|
||||
'ApplicationFontChange' = 'ApplicationFontChange',
|
||||
'ApplicationLayoutDirectionChange' = 'ApplicationLayoutDirectionChange',
|
||||
'ApplicationPaletteChange' = 'ApplicationPaletteChange',
|
||||
'ApplicationStateChange' = 'ApplicationStateChange',
|
||||
'ApplicationWindowIconChange' = 'ApplicationWindowIconChange',
|
||||
'ChildAdded' = 'ChildAdded',
|
||||
'ChildPolished' = 'ChildPolished',
|
||||
'ChildRemoved' = 'ChildRemoved',
|
||||
'Clipboard' = 'Clipboard',
|
||||
'Close' = 'Close',
|
||||
'CloseSoftwareInputPanel' = 'CloseSoftwareInputPanel',
|
||||
'ContentsRectChange' = 'ContentsRectChange',
|
||||
'ContextMenu' = 'ContextMenu',
|
||||
'CursorChange' = 'CursorChange',
|
||||
'DeferredDelete' = 'DeferredDelete',
|
||||
'DragEnter' = 'DragEnter',
|
||||
'DragLeave' = 'DragLeave',
|
||||
'DragMove' = 'DragMove',
|
||||
'Drop' = 'Drop',
|
||||
'DynamicPropertyChange' = 'DynamicPropertyChange',
|
||||
'EnabledChange' = 'EnabledChange',
|
||||
'Enter' = 'Enter',
|
||||
'EnterWhatsThisMode' = 'EnterWhatsThisMode',
|
||||
'Expose' = 'Expose',
|
||||
'FileOpen' = 'FileOpen',
|
||||
'FocusIn' = 'FocusIn',
|
||||
'FocusOut' = 'FocusOut',
|
||||
'FocusAboutToChange' = 'FocusAboutToChange',
|
||||
'FontChange' = 'FontChange',
|
||||
'Gesture' = 'Gesture',
|
||||
'GestureOverride' = 'GestureOverride',
|
||||
'GrabKeyboard' = 'GrabKeyboard',
|
||||
'GrabMouse' = 'GrabMouse',
|
||||
'GraphicsSceneContextMenu' = 'GraphicsSceneContextMenu',
|
||||
'GraphicsSceneDragEnter' = 'GraphicsSceneDragEnter',
|
||||
'GraphicsSceneDragLeave' = 'GraphicsSceneDragLeave',
|
||||
'GraphicsSceneDragMove' = 'GraphicsSceneDragMove',
|
||||
'GraphicsSceneDrop' = 'GraphicsSceneDrop',
|
||||
'GraphicsSceneHelp' = 'GraphicsSceneHelp',
|
||||
'GraphicsSceneHoverEnter' = 'GraphicsSceneHoverEnter',
|
||||
'GraphicsSceneHoverLeave' = 'GraphicsSceneHoverLeave',
|
||||
'GraphicsSceneHoverMove' = 'GraphicsSceneHoverMove',
|
||||
'GraphicsSceneMouseDoubleClick' = 'GraphicsSceneMouseDoubleClick',
|
||||
'GraphicsSceneMouseMove' = 'GraphicsSceneMouseMove',
|
||||
'GraphicsSceneMousePress' = 'GraphicsSceneMousePress',
|
||||
'GraphicsSceneMouseRelease' = 'GraphicsSceneMouseRelease',
|
||||
'GraphicsSceneMove' = 'GraphicsSceneMove',
|
||||
'GraphicsSceneResize' = 'GraphicsSceneResize',
|
||||
'GraphicsSceneWheel' = 'GraphicsSceneWheel',
|
||||
'Hide' = 'Hide',
|
||||
'HideToParent' = 'HideToParent',
|
||||
'HoverEnter' = 'HoverEnter',
|
||||
'HoverLeave' = 'HoverLeave',
|
||||
'HoverMove' = 'HoverMove',
|
||||
'IconDrag' = 'IconDrag',
|
||||
'IconTextChange' = 'IconTextChange',
|
||||
'InputMethod' = 'InputMethod',
|
||||
'InputMethodQuery' = 'InputMethodQuery',
|
||||
'KeyboardLayoutChange' = 'KeyboardLayoutChange',
|
||||
'KeyPress' = 'KeyPress',
|
||||
'KeyRelease' = 'KeyRelease',
|
||||
'LanguageChange' = 'LanguageChange',
|
||||
'LayoutDirectionChange' = 'LayoutDirectionChange',
|
||||
'LayoutRequest' = 'LayoutRequest',
|
||||
'Leave' = 'Leave',
|
||||
'LeaveWhatsThisMode' = 'LeaveWhatsThisMode',
|
||||
'LocaleChange' = 'LocaleChange',
|
||||
'NonClientAreaMouseButtonDblClick' = 'NonClientAreaMouseButtonDblClick',
|
||||
'NonClientAreaMouseButtonPress' = 'NonClientAreaMouseButtonPress',
|
||||
'NonClientAreaMouseButtonRelease' = 'NonClientAreaMouseButtonRelease',
|
||||
'NonClientAreaMouseMove' = 'NonClientAreaMouseMove',
|
||||
'MacSizeChange' = 'MacSizeChange',
|
||||
'MetaCall' = 'MetaCall',
|
||||
'ModifiedChange' = 'ModifiedChange',
|
||||
'MouseButtonDblClick' = 'MouseButtonDblClick',
|
||||
'MouseButtonPress' = 'MouseButtonPress',
|
||||
'MouseButtonRelease' = 'MouseButtonRelease',
|
||||
'MouseMove' = 'MouseMove',
|
||||
'MouseTrackingChange' = 'MouseTrackingChange',
|
||||
'Move' = 'Move',
|
||||
'NativeGesture' = 'NativeGesture',
|
||||
'OrientationChange' = 'OrientationChange',
|
||||
'Paint' = 'Paint',
|
||||
'PaletteChange' = 'PaletteChange',
|
||||
'ParentAboutToChange' = 'ParentAboutToChange',
|
||||
'ParentChange' = 'ParentChange',
|
||||
'PlatformPanel' = 'PlatformPanel',
|
||||
'PlatformSurface' = 'PlatformSurface',
|
||||
'Polish' = 'Polish',
|
||||
'PolishRequest' = 'PolishRequest',
|
||||
'QueryWhatsThis' = 'QueryWhatsThis',
|
||||
'ReadOnlyChange' = 'ReadOnlyChange',
|
||||
'RequestSoftwareInputPanel' = 'RequestSoftwareInputPanel',
|
||||
'Resize' = 'Resize',
|
||||
'ScrollPrepare' = 'ScrollPrepare',
|
||||
'Scroll' = 'Scroll',
|
||||
'Shortcut' = 'Shortcut',
|
||||
'ShortcutOverride' = 'ShortcutOverride',
|
||||
'Show' = 'Show',
|
||||
'ShowToParent' = 'ShowToParent',
|
||||
'SockAct' = 'SockAct',
|
||||
'StateMachineSignal' = 'StateMachineSignal',
|
||||
'StateMachineWrapped' = 'StateMachineWrapped',
|
||||
'StatusTip' = 'StatusTip',
|
||||
'StyleChange' = 'StyleChange',
|
||||
'TabletMove' = 'TabletMove',
|
||||
'TabletPress' = 'TabletPress',
|
||||
'TabletRelease' = 'TabletRelease',
|
||||
'TabletEnterProximity' = 'TabletEnterProximity',
|
||||
'TabletLeaveProximity' = 'TabletLeaveProximity',
|
||||
'TabletTrackingChange' = 'TabletTrackingChange',
|
||||
'ThreadChange' = 'ThreadChange',
|
||||
'Timer' = 'Timer',
|
||||
'ToolBarChange' = 'ToolBarChange',
|
||||
'ToolTip' = 'ToolTip',
|
||||
'ToolTipChange' = 'ToolTipChange',
|
||||
'TouchBegin' = 'TouchBegin',
|
||||
'TouchCancel' = 'TouchCancel',
|
||||
'TouchEnd' = 'TouchEnd',
|
||||
'TouchUpdate' = 'TouchUpdate',
|
||||
'UngrabKeyboard' = 'UngrabKeyboard',
|
||||
'UngrabMouse' = 'UngrabMouse',
|
||||
'UpdateLater' = 'UpdateLater',
|
||||
'UpdateRequest' = 'UpdateRequest',
|
||||
'WhatsThis' = 'WhatsThis',
|
||||
'WhatsThisClicked' = 'WhatsThisClicked',
|
||||
'Wheel' = 'Wheel',
|
||||
'WinEventAct' = 'WinEventAct',
|
||||
'WindowActivate' = 'WindowActivate',
|
||||
'WindowBlocked' = 'WindowBlocked',
|
||||
'WindowDeactivate' = 'WindowDeactivate',
|
||||
'WindowIconChange' = 'WindowIconChange',
|
||||
'WindowStateChange' = 'WindowStateChange',
|
||||
'WindowTitleChange' = 'WindowTitleChange',
|
||||
'WindowUnblocked' = 'WindowUnblocked',
|
||||
'WinIdChange' = 'WinIdChange',
|
||||
'ZOrderChange' = 'ZOrderChange',
|
||||
}
|
||||
|
||||
@ -4,16 +4,28 @@ import { NodeLayout } from '../QtWidgets/QLayout';
|
||||
import { FlexNode } from './YogaWidget';
|
||||
import { NativeElement } from './Component';
|
||||
|
||||
export class FlexLayout extends NodeLayout {
|
||||
type FlexLayoutSignals = {};
|
||||
export class FlexLayout extends NodeLayout<FlexLayoutSignals> {
|
||||
native: NativeElement;
|
||||
constructor() {
|
||||
const native = new addon.FlexLayout();
|
||||
super(native);
|
||||
this.native = native;
|
||||
}
|
||||
protected flexNode?: FlexNode;
|
||||
|
||||
addWidget(childWidget: NodeWidget, childFlexNode?: FlexNode): void {
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.FlexLayout(parent.native);
|
||||
} else {
|
||||
native = new addon.FlexLayout();
|
||||
}
|
||||
super(native);
|
||||
this.native = native;
|
||||
if (parent) {
|
||||
this.setFlexNode(parent.getFlexNode());
|
||||
}
|
||||
}
|
||||
|
||||
addWidget(childWidget: NodeWidget<any>, childFlexNode?: FlexNode): void {
|
||||
const childYogaNode = childFlexNode || childWidget.getFlexNode();
|
||||
if (this.nodeChildren.has(childWidget)) {
|
||||
this.removeWidget(childWidget, childYogaNode);
|
||||
@ -23,8 +35,8 @@ export class FlexLayout extends NodeLayout {
|
||||
}
|
||||
|
||||
insertChildBefore(
|
||||
childWidget: NodeWidget,
|
||||
beforeChildWidget: NodeWidget,
|
||||
childWidget: NodeWidget<any>,
|
||||
beforeChildWidget: NodeWidget<any>,
|
||||
childFlexNode?: FlexNode,
|
||||
beforeChildFlexNode?: FlexNode,
|
||||
): void {
|
||||
@ -37,7 +49,7 @@ export class FlexLayout extends NodeLayout {
|
||||
this.native.insertChildBefore(childWidget.native, beforeChildYogaNode, childYogaNode);
|
||||
}
|
||||
|
||||
removeWidget(childWidget: NodeWidget, childFlexNode?: FlexNode): void {
|
||||
removeWidget(childWidget: NodeWidget<any>, childFlexNode?: FlexNode): void {
|
||||
if (!this.nodeChildren.has(childWidget)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@ export class StyleSheet {
|
||||
}
|
||||
}
|
||||
|
||||
export function prepareInlineStyleSheet(widget: NodeWidget, rawStyle: string): string {
|
||||
export function prepareInlineStyleSheet<Signals>(widget: NodeWidget<Signals>, rawStyle: string): string {
|
||||
const inlineStyle = StyleSheet.create(rawStyle);
|
||||
// Make sure to not calculate ObjectName in the same pass of event loop as other props (incase of react) since the order will matter in that case
|
||||
// So doing it in multiple passes of event loop allows objectName to be set before using it. The above await solves it.
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { NodeObject } from '../QtCore/QObject';
|
||||
|
||||
export type FlexNode = {};
|
||||
export abstract class YogaWidget extends NodeObject {
|
||||
export abstract class YogaWidget<Signals> extends NodeObject<Signals> {
|
||||
getFlexNode(): FlexNode {
|
||||
return this.native.getFlexNode();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user