18#include <wx/spinctrl.h>
19#include <wx/listbox.h>
20#include <wx/checkbox.h>
22#include <wx/textctrl.h>
47 xmlfile.
Parse(
this,xmlFileName.GetFullPath());
56 xmlFileName.GetFullPath(),
XO(
"Error Saving FFmpeg Presets") };
71 bool success = xmlfile.
Parse(
this,filename);
90 FFmpegPresetMap::iterator iter;
93 list.push_back(iter->second.mPresetName);
96 std::sort( list.begin(), list.end() );
113 return &iter->second;
125 auto query =
XO(
"Overwrite preset '%s'?").Format(
name);
128 XO(
"Confirm Overwrite"),
129 wxYES_NO | wxCENTRE);
130 if (action == wxNO)
return false;
146 wnd =
dynamic_cast<wxWindow*
>(parent)->FindWindowById(FEFormatID,parent);
147 lb =
dynamic_cast<wxListBox*
>(wnd);
148 if (lb->GetSelection() < 0)
153 format = lb->GetStringSelection();
155 wnd =
dynamic_cast<wxWindow*
>(parent)->FindWindowById(FECodecID,parent);
156 lb =
dynamic_cast<wxListBox*
>(wnd);
157 if (lb->GetSelection() < 0)
163 codec = lb->GetStringSelection();
174 for (
int id = FEFirstID;
id < FELastID;
id++)
176 wxWindow *wnd =
dynamic_cast<wxWindow*
>(parent)->FindWindowById(
id,parent);
185 preset->mControlState[
id - FEFirstID] = codec;
198 case FEMinPartOrderID:
199 case FEMaxPartOrderID:
202 sc =
dynamic_cast<wxSpinCtrl*
>(wnd);
203 preset->mControlState[
id - FEFirstID] = wxString::Format(
wxT(
"%d"),sc->GetValue());
208 tc =
dynamic_cast<wxTextCtrl*
>(wnd);
209 preset->mControlState[
id - FEFirstID] = tc->GetValue();
214 ch =
dynamic_cast<wxChoice*
>(wnd);
215 preset->mControlState[
id - FEFirstID] = wxString::Format(
wxT(
"%d"),ch->GetSelection());
219 case FEBitReservoirID:
220 case FEVariableBlockLenID:
221 cb =
dynamic_cast<wxCheckBox*
>(wnd);
222 preset->mControlState[
id - FEFirstID] = wxString::Format(
wxT(
"%d"),cb->GetValue());
245 for (
int id = FEFirstID;
id < FELastID;
id++)
247 wxWindow *wnd = parent->FindWindowById(
id,parent);
258 lb =
dynamic_cast<wxListBox*
>(wnd);
259 readstr =
preset->mControlState[
id - FEFirstID];
260 readlong = lb->FindString(readstr);
261 if (readlong > -1) lb->Select(readlong);
274 case FEMinPartOrderID:
275 case FEMaxPartOrderID:
278 sc =
dynamic_cast<wxSpinCtrl*
>(wnd);
279 preset->mControlState[
id - FEFirstID].ToLong(&readlong);
280 sc->SetValue(readlong);
285 tc =
dynamic_cast<wxTextCtrl*
>(wnd);
286 tc->SetValue(
preset->mControlState[
id - FEFirstID]);
291 ch =
dynamic_cast<wxChoice*
>(wnd);
292 preset->mControlState[
id - FEFirstID].ToLong(&readlong);
293 if (readlong > -1) ch->Select(readlong);
297 case FEBitReservoirID:
298 case FEVariableBlockLenID:
299 cb =
dynamic_cast<wxCheckBox*
>(wnd);
300 preset->mControlState[
id - FEFirstID].ToLong(&readlong);
301 if (readlong) readbool =
true;
else readbool =
false;
302 cb->SetValue(readbool);
316 if (tag ==
"ffmpeg_presets")
323 for (
auto pair : attrs)
325 auto attr = pair.first;
326 auto value = pair.second;
330 wxString strValue = value.ToWString();
335 auto query =
XO(
"Replace preset '%s'?").Format( strValue );
338 XO(
"Confirm Overwrite"),
339 wxYES_NO | wxCANCEL | wxCENTRE);
340 if (action == wxCANCEL)
363 if (tag ==
"setctrlstate" &&
mPreset)
366 for (
auto pair : attrs)
368 auto attr = pair.first;
369 auto value = pair.second;
373 for (
long i = FEFirstID; i < FELastID; i++)
377 else if (attr ==
"state")
379 if (
id > FEFirstID &&
id < FELastID)
400 else if (tag ==
"setctrlstate")
410 xmlFile.Write(
wxT(
"<?xml "));
411 xmlFile.Write(
wxT(
"version=\"1.0\" "));
412 xmlFile.Write(
wxT(
"standalone=\"no\" "));
413 xmlFile.Write(
wxT(
"?>\n"));
415 wxString dtdName =
wxT(
"-//audacityffmpegpreset-1.0.0//DTD//EN");
417 wxT(
"http://audacity.sourceforge.net/xml/audacityffmpegpreset-1.0.0.dtd");
419 xmlFile.Write(
wxT(
"<!DOCTYPE "));
420 xmlFile.Write(
wxT(
"project "));
421 xmlFile.Write(
wxT(
"PUBLIC "));
422 xmlFile.Write(
wxT(
"\"-//audacityffmpegpreset-1.0.0//DTD//EN\" "));
423 xmlFile.Write(
wxT(
"\"http://audacity.sourceforge.net/xml/audacityffmpegpreset-1.0.0.dtd\" "));
424 xmlFile.Write(
wxT(
">\n"));
430 xmlFile.StartTag(
wxT(
"ffmpeg_presets"));
431 xmlFile.WriteAttr(
wxT(
"version"),
wxT(
"1.0"));
432 FFmpegPresetMap::const_iterator iter;
433 for (iter = mPresets.begin(); iter != mPresets.end(); ++iter)
435 auto preset = &iter->second;
436 xmlFile.StartTag(
wxT(
"preset"));
437 xmlFile.WriteAttr(
wxT(
"name"),
preset->mPresetName);
438 for (
long i = FEFirstID + 1; i < FELastID; i++)
440 xmlFile.StartTag(
wxT(
"setctrlstate"));
442 xmlFile.WriteAttr(
wxT(
"state"),
preset->mControlState[i - FEFirstID]);
443 xmlFile.EndTag(
wxT(
"setctrlstate"));
445 xmlFile.EndTag(
wxT(
"preset"));
447 xmlFile.EndTag(
wxT(
"ffmpeg_presets"));
R GuardedCall(const F1 &body, const F2 &handler=F2::Default(), F3 delayedHandler=DefaultDelayedHandlerAction) noexcept(noexcept(handler(std::declval< AudacityException * >())) &&noexcept(handler(nullptr)) &&noexcept(std::function< void(AudacityException *)>{std::move(delayedHandler)}))
Execute some code on any thread; catch any AudacityException; enqueue error report on the main thread...
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
static const wxChar * FFmpegExportCtrlIDNames[]
std::unordered_map< wxString, FFmpegPreset > FFmpegPresetMap
std::vector< Attribute > AttributesList
Custom FFmpeg export dialog.
wxArrayString mControlState
void LoadPreset(ExportFFmpegOptions *parent, wxString &name)
bool SavePreset(ExportFFmpegOptions *parent, wxString &name)
void ImportPresets(wxString &filename)
bool OverwriteIsOk(wxString &name)
XMLTagHandler * HandleXMLChild(const std::string_view &tag) override
void DeletePreset(wxString &name)
bool HandleXMLTag(const std::string_view &tag, const AttributesList &attrs) override
~FFmpegPresets() override
void WriteXMLHeader(XMLWriter &xmlFile) const
void GetPresetList(wxArrayString &list)
void WriteXML(XMLWriter &xmlFile) const
void ExportPresets(wxString &filename)
FFmpegPreset * FindPreset(wxString &name)
Reads a file and passes the results through an XMLTagHandler.
bool Parse(XMLTagHandler *baseHandler, const FilePath &fname)
Wrapper to output XML data to files.
This class is an interface which should be implemented by classes which wish to be able to load and s...
Base class for XMLFileWriter and XMLStringWriter that provides the general functionality for creating...
FILES_API FilePath DataDir()
Audacity user data directory.