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 {}
 
wxStaticText * mAnonStateText {}
 
Observer::Subscription mUserStateChangedSubscription {}
 

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 29 of file CloudProjectPropertiesDialog.cpp.

33 : wxDialogWrapper { parent, wxID_ANY, XO("Save to audio.com") }
34{
36
38 new UserPanel(serviceConfig, authService, userService, true, trace, this);
39
41 mUserPanel->Subscribe([this](auto) { OnUpdateCloudSaveState(); });
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 mAnonStateText = safenew wxStaticText {
49 this, wxID_ANY,
50 XO("Cloud saving requires a free audio.com account linked to Audacity. Press \"Link account\" above to proceed.")
51 .Translation()
52 };
53
54 mAnonStateText->Wrap(450 - 32);
55
56 if (!projectName.empty())
57 {
58 mProjectName->SetValue(projectName);
59 // mProjectName->SetInsertionPoint(-1);
60 }
61
62 const wxString choices[] = { XO("Private").Translation(),
63 XO("Unlisted").Translation(),
64 XO("Public").Translation() };
65
66 mSaveToCloud = new wxButton { this, wxID_ANY, XO("Save").Translation() };
67
69 new wxButton { this, wxID_ANY, XO("Save to computer...").Translation() };
70 mCancel = new wxButton { this, wxID_ANY, XO("Cancel").Translation() };
71
72 mProjectName->SetFocus();
73
76
78
80}
void SetupAccessibility(wxWindow *window)
XO("Cut/Copy/Paste")
#define safenew
Definition: MemoryX.h:10
Subscription Subscribe(Callback callback)
Connect a callback to the Publisher; later-connected are called earlier.
Definition: Observer.h:199
AuthorizationHandler & GetAuthorizationHandler()

References audacity::cloud::audiocom::GetAuthorizationHandler(), LayoutControls(), mAnonStateText, mCancel, mProjectName, mSaveLocally, mSaveToCloud, mUserPanel, mUserStateChangedSubscription, OnUpdateCloudSaveState(), audacity::cloud::audiocom::AuthorizationHandler::PushSuppressDialogs(), safenew, SetupAccessibility(), SetupEvents(), Observer::Publisher< Message, NotifyAll >::Subscribe(), and XO().

Here is the call graph for this function:

◆ ~CloudProjectPropertiesDialog()

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

Definition at line 82 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 121 of file CloudProjectPropertiesDialog.cpp.

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

References audacity::cloud::audiocom::UserPanel::IsAuthorized(), mAnonStateText, 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 109 of file CloudProjectPropertiesDialog.cpp.

110{
111 const bool canSubmit =
112 mUserPanel->IsAuthorized() && !GetProjectName().empty();
113
114 if (!canSubmit)
115 return false;
116
117 EndModal(wxID_OK);
118 return true;
119}

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(
214 mUserPanel->IsAuthorized() && !GetProjectName().empty());
215
217 Fit();
218 Layout();
219}

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

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 166 of file CloudProjectPropertiesDialog.cpp.

167{
168 mSaveToCloud->Bind(wxEVT_BUTTON, [this](auto&) { EndModal(wxID_OK); });
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}

References mCancel, mProjectName, mSaveLocally, mSaveToCloud, OnSubmit(), and OnUpdateCloudSaveState().

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 88 of file CloudProjectPropertiesDialog.cpp.

92{
93 CloudProjectPropertiesDialog dialog { serviceConfig, authService,
94 userService, projectName,
95 parent, trace };
96
97 dialog.mSaveLocally->Show(allowLocalSave);
98
99 const auto resultCode = dialog.ShowModal();
100
101 const auto action =
102 resultCode == wxID_OK ?
104 (resultCode == wxID_CANCEL ? Action::Cancel : Action::SaveLocally);
105
106 return { action, dialog.GetProjectName() };
107}
CloudProjectPropertiesDialog(const ServiceConfig &serviceConfig, OAuthService &authService, UserService &userService, const wxString &projectName, wxWindow *parent, AudiocomTrace)

References Cancel, SaveLocally, and SaveToCloud.

Member Data Documentation

◆ mAnonStateText

wxStaticText* audacity::cloud::audiocom::sync::CloudProjectPropertiesDialog::mAnonStateText {}
private

◆ 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

◆ mUserStateChangedSubscription

Observer::Subscription audacity::cloud::audiocom::sync::CloudProjectPropertiesDialog::mUserStateChangedSubscription {}
private

Definition at line 75 of file CloudProjectPropertiesDialog.h.

Referenced by CloudProjectPropertiesDialog().


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