Skip to content

Commit

Permalink
Native style: Fix indeterminate ProgressIndicator
Browse files Browse the repository at this point in the history
We need to pass a styleObject for the animation to work
The state will be shared accross all progressbar, but that's ok
  • Loading branch information
ogoffart committed Jun 21, 2023
1 parent f1bc0eb commit d578481
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions internal/backends/qt/qt_widgets/progress_indicator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl Item for NativeProgressIndicator {

fn_render! { this dpr size painter widget _initial_state =>
let indeterminate = this.indeterminate() as bool;
let progress = if indeterminate { 0 } else { (this.progress().max(0.0).min(1.0) * 100.) as i32 };
let progress = if indeterminate { -1 } else { (this.progress().max(0.0).min(1.0) * 100.) as i32 };

cpp!(unsafe [
painter as "QPainterPtr*",
Expand All @@ -114,9 +114,10 @@ impl Item for NativeProgressIndicator {
QPainter *painter_ = painter->get();
QStyleOptionProgressBar option;
option.rect = QRect(QPoint(), size / dpr);
option.maximum = 100;
option.maximum = progress < 0 ? 0 : 100;
option.minimum = 0;
option.progress = progress;
option.styleObject = widget;

qApp->style()->drawControl(QStyle::CE_ProgressBar, &option, painter_, widget);
});
Expand Down

0 comments on commit d578481

Please sign in to comment.