NDEVR
API Documentation
ProgressWidget

Displays the progress, either horizontally as a bar or as a round spin dial. More...

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

Public Member Functions

 ProgressWidget (QWidget *parent=nullptr)
 Constructs a ProgressWidget.
virtual void addMessage (uint04 id, const LogMessage &) override
 Receives a log message and displays it in the progress widget.
void clearIcon ()
 Removes any icon from the progress widget.
void clearTextRectCache ()
 Clears the cached text layout rectangles, forcing recalculation on next paint.
virtual bool event (QEvent *event) override
 Handles general events, including style changes and timer events.
bool hasHeightForWidth () const override
 Indicates that this widget has a preferred height-for-width relationship.
int heightForWidth (int w) const override
 Returns the appropriate height for a given width to maintain aspect ratio.
bool isHorizontal () const
 Checks whether the widget is in horizontal bar mode.
QSize minimumSizeHint () const override
 Returns the minimum size hint for the widget.
void paintEvent (QPaintEvent *event) override
 Paints the progress widget, rendering either the bar or dial.
fltp04 progressEpsilon () const
 Returns the minimum change in progress needed to trigger a visual update.
void resizeEvent (QResizeEvent *event) override
 Handles resize events, recalculating the layout and cached geometry.
virtual void setAnimatedPercent (fltp08 percent)
 Sets the progress percentage with a smooth animation transition.
void setFontSizeMultiplier (fltp04 size_multiplier)
 Sets a multiplier for the font size used in the progress label.
void setHorizontal (bool is_horizontal)
 Sets whether the progress is displayed as a horizontal bar or a circular dial.
void setIconID (const String &image_id, bool foreground=true)
 Sets the icon displayed within the progress widget.
virtual void setIndeterminateAnimationTimespan (const TimeSpan &span) override
 Sets the time span for one full cycle of the indeterminate animation.
virtual void setPercent (fltp08 percent) override
 Sets the progress percentage directly without animation.
void setProgressThickness (fltp04 thickness)
 Sets the thickness of the progress arc or bar relative to the widget size.
void setShowLogMessage (bool show_log_message)
 Sets whether to display log messages inside the progress widget.
void setSizeMultiplier (fltp04 size_multiplier)
 Sets a multiplier for the overall widget size.
void setState (bool is_warning, bool is_error)
 Sets the visual state to reflect warning or error conditions.
void setTickCount (uint04 tick_count)
 Sets the number of tick marks drawn around the circular dial.
QSize sizeHint () const override
 Returns the preferred size for the widget.
Public Member Functions inherited from QCustomProgressBar
 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 setMessage (const TranslatedString &message)
 Sets the translated message text displayed inside the progress bar when progress is indeterminate.
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.
Public Member Functions inherited from LogStream
virtual ~LogStream ()
 Destructor.
virtual void addMessages (uint04 id, const Buffer< LogMessage > &messages)
 Adds multiple log messages to this stream at once.
virtual void addProgressSource (const TranslatedString &name, uint04 idx, fltp04 progress)
 Registers a new progress source to be tracked by this stream.
virtual void allowCancel (bool)
 Sets whether this stream allows the user to cancel an in-progress operation.
virtual void allowInput (bool)
 Sets whether this stream allows user input during an operation.
virtual void attach (InfoPipe *stream)
 Attaches this LogStream to the given InfoPipe so it receives log updates.
void clearLinks ()
 Detaches this LogStream from all linked InfoPipe objects and clears the link list.
virtual void detach (InfoPipe *stream)
 Detaches this LogStream from the given InfoPipe, stopping further updates from it.
bool ignoringMessages () const
 Returns whether this stream is currently ignoring messages.
virtual void removeProgressSource (uint04 idx)
 Removes a previously registered progress source from this stream.
void setIgnoreMessages (bool ignore)
 Sets whether this stream should ignore incoming messages.

Protected Member Functions

void setProgress (uint04 id, fltp04 percent) override
 Sets the progress for a specific tracked operation by ID.
void updateTimerInterval ()
 Recalculates the timer interval based on the current animation state.
Protected Member Functions inherited from QCustomProgressBar
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

QVariantAnimation * m_animation = nullptr
 The animation object for smooth percent transitions.
