Audacity 3.2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
cloud::audiocom::LinkAccountDialog Class Referencefinal

#include <LinkAccountDialog.h>

Inheritance diagram for cloud::audiocom::LinkAccountDialog:
[legend]
Collaboration diagram for cloud::audiocom::LinkAccountDialog:
[legend]

Public Member Functions

 LinkAccountDialog (wxWindow *parent=nullptr)
 
 ~LinkAccountDialog () override
 
- 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
 

Private Member Functions

void OnContinue ()
 
void OnTextChanged ()
 

Private Attributes

wxButton * mContinueButton { nullptr }
 
wxTextCtrl * mToken { nullptr }
 

Detailed Description

Definition at line 20 of file LinkAccountDialog.h.

Constructor & Destructor Documentation

◆ LinkAccountDialog()

cloud::audiocom::LinkAccountDialog::LinkAccountDialog ( wxWindow *  parent = nullptr)
explicit

Definition at line 31 of file LinkAccountDialog.cpp.

33 parent, wxID_ANY, XO("Link account"), wxDefaultPosition, { 480, -1 },
34 wxDEFAULT_DIALOG_STYLE)
35{
37
38 ShuttleGui s(this, eIsCreating);
39
40 s.StartVerticalLay();
41 {
42 s.StartInvisiblePanel(16);
43 {
44 s.SetBorder(0);
45 s.AddFixedText(XO("Enter token to link your account"));
46
47 s.AddSpace(0, 4, 0);
48
49 mToken = s.AddTextBox(TranslatableString {}, {}, 60);
50 mToken->SetName(XO("Token").Translation());
51 mToken->Bind(wxEVT_TEXT, [this](auto) { OnTextChanged(); });
52
53 s.AddSpace(0, 16, 0);
54
55 s.AddWindow(safenew wxStaticLine { s.GetParent() }, wxEXPAND);
56
57 s.AddSpace(0, 10, 0);
58
59 s.StartHorizontalLay(wxEXPAND, 0);
60 {
61 s.AddSpace(0, 0, 1);
62
63 s.AddButton(XXO("&Cancel"))
64 ->Bind(wxEVT_BUTTON, [this](auto) { Close(); });
65
66 mContinueButton = s.AddButton(XXO("C&ontinue"));
67 mContinueButton->Disable();
68 mContinueButton->Bind(wxEVT_BUTTON, [this](auto) { OnContinue(); });
69 }
70 s.EndHorizontalLay();
71 }
72 s.EndInvisiblePanel();
73 }
74 s.EndVerticalLay();
75
76 Layout();
77 Fit();
78 Centre();
79}
XO("Cut/Copy/Paste")
XXO("&Cut/Copy/Paste Toolbar")
#define safenew
Definition: MemoryX.h:10
@ eIsCreating
Definition: ShuttleGui.h:39
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:628
Holds a msgid for the translation catalog; may also bind format arguments.
AuthorizationHandler & GetAuthorizationHandler()

◆ ~LinkAccountDialog()

cloud::audiocom::LinkAccountDialog::~LinkAccountDialog ( )
override

Definition at line 81 of file LinkAccountDialog.cpp.

References cloud::audiocom::GetAuthorizationHandler(), and cloud::audiocom::AuthorizationHandler::PopSuppressDialogs().

Here is the call graph for this function:

Member Function Documentation

◆ OnContinue()

void cloud::audiocom::LinkAccountDialog::OnContinue ( )
private

Definition at line 86 of file LinkAccountDialog.cpp.

87{
88 mContinueButton->Disable();
89
90 wxWeakRef<LinkAccountDialog> weakDialog(this);
91
93 audacity::ToUTF8(mToken->GetValue()),
94 [weakDialog](auto accessToken)
95 {
96 BasicUI::CallAfter(
97 [weakDialog, token = std::string(accessToken)]()
98 {
99 if (!token.empty())
100 {
101 if (weakDialog)
102 {
103 auto parent = weakDialog->GetParent();
104 weakDialog->Close();
105
106 LinkSucceededDialog successDialog { parent };
107 successDialog.ShowModal();
108 }
109
110 return;
111 }
112
113 LinkFailedDialog errorDialog(weakDialog);
114
115 if (wxID_RETRY != errorDialog.ShowModal())
116 {
117 if (weakDialog)
118 weakDialog->Close();
119 }
120 });
121 });
122}
void HandleLinkURI(std::string_view uri, std::function< void(std::string_view)> completedHandler)
Handle the OAuth callback.
std::string ToUTF8(const std::wstring &wstr)
OAuthService & GetOAuthService()
Returns the instance of the OAuthService.

References cloud::audiocom::GetOAuthService(), cloud::audiocom::OAuthService::HandleLinkURI(), mContinueButton, mToken, and audacity::ToUTF8().

Here is the call graph for this function:

◆ OnTextChanged()

void cloud::audiocom::LinkAccountDialog::OnTextChanged ( )
private

Definition at line 124 of file LinkAccountDialog.cpp.

125{
126 mContinueButton->Enable(!mToken->GetValue().empty());
127}

Member Data Documentation

◆ mContinueButton

wxButton* cloud::audiocom::LinkAccountDialog::mContinueButton { nullptr }
private

Definition at line 30 of file LinkAccountDialog.h.

Referenced by OnContinue().

◆ mToken

wxTextCtrl* cloud::audiocom::LinkAccountDialog::mToken { nullptr }
private

Definition at line 31 of file LinkAccountDialog.h.

Referenced by OnContinue().


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