NDEVR
API Documentation
QCustomProgressBar

Allows for showing of progress bar in horizontal format. More...

Inheritance diagram for QCustomProgressBar:
[legend]
Collaboration diagram for QCustomProgressBar:
[legend]

Public Member Functions

 QCustomProgressBar (QWidget *parent=nullptr)
 Constructs a progress bar widget.
void addProgressColor (fltp08 percent, RGBColor color)
 Adds a color stop at a given percent to form a gradient.
void clearProgressColors ()
 Removes all custom progress colors, reverting to the default appearance.
bool isIndeterminateState () const
 Checks whether the progress bar is in an indeterminate (spinning) state.
fltp08 percent () const
 Returns the current progress percent.
void setDrawBackground (bool draw_background)
 Sets whether to draw the background behind the progress bar.
void setFormat (const StringView &format)
 Sets the raw format string displayed inside the progress bar when progress is indeterminate.
virtual void setIndeterminateAnimationTimespan (const TimeSpan &span)
 Sets the time span for one full cycle of the indeterminate animation.
virtual void setMessage (const TranslatedString &message)
 Sets the translated message text displayed inside the progress bar when progress is indeterminate.
virtual void setPercent (fltp08 percent)
 Sets the progress bar to a specific percent complete.
void setProgressColor (RGBColor color)
 Sets a single solid color for the progress bar fill.
void setProgressColors (const Buffer< RGBColor > &colors)
 Sets multiple progress colors that will be evenly spaced across the progress range.
virtual void setToIndeterminateState (bool is_indeterminate)
 Toggles the indeterminate state, which shows an animation to indicate activity without a known completion percent.

Protected Member Functions

QString customText (fltp04 percent) const
 Returns the formatted display text for a given percent value.
fltp08 indeterminatePercent () const
 Returns the current indeterminate animation percent for rendering.
QSize minimumSizeHint () const override
 Returns the minimum recommended size for the progress bar.
void paintEvent (QPaintEvent *event) override
 Custom paint event handler that draws the progress bar with gradient and indeterminate animation support.
QSize sizeHint () const override
 Returns the recommended size for the progress bar.
void updateFromTimer ()
 Slot called by the timer to update the indeterminate animation.
void updateProgressColor ()
 Recalculates the current progress color based on the gradient stops and percent.

Protected Attributes

bool m_draw_background
 Whether to draw the background behind the progress bar.
TimeSpan m_indeterminate_period = TimeSpan(1.0)
 Duration for one full indeterminate animation cycle.
String m_last_format = String("0%")
 The last format string used for display text.
QString m_last_text
 The last rendered display text.
Buffer< std::pair< fltp08, RGBColor > > m_progress_colors
 Gradient color stops as percent-color pairs.
QTimer * m_update_timer
 Timer driving the indeterminate animation updates.

Detailed Description

Allows for showing of progress bar in horizontal format.


Defaults to look and feel of system progress bar.

A progress bar is used to give the user an indication of the progress of an operation and to reassure them that the application is still running.

The progress bar uses the concept of percent from 0.0 to 1.0. It will display the percentage specified or can be set to an indeterminate or "spinning" state to indicate progress is occuring, but at an unknown rate.

Definition at line 56 of file QCustomProgressbar.h.

Constructor & Destructor Documentation

◆ QCustomProgressBar()

QCustomProgressBar::QCustomProgressBar ( QWidget * parent = nullptr)
explicit

Constructs a progress bar widget.

Parameters
[in]parentThe parent widget, or nullptr for no parent.

References QCustomProgressBar().

Referenced by QCustomProgressBar().

Member Function Documentation

◆ addProgressColor()

void QCustomProgressBar::addProgressColor ( fltp08 percent,
RGBColor color )

Adds a color stop at a given percent to form a gradient.

Can be called multiple times to build a multi-stop gradient.

Parameters
[in]percentThe percent position (0.0 to 1.0) where this color is most prominent.
[in]colorThe color to use at the given percent.

References percent().

◆ customText()

QString QCustomProgressBar::customText ( fltp04 percent) const
nodiscardprotected

Returns the formatted display text for a given percent value.