QIcon m_background_icon
 The cached icon rendered in the background or foreground.
fltp04 m_current_percent = Constant<fltp04>::Invalid
 The current displayed progress percentage.
QRegion m_dirty_blade_region
 The region of dirty blade segments needing repaint.
Buffer< bool > m_dirty_blades
 Tracks which dial blade segments need repainting.
fltp04 m_font_size_multiplier = 2.0f
 Font size multiplier for the progress label.
bool m_icon_foreground = false
 Whether the icon is drawn in the foreground.
String m_icon_id
 The resource identifier for the displayed icon.
bool m_ignore_animation = false
 Whether to skip animation and set progress immediately.
bool m_is_analog
 Whether the widget uses analog-style rendering.
bool m_is_horizontal
 Whether the widget is in horizontal bar mode.
bool m_is_updating_percent
 Guard flag to prevent recursive percent updates.
fltp04 m_last_animation_percent = Constant<fltp04>::Invalid
 The last animation frame percentage.
QFont m_last_font_a
 Cached font for the primary text.
QFont m_last_font_b
 Cached font for the secondary text.
fltp04 m_last_percent
 The last rendered progress percentage.
QString m_last_text
 The last rendered text string.
fltp04 m_last_text_radius_a
 Cached inner text radius for circular mode.
fltp04 m_last_text_radius_b
 Cached outer text radius for circular mode.
Time m_last_update_time = Constant<Time>::Invalid
 The timestamp of the last visual update.
fltp04 m_next_percent = Constant<fltp04>::Invalid
 The target percentage for animation.
bool m_show_log_messages = false
 Whether to display log messages in the widget.
fltp04 m_size_multiplier = 1.0f
 Overall widget size multiplier.
fltp04 m_thickness = 0.1f
 Thickness of the progress arc or bar as a fraction.
uint04 m_tick_count = 20
 Number of tick marks around the circular dial.
Protected Attributes inherited from QCustomProgressBar
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.
Protected Attributes inherited from LogStream
bool m_ignore_message = false
 Whether this stream should ignore incoming messages.
Buffer< InfoPipe * > m_linked_logs
 Collection of InfoPipe objects this stream is listening to.
Dictionary< uint04, ProgressSourcem_progress_sources
 Maps progress source indices to their ProgressSource data.

Detailed Description

Displays the progress, either horizontally as a bar or as a round spin dial.


Contains various options for display and can be added as a LogStream to a Log.

Definition at line 48 of file ProgressWidget.h.

Constructor & Destructor Documentation

◆ ProgressWidget()

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

Constructs a ProgressWidget.

Parameters
[in]parentThe parent widget.

References ProgressWidget().

Referenced by ProgressWidget().

Member Function Documentation

◆ addMessage()

virtual void ProgressWidget::addMessage ( uint04 id,
const LogMessage &  )
overridevirtual

Receives a log message and displays it in the progress widget.

Parameters
[in]idThe message identifier.
[in]messageThe log message to display.

Implements LogStream.

◆ event()

virtual bool ProgressWidget::event ( QEvent * event)
overridevirtual

Handles general events, including style changes and timer events.

Parameters
[in]eventThe event to handle.
Returns
True if the event was handled.

References event().

Referenced by event(), paintEvent(), and resizeEvent().

◆ hasHeightForWidth()

bool ProgressWidget::hasHeightForWidth ( ) const
override

Indicates that this widget has a preferred height-for-width relationship.

Returns
True.

◆ heightForWidth()

int ProgressWidget::heightForWidth ( int w) const
override

Returns the appropriate height for a given width to maintain aspect ratio.

Parameters
[in]wThe width in pixels.
Returns
The computed height in pixels.

◆ isHorizontal()

bool ProgressWidget::isHorizontal ( ) const
inline

Checks whether the widget is in horizontal bar mode.

Returns
True if horizontal, false if circular dial mode.

Definition at line 132 of file ProgressWidget.h.

References m_is_horizontal.

◆ minimumSizeHint()

QSize ProgressWidget::minimumSizeHint ( ) const
nodiscardoverride

Returns the minimum size hint for the widget.

Returns
The minimum QSize.

◆ paintEvent()

void ProgressWidget::paintEvent ( QPaintEvent * event)
override

