FreeCAD's progress bar for long operations To see how to use the progress bar have a look at the following examples: More...
#include <ProgressBar.h>
Public Member Functions | |
virtual void | checkAbort () override |
Check if the operation is aborted by user. More... | |
QProgressBar * | getProgressBar (QWidget *parent=nullptr) |
Returns an instance of the progress bar. More... | |
bool | isBlocking () const override |
Returns true if the running sequencer is blocking any user input. More... | |
void | pause () override |
This restores the last overridden cursor and release the keyboard while the progress bar is running. More... | |
void | resume () override |
This sets the wait cursor again and grabs the keyboard. More... | |
Public Member Functions inherited from Base::SequencerBase | |
virtual void | checkAbort () |
Check if the operation is aborted by user. More... | |
virtual bool | isBlocking () const |
Returns true if the running sequencer is blocking any user input. More... | |
bool | isLocked () const |
Returns true if the sequencer was locked, false otherwise. More... | |
bool | isRunning () const |
Returns true if the sequencer is running, otherwise returns false. More... | |
bool | setLocked (bool bLock) |
If bLock is true then the sequencer gets locked. More... | |
bool | wasCanceled () const |
Returns true if the pending operation was canceled. More... | |
Static Public Member Functions | |
static SequencerBar * | instance () |
Returns the sequencer object. More... | |
Static Public Member Functions inherited from Base::SequencerBase | |
static SequencerBase & | Instance () |
Returns the last created sequencer instance. More... | |
Protected Member Functions | |
void | nextStep (bool canAbort) override |
Increase the progress bar. More... | |
void | resetData () override |
Resets the sequencer. More... | |
SequencerBar () | |
Construction. More... | |
void | setProgress (size_t) override |
Sets the progress indicator to a certain position. More... | |
void | setText (const char *pszTxt) override |
Puts text to the status bar. More... | |
void | showRemainingTime () |
void | startStep () override |
Starts the progress bar. More... | |
~SequencerBar () | |
Destruction. More... | |
Protected Member Functions inherited from Base::SequencerBase | |
bool | next (bool canAbort=false) |
Performs the next step and returns true if the operation is not yet finished. More... | |
virtual void | nextStep (bool canAbort) |
This method can be reimplemented in sub-classes to give the user a feedback when the next is performed. More... | |
size_t | numberOfSteps () const |
Returns the number of steps. More... | |
SequencerBase & | operator= (const SequencerBase &)=default |
virtual void | pause () |
Breaks the sequencer if needed. More... | |
int | progressInPercent () const |
Returns the current state of progress in percent. More... | |
void | rejectCancel () |
If you tried to cancel but then decided to continue the operation. More... | |
virtual void | resetData () |
Resets internal data. More... | |
virtual void | resume () |
Continues with progress. More... | |
SequencerBase () | |
construction More... | |
SequencerBase (const SequencerBase &)=default | |
virtual void | setProgress (size_t) |
Sets the progress indicator to a certain position. More... | |
virtual void | setText (const char *pszTxt) |
Sets a text what the pending operation is doing. More... | |
bool | start (const char *pszStr, size_t steps) |
Starts a new operation, returns false if there is already a pending operation, otherwise it returns true. More... | |
virtual void | startStep () |
This method can be reimplemented in sub-classes to give the user a feedback when a new sequence starts. More... | |
bool | stop () |
Stops the sequencer if all operations are finished. More... | |
void | tryToCancel () |
Try to cancel the pending operation(s). More... | |
virtual | ~SequencerBase () |
Destruction. More... | |
for internal use only | |
class | ProgressBar |
Additional Inherited Members | |
Protected Attributes inherited from Base::SequencerBase | |
size_t | nProgress |
Stores the current amount of progress. More... | |
size_t | nTotalSteps |
Stores the total number of steps. More... | |
FreeCAD's progress bar for long operations To see how to use the progress bar have a look at the following examples:
The example below shows how to use two nested progresses.
If the total number of steps cannot be determined before, use 0 instead of to show just a busy indicator instead of percentage steps.
|
protected |
Construction.
References Gui::SequencerBarPrivate::bar, Gui::SequencerBarPrivate::guiThread, and Gui::SequencerBarPrivate::waitCursor.
Referenced by instance().
|
protected |
Destruction.
|
overridevirtual |
Check if the operation is aborted by user.
Reimplemented from Base::SequencerBase.
References Gui::SequencerBarPrivate::bar, Gui::ProgressBar::canAbort(), Gui::SequencerBarPrivate::checkAbortTime, pause(), Base::SequencerBase::rejectCancel(), resume(), and Base::SequencerBase::wasCanceled().
QProgressBar * SequencerBar::getProgressBar | ( | QWidget * | parent = nullptr | ) |
Returns an instance of the progress bar.
It creates one if needed.
References Gui::SequencerBarPrivate::bar, and ProgressBar.
Referenced by Gui::MainWindow::MainWindow(), WebGui::BrowserView::onLoadProgress(), and WebGui::BrowserView::onLoadStarted().
|
static |
Returns the sequencer object.
References SequencerBar().
Referenced by Gui::MainWindow::MainWindow(), WebGui::BrowserView::onLoadProgress(), and WebGui::BrowserView::onLoadStarted().
|
overridevirtual |
Returns true if the running sequencer is blocking any user input.
This might be only of interest of the GUI where the progress bar or dialog is used from a thread. If started from a thread this method should return false, otherwise true. The default implementation always returns true.
Reimplemented from Base::SequencerBase.
References Gui::SequencerBarPrivate::guiThread.
|
overrideprotectedvirtual |
Increase the progress bar.
Reimplemented from Base::SequencerBase.
References Gui::SequencerBarPrivate::bar, Gui::ProgressBar::canAbort(), Base::SequencerBase::nProgress, pause(), Base::SequencerBase::rejectCancel(), resume(), and Base::SequencerBase::wasCanceled().
|
overridevirtual |
This restores the last overridden cursor and release the keyboard while the progress bar is running.
This is useful e.g. if a modal dialog appears while a long operation is performed to indicate that the user can click on the dialog. Every pause() must eventually be followed by a corresponding resume().
Reimplemented from Base::SequencerBase.
References Gui::SequencerBarPrivate::bar, Gui::SequencerBarPrivate::guiThread, Gui::WaitCursor::restoreCursor(), and Gui::SequencerBarPrivate::waitCursor.
Referenced by checkAbort(), and nextStep().
|
overrideprotectedvirtual |
Resets the sequencer.
Reimplemented from Base::SequencerBase.
References Gui::ProgressBar::aboutToHide(), Gui::SequencerBarPrivate::bar, Gui::getMainWindow(), Gui::SequencerBarPrivate::guiThread, Gui::MainWindow::setPaneText(), Gui::MainWindow::showMessage(), and Gui::SequencerBarPrivate::waitCursor.
Referenced by Gui::ProgressBar::eventFilter().
|
overridevirtual |
This sets the wait cursor again and grabs the keyboard.
Reimplemented from Base::SequencerBase.
References Gui::SequencerBarPrivate::bar, Gui::SequencerBarPrivate::guiThread, Gui::WaitCursor::setWaitCursor(), and Gui::SequencerBarPrivate::waitCursor.
Referenced by checkAbort(), and nextStep().
|
overrideprotectedvirtual |
Sets the progress indicator to a certain position.
Reimplemented from Base::SequencerBase.
References Gui::SequencerBarPrivate::bar.
|
overrideprotectedvirtual |
Puts text to the status bar.
Reimplemented from Base::SequencerBase.
References Gui::SequencerBarPrivate::bar, Gui::getMainWindow(), Gui::MainWindow::showMessage(), and Gui::SequencerBarPrivate::text.
|
protected |
|
overrideprotectedvirtual |
Starts the progress bar.
Reimplemented from Base::SequencerBase.
References Gui::ProgressBar::aboutToShow(), Gui::SequencerBarPrivate::bar, Gui::SequencerBarPrivate::checkAbortTime, Gui::SequencerBarPrivate::guiThread, Gui::SequencerBarPrivate::measureTime, Base::SequencerBase::nTotalSteps, Gui::SequencerBarPrivate::progressTime, and Gui::SequencerBarPrivate::waitCursor.
|
friend |
Referenced by getProgressBar().