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

#include <CloudProjectPropertiesDialog.h>

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

Public Types

enum class  Action { Cancel , SaveToCloud , SaveLocally }
 

Static Public Member Functions

static std::pair< Action, std::string > Show (const ServiceConfig &serviceConfig, OAuthService &authService, UserService &userService, const wxString &projectName, wxWindow *parent, bool allowLocalSave, AudiocomTrace)
 

Private Member Functions

 CloudProjectPropertiesDialog (const ServiceConfig &serviceConfig, OAuthService &authService, UserService &userService, const wxString &projectName, wxWindow *parent, AudiocomTrace)
 
 ~CloudProjectPropertiesDialog () override
 
bool OnSubmit ()
 
void LayoutControls ()
 
void SetupEvents ()
 
std::string GetProjectName () const
 
void OnUpdateCloudSaveState ()
 

Private Attributes

UserPanelmUserPanel {}
 
wxTextCtrl * mProjectName {}
 
wxButton * mSaveToCloud {}
 
wxButton * mSaveLocally {}
 
wxButton * mCancel {}
 

Additional Inherited Members

- 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
 

Detailed Description

Definition at line 37 of file CloudProjectPropertiesDialog.h.

Member Enumeration Documentation

◆ Action

Enumerator
Cancel 
SaveToCloud 
SaveLocally 

Definition at line 46 of file CloudProjectPropertiesDialog.h.

47 {
48 Cancel,
50 SaveLocally
51 };
void SaveToCloud(AudacityProject &project, UploadMode mode, CreateSnapshotCallback snapshotCallback)

Constructor & Destructor Documentation

◆ CloudProjectPropertiesDialog()

audacity::cloud::audiocom::sync::CloudProjectPropertiesDialog::CloudProjectPropertiesDialog ( const ServiceConfig serviceConfig,
OAuthService authService,
UserService userService,
const wxString &  projectName,
wxWindow *  parent,
AudiocomTrace  trace 
)
private

Definition at line 31 of file CloudProjectPropertiesDialog.cpp.

35 : wxDialogWrapper { parent, wxID_ANY, XO("Save to audio.com") }
36{
38
40 new UserPanel(serviceConfig, authService, userService,
41 UserPanel::LinkMode::SignIn, trace, this);
42
43 mProjectName = new wxTextCtrl { this, wxID_ANY,
44 projectName, wxDefaultPosition,
45 wxDefaultSize, wxTE_PROCESS_ENTER };
46 mProjectName->SetName(XO("Project Name").Translation());
47
48 if (!projectName.empty())
49 {
50 mProjectName->SetValue(projectName);
51 // mProjectName->SetInsertionPoint(-1);
52 }
53
54 const wxString choices[] = { XO("Private").Translation(),
55 XO("Unlisted").Translation(),
56 XO("Public").Translation() };
57
58 mSaveToCloud = new wxButton { this, wxID_ANY, XO("Save").Translation() };
59
61 new wxButton { this, wxID_ANY, XO("Save to computer...").Translation() };
62 mCancel = new wxButton { this, wxID_ANY, XO("Cancel").Translation() };
63
64 mProjectName->SetFocus();
65
68
70
72}
void SetupAccessibility(wxWindow *window)
XO("Cut/Copy/Paste")
AuthorizationHandler & GetAuthorizationHandler()

References audacity::cloud::audiocom::GetAuthorizationHandler(), LayoutControls(), mCancel, mProjectName, mSaveLocally, mSaveToCloud, mUserPanel, OnUpdateCloudSaveState(), audacity::cloud::audiocom::AuthorizationHandler::PushSuppressDialogs(), SetupAccessibility(), SetupEvents(), audacity::cloud::audiocom::UserPanel::SignIn, and XO().

Here is the call graph for this function:

◆ ~CloudProjectPropertiesDialog()

audacity::cloud::audiocom::sync::CloudProjectPropertiesDialog::~CloudProjectPropertiesDialog ( )
overrideprivate

Definition at line 74 of file CloudProjectPropertiesDialog.cpp.

