Audacity 3.2.0
Public Types | Public Member Functions | Public Attributes | List of all members
anonymous_namespace{HelpMenus.cpp}::QuickFixDialog Class Reference

Class which makes a dialog for displaying quick fixes to common issues. More...

Inheritance diagram for anonymous_namespace{HelpMenus.cpp}::QuickFixDialog:
[legend]
Collaboration diagram for anonymous_namespace{HelpMenus.cpp}::QuickFixDialog:
[legend]

Public Types

using PrefSetter = std::function< void() >
 

Public Member Functions

 QuickFixDialog (wxWindow *pParent, AudacityProject &project)
 
void Populate ()
 
void PopulateOrExchange (ShuttleGui &S)
 
void AddStuck (ShuttleGui &S, bool &bBool, const PrefSetter &prefSetter, const TranslatableString &Prompt, const ManualPageID &Help)
 
void OnOk (wxCommandEvent &event)
 
void OnCancel (wxCommandEvent &event)
 
void OnHelp (const ManualPageID &Str)
 
void OnFix (const PrefSetter &setter, wxWindowID id)
 
- Public Member Functions inherited from wxDialogWrapper
 wxDialogWrapper ()
 
 wxDialogWrapper (wxWindow *parent, wxWindowID id, const TranslatableString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const TranslatableString &name=XO("Dialog"))
 
bool Create (wxWindow *parent, wxWindowID id, const TranslatableString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const TranslatableString &name=XO("Dialog"))
 
void SetTitle (const TranslatableString &title)
 
void SetLabel (const TranslatableString &title)
 
void SetName (const TranslatableString &title)
 
void SetName ()
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxDialog >
 wxTabTraversalWrapper (Args &&... args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Public Attributes

AudacityProjectmProject
 
int mItem
 
bool mbSyncLocked
 
bool mbInSnapTo
 
bool mbSoundActivated
 

Detailed Description

Class which makes a dialog for displaying quick fixes to common issues.

This class originated with the 'Stuck in a mode' problem, where far too many users get into a mode without realising, and don't know how to get out. It is a band-aid, and we should do more towards a full and proper solution where there are fewer special modes, and they don't persist.

Definition at line 48 of file HelpMenus.cpp.

Member Typedef Documentation

◆ PrefSetter

using anonymous_namespace{HelpMenus.cpp}::QuickFixDialog::PrefSetter = std::function< void() >

Definition at line 51 of file HelpMenus.cpp.

Constructor & Destructor Documentation

◆ QuickFixDialog()

anonymous_namespace{HelpMenus.cpp}::QuickFixDialog::QuickFixDialog ( wxWindow *  pParent,
AudacityProject project 
)

Definition at line 83 of file HelpMenus.cpp.

83 :
84 wxDialogWrapper(pParent, wxID_ANY, XO("Do you have these problems?"),
85 wxDefaultPosition, wxDefaultSize,
86 wxDEFAULT_DIALOG_STYLE )
87 , mProject{ project }
88{
89 const long SNAP_OFF = 0;
90
91 gPrefs->Read(wxT("/GUI/SyncLockTracks"), &mbSyncLocked, false);
92 mbInSnapTo = gPrefs->Read(wxT("/SnapTo"), SNAP_OFF) !=0;
93 gPrefs->Read(wxT("/AudioIO/SoundActivatedRecord"), &mbSoundActivated, false);
94
97
98 Fit();
99 auto sz = GetSize();
100 SetMinSize( sz );
101 SetMaxSize( sz );
102
103 // The close button has the cancel id and acts exactly the same as cancel.
104 wxButton * pWin = (wxButton*)FindWindowById( wxID_CANCEL );
105 if( pWin )
106 pWin->SetFocus( );
107 Center();
108}
wxT("CloseDown"))
XO("Cut/Copy/Paste")
FileConfig * gPrefs
Definition: Prefs.cpp:70
@ SNAP_OFF
@ eIsCreating
Definition: ShuttleGui.h:39
#define S(N)
Definition: ToChars.cpp:64
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:628

Member Function Documentation

◆ AddStuck()

