Audacity 3.2.0
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
ExportOptionsCLEditor Class Referencefinal
Inheritance diagram for ExportOptionsCLEditor:
[legend]
Collaboration diagram for ExportOptionsCLEditor:
[legend]

Public Member Functions

 ExportOptionsCLEditor ()=default
 
void PopulateUI (ShuttleGui &S) override
 
bool TransferDataFromWindow () override
 
SampleRateList GetSampleRateList () const override
 
int GetOptionsCount () const override
 
bool GetOption (int index, ExportOption &option) const override
 
bool GetValue (int id, ExportValue &value) const override
 
bool SetValue (int id, const ExportValue &value) override
 
void Load (const audacity::BasicSettings &config) override
 
void Store (audacity::BasicSettings &config) const override
 
- Public Member Functions inherited from ExportOptionsEditor
virtual ~ExportOptionsEditor ()
 
virtual int GetOptionsCount () const =0
 
virtual bool GetOption (int index, ExportOption &option) const =0
 
virtual bool GetValue (ExportOptionID id, ExportValue &value) const =0
 
virtual bool SetValue (ExportOptionID id, const ExportValue &value)=0
 
virtual SampleRateList GetSampleRateList () const =0
 
virtual void Store (audacity::BasicSettings &settings) const =0
 
virtual void Load (const audacity::BasicSettings &config)=0
 
- Public Member Functions inherited from ExportOptionsUIServices
virtual ~ExportOptionsUIServices ()
 
virtual void PopulateUI (ShuttleGui &)=0
 
virtual bool TransferDataFromWindow ()=0
 

Static Public Member Functions

static bool IsValidCommand (const wxString &command)
 

Private Member Functions

void OnBrowse (const wxCommandEvent &)
 

Private Attributes

wxString mCommand {wxT("lame - \"%f\"")}
 
bool mShowOutput {false}
 
bool mInitialized {false}
 
wxWindow * mParent {nullptr}
 
wxComboBox * mCommandBox {nullptr}
 
wxString mLastCommand
 
FileHistory mHistory
 

Additional Inherited Members

- Public Types inherited from ExportOptionsEditor
using SampleRateList = std::vector< int >
 

Detailed Description

Definition at line 170 of file ExportCL.cpp.

Constructor & Destructor Documentation

◆ ExportOptionsCLEditor()

ExportOptionsCLEditor::ExportOptionsCLEditor ( )
default

Member Function Documentation

◆ GetOption()

bool ExportOptionsCLEditor::GetOption ( int  index,
ExportOption option 
) const
inlineoverridevirtual

Implements ExportOptionsEditor.

Definition at line 322 of file ExportCL.cpp.

323 {
324 if(index >= 0 && index < static_cast<int>(CLOptions.size()))
325 {
326 option = CLOptions[index];
327 return true;
328 }
329 return false;
330 }
const std::vector< ExportOption > CLOptions
Definition: ExportCL.cpp:165

References CLOptions.

◆ GetOptionsCount()

int ExportOptionsCLEditor::GetOptionsCount ( ) const
inlineoverridevirtual

Implements ExportOptionsEditor.

Definition at line 317 of file ExportCL.cpp.

318 {
319 return static_cast<int>(CLOptions.size());
320 }

References CLOptions.

◆ GetSampleRateList()

SampleRateList ExportOptionsCLEditor::GetSampleRateList ( ) const
inlineoverridevirtual

Implements ExportOptionsEditor.

Definition at line 312 of file ExportCL.cpp.

313 {
314 return {};
315 }

◆ GetValue()

bool ExportOptionsCLEditor::GetValue ( int  id,
ExportValue value 
) const
inlineoverridevirtual

Implements ExportOptionsEditor.

Definition at line 332 of file ExportCL.cpp.

333 {
334 if(id == CLOptionIDCommand)
335 {
336 value = std::string(mCommand.ToUTF8());
337 return true;
338 }
339 if(id == CLOptionIDShowOutput)
340 {
341 value = mShowOutput;
342 return true;
343 }
344 return false;
345 }
@ CLOptionIDShowOutput
Definition: ExportCL.cpp:162
@ CLOptionIDCommand
Definition: ExportCL.cpp:161

