4#include <wx/stattext.h>
6#include <wx/textctrl.h>
7#include <wx/hyperlink.h>
32 ?
XO(
"Create cloud account")
33 :
XO(
"Sign in to cloud");
46 button->SetFrameMid(2);
48 button->SetLabel(
label);
49 button->SetMinSize({206, 40});
50 button->SetSize(206, 40);
55 wxStaticText*
MakeLabel(wxWindow* parent,
const wxString& text)
57 auto label =
safenew wxStaticText(parent, wxID_ANY, text);
64 return [weak = wxWeakRef(dialog), mode](
auto code,
auto error)
72 "Please ensure your email is correct and "
73 "that your password is at least 8 characters long"),
78 ShowMessageBox(
XXO(
"Sorry, but it seems the email or password you entered is incorrect.\n"
79 "Please double-check your credentials and try again!"),
101 mOAuthStateSubscription =
103#if defined(__WXMSW__)
115 dialog.wxDialogWrapper::Center();
116 auto result = dialog.wxDialogWrapper::ShowModal();
122 return result == wxID_OK;
128 wxFont titleFont = GetFont();
129 titleFont.SetWeight(wxFONTWEIGHT_BOLD);
130 titleFont.SetPixelSize({ 0, 18 });
132 auto topSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
137 ?
_(
"Create an account to save to the cloud")
138 :
_(
"Sign in to save to the cloud")),
140 title->SetFont(titleFont);
142 auto hSizer = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
144 hSizer->AddSpacer(8);
147 topSizer->Add(hSizer.release(), 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 16);
151 auto vSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
152 vSizer->Add(
MakeLabel(
this,
_(
"Email")), 0, wxBOTTOM, 5);
153 vSizer->Add(
mEmail =
safenew wxTextCtrl(
this, wxID_ANY), 0, wxEXPAND);
154 topSizer->Add(vSizer.release(), 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 16);
157 auto vSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
158 vSizer->Add(
MakeLabel(
this,
_(
"Password")), 0, wxBOTTOM, 5);
171 topSizer->Add(vSizer.release(), 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 16);
178 auto hSizer = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
180 hSizer->Add(
MakeLabel(
this,
_(
"Already have an account? ")), 0, wxALIGN_CENTER_VERTICAL);
182 topSizer->Add(hSizer.release(), 0, wxEXPAND | wxLEFT | wxRIGHT, 16);
186 auto hSizer = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
188 hSizer->Add(
MakeLabel(
this,
_(
"Need an account? ")), 0, wxALIGN_CENTER_VERTICAL);
190 topSizer->Add(hSizer.release(), 0, wxEXPAND | wxALL, 16);
194 auto hSizer = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
195 hSizer->Add(
safenew wxButton(
this, wxID_CANCEL,
_(
"Cancel")));
196 hSizer->AddSpacer(8);
198 topSizer->Add(hSizer.release(), 0, wxALIGN_RIGHT | wxALL, 16);
204 SetSizerAndFit(topSizer.release());
251 const auto email =
mEmail->GetValue().ToStdString();
252 const auto password =
mPassword->GetValue().ToStdString();
255 oauthService.Register(
258 [weakThis = wxWeakRef(
this)](
auto token)
270 weakThis->EndModal(wxID_OK);
281 const auto email =
mEmail->GetValue().ToStdString();
282 const auto password =
mPassword->GetValue().ToStdString();
285 oauthService.Authorize(email, password,
286 [weakThis = wxWeakRef(
this)](
auto token)
298 weakThis->EndModal(wxID_OK);
Toolkit-neutral facade for basic user interface services.
EVT_BUTTON(wxID_NO, DependencyDialog::OnNo) EVT_BUTTON(wxID_YES
XXO("&Cut/Copy/Paste Toolbar")
void OnContinue(wxCommandEvent &)
void OnContinueWithFacebook(wxCommandEvent &)
void OnContinueWithGoogle(wxCommandEvent &)
void onUserCredentialsChange(wxCommandEvent &)
void OnSignIn(wxHyperlinkEvent &)
void ContinueCreateAccount()
void OnOAuthStateChanged(audacity::cloud::audiocom::AuthStateChangedMessage)
void OnCreateAccount(wxHyperlinkEvent &)
static void ContinueAuthorize(std::string_view authClientId)
static bool SignIn(wxWindow *parent, Mode mode=Mode::SignIn)
Subscription Subscribe(Callback callback)
Connect a callback to the Publisher; later-connected are called earlier.
wxColour & Colour(int iIndex)
wxImage & Image(int iIndex)
Holds a msgid for the translation catalog; may also bind format arguments.
static std::string MakeOAuthRequestURL(std::string_view authClientId)
Creates a link to authorization request dialog.
bool OpenInDefaultBrowser(const wxString &url)
Open an URL in default browser.
void CallAfter(Action action)
Schedule an action to be done later, and in the main thread.
MessageBoxResult ShowMessageBox(const TranslatableString &message, MessageBoxOptions options={})
Show a modal message box with either Ok or Yes and No, and optionally Cancel.
auto DialogNameForMode(LoginDialog::Mode mode)
AButton * MakeLoginButton(wxWindow *parent, wxWindowID id, int imageId, const TranslatableString &label)
wxStaticText * MakeLabel(wxWindow *parent, const wxString &text)
constexpr auto RestorePasswordURL
auto DefaultErrorHandler(LoginDialog *dialog, LoginDialog::Mode mode)
OAuthService & GetOAuthService()
Returns the instance of the OAuthService.
MessageBoxOptions && IconStyle(Icon style) &&
Message that is sent when authorization state changes.
bool authorised
Flag that indicates if user is authorised.