2010-01-23 19:44:49 +00:00
|
|
|
/**********************************************************************
|
|
|
|
|
|
|
|
Audacity: A Digital Audio Editor
|
|
|
|
|
|
|
|
ErrorDialog.cpp
|
|
|
|
|
|
|
|
Jimmy Johnson
|
|
|
|
Leland Lucius
|
|
|
|
|
|
|
|
*******************************************************************//**
|
|
|
|
|
|
|
|
\class ErrorDialog
|
2017-11-09 18:32:29 +00:00
|
|
|
\brief Gives an Error message with an option for help.
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
*//********************************************************************/
|
|
|
|
|
2021-05-09 15:16:56 +00:00
|
|
|
|
2018-11-10 19:47:12 +00:00
|
|
|
#include "ErrorDialog.h"
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2019-04-25 20:34:07 +00:00
|
|
|
#include <wx/app.h>
|
2010-01-23 19:44:49 +00:00
|
|
|
#include <wx/button.h>
|
2021-04-01 06:13:15 +00:00
|
|
|
#include <wx/collpane.h>
|
2010-01-23 19:44:49 +00:00
|
|
|
#include <wx/icon.h>
|
|
|
|
#include <wx/dialog.h>
|
|
|
|
#include <wx/intl.h>
|
|
|
|
#include <wx/sizer.h>
|
2020-09-14 19:05:42 +00:00
|
|
|
#include <wx/statbmp.h>
|
2010-01-23 19:44:49 +00:00
|
|
|
#include <wx/stattext.h>
|
|
|
|
#include <wx/utils.h>
|
|
|
|
#include <wx/html/htmlwin.h>
|
|
|
|
#include <wx/settings.h>
|
2010-02-14 06:37:45 +00:00
|
|
|
#include <wx/statusbr.h>
|
2020-09-14 16:43:28 +00:00
|
|
|
#include <wx/artprov.h>
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
#include "../AllThemeResources.h"
|
|
|
|
#include "../ShuttleGui.h"
|
|
|
|
#include "../HelpText.h"
|
|
|
|
#include "../Prefs.h"
|
2014-06-06 21:34:36 +00:00
|
|
|
#include "HelpSystem.h"
|
2011-03-23 01:01:17 +00:00
|
|
|
|
2021-06-07 16:15:17 +00:00
|
|
|
#ifdef HAS_SENTRY_REPORTING
|
|
|
|
# include "ErrorReportDialog.h"
|
|
|
|
#endif
|
|
|
|
|
2016-07-10 21:10:50 +00:00
|
|
|
BEGIN_EVENT_TABLE(ErrorDialog, wxDialogWrapper)
|
2021-04-01 06:13:15 +00:00
|
|
|
EVT_COLLAPSIBLEPANE_CHANGED( wxID_ANY, ErrorDialog::OnPane )
|
2010-01-23 19:44:49 +00:00
|
|
|
EVT_BUTTON( wxID_OK, ErrorDialog::OnOk)
|
|
|
|
EVT_BUTTON( wxID_HELP, ErrorDialog::OnHelp)
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
ErrorDialog::ErrorDialog(
|
2014-06-03 20:30:19 +00:00
|
|
|
wxWindow *parent,
|
2019-12-08 05:25:47 +00:00
|
|
|
const TranslatableString & dlogTitle,
|
2019-12-05 18:38:07 +00:00
|
|
|
const TranslatableString & message,
|
2017-08-25 12:54:37 +00:00
|
|
|
const wxString & helpPage,
|
2021-04-01 06:13:15 +00:00
|
|
|
const wxString & log,
|
|
|
|
const bool Close, const bool modal)
|
|
|
|
: wxDialogWrapper(parent, wxID_ANY, dlogTitle,
|
|
|
|
wxDefaultPosition, wxDefaultSize,
|
|
|
|
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2019-12-08 05:25:47 +00:00
|
|
|
SetName();
|
2015-05-18 12:57:05 +00:00
|
|
|
|
2011-03-06 18:07:12 +00:00
|
|
|
long buttonMask;
|
|
|
|
|
|
|
|
// only add the help button if we have a URL
|
2019-03-14 17:04:37 +00:00
|
|
|
buttonMask = (helpPage.empty()) ? eOkButton : (eHelpButton | eOkButton);
|
2017-08-25 12:54:37 +00:00
|
|
|
dhelpPage = helpPage;
|
2010-12-11 22:32:07 +00:00
|
|
|
dClose = Close;
|
2011-03-01 01:29:03 +00:00
|
|
|
dModal = modal;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
ShuttleGui S(this, eIsCreating);
|
|
|
|
|
2021-04-01 06:13:15 +00:00
|
|
|
S.SetBorder(2);
|
|
|
|
S.StartHorizontalLay(wxEXPAND, 0);
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2021-04-01 06:13:15 +00:00
|
|
|
S.SetBorder(20);
|
2020-09-14 18:43:58 +00:00
|
|
|
wxBitmap bitmap = wxArtProvider::GetBitmap(wxART_WARNING);
|
2021-04-01 06:13:15 +00:00
|
|
|
S.AddWindow(safenew wxStaticBitmap(S.GetParent(), -1, bitmap));
|
|
|
|
|
|
|
|
S.SetBorder(20);
|
|
|
|
S.AddFixedText(message, false, 500);
|
|
|
|
}
|
|
|
|
S.EndHorizontalLay();
|
|
|
|
|
|
|
|
S.SetBorder(2);
|
|
|
|
if (!log.empty())
|
|
|
|
{
|
|
|
|
S.StartHorizontalLay(wxEXPAND, 1);
|
2020-09-14 16:43:28 +00:00
|
|
|
{
|
2021-04-01 06:13:15 +00:00
|
|
|
S.SetBorder(5);
|
|
|
|
|
|
|
|
auto pane = safenew wxCollapsiblePane(S.GetParent(),
|
|
|
|
wxID_ANY,
|
|
|
|
XO("Show &Log...").Translation());
|
|
|
|
S.Style(wxEXPAND | wxALIGN_LEFT);
|
|
|
|
S.Prop(1);
|
|
|
|
S.AddWindow(pane);
|
|
|
|
|
|
|
|
ShuttleGui SI(pane->GetPane(), eIsCreating);
|
|
|
|
auto text = SI.AddTextWindow(log);
|
|
|
|
text->SetInsertionPointEnd();
|
|
|
|
text->ShowPosition(text->GetLastPosition());
|
|
|
|
text->SetMinSize(wxSize(700, 250));
|
2020-09-14 16:43:28 +00:00
|
|
|
}
|
2021-04-01 06:13:15 +00:00
|
|
|
S.EndHorizontalLay();
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
2021-04-01 06:13:15 +00:00
|
|
|
|
|
|
|
S.SetBorder(2);
|
|
|
|
S.AddStandardButtons(buttonMask);
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
Layout();
|
2015-07-31 11:09:02 +00:00
|
|
|
GetSizer()->Fit(this);
|
2010-01-23 19:44:49 +00:00
|
|
|
SetMinSize(GetSize());
|
|
|
|
Center();
|
|
|
|
}
|
|
|
|
|
2021-04-01 06:13:15 +00:00
|
|
|
void ErrorDialog::OnPane(wxCollapsiblePaneEvent & event)
|
|
|
|
{
|
|
|
|
if (!event.GetCollapsed())
|
|
|
|
{
|
|
|
|
Center();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-25 21:51:26 +00:00
|
|
|
void ErrorDialog::OnOk(wxCommandEvent & WXUNUSED(event))
|
2011-03-01 01:29:03 +00:00
|
|
|
{
|
|
|
|
if (dModal)
|
|
|
|
EndModal(true);
|
|
|
|
else
|
|
|
|
Destroy();
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2013-08-25 21:51:26 +00:00
|
|
|
void ErrorDialog::OnHelp(wxCommandEvent & WXUNUSED(event))
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2017-08-25 12:54:37 +00:00
|
|
|
if( dhelpPage.StartsWith(wxT("innerlink:")) )
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2014-06-09 18:42:19 +00:00
|
|
|
HelpSystem::ShowHtmlText(
|
2014-06-03 20:30:19 +00:00
|
|
|
this,
|
2017-08-25 12:54:37 +00:00
|
|
|
TitleText(dhelpPage.Mid( 10 ) ),
|
|
|
|
HelpText( dhelpPage.Mid( 10 )),
|
2010-01-23 19:44:49 +00:00
|
|
|
false,
|
|
|
|
true );
|
|
|
|
return;
|
|
|
|
}
|
2017-08-25 12:54:37 +00:00
|
|
|
HelpSystem::ShowHelp( this, dhelpPage, dClose );
|
|
|
|
//OpenInDefaultBrowser( dhelpURL );
|
2010-12-11 22:32:07 +00:00
|
|
|
if(dClose)
|
2013-02-23 04:33:20 +00:00
|
|
|
EndModal(true);
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ShowErrorDialog(wxWindow *parent,
|
2019-12-08 05:25:47 +00:00
|
|
|
const TranslatableString &dlogTitle,
|
2019-12-05 18:38:07 +00:00
|
|
|
const TranslatableString &message,
|
2017-08-25 12:54:37 +00:00
|
|
|
const wxString &helpPage,
|
2021-04-01 06:13:15 +00:00
|
|
|
const bool Close,
|
|
|
|
const wxString &log)
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2021-04-01 06:13:15 +00:00
|
|
|
ErrorDialog dlog(parent, dlogTitle, message, helpPage, log, Close);
|
2010-01-23 19:44:49 +00:00
|
|
|
dlog.CentreOnParent();
|
|
|
|
dlog.ShowModal();
|
|
|
|
}
|
|
|
|
|
2017-08-25 12:54:37 +00:00
|
|
|
|
2021-06-07 16:15:17 +00:00
|
|
|
void ShowExceptionDialog(
|
|
|
|
wxWindow* parent, const TranslatableString& dlogTitle,
|
|
|
|
const TranslatableString& message, const wxString& helpPage, bool Close,
|
|
|
|
const wxString& log)
|
|
|
|
{
|
|
|
|
#ifndef HAS_SENTRY_REPORTING
|
|
|
|
ShowErrorDialog(parent, dlogTitle, message, helpPage, Close, log);
|
|
|
|
#else
|
|
|
|
ShowErrorReportDialog(parent, dlogTitle, message, helpPage, log);
|
|
|
|
#endif // !HAS_SENTRY_REPORTING
|
|
|
|
}
|
|
|
|
|
2017-08-25 12:54:37 +00:00
|
|
|
// unused.
|
2011-03-01 01:29:03 +00:00
|
|
|
void ShowModelessErrorDialog(wxWindow *parent,
|
2019-12-08 05:25:47 +00:00
|
|
|
const TranslatableString &dlogTitle,
|
2019-12-05 18:38:07 +00:00
|
|
|
const TranslatableString &message,
|
2017-08-25 12:54:37 +00:00
|
|
|
const wxString &helpPage,
|
2021-04-01 06:13:15 +00:00
|
|
|
const bool Close,
|
|
|
|
const wxString &log)
|
2011-03-01 01:29:03 +00:00
|
|
|
{
|
2017-08-25 12:54:37 +00:00
|
|
|
// ensure it has some parent.
|
|
|
|
if( !parent )
|
|
|
|
parent = wxTheApp->GetTopWindow();
|
2016-08-14 03:16:05 +00:00
|
|
|
wxASSERT(parent);
|
2021-04-01 06:13:15 +00:00
|
|
|
ErrorDialog *dlog = safenew ErrorDialog(parent, dlogTitle, message, helpPage, log, Close, false);
|
2011-03-01 01:29:03 +00:00
|
|
|
dlog->CentreOnParent();
|
|
|
|
dlog->Show();
|
2017-08-25 12:54:37 +00:00
|
|
|
// ANSWER-ME: Vigilant Sentry flagged this method as not deleting dlog, so
|
|
|
|
// is this actually a mem leak.
|
2016-08-08 13:54:53 +00:00
|
|
|
// PRL: answer is that the parent window guarantees destruction of the dialog
|
|
|
|
// but in practice Destroy() in OnOK does that
|
2011-03-01 01:29:03 +00:00
|
|
|
}
|
|
|
|
|
2018-03-21 14:16:05 +00:00
|
|
|
void AudacityTextEntryDialog::SetInsertionPointEnd()
|
|
|
|
{
|
2019-04-12 08:39:14 +00:00
|
|
|
mSetInsertionPointEnd = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AudacityTextEntryDialog::Show(bool show)
|
|
|
|
{
|
|
|
|
bool ret = wxTabTraversalWrapper< wxTextEntryDialog >::Show(show);
|
|
|
|
|
|
|
|
if (show && mSetInsertionPointEnd) {
|
|
|
|
// m_textctrl is protected member of wxTextEntryDialog
|
|
|
|
m_textctrl->SetInsertionPointEnd();
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2018-03-21 14:16:05 +00:00
|
|
|
}
|