A thread that automatically pops up a modal dialog box with a progress bar and cancel button while it's busy running. More...
Inherits Thread, and Timer.
Classes | |
class | Holder |
This class manages the lifetime of the ThreadWithQuasiModalProgressWindow. More... | |
Public Member Functions | |
AlertWindow * | getAlertWindow () const noexcept |
Returns the AlertWindow that is being used. More... | |
bool | runThread (int priority=5) |
Starts the thread and waits for it to finish. More... | |
void | setProgress (double newProgress) |
The thread should call this periodically to update the position of the progress bar. More... | |
void | setStatusMessage (const String &newStatusMessage) |
The thread can call this to change the message that's displayed in the dialog box. More... | |
virtual void | threadComplete (bool userPressedCancel) |
This method is called (on the message thread) when the operation has finished. More... | |
ThreadWithQuasiModalProgressWindow (const String &windowTitle, bool hasProgressBar, bool hasCancelButton, Holder *holder, int timeOutMsWhenCancelling=10000, const String &cancelButtonText=String(), Component *componentToCentreAround=nullptr) | |
Creates the thread. More... | |
~ThreadWithQuasiModalProgressWindow () | |
Destructor. More... | |
A thread that automatically pops up a modal dialog box with a progress bar and cancel button while it's busy running.
These are handy for performing some sort of task while giving the user feedback about how long there is to go, etc.
E.g.
ThreadWithQuasiModalProgressWindow | ( | const String & | windowTitle, |
bool | hasProgressBar, | ||
bool | hasCancelButton, | ||
Holder * | holder, | ||
int | timeOutMsWhenCancelling = 10000 , |
||
const String & | cancelButtonText = String() , |
||
Component * | componentToCentreAround = nullptr |
||
) |
Creates the thread.
Initially, the dialog box won't be visible, it'll only appear when the runThread() method is called.
windowTitle | the title to go at the top of the dialog box |
hasProgressBar | whether the dialog box should have a progress bar (see setProgress() ) |
hasCancelButton | whether the dialog box should have a cancel button |
timeOutMsWhenCancelling | when 'cancel' is pressed, this is how long to wait for the thread to stop before killing it forcibly (see Thread::stopThread() ) |
cancelButtonText | the text that should be shown in the cancel button (if it has one). Leave this empty for the default "Cancel" |
componentToCentreAround | if this is non-null, the window will be positioned so that it's centred around this component. |
Destructor.
|
inlinenoexcept |
Returns the AlertWindow that is being used.
bool runThread | ( | int | priority = 5 | ) |
Starts the thread and waits for it to finish.
This will start the thread, make the dialog box appear, and wait until either the thread finishes normally, or until the cancel button is pressed.
Before returning, the dialog box will be hidden.
priority | the priority to use when starting the thread - see Thread::startThread() for values |
void setProgress | ( | double | newProgress | ) |
The thread should call this periodically to update the position of the progress bar.
newProgress | the progress, from 0.0 to 1.0 |
void setStatusMessage | ( | const String & | newStatusMessage | ) |
The thread can call this to change the message that's displayed in the dialog box.
|
virtual |
This method is called (on the message thread) when the operation has finished.
You may choose to use this callback to delete the ThreadWithProgressWindow object.