From 9f9e61289bd9ef334e9f0263758fdc594d1c3beb Mon Sep 17 00:00:00 2001 From: Simon Edwards Date: Sun, 26 Dec 2021 17:21:56 +0100 Subject: [PATCH] More `QWidget` methods and properties --- .../nodegui/QtWidgets/QWidget/qwidget_macro.h | 238 +++++++++------- src/lib/QtWidgets/QWidget.ts | 262 +++++++++++++----- 2 files changed, 331 insertions(+), 169 deletions(-) diff --git a/src/cpp/include/nodegui/QtWidgets/QWidget/qwidget_macro.h b/src/cpp/include/nodegui/QtWidgets/QWidget/qwidget_macro.h index 85b44cdb4..df76b37b1 100644 --- a/src/cpp/include/nodegui/QtWidgets/QWidget/qwidget_macro.h +++ b/src/cpp/include/nodegui/QtWidgets/QWidget/qwidget_macro.h @@ -96,12 +96,6 @@ {Napi::External::New(env, new QPoint(pt.x(), pt.y()))}); \ return instance; \ } \ - Napi::Value isVisible(const Napi::CallbackInfo& info) { \ - Napi::Env env = info.Env(); \ - bool isVisible = this->instance->isVisible(); \ - return Napi::Boolean::New(env, isVisible); \ - } \ - \ Napi::Value setLayout(const Napi::CallbackInfo& info) { \ Napi::Env env = info.Env(); \ Napi::Object layoutObject = info[0].As(); \ @@ -182,29 +176,6 @@ int y = info[1].As().Int32Value(); \ this->instance->move(x, y); \ return env.Null(); \ - } \ - \ - Napi::Value setMouseTracking(const Napi::CallbackInfo& info) { \ - Napi::Env env = info.Env(); \ - Napi::Boolean isMouseTracked = info[0].As(); \ - this->instance->setMouseTracking(isMouseTracked.Value()); \ - return env.Null(); \ - } \ - Napi::Value hasMouseTracking(const Napi::CallbackInfo& info) { \ - Napi::Env env = info.Env(); \ - bool isMouseTracked = this->instance->hasMouseTracking(); \ - return Napi::Value::From(env, isMouseTracked); \ - } \ - Napi::Value setEnabled(const Napi::CallbackInfo& info) { \ - Napi::Env env = info.Env(); \ - Napi::Boolean enabled = info[0].As(); \ - this->instance->setEnabled(enabled.Value()); \ - return env.Null(); \ - } \ - Napi::Value isEnabled(const Napi::CallbackInfo& info) { \ - Napi::Env env = info.Env(); \ - bool enabled = this->instance->isEnabled(); \ - return Napi::Value::From(env, enabled); \ } \ Napi::Value setFixedSize(const Napi::CallbackInfo& info) { \ Napi::Env env = info.Env(); \ @@ -229,13 +200,6 @@ this->instance->setMaximumSize(width, height); \ return env.Null(); \ } \ - Napi::Value maximumSize(const Napi::CallbackInfo& info) { \ - Napi::Env env = info.Env(); \ - QSize size = this->instance->maximumSize(); \ - auto sizeWrap = QSizeWrap::constructor.New({Napi::External::New( \ - env, new QSize(size.width(), size.height()))}); \ - return sizeWrap; \ - } \ Napi::Value setMinimumSize(const Napi::CallbackInfo& info) { \ Napi::Env env = info.Env(); \ int width = info[0].As().Int32Value(); \ @@ -243,13 +207,6 @@ this->instance->setMinimumSize(width, height); \ return env.Null(); \ } \ - Napi::Value minimumSize(const Napi::CallbackInfo& info) { \ - Napi::Env env = info.Env(); \ - QSize size = this->instance->minimumSize(); \ - auto sizeWrap = QSizeWrap::constructor.New({Napi::External::New( \ - env, new QSize(size.width(), size.height()))}); \ - return sizeWrap; \ - } \ Napi::Value repaint(const Napi::CallbackInfo& info) { \ Napi::Env env = info.Env(); \ this->instance->repaint(); \ @@ -386,16 +343,6 @@ this->instance->setGraphicsEffect(effect); \ return env.Null(); \ } \ - Napi::Value acceptDrops(const Napi::CallbackInfo& info) { \ - Napi::Env env = info.Env(); \ - return Napi::Boolean::From(env, this->instance->acceptDrops()); \ - } \ - Napi::Value setAcceptDrops(const Napi::CallbackInfo& info) { \ - Napi::Env env = info.Env(); \ - bool v = info[0].As().Value(); \ - this->instance->setAcceptDrops(v); \ - return env.Null(); \ - } \ Napi::Value setFocus(const Napi::CallbackInfo& info) { \ Napi::Env env = info.Env(); \ int reason = info[0].As().Int32Value(); \ @@ -416,30 +363,6 @@ this->instance->setSizePolicy(horizontal, vertical); \ return env.Null(); \ } \ - Napi::Value setMaximumHeight(const Napi::CallbackInfo& info) { \ - Napi::Env env = info.Env(); \ - int maxh = info[0].As().Int32Value(); \ - this->instance->setMaximumHeight(maxh); \ - return env.Null(); \ - } \ - Napi::Value setMinimumWidth(const Napi::CallbackInfo& info) { \ - Napi::Env env = info.Env(); \ - int minw = info[0].As().Int32Value(); \ - this->instance->setMinimumWidth(minw); \ - return env.Null(); \ - } \ - Napi::Value setMaximumWidth(const Napi::CallbackInfo& info) { \ - Napi::Env env = info.Env(); \ - int maxw = info[0].As().Int32Value(); \ - this->instance->setMaximumWidth(maxw); \ - return env.Null(); \ - } \ - Napi::Value setMinimumHeight(const Napi::CallbackInfo& info) { \ - Napi::Env env = info.Env(); \ - int minh = info[0].As().Int32Value(); \ - this->instance->setMinimumHeight(minh); \ - return env.Null(); \ - } \ Napi::Value style(const Napi::CallbackInfo& info) { \ Napi::Env env = info.Env(); \ QStyle* style = this->instance->style(); \ @@ -456,11 +379,6 @@ bool result = this->instance->isWindowModified(); \ return Napi::Boolean::New(env, result); \ } \ - Napi::Value isHidden(const Napi::CallbackInfo& info) { \ - Napi::Env env = info.Env(); \ - bool result = this->instance->isHidden(); \ - return Napi::Boolean::New(env, result); \ - } \ Napi::Value setDisabled(const Napi::CallbackInfo& info) { \ Napi::Env env = info.Env(); \ bool disable = info[0].As().Value(); \ @@ -505,6 +423,122 @@ int w = info[0].As().Int32Value(); \ this->instance->setFixedWidth(w); \ return env.Null(); \ + } \ + Napi::Value ensurePolished(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + this->instance->ensurePolished(); \ + return env.Null(); \ + } \ + Napi::Value clearMask(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + this->instance->clearMask(); \ + return env.Null(); \ + } \ + Napi::Value grabKeyboard(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + this->instance->grabKeyboard(); \ + return env.Null(); \ + } \ + Napi::Value grabMouse(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + this->instance->grabMouse(); \ + return env.Null(); \ + } \ + Napi::Value hasHeightForWidth(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + bool result = this->instance->hasHeightForWidth(); \ + return Napi::Boolean::New(env, result); \ + } \ + Napi::Value minimumSizeHint(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + QSize result = this->instance->minimumSizeHint(); \ + auto resultInstance = QSizeWrap::constructor.New( \ + {Napi::External::New(env, new QSize(result))}); \ + return resultInstance; \ + } \ + Napi::Value releaseKeyboard(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + this->instance->releaseKeyboard(); \ + return env.Null(); \ + } \ + Napi::Value releaseMouse(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + this->instance->releaseMouse(); \ + return env.Null(); \ + } \ + Napi::Value releaseShortcut(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + int id = info[0].As().Int32Value(); \ + this->instance->releaseShortcut(id); \ + return env.Null(); \ + } \ + Napi::Value setContentsMargins(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + int left = info[0].As().Int32Value(); \ + int top = info[1].As().Int32Value(); \ + int right = info[2].As().Int32Value(); \ + int bottom = info[3].As().Int32Value(); \ + this->instance->setContentsMargins(left, top, right, bottom); \ + return env.Null(); \ + } \ + Napi::Value setShortcutAutoRepeat(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + int id = info[0].As().Int32Value(); \ + bool enable = info[1].As().Value(); \ + this->instance->setShortcutAutoRepeat(id, enable); \ + return env.Null(); \ + } \ + Napi::Value setShortcutEnabled(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + int id = info[0].As().Int32Value(); \ + bool enable = info[1].As().Value(); \ + this->instance->setShortcutEnabled(id, enable); \ + return env.Null(); \ + } \ + Napi::Value setSizeIncrement(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + int w = info[0].As().Int32Value(); \ + int h = info[1].As().Int32Value(); \ + this->instance->setSizeIncrement(w, h); \ + return env.Null(); \ + } \ + Napi::Value setWindowRole(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + std::string roleNapiText = info[0].As().Utf8Value(); \ + QString role = QString::fromUtf8(roleNapiText.c_str()); \ + this->instance->setWindowRole(role); \ + return env.Null(); \ + } \ + Napi::Value underMouse(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + bool result = this->instance->underMouse(); \ + return Napi::Boolean::New(env, result); \ + } \ + Napi::Value unsetCursor(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + this->instance->unsetCursor(); \ + return env.Null(); \ + } \ + Napi::Value unsetLayoutDirection(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + this->instance->unsetLayoutDirection(); \ + return env.Null(); \ + } \ + Napi::Value unsetLocale(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + this->instance->unsetLocale(); \ + return env.Null(); \ + } \ + Napi::Value windowRole(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + QString result = this->instance->windowRole(); \ + return Napi::String::New(env, result.toStdString()); \ + } \ + Napi::Value heightForWidth(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + int w = info[0].As().Int32Value(); \ + int result = this->instance->heightForWidth(w); \ + return Napi::Number::New(env, result); \ } #endif // QWIDGET_WRAPPED_METHODS_DECLARATION @@ -516,7 +550,6 @@ QOBJECT_WRAPPED_METHODS_EXPORT_DEFINE(WidgetWrapName) \ InstanceMethod("show", &WidgetWrapName::show), \ InstanceMethod("resize", &WidgetWrapName::resize), \ - InstanceMethod("isVisible", &WidgetWrapName::isVisible), \ InstanceMethod("close", &WidgetWrapName::close), \ InstanceMethod("mapFromGlobal", &WidgetWrapName::mapFromGlobal), \ InstanceMethod("mapFromParent", &WidgetWrapName::mapFromParent), \ @@ -533,10 +566,6 @@ InstanceMethod("styleSheet", &WidgetWrapName::styleSheet), \ InstanceMethod("hide", &WidgetWrapName::hide), \ InstanceMethod("move", &WidgetWrapName::move), \ - InstanceMethod("setMouseTracking", &WidgetWrapName::setMouseTracking), \ - InstanceMethod("hasMouseTracking", &WidgetWrapName::hasMouseTracking), \ - InstanceMethod("setEnabled", &WidgetWrapName::setEnabled), \ - InstanceMethod("isEnabled", &WidgetWrapName::isEnabled), \ InstanceMethod("setFixedSize", &WidgetWrapName::setFixedSize), \ InstanceMethod("setGeometry", &WidgetWrapName::setGeometry), \ InstanceMethod("setMaximumSize", &WidgetWrapName::setMaximumSize), \ @@ -544,8 +573,6 @@ InstanceMethod("repaint", &WidgetWrapName::repaint), \ InstanceMethod("update", &WidgetWrapName::update), \ InstanceMethod("updateGeometry", &WidgetWrapName::updateGeometry), \ - InstanceMethod("maximumSize", &WidgetWrapName::maximumSize), \ - InstanceMethod("minimumSize", &WidgetWrapName::minimumSize), \ InstanceMethod("pos", &WidgetWrapName::pos), \ InstanceMethod("size", &WidgetWrapName::size), \ InstanceMethod("setAttribute", &WidgetWrapName::setAttribute), \ @@ -565,26 +592,43 @@ InstanceMethod("removeAction", &WidgetWrapName::removeAction), \ InstanceMethod("repolish", &WidgetWrapName::repolish), \ InstanceMethod("setGraphicsEffect", &WidgetWrapName::setGraphicsEffect), \ - InstanceMethod("acceptDrops", &WidgetWrapName::acceptDrops), \ - InstanceMethod("setAcceptDrops", &WidgetWrapName::setAcceptDrops), \ InstanceMethod("setFocus", &WidgetWrapName::setFocus), \ InstanceMethod("clearFocus", &WidgetWrapName::clearFocus), \ InstanceMethod("setSizePolicy", &WidgetWrapName::setSizePolicy), \ - InstanceMethod("setMaximumHeight", &WidgetWrapName::setMaximumHeight), \ - InstanceMethod("setMinimumWidth", &WidgetWrapName::setMinimumWidth), \ - InstanceMethod("setMaximumWidth", &WidgetWrapName::setMaximumWidth), \ - InstanceMethod("setMinimumHeight", &WidgetWrapName::setMinimumHeight), \ InstanceMethod("style", &WidgetWrapName::style), \ InstanceMethod("isWindow", &WidgetWrapName::isWindow), \ InstanceMethod("isWindowModified", &WidgetWrapName::isWindowModified), \ - InstanceMethod("isHidden", &WidgetWrapName::isHidden), \ InstanceMethod("setDisabled", &WidgetWrapName::setDisabled), \ InstanceMethod("setHidden", &WidgetWrapName::setHidden), \ InstanceMethod("setVisible", &WidgetWrapName::setVisible), \ InstanceMethod("setWindowModified", &WidgetWrapName::setWindowModified), \ InstanceMethod("windowHandle", &WidgetWrapName::windowHandle), \ InstanceMethod("setFixedHeight", &WidgetWrapName::setFixedHeight), \ - InstanceMethod("setFixedWidth", &WidgetWrapName::setFixedWidth), + InstanceMethod("setFixedWidth", &WidgetWrapName::setFixedWidth), \ + InstanceMethod("ensurePolished", &WidgetWrapName::ensurePolished), \ + InstanceMethod("clearMask", &WidgetWrapName::clearMask), \ + InstanceMethod("grabKeyboard", &WidgetWrapName::grabKeyboard), \ + InstanceMethod("grabMouse", &WidgetWrapName::grabMouse), \ + InstanceMethod("hasHeightForWidth", &WidgetWrapName::hasHeightForWidth), \ + InstanceMethod("minimumSizeHint", &WidgetWrapName::minimumSizeHint), \ + InstanceMethod("releaseKeyboard", &WidgetWrapName::releaseKeyboard), \ + InstanceMethod("releaseMouse", &WidgetWrapName::releaseMouse), \ + InstanceMethod("releaseShortcut", &WidgetWrapName::releaseShortcut), \ + InstanceMethod("setContentsMargins", \ + &WidgetWrapName::setContentsMargins), \ + InstanceMethod("setShortcutAutoRepeat", \ + &WidgetWrapName::setShortcutAutoRepeat), \ + InstanceMethod("setShortcutEnabled", \ + &WidgetWrapName::setShortcutEnabled), \ + InstanceMethod("setSizeIncrement", &WidgetWrapName::setSizeIncrement), \ + InstanceMethod("setWindowRole", &WidgetWrapName::setWindowRole), \ + InstanceMethod("underMouse", &WidgetWrapName::underMouse), \ + InstanceMethod("unsetCursor", &WidgetWrapName::unsetCursor), \ + InstanceMethod("unsetLayoutDirection", \ + &WidgetWrapName::unsetLayoutDirection), \ + InstanceMethod("unsetLocale", &WidgetWrapName::unsetLocale), \ + InstanceMethod("windowRole", &WidgetWrapName::windowRole), \ + InstanceMethod("heightForWidth", &WidgetWrapName::heightForWidth), #endif // QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE diff --git a/src/lib/QtWidgets/QWidget.ts b/src/lib/QtWidgets/QWidget.ts index 12dde16ff..64563d6c6 100644 --- a/src/lib/QtWidgets/QWidget.ts +++ b/src/lib/QtWidgets/QWidget.ts @@ -74,10 +74,14 @@ export abstract class NodeWidget extends YogaWid } // *** Public Functions *** acceptDrops(): boolean { - return this.native.acceptDrops(); + return this.property('acceptDrops').toBool(); + } + accessibleDescription(): string { + return this.property('accessibleDescription').toString(); + } + accessibleName(): string { + return this.property('accessibleName').toString(); } - // TODO: QString accessibleDescription() const - // TODO: QString accessibleName() const // TODO: QList actions() const activateWindow(): void { this.native.activateWindow(); @@ -96,24 +100,37 @@ export abstract class NodeWidget extends YogaWid adjustSize(): void { this.native.adjustSize(); } - // TODO: bool autoFillBackground() const + autoFillBackground(): boolean { + return this.property('autoFillBackground').toBool(); + } + // CLASS: QWidget // TODO: QPalette::ColorRole backgroundRole() const // TODO: QBackingStore * backingStore() const - // TODO: QSize baseSize() const + baseSize(): QSize { + return QSize.fromQVariant(this.property('baseSize')); + } // TODO: QWidget * childAt(int x, int y) const // TODO: QWidget * childAt(const QPoint &p) const - // TODO: QRect childrenRect() const + childrenRect(): QRect { + return QRect.fromQVariant(this.property('childrenRect')); + } // TODO: QRegion childrenRegion() const clearFocus(): void { this.native.clearFocus(); } - // TODO: void clearMask() + clearMask(): void { + this.native.clearMask(); + } // TODO: QMargins contentsMargins() const // TODO: QRect contentsRect() const - // TODO: Qt::ContextMenuPolicy contextMenuPolicy() const + contextMenuPolicy(): ContextMenuPolicy { + return this.property('contextMenuPolicy').toInt(); + } // TODO: QCursor cursor() const // TODO: WId effectiveWinId() const - // TODO: void ensurePolished() const + ensurePolished(): void { + this.native.ensurePolished(); + } // TODO: Qt::FocusPolicy focusPolicy() const // TODO: QWidget * focusProxy() const // TODO: QWidget * focusWidget() const @@ -126,14 +143,20 @@ export abstract class NodeWidget extends YogaWid frameGeometry(): QRect { return QRect.fromQVariant(this.property('frameGeometry')); } - // TODO: QSize frameSize() const + frameSize(): QSize { + return QSize.fromQVariant(this.property('frameSize')); + } geometry(): QRect { return QRect.fromQVariant(this.property('geometry')); } // TODO: QPixmap grab(const QRect &rectangle = QRect(QPoint(0, 0), QSize(-1, -1))) // TODO: void grabGesture(Qt::GestureType gesture, Qt::GestureFlags flags = Qt::GestureFlags()) - // TODO: void grabKeyboard() - // TODO: void grabMouse() + grabKeyboard(): void { + this.native.grabKeyboard(); + } + grabMouse(): void { + this.native.grabMouse(); + } // TODO: void grabMouse(const QCursor &cursor) // TODO: int grabShortcut(const QKeySequence &key, Qt::ShortcutContext context = Qt::WindowShortcut) // TODO: QGraphicsEffect * graphicsEffect() const @@ -141,15 +164,21 @@ export abstract class NodeWidget extends YogaWid hasFocus(): boolean { return this.property('focus').toBool(); } - // TODO: virtual bool hasHeightForWidth() const - hasMouseTracking(): boolean { - return this.native.hasMouseTracking(); + hasHeightForWidth(): boolean { + return this.native.hasHeightForWidth(); + } + hasMouseTracking(): boolean { + return this.property('mouseTracking').toBool(); + } + hasTabletTracking(): boolean { + return this.property('tabletTracking').toBool(); } - // TODO: bool hasTabletTracking() const height(): number { return this.property('height').toInt(); } - // TODO: virtual int heightForWidth(int w) const + heightForWidth(w: number): number { + return this.native.heightForWidth(w); + } // TODO: Qt::InputMethodHints inputMethodHints() const // TODO: virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const // TODO: void insertAction(QAction *before, QAction *action) @@ -159,14 +188,14 @@ export abstract class NodeWidget extends YogaWid } // TODO: bool isAncestorOf(const QWidget *child) const isEnabled(): boolean { - return this.native.isEnabled(); + return this.property('enabled').toBool(); } // TODO: bool isEnabledTo(const QWidget *ancestor) const isFullScreen(): boolean { return this.property('fullScreen').toBool(); } isHidden(): boolean { - return this.native.isHidden(); + return !this.property('visible').toBool(); } isMaximized(): boolean { return this.property('maximized').toBool(); @@ -178,7 +207,7 @@ export abstract class NodeWidget extends YogaWid return this.property('modal').toBool(); } isVisible(): boolean { - return this.native.isVisible(); + return this.property('visible').toBool(); } // TODO: bool isVisibleTo(const QWidget *ancestor) const isWindow(): boolean { @@ -205,35 +234,57 @@ export abstract class NodeWidget extends YogaWid return new QPoint(this.native.mapToParent(pos.native)); } // TODO: QRegion mask() const - // TODO: int maximumHeight() const + maximumHeight(): number { + return this.property('maximumHeight').toInt(); + } maximumSize(): QSize { - return new QSize(this.native.maximumSize()); + return QSize.fromQVariant(this.property('maximumSize')); + } + maximumWidth(): number { + return this.property('maximumWidth').toInt(); + } + minimumHeight(): number { + return this.property('minimumHeight').toInt(); } - // TODO: int maximumWidth() const - // TODO: int minimumHeight() const minimumSize(): QSize { - return new QSize(this.native.minimumSize()); + return QSize.fromQVariant(this.property('minimumSize')); + } + minimumSizeHint(): QSize { + return new QSize(this.native.minimumSizeHint()); + } + minimumWidth(): number { + return this.property('minimumWidth').toInt(); } - // TODO: virtual QSize minimumSizeHint() const - // TODO: int minimumWidth() const // TODO: void move(const QPoint &) move(x: number, y: number): void { this.native.move(x, y); } // TODO: QWidget * nativeParentWidget() const // TODO: QWidget * nextInFocusChain() const - // TODO: QRect normalGeometry() const + normalGeometry(): QRect { + return QRect.fromQVariant(this.property('normalGeometry')); + } // TODO: void overrideWindowFlags(Qt::WindowFlags flags) // TODO: const QPalette & palette() const // TODO: QWidget * parentWidget() const + + // PROP: QWidget pos(): { x: number; y: number } { return this.native.pos(); } // TODO: QWidget * previousInFocusChain() const - // TODO: QRect rect() const - // TODO: void releaseKeyboard() - // TODO: void releaseMouse() - // TODO: void releaseShortcut(int id) + rect(): QRect { + return QRect.fromQVariant(this.property('rect')); + } + releaseKeyboard(): void { + this.native.releaseKeyboard(); + } + releaseMouse(): void { + this.native.releaseMouse(); + } + releaseShortcut(id: number): void { + this.native.releaseShortcut(id); + } removeAction(action: QAction): void { this.native.removeAction(action.native); } @@ -251,24 +302,34 @@ export abstract class NodeWidget extends YogaWid } // TODO: QScreen *QWidget::screen() const setAcceptDrops(on: boolean): void { - this.native.setAcceptDrops(on); + this.setProperty('acceptDrops', on); + } + setAccessibleDescription(description: string): void { + this.setProperty('accessibleDescription', description); + } + setAccessibleName(name: string): void { + this.setProperty('accessibleName', name); } - // TODO: void setAcceptDrops(bool on) - // TODO: void setAccessibleDescription(const QString &description) - // TODO: void setAccessibleName(const QString &name) setAttribute(attribute: WidgetAttribute, switchOn: boolean): void { // react:⛔️ return this.native.setAttribute(attribute, switchOn); } - // TODO: void setAutoFillBackground(bool enabled) + setAutoFillBackground(enabled: boolean): void { + this.setProperty('autoFillBackground', enabled); + } // TODO: void setBackgroundRole(QPalette::ColorRole role) - // TODO: void setBaseSize(const QSize &) + setBaseSize(size: QSize): void { + this.setProperty('baseSize', size.native); + } // TODO: void setBaseSize(int basew, int baseh) - // TODO: void setContentsMargins(int left, int top, int right, int bottom) + setContentsMargins(left: number, top: number, right: number, bottom: number): void { + this.native.setContentsMargins(left, top, right, bottom); + } // TODO: void setContentsMargins(const QMargins &margins) setContextMenuPolicy(contextMenuPolicy: ContextMenuPolicy): void { this.setProperty('contextMenuPolicy', contextMenuPolicy); } + // PROP: QWidget setCursor(cursor: CursorShape | QCursor): void { if (typeof cursor === 'number') { this.native.setCursor(cursor); @@ -276,7 +337,7 @@ export abstract class NodeWidget extends YogaWid this.native.setCursor(cursor.native); } } - // TODO: void setEditFocus(bool enable) + // Embedded only: void setEditFocus(bool enable) setFixedHeight(h: number): void { this.native.setFixedHeight(h); } @@ -323,27 +384,29 @@ export abstract class NodeWidget extends YogaWid // TODO: void setMask(const QBitmap &bitmap) // TODO: void setMask(const QRegion ®ion) setMaximumHeight(maxh: number): void { - this.native.setMaximumHeight(maxh); + this.setProperty('maximumHeight', maxh); } + // PROP: QWidget // TODO: void setMaximumSize(const QSize &) setMaximumSize(maxw: number, maxh: number): void { this.native.setMaximumSize(maxw, maxh); } setMaximumWidth(maxw: number): void { - this.native.setMaximumWidth(maxw); + this.setProperty('maximumWidth', maxw); } - // TODO: void setMinimumSize(const QSize &) + // PROP: QWidget + // TODO: void setMinimumSize(const QSize &size) setMinimumHeight(minh: number): void { - this.native.setMinimumHeight(minh); + this.setProperty('minimumHeight', minh); } setMinimumSize(minw: number, minh: number): void { this.native.setMinimumSize(minw, minh); } setMinimumWidth(minw: number): void { - this.native.setMinimumWidth(minw); + this.setProperty('minimumWidth', minw); } setMouseTracking(isMouseTracked: boolean): void { - this.native.setMouseTracking(isMouseTracked); + this.setProperty('mouseTracking', isMouseTracked); } setObjectName(objectName: string): void { super.setObjectName(objectName); @@ -355,35 +418,62 @@ export abstract class NodeWidget extends YogaWid // TODO: void setPalette(const QPalette &) // TODO: void setParent(QWidget *parent) // TODO: void setParent(QWidget *parent, Qt::WindowFlags f) - // TODO: void setShortcutAutoRepeat(int id, bool enable = true) - // TODO: void setShortcutEnabled(int id, bool enable = true) - // TODO: void setSizeIncrement(const QSize &) - // TODO: void setSizeIncrement(int w, int h) + setShortcutAutoRepeat(id: number, enable = true): void { + this.native.setShortcutAutoRepeat(id, enable); + } + setShortcutEnabled(id: number, enable = true): void { + this.native.setShortcutEnabled(id, enable); + } + setSizeIncrement(w_or_size: QSize | number, h = 0): void { + if (typeof w_or_size === 'number') { + this.native.setSizeIncrement(w_or_size, h); + } else { + this.setProperty('sizeIncrement', w_or_size.native); + } + } // TODO: void setSizePolicy(QSizePolicy) setSizePolicy(horizontal: QSizePolicyPolicy, vertical: QSizePolicyPolicy): void { this.native.setSizePolicy(horizontal, vertical); } - // TODO: void setStatusTip(const QString &) + setStatusTip(statusTip: string): void { + this.setProperty('statusTip', statusTip); + } // TODO: void setStyle(QStyle *style) - // TODO: void setTabletTracking(bool enable) - // TODO: void setToolTip(const QString &) - // TODO: void setToolTipDuration(int msec) - // TODO: void setUpdatesEnabled(bool enable) - // TODO: void setWhatsThis(const QString &) - // TODO: void setWindowFilePath(const QString &filePath) + setTabletTracking(enable: boolean): void { + this.setProperty('tabletTracking', enable); + } + setToolTip(text: string): void { + this.native.setProperty('toolTip', text); + } + setToolTipDuration(msec: number): void { + this.setProperty('toolTipDuration', msec); + } + setUpdatesEnabled(enable: boolean): void { + this.native.setProperty('updatesEnabled', enable); + } + setWhatsThis(whatsThis: string): void { + this.setProperty('whatsThis', whatsThis); + } + setWindowFilePath(filePath: string): void { + this.setProperty('windowFilePath', filePath); + } setWindowFlag(windowType: WindowType, switchOn: boolean): void { // react:⛔️ return this.native.setWindowFlag(windowType, switchOn); } + // PROP: QWidget // TODO: void setWindowFlags(Qt::WindowFlags type) setWindowIcon(icon: QIcon): void { this.native.setWindowIcon(icon.native); } + // PROP: QWidget // TODO: void setWindowModality(Qt::WindowModality windowModality) setWindowOpacity(opacity: number): void { this.native.setWindowOpacity(opacity); } - // TODO: void setWindowRole(const QString &role) + setWindowRole(role: string): void { + this.native.setWindowRole(role); + } setWindowState(state: WindowState): void { return this.native.setWindowState(state); } @@ -393,10 +483,15 @@ export abstract class NodeWidget extends YogaWid sizeHint(): QSize { return QSize.fromQVariant(this.property('sizeHint')); } - // TODO: QSize sizeIncrement() const + sizeIncrement(): QSize { + return QSize.fromQVariant(this.property('sizeIncrement')); + } + // PROP: QWidget // TODO: QSizePolicy sizePolicy() const // TODO: void stackUnder(QWidget *w) - // TODO: QString statusTip() const + statusTip(): string { + return this.property('statusTip').toString(); + } style(): QStyle { return new QStyle(this.native.style()); } @@ -407,13 +502,25 @@ export abstract class NodeWidget extends YogaWid // react:⛔️ return this.native.testAttribute(attribute); } - // TODO: QString toolTip() const - // TODO: int toolTipDuration() const - // TODO: bool underMouse() const + toolTip(): string { + return this.property('toolTip').toString(); + } + toolTipDuration(): number { + return this.property('toolTipDuration').toInt(); + } // TODO: void ungrabGesture(Qt::GestureType gesture) - // TODO: void unsetCursor() - // TODO: void unsetLayoutDirection() - // TODO: void unsetLocale() + underMouse(): boolean { + return this.native.underMouse(); + } + unsetCursor(): void { + this.native.unsetCursor(); + } + unsetLayoutDirection(): void { + this.native.unsetLayoutDirection(); + } + unsetLocale(): void { + this.native.unsetLocale(); + } // TODO: void update(int x, int y, int w, int h) // TODO: void update(const QRect &rect) // TODO: void update(const QRegion &rgn) @@ -421,15 +528,22 @@ export abstract class NodeWidget extends YogaWid // react:⛔️ this.native.updateGeometry(); } - // TODO: bool updatesEnabled() const + updatesEnabled(): boolean { + return this.property('updatesEnabled').toBool(); + } // TODO: QRegion visibleRegion() const - // TODO: QString whatsThis() const + whatsThis(): string { + return this.property('whatsThis').toString(); + } width(): number { return this.property('width').toInt(); } // TODO: WId winId() const // TODO: QWidget * window() const - // TODO: QString windowFilePath() const + windowFilePath(): string { + return this.property('windowFilePath').toString(); + } + // PROP: QWidget // TODO: Qt::WindowFlags windowFlags() const windowHandle(): QWindow | null { const handle = this.native.windowHandle(); @@ -438,12 +552,17 @@ export abstract class NodeWidget extends YogaWid } return null; } - // TODO: QIcon windowIcon() const + windowIcon(): QIcon { + return QIcon.fromQVariant(this.property('windowIcon')); + } + // PROP: QWidget // TODO: Qt::WindowModality windowModality() const windowOpacity(): number { return this.native.windowOpacity(); } - // TODO: QString windowRole() const + windowRole(): string { + return this.native.windowRole(); + } windowState(): number { return this.native.windowState(); } @@ -491,7 +610,6 @@ export abstract class NodeWidget extends YogaWid const preparedSheet = StyleSheet.create(styleSheet); this.native.setStyleSheet(preparedSheet); } - // TODO: void setStyleSheet(const QString &styleSheet) setVisible(visible: boolean): void { this.native.setVisible(visible); }