NDEVR
API Documentation
ProgressWidget.h
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Widgets
28File: ProgressWidget
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/QCustomProgressBar.h>
35#include <NDEVR/LogStream.h>
36class QTimer;
37class QRectF;
38class QPixmap;
39class QRadialGradient;
40class QVariantAnimation;
41namespace NDEVR
42{
48 class NDEVR_WIDGETS_API ProgressWidget : public QCustomProgressBar, public LogStream
49 {
50 public:
55 explicit ProgressWidget(QWidget* parent = nullptr);
56 virtual ~ProgressWidget() override;
62 void setIconID(const String& image_id, bool foreground = true);
66 void clearIcon();
71 void resizeEvent(QResizeEvent* event) override;
76 void setHorizontal(bool is_horizontal);
81 void setTickCount(uint04 tick_count);
86 void paintEvent(QPaintEvent* event) override;
91 void setShowLogMessage(bool show_log_message);
96 void setSizeMultiplier(fltp04 size_multiplier);
101 void setFontSizeMultiplier(fltp04 size_multiplier);
106 virtual void setIndeterminateAnimationTimespan(const TimeSpan& span) override;
116 [[nodiscard]] QSize sizeHint() const override;
121 [[nodiscard]] QSize minimumSizeHint() const override;
127 virtual bool event(QEvent* event) override;
132 bool isHorizontal() const { return m_is_horizontal; }
138 int heightForWidth(int w) const override;
143 bool hasHeightForWidth() const override;
149 virtual void addMessage(uint04 id, const LogMessage&) override;
159 void setState(bool is_warning, bool is_error);
169 virtual void setPercent(fltp08 percent) override;
175 protected:
185 void setProgress(uint04 id, fltp04 percent) override;
186 protected:
188 Time m_last_update_time = Constant<Time>::Invalid;
189 QVariantAnimation* m_animation = nullptr;
194 QString m_last_text;
198 fltp04 m_last_animation_percent = Constant<fltp04>::Invalid;
199 fltp04 m_current_percent = Constant<fltp04>::Invalid;
200 fltp04 m_next_percent = Constant<fltp04>::Invalid;
208 bool m_icon_foreground = false;
209 bool m_show_log_messages = false;
210 bool m_ignore_animation = false;
212 };
213
214}
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
A class that allows for specific log information to be conveyed to a InfoPipe object including inform...
Definition LogMessage.h:48
A listener that receives and processes log messages and progress updates from an InfoPipe.
Definition LogStream.h:49
fltp04 m_thickness
Thickness of the progress arc or bar as a fraction.
void setSizeMultiplier(fltp04 size_multiplier)
Sets a multiplier for the overall widget size.
fltp04 m_last_text_radius_b
Cached outer text radius for circular mode.
virtual void setIndeterminateAnimationTimespan(const TimeSpan &span) override
Sets the time span for one full cycle of the indeterminate animation.
void setTickCount(uint04 tick_count)
Sets the number of tick marks drawn around the circular dial.
virtual void setPercent(fltp08 percent) override
Sets the progress percentage directly without animation.
int heightForWidth(int w) const override
Returns the appropriate height for a given width to maintain aspect ratio.
void resizeEvent(QResizeEvent *event) override
Handles resize events, recalculating the layout and cached geometry.
ProgressWidget(QWidget *parent=nullptr)
Constructs a ProgressWidget.
QString m_last_text
The last rendered text string.
virtual void addMessage(uint04 id, const LogMessage &) override
Receives a log message and displays it in the progress widget.
QSize minimumSizeHint() const override
Returns the minimum size hint for the widget.
fltp04 m_size_multiplier
Overall widget size multiplier.
fltp04 m_font_size_multiplier
Font size multiplier for the progress label.
void setShowLogMessage(bool show_log_message)
Sets whether to display log messages inside the progress widget.
Buffer< bool > m_dirty_blades
Tracks which dial blade segments need repainting.
QVariantAnimation * m_animation
The animation object for smooth percent transitions.
bool m_icon_foreground
Whether the icon is drawn in the foreground.
void setFontSizeMultiplier(fltp04 size_multiplier)
Sets a multiplier for the font size used in the progress label.
bool hasHeightForWidth() const override
Indicates that this widget has a preferred height-for-width relationship.
void paintEvent(QPaintEvent *event) override
Paints the progress widget, rendering either the bar or dial.
Time m_last_update_time
The timestamp of the last visual update.
void setProgressThickness(fltp04 thickness)
Sets the thickness of the progress arc or bar relative to the widget size.
QSize sizeHint() const override
Returns the preferred size for the widget.
fltp04 m_next_percent
The target percentage for animation.
void updateTimerInterval()
Recalculates the timer interval based on the current animation state.
bool m_is_updating_percent
Guard flag to prevent recursive percent updates.
void clearTextRectCache()
Clears the cached text layout rectangles, forcing recalculation on next paint.
fltp04 m_last_text_radius_a
Cached inner text radius for circular mode.
QRegion m_dirty_blade_region
The region of dirty blade segments needing repaint.
virtual bool event(QEvent *event) override
Handles general events, including style changes and timer events.
void setIconID(const String &image_id, bool foreground=true)
Sets the icon displayed within the progress widget.
virtual void setAnimatedPercent(fltp08 percent)
Sets the progress percentage with a smooth animation transition.
uint04 m_tick_count
Number of tick marks around the circular dial.
fltp04 m_last_animation_percent
The last animation frame percentage.
fltp04 m_current_percent
The current displayed progress percentage.
bool isHorizontal() const
Checks whether the widget is in horizontal bar mode.
QFont m_last_font_a
Cached font for the primary text.
bool m_ignore_animation
Whether to skip animation and set progress immediately.
bool m_is_horizontal
Whether the widget is in horizontal bar mode.
void setProgress(uint04 id, fltp04 percent) override
Sets the progress for a specific tracked operation by ID.
void clearIcon()
Removes any icon from the progress widget.
QIcon m_background_icon
The cached icon rendered in the background or foreground.
bool m_show_log_messages
Whether to display log messages in the widget.
fltp04 m_last_percent
The last rendered progress percentage.
fltp04 progressEpsilon() const
Returns the minimum change in progress needed to trigger a visual update.
void setHorizontal(bool is_horizontal)
Sets whether the progress is displayed as a horizontal bar or a circular dial.
String m_icon_id
The resource identifier for the displayed icon.
QFont m_last_font_b
Cached font for the secondary text.
void setState(bool is_warning, bool is_error)
Sets the visual state to reflect warning or error conditions.
bool m_is_analog
Whether the widget uses analog-style rendering.
fltp08 percent() const
Returns the current progress percent.
QCustomProgressBar(QWidget *parent=nullptr)
Constructs a progress bar widget.
The core String class for the NDEVR API.
Definition String.h:95
Stores a time span, or difference between two times, with an optional start time.
Definition TimeSpan.h:46
Represents a timestamp with utilities for manipulation and conversion.
Definition Time.h:62
The primary namespace for the NDEVR SDK.
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
double fltp08
Defines an alias representing an 8 byte floating-point number.