mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-16 08:34:10 +02:00
Bug 1180 - Custom FFmpeg Export: an empty presets list can be Exported
Also added help button, per 1180 comments.
This commit is contained in:
parent
582d8afdcb
commit
1f6e4ce037
@ -61,6 +61,7 @@
|
|||||||
#include "../Tags.h"
|
#include "../Tags.h"
|
||||||
#include "../TranslatableStringArray.h"
|
#include "../TranslatableStringArray.h"
|
||||||
#include "../widgets/AudacityMessageBox.h"
|
#include "../widgets/AudacityMessageBox.h"
|
||||||
|
#include "../widgets/HelpSystem.h"
|
||||||
|
|
||||||
#include "Export.h"
|
#include "Export.h"
|
||||||
|
|
||||||
@ -560,17 +561,25 @@ FFmpegPreset *FFmpegPresets::FindPreset(wxString &name)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FFmpegPresets::SavePreset(ExportFFmpegOptions *parent, wxString &name)
|
// return false if overwrite was not allowed.
|
||||||
|
bool FFmpegPresets::OverwriteIsOk( wxString &name )
|
||||||
{
|
{
|
||||||
wxString format;
|
|
||||||
wxString codec;
|
|
||||||
FFmpegPreset *preset = FindPreset(name);
|
FFmpegPreset *preset = FindPreset(name);
|
||||||
if (preset)
|
if (preset)
|
||||||
{
|
{
|
||||||
wxString query = wxString::Format(_("Overwrite preset '%s'?"),name);
|
wxString query = wxString::Format(_("Overwrite preset '%s'?"),name);
|
||||||
int action = AudacityMessageBox(query,_("Confirm Overwrite"),wxYES_NO | wxCENTRE);
|
int action = AudacityMessageBox(query,_("Confirm Overwrite"),wxYES_NO | wxCENTRE);
|
||||||
if (action == wxNO) return;
|
if (action == wxNO) return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool FFmpegPresets::SavePreset(ExportFFmpegOptions *parent, wxString &name)
|
||||||
|
{
|
||||||
|
wxString format;
|
||||||
|
wxString codec;
|
||||||
|
FFmpegPreset *preset;
|
||||||
|
|
||||||
{
|
{
|
||||||
wxWindow *wnd;
|
wxWindow *wnd;
|
||||||
@ -581,7 +590,7 @@ void FFmpegPresets::SavePreset(ExportFFmpegOptions *parent, wxString &name)
|
|||||||
if (lb->GetSelection() < 0)
|
if (lb->GetSelection() < 0)
|
||||||
{
|
{
|
||||||
AudacityMessageBox(_("Please select format before saving a profile"));
|
AudacityMessageBox(_("Please select format before saving a profile"));
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
format = lb->GetStringSelection();
|
format = lb->GetStringSelection();
|
||||||
|
|
||||||
@ -590,7 +599,7 @@ void FFmpegPresets::SavePreset(ExportFFmpegOptions *parent, wxString &name)
|
|||||||
if (lb->GetSelection() < 0)
|
if (lb->GetSelection() < 0)
|
||||||
{
|
{
|
||||||
AudacityMessageBox(_("Please select codec before saving a profile"));
|
AudacityMessageBox(_("Please select codec before saving a profile"));
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
codec = lb->GetStringSelection();
|
codec = lb->GetStringSelection();
|
||||||
}
|
}
|
||||||
@ -656,6 +665,7 @@ void FFmpegPresets::SavePreset(ExportFFmpegOptions *parent, wxString &name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FFmpegPresets::LoadPreset(ExportFFmpegOptions *parent, wxString &name)
|
void FFmpegPresets::LoadPreset(ExportFFmpegOptions *parent, wxString &name)
|
||||||
@ -884,6 +894,7 @@ void FFmpegPresets::WriteXML(XMLWriter &xmlFile) const
|
|||||||
|
|
||||||
BEGIN_EVENT_TABLE(ExportFFmpegOptions, wxDialogWrapper)
|
BEGIN_EVENT_TABLE(ExportFFmpegOptions, wxDialogWrapper)
|
||||||
EVT_BUTTON(wxID_OK,ExportFFmpegOptions::OnOK)
|
EVT_BUTTON(wxID_OK,ExportFFmpegOptions::OnOK)
|
||||||
|
EVT_BUTTON(wxID_HELP,ExportFFmpegOptions::OnGetURL)
|
||||||
EVT_LISTBOX(FEFormatID,ExportFFmpegOptions::OnFormatList)
|
EVT_LISTBOX(FEFormatID,ExportFFmpegOptions::OnFormatList)
|
||||||
EVT_LISTBOX(FECodecID,ExportFFmpegOptions::OnCodecList)
|
EVT_LISTBOX(FECodecID,ExportFFmpegOptions::OnCodecList)
|
||||||
EVT_BUTTON(FEAllFormatsID,ExportFFmpegOptions::OnAllFormats)
|
EVT_BUTTON(FEAllFormatsID,ExportFFmpegOptions::OnAllFormats)
|
||||||
@ -1595,7 +1606,7 @@ void ExportFFmpegOptions::PopulateOrExchange(ShuttleGui & S)
|
|||||||
S.EndStatic();
|
S.EndStatic();
|
||||||
//S.EndScroller();
|
//S.EndScroller();
|
||||||
S.SetBorder( 5 );
|
S.SetBorder( 5 );
|
||||||
S.AddStandardButtons();
|
S.AddStandardButtons(eOkButton | eCancelButton | eHelpButton );
|
||||||
}
|
}
|
||||||
S.EndVerticalLay();
|
S.EndVerticalLay();
|
||||||
}
|
}
|
||||||
@ -1829,15 +1840,24 @@ void ExportFFmpegOptions::OnDeletePreset(wxCommandEvent& WXUNUSED(event))
|
|||||||
///
|
///
|
||||||
///
|
///
|
||||||
void ExportFFmpegOptions::OnSavePreset(wxCommandEvent& WXUNUSED(event))
|
void ExportFFmpegOptions::OnSavePreset(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{ const bool kCheckForOverwrite = true;
|
||||||
|
SavePreset(kCheckForOverwrite);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return false if failed to save.
|
||||||
|
bool ExportFFmpegOptions::SavePreset(bool bCheckForOverwrite)
|
||||||
{
|
{
|
||||||
wxComboBox *preset = dynamic_cast<wxComboBox*>(FindWindowById(FEPresetID,this));
|
wxComboBox *preset = dynamic_cast<wxComboBox*>(FindWindowById(FEPresetID,this));
|
||||||
wxString name = preset->GetValue();
|
wxString name = preset->GetValue();
|
||||||
if (name.empty())
|
if (name.empty())
|
||||||
{
|
{
|
||||||
AudacityMessageBox(_("You can't save a preset without name"));
|
AudacityMessageBox(_("You can't save a preset without a name"));
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
mPresets->SavePreset(this,name);
|
if( bCheckForOverwrite && !mPresets->OverwriteIsOk(name))
|
||||||
|
return false;
|
||||||
|
if( !mPresets->SavePreset(this,name) )
|
||||||
|
return false;
|
||||||
int index = mPresetNames.Index(name,false);
|
int index = mPresetNames.Index(name,false);
|
||||||
if (index == -1)
|
if (index == -1)
|
||||||
{
|
{
|
||||||
@ -1846,6 +1866,7 @@ void ExportFFmpegOptions::OnSavePreset(wxCommandEvent& WXUNUSED(event))
|
|||||||
mPresetCombo->Append(mPresetNames);
|
mPresetCombo->Append(mPresetNames);
|
||||||
mPresetCombo->Select(mPresetNames.Index(name,false));
|
mPresetCombo->Select(mPresetNames.Index(name,false));
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
@ -1894,6 +1915,20 @@ void ExportFFmpegOptions::OnImportPresets(wxCommandEvent& WXUNUSED(event))
|
|||||||
///
|
///
|
||||||
void ExportFFmpegOptions::OnExportPresets(wxCommandEvent& WXUNUSED(event))
|
void ExportFFmpegOptions::OnExportPresets(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
|
const bool kCheckForOverwrite = true;
|
||||||
|
// Bug 1180 save any pending preset before exporting the lot.
|
||||||
|
// If saving fails, don't try to export.
|
||||||
|
if( !SavePreset(!kCheckForOverwrite) )
|
||||||
|
return;
|
||||||
|
|
||||||
|
wxArrayString presets;
|
||||||
|
mPresets->GetPresetList( presets);
|
||||||
|
if( presets.Count() < 1)
|
||||||
|
{
|
||||||
|
AudacityMessageBox(_("No presets to export"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
wxString path;
|
wxString path;
|
||||||
FileDialogWrapper dlg(this,
|
FileDialogWrapper dlg(this,
|
||||||
_("Select xml file to export presets into"),
|
_("Select xml file to export presets into"),
|
||||||
@ -2050,6 +2085,7 @@ void ExportFFmpegOptions::OnCodecList(wxCommandEvent& WXUNUSED(event))
|
|||||||
DoOnCodecList();
|
DoOnCodecList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
void ExportFFmpegOptions::OnOK(wxCommandEvent& WXUNUSED(event))
|
void ExportFFmpegOptions::OnOK(wxCommandEvent& WXUNUSED(event))
|
||||||
@ -2070,4 +2106,10 @@ void ExportFFmpegOptions::OnOK(wxCommandEvent& WXUNUSED(event))
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ExportFFmpegOptions::OnGetURL(wxCommandEvent & WXUNUSED(event))
|
||||||
|
{
|
||||||
|
HelpSystem::ShowHelp(this, wxT("Custom_FFmpeg_Export_Options#Presets"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -195,6 +195,7 @@ public:
|
|||||||
~ExportFFmpegOptions();
|
~ExportFFmpegOptions();
|
||||||
void PopulateOrExchange(ShuttleGui & S);
|
void PopulateOrExchange(ShuttleGui & S);
|
||||||
void OnOK(wxCommandEvent& event);
|
void OnOK(wxCommandEvent& event);
|
||||||
|
void OnGetURL(wxCommandEvent& event);
|
||||||
void OnFormatList(wxCommandEvent& event);
|
void OnFormatList(wxCommandEvent& event);
|
||||||
void DoOnFormatList();
|
void DoOnFormatList();
|
||||||
void OnCodecList(wxCommandEvent& event);
|
void OnCodecList(wxCommandEvent& event);
|
||||||
@ -206,6 +207,8 @@ public:
|
|||||||
void OnDeletePreset(wxCommandEvent& event);
|
void OnDeletePreset(wxCommandEvent& event);
|
||||||
void OnImportPresets(wxCommandEvent& event);
|
void OnImportPresets(wxCommandEvent& event);
|
||||||
void OnExportPresets(wxCommandEvent& event);
|
void OnExportPresets(wxCommandEvent& event);
|
||||||
|
bool SavePreset( bool bCheckForOverwrite);
|
||||||
|
|
||||||
|
|
||||||
// Static tables
|
// Static tables
|
||||||
static CompatibilityEntry CompatibilityList[];
|
static CompatibilityEntry CompatibilityList[];
|
||||||
@ -335,8 +338,9 @@ public:
|
|||||||
|
|
||||||
void GetPresetList(wxArrayString &list);
|
void GetPresetList(wxArrayString &list);
|
||||||
void LoadPreset(ExportFFmpegOptions *parent, wxString &name);
|
void LoadPreset(ExportFFmpegOptions *parent, wxString &name);
|
||||||
void SavePreset(ExportFFmpegOptions *parent, wxString &name);
|
bool SavePreset(ExportFFmpegOptions *parent, wxString &name);
|
||||||
void DeletePreset(wxString &name);
|
void DeletePreset(wxString &name);
|
||||||
|
bool OverwriteIsOk( wxString &name );
|
||||||
FFmpegPreset *FindPreset(wxString &name);
|
FFmpegPreset *FindPreset(wxString &name);
|
||||||
|
|
||||||
void ImportPresets(wxString &filename);
|
void ImportPresets(wxString &filename);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user