Audacity 3.2.0
Public Member Functions | Public Attributes | List of all members
cloud::audiocom::ShareAudioDialog::InitialStatePanel Struct Referencefinal
Collaboration diagram for cloud::audiocom::ShareAudioDialog::InitialStatePanel:
[legend]

Public Member Functions

 InitialStatePanel (ShareAudioDialog &parent)
 
void PopulateInitialStatePanel (ShuttleGui &s)
 
void UpdateUserData ()
 
void OnLinkButtonPressed ()
 
void SetAnonymousState ()
 

Public Attributes

ShareAudioDialogparent
 
wxWindow * root { nullptr }
 
UserImageavatar { nullptr }
 
wxStaticText * name { nullptr }
 
wxButton * oauthButton { nullptr }
 
wxPanel * anonInfoPanel { nullptr }
 
wxPanel * authorizedInfoPanel { nullptr }
 
Observer::Subscription mUserDataChangedSubscription
 

Detailed Description

Definition at line 69 of file ShareAudioDialog.h.

Constructor & Destructor Documentation

◆ InitialStatePanel()

cloud::audiocom::ShareAudioDialog::InitialStatePanel::InitialStatePanel ( ShareAudioDialog parent)
explicit

Definition at line 577 of file ShareAudioDialog.cpp.

References UpdateUserData().

Here is the call graph for this function:

Member Function Documentation

◆ OnLinkButtonPressed()

void cloud::audiocom::ShareAudioDialog::InitialStatePanel::OnLinkButtonPressed ( )

Definition at line 722 of file ShareAudioDialog.cpp.

723{
724 auto& oauthService = GetOAuthService();
725
726 if (oauthService.HasAccessToken())
727 oauthService.UnlinkAccount();
728 else
729 {
731 { audacity::ToWXString(GetServiceConfig().GetOAuthLoginPage()) });
732
733#ifdef HAS_CUSTOM_URL_HANDLING
735#endif
736 {
737 LinkAccountDialog dlg(root);
738 dlg.ShowModal();
739 }
740 }
741}
bool IsURLHandlingSupported() const noexcept
Returns true, if Audacity can handle custom URLs.
static URLSchemesRegistry & Get()
Retrieves the registry instance.
bool OpenInDefaultBrowser(const wxString &url)
Open an URL in default browser.
Definition: BasicUI.cpp:240
wxString ToWXString(const std::string &str)
const ServiceConfig & GetServiceConfig()
Returns the instance of the ServiceConfig.
OAuthService & GetOAuthService()
Returns the instance of the OAuthService.

References URLSchemesRegistry::Get(), cloud::audiocom::GetOAuthService(), cloud::audiocom::GetServiceConfig(), URLSchemesRegistry::IsURLHandlingSupported(), BasicUI::OpenInDefaultBrowser(), and audacity::ToWXString().

Here is the call graph for this function:

◆ PopulateInitialStatePanel()

void cloud::audiocom::ShareAudioDialog::InitialStatePanel::PopulateInitialStatePanel ( ShuttleGui s)

Definition at line 584 of file ShareAudioDialog.cpp.

