diff --git a/src/AudacityException.cpp b/src/AudacityException.cpp index b7849b343..c35b53928 100644 --- a/src/AudacityException.cpp +++ b/src/AudacityException.cpp @@ -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; diff --git a/src/AudacityException.h b/src/AudacityException.h index 0ed1227bb..8f522e41d 100644 --- a/src/AudacityException.h +++ b/src/AudacityException.h @@ -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 diff --git a/src/DBConnection.cpp b/src/DBConnection.cpp index 908abf622..0cbc3c980 100644 --- a/src/DBConnection.cpp +++ b/src/DBConnection.cpp @@ -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() diff --git a/src/FileException.cpp b/src/FileException.cpp index ee3bc817e..948617f20 100644 --- a/src/FileException.cpp +++ b/src/FileException.cpp @@ -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; diff --git a/src/FileException.h b/src/FileException.h index 55910a4fd..388763724 100644 --- a/src/FileException.h +++ b/src/FileException.h @@ -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; diff --git a/src/ProjectFileIO.cpp b/src/ProjectFileIO.cpp index a1b367c51..bc09bbedc 100644 --- a/src/ProjectFileIO.cpp +++ b/src/ProjectFileIO.cpp @@ -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" }; } } diff --git a/src/ProjectHistory.cpp b/src/ProjectHistory.cpp index 683eb156e..974480dc8 100644 --- a/src/ProjectHistory.cpp +++ b/src/ProjectHistory.cpp @@ -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" + }; } } diff --git a/src/ShuttleGui.cpp b/src/ShuttleGui.cpp index f680bdcd2..aac00aad3 100644 --- a/src/ShuttleGui.cpp +++ b/src/ShuttleGui.cpp @@ -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(); } diff --git a/src/SqliteSampleBlock.cpp b/src/SqliteSampleBlock.cpp index 6dd5adf76..eb5611b07 100644 --- a/src/SqliteSampleBlock.cpp +++ b/src/SqliteSampleBlock.cpp @@ -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(); diff --git a/src/WaveClip.cpp b/src/WaveClip.cpp index 842fe0149..441c9e06c 100644 --- a/src/WaveClip.cpp +++ b/src/WaveClip.cpp @@ -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 { diff --git a/src/WaveTrack.cpp b/src/WaveTrack.cpp index f9ee1977a..18b48c7d3 100644 --- a/src/WaveTrack.cpp +++ b/src/WaveTrack.cpp @@ -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" }; } } diff --git a/src/import/RawAudioGuess.cpp b/src/import/RawAudioGuess.cpp index 710df0787..4bb87b3d7 100644 --- a/src/import/RawAudioGuess.cpp +++ b/src/import/RawAudioGuess.cpp @@ -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; diff --git a/src/menus/EditMenus.cpp b/src/menus/EditMenus.cpp index 4bc68edb8..32032312f 100644 --- a/src/menus/EditMenus.cpp +++ b/src/menus/EditMenus.cpp @@ -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 diff --git a/src/widgets/ErrorDialog.cpp b/src/widgets/ErrorDialog.cpp index a1714ea6c..c3e0f1ad2 100644 --- a/src/widgets/ErrorDialog.cpp +++ b/src/widgets/ErrorDialog.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #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);