void anonymous_namespace{HelpMenus.cpp}::QuickFixDialog::AddStuck ( ShuttleGui S,
bool &  bBool,
const PrefSetter prefSetter,
const TranslatableString Prompt,
const ManualPageID Help 
)

Definition at line 110 of file HelpMenus.cpp.

113{
114 mItem++;
115 wxWindowID id = FixButtonID + mItem;
116 if( !bBool)
117 return;
118
119 S
120 .AddFixedText( Prompt );
121
122 S
123 .Id( id )
124 .AddButton( XXO("Fix") )
125 ->Bind( wxEVT_BUTTON, [this, prefSetter, id](wxCommandEvent&){
126 OnFix( prefSetter, id );
127 } );
128
129 {
130 // Replace standard Help button with smaller icon button.
131 // bs->AddButton(safenew wxButton(parent, wxID_HELP));
132 auto b = safenew wxBitmapButton(S.GetParent(), HelpButtonID+mItem, theTheme.Bitmap( bmpHelpIcon ));
133 b->SetToolTip( _("Help") );
134 b->SetLabel(_("Help")); // for screen readers
135 b->Bind( wxEVT_BUTTON, [this, Help](const wxCommandEvent&){
136 OnHelp( Help );
137 } );
138 S.AddWindow( b );
139 }
140}
XXO("&Cut/Copy/Paste Toolbar")
#define HelpButtonID
Definition: HelpMenus.cpp:76
#define FixButtonID
Definition: HelpMenus.cpp:75
#define _(s)
Definition: Internat.h:75
#define safenew
Definition: MemoryX.h:10
THEME_API Theme theTheme
Definition: Theme.cpp:82
wxBitmap & Bitmap(int iIndex)
void OnFix(const PrefSetter &setter, wxWindowID id)
Definition: HelpMenus.cpp:229

References _, ThemeBase::Bitmap(), FixButtonID, HelpButtonID, S, safenew, theTheme, and XXO().

Here is the call graph for this function:

◆ OnCancel()

void anonymous_namespace{HelpMenus.cpp}::QuickFixDialog::OnCancel ( wxCommandEvent &  event)

Definition at line 218 of file HelpMenus.cpp.

219{
220 (void)event;// Compiler food
221 EndModal(wxID_CANCEL);
222}

◆ OnFix()

void anonymous_namespace{HelpMenus.cpp}::QuickFixDialog::OnFix ( const PrefSetter setter,
wxWindowID  id 
)

Definition at line 229 of file HelpMenus.cpp.

230{
231 if ( setter )
232 setter();
233
234 // Change the label after doing the fix, as the fix may take a second or two.
235 auto pBtn = FindWindow(id);
236 if( pBtn )
237 pBtn->SetLabel( _("Fixed") );
238
239 // The close button has the cancel id and acts exactly the same as cancel.
240 wxButton * pWin = (wxButton*)FindWindowById( wxID_CANCEL );
241 if( pWin )
242 pWin->SetFocus( );
243}

References _.

◆ OnHelp()

void anonymous_namespace{HelpMenus.cpp}::QuickFixDialog::OnHelp ( const ManualPageID Str)

Definition at line 224 of file HelpMenus.cpp.

225{
226 HelpSystem::ShowHelp(this, Str, true);
227}
static void ShowHelp(wxWindow *parent, const FilePath &localFileName, const URLString &remoteURL, bool bModal=false, bool alwaysDefaultBrowser=false)
Definition: HelpSystem.cpp:234

References HelpSystem::ShowHelp().

Here is the call graph for this function:

◆ OnOk()

void anonymous_namespace{HelpMenus.cpp}::QuickFixDialog::OnOk ( wxCommandEvent &  event)

Definition at line 212 of file HelpMenus.cpp.

213{
214 (void)event;// Compiler food
215 EndModal(wxID_OK);
216}

◆ Populate()

void anonymous_namespace{HelpMenus.cpp}::QuickFixDialog::Populate ( )

◆ PopulateOrExchange()

void anonymous_namespace{HelpMenus.cpp}::QuickFixDialog::PopulateOrExchange ( ShuttleGui S)

Definition at line 142 of file HelpMenus.cpp.

