mirror of
https://github.com/cookiengineer/audacity
synced 2025-11-14 17:14:07 +01:00
Correct menu ordering after "Reset Configuration" command, see f5afb28
This commit is contained in:
@@ -1024,11 +1024,18 @@ void Visit( Visitor &visitor, BaseItem *pTopItem, const GroupItem *pRegistry )
|
|||||||
}
|
}
|
||||||
|
|
||||||
OrderingPreferenceInitializer::OrderingPreferenceInitializer(
|
OrderingPreferenceInitializer::OrderingPreferenceInitializer(
|
||||||
Literal root, const Pairs &pairs )
|
Literal root, Pairs pairs )
|
||||||
|
: mPairs{ std::move( pairs ) }
|
||||||
|
, mRoot{ root }
|
||||||
|
{
|
||||||
|
(*this)();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OrderingPreferenceInitializer::operator () ()
|
||||||
{
|
{
|
||||||
bool doFlush = false;
|
bool doFlush = false;
|
||||||
for (const auto &pair : pairs) {
|
for (const auto &pair : mPairs) {
|
||||||
const auto key = wxString{'/'} + root + pair.first;
|
const auto key = wxString{'/'} + mRoot + pair.first;
|
||||||
if ( gPrefs->Read(key).empty() ) {
|
if ( gPrefs->Read(key).empty() ) {
|
||||||
gPrefs->Write( key, pair.second );
|
gPrefs->Write( key, pair.second );
|
||||||
doFlush = true;
|
doFlush = true;
|
||||||
|
|||||||
@@ -407,3 +407,30 @@ wxString WarningDialogKey(const wxString &internalDialogName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ByColumns_t ByColumns{};
|
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.
|
/// becomes false.
|
||||||
wxString WarningDialogKey(const wxString &internalDialogName);
|
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
|
#endif
|
||||||
|
|||||||
@@ -21,6 +21,9 @@
|
|||||||
#include "CommandFlag.h"
|
#include "CommandFlag.h"
|
||||||
|
|
||||||
#include "Keyboard.h"
|
#include "Keyboard.h"
|
||||||
|
|
||||||
|
#include "../Prefs.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "../xml/XMLTagHandler.h"
|
#include "../xml/XMLTagHandler.h"
|
||||||
@@ -663,7 +666,7 @@ namespace Registry {
|
|||||||
// registry of plug-ins, and something must be done to preserve old
|
// registry of plug-ins, and something must be done to preserve old
|
||||||
// behavior. It can be done in the central place using string literal
|
// behavior. It can be done in the central place using string literal
|
||||||
// identifiers only, not requiring static compilation or linkage dependency.
|
// identifiers only, not requiring static compilation or linkage dependency.
|
||||||
struct OrderingPreferenceInitializer {
|
struct OrderingPreferenceInitializer : PreferenceInitializer {
|
||||||
using Literal = const wxChar *;
|
using Literal = const wxChar *;
|
||||||
using Pair = std::pair< Literal, Literal >;
|
using Pair = std::pair< Literal, Literal >;
|
||||||
using Pairs = std::vector< Pair >;
|
using Pairs = std::vector< Pair >;
|
||||||
@@ -674,7 +677,13 @@ namespace Registry {
|
|||||||
// (these should be blank or start with / and not end with /),
|
// (these should be blank or start with / and not end with /),
|
||||||
// each with a ,-separated sequence of identifiers, which specify a
|
// each with a ,-separated sequence of identifiers, which specify a
|
||||||
// desired ordering at one node of the tree:
|
// 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 )
|
void DoReloadPreferences( AudacityProject &project )
|
||||||
{
|
{
|
||||||
|
PreferenceInitializer::ReinitializeAll();
|
||||||
|
|
||||||
{
|
{
|
||||||
GlobalPrefsDialog dialog(
|
GlobalPrefsDialog dialog(
|
||||||
&GetProjectFrame( project ) /* parent */, &project );
|
&GetProjectFrame( project ) /* parent */, &project );
|
||||||
|
|||||||
Reference in New Issue
Block a user