Paints the progress widget, rendering either the bar or dial.

Parameters
[in]eventThe paint event.

References event().

◆ progressEpsilon()

fltp04 ProgressWidget::progressEpsilon ( ) const

Returns the minimum change in progress needed to trigger a visual update.

Returns
The epsilon threshold as a float.

◆ resizeEvent()

void ProgressWidget::resizeEvent ( QResizeEvent * event)
override

Handles resize events, recalculating the layout and cached geometry.

Parameters
[in]eventThe resize event.

References event().

◆ setAnimatedPercent()

virtual void ProgressWidget::setAnimatedPercent ( fltp08 percent)
virtual

Sets the progress percentage with a smooth animation transition.

Parameters
[in]percentThe target progress percentage from 0.0 to 1.0.

References QCustomProgressBar::percent().

◆ setFontSizeMultiplier()

void ProgressWidget::setFontSizeMultiplier ( fltp04 size_multiplier)

Sets a multiplier for the font size used in the progress label.

Parameters
[in]size_multiplierThe font size scaling factor.

◆ setHorizontal()

void ProgressWidget::setHorizontal ( bool is_horizontal)

Sets whether the progress is displayed as a horizontal bar or a circular dial.

Parameters
[in]is_horizontalTrue for horizontal bar mode, false for circular dial mode.

Referenced by ProgressWidgetDemo::UpdateWidgetDemo().

◆ setIconID()

void ProgressWidget::setIconID ( const String & image_id,
bool foreground = true )

Sets the icon displayed within the progress widget.

Parameters
[in]image_idThe icon resource identifier.
[in]foregroundIf true, draws the icon in the foreground; otherwise in the background.

Referenced by ProgressWidgetDemo::UpdateWidgetDemo().

◆ setIndeterminateAnimationTimespan()

virtual void ProgressWidget::setIndeterminateAnimationTimespan ( const TimeSpan & span)
overridevirtual

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

Parameters
[in]spanThe animation cycle duration.

Reimplemented from QCustomProgressBar.

◆ setPercent()

virtual void ProgressWidget::setPercent ( fltp08 percent)
overridevirtual

Sets the progress percentage directly without animation.

Parameters
[in]percentThe progress percentage from 0.0 to 1.0.

Reimplemented from QCustomProgressBar.

References QCustomProgressBar::percent().

Referenced by ProgressWidgetDemo::UpdateWidgetDemo().

◆ setProgress()

void ProgressWidget::setProgress ( uint04 id,
fltp04 percent )
overrideprotectedvirtual

Sets the progress for a specific tracked operation by ID.

Parameters
[in]idThe operation identifier.
[in]percentThe progress percentage for that operation.

Implements LogStream.

References QCustomProgressBar::percent().

◆ setProgressThickness()

void ProgressWidget::setProgressThickness ( fltp04 thickness)

Sets the thickness of the progress arc or bar relative to the widget size.

Parameters
[in]thicknessThe thickness as a fraction of the widget dimension.

Referenced by ProgressWidgetDemo::UpdateWidgetDemo().

◆ setShowLogMessage()

void ProgressWidget::setShowLogMessage ( bool show_log_message)

Sets whether to display log messages inside the progress widget.

Parameters
[in]show_log_messageTrue to show messages, false to hide them.

◆ setSizeMultiplier()

void ProgressWidget::setSizeMultiplier ( fltp04 size_multiplier)

Sets a multiplier for the overall widget size.

Parameters
[in]size_multiplierThe size scaling factor.

◆ setState()

void ProgressWidget::setState ( bool is_warning,
bool is_error )

Sets the visual state to reflect warning or error conditions.

Parameters
[in]is_warningWhether the progress indicates a warning.
[in]is_errorWhether the progress indicates an error.

◆ setTickCount()

void ProgressWidget::setTickCount ( uint04 tick_count)

Sets the number of tick marks drawn around the circular dial.

Parameters
[in]tick_countThe number of ticks.

Referenced by ProgressWidgetDemo::UpdateWidgetDemo().

◆ sizeHint()

QSize ProgressWidget::sizeHint ( ) const
nodiscardoverride

Returns the preferred size for the widget.

Returns
The preferred QSize.

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