Audacity 3.2.0
Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Private Attributes | List of all members
audacity::cloud::audiocom::sync::AudioComDialogBase Class Reference

#include <AudioComDialogBase.h>

Inheritance diagram for audacity::cloud::audiocom::sync::AudioComDialogBase:
[legend]
Collaboration diagram for audacity::cloud::audiocom::sync::AudioComDialogBase:
[legend]

Public Member Functions

DialogButtonIdentifier ShowDialog (std::function< DialogButtonIdentifier()> poller={})
 

Static Public Member Functions

static DialogButtonIdentifier CancelButtonIdentifier ()
 

Protected Types

enum class  DialogMode { Opening , Saving }
 
enum  ButtonType { None = 0 , DefaultButton = 1 , EscButton = 2 }
 

Protected Member Functions

 AudioComDialogBase (const AudacityProject *project, const DialogIdentifier &optionalPrefsIdentifier={}, DialogMode dialogMode=DialogMode::Saving)
 
virtual ~AudioComDialogBase ()=default
 
void AddTitle (const TranslatableString &title)
 
void AddParagraph (const TranslatableString &paragraph)
 
void AddButton (DialogButtonIdentifier identifier, const TranslatableString &text, int type=None)
 
void SetDialogTitle (const TranslatableString &dialog)
 
virtual bool HasSeparator () const
 
void EndDialog (DialogButtonIdentifier identifier)
 

Private Attributes

const AudacityProjectmProject
 
DialogIdentifier mOptionalPrefsIdentifier
 
wxBoxSizer * mDialogSizer
 
wxBoxSizer * mButtonSizer
 
DialogButtonIdentifier mEscButtonIdentifier { CancelButtonIdentifier() }
 
DialogButtonIdentifier mResultButtonIdentifier
 

Additional Inherited Members

- Private 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 ()
 
- Private Member Functions inherited from wxTabTraversalWrapper< wxDialog >
 wxTabTraversalWrapper (Args &&... args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Detailed Description

Definition at line 37 of file AudioComDialogBase.h.

Member Enumeration Documentation

◆ ButtonType

◆ DialogMode

Enumerator
Opening 
Saving 

Definition at line 46 of file AudioComDialogBase.h.

47 {
48 Opening,
49 Saving,
50 };

Constructor & Destructor Documentation

◆ AudioComDialogBase()

audacity::cloud::audiocom::sync::AudioComDialogBase::AudioComDialogBase ( const AudacityProject project,
const DialogIdentifier optionalPrefsIdentifier = {},
DialogMode  dialogMode = DialogMode::Saving 
)
protected

Definition at line 118 of file AudioComDialogBase.cpp.

122 dialogMode == DialogMode::Saving ?
123 XO("Save to audio.com") :
124 XO("Open from audio.com") }
125 , mProject { project }
127 optionalPrefsIdentifier) }
128 , mDialogSizer { new wxBoxSizer(wxVERTICAL) }
129 , mButtonSizer { new wxBoxSizer(wxHORIZONTAL) }
130{
131 mDialogSizer->SetMinSize({ 420, 140 });
133 {
134 const auto skipDialog =
136
137 auto checkbox =
138 safenew wxCheckBox { this, wxID_ANY,
139 XO("Don't show this again").Translation() };
140
141 checkbox->SetValue(skipDialog);
142
143 mButtonSizer->Add(checkbox, wxSizerFlags {}.CenterVertical());
144
145 checkbox->Bind(
146 wxEVT_CHECKBOX,
147 [this, checkbox](auto&)
148 {
149 gPrefs->Write(mOptionalPrefsIdentifier.GET(), checkbox->GetValue());
150 gPrefs->Flush();
151 });
152 }
153
154 mButtonSizer->AddStretchSpacer();
155
156 Bind(
157 wxEVT_CHAR_HOOK,
158 [this](auto& evt)
159 {
160 if (!IsEscapeKey(evt))
161 {
162 evt.Skip();
163 return;
164 }
165
167 });
168}
XO("Cut/Copy/Paste")
#define safenew
Definition: MemoryX.h:10
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
const auto project
bool empty() const
Definition: Identifier.h:61
const wxString & GET() const
Explicit conversion to wxString, meant to be ugly-looking and demanding of a comment why it's correct...
Definition: Identifier.h:66
virtual bool Flush() noexcept=0
virtual bool Write(const wxString &key, bool value)=0
bool ReadBool(const wxString &key, bool defaultValue) const
void EndDialog(DialogButtonIdentifier identifier)

References Identifier::empty(), EndDialog(), audacity::BasicSettings::Flush(), Identifier::GET(), gPrefs, mButtonSizer, mDialogSizer, mEscButtonIdentifier, mOptionalPrefsIdentifier, audacity::BasicSettings::ReadBool(), safenew, audacity::BasicSettings::Write(), and XO().

Here is the call graph for this function:

◆ ~AudioComDialogBase()

virtual audacity::cloud::audiocom::sync::AudioComDialogBase::~AudioComDialogBase ( )
protectedvirtualdefault