143{
144
145 S.StartVerticalLay(1);
146 S.StartStatic( XO("Quick Fixes"));
147
148 // These aren't all possible modes one can be stuck in, but they are some of them.
149 bool bStuckInMode = mbSyncLocked || mbInSnapTo || mbSoundActivated;
150
151 if( !bStuckInMode ){
152 SetLabel(XO("Nothing to do"));
153 S.AddFixedText(XO("No quick, easily fixed problems were found"));
154 }
155 else {
156 S.StartMultiColumn(3, wxALIGN_CENTER);
157 {
158 mItem = -1;
159
160 auto defaultAction =
161 [](AudacityProject *pProject, const wxString &path){ return
162 [pProject, path]{
163 gPrefs->Write(path, 0);
164 gPrefs->Flush();
165 // This is overkill (aka slow), as all preferences are
166 // reloaded and all
167 // toolbars recreated.
168 // Overkill probably doesn't matter, as this command is
169 // infrequently used.
170 DoReloadPreferences( *pProject );
171 };
172 };
173
174 // Use # in the URLs to ensure we go to the online version of help.
175 // Local help may well not be installed.
176 auto pProject = &mProject;
178 defaultAction( pProject, "/GUI/SyncLockTracks" ),
179 XO("Clocks on the Tracks"), "Quick_Fix#sync_lock" );
181 [pProject] {
182 gPrefs->Write( "/SnapTo", 0 );
183 gPrefs->Flush();
184 // Sadly SnapTo has to be handled specially,
185 // as it is not part of the standard
186 // preference dialogs.
188 },
189 XO("Can't select precisely"), "Quick_Fix#snap_to" );
191 defaultAction( pProject, "/AudioIO/SoundActivatedRecord" ),
192 XO("Recording stops and starts"),
193 "Quick_Fix#sound_activated_recording" );
194 }
195 S.EndMultiColumn();
196 }
197 S.EndStatic();
198
199 S.StartHorizontalLay(wxALIGN_CENTER_HORIZONTAL, 0);
200 S.AddStandardButtons(eCloseButton + (bStuckInMode ? 0 : eHelpButton));
201 S.EndHorizontalLay();
202
203 S.EndVerticalLay();
204
205 wxButton * pBtn = (wxButton*)FindWindowById( wxID_HELP );
206 if( pBtn )
207 pBtn->Bind( wxEVT_BUTTON, [this]( const wxCommandEvent & ){
208 OnHelp( "Quick_Fix#" );
209 } );
210}
void DoReloadPreferences(AudacityProject &project)
@ eCloseButton
Definition: ShuttleGui.h:607
@ eHelpButton
Definition: ShuttleGui.h:601
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
Definition: FileConfig.cpp:143
void AS_SetSnapTo(int snap) override
static ProjectSelectionManager & Get(AudacityProject &project)
void AddStuck(ShuttleGui &S, bool &bBool, const PrefSetter &prefSetter, const TranslatableString &Prompt, const ManualPageID &Help)
Definition: HelpMenus.cpp:110
void SetLabel(const TranslatableString &title)

References ProjectSelectionManager::AS_SetSnapTo(), DoReloadPreferences(), eCloseButton, eHelpButton, FileConfig::Flush(), ProjectSelectionManager::Get(), gPrefs, S, and XO().

Here is the call graph for this function:

Member Data Documentation

◆ mbInSnapTo

bool anonymous_namespace{HelpMenus.cpp}::QuickFixDialog::mbInSnapTo

Definition at line 69 of file HelpMenus.cpp.

◆ mbSoundActivated

bool anonymous_namespace{HelpMenus.cpp}::QuickFixDialog::mbSoundActivated

Definition at line 70 of file HelpMenus.cpp.

◆ mbSyncLocked

bool anonymous_namespace{HelpMenus.cpp}::QuickFixDialog::mbSyncLocked

Definition at line 68 of file HelpMenus.cpp.

◆ mItem

int anonymous_namespace{HelpMenus.cpp}::QuickFixDialog::mItem

Definition at line 67 of file HelpMenus.cpp.

◆ mProject

AudacityProject& anonymous_namespace{HelpMenus.cpp}::QuickFixDialog::mProject

Definition at line 65 of file HelpMenus.cpp.


The documentation for this class was generated from the following file: