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)
 

Private Member Functions

 CloudProjectPropertiesDialog (const ServiceConfig &serviceConfig, OAuthService &authService, UserService &userService, const wxString &projectName, wxWindow *parent)
 
 ~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 36 of file CloudProjectPropertiesDialog.h.

Member Enumeration Documentation

◆ Action

Enumerator
Cancel 
SaveToCloud 
SaveLocally 

Definition at line 44 of file CloudProjectPropertiesDialog.h.

45 {
46 Cancel,
48 SaveLocally
49 };
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 
)
private

Definition at line 29 of file CloudProjectPropertiesDialog.cpp.

32 : wxDialogWrapper { parent, wxID_ANY, XO("Save to audio.com") }
33{
35
37 new UserPanel(serviceConfig, authService, userService, true, this);
38
40 mUserPanel->Subscribe([this](auto) { OnUpdateCloudSaveState(); });
41
42 mProjectName = new wxTextCtrl { this, wxID_ANY,
43 projectName, wxDefaultPosition,
44 wxDefaultSize, wxTE_PROCESS_ENTER };
45 mProjectName->SetName(XO("Project Name").Translation());
46
47 mAnonStateText = safenew wxStaticText {
48 this, wxID_ANY,
49 XO("Cloud saving requires a free audio.com account linked to Audacity. Press \"Link account\" above to proceed.")
50 .Translation()
51 };
52
53 mAnonStateText->Wrap(450 - 32);
54
55 if (!projectName.empty())
56 {
57 mProjectName->SetValue(projectName);
58 // mProjectName->SetInsertionPoint(-1);
59 }
60
61 const wxString choices[] = { XO("Private").Translation(),
62 XO("Unlisted").Translation(),
63 XO("Public").Translation() };
64
65 mSaveToCloud = new wxButton { this, wxID_ANY, XO("Save").Translation() };
66
68 new wxButton { this, wxID_ANY, XO("Save to computer...").Translation() };
69 mCancel = new wxButton { this, wxID_ANY, XO("Cancel").Translation() };
70
71 mProjectName->SetFocus();
72
75
77
79}
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 81 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 202 of file CloudProjectPropertiesDialog.cpp.

203{
204 wxString result { mProjectName->GetValue() };
205 result.Trim(true).Trim(false);
206 return audacity::ToUTF8(result);
207}
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 119 of file CloudProjectPropertiesDialog.cpp.

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

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

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

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

210{
211 mSaveToCloud->Enable(
212 mUserPanel->IsAuthorized() && !GetProjectName().empty());
213
215 Fit();
216 Layout();
217}

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

165{
166 mSaveToCloud->Bind(wxEVT_BUTTON, [this](auto&) { EndModal(wxID_OK); });
167 mSaveLocally->Bind(wxEVT_BUTTON, [this](auto&) { EndModal(wxID_SAVE); });
168 mCancel->Bind(wxEVT_BUTTON, [this](auto&) { EndModal(wxID_CANCEL); });
169
170 Bind(
171 wxEVT_CHAR_HOOK,
172 [this](auto& evt)
173 {
174 if (!IsEscapeKey(evt))
175 {
176 evt.Skip();
177 return;
178 }
179
180 EndModal(wxID_CANCEL);
181 });
182
183 Bind(
184 wxEVT_KEY_UP,
185 [this](auto& evt)
186 {
187 const auto keyCode = evt.GetKeyCode();
188 if (keyCode != WXK_RETURN && keyCode != WXK_NUMPAD_ENTER)
189 {
190 evt.Skip();
191 return;
192 }
193
194 if (!OnSubmit())
195 evt.Skip();
196 });
197
198 mProjectName->Bind(wxEVT_TEXT, [this](auto&) { OnUpdateCloudSaveState(); });
199 mProjectName->Bind(wxEVT_TEXT_ENTER, [this](auto&) { OnSubmit(); });
200}

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 
)
static

Definition at line 87 of file CloudProjectPropertiesDialog.cpp.

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

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 72 of file CloudProjectPropertiesDialog.h.

Referenced by CloudProjectPropertiesDialog().


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