Classes | |
class | ProgressDialog |
Dialog displaying a progress bar and cancel button. More... | |
class | ProgressTask |
Wrapper around QThread and ProgressDialog that runs a task in the background, providing updates to the progress bar on the main thread. More... | |
class ProgressDialog |
Dialog displaying a progress bar and cancel button.
Public Slots | |
void | update (int cur, int total) |
void | cancel () |
Signals | |
void | canceled () |
Public Member Functions | |
ProgressDialog (QWidget *parent, const QString &title, const QString &text, const QString &cancel=QString()) | |
bool | wasCancelled () const |
void | hideForModal (std::function< void()> modal) |
QString | text () const |
void | setText (const QString &text) |
Protected Member Functions | |
virtual void | keyPressEvent (QKeyEvent *event) override |
ProgressDialog::ProgressDialog | ( | QWidget * | parent, |
const QString & | title, | ||
const QString & | text, | ||
const QString & | cancel = QString() ) |
bool ProgressDialog::wasCancelled | ( | ) | const |
void ProgressDialog::hideForModal | ( | std::function< void()> | modal | ) |
QString ProgressDialog::text | ( | ) | const |
void ProgressDialog::setText | ( | const QString & | text | ) |
|
overrideprotectedvirtual |
|
slot |
|
slot |
|
signal |
class ProgressTask |
Wrapper around QThread and ProgressDialog that runs a task in the background, providing updates to the progress bar on the main thread.
Started automatically. Call wait() to wait for completion, or cancel() to cancel.
Example:
Public Slots | |
void | cancel () |
Cancel the progress dialog. | |
Signals | |
void | progress (int cur, int max) |
Signal reported every time there is a progress update (probably often) | |
void | finished () |
Signal reported when the task has finished. | |
Public Member Functions | |
ProgressTask (QWidget *parent, const QString &name, const QString &text, const QString &cancel, std::function< void(std::function< bool(size_t, size_t)>)> func) | |
Construct a new progress task, which automatically starts running a given function. | |
virtual | ~ProgressTask () |
bool | wait () |
Wait for the task to finish. | |
void | hideForModal (std::function< void()> modal) |
Hide the task to present a modal (in a function) since the progress dialog will block other parts of the ui from responding while it is present. | |
QString | text () const |
Get the text label of the progress dialog. | |
void | setText (const QString &text) |
Set the text label on the progress dialog. | |
ProgressTask::ProgressTask | ( | QWidget * | parent, |
const QString & | name, | ||
const QString & | text, | ||
const QString & | cancel, | ||
std::function< void(std::function< bool(size_t, size_t)>)> | func ) |
Construct a new progress task, which automatically starts running a given function.
parent | Parent QWidget to display progress dialog on top of |
name | Title for progress dialog |
text | Text for progress dialog |
cancel | Cancel button title. If empty, the cancel button will not be shown |
func | Function to run in the background, which takes a progress reporting function for its argument. The function should call the progress function periodically to signal updates and check for cancellation. |
|
virtual |
bool ProgressTask::wait | ( | ) |
Wait for the task to finish.
exception | Any exception that the provided func throws |
void ProgressTask::hideForModal | ( | std::function< void()> | modal | ) |
Hide the task to present a modal (in a function) since the progress dialog will block other parts of the ui from responding while it is present.
modal | Function to present a modal ui on top |
QString ProgressTask::text | ( | ) | const |
Get the text label of the progress dialog.
void ProgressTask::setText | ( | const QString & | text | ) |
Set the text label on the progress dialog.
text | New text label contents |
|
slot |
Cancel the progress dialog.
|
signal |
Signal reported every time there is a progress update (probably often)
cur | Current progress value |
max | Maximum progress value |
|
signal |
Signal reported when the task has finished.