From b33345bc921f9deb561b66af83ac68a8e59bd1f9 Mon Sep 17 00:00:00 2001 From: slidinghotdog Date: Tue, 3 Dec 2019 02:05:01 -0300 Subject: [PATCH] remove unused imports from demo --- .../QtWidgets/QBoxLayout/qboxlayout_wrap.cpp | 17 ++++++++------ src/demo.ts | 23 +++++++++---------- src/lib/QtWidgets/QBoxLayout.ts | 6 ++--- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/cpp/lib/QtWidgets/QBoxLayout/qboxlayout_wrap.cpp b/src/cpp/lib/QtWidgets/QBoxLayout/qboxlayout_wrap.cpp index bfc0f3d46..bcd42ab15 100644 --- a/src/cpp/lib/QtWidgets/QBoxLayout/qboxlayout_wrap.cpp +++ b/src/cpp/lib/QtWidgets/QBoxLayout/qboxlayout_wrap.cpp @@ -34,16 +34,18 @@ QBoxLayoutWrap::QBoxLayoutWrap(const Napi::CallbackInfo& info) Napi::HandleScope scope(env); if (info.Length() == 2) { - QBoxLayout::Direction dir = static_cast(info[0].As().Int32Value()); + QBoxLayout::Direction dir = static_cast( + info[0].As().Int32Value()); Napi::Object parentObject = info[1].As(); QWidgetWrap* parentWidgetWrap = Napi::ObjectWrap::Unwrap(parentObject); - this->instance = new NBoxLayout(dir, parentWidgetWrap->getInternalInstance()); - } else if (info.Length() == 1){ - QBoxLayout::Direction dir = static_cast(info[0].As().Int32Value()); + this->instance = + new NBoxLayout(dir, parentWidgetWrap->getInternalInstance()); + } else if (info.Length() == 1) { + QBoxLayout::Direction dir = static_cast( + info[0].As().Int32Value()); this->instance = new NBoxLayout(dir); - } - else { + } else { Napi::TypeError::New(env, "Wrong number of arguments") .ThrowAsJavaScriptException(); } @@ -124,7 +126,8 @@ Napi::Value QBoxLayoutWrap::removeWidget(const Napi::CallbackInfo& info) { Napi::Value QBoxLayoutWrap::setDirection(const Napi::CallbackInfo& info) { Napi::Env env = info.Env(); Napi::HandleScope scope(env); - QBoxLayout::Direction dir = static_cast(info[0].As().Int32Value()); + QBoxLayout::Direction dir = static_cast( + info[0].As().Int32Value()); this->instance->setDirection(dir); return env.Null(); } \ No newline at end of file diff --git a/src/demo.ts b/src/demo.ts index 7cc5fe56e..08642c797 100644 --- a/src/demo.ts +++ b/src/demo.ts @@ -1,12 +1,11 @@ -import { QWidget, QMainWindow, FlexLayout, QLabel, QBoxLayout, QPushButton } from './index'; -import { QScrollArea } from './lib/QtWidgets/QScrollArea'; +import { QWidget, QMainWindow, QLabel, QBoxLayout, QPushButton } from './index'; import { Direction } from './lib/QtEnums'; const win = new QMainWindow(); const center = new QWidget(); const btn1 = new QPushButton(); const btn2 = new QPushButton(); -const boxLayout = new QBoxLayout(Direction.LeftToRight) +const boxLayout = new QBoxLayout(Direction.LeftToRight); btn1.setText(` 😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱 Hellloooooo @@ -38,22 +37,22 @@ btn2.setInlineStyle(`padding: 10;font-family: "Sans serif";`); center.setLayout(boxLayout); boxLayout.addWidget(btn1); boxLayout.addWidget(btn2); -const box2 = new QBoxLayout(Direction.BottomToTop) +const box2 = new QBoxLayout(Direction.BottomToTop); const lbl1 = new QLabel(); const lbl2 = new QLabel(); -lbl1.setText("lbl1") -lbl2.setText("lbl2") +lbl1.setText('lbl1'); +lbl2.setText('lbl2'); lbl1.setInlineStyle(`border: 2px solid blue;`); lbl2.setInlineStyle(`border: 2px solid green;`); box2.addWidget(lbl1); box2.addWidget(lbl2); -btn1.addEventListener('clicked', ()=>{ - console.log('direction',boxLayout.direction()) - boxLayout.addLayout(box2, 2) -}) -btn2.addEventListener('clicked', ()=>{ +btn1.addEventListener('clicked', () => { + console.log('direction', boxLayout.direction()); + boxLayout.addLayout(box2, 2); +}); +btn2.addEventListener('clicked', () => { boxLayout.addSpacing(20); -} ) +}); win.setCentralWidget(center); win.show(); diff --git a/src/lib/QtWidgets/QBoxLayout.ts b/src/lib/QtWidgets/QBoxLayout.ts index 1f1c4824f..95b12114a 100644 --- a/src/lib/QtWidgets/QBoxLayout.ts +++ b/src/lib/QtWidgets/QBoxLayout.ts @@ -17,13 +17,13 @@ export class QBoxLayout extends NodeLayout { this.nodeParent = parent; this.native = native; } - addLayout(layout: NodeLayout, stretch: number = 0): void { + addLayout(layout: NodeLayout, stretch = 0): void { this.native.addLayout(layout.native, stretch); } addSpacing(size: number): void { this.native.addSpacing(size); } - addStretch(stretch: number = 0): void { + addStretch(stretch = 0): void { this.native.addStretch(stretch); } addStrut(size: number): void { @@ -36,7 +36,7 @@ export class QBoxLayout extends NodeLayout { direction(): Direction { return this.native.direction(); } - insertLayout(index: number, layout: NodeLayout, stretch: number = 0): void { + insertLayout(index: number, layout: NodeLayout, stretch = 0): void { this.native.insertLayout(index, layout.native, stretch); } removeWidget(widget: NodeWidget): void {