Help button for many warning messages; Restored warning icon.

The error icon was gone because we are now using the ErrorDialog, which didn't have it.  So added back explicitly.  I decided to go with wxART_WARNING rather than wxART_ERROR because nearly all of these present as warnings.
This commit is contained in:
James Crook 2020-09-14 17:43:28 +01:00
parent b9212d8393
commit caf4eadb97
14 changed files with 74 additions and 20 deletions

View File

@ -73,7 +73,7 @@ void MessageBoxException::DelayedHandlerAction()
// give the user no useful added information.
if ( wxAtomicDec( sOutstandingMessages ) == 0 )
if (helpUrl.IsEmpty())
if (ErrorHelpUrl().IsEmpty())
{
::AudacityMessageBox(
ErrorMessage(),
@ -87,7 +87,7 @@ void MessageBoxException::DelayedHandlerAction()
nullptr,
(caption.empty() ? AudacityMessageBoxCaptionStr() : caption),
ErrorMessage(),
helpUrl);
ErrorHelpUrl());
}
moved = true;

View File

@ -64,6 +64,7 @@ protected:
//! %Format the error message for this exception.
virtual TranslatableString ErrorMessage() const = 0;
virtual wxString ErrorHelpUrl() const { return helpUrl; };
private:
TranslatableString caption; //!< Stored caption

View File

@ -320,7 +320,7 @@ void DBConnection::CheckpointThread()
// Reset
mCheckpointActive = false;
if ( rc != SQLITE_OK ) {
if ( rc == SQLITE_OK ) {
// Can't checkpoint -- maybe the device has too little space
wxFileNameWrapper fName{ name };
auto path = FileException::AbbreviatePath( fName );
@ -436,7 +436,11 @@ TransactionScope::TransactionScope(
mInTrans = TransactionStart(mName);
if ( !mInTrans )
// To do, improve the message
throw SimpleMessageBoxException( XO("Database error") );
throw SimpleMessageBoxException(
XO("Database error. Sorry, but we don't have more details."),
XO("Warning"),
"Error:_Disk_full_or_not_writable"
);
}
TransactionScope::~TransactionScope()

View File

@ -42,6 +42,24 @@ XO("Audacity successfully wrote a file in %s but failed to rename it as %s.");
AbbreviatePath(fileName), renameTarget.GetFullName() );
}
wxString FileException::ErrorHelpUrl() const
{
switch (cause) {
case Cause::Open:
case Cause::Read:
return "Error:_Opening_or_reading_file";
break;
case Cause::Write:
case Cause::Rename:
return "Error:_Disk_full_or_not_writable";
default:
break;
}
return "";
}
wxString FileException::AbbreviatePath( const wxFileName &fileName )
{
wxString target;

View File

@ -51,6 +51,7 @@ public:
protected:
//! %Format an error message appropriate for the @ref Cause.
TranslatableString ErrorMessage() const override;
wxString ErrorHelpUrl() const override;
public:
Cause cause;

View File

@ -265,7 +265,9 @@ DBConnection &ProjectFileIO::GetConnection()
{
throw SimpleMessageBoxException
{
XO("Failed to open the project's database")
XO("Failed to open the project's database"),
XO("Warning"),
"Error:_Disk_full_or_not_writable"
};
}
}

View File

@ -80,7 +80,10 @@ namespace {
{
if ( !projectFileIO.AutoSave() )
throw SimpleMessageBoxException{
XO("Automatic database backup failed.") };
XO("Automatic database backup failed."),
XO("Warining"),
"Error:_Disk_full_or_not_writable"
};
}
}

View File

@ -845,7 +845,8 @@ void ShuttleGuiBase::AddIcon(wxBitmap *pBmp)
wxBitmapButton * pBtn;
mpWind = pBtn = safenew wxBitmapButton(GetParent(), miId, *pBmp,
wxDefaultPosition, wxDefaultSize, GetStyle( wxBU_AUTODRAW ) );
pBtn->SetWindowStyle( 0 );
pBtn->SetWindowStyle( wxBORDER_NONE );
pBtn->SetCanFocus(false);
UpdateSizersC();
}