References CLOptionIDCommand, CLOptionIDShowOutput, mCommand, and mShowOutput.

◆ IsValidCommand()

static bool ExportOptionsCLEditor::IsValidCommand ( const wxString &  command)
inlinestatic

Definition at line 243 of file ExportCL.cpp.

244 {
245 wxArrayString argv = wxCmdLineParser::ConvertStringToArgs(command,
246#if defined(__WXMSW__)
247 wxCMD_LINE_SPLIT_DOS
248#else
249 wxCMD_LINE_SPLIT_UNIX
250#endif
251 );
252
253 if (argv.empty()) {
255 XO("Warning"),
256 XO("Program name appears to be missing."),//":745"
257 true);
258 return false;
259 }
260
261 // Normalize the path (makes absolute and resolves variables)
262 wxFileName cmd(argv[0]);
263 cmd.Normalize(wxPATH_NORM_ALL & ~wxPATH_NORM_ABSOLUTE);
264
265 // Just verify the given path exists if it is absolute.
266 if (cmd.IsAbsolute()) {
267 if (!cmd.Exists()) {
268 BasicUI::ShowMessageBox(XO("\"%s\" couldn't be found.").Format(cmd.GetFullPath()),
271 .Caption(XO("Warning")));
272 return false;
273 }
274
275 return true;
276 }
277
278 // Search for the command in the PATH list
279 wxPathList pathlist;
280 pathlist.AddEnvList(wxT("PATH"));
281 wxString path = pathlist.FindAbsoluteValidPath(argv[0]);
282
283 #if defined(__WXMSW__)
284 if (path.empty()) {
285 path = pathlist.FindAbsoluteValidPath(argv[0] + wxT(".exe"));
286 }
287 #endif
288
289 if (path.empty()) {
290 BasicUI::ShowMessageBox(XO("Unable to locate \"%s\" in your path.").Format(cmd.GetFullPath()),
293 .Caption(XO("Warning")));
294 return false;
295 }
296
297 return true;
298 }
wxT("CloseDown"))
void ShowExportErrorDialog(const TranslatableString &message, const TranslatableString &caption, bool allowReporting)
Definition: Export.cpp:144
XO("Cut/Copy/Paste")
Abstract base class used in importing a file.
MessageBoxResult ShowMessageBox(const TranslatableString &message, MessageBoxOptions options={})
Show a modal message box with either Ok or Yes and No, and optionally Cancel.
Definition: BasicUI.h:279
UTILITY_API const char *const * argv
A copy of argv; responsibility of application startup to assign it.
MessageBoxOptions && Caption(TranslatableString caption_) &&
Definition: BasicUI.h:101
MessageBoxOptions && IconStyle(Icon style) &&
Definition: BasicUI.h:104

References CommandLineArgs::argv, BasicUI::MessageBoxOptions::Caption(), BasicUI::MessageBoxOptions::IconStyle(), ShowExportErrorDialog(), BasicUI::ShowMessageBox(), BasicUI::Warning, wxT(), and XO().

Referenced by TransferDataFromWindow().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Load()

void ExportOptionsCLEditor::Load ( const audacity::BasicSettings config)
inlineoverridevirtual

Implements ExportOptionsEditor.

Definition at line 362 of file ExportCL.cpp.

363 {
364 mCommand = config.Read(wxT("/FileFormats/ExternalProgramExportCommand"), mCommand);
365 mShowOutput = config.Read(wxT("/FileFormats/ExternalProgramShowOutput"), mShowOutput);
366 }
virtual bool Read(const wxString &key, bool *value) const =0

References mCommand, mShowOutput, audacity::BasicSettings::Read(), and wxT().

Here is the call graph for this function:

◆ OnBrowse()

void ExportOptionsCLEditor::OnBrowse ( const wxCommandEvent &  )
inlineprivate

Definition at line 376 of file ExportCL.cpp.

