Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/api/QProgressBar.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
9 changes: 9 additions & 0 deletions src/cpp/QtWidgets/QProgressBar/qprogressbar_wrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
});
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/cpp/QtWidgets/QProgressBar/qprogressbar_wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
5 changes: 5 additions & 0 deletions src/lib/QtEnums/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,8 @@ export enum WidgetAttribute {
WA_AlwaysStackOnTop = 128,
WA_ContentsMarginsRespectsSafeArea = 13
}

export enum Orientation {
Horizontal = 1,
Vertical = 2
}
5 changes: 5 additions & 0 deletions src/lib/QtWidgets/QProgressBar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand All @@ -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();
}
Expand Down