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 47 of file HelpMenus.cpp.

Member Typedef Documentation

◆ PrefSetter

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

Definition at line 50 of file HelpMenus.cpp.

Constructor & Destructor Documentation

◆ QuickFixDialog()

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

Definition at line 82 of file HelpMenus.cpp.

82 :
83 wxDialogWrapper(pParent, wxID_ANY, XO("Do you have these problems?"),
84 wxDefaultPosition, wxDefaultSize,
85 wxDEFAULT_DIALOG_STYLE )
86 , mProject{ project }
87{
91
94
95 Fit();
96 auto sz = GetSize();
97 SetMinSize( sz );
98 SetMaxSize( sz );
99
100 // The close button has the cancel id and acts exactly the same as cancel.
101 wxButton * pWin = (wxButton*)FindWindowById( wxID_CANCEL );
102 if( pWin )
103 pWin->SetFocus( );
104 Center();
105}
wxT("CloseDown"))
BoolSetting SoundActivatedRecord
Definition: AudioIO.cpp:3407
XO("Cut/Copy/Paste")
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
@ eIsCreating
Definition: ShuttleGui.h:37
BoolSetting SyncLockTracks
Definition: SyncLock.cpp:163
const auto project
#define S(N)
Definition: ToChars.cpp:64
Project snapping settings.
Definition: ProjectSnap.h:29
SnapMode GetSnapMode() const
Definition: ProjectSnap.cpp:54
bool Read(T *pVar) const
overload of Read returning a boolean that is true if the value was previously defined *‍/
Definition: Prefs.h:207
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:640
virtual bool Read(const wxString &key, bool *value) const =0

References project.

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 107 of file HelpMenus.cpp.

110{
111 mItem++;
112 wxWindowID id = FixButtonID + mItem;
113 if( !bBool)
114 return;
115
116 S
117 .AddFixedText( Prompt );
118
119 S
120 .Id( id )
121 .AddButton( XXO("Fix") )
122 ->Bind( wxEVT_BUTTON, [this, prefSetter, id](wxCommandEvent&){
123 OnFix( prefSetter, id );
124 } );
125
126 {
127 // Replace standard Help button with smaller icon button.
128 // bs->AddButton(safenew wxButton(parent, wxID_HELP));
129 auto b = safenew wxBitmapButton(S.GetParent(), HelpButtonID+mItem, theTheme.Bitmap( bmpHelpIcon ));
130 b->SetToolTip( _("Help") );
131 b->SetLabel(_("Help")); // for screen readers
132 b->Bind( wxEVT_BUTTON, [this, Help](const wxCommandEvent&){
133 OnHelp( Help );
134 } );
135 S.AddWindow( b );
136 }
137}
XXO("&Cut/Copy/Paste Toolbar")
#define HelpButtonID
Definition: HelpMenus.cpp:75
#define FixButtonID
Definition: HelpMenus.cpp:74
#define _(s)
Definition: Internat.h:73
#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:224

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 213 of file HelpMenus.cpp.

214{
215 (void)event;// Compiler food
216 EndModal(wxID_CANCEL);
217}

◆ OnFix()

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

Definition at line 224 of file HelpMenus.cpp.

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

References _.

◆ OnHelp()

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

Definition at line 219 of file HelpMenus.cpp.

220{
221 HelpSystem::ShowHelp(this, Str, true);
222}
static void ShowHelp(wxWindow *parent, const FilePath &localFileName, const URLString &remoteURL, bool bModal=false, bool alwaysDefaultBrowser=false)
Definition: HelpSystem.cpp:231

References HelpSystem::ShowHelp().

Here is the call graph for this function:

◆ OnOk()

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

Definition at line 207 of file HelpMenus.cpp.

208{
209 (void)event;// Compiler food
210 EndModal(wxID_OK);
211}

◆ Populate()

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

◆ PopulateOrExchange()

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

Definition at line 139 of file HelpMenus.cpp.

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

References DoReloadPreferences(), eCloseButton, eHelpButton, audacity::BasicSettings::Flush(), ProjectSnap::Get(), gPrefs, S, ProjectSnap::SetSnapMode(), SNAP_OFF, SoundActivatedRecord, SyncLockTracks, and XO().

Here is the call graph for this function:

Member Data Documentation

◆ mbInSnapTo

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

Definition at line 68 of file HelpMenus.cpp.

◆ mbSoundActivated

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

Definition at line 69 of file HelpMenus.cpp.

◆ mbSyncLocked

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

Definition at line 67 of file HelpMenus.cpp.

◆ mItem

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

Definition at line 66 of file HelpMenus.cpp.

◆ mProject

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

Definition at line 64 of file HelpMenus.cpp.


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