Member Function Documentation

◆ AddButton()

void audacity::cloud::audiocom::sync::AudioComDialogBase::AddButton ( DialogButtonIdentifier  identifier,
const TranslatableString text,
int  type = None 
)
protected

Definition at line 195 of file AudioComDialogBase.cpp.

197{
198 auto button = safenew wxButton { this, wxID_ANY, text.Translation() };
199
200 mButtonSizer->Add(button, wxSizerFlags {}.Border(wxLEFT, 8));
201
202 if (type & EscButton)
203 mEscButtonIdentifier = identifier;
204
205 button->Bind(
206 wxEVT_BUTTON, [this, identifier = std::move(identifier)](auto&)
207 { EndDialog(identifier); });
208
209 if (type & DefaultButton)
210 button->SetDefault();
211}
wxString Translation() const

References DefaultButton, EndDialog(), EscButton, mButtonSizer, mEscButtonIdentifier, safenew, and TranslatableString::Translation().

Referenced by audacity::cloud::audiocom::sync::LinkAccountDialog::LinkAccountDialog(), audacity::cloud::audiocom::sync::NotCloudProjectDialog::NotCloudProjectDialog(), audacity::cloud::audiocom::sync::ProjectLimitDialog::ProjectLimitDialog(), audacity::cloud::audiocom::sync::ProjectVersionConflictDialog::ProjectVersionConflictDialog(), audacity::cloud::audiocom::sync::SyncInBackroundDialog::SyncInBackroundDialog(), audacity::cloud::audiocom::sync::SyncSucceededDialog::SyncSucceededDialog(), audacity::cloud::audiocom::sync::UnsyncedProjectDialog::UnsyncedProjectDialog(), audacity::cloud::audiocom::sync::UploadCanceledDialog::UploadCanceledDialog(), and audacity::cloud::audiocom::sync::WaitForActionDialog::WaitForActionDialog().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddParagraph()

void audacity::cloud::audiocom::sync::AudioComDialogBase::AddParagraph ( const TranslatableString paragraph)
protected

Definition at line 184 of file AudioComDialogBase.cpp.

185{
186 auto statText =
187 safenew wxStaticText { this, wxID_ANY, paragraph.Translation() };
188
189 mDialogSizer->AddSpacer(16);
190 mDialogSizer->Add(statText, wxSizerFlags {}.Border(wxLEFT | wxRIGHT, 16));
191
192 statText->Wrap(400);
193}

References mDialogSizer, safenew, and TranslatableString::Translation().

Referenced by audacity::cloud::audiocom::sync::LinkAccountDialog::LinkAccountDialog(), audacity::cloud::audiocom::sync::NotCloudProjectDialog::NotCloudProjectDialog(), audacity::cloud::audiocom::sync::ProjectLimitDialog::ProjectLimitDialog(), audacity::cloud::audiocom::sync::ProjectVersionConflictDialog::ProjectVersionConflictDialog(), audacity::cloud::audiocom::sync::SyncInBackroundDialog::SyncInBackroundDialog(), audacity::cloud::audiocom::sync::SyncSucceededDialog::SyncSucceededDialog(), audacity::cloud::audiocom::sync::UnsyncedProjectDialog::UnsyncedProjectDialog(), audacity::cloud::audiocom::sync::UploadCanceledDialog::UploadCanceledDialog(), and audacity::cloud::audiocom::sync::WaitForActionDialog::WaitForActionDialog().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddTitle()

void audacity::cloud::audiocom::sync::AudioComDialogBase::AddTitle ( const TranslatableString title)
protected

Definition at line 170 of file AudioComDialogBase.cpp.

171{
172 auto font = GetFont().Bold();
173
174 font.SetFractionalPointSize(font.GetFractionalPointSize() * 1.5f);
175
176 auto statText = safenew wxStaticText { this, wxID_ANY, title.Translation() };
177
178 statText->SetFont(font);
179
180 mDialogSizer->AddSpacer(16);
181 mDialogSizer->Add(statText, wxSizerFlags {}.Border(wxLEFT | wxRIGHT, 16));
182}
static const auto title

References mDialogSizer, safenew, and title.

Referenced by audacity::cloud::audiocom::sync::LinkAccountDialog::LinkAccountDialog(), audacity::cloud::audiocom::sync::NotCloudProjectDialog::NotCloudProjectDialog(), audacity::cloud::audiocom::sync::ProjectLimitDialog::ProjectLimitDialog(), audacity::cloud::audiocom::sync::ProjectVersionConflictDialog::ProjectVersionConflictDialog(), audacity::cloud::audiocom::sync::SyncInBackroundDialog::SyncInBackroundDialog(), audacity::cloud::audiocom::sync::SyncSucceededDialog::SyncSucceededDialog(), audacity::cloud::audiocom::sync::UnsyncedProjectDialog::UnsyncedProjectDialog(), and audacity::cloud::audiocom::sync::WaitForActionDialog::WaitForActionDialog().

