1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-03 09:09:47 +02:00

Lower DoReloadPreferences into PrefsDialog.cpp

This commit is contained in:
Paul Licameli 2019-06-21 22:54:34 -04:00
parent 8db51416bc
commit b6077fd3cd
6 changed files with 44 additions and 44 deletions

View File

@ -104,11 +104,6 @@ public:
// Exported helper functions from various menu handling source files
/// Namespace for functions for Edit menu
namespace EditActions {
void DoReloadPreferences( AudacityProject & );
}
/// Namespace for functions for View menu
namespace ViewActions {
double GetZoomOfToFit( const AudacityProject &project );

View File

@ -18,11 +18,11 @@ SetPreferenceCommand classes
#include "../Audacity.h"
#include "PreferenceCommands.h"
#include "../Menus.h"
#include "../Prefs.h"
#include "../Shuttle.h"
#include "../ShuttleGui.h"
#include "../commands/CommandContext.h"
#include "../prefs/PrefsDialog.h"
bool GetPreferenceCommand::DefineParams( ShuttleParams & S ){
S.Define( mName, wxT("Name"), wxT("") );
@ -76,7 +76,7 @@ bool SetPreferenceCommand::Apply(const CommandContext & context)
bool bOK = gPrefs->Write(mName, mValue) && gPrefs->Flush();
if( bOK && mbReload ){
auto &project = context.project;
EditActions::DoReloadPreferences( project );
DoReloadPreferences( project );
}
return bOK;
}

View File

@ -171,41 +171,6 @@ bool DoPasteNothingSelected(AudacityProject &project)
namespace EditActions {
// exported helper functions
void DoReloadPreferences( AudacityProject &project )
{
{
SpectrogramSettings::defaults().LoadPrefs();
WaveformSettings::defaults().LoadPrefs();
GlobalPrefsDialog dialog(&GetProjectFrame( project ) /* parent */ );
wxCommandEvent Evt;
//dialog.Show();
dialog.OnOK(Evt);
}
// LL: Moved from PrefsDialog since wxWidgets on OSX can't deal with
// rebuilding the menus while the PrefsDialog is still in the modal
// state.
for (auto p : AllProjects{}) {
MenuManager::Get(*p).RebuildMenuBar(*p);
// TODO: The comment below suggests this workaround is obsolete.
#if defined(__WXGTK__)
// Workaround for:
//
// http://bugzilla.audacityteam.org/show_bug.cgi?id=458
//
// This workaround should be removed when Audacity updates to wxWidgets
// 3.x which has a fix.
auto &window = GetProjectFrame( *p );
wxRect r = window.GetRect();
window.SetSize(wxSize(1,1));
window.SetSize(r.GetSize());
#endif
}
}
// Menu handler functions
struct Handler : CommandHandlerObject {

View File

@ -14,7 +14,6 @@
#include "../Dependencies.h"
#include "../FileNames.h"
#include "../HelpText.h"
#include "../Menus.h"
#include "../Prefs.h"
#include "../Project.h"
#include "../ProjectSelectionManager.h"
@ -23,6 +22,7 @@
#include "../Theme.h"
#include "../commands/CommandContext.h"
#include "../commands/CommandManager.h"
#include "../prefs/PrefsDialog.h"
#include "../widgets/AudacityMessageBox.h"
#include "../widgets/HelpSystem.h"
#include "../widgets/LinkingHtmlWindow.h"
@ -261,7 +261,7 @@ void QuickFixDialog::OnFix(wxCommandEvent &event)
// This is overkill (aka slow), as all preferences are reloaded and all
// toolbars recreated.
// Overkill probably doesn't matter, as this command is infrequently used.
EditActions::DoReloadPreferences( *pProject );
DoReloadPreferences( *pProject );
}
}

View File

@ -932,3 +932,40 @@ wxString PrefsPanel::HelpPageName()
{
return wxEmptyString;
}
#include <wx/frame.h>
#include "../Menus.h"
#include "../Project.h"
void DoReloadPreferences( AudacityProject &project )
{
{
SpectrogramSettings::defaults().LoadPrefs();
WaveformSettings::defaults().LoadPrefs();
GlobalPrefsDialog dialog(&GetProjectFrame( project ) /* parent */ );
wxCommandEvent Evt;
//dialog.Show();
dialog.OnOK(Evt);
}
// LL: Moved from PrefsDialog since wxWidgets on OSX can't deal with
// rebuilding the menus while the PrefsDialog is still in the modal
// state.
for (auto p : AllProjects{}) {
MenuManager::Get(*p).RebuildMenuBar(*p);
// TODO: The comment below suggests this workaround is obsolete.
#if defined(__WXGTK__)
// Workaround for:
//
// http://bugzilla.audacityteam.org/show_bug.cgi?id=458
//
// This workaround should be removed when Audacity updates to wxWidgets
// 3.x which has a fix.
auto &window = GetProjectFrame( *p );
wxRect r = window.GetRect();
window.SetSize(wxSize(1,1));
window.SetSize(r.GetSize());
#endif
}
}

View File

@ -98,4 +98,7 @@ public:
void SavePreferredPage() override;
};
class AudacityProject;
void DoReloadPreferences( AudacityProject &project );
#endif