yolo
This commit is contained in:
parent
8486f40a99
commit
f14111bc96
@ -23,6 +23,7 @@
|
||||
"../src/cpp/QtWidgets/QMainWindow/qmainwindow_wrap.cpp",
|
||||
"../src/cpp/QtWidgets/QPushButton/qpushbutton_wrap.cpp",
|
||||
"../src/cpp/QtWidgets/QCheckBox/qcheckbox_wrap.cpp",
|
||||
"../src/cpp/QtWidgets/QProgressBar/qprogressbar_wrap.cpp",
|
||||
],
|
||||
}
|
||||
]
|
||||
|
||||
4
demo.ts
4
demo.ts
@ -4,6 +4,7 @@ import { QGridLayout } from "./src/lib/QtWidgets/QGridLayout";
|
||||
import { QLabel } from "./src/lib/QtWidgets/QLabel";
|
||||
import { QPushButton } from "./src/lib/QtWidgets/QPushButton";
|
||||
import { QCheckBox } from "./src/lib/QtWidgets/QCheckBox";
|
||||
import { QProgressBar } from "./src/lib/QtWidgets/QProgressBar";
|
||||
|
||||
const win = new QMainWindow();
|
||||
const view = new QWidget();
|
||||
@ -23,10 +24,13 @@ button1.setText("Yolo");
|
||||
const checkbox = new QCheckBox();
|
||||
checkbox.setText("Pumpkeen");
|
||||
|
||||
const progressbar = new QProgressBar();
|
||||
|
||||
gridLayout.addWidget(label);
|
||||
gridLayout.addWidget(label2);
|
||||
gridLayout.addWidget(button1);
|
||||
gridLayout.addWidget(checkbox);
|
||||
gridLayout.addWidget(progressbar);
|
||||
|
||||
view.setLayout(gridLayout);
|
||||
|
||||
|
||||
47
src/cpp/QtWidgets/QProgressBar/qprogressbar_wrap.cpp
Normal file
47
src/cpp/QtWidgets/QProgressBar/qprogressbar_wrap.cpp
Normal file
@ -0,0 +1,47 @@
|
||||
|
||||
#include "qprogressbar_wrap.h"
|
||||
#include "src/cpp/QtGui/QWidget/qwidget_wrap.h"
|
||||
#include "src/cpp/Extras/Utils/utils.h"
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
Napi::FunctionReference QProgressBarWrap::constructor;
|
||||
|
||||
Napi::Object QProgressBarWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
Napi::HandleScope scope(env);
|
||||
char CLASSNAME[] = "QProgressBar";
|
||||
Napi::Function func = DefineClass(env, CLASSNAME, {
|
||||
QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE(QProgressBarWrap)
|
||||
});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
return exports;
|
||||
}
|
||||
|
||||
QProgressBar* QProgressBarWrap::getInternalInstance() {
|
||||
return this->instance;
|
||||
}
|
||||
|
||||
QProgressBarWrap::QProgressBarWrap(const Napi::CallbackInfo& info): Napi::ObjectWrap<QProgressBarWrap>(info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
if(info.Length() == 1) {
|
||||
if(info[0].IsObject()){
|
||||
Napi::Object object_parent = info[0].As<Napi::Object>();
|
||||
QWidgetWrap* w_parent = Napi::ObjectWrap<QWidgetWrap>::Unwrap(object_parent);
|
||||
this->instance = new QProgressBar(w_parent->getInternalInstance()); //this sets the parent to current widget
|
||||
}else{
|
||||
extrautils::throwTypeError(env, "Wrong type of arguments");
|
||||
}
|
||||
}else if (info.Length() == 0){
|
||||
this->instance = new QProgressBar();
|
||||
}else {
|
||||
extrautils::throwTypeError(env, "Wrong number of arguments");
|
||||
}
|
||||
}
|
||||
|
||||
QProgressBarWrap::~QProgressBarWrap() {
|
||||
delete this->instance;
|
||||
}
|
||||
|
||||
22
src/cpp/QtWidgets/QProgressBar/qprogressbar_wrap.h
Normal file
22
src/cpp/QtWidgets/QProgressBar/qprogressbar_wrap.h
Normal file
@ -0,0 +1,22 @@
|
||||
#ifndef QPROGRESSBAR_WRAP_H
|
||||
#define QPROGRESSBAR_WRAP_H
|
||||
#include <napi.h>
|
||||
#include <QProgressBar>
|
||||
#include "src/cpp/QtGui/QWidget/qwidget_macro.h"
|
||||
|
||||
class QProgressBarWrap : public Napi::ObjectWrap<QProgressBarWrap>{
|
||||
private:
|
||||
QProgressBar* instance;
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QProgressBarWrap(const Napi::CallbackInfo& info);
|
||||
~QProgressBarWrap();
|
||||
QProgressBar* getInternalInstance();
|
||||
//class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
//wrapped methods
|
||||
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -6,6 +6,7 @@
|
||||
#include "src/cpp/QtWidgets/QMainWindow/qmainwindow_wrap.h"
|
||||
#include "src/cpp/QtWidgets/QPushButton/qpushbutton_wrap.h"
|
||||
#include "src/cpp/QtWidgets/QCheckBox/qcheckbox_wrap.h"
|
||||
#include "src/cpp/QtWidgets/QProgressBar/qprogressbar_wrap.h"
|
||||
#include <napi.h>
|
||||
|
||||
//private : will not be accessibe in js
|
||||
@ -21,6 +22,7 @@ Napi::Object Main(Napi::Env env, Napi::Object exports) {
|
||||
QMainWindowWrap::init(env,exports);
|
||||
QPushButtonWrap::init(env, exports);
|
||||
QCheckBoxWrap::init(env, exports);
|
||||
QProgressBarWrap::init(env, exports);
|
||||
return QLabelWrap::init(env, exports);
|
||||
}
|
||||
|
||||
|
||||
20
src/index.ts
20
src/index.ts
@ -1,20 +0,0 @@
|
||||
import { QApplication } from "./lib/QtGui/QApplication";
|
||||
import { QWidget } from "./lib/QtGui/QWidget";
|
||||
import { QGridLayout } from "./lib/QtWidgets/QGridLayout";
|
||||
import { QLabel } from "./lib/QtWidgets/QLabel";
|
||||
import { QLayout } from "./lib/QtWidgets/QLayout";
|
||||
import { QMainWindow } from "./lib/QtWidgets/QMainWindow";
|
||||
import { QPushButton } from "./lib/QtWidgets/QPushButton";
|
||||
|
||||
export const QtGui = {
|
||||
QApplication,
|
||||
QWidget
|
||||
};
|
||||
|
||||
export const QtWidgets = {
|
||||
QGridLayout,
|
||||
QLabel,
|
||||
QMainWindow,
|
||||
QLayout,
|
||||
QPushButton
|
||||
};
|
||||
17
src/lib/QtWidgets/QProgressBar/index.ts
Normal file
17
src/lib/QtWidgets/QProgressBar/index.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import addon from "../../core/addon";
|
||||
import { NodeWidget } from "../../QtGui/QWidget";
|
||||
import { QLayout } from "../QLayout";
|
||||
|
||||
export class QProgressBar extends NodeWidget {
|
||||
native: any;
|
||||
layout?: QLayout;
|
||||
constructor(parent?: NodeWidget) {
|
||||
super();
|
||||
if (parent) {
|
||||
this.native = new addon.QProgressBar(parent.native);
|
||||
this.parent = parent;
|
||||
} else {
|
||||
this.native = new addon.QProgressBar();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user