References audacity::cloud::audiocom::GetAuthorizationHandler(), and audacity::cloud::audiocom::AuthorizationHandler::PopSuppressDialogs().

Here is the call graph for this function:

Member Function Documentation

◆ GetProjectName()

std::string audacity::cloud::audiocom::sync::CloudProjectPropertiesDialog::GetProjectName ( ) const
private

Definition at line 204 of file CloudProjectPropertiesDialog.cpp.

205{
206 wxString result { mProjectName->GetValue() };
207 result.Trim(true).Trim(false);
208 return audacity::ToUTF8(result);
209}
std::string ToUTF8(const std::wstring &wstr)

References mProjectName, and audacity::ToUTF8().

Referenced by OnSubmit(), and OnUpdateCloudSaveState().

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

◆ LayoutControls()

void audacity::cloud::audiocom::sync::CloudProjectPropertiesDialog::LayoutControls ( )
private

Definition at line 113 of file CloudProjectPropertiesDialog.cpp.

114{
115 auto* topSizer = new wxBoxSizer { wxVERTICAL };
116
117 constexpr auto spacerHeight = 8;
118
119 topSizer->AddSpacer(spacerHeight);
120
121 topSizer->Add(mUserPanel, 0, wxEXPAND | wxLEFT | wxRIGHT, 16);
122 topSizer->AddSpacer(spacerHeight);
123
124 topSizer->Add(new wxStaticLine { this }, 0, wxEXPAND | wxLEFT | wxRIGHT, 16);
125 topSizer->AddSpacer(spacerHeight);
126
127 topSizer->Add(
128 new wxStaticText { this, wxID_ANY, XO("Project Name").Translation() }, 0,
129 wxEXPAND | wxLEFT | wxRIGHT, 16);
130 topSizer->AddSpacer(spacerHeight);
131
132 topSizer->Add(mProjectName, 0, wxEXPAND | wxLEFT | wxRIGHT, 16);
133
134 topSizer->AddSpacer(spacerHeight);
135
136 topSizer->AddSpacer(2 * spacerHeight);
137
138 auto buttonSizer = new wxBoxSizer { wxHORIZONTAL };
139
140 buttonSizer->Add(mSaveLocally, 0, wxLEFT, 16);
141 buttonSizer->AddStretchSpacer();
142 buttonSizer->Add(mCancel, 0, wxRIGHT, 4);
143 buttonSizer->Add(mSaveToCloud, 0, wxRIGHT, 16);
144
145 topSizer->Add(buttonSizer, 0, wxEXPAND | wxALL, 0);
146 topSizer->AddSpacer(spacerHeight);
147
148 SetMinSize({ 450, -1 });
149 SetSizer(topSizer);
150 Fit();
151 Centre(wxBOTH);
152}

References mCancel, mProjectName, mSaveLocally, mSaveToCloud, mUserPanel, and XO().

Referenced by CloudProjectPropertiesDialog().

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

◆ OnSubmit()

bool audacity::cloud::audiocom::sync::CloudProjectPropertiesDialog::OnSubmit ( )
private

Definition at line 101 of file CloudProjectPropertiesDialog.cpp.

102{
103 const bool canSubmit =
104 mUserPanel->IsAuthorized() && !GetProjectName().empty();
105
106 if (!canSubmit)
107 return false;
108
109 EndModal(wxID_OK);
110 return true;
111}

References GetProjectName(), audacity::cloud::audiocom::UserPanel::IsAuthorized(), and mUserPanel.

Referenced by SetupEvents().

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

◆ OnUpdateCloudSaveState()

void audacity::cloud::audiocom::sync::CloudProjectPropertiesDialog::OnUpdateCloudSaveState ( )
private

Definition at line 211 of file CloudProjectPropertiesDialog.cpp.

212{
213 mSaveToCloud->Enable(!GetProjectName().empty());
214}

References GetProjectName(), and mSaveToCloud.

Referenced by CloudProjectPropertiesDialog(), and SetupEvents().

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

◆ SetupEvents()

