17#include <wx/statline.h>
18#include <wx/stattext.h>
19#include <wx/textctrl.h>
21#include "../UserPanel.h"
31 UserService& userService,
const wxString& projectName, wxWindow* parent,
38 new UserPanel(serviceConfig, authService, userService,
true, trace,
this);
44 projectName, wxDefaultPosition,
45 wxDefaultSize, wxTE_PROCESS_ENTER };
50 XO(
"Cloud saving requires a free audio.com account linked to Audacity. Press \"Link account\" above to proceed.")
56 if (!projectName.empty())
62 const wxString choices[] = {
XO(
"Private").Translation(),
63 XO(
"Unlisted").Translation(),
64 XO(
"Public").Translation() };
66 mSaveToCloud =
new wxButton {
this, wxID_ANY,
XO(
"Save").Translation() };
69 new wxButton {
this, wxID_ANY,
XO(
"Save to computer...").Translation() };
70 mCancel =
new wxButton {
this, wxID_ANY,
XO(
"Cancel").Translation() };
87std::pair<CloudProjectPropertiesDialog::Action, std::string>
90 UserService& userService,
const wxString& projectName, wxWindow* parent,
94 userService, projectName,
97 dialog.mSaveLocally->Show(allowLocalSave);
99 const auto resultCode = dialog.ShowModal();
102 resultCode == wxID_OK ?
106 return { action, dialog.GetProjectName() };
111 const bool canSubmit =
123 auto* topSizer =
new wxBoxSizer { wxVERTICAL };
125 constexpr auto spacerHeight = 8;
127 topSizer->AddSpacer(spacerHeight);
129 topSizer->Add(
mUserPanel, 0, wxEXPAND | wxLEFT | wxRIGHT, 16);
130 topSizer->AddSpacer(spacerHeight);
132 topSizer->Add(
new wxStaticLine {
this }, 0, wxEXPAND | wxLEFT | wxRIGHT, 16);
133 topSizer->AddSpacer(spacerHeight);
136 new wxStaticText {
this, wxID_ANY,
XO(
"Project Name").Translation() }, 0,
137 wxEXPAND | wxLEFT | wxRIGHT, 16);
138 topSizer->AddSpacer(spacerHeight);
140 topSizer->Add(
mProjectName, 0, wxEXPAND | wxLEFT | wxRIGHT, 16);
142 topSizer->AddSpacer(spacerHeight);
144 topSizer->Add(
mAnonStateText, 0, wxEXPAND | wxLEFT | wxRIGHT, 16);
146 topSizer->AddSpacer(2 * spacerHeight);
148 auto buttonSizer =
new wxBoxSizer { wxHORIZONTAL };
151 buttonSizer->AddStretchSpacer();
152 buttonSizer->Add(
mCancel, 0, wxRIGHT, 4);
155 topSizer->Add(buttonSizer, 0, wxEXPAND | wxALL, 0);
156 topSizer->AddSpacer(spacerHeight);
158 SetMinSize({ 450, -1 });
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); });
176 if (!IsEscapeKey(evt))
182 EndModal(wxID_CANCEL);
189 const auto keyCode = evt.GetKeyCode();
190 if (keyCode != WXK_RETURN && keyCode != WXK_NUMPAD_ENTER)
207 result.Trim(
true).Trim(
false);
void SetupAccessibility(wxWindow *window)
Declare functions to perform UTF-8 to std::wstring conversions.
Subscription Subscribe(Callback callback)
Connect a callback to the Publisher; later-connected are called earlier.
void PopSuppressDialogs()
void PushSuppressDialogs()
Service responsible for OAuth authentication against the audio.com service.
Configuration for the audio.com.
bool IsAuthorized() const
Service for providing information about the user profile.
wxStaticText * mAnonStateText
~CloudProjectPropertiesDialog() override
void OnUpdateCloudSaveState()
static std::pair< Action, std::string > Show(const ServiceConfig &serviceConfig, OAuthService &authService, UserService &userService, const wxString &projectName, wxWindow *parent, bool allowLocalSave, AudiocomTrace)
Observer::Subscription mUserStateChangedSubscription
std::string GetProjectName() const
wxTextCtrl * mProjectName
CloudProjectPropertiesDialog(const ServiceConfig &serviceConfig, OAuthService &authService, UserService &userService, const wxString &projectName, wxWindow *parent, AudiocomTrace)
AuthorizationHandler & GetAuthorizationHandler()
std::string ToUTF8(const std::wstring &wstr)