Feature/bug fixes (#254)

* cleanup

* Check for preventing double addition due to the way reconciler works

* set scrollarea as resizeable by default
This commit is contained in:
Atul R 2019-12-08 20:55:13 +01:00 committed by GitHub
parent a3aa6ea44a
commit f8c9557166
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 17 additions and 9 deletions

View File

@ -20,7 +20,7 @@
\
Napi::String napiText = info[0].As<Napi::String>(); \
std::string text = napiText.Utf8Value(); \
this->instance->setText(text.c_str()); \
this->instance->setText(QString::fromUtf8(text.c_str())); \
return env.Null(); \
} \
\

View File

@ -76,7 +76,7 @@ Napi::Value QLabelWrap::setText(const Napi::CallbackInfo& info) {
Napi::String text = info[0].As<Napi::String>();
std::string label = text.Utf8Value();
this->instance->setText(label.c_str());
this->instance->setText(QString::fromUtf8(label.c_str()));
return env.Null();
}

View File

@ -10,9 +10,9 @@ void EventWidget::subscribeToQtEvent(std::string evtString) {
this->subscribedEvents.insert(
{static_cast<QEvent::Type>(evtType), evtString});
} catch (...) {
qDebug() << "EventWidget: Couldn't subscribe to qt event"
<< evtString.c_str()
<< ". If this is a signal you can safely ignore this warning";
// qDebug() << "EventWidget: Couldn't subscribe to qt event"
// << evtString.c_str()
// << ". If this is a signal you can safely ignore this warning";
}
}
@ -22,9 +22,9 @@ void EventWidget::unSubscribeToQtEvent(std::string evtString) {
this->subscribedEvents.erase(
static_cast<QEvent::Type>(evtType)); // erasing by key
} catch (...) {
qDebug() << "EventWidget: Couldn't unsubscribe to qt event "
<< evtString.c_str()
<< ". If this is a signal you can safely ignore this warning ";
// qDebug() << "EventWidget: Couldn't unsubscribe to qt event "
// << evtString.c_str()
// << ". If this is a signal you can safely ignore this warning ";
}
}

View File

@ -5,6 +5,7 @@ import { NodeObject } from '../QtCore/QObject';
export abstract class NodeLayout extends NodeObject {
type = 'layout';
abstract addWidget(childWidget: NodeWidget, ...args: any[]): void;
abstract removeWidget(childWidget: NodeWidget): void;
activate(): boolean {
return this.native.activate();
}

View File

@ -20,6 +20,7 @@ export class QScrollArea extends QAbstractScrollArea {
super(native);
this.native = native;
this.nodeParent = parent;
this.setWidgetResizable(true);
}
setWidget(widget: NodeWidget): void {
// react:✓, //TODO:getter

View File

@ -14,6 +14,9 @@ export class FlexLayout extends NodeLayout {
protected flexNode?: FlexNode;
addWidget(childWidget: NodeWidget, childFlexNode?: FlexNode): void {
if (this.nodeChildren.has(childWidget)) {
return;
}
const childYogaNode = childFlexNode || childWidget.getFlexNode();
this.nodeChildren.add(childWidget);
this.native.addWidget(childWidget.native, childYogaNode);
@ -25,6 +28,9 @@ export class FlexLayout extends NodeLayout {
childFlexNode?: FlexNode,
beforeChildFlexNode?: FlexNode,
): void {
if (this.nodeChildren.has(childWidget)) {
return;
}
const childYogaNode = childFlexNode || childWidget.getFlexNode();
const beforeChildYogaNode = beforeChildFlexNode || beforeChildWidget.getFlexNode();
this.nodeChildren.add(childWidget); // No orderer required yet, so just inserting at the end.
@ -36,8 +42,8 @@ export class FlexLayout extends NodeLayout {
return;
}
const childYogaNode = childFlexNode || childWidget.getFlexNode();
this.nodeChildren.delete(childWidget);
this.native.removeWidget(childWidget.native, childYogaNode);
this.nodeChildren.delete(childWidget);
}
setFlexNode(flexNode: FlexNode): void {