mirror of
https://github.com/cookiengineer/audacity
synced 2025-11-21 16:37:12 +01:00
Missing alias dialog tracking is non-intrusive in class AudacityProject
This commit is contained in:
@@ -1005,9 +1005,9 @@ Choose Help > Diagnostics > Check Dependencies to view a list of \
|
||||
locations of the missing files."), missingFileName);
|
||||
|
||||
// if an old dialog exists, raise it if it is
|
||||
if (offendingProject->GetMissingAliasFileDialog()) {
|
||||
offendingProject->GetMissingAliasFileDialog()->Raise();
|
||||
} else {
|
||||
if ( auto dialog = MissingAliasFilesDialog::Find( *offendingProject ) )
|
||||
dialog->Raise();
|
||||
else {
|
||||
MissingAliasFilesDialog::Show(offendingProject.get(), _("Files Missing"),
|
||||
errorMessage, wxT(""), true);
|
||||
}
|
||||
|
||||
@@ -14,11 +14,16 @@
|
||||
#include "Project.h"
|
||||
#include "widgets/ErrorDialog.h"
|
||||
|
||||
namespace {
|
||||
using wxDialogRef = wxWeakRef< wxDialog >;
|
||||
std::vector< wxDialogRef > sDialogs;
|
||||
}
|
||||
|
||||
// special case for alias missing dialog because we keep track of if it exists.
|
||||
class MissingAliasFileDialog final : public ErrorDialog
|
||||
{
|
||||
public:
|
||||
MissingAliasFileDialog(AudacityProject *parent,
|
||||
MissingAliasFileDialog(wxWindow *parent,
|
||||
const wxString & dlogTitle,
|
||||
const wxString & message,
|
||||
const wxString & helpURL,
|
||||
@@ -27,20 +32,23 @@ class MissingAliasFileDialog final : public ErrorDialog
|
||||
};
|
||||
|
||||
|
||||
MissingAliasFileDialog::MissingAliasFileDialog(AudacityProject *parent,
|
||||
MissingAliasFileDialog::MissingAliasFileDialog(wxWindow *parent,
|
||||
const wxString & dlogTitle,
|
||||
const wxString & message,
|
||||
const wxString & helpURL,
|
||||
const bool Close, const bool modal):
|
||||
ErrorDialog(parent, dlogTitle, message, helpURL, Close, modal)
|
||||
{
|
||||
parent->SetMissingAliasFileDialog(this);
|
||||
sDialogs.push_back( this );
|
||||
}
|
||||
|
||||
MissingAliasFileDialog::~MissingAliasFileDialog()
|
||||
{
|
||||
static_cast<AudacityProject *>(GetParent())
|
||||
->SetMissingAliasFileDialog( nullptr );
|
||||
auto begin = sDialogs.begin(), end = sDialogs.end(),
|
||||
newEnd = std::remove_if( begin, end,
|
||||
[&]( const wxDialogRef &ref ){
|
||||
return ref == this; } );
|
||||
sDialogs.erase( newEnd, end );
|
||||
}
|
||||
|
||||
namespace MissingAliasFilesDialog {
|
||||
@@ -82,6 +90,17 @@ namespace MissingAliasFilesDialog {
|
||||
// but in practice Destroy() in OnOK does that
|
||||
}
|
||||
|
||||
wxDialog *Find( const AudacityProject &project )
|
||||
{
|
||||
auto begin = sDialogs.begin(), end = sDialogs.end(),
|
||||
iter = std::find_if( begin, end,
|
||||
[&]( const wxDialogRef &ref ){
|
||||
return ref && ref->GetParent() == &project; } );
|
||||
if (iter != end)
|
||||
return *iter;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Mark(const AliasBlockFile *b)
|
||||
{
|
||||
Lock lock{ m_LastMissingBlockFileLock };
|
||||
|
||||
@@ -37,6 +37,8 @@ void Show(AudacityProject *parent,
|
||||
const wxString &helpPage,
|
||||
const bool Close = true);
|
||||
|
||||
wxDialog *Find( const AudacityProject &project );
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1548,16 +1548,6 @@ void AudacityProject::UpdatePrefs()
|
||||
}
|
||||
}
|
||||
|
||||
void AudacityProject::SetMissingAliasFileDialog(wxDialog *dialog)
|
||||
{
|
||||
mMissingAliasFilesWarningDialog = dialog;
|
||||
}
|
||||
|
||||
wxDialog *AudacityProject::GetMissingAliasFileDialog()
|
||||
{
|
||||
return mMissingAliasFilesWarningDialog;
|
||||
}
|
||||
|
||||
void AudacityProject::RedrawProject(const bool bForceWaveTracks /*= false*/)
|
||||
{
|
||||
FixScrollbars();
|
||||
|
||||
@@ -341,15 +341,6 @@ public:
|
||||
bool GetNormalizeOnLoad() { return mNormalizeOnLoad; } //lda
|
||||
void SetNormalizeOnLoad(bool flag) { mNormalizeOnLoad = flag; } //lda
|
||||
|
||||
/** \brief Sets the wxDialog that is being displayed
|
||||
* Used by the custom dialog warning constructor and destructor
|
||||
*/
|
||||
void SetMissingAliasFileDialog(wxDialog *dialog);
|
||||
|
||||
/** \brief returns a pointer to the wxDialog if it is displayed, NULL otherwise.
|
||||
*/
|
||||
wxDialog *GetMissingAliasFileDialog();
|
||||
|
||||
// Timer Record Auto Save/Export Routines
|
||||
bool SaveFromTimerRecording(wxFileName fnFile);
|
||||
bool ExportFromTimerRecording(wxFileName fnFile, int iFormat, int iSubFormat, int iFilterIndex);
|
||||
@@ -645,9 +636,6 @@ private:
|
||||
Destroy_ptr<FreqWindow> mFreqWindow;
|
||||
Destroy_ptr<ContrastDialog> mContrastDialog;
|
||||
|
||||
// dialog for missing alias warnings
|
||||
wxDialog *mMissingAliasFilesWarningDialog{};
|
||||
|
||||
bool mShownOnce{ false };
|
||||
|
||||
// Project owned meters
|
||||
|
||||
Reference in New Issue
Block a user