1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-16 16:10:06 +02:00

MultiDialog uses ShuttleGui, and TranslatableString for title

This commit is contained in:
Paul Licameli 2017-10-27 11:44:43 -04:00
parent 75b3ad7c61
commit 093ffbd2f1
4 changed files with 63 additions and 65 deletions

View File

@ -271,9 +271,8 @@ void ModuleManager::Initialize(CommandHandler &cmdHandler)
// and let the user decide for each one.
{
wxString ShortName = wxFileName( files[i] ).GetName();
wxString msg;
msg.Printf(_("Module \"%s\" found."), ShortName);
msg += _("\n\nOnly use modules from trusted sources");
auto msg = XO("Module \"%s\" found.").Format( ShortName );
msg += XO("\n\nOnly use modules from trusted sources");
const TranslatableStrings buttons{
XO("Yes"), XO("No"),
}; // could add a button here for 'yes and remember that', and put it into the cfg file. Needs more thought.

View File

@ -55,7 +55,7 @@ int ProjectFSCK(
This error message is about the tags that hold the sequence information.
The error message is confusing to users in English, and could just say
"Found problems with <sequence> when checking project file." */
wxString msg = _("Project check read faulty Sequence tags.");
auto msg = XO("Project check read faulty Sequence tags.");
const TranslatableStrings buttons{
XO("Close project immediately with no changes"),
XO("Continue with repairs noted in log, and check for more errors. This will save the project in its current state, unless you \"Close project immediately\" on further error alerts.")
@ -95,8 +95,8 @@ int ProjectFSCK(
action = 2;
else
{
wxString msgA =
_("Project check of \"%s\" folder \
auto msg =
XO("Project check of \"%s\" folder \
\ndetected %lld missing external audio file(s) \
\n('aliased files'). There is no way for Audacity \
\nto recover these files automatically. \
@ -107,9 +107,10 @@ _("Project check of \"%s\" folder \
\nmay not show silence. \
\n\nIf you choose the third option, this will save the \
\nproject in its current state, unless you \"Close \
\nproject immediately\" on further error alerts.");
wxString msg;
msg.Printf(msgA, dm.GetProjectName(), (long long) missingAliasFilesPathHash.size());
\nproject immediately\" on further error alerts.")
.Format(
dm.GetProjectName(),
(long long) missingAliasFilesPathHash.size() );
const TranslatableStrings buttons{
XO("Close project immediately with no changes"),
XO("Treat missing audio as silence (this session only)"),
@ -181,13 +182,13 @@ _("Project check of \"%s\" folder \
action = 0;
else
{
wxString msgA =
_("Project check of \"%s\" folder \
auto msg =
XO("Project check of \"%s\" folder \
\ndetected %lld missing alias (.auf) blockfile(s). \
\nAudacity can fully regenerate these files \
\nfrom the current audio in the project.");
wxString msg;
msg.Printf(msgA, dm.GetProjectName(), (long long) missingAUFHash.size());
\nfrom the current audio in the project.")
.Format(
dm.GetProjectName(), (long long) missingAUFHash.size() );
const TranslatableStrings buttons{
XO("Regenerate alias summary files (safe and recommended)"),
XO("Fill in silence for missing display data (this session only)"),
@ -248,8 +249,8 @@ _("Project check of \"%s\" folder \
action = 2;
else
{
wxString msgA =
_("Project check of \"%s\" folder \
auto msg =
XO("Project check of \"%s\" folder \
\ndetected %lld missing audio data (.au) blockfile(s), \
\nprobably due to a bug, system crash, or accidental \
\ndeletion. There is no way for Audacity to recover \
@ -258,9 +259,9 @@ _("Project check of \"%s\" folder \
\nyou can try to find and restore the missing files \
\nto their previous location. \
\n\nNote that for the second option, the waveform \
\nmay not show silence.");
wxString msg;
msg.Printf(msgA, dm.GetProjectName(), (long long) missingAUHash.size());
\nmay not show silence.")
.Format(
dm.GetProjectName(), (long long) missingAUHash.size() );
const TranslatableStrings buttons{
XO("Close project immediately with no further changes"),
XO("Treat missing audio as silence (this session only)"),
@ -325,14 +326,13 @@ _("Project check of \"%s\" folder \
}
else
{
wxString msgA =
_("Project check of \"%s\" folder \
auto msg =
XO("Project check of \"%s\" folder \
\nfound %d orphan block file(s). These files are \
\nunused by this project, but might belong to \
other projects. \
\nThey are doing no harm and are small.");
wxString msg;
msg.Printf(msgA, dm.GetProjectName(), (int)orphanFilePathArray.size());
\nThey are doing no harm and are small.")
.Format( dm.GetProjectName(), (int)orphanFilePathArray.size() );
const TranslatableStrings buttons{
XO("Continue without deleting; ignore the extra files this session"),

View File

@ -21,6 +21,8 @@ for each problem encountered, since there can be many orphans.
#include "../Audacity.h"
#include "MultiDialog.h"
#include "../ShuttleGui.h"
#include <wx/app.h>
#include <wx/button.h>
#include <wx/dialog.h>
@ -39,7 +41,7 @@ class MultiDialog final : public wxDialogWrapper
{
public:
MultiDialog(wxWindow * pParent,
wxString message,
const TranslatableString &message,
const TranslatableString &title,
const TranslatableStrings &buttons,
const TranslatableString &boxMsg, bool log);
@ -62,7 +64,7 @@ BEGIN_EVENT_TABLE(MultiDialog, wxDialogWrapper)
END_EVENT_TABLE()
MultiDialog::MultiDialog(wxWindow * pParent,
wxString message,
const TranslatableString &message,
const TranslatableString &title,
const TranslatableStrings &buttons,
const TranslatableString &boxMsg, bool log)
@ -72,27 +74,25 @@ MultiDialog::MultiDialog(wxWindow * pParent,
{
SetName();
wxBoxSizer *mainSizer;
ShuttleGui S{ this, eIsCreating };
{
auto uMainSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
mainSizer = uMainSizer.get();
S.SetBorder( 5 );
S.StartVerticalLay( 0 );
{
auto vSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
S.StartHorizontalLay(wxALIGN_LEFT | wxALL, 0);
{
auto iconAndTextSizer = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
S.SetBorder( 0 );
wxBitmap bitmap = wxArtProvider::GetIcon(wxART_WARNING,
wxART_MESSAGE_BOX);
wxStaticBitmap *icon = safenew wxStaticBitmap(this, -1, bitmap);
iconAndTextSizer->Add(icon, 0, wxCENTER);
auto icon = safenew wxStaticBitmap(S.GetParent(), -1, bitmap);
S
.Position( wxCENTER )
.AddWindow( icon );
wxStaticText *statText = safenew wxStaticText(this, -1, message);
statText->SetName(message); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs)
iconAndTextSizer->Add(statText, 1, wxCENTER | wxLEFT, 15);
vSizer->Add(iconAndTextSizer.release(), 0, wxALIGN_LEFT | wxALL, 5);
S.SetBorder( 15 );
S.Prop(1).AddVariableText( message, false, wxCENTER | wxLEFT );
}
S.EndHorizontalLay();
const auto buttonLabels = transform_container<wxArrayStringEx>(
buttons, std::mem_fn( &TranslatableString::Translation ) );
@ -101,46 +101,45 @@ MultiDialog::MultiDialog(wxWindow * pParent,
const auto boxStr = boxMsg.Translation();
mRadioBox = safenew wxRadioBox(this, -1,
S.SetBorder( 5 );
mRadioBox = safenew wxRadioBox(S.GetParent(), -1,
boxStr,
wxDefaultPosition, wxDefaultSize,
count, count ? &buttonLabels[0] : nullptr,
1, wxRA_SPECIFY_COLS);
mRadioBox->SetName(boxStr);
mRadioBox->SetSelection(0);
vSizer->Add(mRadioBox, 1, wxEXPAND | wxALL, 5);
S.Prop( 1 )
.Name( boxMsg )
.Position(wxEXPAND | wxALL)
.AddWindow( mRadioBox );
S.StartHorizontalLay(wxALIGN_CENTER | wxALL, 0);
{
auto buttonSizer = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
wxButton* pButton;
if (log)
{
pButton = safenew wxButton(this, ID_SHOW_LOG_BUTTON, _("Show Log for Details"));
buttonSizer->Add(pButton, 0, wxALIGN_LEFT | wxALL, 5);
pButton->SetDefault(); // Encourage user to look at files.
S
.Id( ID_SHOW_LOG_BUTTON )
.AddButton(
XO("Show Log for Details"), wxALIGN_LEFT | wxALL,
// set default to encourage user to look at files.
true );
buttonSizer->AddSpacer(40);
S.AddSpace( 40, 0 );
}
pButton = safenew wxButton(this, wxID_OK, _("OK"));
if (!log)
pButton->SetDefault();
buttonSizer->Add(pButton, 0, wxALL, 5);
vSizer->Add(buttonSizer.release(), 0, wxALIGN_CENTER | wxALL, 5);
auto pButton = S.Id( wxID_OK )
.AddButton( XO("OK"), wxALIGN_CENTER, !log );
}
mainSizer->Add(vSizer.release(), 0, wxALL, 5);
S.EndHorizontalLay();
}
SetAutoLayout(true);
SetSizer(uMainSizer.release());
S.EndVerticalLay();
}
mainSizer->Fit(this);
mainSizer->SetSizeHints(this);
SetAutoLayout(true);
GetSizer()->Fit(this);
GetSizer()->SetSizeHints(this);
}
void MultiDialog::OnOK(wxCommandEvent & WXUNUSED(event))
@ -157,7 +156,7 @@ void MultiDialog::OnShowLog(wxCommandEvent & WXUNUSED(event))
}
int ShowMultiDialog(const wxString &message,
int ShowMultiDialog(const TranslatableString &message,
const TranslatableString &title,
const TranslatableStrings &buttons,
const TranslatableString &boxMsg, bool log)

View File

@ -24,7 +24,7 @@ const TranslatableString &DefaultMultiDialogMessage();
// Display a dialog with radio buttons.
// Return the zero-based index of the chosen button.
int ShowMultiDialog(const wxString &message,
int ShowMultiDialog(const TranslatableString &message,
const TranslatableString &title,
const TranslatableStrings &buttons,
const TranslatableString &boxMsg