| 51 | } // namespace |
| 52 | |
| 53 | UserPanel::UserPanel( |
| 54 | const ServiceConfig& serviceConfig, OAuthService& authService, |
| 55 | UserService& userService, bool linkButtonVisible, AudiocomTrace trace, |
| 56 | wxWindow* parent, const wxPoint& pos, const wxSize& size) |
| 57 | : wxPanelWrapper { parent, wxID_ANY, pos, size } |
| 58 | , mServiceConfig { serviceConfig } |
| 59 | , mAuthService { authService } |
| 60 | , mUserService { userService } |
| 61 | , mAudiocomTrace { trace } |
| 62 | , mUserDataChangedSubscription { userService.Subscribe( |
| 63 | [this](const auto&) { UpdateUserData(); }) } |
| 64 | , mLinkButtonVisible { linkButtonVisible } |
| 65 | { |
| 66 | GetAuthorizationHandler().PushSuppressDialogs(); |
| 67 | mUserImage = safenew UserImage(this, avatarSize); |
| 68 | mUserImage->SetLabel(anonymousText); // for screen readers |
| 69 | mUserName = safenew wxStaticText( |
| 70 | this, |
| 71 | wxID_ANY, |
| 72 | anonymousText.Translation() ); |
| 73 | |
| 74 | mLinkButton = |
| 75 | safenew wxButton(this, wxID_ANY, XXO("Sign in").Translation()); |
| 76 | mLinkButton->Bind(wxEVT_BUTTON, [this](auto) { OnLinkButtonPressed(); }); |
| 77 | |
| 78 | mLinkButton->Show(mLinkButtonVisible); |
| 79 | |
| 80 | auto sizer = safenew wxBoxSizer { wxHORIZONTAL }; |
| 81 | |
| 82 | sizer->Add(mUserImage, 0, wxALIGN_CENTER_VERTICAL); |
| 83 | sizer->AddSpacer(8); |
| 84 | sizer->Add(mUserName, 0, wxALIGN_CENTER_VERTICAL); |
| 85 | sizer->AddStretchSpacer(); |
| 86 | sizer->Add(mLinkButton, 0, wxALIGN_CENTER_VERTICAL); |
| 87 | |
| 88 | SetSizerAndFit(sizer); |
| 89 | UpdateUserData(); |
| 90 | } |
| 91 | |
| 92 | UserPanel::~UserPanel() = default; |
| 93 |
nothing calls this directly
no test coverage detected