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 (AudiocomTrace, 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 }
 
const AudiocomTrace mAudiocomTrace
 

Detailed Description

Definition at line 21 of file LinkWithTokenDialog.h.

Constructor & Destructor Documentation

◆ LinkWithTokenDialog()

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

Definition at line 32 of file LinkWithTokenDialog.cpp.

34 parent, wxID_ANY, XO("Link account"), wxDefaultPosition, { 480, -1 },
35 wxDEFAULT_DIALOG_STYLE)
36 , mAudiocomTrace(trace)
37{
39
40 ShuttleGui s(this, eIsCreating);
41
42 s.StartVerticalLay();
43 {
44 s.StartInvisiblePanel(16);
45 {
46 s.SetBorder(0);
47 s.AddFixedText(XO("Enter token to link your account"));
48
49 s.AddSpace(0, 4, 0);
50
51 mToken = s.AddTextBox(TranslatableString {}, {}, 60);
52 mToken->SetName(XO("Token").Translation());
53 mToken->Bind(wxEVT_TEXT, [this](auto) { OnTextChanged(); });
54
55 s.AddSpace(0, 16, 0);
56
57 s.AddWindow(safenew wxStaticLine { s.GetParent() }, wxEXPAND);
58
59 s.AddSpace(0, 10, 0);
60
61 s.StartHorizontalLay(wxEXPAND, 0);
62 {
63 s.AddSpace(0, 0, 1);
64
65 s.AddButton(XXO("&Cancel"))
66 ->Bind(wxEVT_BUTTON, [this](auto) { Close(); });
67
68 mContinueButton = s.AddButton(XXO("C&ontinue"));
69 mContinueButton->Disable();
70 mContinueButton->Bind(wxEVT_BUTTON, [this](auto) { OnContinue(); });
71 }
72 s.EndHorizontalLay();
73 }
74 s.EndInvisiblePanel();
75 }
76 s.EndVerticalLay();
77
78 Layout();
79 Fit();
80 Centre();
81
82 mToken->SetFocus();
83}
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 85 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 90 of file LinkWithTokenDialog.cpp.

91{
92 mContinueButton->Disable();
93
94 wxWeakRef<LinkWithTokenDialog> weakDialog(this);
95
98 [weakDialog, trace = mAudiocomTrace](auto accessToken) {
99 BasicUI::CallAfter(
100 [weakDialog, token = std::string(accessToken), trace]() {
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, trace);
116
117 if (wxID_RETRY != errorDialog.ShowModal())
118 {
119 if (weakDialog)
120 weakDialog->Close();
121 }
122 });
123 });
124}
bool HandleLinkURI(std::string_view uri, AudiocomTrace, 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(), mAudiocomTrace, 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

◆ mAudiocomTrace

const AudiocomTrace audacity::cloud::audiocom::LinkWithTokenDialog::mAudiocomTrace
private

Definition at line 33 of file LinkWithTokenDialog.h.

Referenced by OnContinue().

◆ mContinueButton

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

Definition at line 31 of file LinkWithTokenDialog.h.

Referenced by OnContinue().

◆ mToken

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

Definition at line 32 of file LinkWithTokenDialog.h.

Referenced by OnContinue().


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