mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-22 07:10:06 +02:00
Pass AudacityProject * into preference panel factories
This commit is contained in:
parent
72f66b7096
commit
c9a9c06bd0
@ -1658,8 +1658,9 @@ bool AudacityApp::OnInit()
|
||||
// Only want one page of the preferences
|
||||
PrefsDialog::Factories factories;
|
||||
factories.push_back(KeyConfigPrefsFactory( id ));
|
||||
auto pWindow = FindProjectFrame( GetActiveProject() );
|
||||
GlobalPrefsDialog dialog( pWindow, factories );
|
||||
const auto pProject = GetActiveProject();
|
||||
auto pWindow = FindProjectFrame( pProject );
|
||||
GlobalPrefsDialog dialog( pWindow, pProject, factories );
|
||||
dialog.ShowModal();
|
||||
MenuCreator::RebuildAllMenuBars();
|
||||
return true;
|
||||
@ -1796,7 +1797,7 @@ bool AudacityApp::InitTempDir()
|
||||
// Only want one page of the preferences
|
||||
PrefsDialog::Factories factories;
|
||||
factories.push_back(DirectoriesPrefsFactory());
|
||||
GlobalPrefsDialog dialog(NULL, factories);
|
||||
GlobalPrefsDialog dialog(nullptr, nullptr, factories);
|
||||
dialog.ShowModal();
|
||||
|
||||
AudacityMessageBox(XO(
|
||||
@ -2248,7 +2249,7 @@ void AudacityApp::OnMenuPreferences(wxCommandEvent & event)
|
||||
// all platforms.
|
||||
|
||||
if(AllProjects{}.empty()) {
|
||||
GlobalPrefsDialog dialog(NULL /* parent */ );
|
||||
GlobalPrefsDialog dialog(nullptr /* parent */, nullptr );
|
||||
dialog.ShowModal();
|
||||
}
|
||||
else
|
||||
|
@ -362,7 +362,7 @@ bool GetInfoCommand::SendPreferences(const CommandContext &context)
|
||||
{
|
||||
context.StartArray();
|
||||
auto pWin = &GetProjectFrame( context.project );
|
||||
GlobalPrefsDialog dialog( pWin );
|
||||
GlobalPrefsDialog dialog( pWin, &context.project );
|
||||
// wxCommandEvent Evt;
|
||||
//dialog.Show();
|
||||
ShuttleGuiGetDefinition S(pWin, *((context.pOutput)->mStatusTarget) );
|
||||
|
@ -933,7 +933,7 @@ void OnPreferences(const CommandContext &context)
|
||||
{
|
||||
auto &project = context.project;
|
||||
|
||||
GlobalPrefsDialog dialog(&GetProjectFrame( project ) /* parent */ );
|
||||
GlobalPrefsDialog dialog(&GetProjectFrame( project ) /* parent */, &project );
|
||||
|
||||
if( ScreenshotCommand::MayCapture( &dialog ) )
|
||||
return;
|
||||
|
@ -96,7 +96,7 @@ BatchPrefs::~BatchPrefs()
|
||||
}
|
||||
|
||||
PrefsPanel::Factory
|
||||
BatchPrefsFactory = [](wxWindow *parent, wxWindowID winid)
|
||||
BatchPrefsFactory = [](wxWindow *parent, wxWindowID winid, AudacityProject *)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew BatchPrefs(parent, winid);
|
||||
|
@ -423,7 +423,7 @@ bool DevicePrefs::Commit()
|
||||
}
|
||||
|
||||
PrefsPanel::Factory
|
||||
DevicePrefsFactory = [](wxWindow *parent, wxWindowID winid)
|
||||
DevicePrefsFactory = [](wxWindow *parent, wxWindowID winid, AudacityProject *)
|
||||
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
|
@ -292,7 +292,7 @@ bool DirectoriesPrefs::Commit()
|
||||
|
||||
PrefsPanel::Factory
|
||||
DirectoriesPrefsFactory() {
|
||||
return [](wxWindow *parent, wxWindowID winid)
|
||||
return [](wxWindow *parent, wxWindowID winid, AudacityProject *)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew DirectoriesPrefs(parent, winid);
|
||||
|
@ -251,7 +251,7 @@ bool EffectsPrefs::Commit()
|
||||
}
|
||||
|
||||
PrefsPanel::Factory
|
||||
EffectsPrefsFactory = [](wxWindow *parent, wxWindowID winid)
|
||||
EffectsPrefsFactory = [](wxWindow *parent, wxWindowID winid, AudacityProject *)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew EffectsPrefs(parent, winid);
|
||||
|
@ -827,7 +827,7 @@ void ExtImportPrefsDropTarget::OnLeave()
|
||||
}
|
||||
|
||||
PrefsPanel::Factory
|
||||
ExtImportPrefsFactory = [](wxWindow *parent, wxWindowID winid)
|
||||
ExtImportPrefsFactory = [](wxWindow *parent, wxWindowID winid, AudacityProject *)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew ExtImportPrefs(parent, winid);
|
||||
|
@ -378,7 +378,7 @@ int ShowClippingPrefsID()
|
||||
}
|
||||
|
||||
PrefsPanel::Factory
|
||||
GUIPrefsFactory = [](wxWindow *parent, wxWindowID winid)
|
||||
GUIPrefsFactory = [](wxWindow *parent, wxWindowID winid, AudacityProject *)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew GUIPrefs(parent, winid);
|
||||
|
@ -150,7 +150,7 @@ bool ImportExportPrefs::Commit()
|
||||
}
|
||||
|
||||
PrefsPanel::Factory
|
||||
ImportExportPrefsFactory = [](wxWindow *parent, wxWindowID winid)
|
||||
ImportExportPrefsFactory = [](wxWindow *parent, wxWindowID winid, AudacityProject *)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew ImportExportPrefs(parent, winid);
|
||||
|
@ -714,7 +714,7 @@ void KeyConfigPrefs::Cancel()
|
||||
PrefsPanel::Factory
|
||||
KeyConfigPrefsFactory( const CommandID &name )
|
||||
{
|
||||
return [=](wxWindow *parent, wxWindowID winid)
|
||||
return [=](wxWindow *parent, wxWindowID winid, AudacityProject *)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
auto result = safenew KeyConfigPrefs{ parent, winid, name };
|
||||
|
@ -262,7 +262,7 @@ bool LibraryPrefs::Commit()
|
||||
}
|
||||
|
||||
PrefsPanel::Factory
|
||||
LibraryPrefsFactory = [](wxWindow *parent, wxWindowID winid)
|
||||
LibraryPrefsFactory = [](wxWindow *parent, wxWindowID winid, AudacityProject *)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew LibraryPrefs(parent, winid);
|
||||
|
@ -302,7 +302,7 @@ bool MidiIOPrefs::Validate()
|
||||
}
|
||||
|
||||
PrefsPanel::Factory
|
||||
MidiIOPrefsFactory = [](wxWindow *parent, wxWindowID winid)
|
||||
MidiIOPrefsFactory = [](wxWindow *parent, wxWindowID winid, AudacityProject *)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew MidiIOPrefs(parent, winid);
|
||||
|
@ -188,7 +188,7 @@ void ModulePrefs::SetModuleStatus(const FilePath &fname, int iStatus){
|
||||
}
|
||||
|
||||
PrefsPanel::Factory
|
||||
ModulePrefsFactory = [](wxWindow *parent, wxWindowID winid)
|
||||
ModulePrefsFactory = [](wxWindow *parent, wxWindowID winid, AudacityProject *)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew ModulePrefs(parent, winid);
|
||||
|
@ -223,7 +223,7 @@ bool MousePrefs::Commit()
|
||||
}
|
||||
|
||||
PrefsPanel::Factory
|
||||
MousePrefsFactory = [](wxWindow *parent, wxWindowID winid)
|
||||
MousePrefsFactory = [](wxWindow *parent, wxWindowID winid, AudacityProject *)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew MousePrefs(parent, winid);
|
||||
|
@ -183,7 +183,7 @@ bool PlaybackPrefs::Commit()
|
||||
}
|
||||
|
||||
PrefsPanel::Factory
|
||||
PlaybackPrefsFactory = [](wxWindow *parent, wxWindowID winid)
|
||||
PlaybackPrefsFactory = [](wxWindow *parent, wxWindowID winid, AudacityProject *)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew PlaybackPrefs(parent, winid);
|
||||
|
@ -533,7 +533,7 @@ PrefsDialog::Factories
|
||||
|
||||
|
||||
PrefsDialog::PrefsDialog(
|
||||
wxWindow * parent,
|
||||
wxWindow * parent, AudacityProject *pProject,
|
||||
const TranslatableString &titlePrefix, Factories &factories)
|
||||
: wxDialogWrapper(parent, wxID_ANY, XO("Audacity Preferences"),
|
||||
wxDefaultPosition,
|
||||
@ -575,7 +575,7 @@ PrefsDialog::PrefsDialog(
|
||||
{
|
||||
const PrefsNode &node = *it;
|
||||
const PrefsPanel::Factory &factory = node.factory;
|
||||
wxWindow *const w = factory(mCategories, wxID_ANY);
|
||||
wxWindow *const w = factory(mCategories, wxID_ANY, pProject);
|
||||
if (stack.empty())
|
||||
// Parameters are: AddPage(page, name, IsSelected, imageId).
|
||||
mCategories->AddPage(w, w->GetName(), false, 0);
|
||||
@ -603,7 +603,7 @@ PrefsDialog::PrefsDialog(
|
||||
// Unique page, don't show the factory
|
||||
const PrefsNode &node = factories[0];
|
||||
const PrefsPanel::Factory &factory = node.factory;
|
||||
mUniquePage = factory(S.GetParent(), wxID_ANY);
|
||||
mUniquePage = factory(S.GetParent(), wxID_ANY, pProject);
|
||||
wxWindow * uniquePageWindow = S.Prop(1)
|
||||
.Position(wxEXPAND)
|
||||
.AddWindow(mUniquePage);
|
||||
@ -888,8 +888,9 @@ int PrefsDialog::GetSelectedPage() const
|
||||
return 0;
|
||||
}
|
||||
|
||||
GlobalPrefsDialog::GlobalPrefsDialog(wxWindow * parent, Factories &factories)
|
||||
: PrefsDialog(parent, XO("Preferences:"), factories)
|
||||
GlobalPrefsDialog::GlobalPrefsDialog(
|
||||
wxWindow * parent, AudacityProject *pProject, Factories &factories)
|
||||
: PrefsDialog(parent, pProject, XO("Preferences:"), factories)
|
||||
{
|
||||
}
|
||||
|
||||
@ -951,7 +952,8 @@ void DoReloadPreferences( AudacityProject &project )
|
||||
SpectrogramSettings::defaults().LoadPrefs();
|
||||
WaveformSettings::defaults().LoadPrefs();
|
||||
|
||||
GlobalPrefsDialog dialog(&GetProjectFrame( project ) /* parent */ );
|
||||
GlobalPrefsDialog dialog(
|
||||
&GetProjectFrame( project ) /* parent */, &project );
|
||||
wxCommandEvent Evt;
|
||||
//dialog.Show();
|
||||
dialog.OnOK(Evt);
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include <vector>
|
||||
#include "../widgets/wxPanelWrapper.h" // to inherit
|
||||
|
||||
class AudacityProject;
|
||||
class wxTreebook;
|
||||
class wxTreeEvent;
|
||||
class PrefsPanel;
|
||||
@ -27,13 +28,16 @@ class ShuttleGui;
|
||||
#define CONST const
|
||||
#endif
|
||||
|
||||
class AudacityProject;
|
||||
|
||||
class PrefsDialog /* not final */ : public wxDialogWrapper
|
||||
{
|
||||
public:
|
||||
// An array of PrefsNode specifies the tree of pages in pre-order traversal.
|
||||
struct PrefsNode {
|
||||
using Factory =
|
||||
std::function< PrefsPanel * (wxWindow *parent, wxWindowID winid) >;
|
||||
std::function< PrefsPanel * (
|
||||
wxWindow *parent, wxWindowID winid, AudacityProject *) >;
|
||||
Factory factory;
|
||||
CONST int nChildren;
|
||||
bool expanded;
|
||||
@ -48,6 +52,7 @@ class PrefsDialog /* not final */ : public wxDialogWrapper
|
||||
static Factories &DefaultFactories();
|
||||
|
||||
PrefsDialog(wxWindow * parent,
|
||||
AudacityProject *pProject, // may be null
|
||||
const TranslatableString &titlePrefix = XO("Preferences:"),
|
||||
Factories &factories = DefaultFactories());
|
||||
virtual ~PrefsDialog();
|
||||
@ -92,7 +97,9 @@ private:
|
||||
class GlobalPrefsDialog final : public PrefsDialog
|
||||
{
|
||||
public:
|
||||
GlobalPrefsDialog(wxWindow * parent, Factories &factories = DefaultFactories());
|
||||
GlobalPrefsDialog(
|
||||
wxWindow * parent, AudacityProject *pProject,
|
||||
Factories &factories = DefaultFactories());
|
||||
virtual ~GlobalPrefsDialog();
|
||||
long GetPreferredPage() override;
|
||||
void SavePreferredPage() override;
|
||||
|
@ -42,6 +42,7 @@ MousePrefs, QualityPrefs, SpectrumPrefs and ThemePrefs.
|
||||
#define TOP_LEVEL_BORDER 5
|
||||
#define GENERIC_CONTROL_BORDER 5
|
||||
|
||||
class AudacityProject;
|
||||
class ShuttleGui;
|
||||
|
||||
class PrefsPanel /* not final */ : public wxPanelWrapper, ComponentInterface
|
||||
@ -49,8 +50,12 @@ class PrefsPanel /* not final */ : public wxPanelWrapper, ComponentInterface
|
||||
public:
|
||||
// \brief Type alias for factories such as GUIPrefsFactory that produce a
|
||||
// PrefsPanel.
|
||||
// The project pointer may be null. Usually it's not needed because
|
||||
// preferences are global. But sometimes you need a project, such as to
|
||||
// preview the preference changes for spectrograms.
|
||||
using Factory =
|
||||
std::function< PrefsPanel * (wxWindow *parent, wxWindowID winid) >;
|
||||
std::function< PrefsPanel * (
|
||||
wxWindow *parent, wxWindowID winid, AudacityProject *) >;
|
||||
|
||||
PrefsPanel(
|
||||
wxWindow * parent, wxWindowID winid, const TranslatableString &title)
|
||||
|
@ -96,7 +96,7 @@ bool ProjectsPrefs::Commit()
|
||||
}
|
||||
|
||||
PrefsPanel::Factory
|
||||
ProjectsPrefsFactory = [](wxWindow *parent, wxWindowID winid)
|
||||
ProjectsPrefsFactory = [](wxWindow *parent, wxWindowID winid, AudacityProject *)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew ProjectsPrefs(parent, winid);
|
||||
|
@ -234,7 +234,7 @@ bool QualityPrefs::Commit()
|
||||
}
|
||||
|
||||
PrefsPanel::Factory
|
||||
QualityPrefsFactory = [](wxWindow *parent, wxWindowID winid)
|
||||
QualityPrefsFactory = [](wxWindow *parent, wxWindowID winid, AudacityProject *)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew QualityPrefs(parent, winid);
|
||||
|
@ -305,7 +305,7 @@ void RecordingPrefs::OnToggleCustomName(wxCommandEvent & /* Evt */)
|
||||
}
|
||||
|
||||
PrefsPanel::Factory
|
||||
RecordingPrefsFactory = [](wxWindow *parent, wxWindowID winid)
|
||||
RecordingPrefsFactory = [](wxWindow *parent, wxWindowID winid, AudacityProject *)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew RecordingPrefs(parent, winid);
|
||||
|
@ -588,7 +588,7 @@ END_EVENT_TABLE()
|
||||
PrefsPanel::Factory
|
||||
SpectrumPrefsFactory( WaveTrack *wt )
|
||||
{
|
||||
return [=](wxWindow *parent, wxWindowID winid)
|
||||
return [=](wxWindow *parent, wxWindowID winid, AudacityProject *)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew SpectrumPrefs(parent, winid, wt);
|
||||
|
@ -230,7 +230,7 @@ bool ThemePrefs::Commit()
|
||||
}
|
||||
|
||||
PrefsPanel::Factory
|
||||
ThemePrefsFactory = [](wxWindow *parent, wxWindowID winid)
|
||||
ThemePrefsFactory = [](wxWindow *parent, wxWindowID winid, AudacityProject *)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew ThemePrefs(parent, winid);
|
||||
|
@ -132,7 +132,7 @@ bool TracksBehaviorsPrefs::Commit()
|
||||
}
|
||||
|
||||
PrefsPanel::Factory
|
||||
TracksBehaviorsPrefsFactory = [](wxWindow *parent, wxWindowID winid)
|
||||
TracksBehaviorsPrefsFactory = [](wxWindow *parent, wxWindowID winid, AudacityProject *)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew TracksBehaviorsPrefs(parent, winid);
|
||||
|
@ -396,7 +396,7 @@ bool TracksPrefs::Commit()
|
||||
}
|
||||
|
||||
PrefsPanel::Factory
|
||||
TracksPrefsFactory = [](wxWindow *parent, wxWindowID winid)
|
||||
TracksPrefsFactory = [](wxWindow *parent, wxWindowID winid, AudacityProject *)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew TracksPrefs(parent, winid);
|
||||
|
@ -107,7 +107,7 @@ bool WarningsPrefs::Commit()
|
||||
}
|
||||
|
||||
PrefsPanel::Factory
|
||||
WarningsPrefsFactory = [](wxWindow *parent, wxWindowID winid)
|
||||
WarningsPrefsFactory = [](wxWindow *parent, wxWindowID winid, AudacityProject *)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew WarningsPrefs(parent, winid);
|
||||
|
@ -256,7 +256,7 @@ END_EVENT_TABLE()
|
||||
PrefsPanel::Factory
|
||||
WaveformPrefsFactory(WaveTrack *wt)
|
||||
{
|
||||
return [=](wxWindow *parent, wxWindowID winid)
|
||||
return [=](wxWindow *parent, wxWindowID winid, AudacityProject *)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew WaveformPrefs(parent, winid, wt);
|
||||
|
@ -828,10 +828,10 @@ void WaveTrackMenuTable::OnSpectrogramSettings(wxCommandEvent &)
|
||||
class ViewSettingsDialog final : public PrefsDialog
|
||||
{
|
||||
public:
|
||||
ViewSettingsDialog(wxWindow *parent,
|
||||
ViewSettingsDialog(wxWindow *parent, AudacityProject &project,
|
||||
const TranslatableString &title, PrefsDialog::Factories &factories,
|
||||
int page)
|
||||
: PrefsDialog(parent, title, factories)
|
||||
: PrefsDialog(parent, &project, title, factories)
|
||||
, mPage(page)
|
||||
{
|
||||
}
|
||||
@ -869,7 +869,8 @@ void WaveTrackMenuTable::OnSpectrogramSettings(wxCommandEvent &)
|
||||
0;
|
||||
|
||||
auto title = XO("%s:").Format( pTrack->GetName() );
|
||||
ViewSettingsDialog dialog(mpData->pParent, title, factories, page);
|
||||
ViewSettingsDialog dialog(
|
||||
mpData->pParent, mpData->project, title, factories, page);
|
||||
|
||||
if (0 != dialog.ShowModal()) {
|
||||
// Redraw
|
||||
|
Loading…
x
Reference in New Issue
Block a user