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 ()
 
wxString GetTrackTitle () const
 
bool HasValidTitle () const
 

Public Attributes

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

Detailed Description

Definition at line 64 of file ShareAudioDialog.h.

Constructor & Destructor Documentation

◆ InitialStatePanel()

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

Definition at line 590 of file ShareAudioDialog.cpp.

References UpdateUserData().

Here is the call graph for this function:

Member Function Documentation

◆ GetTrackTitle()

wxString cloud::audiocom::ShareAudioDialog::InitialStatePanel::GetTrackTitle ( ) const

Definition at line 782 of file ShareAudioDialog.cpp.

783{
784 wxString ret { trackTitle->GetValue() };
785 ret.Trim(true).Trim(false);
786 return ret;
787}

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

Here is the caller graph for this function:

◆ HasValidTitle()

bool cloud::audiocom::ShareAudioDialog::InitialStatePanel::HasValidTitle ( ) const

Definition at line 789 of file ShareAudioDialog.cpp.

790{
791 return !GetTrackTitle().empty();
792}

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

Here is the caller graph for this function:

◆ OnLinkButtonPressed()

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

Definition at line 746 of file ShareAudioDialog.cpp.

747{
748 auto& oauthService = GetOAuthService();
749
750 if (oauthService.HasAccessToken())
751 oauthService.UnlinkAccount();
752 else
753 {
755 { audacity::ToWXString(GetServiceConfig().GetOAuthLoginPage()) });
756
757#ifdef HAS_CUSTOM_URL_HANDLING
759#endif
760 {
761 LinkAccountDialog dlg(root);
762 dlg.ShowModal();
763 }
764 }
765}
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 597 of file ShareAudioDialog.cpp.

599{
601 s.StartVerticalLay(wxEXPAND, 1);
602 {
603 s.SetBorder(16);
604
605 s.StartHorizontalLay(wxEXPAND, 0);
606 {
607 avatar = safenew UserImage(s.GetParent(), avatarSize);
608
609 s.AddWindow(avatar);
610
611 s.StartVerticalLay(wxEXPAND, 1);
612 {
613 s.SetBorder(0);
614 s.AddSpace(0, 0, 1);
615 name = s.AddVariableText(XO("Anonymous"));
616 s.AddSpace(0, 0, 1);
617 }
618 s.EndVerticalLay();
619
620 s.AddSpace(0, 0, 1);
621
622 s.StartVerticalLay(wxEXPAND, 1);
623 {
624 s.AddSpace(0, 0, 1);
625
626 s.SetBorder(16);
627 oauthButton = s.AddButton(XXO("&Link Account"));
628 oauthButton->Bind(
629 wxEVT_BUTTON, [this](auto) { OnLinkButtonPressed(); });
630 s.AddSpace(0, 0, 1);
631 }
632 s.EndVerticalLay();
633 }
635
636 s.SetBorder(0);
637
638 s.AddWindow(safenew wxStaticLine { s.GetParent() }, wxEXPAND);
639
641 {
643 {
644 s.AddFixedText(XO("Track Title"));
645 s.AddSpace(8);
646 trackTitle = s.AddTextBox({}, {}, 60);
647 trackTitle->SetName(XO("Track Title").Translation());
648 trackTitle->SetFocus();
649 trackTitle->SetMaxLength(100);
650 s.AddSpace(16);
651
653 {
654 AccessibleLinksFormatter privacyPolicy(XO(
655 /*i18n-hint: %s substitutes for audio.com. %% creates a linebreak in this context. */
656 "Sharing audio requires a free %s account linked to Audacity. %%Press \"Link account\" above to proceed."));
657
658 privacyPolicy.FormatLink(
659 L"%s", XO("audio.com"), "https://audio.com");
660
661 privacyPolicy.FormatLink(
662 L"%%", TranslatableString {},
664
665 privacyPolicy.Populate(s);
666 }
668
670 s.StartHorizontalLay(wxEXPAND, 1);
671 {
672 s.AddFixedText(XO("Press \"Continue\" to upload to audio.com"));
673 }
676 }
678 }
680 }
681 s.EndVerticalLay();
683
685}
XO("Cut/Copy/Paste")
XXO("&Cut/Copy/Paste Toolbar")
#define safenew
Definition: MemoryX.h:9
void SetBorder(int Border)
Definition: ShuttleGui.h:495
void EndVerticalLay()
void EndInvisiblePanel()
wxPanel * StartInvisiblePanel(int border=0)
wxWindow * GetParent()
Definition: ShuttleGui.h:502
wxTextCtrl * AddTextBox(const TranslatableString &Caption, const wxString &Value, const int nChars)
Definition: ShuttleGui.cpp:659
void StartVerticalLay(int iProp=1)
wxButton * AddButton(const TranslatableString &Text, int PositionFlags=wxALIGN_CENTRE, bool setDefault=false)
Definition: ShuttleGui.cpp:362
void EndHorizontalLay()
void StartHorizontalLay(int PositionFlags=wxALIGN_CENTRE, int iProp=1)
wxWindow * AddWindow(wxWindow *pWindow, int PositionFlags=wxALIGN_CENTRE)
Definition: ShuttleGui.cpp:301
void AddFixedText(const TranslatableString &Str, bool bCenter=false, int wrapWidth=0)
Definition: ShuttleGui.cpp:442
wxStaticText * AddVariableText(const TranslatableString &Str, bool bCenter=false, int PositionFlags=0, int wrapWidth=0)
Definition: ShuttleGui.cpp:465
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::AddTextBox(), 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 767 of file ShareAudioDialog.cpp.

768{
769 parent.mIsAuthorised = false;
770
771 name->SetLabel(XO("Anonymous").Translation());
772 avatar->SetBitmap(theTheme.Bitmap(bmpAnonymousUser));
773 oauthButton->SetLabel(XXO("&Link Account").Translation());
774
775 anonInfoPanel->Show();
776 authorizedInfoPanel->Hide();
777
778 if (parent.mContinueButton != nullptr)
779 parent.mContinueButton->Enable(false);
780}
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 687 of file ShareAudioDialog.cpp.

688{
689 auto rootParent = root->GetParent();
690 rootParent->Freeze();
691
692 auto layoutUpdater = finally(
693 [rootParent = root->GetParent(), this]()
694 {
695 oauthButton->Fit();
696 rootParent->Fit();
697 rootParent->Layout();
698
699 rootParent->Thaw();
700
701 rootParent->Refresh();
702 });
703
704 auto& oauthService = GetOAuthService();
705
706 if (!oauthService.HasRefreshToken())
707 {
709 return;
710 }
711
712 if (!oauthService.HasAccessToken())
713 oauthService.ValidateAuth({});
714
715 auto& userService = GetUserService();
716
717 if (userService.GetUserSlug().empty())
718 {
720 return;
721 }
722
723 const auto displayName = userService.GetDisplayName();
724
725 if (!displayName.empty())
726 name->SetLabel(displayName);
727
728 const auto avatarPath = userService.GetAvatarPath();
729
730 if (!avatarPath.empty())
731 avatar->SetBitmap(avatarPath);
732 else
733 avatar->SetBitmap(theTheme.Bitmap(bmpAnonymousUser));
734
735 oauthButton->SetLabel(XXO("&Unlink Account").Translation());
736
737 parent.mIsAuthorised = true;
738
739 anonInfoPanel->Hide();
740 authorizedInfoPanel->Show();
741
742 if (parent.mContinueButton != nullptr)
743 parent.mContinueButton->Enable(!trackTitle->GetValue().empty());
744}

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 75 of file ShareAudioDialog.h.

◆ authorizedInfoPanel

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

Definition at line 76 of file ShareAudioDialog.h.

◆ avatar

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

Definition at line 72 of file ShareAudioDialog.h.

◆ mUserDataChangedSubscription

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

Definition at line 79 of file ShareAudioDialog.h.

◆ name

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

Definition at line 73 of file ShareAudioDialog.h.

◆ oauthButton

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

Definition at line 74 of file ShareAudioDialog.h.

◆ parent

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

Definition at line 68 of file ShareAudioDialog.h.

◆ root

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

◆ trackTitle

wxTextCtrl* cloud::audiocom::ShareAudioDialog::InitialStatePanel::trackTitle { nullptr }

Definition at line 77 of file ShareAudioDialog.h.

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


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