586{
588 s.StartVerticalLay(wxEXPAND, 1);
589 {
590 s.SetBorder(16);
591
592 s.StartHorizontalLay(wxEXPAND, 0);
593 {
594 avatar = safenew UserImage(s.GetParent(), avatarSize);
595
596 s.AddWindow(avatar);
597
598 s.StartVerticalLay(wxEXPAND, 1);
599 {
600 s.SetBorder(0);
601 s.AddSpace(0, 0, 1);
602 name = s.AddVariableText(XO("Anonymous"));
603 s.AddSpace(0, 0, 1);
604 }
605 s.EndVerticalLay();
606
607 s.AddSpace(0, 0, 1);
608
609 s.StartVerticalLay(wxEXPAND, 1);
610 {
611 s.AddSpace(0, 0, 1);
612
613 s.SetBorder(16);
614 oauthButton = s.AddButton(XXO("&Link Account"));
615 oauthButton->Bind(
616 wxEVT_BUTTON, [this](auto) { OnLinkButtonPressed(); });
617 s.AddSpace(0, 0, 1);
618 }
619 s.EndVerticalLay();
620 }
622
623 s.SetBorder(0);
624
625 s.AddWindow(safenew wxStaticLine { s.GetParent() }, wxEXPAND);
626
627 s.AddSpace(16);
629 {
631 {
632 s.SetBorder(30);
633
634 AccessibleLinksFormatter privacyPolicy(XO(
635 "Your audio will be uploaded to our sharing service: %s,%%which requires a free account to use."));
636
637 privacyPolicy.FormatLink(
638 L"%s", XO("audio.com"), "https://audio.com");
639
640 privacyPolicy.FormatLink(
641 L"%%", TranslatableString {},
643
644 privacyPolicy.Populate(s);
645 }
647
649 s.StartHorizontalLay(wxEXPAND, 1);
650 {
651 s.AddSpace(30);
652 s.AddFixedText(XO("Press \"Continue\" to upload to audio.com"));
653 }
656 }
658 }
659 s.EndVerticalLay();
661
663}
XO("Cut/Copy/Paste")
XXO("&Cut/Copy/Paste Toolbar")
#define safenew
Definition: MemoryX.h:10
void SetBorder(int Border)
Definition: ShuttleGui.h:484
void EndVerticalLay()
void EndInvisiblePanel()
wxPanel * StartInvisiblePanel(int border=0)
wxWindow * GetParent()
Definition: ShuttleGui.h:491
void StartVerticalLay(int iProp=1)
wxButton * AddButton(const TranslatableString &Text, int PositionFlags=wxALIGN_CENTRE, bool setDefault=false)
Definition: ShuttleGui.cpp:359
void EndHorizontalLay()
void StartHorizontalLay(int PositionFlags=wxALIGN_CENTRE, int iProp=1)
wxWindow * AddWindow(wxWindow *pWindow, int PositionFlags=wxALIGN_CENTRE)
Definition: ShuttleGui.cpp:298
void AddFixedText(const TranslatableString &Str, bool bCenter=false, int wrapWidth=0)
Definition: ShuttleGui.cpp:439
wxStaticText * AddVariableText(const TranslatableString &Str, bool bCenter=false, int PositionFlags=0, int wrapWidth=0)
Definition: ShuttleGui.cpp:462
wxSizerItem * AddSpace(int width, int height, int prop=0)
Holds a msgid for the translation catalog; may also bind format arguments.

References ShuttleGuiBase::AddButton(), ShuttleGuiBase::AddFixedText(), ShuttleGui::AddSpace(), ShuttleGuiBase::AddVariableText(), ShuttleGuiBase::AddWindow(), cloud::audiocom::anonymous_namespace{ShareAudioDialog.cpp}::avatarSize, ShuttleGuiBase::EndHorizontalLay(), ShuttleGuiBase::EndInvisiblePanel(), ShuttleGuiBase::EndVerticalLay(), AccessibleLinksFormatter::FormatLink(), ShuttleGuiBase::GetParent(), name, AccessibleLinksFormatter::Populate(), safenew, ShuttleGuiBase::SetBorder(), ShuttleGuiBase::StartHorizontalLay(), ShuttleGuiBase::StartInvisiblePanel(), ShuttleGuiBase::StartVerticalLay(), XO(), and XXO().

Referenced by cloud::audiocom::ShareAudioDialog::Populate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetAnonymousState()

void cloud::audiocom::ShareAudioDialog::InitialStatePanel::SetAnonymousState ( )

Definition at line 743 of file ShareAudioDialog.cpp.

744{
745 parent.mIsAuthorised = false;
746
747 name->SetLabel(XO("Anonymous").Translation());
748 avatar->SetBitmap(theTheme.Bitmap(bmpAnonymousUser));
749 oauthButton->SetLabel(XXO("&Link Account").Translation());
750
751 anonInfoPanel->Show();
752 authorizedInfoPanel->Hide();
753
754 if (parent.mContinueButton != nullptr)
755 parent.mContinueButton->Enable(false);
756}
THEME_API Theme theTheme
Definition: Theme.cpp:82
wxBitmap & Bitmap(int iIndex)
void SetBitmap(const wxBitmap &bitmap)
Definition: UserImage.cpp:32

References ThemeBase::Bitmap(), name, theTheme, XO(), and XXO().

Here is the call graph for this function:

◆ UpdateUserData()

void cloud::audiocom::ShareAudioDialog::InitialStatePanel::UpdateUserData ( )

Definition at line 665 of file ShareAudioDialog.cpp.

666{
667 auto rootParent = root->GetParent();
668 rootParent->Freeze();
669
670 auto layoutUpdater = finally(
671 [rootParent = root->GetParent(), this]()
672 {
673 oauthButton->Fit();
674 rootParent->Fit();
675 rootParent->Layout();
676
677 rootParent->Thaw();
678 });
679
680 auto& oauthService = GetOAuthService();
681
682 if (!oauthService.HasRefreshToken())
683 {
685 return;
686 }
687
688 if (!oauthService.HasAccessToken())
689 oauthService.ValidateAuth({});
690
691 auto& userService = GetUserService();
692
693 if (userService.GetUserSlug().empty())
694 {
696 return;
697 }
698
699 const auto displayName = userService.GetDisplayName();
700
701 if (!displayName.empty())
702 name->SetLabel(displayName);
703
704 const auto avatarPath = userService.GetAvatarPath();
705
706 if (!avatarPath.empty())
707 avatar->SetBitmap(avatarPath);
708 else
709 avatar->SetBitmap(theTheme.Bitmap(bmpAnonymousUser));
710
711 oauthButton->SetLabel(XXO("&Unlink Account").Translation());
712
713 parent.mIsAuthorised = true;
714
715 anonInfoPanel->Hide();
716 authorizedInfoPanel->Show();
717
718 if (parent.mContinueButton != nullptr)
719 parent.mContinueButton->Enable();
720}

References ThemeBase::Bitmap(), cloud::audiocom::anonymous_namespace{UserService.cpp}::displayName, cloud::audiocom::GetOAuthService(), cloud::audiocom::GetUserService(), name, theTheme, and XXO().

Referenced by InitialStatePanel().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ anonInfoPanel

wxPanel* cloud::audiocom::ShareAudioDialog::InitialStatePanel::anonInfoPanel { nullptr }

Definition at line 80 of file ShareAudioDialog.h.

◆ authorizedInfoPanel

wxPanel* cloud::audiocom::ShareAudioDialog::InitialStatePanel::authorizedInfoPanel { nullptr }

Definition at line 81 of file ShareAudioDialog.h.

◆ avatar

UserImage* cloud::audiocom::ShareAudioDialog::InitialStatePanel::avatar { nullptr }

Definition at line 77 of file ShareAudioDialog.h.

◆ mUserDataChangedSubscription

Observer::Subscription cloud::audiocom::ShareAudioDialog::InitialStatePanel::mUserDataChangedSubscription

Definition at line 83 of file ShareAudioDialog.h.

◆ name

wxStaticText* cloud::audiocom::ShareAudioDialog::InitialStatePanel::name { nullptr }

Definition at line 78 of file ShareAudioDialog.h.

◆ oauthButton

wxButton* cloud::audiocom::ShareAudioDialog::InitialStatePanel::oauthButton { nullptr }

Definition at line 79 of file ShareAudioDialog.h.

◆ parent

ShareAudioDialog& cloud::audiocom::ShareAudioDialog::InitialStatePanel::parent

Definition at line 73 of file ShareAudioDialog.h.

◆ root

wxWindow* cloud::audiocom::ShareAudioDialog::InitialStatePanel::root { nullptr }

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