API Documentation
Loading...
Searching...
No Matches
QCustomProgressbar.h
Go to the documentation of this file.
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: QCustomProgressbar
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/BaseValues.h>
35#include <NDEVR/TimeSpan.h>
36#include <NDEVR/RGBColor.h>
37#include <NDEVR/Buffer.h>
38#include <QProgressBar>
39namespace NDEVR
40{
41 class TranslatedString;
42 class String;
43 /**--------------------------------------------------------------------------------------------------
44 \brief Allows for showing of progress bar in horizontal format. Defaults to look and feel of system progress
45 bar.
46
47 A progress bar is used to give the user an indication of the progress of an operation and to reassure
48 them that the application is still running.
49
50 The progress bar uses the concept of percent from 0.0 to 1.0. It will display the percentage
51 specified or can be set to an indeterminate or "spinning" state to indicate progress is
52 occuring, but at an unknown rate.
53 *-----------------------------------------------------------------------------------------------**/
54 class NDEVR_WIDGETS_API QCustomProgressBar : public QProgressBar
55 {
56 Q_OBJECT
57 public:
58 explicit QCustomProgressBar(QWidget* parent = nullptr);
59 virtual ~QCustomProgressBar() override;
60
61 /**--------------------------------------------------------------------------------------------------
62 Parameters:
63 color - The color to use as the progress bar
64 *-----------------------------------------------------------------------------------------------**/
66
67 /**--------------------------------------------------------------------------------------------------
68 called multiple times to form a gradiant.
69 Parameters:
70 percent - The percent where this color will be most prominant.
71 color - The color use at the given percent
72 *-----------------------------------------------------------------------------------------------**/
73 void addProgressColor(fltp08 percent, RGBColor color);
74
75 /**--------------------------------------------------------------------------------------------------
76 Parameters:
77 colors - The colors to use. Will be evenly spaced out across progress.
78 *-----------------------------------------------------------------------------------------------**/
81
82 /**--------------------------------------------------------------------------------------------------
83 percent - The percent that the progress bar is between 0.0 and 1.0. Invalid will set the value to
84 indeterminate or "spinning" state
85 *-----------------------------------------------------------------------------------------------**/
86 virtual void setPercent(fltp08 percent);
87 [[nodiscard]] fltp08 percent() const;
88
89 /**--------------------------------------------------------------------------------------------------
90 *-----------------------------------------------------------------------------------------------**/
91 [[nodiscard]] bool isIndeterminateState() const;
92
93 /**--------------------------------------------------------------------------------------------------
94
95 Parameters:
96 draw_background - Whether or not to draw the background
97 *-----------------------------------------------------------------------------------------------**/
98 void setDrawBackground(bool draw_background);
99
100 /**--------------------------------------------------------------------------------------------------
101 if progress is indeterminate. Translated version of setFormat.
102
103 Parameters:
104 message - The message to display inside the progress widget
105 *-----------------------------------------------------------------------------------------------**/
106 virtual void setMessage(const TranslatedString& message);
107
108 /**--------------------------------------------------------------------------------------------------
109 if progress is indeterminate. Untranslated version of setMessage.
110
111 Parameters:
112 message - The message to display inside the progress widget
113 *-----------------------------------------------------------------------------------------------**/
114 void setFormat(const String& format);
115
116 /**--------------------------------------------------------------------------------------------------
117 an animation to indicate something is happening, but that a percent could not be determined.
118 Can also be triggered by setPercent using Invalid to make indeterminate or a real number to make progress.
119 Parameters:
120 is_indeterminate - whether to make the progress bar indeterminate
121 *-----------------------------------------------------------------------------------------------**/
122 virtual void setToIndeterminateState(bool is_indeterminate);
123
124 /**--------------------------------------------------------------------------------------------------
125
126 Parameters:
127 span - The span of time between a complete rotation or color animation when the widget is
128 set to indeterminate progress
129 *-----------------------------------------------------------------------------------------------**/
131 protected:
132 [[nodiscard]] QSize sizeHint() const override;
133 [[nodiscard]] QSize minimumSizeHint() const override;
134 [[nodiscard]] fltp08 indeterminatePercent() const;
135 [[nodiscard]] QString customText() const;
136 void paintEvent(QPaintEvent* event) override;
137 protected slots:
139 protected:
141 protected:
143 TimeSpan m_indeterminate_period = TimeSpan(1.0);//how much time to do full cycle indeterminate animation
145 QString m_last_text;
147 };
148}
#define NDEVR_WIDGETS_API
Definition DLLInfo.h:81
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:59
Allows for showing of progress bar in horizontal format. Defaults to look and feel of system progress...
Definition QCustomProgressbar.h:55
QSize minimumSizeHint() const override
QString customText() const
virtual void setToIndeterminateState(bool is_indeterminate)
fltp08 indeterminatePercent() const
Buffer< std::pair< fltp08, RGBColor > > m_progress_colors
Definition QCustomProgressbar.h:144
QSize sizeHint() const override
void setFormat(const String &format)
QString m_last_text
Definition QCustomProgressbar.h:145
void setDrawBackground(bool draw_background)
QCustomProgressBar(QWidget *parent=nullptr)
virtual void setPercent(fltp08 percent)
bool isIndeterminateState() const
virtual ~QCustomProgressBar() override
void setProgressColor(RGBColor color)
virtual void setIndeterminateAnimationTimespan(const TimeSpan &span)
void setProgressColors(const Buffer< RGBColor > &colors)
virtual void setMessage(const TranslatedString &message)
void paintEvent(QPaintEvent *event) override
void addProgressColor(fltp08 percent, RGBColor color)
bool m_draw_background
Definition QCustomProgressbar.h:146
QTimer * m_update_timer
Definition QCustomProgressbar.h:142
Represents a color in the RGB space with optional alpha transparency.
Definition RGBColor.h:53
The core String class for the software.
Definition String.h:47
Stores a time span, or difference between two times, with an optional start time.
Definition TimeSpan.h:46
Any text displayed to the user should be defined as a TranslatedString which allows the.
Definition TranslatedString.h:13
Definition ACIColor.h:37
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:146