mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-14 15:48:21 +02:00
Add new error dialog for unwritable directory.
This commit is contained in:
parent
e33b5a478d
commit
41341e12cd
@ -965,6 +965,8 @@ list( APPEND SOURCES
|
|||||||
widgets/ErrorReportDialog.cpp
|
widgets/ErrorReportDialog.cpp
|
||||||
widgets/ErrorReportDialog.h
|
widgets/ErrorReportDialog.h
|
||||||
>
|
>
|
||||||
|
widgets/UnwritableLocationErrorDialog.cpp
|
||||||
|
widgets/UnwritableLocationErrorDialog.h
|
||||||
widgets/Warning.cpp
|
widgets/Warning.cpp
|
||||||
widgets/Warning.h
|
widgets/Warning.h
|
||||||
widgets/WindowAccessible.cpp
|
widgets/WindowAccessible.cpp
|
||||||
|
@ -43,9 +43,12 @@ Paul Licameli split from AudacityProject.cpp
|
|||||||
#include "widgets/AudacityMessageBox.h"
|
#include "widgets/AudacityMessageBox.h"
|
||||||
#include "widgets/ErrorDialog.h"
|
#include "widgets/ErrorDialog.h"
|
||||||
#include "widgets/FileHistory.h"
|
#include "widgets/FileHistory.h"
|
||||||
|
#include "widgets/UnwritableLocationErrorDialog.h"
|
||||||
#include "widgets/Warning.h"
|
#include "widgets/Warning.h"
|
||||||
#include "xml/XMLFileReader.h"
|
#include "xml/XMLFileReader.h"
|
||||||
|
|
||||||
|
#include "HelpText.h"
|
||||||
|
|
||||||
static const AudacityProject::AttachedObjects::RegisteredFactory sFileManagerKey{
|
static const AudacityProject::AttachedObjects::RegisteredFactory sFileManagerKey{
|
||||||
[]( AudacityProject &parent ){
|
[]( AudacityProject &parent ){
|
||||||
auto result = std::make_shared< ProjectFileManager >( parent );
|
auto result = std::make_shared< ProjectFileManager >( parent );
|
||||||
@ -770,13 +773,10 @@ bool ProjectFileManager::OpenNewProject()
|
|||||||
bool bOK = OpenProject();
|
bool bOK = OpenProject();
|
||||||
if( !bOK )
|
if( !bOK )
|
||||||
{
|
{
|
||||||
ShowExceptionDialog(
|
auto tmpdir = wxFileName(TempDirectory::UnsavedProjectFileName()).GetPath();
|
||||||
nullptr,
|
|
||||||
XO("Can't open new empty project"),
|
UnwritableLocationErrorDialog dlg(nullptr, tmpdir);
|
||||||
XO("Error opening a new empty project"),
|
dlg.ShowModal();
|
||||||
"FAQ:Errors_opening_a_new_empty_project",
|
|
||||||
true,
|
|
||||||
projectFileIO.GetLastLog());
|
|
||||||
}
|
}
|
||||||
return bOK;
|
return bOK;
|
||||||
}
|
}
|
||||||
|
102
src/widgets/UnwritableLocationErrorDialog.cpp
Normal file
102
src/widgets/UnwritableLocationErrorDialog.cpp
Normal 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);
|
||||||
|
}
|
27
src/widgets/UnwritableLocationErrorDialog.h
Normal file
27
src/widgets/UnwritableLocationErrorDialog.h
Normal 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()
|
||||||
|
};
|
Loading…
x
Reference in New Issue
Block a user