Audacity  3.0.3
OpenSaveCommands.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity - A Digital Audio Editor
4  Copyright 1999-2018 Audacity Team
5  File License: wxWidgets
6 
7  Stephen Parry
8  James Crook
9 
10 ******************************************************************//*******************************************************************/
16 
17 
18 #include "OpenSaveCommands.h"
19 
20 #include "LoadCommands.h"
21 #include "../AudacityLogger.h"
22 #include "../Project.h"
23 #include "../ProjectFileIO.h"
24 #include "../ProjectFileManager.h"
25 #include "../ProjectManager.h"
26 #include "../export/Export.h"
27 #include "../Shuttle.h"
28 #include "../ShuttleGui.h"
29 #include "CommandContext.h"
30 
31 
33 { XO("Open Project2") };
34 
36 
38  S.Define( mFileName, wxT("Filename"), "test.aup3" );
39  S.OptionalN(bHasAddToHistory).Define( mbAddToHistory, wxT("AddToHistory"), false );
40  return true;
41 }
42 
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 }
54 
56 
57  auto &projectFileIO = ProjectFileIO::Get(context.project);
58 
59  auto oldFileName = projectFileIO.GetFileName();
60  if(mFileName.empty())
61  {
62  auto project = &context.project;
64  }
65  else
66  {
69  }
70  const auto &newFileName = projectFileIO.GetFileName();
71 
72  // Because Open does not return a success or failure, we have to guess
73  // at this point, based on whether the project file name has
74  // changed and what to...
75  return !newFileName.empty() && newFileName != oldFileName;
76 }
77 
79 { XO("Save Project2") };
80 
82 
84  S.Define( mFileName, wxT("Filename"), "name.aup3" );
85  S.Define( mbAddToHistory, wxT("AddToHistory"), false );
86  return true;
87 }
88 
90 {
91  S.AddSpace(0, 5);
92 
93  S.StartMultiColumn(2, wxALIGN_CENTER);
94  {
95  S.TieTextBox(XXO("File Name:"),mFileName);
96  S.TieCheckBox(XXO("Add to History"), mbAddToHistory );
97  }
98  S.EndMultiColumn();
99 }
100 
102 {
103  auto &projectFileManager = ProjectFileManager::Get( context.project );
104  if ( mFileName.empty() )
105  return projectFileManager.SaveAs();
106  else
107  return projectFileManager.SaveAs(mFileName, mbAddToHistory);
108 }
109 
111 { XO("Save Copy") };
112 
114 
116  S.Define( mFileName, wxT("Filename"), "name.aup3" );
117  return true;
118 }
119 
121 {
122  S.AddSpace(0, 5);
123 
124  S.StartMultiColumn(2, wxALIGN_CENTER);
125  {
126  S.TieTextBox(XXO("File Name:"),mFileName);
127  }
128  S.EndMultiColumn();
129 }
130 
132 {
133  auto &projectFileManager = ProjectFileManager::Get( context.project );
134  return projectFileManager.SaveCopy(mFileName);
135 }
136 
138 { XO("Save Log") };
139 
141 
143 {
144  S.Define( mFileName, wxT("Filename"), "log.txt" );
145  return true;
146 }
147 
149 {
150  S.AddSpace(0, 5);
151 
152  S.StartMultiColumn(2, wxALIGN_CENTER);
153  {
154  S.TieTextBox(XXO("File Name:"),mFileName);
155  }
156  S.EndMultiColumn();
157 }
158 
160 {
161  auto logger = AudacityLogger::Get();
162  return logger->SaveLog(mFileName);
163 }
164 
166 { XO("Clear Log") };
167 
169 
171 {
172  return true;
173 }
174 
175 bool ClearLogCommand::PromptUser(wxWindow *parent)
176 {
177  return true;
178 }
179 
181 {
182  auto logger = AudacityLogger::Get();
183  return logger->ClearLog();
184 }
SaveProjectCommand::DefineParams
bool DefineParams(ShuttleParams &S) override
Definition: OpenSaveCommands.cpp:83
anonymous_namespace{OpenSaveCommands.cpp}::reg2
BuiltinCommandsModule::Registration< SaveProjectCommand > reg2
Definition: OpenSaveCommands.cpp:81
anonymous_namespace{OpenSaveCommands.cpp}::reg5
BuiltinCommandsModule::Registration< ClearLogCommand > reg5
Definition: OpenSaveCommands.cpp:168
LoadCommands.h
OpenProjectCommand::Symbol
static const ComponentInterfaceSymbol Symbol
Definition: OpenSaveCommands.h:33
OpenProjectCommand::bHasAddToHistory
bool bHasAddToHistory
Definition: OpenSaveCommands.h:47
SaveProjectCommand::Symbol
static const ComponentInterfaceSymbol Symbol
Definition: OpenSaveCommands.h:53
ShuttleGuiBase::TieCheckBox
wxCheckBox * TieCheckBox(const TranslatableString &Prompt, bool &Var)
Definition: ShuttleGui.cpp:1603
ShuttleGui::AddSpace
wxSizerItem * AddSpace(int width, int height, int prop=0)
Definition: ShuttleGui.cpp:2421
OpenProjectCommand::mFileName
wxString mFileName
Definition: OpenSaveCommands.h:43
ProjectFileManager::OpenFile
void OpenFile(const FilePath &fileName, bool addtohistory=true)
Definition: ProjectFileManager.cpp:867
XO
#define XO(s)
Definition: Internat.h:32
ProjectFileIO::Get
static ProjectFileIO & Get(AudacityProject &project)
Definition: ProjectFileIO.cpp:267
ShuttleParams
Shuttle that deals with parameters. This is a base class with lots of virtual functions that do nothi...
Definition: Shuttle.h:61
OpenProjectCommand::PopulateOrExchange
void PopulateOrExchange(ShuttleGui &S) override
Definition: OpenSaveCommands.cpp:43
ShuttleGuiBase::EndMultiColumn
void EndMultiColumn()
Definition: ShuttleGui.cpp:1212
ClearLogCommand::DefineParams
bool DefineParams(ShuttleParams &S) override
Definition: OpenSaveCommands.cpp:170
OpenProjectCommand::DefineParams
bool DefineParams(ShuttleParams &S) override
Definition: OpenSaveCommands.cpp:37
ComponentInterfaceSymbol
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Definition: ComponentInterface.h:60
SaveCopyCommand::mFileName
wxString mFileName
Definition: OpenSaveCommands.h:83
ShuttleParams::OptionalN
virtual ShuttleParams & OptionalN(bool &var)
Definition: Shuttle.h:71
ShuttleGuiBase::TieTextBox
wxTextCtrl * TieTextBox(const TranslatableString &Caption, wxString &Value, const int nChars=0)
Definition: ShuttleGui.cpp:1626
ClearLogCommand::Apply
bool Apply(const CommandContext &context) override
Definition: OpenSaveCommands.cpp:180
BuiltinCommandsModule::Registration
Definition: LoadCommands.h:41
anonymous_namespace{OpenSaveCommands.cpp}::reg3
BuiltinCommandsModule::Registration< SaveCopyCommand > reg3
Definition: OpenSaveCommands.cpp:113
CommandContext.h
XXO
#define XXO(s)
Definition: Internat.h:45
CommandContext
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
Definition: CommandContext.h:22
ProjectFileManager::Get
static ProjectFileManager & Get(AudacityProject &project)
Definition: ProjectFileManager.cpp:56
ShuttleGuiBase::StartMultiColumn
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
Definition: ShuttleGui.cpp:1203
SaveCopyCommand::DefineParams
bool DefineParams(ShuttleParams &S) override
Definition: OpenSaveCommands.cpp:115
SaveLogCommand::Symbol
static const ComponentInterfaceSymbol Symbol
Definition: OpenSaveCommands.h:91
AudacityLogger::Get
static AudacityLogger * Get()
Definition: AudacityLogger.cpp:58
SaveLogCommand::Apply
bool Apply(const CommandContext &context) override
Definition: OpenSaveCommands.cpp:159
SaveCopyCommand::PopulateOrExchange
void PopulateOrExchange(ShuttleGui &S) override
Definition: OpenSaveCommands.cpp:120
OpenProjectCommand::Apply
bool Apply(const CommandContext &context) override
Definition: OpenSaveCommands.cpp:55
SaveCopyCommand::Symbol
static const ComponentInterfaceSymbol Symbol
Definition: OpenSaveCommands.h:73
SaveProjectCommand::mbAddToHistory
bool mbAddToHistory
Definition: OpenSaveCommands.h:66
SaveProjectCommand::Apply
bool Apply(const CommandContext &context) override
Definition: OpenSaveCommands.cpp:101
ClearLogCommand::PromptUser
bool PromptUser(wxWindow *parent) override
Definition: OpenSaveCommands.cpp:175
anonymous_namespace{OpenSaveCommands.cpp}::reg4
BuiltinCommandsModule::Registration< SaveLogCommand > reg4
Definition: OpenSaveCommands.cpp:140
SaveProjectCommand::mFileName
wxString mFileName
Definition: OpenSaveCommands.h:63
ProjectManager::OpenFiles
static void OpenFiles(AudacityProject *proj)
Definition: ProjectManager.cpp:855
ClearLogCommand::Symbol
static const ComponentInterfaceSymbol Symbol
Definition: OpenSaveCommands.h:109
SaveProjectCommand::PopulateOrExchange
void PopulateOrExchange(ShuttleGui &S) override
Definition: OpenSaveCommands.cpp:89
SaveLogCommand::DefineParams
bool DefineParams(ShuttleParams &S) override
Definition: OpenSaveCommands.cpp:142
SaveCopyCommand::Apply
bool Apply(const CommandContext &context) override
Definition: OpenSaveCommands.cpp:131
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
OpenSaveCommands.h
OpenProjectCommand::mbAddToHistory
bool mbAddToHistory
Definition: OpenSaveCommands.h:46
anonymous_namespace{OpenSaveCommands.cpp}::reg
BuiltinCommandsModule::Registration< OpenProjectCommand > reg
Definition: OpenSaveCommands.cpp:35
SaveLogCommand::PopulateOrExchange
void PopulateOrExchange(ShuttleGui &S) override
Definition: OpenSaveCommands.cpp:148
CommandContext::project
AudacityProject & project
Definition: CommandContext.h:52
ShuttleGui
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:638
SaveLogCommand::mFileName
wxString mFileName
Definition: OpenSaveCommands.h:101