17#include <wx/stattext.h>
35 wxStaticText* mText{
nullptr};
36 wxStaticText* mElapsed{
nullptr};
37 wxGauge* mProgress{
nullptr};
47 auto rootSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
48 auto topSizer = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
56 wxST_ELLIPSIZE_START | wxST_NO_AUTORESIZE),
58 topSizer->AddSpacer(5);
59 topSizer->Add(
safenew wxButton(
this, wxID_IGNORE,
_(
"&Skip")), 0);
61 auto timerSizer = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
69 wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL), 1, wxEXPAND);
70 timerSizer->AddSpacer(5);
71 timerSizer->Add(mElapsed =
78 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL), 1, wxEXPAND);
80 rootSizer->Add(topSizer.release(), 0, wxEXPAND | wxALL, 10);
81 rootSizer->Add(mProgress =
82 safenew wxGauge(
this, wxID_ANY, 1000),
83 0, wxEXPAND | wxLEFT | wxRIGHT, 10);
84 rootSizer->AddSpacer(10);
85 rootSizer->Add(timerSizer.release(), 0, wxEXPAND);
87 rootSizer->Add(CreateButtonSizer(wxCANCEL), 0, wxEXPAND);
89 rootSizer->Add(CreateButtonSizer(wxCANCEL), 0, wxEXPAND | wxALL, 10);
91 SetSizer(rootSizer.release());
93 Bind(wxEVT_SHOW, &PluginScanDialog::OnShow,
this);
94 Bind(wxEVT_IDLE, &PluginScanDialog::OnIdle,
this);
96 SetInitialSize({500, -1});
101 mText->SetLabel(text);
102 mText->SetToolTip(text);
103 mProgress->SetValue(mProgress->GetRange() * progress);
111 mStartTime = std::chrono::system_clock::now();
124 auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - mStartTime).count();
125 mElapsed->SetLabel(wxTimeSpan(0, 0, 0, elapsed).
Format(
"%H:%M:%S"));
132 for(
auto& p : pluginsToProcess)
157 pluginDescriptor.
SetID(ID);
159 pluginDescriptor.
SetPath(path);
212 PluginScanDialog dialog(
nullptr, wxID_ANY,
XO(
"Searching for plugins"));
218 dialog.Bind(wxEVT_BUTTON, [
this](wxCommandEvent& evt) {
220 if(evt.GetId() == wxID_IGNORE)
223 dialog.Bind(wxEVT_TIMER, [
this](wxTimerEvent& evt) {
226 if(mValidator && mValidator->InactiveSince() < mRequestStartTime)
234 dialog.Bind(wxEVT_CLOSE_WINDOW, [
this](wxCloseEvent& evt) {
241 dialog.CenterOnScreen();
260 std::thread([validator = std::shared_ptr<AsyncPluginValidator>(std::move(
mValidator))]{ }).detach();
285 wxLogError(
"Plugin registration error: %s", msg);
299 if(
auto dialog =
static_cast<PluginScanDialog*
>(
mScanDialog.get()))
302 dialog->UpdateProgress(
307 mValidator = std::make_unique<AsyncPluginValidator>(*
this);
315 timer->StartOnce(std::chrono::duration_cast<std::chrono::milliseconds>(
mTimeout).count());
317 catch(std::exception& e)
void SetEnabled(bool enable)
void SetPath(const PluginPath &path)
void SetValid(bool valid)
void SetProviderID(const PluginID &providerID)
void SetID(const PluginID &ID)
void SetPluginType(PluginType type)
void Save()
Save to preferences.
void RegisterPlugin(PluginDescriptor &&desc)
void NotifyPluginsChanged()
static PluginManager & Get()
size_t mCurrentPluginProviderIndex
void OnInternalError(const wxString &error) override
Called on error, further processing is not possible.
void Run(std::chrono::seconds timeout=std::chrono::seconds(30))
size_t mCurrentPluginIndex
std::unique_ptr< AsyncPluginValidator > mValidator
void OnValidationFinished() override
Called when module processing finished.
std::vector< PluginDescriptor > mFailedPluginsCache
wxWeakRef< wxDialogWrapper > mScanDialog
void OnPluginFound(const PluginDescriptor &desc) override
Called for each plugin instance found inside module.
wxWeakRef< wxTimer > mTimeoutTimer
std::chrono::system_clock::time_point mRequestStartTime
void StopWithError(const wxString &msg)
std::vector< wxString > mFailedPluginsPaths
void OnPluginValidationFailed(const wxString &providerId, const wxString &path) override
const std::vector< wxString > & GetFailedPluginsPaths() const noexcept
Returns list of paths of plugins that didn't pass validation for some reason.
std::vector< std::pair< wxString, std::vector< wxString > > > mPluginsToProcess
PluginStartupRegistration(const std::map< wxString, std::vector< wxString > > &pluginsToProcess)
std::chrono::system_clock::duration mTimeout
Holds a msgid for the translation catalog; may also bind format arguments.
void OnIdle(wxIdleEvent &evt)
PluginScanDialog(wxWindow *parent, wxWindowID winid, const TranslatableString &title)
void OnShow(wxShowEvent &evt)
void UpdateProgress(const wxString &text, float progress)
std::chrono::system_clock::time_point mStartTime
const TranslatableString desc