From 565d89a2e2898cb76d9fabd052976c442fabdcab Mon Sep 17 00:00:00 2001 From: David Kocik Date: Mon, 5 Feb 2024 14:47:10 +0100 Subject: [PATCH] Simple error page --- resources/web/connection_failed.html | 27 +++++++++++++++++++++++++++ src/slic3r/GUI/WebViewDialog.cpp | 10 +++++++--- src/slic3r/GUI/WebViewDialog.hpp | 7 ++----- 3 files changed, 36 insertions(+), 8 deletions(-) create mode 100644 resources/web/connection_failed.html diff --git a/resources/web/connection_failed.html b/resources/web/connection_failed.html new file mode 100644 index 0000000000..72cb686232 --- /dev/null +++ b/resources/web/connection_failed.html @@ -0,0 +1,27 @@ + + + + + + Connection failed + + + +
+

Connection failed

+

Something went wrong.

+
+ + diff --git a/src/slic3r/GUI/WebViewDialog.cpp b/src/slic3r/GUI/WebViewDialog.cpp index 4f7f18a267..de7ab37ce9 100644 --- a/src/slic3r/GUI/WebViewDialog.cpp +++ b/src/slic3r/GUI/WebViewDialog.cpp @@ -174,6 +174,11 @@ void WebViewPanel::load_default_url_delayed() m_load_default_url = true; } +void WebViewPanel::load_error_page() +{ + load_url(wxString::Format("file://%s/web/connection_failed.html", from_u8(resources_dir()))); +} + void WebViewPanel::on_show(wxShowEvent& evt) { if (evt.IsShown() && m_load_default_url) @@ -409,10 +414,9 @@ case type: \ WX_ERROR_CASE(wxWEBVIEW_NAV_ERR_OTHER); } - BOOST_LOG_TRIVIAL(warning) << "WebView error: " << category; - //Show the info bar with an error + BOOST_LOG_TRIVIAL(error) << "WebView error: " << category; + load_error_page(); #ifdef DEBUG_URL_PANEL - m_info->ShowMessage(_L("An error occurred loading ") + evt.GetURL() + "\n" + "'" + category + "'", wxICON_ERROR); #endif diff --git a/src/slic3r/GUI/WebViewDialog.hpp b/src/slic3r/GUI/WebViewDialog.hpp index 16dce9e6b2..785edbb2d2 100644 --- a/src/slic3r/GUI/WebViewDialog.hpp +++ b/src/slic3r/GUI/WebViewDialog.hpp @@ -39,9 +39,11 @@ public: void load_url(const wxString& url); void load_default_url_delayed(); + void load_error_page(); void on_show(wxShowEvent& evt); virtual void on_script_message(wxWebViewEvent& evt); + void on_loaded(wxWebViewEvent& evt); void on_idle(wxIdleEvent& evt); void on_url(wxCommandEvent& evt); @@ -71,11 +73,6 @@ public: wxString get_default_url() const { return m_default_url; } void set_default_url(const wxString& url) { m_default_url = url; } - - virtual bool Show(bool show = true) override - { - return wxPanel::Show(show); - } protected: wxWebView* m_browser;