void audacity::cloud::audiocom::sync::CloudProjectPropertiesDialog::SetupEvents ( )
private

Definition at line 154 of file CloudProjectPropertiesDialog.cpp.

155{
156 mSaveToCloud->Bind(wxEVT_BUTTON, [this](auto&)
157 {
158 Disable();
159 if(!GetOAuthService().HasAccessToken())
160 {
162 }
163 Enable();
164 if(GetOAuthService().HasAccessToken())
165 {
166 EndModal(wxID_OK);
167 }
168 });
169 mSaveLocally->Bind(wxEVT_BUTTON, [this](auto&) { EndModal(wxID_SAVE); });
170 mCancel->Bind(wxEVT_BUTTON, [this](auto&) { EndModal(wxID_CANCEL); });
171
172 Bind(
173 wxEVT_CHAR_HOOK,
174 [this](auto& evt)
175 {
176 if (!IsEscapeKey(evt))
177 {
178 evt.Skip();
179 return;
180 }
181
182 EndModal(wxID_CANCEL);
183 });
184
185 Bind(
186 wxEVT_KEY_UP,
187 [this](auto& evt)
188 {
189 const auto keyCode = evt.GetKeyCode();
190 if (keyCode != WXK_RETURN && keyCode != WXK_NUMPAD_ENTER)
191 {
192 evt.Skip();
193 return;
194 }
195
196 if (!OnSubmit())
197 evt.Skip();
198 });
199
200 mProjectName->Bind(wxEVT_TEXT, [this](auto&) { OnUpdateCloudSaveState(); });
201 mProjectName->Bind(wxEVT_TEXT_ENTER, [this](auto&) { OnSubmit(); });
202}
static bool SignIn(wxWindow *parent, Mode mode=Mode::SignIn)
OAuthService & GetOAuthService()
Returns the instance of the OAuthService.

References LoginDialog::Create, audacity::cloud::audiocom::GetOAuthService(), mCancel, mProjectName, mSaveLocally, mSaveToCloud, OnSubmit(), OnUpdateCloudSaveState(), and LoginDialog::SignIn().

Referenced by CloudProjectPropertiesDialog().

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

◆ Show()

std::pair< CloudProjectPropertiesDialog::Action, std::string > audacity::cloud::audiocom::sync::CloudProjectPropertiesDialog::Show ( const ServiceConfig serviceConfig,
OAuthService authService,
UserService userService,
const wxString &  projectName,
wxWindow *  parent,
bool  allowLocalSave,
AudiocomTrace  trace 
)
static

Definition at line 80 of file CloudProjectPropertiesDialog.cpp.

84{
85 CloudProjectPropertiesDialog dialog { serviceConfig, authService,
86 userService, projectName,
87 parent, trace };
88
89 dialog.mSaveLocally->Show(allowLocalSave);
90
91 const auto resultCode = dialog.ShowModal();
92
93 const auto action =
94 resultCode == wxID_OK ?
96 (resultCode == wxID_CANCEL ? Action::Cancel : Action::SaveLocally);
97
98 return { action, dialog.GetProjectName() };
99}
CloudProjectPropertiesDialog(const ServiceConfig &serviceConfig, OAuthService &authService, UserService &userService, const wxString &projectName, wxWindow *parent, AudiocomTrace)

References Cancel, SaveLocally, and SaveToCloud.

Member Data Documentation

◆ mCancel

wxButton* audacity::cloud::audiocom::sync::CloudProjectPropertiesDialog::mCancel {}
private

◆ mProjectName

wxTextCtrl* audacity::cloud::audiocom::sync::CloudProjectPropertiesDialog::mProjectName {}
private

◆ mSaveLocally

wxButton* audacity::cloud::audiocom::sync::CloudProjectPropertiesDialog::mSaveLocally {}
private

◆ mSaveToCloud

wxButton* audacity::cloud::audiocom::sync::CloudProjectPropertiesDialog::mSaveToCloud {}
private

◆ mUserPanel

UserPanel* audacity::cloud::audiocom::sync::CloudProjectPropertiesDialog::mUserPanel {}
private

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