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

Move error dialog functions into the BasicUI facade...

... now ErrorDialog.h is included only in ErrorDialog.cpp and
wxWidgetsBasicUI.cpp
This commit is contained in:
Paul Licameli
2021-02-09 12:50:27 -05:00
parent 3a3ff8ecbe
commit 189c6c1dbc
26 changed files with 251 additions and 216 deletions

View File

@@ -8,6 +8,7 @@ Paul Licameli
**********************************************************************/
#include "BasicUI.h"
#include "Internat.h"
#include <mutex>
#include <vector>
@@ -63,4 +64,8 @@ void Yield()
while ( !sActions.empty() );
}
TranslatableString DefaultCaption()
{
return XO("Message");
}
}

View File

@@ -12,6 +12,9 @@ Paul Licameli
#define __AUDACITY_BASIC_UI__
#include <functional>
#include "Identifier.h"
class TranslatableString;
namespace BasicUI {
@@ -34,6 +37,43 @@ public:
virtual ~WindowPlacement();
};
enum class ErrorDialogType {
ModelessError,
ModalError,
ModalErrorReport, /*!< If error reporting is enabled, may give option to
send; if not, then like ModalError
*/
};
//! Options for variations of error dialogs; the default is for modal dialogs
struct ErrorDialogOptions {
ErrorDialogOptions() = default;
//! Non-explicit
ErrorDialogOptions( ErrorDialogType type ) : type{ type } {}
//! @name Chain-call style initializers
//! @{
ErrorDialogOptions &&ModalHelp( bool modalHelp_ ) &&
{ modalHelp = modalHelp_; return std::move(*this); }
ErrorDialogOptions &&Log( std::wstring log_ ) &&
{ log = std::move(log_); return std::move(*this); }
//! @}
//! Type of help dialog
ErrorDialogType type{ ErrorDialogType::ModalError };
//! Whether the secondary help dialog with more information should be modal
bool modalHelp{ true };
//! Optional extra logging information to be shown
std::wstring log;
};
//! "Message", suitably translated
BASIC_UI_API TranslatableString DefaultCaption();
//! @}
//! Abstract class defines a few user interface services, not mentioning particular toolkits
@@ -45,6 +85,11 @@ public:
virtual ~Services();
virtual void DoCallAfter(const Action &action) = 0;
virtual void DoYield() = 0;
virtual void DoShowErrorDialog(const WindowPlacement &placement,
const TranslatableString &dlogTitle,
const TranslatableString &message,
const ManualPageID &helpPage,
const ErrorDialogOptions &options) = 0;
};
//! Fetch the global instance, or nullptr if none is yet installed
@@ -75,6 +120,18 @@ void CallAfter(Action action);
*/
void Yield();
//! Show an error dialog with a link to the manual for further help
inline void ShowErrorDialog(
const WindowPlacement &placement, //!< how to parent the dialog
const TranslatableString &dlogTitle, //!< Text for title bar
const TranslatableString &message, //!< The main message text
const ManualPageID &helpPage, //!< Identifies manual page (and maybe an anchor)
const ErrorDialogOptions &options = {})
{
if (auto p = Get())
p->DoShowErrorDialog(placement, dlogTitle, message, helpPage, options);
}
//! @}
}

View File

@@ -17,7 +17,11 @@ set( SOURCES
BasicUI.cpp
BasicUI.h
)
audacity_library( lib-basic-ui "${SOURCES}"
""
set( LIBRARIES
lib-strings-interface
PRIVATE
wxBase
)
audacity_library( lib-basic-ui "${SOURCES}" "${LIBRARIES}"
"" ""
)