Merge pull request #39 from Uriziel01/master
Support for setting orientation inside progressbar widget
This commit is contained in:
commit
2011d51d27
@ -50,6 +50,12 @@ Sets the min value of the progressBar. It calls the native method [QProgressBar:
|
||||
|
||||
- `min` number - Set the value as min value of the progress bar.
|
||||
|
||||
#### `progressBar.setOrientation(orientation)`
|
||||
|
||||
Sets the orientation of the progressBar. It calls the native method [QProgressBar: setOrientation](https://doc.qt.io/qt-5/qprogressbar.html#orientation-prop).
|
||||
|
||||
- `orientation` Orientation - Specifies visual orientation of the progress bar. [Orientation is an enum from Qt](api/QtEnums.md)
|
||||
|
||||
#### `progressBar.value()`
|
||||
|
||||
Returns the current value (Number) of the progressBar. It calls the native method [QProgressBar: value](https://doc.qt.io/qt-5/qprogressbar.html#value-prop).
|
||||
|
||||
@ -14,6 +14,7 @@ Napi::Object QProgressBarWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
InstanceMethod("setValue", &QProgressBarWrap::setValue),
|
||||
InstanceMethod("setMaximum", &QProgressBarWrap::setMaximum),
|
||||
InstanceMethod("setMinimum", &QProgressBarWrap::setMinimum),
|
||||
InstanceMethod("setOrientation", &QProgressBarWrap::setOrientation),
|
||||
InstanceMethod("value", &QProgressBarWrap::value),
|
||||
QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE(QProgressBarWrap)
|
||||
});
|
||||
@ -71,6 +72,14 @@ Napi::Value QProgressBarWrap::setMinimum(const Napi::CallbackInfo& info) {
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QProgressBarWrap::setOrientation(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
Napi::Number value = info[0].As<Napi::Number>();
|
||||
this->instance->setOrientation(static_cast<Qt::Orientation>(value.Int32Value()));
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QProgressBarWrap::value(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
@ -18,6 +18,7 @@ class QProgressBarWrap : public Napi::ObjectWrap<QProgressBarWrap>{
|
||||
Napi::Value setValue(const Napi::CallbackInfo& info);
|
||||
Napi::Value setMaximum(const Napi::CallbackInfo& info);
|
||||
Napi::Value setMinimum(const Napi::CallbackInfo& info);
|
||||
Napi::Value setOrientation(const Napi::CallbackInfo& info);
|
||||
Napi::Value value(const Napi::CallbackInfo& info);
|
||||
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// enums
|
||||
export { AspectRatioMode, WidgetAttribute, WindowType } from "./lib/QtEnums";
|
||||
export { AspectRatioMode, WidgetAttribute, WindowType, Orientation } from "./lib/QtEnums";
|
||||
export { QApplication } from "./lib/QtGui/QApplication";
|
||||
export { QWidget, QWidgetEvents } from "./lib/QtGui/QWidget";
|
||||
export { QPixmap } from "./lib/QtGui/QPixmap";
|
||||
|
||||
@ -124,3 +124,8 @@ export enum WidgetAttribute {
|
||||
WA_AlwaysStackOnTop = 128,
|
||||
WA_ContentsMarginsRespectsSafeArea = 13
|
||||
}
|
||||
|
||||
export enum Orientation {
|
||||
Horizontal = 1,
|
||||
Vertical = 2
|
||||
}
|
||||
@ -2,6 +2,7 @@ import addon from "../../core/addon";
|
||||
import { NodeWidget } from "../../QtGui/QWidget";
|
||||
import { BaseWidgetEvents } from "../../core/EventWidget";
|
||||
import { NativeElement } from "../../core/Component";
|
||||
import { Orientation } from "../../QtEnums";
|
||||
|
||||
export const QProgressBarEvents = Object.freeze({
|
||||
...BaseWidgetEvents
|
||||
@ -22,6 +23,7 @@ export class QProgressBar extends NodeWidget {
|
||||
this.setValue.bind(this);
|
||||
this.setMinimum.bind(this);
|
||||
this.setMaximum.bind(this);
|
||||
this.setOrientation.bind(this);
|
||||
this.value.bind(this);
|
||||
}
|
||||
setValue(value: number) {
|
||||
@ -33,6 +35,9 @@ export class QProgressBar extends NodeWidget {
|
||||
setMaximum(max: number) {
|
||||
this.native.setMaximum(max);
|
||||
}
|
||||
setOrientation(orientation: Orientation) {
|
||||
this.native.setOrientation(orientation);
|
||||
}
|
||||
value(): number {
|
||||
return this.native.value();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user