Do not loade web page until switching to device page (#9031)

* Do not loade web page until switching to device page
This commit is contained in:
Noisyfox 2025-04-01 22:38:38 +08:00 committed by GitHub
parent 67681c971f
commit 075565f4f4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 2 deletions

View File

@ -77,12 +77,26 @@ void PrinterWebView::load_url(wxString& url, wxString apikey)
return; return;
m_apikey = apikey; m_apikey = apikey;
m_apikey_sent = false; m_apikey_sent = false;
m_browser->LoadURL(url); if (this->IsShown()) {
m_url_deferred = *wxEmptyString;
m_browser->LoadURL(url);
} else {
m_url_deferred = url;
}
//m_browser->SetFocus(); //m_browser->SetFocus();
UpdateState(); UpdateState();
} }
bool PrinterWebView::Show(bool show)
{
if (show && !m_url_deferred.empty()) {
m_browser->LoadURL(m_url_deferred);
m_url_deferred = *wxEmptyString;
}
return wxPanel::Show(show);
}
void PrinterWebView::reload() void PrinterWebView::reload()
{ {
m_browser->Reload(); m_browser->Reload();

View File

@ -43,6 +43,9 @@ public:
void OnLoaded(wxWebViewEvent& evt); void OnLoaded(wxWebViewEvent& evt);
void reload(); void reload();
void update_mode(); void update_mode();
bool Show(bool show = true) override;
private: private:
void SendAPIKey(); void SendAPIKey();
@ -51,6 +54,8 @@ private:
wxString m_apikey; wxString m_apikey;
bool m_apikey_sent; bool m_apikey_sent;
wxString m_url_deferred;
// DECLARE_EVENT_TABLE() // DECLARE_EVENT_TABLE()
}; };