Audacity 3.2.0
UserException.cpp
Go to the documentation of this file.
1
9#include "UserException.h"
10#include "BasicUI.h"
11
13{
14}
15
17{
18}
19
21 std::function<void(const ProgressReporter&)> action,
23{
24 using namespace BasicUI;
25 auto progress =
26 MakeProgress(std::move(title), std::move(message), ProgressShowCancel);
27 const auto reportProgress = [&](double progressFraction) {
28 const auto result = progress->Poll(progressFraction * 1000, 1000);
29 if (result != ProgressResult::Success)
30 throw UserException {};
31 };
32 action(reportProgress);
33}
Toolkit-neutral facade for basic user interface services.
static const auto title
An AudacityException with no visible message.
Holds a msgid for the translation catalog; may also bind format arguments.
Can be thrown when user cancels operations, as with a progress dialog. Delayed handler does nothing.
Definition: UserException.h:17
~UserException() override
std::function< void(double)> ProgressReporter
Definition: UserException.h:25
static void WithCancellableProgress(std::function< void(const ProgressReporter &)> action, TranslatableString title, TranslatableString message)
A frequently useful convenience wraps a lambda and may throw this type.
void DelayedHandlerAction() override
Action to do in the main thread at idle time of the event loop.
@ ProgressShowCancel
Definition: BasicUI.h:142
std::unique_ptr< ProgressDialog > MakeProgress(const TranslatableString &title, const TranslatableString &message, unsigned flags=(ProgressShowStop|ProgressShowCancel), const TranslatableString &remainingLabelText={})
Create and display a progress dialog.
Definition: BasicUI.h:294