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)
37 new UserPanel(serviceConfig, authService, userService,
true,
this);
43 projectName, wxDefaultPosition,
44 wxDefaultSize, wxTE_PROCESS_ENTER };
49 XO(
"Cloud saving requires a free audio.com account linked to Audacity. Press \"Link account\" above to proceed.")
55 if (!projectName.empty())
61 const wxString choices[] = {
XO(
"Private").Translation(),
62 XO(
"Unlisted").Translation(),
63 XO(
"Public").Translation() };
65 mSaveToCloud =
new wxButton {
this, wxID_ANY,
XO(
"Save").Translation() };
68 new wxButton {
this, wxID_ANY,
XO(
"Save to computer...").Translation() };
69 mCancel =
new wxButton {
this, wxID_ANY,
XO(
"Cancel").Translation() };
86std::pair<CloudProjectPropertiesDialog::Action, std::string>
89 UserService& userService,
const wxString& projectName, wxWindow* parent,
93 userService, projectName, parent };
95 dialog.mSaveLocally->Show(allowLocalSave);
97 const auto resultCode = dialog.ShowModal();
100 resultCode == wxID_OK ?
104 return { action, dialog.GetProjectName() };
109 const bool canSubmit =
121 auto* topSizer =
new wxBoxSizer { wxVERTICAL };
123 constexpr auto spacerHeight = 8;
125 topSizer->AddSpacer(spacerHeight);
127 topSizer->Add(
mUserPanel, 0, wxEXPAND | wxLEFT | wxRIGHT, 16);
128 topSizer->AddSpacer(spacerHeight);
130 topSizer->Add(
new wxStaticLine {
this }, 0, wxEXPAND | wxLEFT | wxRIGHT, 16);
131 topSizer->AddSpacer(spacerHeight);
134 new wxStaticText {
this, wxID_ANY,
XO(
"Project Name").Translation() }, 0,
135 wxEXPAND | wxLEFT | wxRIGHT, 16);
136 topSizer->AddSpacer(spacerHeight);
138 topSizer->Add(
mProjectName, 0, wxEXPAND | wxLEFT | wxRIGHT, 16);
140 topSizer->AddSpacer(spacerHeight);
142 topSizer->Add(
mAnonStateText, 0, wxEXPAND | wxLEFT | wxRIGHT, 16);
144 topSizer->AddSpacer(2 * spacerHeight);
146 auto buttonSizer =
new wxBoxSizer { wxHORIZONTAL };
149 buttonSizer->AddStretchSpacer();
150 buttonSizer->Add(
mCancel, 0, wxRIGHT, 4);
153 topSizer->Add(buttonSizer, 0, wxEXPAND | wxALL, 0);
154 topSizer->AddSpacer(spacerHeight);
156 SetMinSize({ 450, -1 });
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); });
174 if (!IsEscapeKey(evt))
180 EndModal(wxID_CANCEL);
187 const auto keyCode = evt.GetKeyCode();
188 if (keyCode != WXK_RETURN && keyCode != WXK_NUMPAD_ENTER)
205 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(const ServiceConfig &serviceConfig, OAuthService &authService, UserService &userService, const wxString &projectName, wxWindow *parent)
~CloudProjectPropertiesDialog() override
static std::pair< Action, std::string > Show(const ServiceConfig &serviceConfig, OAuthService &authService, UserService &userService, const wxString &projectName, wxWindow *parent, bool allowLocalSave)
void OnUpdateCloudSaveState()
Observer::Subscription mUserStateChangedSubscription
std::string GetProjectName() const
wxTextCtrl * mProjectName
AuthorizationHandler & GetAuthorizationHandler()
std::string ToUTF8(const std::wstring &wstr)