377 {
378 wxString path;
379 FileExtension ext;
381
382 #if defined(__WXMSW__)
383 ext = wxT("exe");
384 /* i18n-hint files that can be run as programs */
385 type = { XO("Executables"), { ext } };
386 #endif
387
388 path = SelectFile(FileNames::Operation::Open,
389 XO("Find path to command"),
390 wxEmptyString,
391 wxEmptyString,
392 ext,
393 { type },
394 wxFD_OPEN | wxRESIZE_BORDER,
395 mParent);
396 if (path.empty()) {
397 return;
398 }
399
400 if (path.Find(wxT(' ')) != wxNOT_FOUND)
401 path = wxT('"') + path + wxT('"');
402
403 mCommandBox->SetValue(path);
404 mCommandBox->SetInsertionPointEnd();
405 }
wxString FileExtension
File extension, not including any leading dot.
Definition: Identifier.h:224
FilePath SelectFile(FileNames::Operation op, const TranslatableString &message, const FilePath &default_path, const FilePath &default_filename, const FileExtension &default_extension, const FileTypes &fileTypes, int flags, wxWindow *parent)
Definition: SelectFile.cpp:17
wxComboBox * mCommandBox
Definition: ExportCL.cpp:408
FILES_API const FileType AllFiles
Definition: FileNames.h:70

References FileNames::AllFiles, mCommandBox, mParent, SelectFile(), wxT(), and XO().

Referenced by PopulateUI().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PopulateUI()

void ExportOptionsCLEditor::PopulateUI ( ShuttleGui S)
inlineoverridevirtual

Implements ExportOptionsUIServices.

Definition at line 181 of file ExportCL.cpp.

182 {
183 if(!mInitialized)
184 {
185 mHistory.Load(*gPrefs, wxT("/FileFormats/ExternalProgramHistory"));
186
187 if (mHistory.empty()) {
188 mHistory.Append(wxT("ffmpeg -i - \"%f.opus\""));
189 mHistory.Append(wxT("ffmpeg -i - \"%f.wav\""));
190 mHistory.Append(wxT("ffmpeg -i - \"%f\""));
191 mHistory.Append(wxT("lame - \"%f\""));
192 }
193
194 if(!mCommand.empty())
196
197 mInitialized = true;
198 }
199
200 mParent = wxGetTopLevelParent(S.GetParent());
201
203 auto cmd = cmds[0];
204
205 S.StartVerticalLay();
206 {
207 S.StartHorizontalLay(wxEXPAND);
208 {
209 S.SetSizerProportion(1);
210 S.StartMultiColumn(3, wxEXPAND);
211 {
212 S.SetStretchyCol(1);
213 mCommandBox = S.AddCombo(XXO("Command:"),
214 cmd,
215 cmds);
216 mCommandBox->Bind(wxEVT_TEXT, [this](wxCommandEvent& event) {
217 mLastCommand = event.GetString();
218 });
219 mLastCommand = mCommandBox->GetValue();
220 mCommandBox->SetMaxSize(wxSize(50,400));
221
222 S.AddButton(XXO("Browse..."), wxALIGN_CENTER_VERTICAL)
223 ->Bind(wxEVT_BUTTON, &ExportOptionsCLEditor::OnBrowse, this);
224
225 S.AddFixedText( {} );
226 S.TieCheckBox(XXO("Show output"), mShowOutput);
227 }
228 S.EndMultiColumn();
229 }
230 S.EndHorizontalLay();
231
232 S.AddTitle(XO(
233 /* i18n-hint: Some programmer-oriented terminology here:
234 "Data" refers to the sound to be exported, "piped" means sent,
235 and "standard in" means the default input stream that the external program,
236 named by %f, will read. And yes, it's %f, not %s -- this isn't actually used
237 in the program as a format string. Keep %f unchanged. */
238 "Data will be piped to standard in. \"%f\" uses the file name in the export window."), 250);
239 }
240 S.EndVerticalLay();
241 }
XXO("&Cut/Copy/Paste Toolbar")
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
#define S(N)
Definition: ToChars.cpp:64
FileHistory mHistory
Definition: ExportCL.cpp:415
void OnBrowse(const wxCommandEvent &)
Definition: ExportCL.cpp:376
const_iterator begin() const
Definition: FileHistory.h:60
bool empty() const
Definition: FileHistory.h:63
void Load(audacity::BasicSettings &config, const wxString &group=wxEmptyString)
void Append(const FilePath &file)
Definition: FileHistory.h:46
const_iterator end() const
Definition: FileHistory.h:61
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.

References FileHistory::Append(), FileHistory::begin(), FileHistory::empty(), FileHistory::end(), gPrefs, FileHistory::Load(), mCommand, mCommandBox, mHistory, mInitialized, mLastCommand, mParent, mShowOutput, OnBrowse(), S, wxT(), XO(), and XXO().

Here is the call graph for this function:

◆ SetValue()

bool ExportOptionsCLEditor::SetValue ( int  id,
const ExportValue value 
)
inlineoverridevirtual

Implements ExportOptionsEditor.

Definition at line 347 of file ExportCL.cpp.

348 {
349 if(id == CLOptionIDCommand && std::holds_alternative<std::string>(value))
350 {
351 mCommand = wxString::FromUTF8(*std::get_if<std::string>(&value));
352 return true;
353 }
354 if(id == CLOptionIDShowOutput && std::holds_alternative<bool>(value))
355 {
356 mShowOutput = *std::get_if<bool>(&value);
357 return true;
358 }
359 return false;
360 }

References CLOptionIDCommand, CLOptionIDShowOutput, mCommand, and mShowOutput.

◆ Store()

void ExportOptionsCLEditor::Store ( audacity::BasicSettings config) const
inlineoverridevirtual

Implements ExportOptionsEditor.

Definition at line 368 of file ExportCL.cpp.

369 {
370 config.Write(wxT("/FileFormats/ExternalProgramExportCommand"), mCommand);
371 config.Write(wxT("/FileFormats/ExternalProgramShowOutput"), mShowOutput);
372 }
virtual bool Write(const wxString &key, bool value)=0

References mCommand, mShowOutput, audacity::BasicSettings::Write(), and wxT().

Here is the call graph for this function:

◆ TransferDataFromWindow()

bool ExportOptionsCLEditor::TransferDataFromWindow ( )
inlineoverridevirtual

Implements ExportOptionsUIServices.

Definition at line 300 of file ExportCL.cpp.

301 {
303 {
307 return true;
308 }
309 return false;
310 }
static bool IsValidCommand(const wxString &command)
Definition: ExportCL.cpp:243
void Save(audacity::BasicSettings &config)

References FileHistory::Append(), gPrefs, IsValidCommand(), mCommand, mHistory, mLastCommand, and FileHistory::Save().

Here is the call graph for this function:

Member Data Documentation

◆ mCommand

wxString ExportOptionsCLEditor::mCommand {wxT("lame - \"%f\"")}
private

Definition at line 174 of file ExportCL.cpp.

Referenced by GetValue(), Load(), PopulateUI(), SetValue(), Store(), and TransferDataFromWindow().

◆ mCommandBox

wxComboBox* ExportOptionsCLEditor::mCommandBox {nullptr}
private

Definition at line 408 of file ExportCL.cpp.

Referenced by OnBrowse(), and PopulateUI().

◆ mHistory

FileHistory ExportOptionsCLEditor::mHistory
private

Definition at line 415 of file ExportCL.cpp.

Referenced by PopulateUI(), and TransferDataFromWindow().

◆ mInitialized

bool ExportOptionsCLEditor::mInitialized {false}
private

Definition at line 176 of file ExportCL.cpp.

Referenced by PopulateUI().

◆ mLastCommand

wxString ExportOptionsCLEditor::mLastCommand
private

Definition at line 413 of file ExportCL.cpp.

Referenced by PopulateUI(), and TransferDataFromWindow().

◆ mParent

wxWindow* ExportOptionsCLEditor::mParent {nullptr}
private

Definition at line 407 of file ExportCL.cpp.

Referenced by OnBrowse(), and PopulateUI().

◆ mShowOutput

bool ExportOptionsCLEditor::mShowOutput {false}
private

Definition at line 175 of file ExportCL.cpp.

Referenced by GetValue(), Load(), PopulateUI(), SetValue(), and Store().


The documentation for this class was generated from the following file: