Correct menu ordering after "Reset Configuration" command, see f5afb28
This commit is contained in:
parent
f5afb28f54
commit
2c8c5799f6
|
@ -1024,11 +1024,18 @@ void Visit( Visitor &visitor, BaseItem *pTopItem, const GroupItem *pRegistry )
|
|||
}
|
||||
|
||||
OrderingPreferenceInitializer::OrderingPreferenceInitializer(
|
||||
Literal root, const Pairs &pairs )
|
||||
Literal root, Pairs pairs )
|
||||
: mPairs{ std::move( pairs ) }
|
||||
, mRoot{ root }
|
||||
{
|
||||
(*this)();
|
||||
}
|
||||
|
||||
void OrderingPreferenceInitializer::operator () ()
|
||||
{
|
||||
bool doFlush = false;
|
||||
for (const auto &pair : pairs) {
|
||||
const auto key = wxString{'/'} + root + pair.first;
|
||||
for (const auto &pair : mPairs) {
|
||||
const auto key = wxString{'/'} + mRoot + pair.first;
|
||||
if ( gPrefs->Read(key).empty() ) {
|
||||
gPrefs->Write( key, pair.second );
|
||||
doFlush = true;
|
||||
|
|
|
@ -407,3 +407,30 @@ wxString WarningDialogKey(const wxString &internalDialogName)
|
|||
}
|
||||
|
||||
ByColumns_t ByColumns{};
|
||||
|
||||
#include <set>
|
||||
|
||||
namespace {
|
||||
using PreferenceInitializers = std::set< PreferenceInitializer* >;
|
||||
PreferenceInitializers &allInitializers()
|
||||
{
|
||||
static PreferenceInitializers theSet;
|
||||
return theSet;
|
||||
}
|
||||
}
|
||||
|
||||
PreferenceInitializer::PreferenceInitializer()
|
||||
{
|
||||
allInitializers().insert( this );
|
||||
}
|
||||
|
||||
PreferenceInitializer::~PreferenceInitializer()
|
||||
{
|
||||
allInitializers().erase( this );
|
||||
}
|
||||
|
||||
void PreferenceInitializer::ReinitializeAll()
|
||||
{
|
||||
for ( auto pInitializer : allInitializers() )
|
||||
(*pInitializer)();
|
||||
}
|
||||
|
|
12
src/Prefs.h
12
src/Prefs.h
|
@ -272,4 +272,16 @@ private:
|
|||
/// becomes false.
|
||||
wxString WarningDialogKey(const wxString &internalDialogName);
|
||||
|
||||
/*
|
||||
Meant to be statically constructed. A callback to repopulate configuration
|
||||
files after a reset.
|
||||
*/
|
||||
struct PreferenceInitializer {
|
||||
PreferenceInitializer();
|
||||
virtual ~PreferenceInitializer();
|
||||
virtual void operator () () = 0;
|
||||
|
||||
static void ReinitializeAll();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -21,6 +21,9 @@
|
|||
#include "CommandFlag.h"
|
||||
|
||||
#include "Keyboard.h"
|
||||
|
||||
#include "../Prefs.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "../xml/XMLTagHandler.h"
|
||||
|
@ -663,7 +666,7 @@ namespace Registry {
|
|||
// registry of plug-ins, and something must be done to preserve old
|
||||
// behavior. It can be done in the central place using string literal
|
||||
// identifiers only, not requiring static compilation or linkage dependency.
|
||||
struct OrderingPreferenceInitializer {
|
||||
struct OrderingPreferenceInitializer : PreferenceInitializer {
|
||||
using Literal = const wxChar *;
|
||||
using Pair = std::pair< Literal, Literal >;
|
||||
using Pairs = std::vector< Pair >;
|
||||
|
@ -674,7 +677,13 @@ namespace Registry {
|
|||
// (these should be blank or start with / and not end with /),
|
||||
// each with a ,-separated sequence of identifiers, which specify a
|
||||
// desired ordering at one node of the tree:
|
||||
const Pairs &pairs );
|
||||
Pairs pairs );
|
||||
|
||||
void operator () () override;
|
||||
|
||||
private:
|
||||
Pairs mPairs;
|
||||
Literal mRoot;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -966,6 +966,8 @@ wxString PrefsPanel::HelpPageName()
|
|||
|
||||
void DoReloadPreferences( AudacityProject &project )
|
||||
{
|
||||
PreferenceInitializer::ReinitializeAll();
|
||||
|
||||
{
|
||||
GlobalPrefsDialog dialog(
|
||||
&GetProjectFrame( project ) /* parent */, &project );
|
||||
|
|
Loading…
Reference in New Issue