Parameters
[in]percentThe percent value to format.
Returns
The formatted QString for display.

References percent().

◆ indeterminatePercent()

fltp08 QCustomProgressBar::indeterminatePercent ( ) const
nodiscardprotected

Returns the current indeterminate animation percent for rendering.

Returns
The animation percent used during indeterminate state rendering.

◆ isIndeterminateState()

bool QCustomProgressBar::isIndeterminateState ( ) const
nodiscard

Checks whether the progress bar is in an indeterminate (spinning) state.

Returns
True if the progress bar is indeterminate, false otherwise.

◆ minimumSizeHint()

QSize QCustomProgressBar::minimumSizeHint ( ) const
nodiscardoverrideprotected

Returns the minimum recommended size for the progress bar.

Returns
The minimum QSize for layout calculations.

◆ paintEvent()

void QCustomProgressBar::paintEvent ( QPaintEvent * event)
overrideprotected

Custom paint event handler that draws the progress bar with gradient and indeterminate animation support.

Parameters
[in]eventThe paint event.

◆ percent()

fltp08 QCustomProgressBar::percent ( ) const
nodiscard

Returns the current progress percent.

Returns
The current percent value between 0.0 and 1.0.

Referenced by addProgressColor(), customText(), ProgressWidget::setAnimatedPercent(), ProgressWidget::setPercent(), setPercent(), and ProgressWidget::setProgress().

◆ setDrawBackground()

void QCustomProgressBar::setDrawBackground ( bool draw_background)

Sets whether to draw the background behind the progress bar.

Parameters
[in]draw_backgroundWhether or not to draw the background.

◆ setFormat()

void QCustomProgressBar::setFormat ( const StringView & format)

Sets the raw format string displayed inside the progress bar when progress is indeterminate.

This is the untranslated version of setMessage.

Parameters
[in]formatThe format string to display inside the progress widget.

Referenced by ProgressWidgetDemo::UpdateWidgetDemo().

◆ setIndeterminateAnimationTimespan()

virtual void QCustomProgressBar::setIndeterminateAnimationTimespan ( const TimeSpan & span)
virtual

Sets the time span for one full cycle of the indeterminate animation.

Parameters
[in]spanThe time span between a complete rotation or color animation cycle when the widget is set to indeterminate progress.

Reimplemented in ProgressWidget.

◆ setMessage()

virtual void QCustomProgressBar::setMessage ( const TranslatedString & message)
virtual

Sets the translated message text displayed inside the progress bar when progress is indeterminate.

Parameters
[in]messageThe translated message to display inside the progress widget.

◆ setPercent()

virtual void QCustomProgressBar::setPercent ( fltp08 percent)
virtual

Sets the progress bar to a specific percent complete.

Parameters
[in]percentThe percent complete between 0.0 and 1.0. Passing an invalid value sets the progress bar to an indeterminate or "spinning" state.

Reimplemented in ProgressWidget.

References percent().

◆ setProgressColor()

void QCustomProgressBar::setProgressColor ( RGBColor color)

Sets a single solid color for the progress bar fill.

Parameters
[in]colorThe color to use as the progress bar fill.

◆ setProgressColors()

void QCustomProgressBar::setProgressColors ( const Buffer< RGBColor > & colors)

Sets multiple progress colors that will be evenly spaced across the progress range.

Parameters
[in]colorsThe colors to use, evenly distributed across the progress bar.

Referenced by ProgressWidgetDemo::Setup().

◆ setToIndeterminateState()

virtual void QCustomProgressBar::setToIndeterminateState ( bool is_indeterminate)
virtual

Toggles the indeterminate state, which shows an animation to indicate activity without a known completion percent.

Can also be triggered by setPercent using an invalid value to enter indeterminate mode, or a real number to show progress.

Parameters
[in]is_indeterminateWhether to make the progress bar indeterminate.

◆ sizeHint()

QSize QCustomProgressBar::sizeHint ( ) const
nodiscardoverrideprotected

Returns the recommended size for the progress bar.

Returns
The recommended QSize for layout calculations.

The documentation for this class was generated from the following file: