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 ()
 
void PopulateInitialStatePanel (ShuttleGui &s)
 
void PopulateFirstTimeNotice (ShuttleGui &s)
 
void UpdateUserData ()
 
void OnLinkButtonPressed ()
 

Public Attributes

wxWindow * root { nullptr }
 
UserImageavatar { nullptr }
 
wxStaticText * name { nullptr }
 
wxButton * oauthButton { nullptr }
 
wxRadioButton * isPublic { nullptr }
 
Observer::Subscription mUserDataChangedSubscription
 

Detailed Description

Definition at line 66 of file ShareAudioDialog.h.

Constructor & Destructor Documentation

◆ InitialStatePanel()

cloud::audiocom::ShareAudioDialog::InitialStatePanel::InitialStatePanel ( )

Definition at line 563 of file ShareAudioDialog.cpp.

565 GetUserService().Subscribe([this](const auto&) { UpdateUserData(); }))
566{
567}
UserService & GetUserService()

References UpdateUserData().

Here is the call graph for this function:

Member Function Documentation

◆ OnLinkButtonPressed()

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

Definition at line 771 of file ShareAudioDialog.cpp.

772{
773 auto& oauthService = GetOAuthService();
774
775 if (oauthService.HasAccessToken())
776 oauthService.UnlinkAccount();
777 else
778 {
780 { audacity::ToWXString(GetServiceConfig().GetOAuthLoginPage()) });
781
782#ifdef HAS_CUSTOM_URL_HANDLING
784#endif
785 {
786 LinkAccountDialog dlg(root);
787 dlg.ShowModal();
788 }
789 }
790}
void OpenInDefaultBrowser(const URLString &link)
Definition: HelpSystem.cpp:527
bool IsURLHandlingSupported() const noexcept
Returns true, if Audacity can handle custom URLs.
static URLSchemesRegistry & Get()
Retrieves the registry instance.
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(), OpenInDefaultBrowser(), and audacity::ToWXString().

Here is the call graph for this function:

◆ PopulateFirstTimeNotice()

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

Definition at line 701 of file ShareAudioDialog.cpp.

702{
703 s.AddSpace(16);
705 s.SetBorder(30);
706 {
707 AccessibleLinksFormatter privacyPolicy(XO(
708 "Your audio will be uploaded to our sharing service: %s,%%which requires a free account to use.\n\nIf you have problems uploading, try the Link Account button."));
709
710 privacyPolicy.FormatLink(
711 L"%s", XO("audio.com"),
712 "https://audio.com");
713
714 privacyPolicy.FormatLink(
715 L"%%", TranslatableString {},
717
718 privacyPolicy.Populate(s);
719 }
721
722 wasOpened.Write(true);
723 gPrefs->Flush();
724}
XO("Cut/Copy/Paste")
FileConfig * gPrefs
Definition: Prefs.cpp:70
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
Definition: FileConfig.cpp:143
bool Write(const T &value)
Write value to config and return true if successful.
Definition: Prefs.h:252
void SetBorder(int Border)
Definition: ShuttleGui.h:486
void EndInvisiblePanel()
wxPanel * StartInvisiblePanel(int border=0)
wxSizerItem * AddSpace(int width, int height, int prop=0)
Holds a msgid for the translation catalog; may also bind format arguments.

References ShuttleGui::AddSpace(), ShuttleGuiBase::EndInvisiblePanel(), FileConfig::Flush(), AccessibleLinksFormatter::FormatLink(), gPrefs, AccessibleLinksFormatter::Populate(), ShuttleGuiBase::SetBorder(), ShuttleGuiBase::StartInvisiblePanel(), cloud::audiocom::anonymous_namespace{ShareAudioDialog.cpp}::wasOpened, Setting< T >::Write(), and XO().

Here is the call graph for this function:

◆ PopulateInitialStatePanel()

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

Definition at line 569 of file ShareAudioDialog.cpp.

571{
573 s.StartVerticalLay(wxEXPAND, 1);
574 {
575 s.SetBorder(16);
576
577 s.StartHorizontalLay(wxEXPAND, 0);
578 {
579 avatar = safenew UserImage(s.GetParent(), avatarSize);
580
581 s.AddWindow(avatar);
582
583 s.StartVerticalLay(wxEXPAND, 1);
584 {
585 s.SetBorder(0);
586 s.AddSpace(0, 0, 1);
587 name = s.AddVariableText(XO("Anonymous"));
588 s.AddSpace(0, 0, 1);
589 }
590 s.EndVerticalLay();
591
592 s.AddSpace(0, 0, 1);
593
594 s.StartVerticalLay(wxEXPAND, 1);
595 {
596 s.AddSpace(0, 0, 1);
597
598 s.SetBorder(16);
599 oauthButton = s.AddButton(XXO("&Link Account"));
600 oauthButton->Bind(
601 wxEVT_BUTTON, [this](auto) { OnLinkButtonPressed(); });
602 s.AddSpace(0, 0, 1);
603 }
604 s.EndVerticalLay();
605 }
607
608 s.SetBorder(0);
609
610 s.AddWindow(safenew wxStaticLine { s.GetParent() }, wxEXPAND);
611
612 s.AddSpace(16);
613
614 s.StartHorizontalLay(wxEXPAND, 0);
615 {
616 constexpr auto maxWidth = 380;
617 s.AddSpace(30, 0, 0);
618 s.StartMultiColumn(2, wxEXPAND);
619 {
620 s.SetBorder(2);
621 s.SetStretchyCol(1);
622
623 const auto selectedIndex = SharePublicly.Read() ? 0 : 1;
624
626 publicLabelText.Translation() + ". " +
627 publicDescriptionText.Translation()))
628 .AddRadioButton({}, 0, selectedIndex);
629#if wxUSE_ACCESSIBILITY
630 // so that name can be set on a standard control
631 isPublic->SetAccessible(safenew WindowAccessible(isPublic));
632#endif
633 isPublic->Bind(
634 wxEVT_RADIOBUTTON, [this](auto) { UpdatePublicity(true); });
635
637 ->Bind(
638 wxEVT_LEFT_UP,
639 [this](auto)
640 {
641 isPublic->SetValue(true);
642 UpdatePublicity(true);
643 });
644
645 s.AddFixedText({});
646 s.AddVariableText(publicDescriptionText, false, 0, maxWidth);
647
648 // Margin between options
649 s.AddFixedText({});
650 s.AddFixedText({});
651
652 auto rbUnlisted = s.Name(Verbatim(
653 unlistedLabelText.Translation() + ". " +
654 unlistedDescriptionText.Translation()))
655 .AddRadioButtonToGroup({}, 1, selectedIndex);
656
657#if wxUSE_ACCESSIBILITY
658 // so that name can be set on a standard control
659 rbUnlisted->SetAccessible(safenew WindowAccessible(rbUnlisted));
660#endif
661
662 rbUnlisted->Bind(
663 wxEVT_RADIOBUTTON, [this](auto) { UpdatePublicity(false); });
664
666 ->Bind(
667 wxEVT_LEFT_UP,
668 [this, rbUnlisted](auto)
669 {
670 rbUnlisted->SetValue(true);
671 UpdatePublicity(false);
672 });
673
674 s.AddFixedText({});
675 s.AddVariableText(unlistedDescriptionText, false, 0, maxWidth);
676 }
677 s.EndMultiColumn();
678 }
680
681 if (!wasOpened.Read())
683 else
684 {
685 s.AddSpace(16);
686 s.StartHorizontalLay(wxEXPAND, 0);
687 {
688 s.AddSpace(30, 0, 0);
689 s.AddFixedText(XO("Press \"Continue\" to upload to audio.com"));
690 }
692 }
693
694 }
695 s.EndVerticalLay();
697
699}
XXO("&Cut/Copy/Paste Toolbar")
#define safenew
Definition: MemoryX.h:10
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
bool Read(T *pVar) const
overload of Read returning a boolean that is true if the value was previously defined *‍/
Definition: Prefs.h:200
void EndVerticalLay()
void EndMultiColumn()
wxWindow * GetParent()
Definition: ShuttleGui.h:493
void StartVerticalLay(int iProp=1)
wxButton * AddButton(const TranslatableString &Text, int PositionFlags=wxALIGN_CENTRE, bool setDefault=false)
Definition: ShuttleGui.cpp:361
void EndHorizontalLay()
void StartHorizontalLay(int PositionFlags=wxALIGN_CENTRE, int iProp=1)
wxWindow * AddWindow(wxWindow *pWindow, int PositionFlags=wxALIGN_CENTRE)
Definition: ShuttleGui.cpp:300
void SetStretchyCol(int i)
Used to modify an already placed FlexGridSizer to make a column stretchy.
Definition: ShuttleGui.cpp:203
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
void AddFixedText(const TranslatableString &Str, bool bCenter=false, int wrapWidth=0)
Definition: ShuttleGui.cpp:441
wxStaticText * AddVariableText(const TranslatableString &Str, bool bCenter=false, int PositionFlags=0, int wrapWidth=0)
Definition: ShuttleGui.cpp:464
ShuttleGui & Name(const TranslatableString &name)
Definition: ShuttleGui.h:660
An alternative to using wxWindowAccessible, which in wxWidgets 3.1.1 contained GetParent() which was ...

References ShuttleGuiBase::AddButton(), ShuttleGuiBase::AddFixedText(), ShuttleGui::AddSpace(), ShuttleGuiBase::AddVariableText(), ShuttleGuiBase::AddWindow(), cloud::audiocom::anonymous_namespace{ShareAudioDialog.cpp}::avatarSize, ShuttleGuiBase::EndHorizontalLay(), ShuttleGuiBase::EndInvisiblePanel(), ShuttleGuiBase::EndMultiColumn(), ShuttleGuiBase::EndVerticalLay(), ShuttleGuiBase::GetParent(), name, ShuttleGui::Name(), cloud::audiocom::anonymous_namespace{ShareAudioDialog.cpp}::publicDescriptionText, cloud::audiocom::anonymous_namespace{ShareAudioDialog.cpp}::publicLabelText, Setting< T >::Read(), safenew, ShuttleGuiBase::SetBorder(), ShuttleGuiBase::SetStretchyCol(), cloud::audiocom::anonymous_namespace{ShareAudioDialog.cpp}::SharePublicly, ShuttleGuiBase::StartHorizontalLay(), ShuttleGuiBase::StartInvisiblePanel(), ShuttleGuiBase::StartMultiColumn(), ShuttleGuiBase::StartVerticalLay(), cloud::audiocom::anonymous_namespace{ShareAudioDialog.cpp}::unlistedDescriptionText, cloud::audiocom::anonymous_namespace{ShareAudioDialog.cpp}::unlistedLabelText, cloud::audiocom::anonymous_namespace{ShareAudioDialog.cpp}::UpdatePublicity(), Verbatim(), cloud::audiocom::anonymous_namespace{ShareAudioDialog.cpp}::wasOpened, 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:

◆ UpdateUserData()

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

Definition at line 726 of file ShareAudioDialog.cpp.

727{
728 auto parent = root->GetParent();
729 parent->Freeze();
730
731 auto layoutUpdater = finally(
732 [parent = root->GetParent(), this]()
733 {
734 oauthButton->Fit();
735 parent->Layout();
736
737 parent->Thaw();
738 });
739
740 auto& oauthService = GetOAuthService();
741
742 if (!oauthService.HasRefreshToken())
743 {
744 name->SetLabel(XO("Anonymous").Translation());
745 avatar->SetBitmap(theTheme.Bitmap(bmpAnonymousUser));
746 oauthButton->SetLabel(XXO("&Link Account").Translation());
747
748 return;
749 }
750
751 if (!oauthService.HasAccessToken())
752 oauthService.ValidateAuth({});
753
754 oauthButton->SetLabel(XXO("&Unlink Account").Translation());
755
756 auto& userService = GetUserService();
757
758 const auto displayName = userService.GetDisplayName();
759
760 if (!displayName.empty())
761 name->SetLabel(displayName);
762
763 const auto avatarPath = userService.GetAvatarPath();
764
765 if (!avatarPath.empty())
766 avatar->SetBitmap(avatarPath);
767 else
768 avatar->SetBitmap(theTheme.Bitmap(bmpAnonymousUser));
769}
THEME_API Theme theTheme
Definition: Theme.cpp:82
wxBitmap & Bitmap(int iIndex)
void SetBitmap(const wxBitmap &bitmap)
Definition: UserImage.cpp:32

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

Referenced by InitialStatePanel().

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

Member Data Documentation

◆ avatar

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

Definition at line 72 of file ShareAudioDialog.h.

◆ isPublic

wxRadioButton* cloud::audiocom::ShareAudioDialog::InitialStatePanel::isPublic { nullptr }

◆ mUserDataChangedSubscription

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

Definition at line 78 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.

◆ root

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

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