1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-14 07:37:43 +02:00

Add new error dialog for unwritable directory.

This commit is contained in:
Dmitry Vedenko 2021-07-15 19:13:38 +03:00 committed by Dmitry Vedenko
parent e33b5a478d
commit 41341e12cd
4 changed files with 138 additions and 7 deletions

View File

@ -965,6 +965,8 @@ list( APPEND SOURCES
widgets/ErrorReportDialog.cpp
widgets/ErrorReportDialog.h
>
widgets/UnwritableLocationErrorDialog.cpp
widgets/UnwritableLocationErrorDialog.h
widgets/Warning.cpp
widgets/Warning.h
widgets/WindowAccessible.cpp

View File

@ -43,9 +43,12 @@ Paul Licameli split from AudacityProject.cpp
#include "widgets/AudacityMessageBox.h"
#include "widgets/ErrorDialog.h"
#include "widgets/FileHistory.h"
#include "widgets/UnwritableLocationErrorDialog.h"
#include "widgets/Warning.h"
#include "xml/XMLFileReader.h"
#include "HelpText.h"
static const AudacityProject::AttachedObjects::RegisteredFactory sFileManagerKey{
[]( AudacityProject &parent ){
auto result = std::make_shared< ProjectFileManager >( parent );
@ -770,13 +773,10 @@ bool ProjectFileManager::OpenNewProject()
bool bOK = OpenProject();
if( !bOK )
{
ShowExceptionDialog(
nullptr,
XO("Can't open new empty project"),
XO("Error opening a new empty project"),
"FAQ:Errors_opening_a_new_empty_project",
true,
projectFileIO.GetLastLog());
auto tmpdir = wxFileName(TempDirectory::UnsavedProjectFileName()).GetPath();
UnwritableLocationErrorDialog dlg(nullptr, tmpdir);
dlg.ShowModal();
}
return bOK;
}

View File

@ -0,0 +1,102 @@
/**********************************************************************
Audacity: A Digital Audio Editor
UnwritableLocationError.h
Dmitry Vedenko
**********************************************************************/
#include "UnwritableLocationErrorDialog.h"
#include "HelpSystem.h"
#include "ShuttleGui.h"
#include "prefs/PrefsDialog.h"
#include "ui/AccessibleLinksFormatter.h"
BEGIN_EVENT_TABLE(UnwritableLocationErrorDialog, wxDialogWrapper)
EVT_BUTTON(wxID_OK, UnwritableLocationErrorDialog::OnOk)
EVT_BUTTON(wxID_HELP, UnwritableLocationErrorDialog::OnError)
END_EVENT_TABLE()
UnwritableLocationErrorDialog::UnwritableLocationErrorDialog(wxWindow* parent, const wxString& path)
: wxDialogWrapper(
parent, -1, XO("Error"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX)
{
ShuttleGui S(this, eIsCreating);
S.SetBorder(8);
S.StartVerticalLay();
{
S.AddSpace(0, 12);
S.StartHorizontalLay();
{
S.AddSpace(12, 0);
S.StartVerticalLay();
{
S.AddFixedText(
/* i18n-hint: %s is replaced with a directory path. */
XO("Unable to write files to directory: %s.").Format(path),
false, 500);
S.AddFixedText(
/* i18n-hint: This message describes the error in the Error dialog. */
XO("Please check that the directory exists, has the necessary permissions, and the drive isn't full."),
false, 0);
S.AddSpace(0, 8);
AccessibleLinksFormatter preferencesMessage(
/* i18n-hint: %s is replaced with 'Preferences > Directories'. */
XO("You can change the directory in %s."));
preferencesMessage.FormatLink(
/* i18n-hint: Hyperlink title that opens Preferences dialog on Directories page. */
wxT("%s"), XO("Preferences > Directories"), [parent, this]() {
EndModal(wxID_OK);
GlobalPrefsDialog dialog(parent, nullptr);
dialog.SelectPageByName(XO("Directories").Translation());
dialog.ShowModal();
});
preferencesMessage.Populate(S);
}
S.EndVerticalLay();
S.AddSpace(12, 0);
}
S.EndHorizontalLay();
S.AddSpace(0, 12);
S.AddStandardButtons(eHelpButton | eOkButton);
}
S.EndVerticalLay();
Layout();
Fit();
Center();
}
UnwritableLocationErrorDialog::~UnwritableLocationErrorDialog()
{
}
void UnwritableLocationErrorDialog::OnOk(wxCommandEvent&)
{
EndModal(wxID_OK);
}
void UnwritableLocationErrorDialog::OnError(wxCommandEvent&)
{
HelpSystem::ShowHelp(this, "Error:_Disk_full_or_not_writable", false);
}

View File

@ -0,0 +1,27 @@
/**********************************************************************
Audacity: A Digital Audio Editor
UnwritableLocationError.h
Dmitry Vedenko
**********************************************************************/
#pragma once
#include "widgets/wxPanelWrapper.h"
/// An error dialog about unwritable location, that allows to navigate to settings quickly
class UnwritableLocationErrorDialog final : public wxDialogWrapper
{
public:
explicit UnwritableLocationErrorDialog(wxWindow* parent, const wxString& path);
virtual ~UnwritableLocationErrorDialog();
void OnOk(wxCommandEvent& event);
void OnError(wxCommandEvent& event);
DECLARE_EVENT_TABLE()
};