1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-16 16:10:06 +02:00

Update OnResetConfig

Now it resets the toolbars, and fixes three common 'stuck-in-a-mode' issues.

Paul wrote: "I would move that function [OnResetToolBars(context)] into ToolManager.cpp so it can be called from ToolBarMenus.cpp and HelpMenus.cpp, with neither of those two dependent on the other."
This commit is contained in:
James Crook 2020-05-31 12:22:08 +01:00
parent b5e056575b
commit bc621158b8
4 changed files with 39 additions and 10 deletions

View File

@ -21,6 +21,7 @@
#include "../ShuttleGui.h"
#include "../SplashDialog.h"
#include "../Theme.h"
#include "../toolbars/ToolManager.h"
#include "../commands/CommandContext.h"
#include "../commands/CommandManager.h"
#include "../prefs/PrefsDialog.h"
@ -306,14 +307,29 @@ struct Handler : CommandHandlerObject {
void OnResetConfig(const CommandContext &context)
{
auto &project = context.project;
wxString dir = gPrefs->Read(wxT("/Directories/TempDir"));
wxString dir = gPrefs->Read("/Directories/TempDir");
gPrefs->DeleteAll();
// This stops ReloadPreferences warning about directory change
// on next restart.
gPrefs->Write(wxT("/Directories/TempDir"), dir);
gPrefs->Write("/Directories/TempDir", dir);
gPrefs->Write("/GUI/SyncLockTracks", 0);
gPrefs->Write("/SnapTo", 0 );
ProjectSelectionManager::Get( project ).AS_SetSnapTo( 0 );
// There are many more things we could reset here.
// Beeds discussion as to which make sense to.
// Maybe in future versions?
// - Reset Effects
// - Reset Recording and Playback volumes
// - Reset Selection formats (and for spectral too)
// - Reset Play-at-speed speed to x1
// - Reset Selected tool to cursor.
// - Stop playback/recording and unapply pause.
// - Set Zoom sensibly.
//ProjectSelectionManager::Get(project).AS_SetRate(44100.0);
gPrefs->Write("/AudioIO/SoundActivatedRecord", 0);
gPrefs->Flush();
DoReloadPreferences(project);
// OnResetToolBars(context);
ToolManager::OnResetToolBars(context);
gPrefs->Flush();
}

View File

@ -18,15 +18,12 @@ struct Handler : CommandHandlerObject {
void OnResetToolBars(const CommandContext &context)
{
auto &project = context.project;
auto &toolManager = ToolManager::Get( project );
toolManager.Reset();
MenuManager::Get(project).ModifyToolbarMenus(project);
ToolManager::OnResetToolBars(context);
}
}; // struct Handler
} // namespace
static CommandHandlerObject &findCommandHandler(AudacityProject &) {

View File

@ -28,6 +28,7 @@
#include "ToolManager.h"
#include "../Experimental.h"
#include "../commands/CommandContext.h"
// For compilers that support precompilation, includes "wx/wx.h".
#include <wx/wxprec.h>
@ -547,6 +548,17 @@ static struct DefaultConfigEntry {
{ SpectralSelectionBarID, NoBarID, NoBarID },
};
// Static member function.
void ToolManager::OnResetToolBars(const CommandContext &context)
{
auto &project = context.project;
auto &toolManager = ToolManager::Get( project );
toolManager.Reset();
MenuManager::Get(project).ModifyToolbarMenus(project);
}
void ToolManager::Reset()
{
// Disconnect all docked bars

View File

@ -23,6 +23,10 @@
#include "../ClientData.h"
#include "ToolDock.h"
#include "../commands/CommandFunctors.h"
#include "../commands/CommandManager.h"
class wxCommandEvent;
class wxFrame;
class wxMouseEvent;
@ -80,6 +84,8 @@ class ToolManager final
const ToolDock *GetBotDock() const;
void Reset();
static void OnResetToolBars(const CommandContext &context);
void Destroy();
void RegenerateTooltips();
@ -210,8 +216,6 @@ public:
};
#include "../commands/CommandFunctors.h"
#include "../commands/CommandManager.h"
// Construct a static instance of this class to add a menu item that shows and
// hides a toolbar