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

#include <LinkWithTokenDialog.h>

Inheritance diagram for audacity::cloud::audiocom::LinkWithTokenDialog:
[legend]
Collaboration diagram for audacity::cloud::audiocom::LinkWithTokenDialog:
[legend]

Public Member Functions

 LinkWithTokenDialog (wxWindow *parent=nullptr)
 
 ~LinkWithTokenDialog () 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 LinkWithTokenDialog.h.

Constructor & Destructor Documentation

◆ LinkWithTokenDialog()

audacity::cloud::audiocom::LinkWithTokenDialog::LinkWithTokenDialog ( wxWindow *  parent = nullptr)
explicit

Definition at line 31 of file LinkWithTokenDialog.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
80 mToken->SetFocus();
81}
XO("Cut/Copy/Paste")
XXO("&Cut/Copy/Paste Toolbar")
#define safenew
Definition: MemoryX.h:10
@ eIsCreating
Definition: ShuttleGui.h:37
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:640
Holds a msgid for the translation catalog; may also bind format arguments.
AuthorizationHandler & GetAuthorizationHandler()

◆ ~LinkWithTokenDialog()

audacity::cloud::audiocom::LinkWithTokenDialog::~LinkWithTokenDialog ( )
override

Definition at line 83 of file LinkWithTokenDialog.cpp.

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

Here is the call graph for this function:

Member Function Documentation

◆ OnContinue()

void audacity::cloud::audiocom::LinkWithTokenDialog::OnContinue ( )
private

Definition at line 88 of file LinkWithTokenDialog.cpp.

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

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

Here is the call graph for this function:

◆ OnTextChanged()

void audacity::cloud::audiocom::LinkWithTokenDialog::OnTextChanged ( )
private

Definition at line 126 of file LinkWithTokenDialog.cpp.

127{
128 mContinueButton->Enable(!mToken->GetValue().empty());
129}

Member Data Documentation

◆ mContinueButton

wxButton* audacity::cloud::audiocom::LinkWithTokenDialog::mContinueButton { nullptr }
private

Definition at line 30 of file LinkWithTokenDialog.h.

Referenced by OnContinue().

◆ mToken

wxTextCtrl* audacity::cloud::audiocom::LinkWithTokenDialog::mToken { nullptr }
private

Definition at line 31 of file LinkWithTokenDialog.h.

Referenced by OnContinue().


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