Enable WebView devtools if developer mode is enabled (#6298)

* Enable WebView devtools if developer mode is enabled
This commit is contained in:
Ocraftyone 2024-08-02 12:23:07 -04:00 committed by GitHub
parent ade20222a5
commit e96527b2fe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 13 additions and 0 deletions

View file

@ -5255,6 +5255,8 @@ void GUI_App::update_mode()
mainframe->m_param_panel->update_mode(); mainframe->m_param_panel->update_mode();
if (mainframe->m_param_dialog) if (mainframe->m_param_dialog)
mainframe->m_param_dialog->panel()->update_mode(); mainframe->m_param_dialog->panel()->update_mode();
if (mainframe->m_printer_view)
mainframe->m_printer_view->update_mode();
mainframe->m_webview->update_mode(); mainframe->m_webview->update_mode();
#ifdef _MSW_DARK_MODE #ifdef _MSW_DARK_MODE
@ -5274,6 +5276,8 @@ void GUI_App::update_mode()
void GUI_App::update_internal_development() { void GUI_App::update_internal_development() {
mainframe->m_webview->update_mode(); mainframe->m_webview->update_mode();
if (mainframe->m_printer_view)
mainframe->m_printer_view->update_mode();
} }
void GUI_App::show_ip_address_enter_dialog(wxString title) void GUI_App::show_ip_address_enter_dialog(wxString title)

View file

@ -38,6 +38,8 @@ PrinterWebView::PrinterWebView(wxWindow *parent)
topsizer->Add(m_browser, wxSizerFlags().Expand().Proportion(1)); topsizer->Add(m_browser, wxSizerFlags().Expand().Proportion(1));
update_mode();
// Log backend information // Log backend information
/* m_browser->GetUserAgent() may lead crash /* m_browser->GetUserAgent() may lead crash
if (wxGetApp().get_mode() == comDevelop) { if (wxGetApp().get_mode() == comDevelop) {
@ -83,6 +85,12 @@ void PrinterWebView::reload()
{ {
m_browser->Reload(); m_browser->Reload();
} }
void PrinterWebView::update_mode()
{
m_browser->EnableAccessToDevTools(wxGetApp().app_config->get_bool("developer_mode"));
}
/** /**
* Method that retrieves the current state from the web control and updates the * Method that retrieves the current state from the web control and updates the
* GUI the reflect this current state. * GUI the reflect this current state.

View file

@ -42,6 +42,7 @@ public:
void OnError(wxWebViewEvent& evt); void OnError(wxWebViewEvent& evt);
void OnLoaded(wxWebViewEvent& evt); void OnLoaded(wxWebViewEvent& evt);
void reload(); void reload();
void update_mode();
private: private:
void SendAPIKey(); void SendAPIKey();