Skip to content

Commit

Permalink
Enable WebView devtools if developer mode is enabled (#6298)
Browse files Browse the repository at this point in the history
* Enable WebView devtools if developer mode is enabled
  • Loading branch information
Ocraftyone authored Aug 2, 2024
1 parent ade2022 commit e96527b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/slic3r/GUI/GUI_App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5255,6 +5255,8 @@ void GUI_App::update_mode()
mainframe->m_param_panel->update_mode();
if (mainframe->m_param_dialog)
mainframe->m_param_dialog->panel()->update_mode();
if (mainframe->m_printer_view)
mainframe->m_printer_view->update_mode();
mainframe->m_webview->update_mode();

#ifdef _MSW_DARK_MODE
Expand All @@ -5274,6 +5276,8 @@ void GUI_App::update_mode()

void GUI_App::update_internal_development() {
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)
Expand Down
8 changes: 8 additions & 0 deletions src/slic3r/GUI/PrinterWebView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ PrinterWebView::PrinterWebView(wxWindow *parent)

topsizer->Add(m_browser, wxSizerFlags().Expand().Proportion(1));

update_mode();

// Log backend information
/* m_browser->GetUserAgent() may lead crash
if (wxGetApp().get_mode() == comDevelop) {
Expand Down Expand Up @@ -83,6 +85,12 @@ void PrinterWebView::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
* GUI the reflect this current state.
Expand Down
1 change: 1 addition & 0 deletions src/slic3r/GUI/PrinterWebView.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class PrinterWebView : public wxPanel {
void OnError(wxWebViewEvent& evt);
void OnLoaded(wxWebViewEvent& evt);
void reload();
void update_mode();
private:
void SendAPIKey();

Expand Down

0 comments on commit e96527b

Please sign in to comment.