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{
92
95
96 Fit();
97 auto sz = GetSize();
98 SetMinSize( sz );
99 SetMaxSize( sz );
100
101 // The close button has the cancel id and acts exactly the same as cancel.
102 wxButton * pWin = (wxButton*)FindWindowById( wxID_CANCEL );
103 if( pWin )
104 pWin->SetFocus( );
105 Center();
106}
wxT("CloseDown"))
BoolSetting SoundActivatedRecord
Definition: AudioIO.cpp:3357
XO("Cut/Copy/Paste")
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
@ eIsCreating
Definition: ShuttleGui.h:37
BoolSetting SyncLockTracks
Definition: SyncLock.cpp:173
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 108 of file HelpMenus.cpp.

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

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

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

◆ OnFix()

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

Definition at line 225 of file HelpMenus.cpp.

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

References _.

◆ OnHelp()

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

Definition at line 220 of file HelpMenus.cpp.

221{
222 HelpSystem::ShowHelp(this, Str, true);
223}
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 208 of file HelpMenus.cpp.

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

◆ Populate()

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

◆ PopulateOrExchange()

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

Definition at line 140 of file HelpMenus.cpp.

141{
142
143 S.StartVerticalLay(1);
144 S.StartStatic( XO("Quick Fixes"));
145
146 // These aren't all possible modes one can be stuck in, but they are some of them.
147 bool bStuckInMode = mbSyncLocked || mbInSnapTo || mbSoundActivated;
148
149 if( !bStuckInMode ){
150 SetLabel(XO("Nothing to do"));
151 S.AddFixedText(XO("No quick, easily fixed problems were found"));
152 }
153 else {
154 S.StartMultiColumn(3, wxALIGN_CENTER);
155 {
156 mItem = -1;
157
158 auto defaultAction =
159 [](AudacityProject *pProject, BoolSetting &setting){ return
160 [pProject, &setting]{
161 setting.Reset();
162 gPrefs->Flush();
163 // This is overkill (aka slow), as all preferences are
164 // reloaded and all
165 // toolbars recreated.
166 // Overkill probably doesn't matter, as this command is
167 // infrequently used.
168 DoReloadPreferences( *pProject );
169 };
170 };
171
172 // Use # in the URLs to ensure we go to the online version of help.
173 // Local help may well not be installed.
174 auto pProject = &mProject;
176 defaultAction( pProject, SyncLockTracks ),
177 XO("Clocks on the Tracks"), "Quick_Fix#sync_lock" );
179 [pProject] {
180 // Sadly SnapTo has to be handled specially,
181 // as it is not part of the standard
182 // preference dialogs.
184 },
185 XO("Can't select precisely"), "Quick_Fix#snap_to" );
187 defaultAction( pProject, SoundActivatedRecord ),
188 XO("Recording stops and starts"),
189 "Quick_Fix#sound_activated_recording" );
190 }
191 S.EndMultiColumn();
192 }
193 S.EndStatic();
194
195 S.StartHorizontalLay(wxALIGN_CENTER_HORIZONTAL, 0);
196 S.AddStandardButtons(eCloseButton + (bStuckInMode ? 0 : eHelpButton));
197 S.EndHorizontalLay();
198
199 S.EndVerticalLay();
200
201 wxButton * pBtn = (wxButton*)FindWindowById( wxID_HELP );
202 if( pBtn )
203 pBtn->Bind( wxEVT_BUTTON, [this]( const wxCommandEvent & ){
204 OnHelp( "Quick_Fix#" );
205 } );
206}
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:108
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 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: