1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-20 17:41:13 +02:00

Add BasicUI::MakeGenericProgress, for when the denominator is unknown

This commit is contained in:
Paul Licameli
2021-02-19 12:26:45 -05:00
parent 0555c1139d
commit 333aa10624
4 changed files with 65 additions and 0 deletions

View File

@@ -19,6 +19,8 @@ Services::~Services() = default;
ProgressDialog::~ProgressDialog() = default;
GenericProgressDialog::~GenericProgressDialog() = default;
static Services *theInstance = nullptr;
Services *Get() { return theInstance; }

View File

@@ -162,6 +162,15 @@ public:
const TranslatableString &message = {}) = 0;
};
//! Abstraction of a progress dialog with undefined time-to-completion estimate
class BASIC_UI_API GenericProgressDialog
{
public:
virtual ~GenericProgressDialog();
//! Give some visual indication of progress. Call only on the main thread.
virtual void Pulse() = 0;
};
//! @}
//! Abstract class defines a few user interface services, not mentioning particular toolkits
@@ -186,6 +195,10 @@ public:
const TranslatableString &message,
unsigned flag,
const TranslatableString &remainingLabelText) = 0;
virtual std::unique_ptr<GenericProgressDialog>
DoMakeGenericProgress(const WindowPlacement &placement,
const TranslatableString &title,
const TranslatableString &message) = 0;
};
//! Fetch the global instance, or nullptr if none is yet installed
@@ -259,6 +272,22 @@ inline std::unique_ptr<ProgressDialog> MakeProgress(
return nullptr;
}
//! Create and display a progress dialog (return nullptr if Services not installed)
/*!
This function makes a "generic" progress dialog, for the case when time
to completion cannot be estimated, but some indication of progress is still
given
*/
inline std::unique_ptr<GenericProgressDialog> MakeGenericProgress(
const WindowPlacement &placement,
const TranslatableString &title, const TranslatableString &message)
{
if (auto p = Get())
return p->DoMakeGenericProgress(placement, title, message);
else
return nullptr;
}
//! @}
}