Here is the caller graph for this function:

◆ CancelButtonIdentifier()

DialogButtonIdentifier audacity::cloud::audiocom::sync::AudioComDialogBase::CancelButtonIdentifier ( )
static

◆ EndDialog()

void audacity::cloud::audiocom::sync::AudioComDialogBase::EndDialog ( DialogButtonIdentifier  identifier)
protected

Definition at line 223 of file AudioComDialogBase.cpp.

224{
225 mResultButtonIdentifier = std::move(identifier);
226 Close();
227}

References mResultButtonIdentifier.

Referenced by AddButton(), and AudioComDialogBase().

Here is the caller graph for this function:

◆ HasSeparator()

bool audacity::cloud::audiocom::sync::AudioComDialogBase::HasSeparator ( ) const
protectedvirtual

◆ SetDialogTitle()

void audacity::cloud::audiocom::sync::AudioComDialogBase::SetDialogTitle ( const TranslatableString dialog)
protected

Definition at line 213 of file AudioComDialogBase.cpp.

214{
215 SetTitle(dialog);
216}
void SetTitle(const TranslatableString &title)

References wxDialogWrapper::SetTitle().

Here is the call graph for this function:

◆ ShowDialog()

DialogButtonIdentifier audacity::cloud::audiocom::sync::AudioComDialogBase::ShowDialog ( std::function< DialogButtonIdentifier()>  poller = {})

Definition at line 55 of file AudioComDialogBase.cpp.

57{
58 mDialogSizer->AddStretchSpacer(1);
59
60 if (HasSeparator())
61 {
62 mDialogSizer->Add(
63 safenew wxStaticLine { this },
64 wxSizerFlags {}.Border(wxTOP, 16).Expand());
65 mDialogSizer->AddSpacer(8);
66 }
67 else
68 mDialogSizer->AddSpacer(16);
69
70 mDialogSizer->Add(
71 mButtonSizer, wxSizerFlags {}.Border(wxLEFT | wxRIGHT, 16).Expand());
72 mDialogSizer->AddSpacer(8);
73
74 SetSizerAndFit(mDialogSizer);
76 Center();
77
78 // We cannot do it earlier to avoid licking the sizers and children
80 {
83 }
84
85 Show();
86 Raise();
87
88 {
89 wxWindowDisabler disabler { this };
90
91 if (!poller)
92 poller = [] { return DialogButtonIdentifier {}; };
93
94 while (IsShown())
95 {
96 wxYield();
97
98 if (auto result = poller(); !result.empty())
99 return result;
100 }
101 }
102
103 // On Windows, parent window will lose focus after the wxWindowDisabler is destroyed
104 if (auto parent = GetParent())
105 parent->Raise();
106
107 // mResultButtonIdentifier is empty if the dialog was closed using the
108 // cross button
111}
void SetupAccessibility(wxWindow *window)
IMPORT_EXPORT_API ExportResult Show(ExportTask exportTask)
TaggedIdentifier< DialogButtonIdentifierTag > DialogButtonIdentifier

References gPrefs, audacity::BasicSettings::ReadBool(), safenew, SetupAccessibility(), and ExportProgressUI::Show().

Referenced by audacity::cloud::audiocom::sync::anonymous_namespace{CloudProjectOpenUtils.cpp}::HandleFailure(), and audacity::cloud::audiocom::sync::ProjectCloudUIExtension::OnCloudStatusChanged().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ mButtonSizer

wxBoxSizer* audacity::cloud::audiocom::sync::AudioComDialogBase::mButtonSizer
private

Definition at line 84 of file AudioComDialogBase.h.

Referenced by AddButton(), and AudioComDialogBase().

◆ mDialogSizer

wxBoxSizer* audacity::cloud::audiocom::sync::AudioComDialogBase::mDialogSizer
private

Definition at line 83 of file AudioComDialogBase.h.

Referenced by AddParagraph(), AddTitle(), and AudioComDialogBase().

◆ mEscButtonIdentifier

DialogButtonIdentifier audacity::cloud::audiocom::sync::AudioComDialogBase::mEscButtonIdentifier { CancelButtonIdentifier() }
private

Definition at line 86 of file AudioComDialogBase.h.

Referenced by AddButton(), and AudioComDialogBase().

◆ mOptionalPrefsIdentifier

DialogIdentifier audacity::cloud::audiocom::sync::AudioComDialogBase::mOptionalPrefsIdentifier
private

Definition at line 81 of file AudioComDialogBase.h.

Referenced by AudioComDialogBase().

◆ mProject

const AudacityProject* audacity::cloud::audiocom::sync::AudioComDialogBase::mProject
private

Definition at line 80 of file AudioComDialogBase.h.

◆ mResultButtonIdentifier

DialogButtonIdentifier audacity::cloud::audiocom::sync::AudioComDialogBase::mResultButtonIdentifier
private

Definition at line 87 of file AudioComDialogBase.h.

Referenced by EndDialog().


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