Audacity  3.0.3
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
OpenProjectCommand Class Reference

Command for opening an Audacity project. More...

#include <OpenSaveCommands.h>

Inheritance diagram for OpenProjectCommand:
[legend]
Collaboration diagram for OpenProjectCommand:
[legend]

Public Member Functions

ComponentInterfaceSymbol GetSymbol () override
 
TranslatableString GetDescription () override
 
bool DefineParams (ShuttleParams &S) override
 
void PopulateOrExchange (ShuttleGui &S) override
 
bool Apply (const CommandContext &context) override
 
ManualPageID ManualPage () override
 
- Public Member Functions inherited from AudacityCommand
 AudacityCommand ()
 
virtual ~AudacityCommand ()
 
PluginPath GetPath () override
 
VendorSymbol GetVendor () override
 
wxString GetVersion () override
 
virtual bool IsBatchProcessing ()
 
virtual void SetBatchProcessing (bool start)
 
virtual bool Apply (const CommandContext &WXUNUSED(context))
 
bool ShowInterface (wxWindow *parent, bool forceModal=false)
 
virtual void SetHostUI (EffectUIHostInterface *WXUNUSED(host))
 
wxDialog * CreateUI (wxWindow *parent, AudacityCommand *client)
 
virtual bool GetAutomationParameters (wxString &parms)
 
virtual bool SetAutomationParameters (const wxString &parms)
 
bool DoAudacityCommand (wxWindow *parent, const CommandContext &context, bool shouldPrompt=true)
 
int MessageBox (const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={})
 
virtual bool Init ()
 
virtual bool PromptUser (wxWindow *parent)
 
virtual bool CheckWhetherSkipAudacityCommand ()
 
virtual void End ()
 
virtual void PopulateOrExchange (ShuttleGui &WXUNUSED(S))
 
virtual bool TransferDataToWindow ()
 
virtual bool TransferDataFromWindow ()
 
- Public Member Functions inherited from ComponentInterface
virtual ~ComponentInterface ()
 
TranslatableString GetName ()
 
virtual bool DefineParams (ShuttleParams &WXUNUSED(S))
 

Public Attributes

wxString mFileName
 
bool mbAddToHistory
 
bool bHasAddToHistory
 

Static Public Attributes

static const ComponentInterfaceSymbol Symbol { XO("Open Project2") }
 

Additional Inherited Members

- Public Types inherited from AudacityCommand
enum  : long { DefaultMessageBoxStyle = wxOK | wxCENTRE }
 
using VetoDialogHook = bool(*)(wxDialog *)
 
- Static Public Member Functions inherited from AudacityCommand
static VetoDialogHook SetVetoDialogHook (VetoDialogHook hook)
 
- Protected Attributes inherited from AudacityCommand
ProgressDialogmProgress
 
wxDialog * mUIDialog
 
wxWindow * mUIParent
 
int mUIResultID
 

Detailed Description

Command for opening an Audacity project.

Definition at line 30 of file OpenSaveCommands.h.

Member Function Documentation

◆ Apply()

bool OpenProjectCommand::Apply ( const CommandContext context)
override

Definition at line 55 of file OpenSaveCommands.cpp.

55  {
56 
57  auto &projectFileIO = ProjectFileIO::Get(context.project);
58 
59  auto oldFileName = projectFileIO.GetFileName();
60  if(mFileName.empty())
61  {
62  // This path queries the user for files to open
63  auto project = &context.project;
65  }
66  else
67  {
68  ProjectManager::ProjectChooser chooser{ &context.project, true };
70  std::ref(chooser), mFileName, mbAddToHistory))
71  chooser.Commit();
72  }
73  const auto &newFileName = projectFileIO.GetFileName();
74 
75  // Because Open does not return a success or failure, we have to guess
76  // at this point, based on whether the project file name has
77  // changed and what to...
78  return !newFileName.empty() && newFileName != oldFileName;
79 }

References ProjectFileIO::Get(), mbAddToHistory, mFileName, ProjectFileManager::OpenFile(), ProjectManager::OpenFiles(), and CommandContext::project.

Here is the call graph for this function:

◆ DefineParams()

bool OpenProjectCommand::DefineParams ( ShuttleParams S)
override

Definition at line 37 of file OpenSaveCommands.cpp.

37  {
38  S.Define( mFileName, wxT("Filename"), "test.aup3" );
39  S.OptionalN(bHasAddToHistory).Define( mbAddToHistory, wxT("AddToHistory"), false );
40  return true;
41 }

References bHasAddToHistory, ShuttleParams::Define(), mbAddToHistory, mFileName, and ShuttleParams::OptionalN().

Here is the call graph for this function:

◆ GetDescription()

TranslatableString OpenProjectCommand::GetDescription ( )
inlineoverridevirtual

Reimplemented from AudacityCommand.

Definition at line 37 of file OpenSaveCommands.h.

37 {return XO("Opens a project.");};

References XO.

◆ GetSymbol()

ComponentInterfaceSymbol OpenProjectCommand::GetSymbol ( )
inlineoverridevirtual

Implements AudacityCommand.

Definition at line 36 of file OpenSaveCommands.h.

36 {return Symbol;};

References Symbol.

◆ ManualPage()

ManualPageID OpenProjectCommand::ManualPage ( )
inlineoverridevirtual

Reimplemented from AudacityCommand.

Definition at line 43 of file OpenSaveCommands.h.

43 {return L"Extra_Menu:_Scriptables_II#open_project";}

◆ PopulateOrExchange()

void OpenProjectCommand::PopulateOrExchange ( ShuttleGui S)
override

Definition at line 43 of file OpenSaveCommands.cpp.

44 {
45  S.AddSpace(0, 5);
46 
47  S.StartMultiColumn(2, wxALIGN_CENTER);
48  {
49  S.TieTextBox(XXO("File Name:"),mFileName);
50  S.TieCheckBox(XXO("Add to History"), mbAddToHistory );
51  }
52  S.EndMultiColumn();
53 }

References ShuttleGui::AddSpace(), ShuttleGuiBase::EndMultiColumn(), mbAddToHistory, mFileName, ShuttleGuiBase::StartMultiColumn(), ShuttleGuiBase::TieCheckBox(), ShuttleGuiBase::TieTextBox(), and XXO.

Here is the call graph for this function:

Member Data Documentation

◆ bHasAddToHistory

bool OpenProjectCommand::bHasAddToHistory

Definition at line 47 of file OpenSaveCommands.h.

Referenced by DefineParams().

◆ mbAddToHistory

bool OpenProjectCommand::mbAddToHistory

Definition at line 46 of file OpenSaveCommands.h.

Referenced by Apply(), DefineParams(), and PopulateOrExchange().

◆ mFileName

wxString OpenProjectCommand::mFileName

Definition at line 45 of file OpenSaveCommands.h.

Referenced by Apply(), DefineParams(), and PopulateOrExchange().

◆ Symbol

const ComponentInterfaceSymbol OpenProjectCommand::Symbol { XO("Open Project2") }
static

Definition at line 33 of file OpenSaveCommands.h.

Referenced by GetSymbol().


The documentation for this class was generated from the following files:
OpenProjectCommand::Symbol
static const ComponentInterfaceSymbol Symbol
Definition: OpenSaveCommands.h:33
OpenProjectCommand::bHasAddToHistory
bool bHasAddToHistory
Definition: OpenSaveCommands.h:47
ShuttleGuiBase::TieCheckBox
wxCheckBox * TieCheckBox(const TranslatableString &Prompt, bool &Var)
Definition: ShuttleGui.cpp:1629
ProjectFileManager::OpenFile
static AudacityProject * OpenFile(const ProjectChooserFn &chooser, const FilePath &fileName, bool addtohistory=true)
Definition: ProjectFileManager.cpp:869
ProjectManager::ProjectChooser
Callable object that supplies the chooser argument of ProjectFileManager::OpenFile.
Definition: ProjectManager.h:63
ShuttleGui::AddSpace
wxSizerItem * AddSpace(int width, int height, int prop=0)
Definition: ShuttleGui.cpp:2459
OpenProjectCommand::mFileName
wxString mFileName
Definition: OpenSaveCommands.h:45
XO
#define XO(s)
Definition: Internat.h:31
ProjectFileIO::Get
static ProjectFileIO & Get(AudacityProject &project)
Definition: ProjectFileIO.cpp:265
ShuttleGuiBase::EndMultiColumn
void EndMultiColumn()
Definition: ShuttleGui.cpp:1238
ShuttleParams::OptionalN
virtual ShuttleParams & OptionalN(bool &var)
Definition: Shuttle.h:72
ShuttleGuiBase::TieTextBox
wxTextCtrl * TieTextBox(const TranslatableString &Caption, wxString &Value, const int nChars=0)
Definition: ShuttleGui.cpp:1652
XXO
#define XXO(s)
Definition: Internat.h:44
ShuttleGuiBase::StartMultiColumn
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
Definition: ShuttleGui.cpp:1229
ProjectManager::OpenFiles
static void OpenFiles(AudacityProject *proj)
Definition: ProjectManager.cpp:866
ShuttleParams::Define
virtual void Define(bool &var, const wxChar *key, const bool vdefault, const bool vmin=false, const bool vmax=false, const bool vscl=false)
Definition: Shuttle.cpp:332
OpenProjectCommand::mbAddToHistory
bool mbAddToHistory
Definition: OpenSaveCommands.h:46
CommandContext::project
AudacityProject & project
Definition: CommandContext.h:64