Audacity 3.2.0
ImportExportPrefs.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 ImportExportPrefs.cpp
6
7 Joshua Haberman
8 Dominic Mazzoni
9 James Crook
10
11*******************************************************************//*******************************************************************/
17
18
19#include "ImportExportPrefs.h"
20
21#include <wx/defs.h>
22#include <wx/statbox.h>
23#include <wx/stattext.h>
24
25#include "NoteTrack.h"
26#include "Prefs.h"
27#include "ShuttleGui.h"
28#include "WindowAccessible.h"
29
30static const auto PathStart = wxT("ImportExportPreferences");
31
34{
35 static Registry::GroupItem<Traits> registry{ PathStart };
36 return registry;
37}
38
40 const Identifier &id, Populator populator)
41 : SingleItem{ id }
42 , mPopulator{ move(populator) }
43{}
44
46 const Identifier &id, Populator populator,
47 const Registry::Placement &placement )
48 : RegisteredItem{
49 std::make_unique<PopulatorItem>(id, move(populator)),
50 placement
51 }
52{}
53
55{
56 return !PopulatorItem::Registry().empty();
57}
58
59ImportExportPrefs::ImportExportPrefs(wxWindow * parent, wxWindowID winid)
60: PrefsPanel(parent, winid, XO("Import / Export"))
61{
62 Populate();
63}
64
66{
67}
68
70{
72}
73
75{
76 return XO("Preferences for ImportExport");
77}
78
80{
81 return "Import_-_Export_Preferences";
82}
83
86{
87 //------------------------- Main section --------------------
88 // Now construct the GUI itself.
89 // Use 'eIsCreatingFromPrefs' so that the GUI is
90 // initialised with values from gPrefs.
93 // ----------------------- End of main section --------------
94}
95
97 wxT("/FileFormats/MusicFileImportSettingChoice"),
98 {
99 /* i18n-hint: The music theory "beat" */
101 wxT("Yes"),
102 XXO(
103 "S&witch view to Beats and Measures and align with musical grid") },
104 EnumValueSymbol { wxT("Ask"), XXO("&Ask me each time") },
105 EnumValueSymbol { wxT("No"), XXO("Do &nothing") },
106 },
107 1,
108 { false, true, false },
109 wxT("/FileFormats/MusicFileImportSetting"),
110};
111
113{
114 S.SetBorder(2);
115 S.StartScroller();
116
117 // Add registered controls
118 using namespace Registry;
120 PathStart,
121 { {wxT(""), wxT("LabelStyle,AllegroTimeOption") } },
122 };
123
124 // visit the registry to collect the plug-ins properly
125 // sorted
128 [&](const PopulatorItem &item, auto &) { item.mPopulator(S); },
129 &top, &PopulatorItem::Registry());
130
131
132 auto musicImportsBox = S.StartStatic(XO("Music Imports"));
133 {
134 const auto header = S.AddVariableText(
135 XO("When Audacity detects music in file imported on empty project"));
136#if wxUSE_ACCESSIBILITY
137 if (musicImportsBox != nullptr)
138 {
139 musicImportsBox->SetName(header->GetLabel());
140 safenew WindowAccessible(musicImportsBox);
141 }
142#endif
143#if defined(__WXMAC__)
144 // see https://bugzilla.audacityteam.org/show_bug.cgi?id=2692
145 S.StartPanel();
146#endif
147 {
148 S.StartRadioButtonGroup(ImportExportPrefs::MusicFileImportSetting);
149 {
150 S.TieRadioButton();
151 S.TieRadioButton();
152 S.TieRadioButton();
153 }
154 S.EndRadioButtonGroup();
155 }
156#if defined(__WXMAC__)
157 S.EndPanel();
158#endif
159 }
160 S.EndStatic();
161
162 S.EndScroller();
163}
164
166{
169
170 return true;
171}
172
173namespace {
175 [](wxWindow *parent, wxWindowID winid, AudacityProject *) -> PrefsPanel *
176 {
177 wxASSERT(parent); // to justify safenew
179 return safenew ImportExportPrefs(parent, winid);
180 else
181 return nullptr;
182 },
183 false,
184 // Register with an explicit ordering hint because this one might be
185 // absent
186 { "", { Registry::OrderingHint::After, "Tracks" } }
187};
188}
189
191{
193}
wxT("CloseDown"))
XO("Cut/Copy/Paste")
XXO("&Cut/Copy/Paste Toolbar")
static const auto PathStart
#define IMPORT_EXPORT_PREFS_PLUGIN_SYMBOL
#define safenew
Definition: MemoryX.h:10
@ eIsCreatingFromPrefs
Definition: ShuttleGui.h:46
@ eIsSavingToPrefs
Definition: ShuttleGui.h:47
#define S(N)
Definition: ToChars.cpp:64
int id
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
An explicitly nonlocalized string, not meant for the user to see.
Definition: Identifier.h:22
A PrefsPanel used to select import and export options.
void Populate()
Creates the dialog and its contents.
ImportExportPrefs(wxWindow *parent, wxWindowID winid)
bool Commit() override
void PopulateOrExchange(ShuttleGui &S) override
static EnumSetting< bool > MusicFileImportSetting
ManualPageID HelpPageName() override
If not empty string, the Help button is added below the panel.
std::function< void(ShuttleGui &)> Populator
Type of function that adds to the Import/Export preference page.
TranslatableString GetDescription() const override
ComponentInterfaceSymbol GetSymbol() const override
Base class for a panel in the PrefsDialog. Classes derived from this class include BatchPrefs,...
Definition: PrefsPanel.h:51
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:640
Holds a msgid for the translation catalog; may also bind format arguments.
An alternative to using wxWindowAccessible, which in wxWidgets 3.1.1 contained GetParent() which was ...
void Visit(const Visitors &visitors, const GroupItem< RegistryTraits > *pTopItem, const GroupItem< RegistryTraits > *pRegistry={}, typename RegistryTraits::ComputedItemContextType &computedItemContext=RegistryTraits::ComputedItemContextType::Instance)
Definition: Registry.h:609
STL namespace.
static Registry::GroupItem< Traits > & Registry()
PopulatorItem(const Identifier &id, Populator populator)
RegisteredControls(const Identifier &id, Populator populator, const Registry::Placement &placement={ wxEmptyString, {} })