View File

@ -332,7 +332,9 @@ DBConnection *SqliteSampleBlock::Conn() const
if (!pConnection) {
throw SimpleMessageBoxException
{
XO("Failed to open the project's database")
XO("Failed to open the project's database"),
XO("Warning"),
"Error:_Disk_full_or_not_writable"
};
}
return pConnection.get();

View File

@ -1754,7 +1754,9 @@ void WaveClip::Resample(int rate, ProgressDialog *progress)
if (error)
throw SimpleMessageBoxException{
XO("Resampling failed.")
XO("Resampling failed."),
XO("Warning"),
"Error:_Resampling"
};
else
{

View File

@ -1256,7 +1256,9 @@ void WaveTrack::Paste(double t0, const Track *src)
// Strong-guarantee in case of this path
// not that it matters.
throw SimpleMessageBoxException{
XO("There is not enough room available to paste the selection")
XO("There is not enough room available to paste the selection"),
XO("Warning"),
"Error:_Insufficient_space_in_track"
};
}
}
@ -1276,7 +1278,9 @@ void WaveTrack::Paste(double t0, const Track *src)
// Strong-guarantee in case of this path
// not that it matters.
throw SimpleMessageBoxException{
XO("There is not enough room available to paste the selection")
XO("There is not enough room available to paste the selection"),
XO("Warning"),
"Error:_Insufficient_space_in_track"
};
for (const auto &clip : other->mClips)
@ -2385,7 +2389,9 @@ void WaveTrack::ExpandCutLine(double cutLinePosition, double* cutlineStart,
clip->GetEndTime() + end - start > clip2->GetStartTime())
// Strong-guarantee in case of this path
throw SimpleMessageBoxException{
XO("There is not enough room available to expand the cut line")
XO("There is not enough room available to expand the cut line"),
XO("Warning"),
"Error:_Insufficient_space_in_track"
};
}
}

View File

@ -209,7 +209,11 @@ static void Extract(bool bits16,
}
if( dataSizeIn < 1 )
throw SimpleMessageBoxException{XO("Bad data size")};
throw SimpleMessageBoxException{
XO("Bad data size. Could not import audio"),
XO("Warning"),
"Error:_Importing_raw_audio"
};
size_t dataSize = (size_t)dataSizeIn;

View File

@ -462,7 +462,10 @@ void OnPaste(const CommandContext &context)
// Throw, so that any previous changes to the project in this loop
// are discarded.
throw SimpleMessageBoxException{
XO("Pasting one type of track into another is not allowed.")
XO("Pasting one type of track into another is not allowed.",
XO("Warning"),
"Error:_Copying_or_Pasting"
)
};
// We should need this check only each time we visit the leading

View File

@ -28,6 +28,7 @@
#include <wx/html/htmlwin.h>
#include <wx/settings.h>
#include <wx/statusbr.h>
#include <wx/artprov.h>
#include "../AllThemeResources.h"
#include "../ShuttleGui.h"
@ -60,14 +61,20 @@ ErrorDialog::ErrorDialog(
ShuttleGui S(this, eIsCreating);
S.StartVerticalLay();
S.StartHorizontalLay();
{
S.SetBorder( 20 );
S.AddFixedText( message );
S.SetBorder( 2 );
S.AddStandardButtons( buttonMask );
// wxART_ERROR and wxART_INFORMATION are other possibilities.
S.AddIcon( &wxArtProvider::GetBitmap( wxART_WARNING));
S.StartVerticalLay();
{
S.SetBorder(20);
S.AddFixedText(message);
S.SetBorder(2);
S.AddStandardButtons(buttonMask);
}
S.EndVerticalLay();
}
S.EndVerticalLay();
S.EndHorizontalLay();
Layout();
GetSizer()->Fit(this);