diff --git a/src/slic3r/GUI/WebView.cpp b/src/slic3r/GUI/WebView.cpp index 5a97802506..d9b5c55e85 100644 --- a/src/slic3r/GUI/WebView.cpp +++ b/src/slic3r/GUI/WebView.cpp @@ -22,7 +22,7 @@ wxWebView* WebView::CreateWebView(wxWindow * parent, const wxString& url, std::v if (webView) { wxString correct_url = url.empty() ? wxString("") : wxURI(url).BuildURI(); -#ifdef __WIN32_ +#ifdef __WIN32__ webView->SetUserAgent(SLIC3R_APP_FULL_NAME); webView->Create(parent, wxID_ANY, correct_url, wxDefaultPosition, wxDefaultSize); //We register the wxfs:// protocol for testing purposes diff --git a/src/slic3r/GUI/WebViewDialog.cpp b/src/slic3r/GUI/WebViewDialog.cpp index bac2bcdf7e..33325671ad 100644 --- a/src/slic3r/GUI/WebViewDialog.cpp +++ b/src/slic3r/GUI/WebViewDialog.cpp @@ -107,6 +107,7 @@ WebViewPanel::WebViewPanel(wxWindow *parent, const wxString& default_url, const // Connect the webview events Bind(wxEVT_WEBVIEW_ERROR, &WebViewPanel::on_error, this, m_browser->GetId()); Bind(wxEVT_WEBVIEW_SCRIPT_MESSAGE_RECEIVED, &WebViewPanel::on_script_message, this, m_browser->GetId()); + Bind(wxEVT_WEBVIEW_NAVIGATING, &WebViewPanel::on_navigation_request, this, m_browser->GetId()); #ifdef DEBUG_URL_PANEL // Connect the button events @@ -253,6 +254,10 @@ void WebViewPanel::on_script_message(wxWebViewEvent& evt) { } +void WebViewPanel::on_navigation_request(wxWebViewEvent &evt) +{ +} + /** * Invoked when user selects the "View Source" menu item */ @@ -468,13 +473,10 @@ SourceViewDialog::SourceViewDialog(wxWindow* parent, wxString source) : ConnectRequestHandler::ConnectRequestHandler() { - m_actions["REQUEST_ACCESS_TOKEN"] = std::bind(&ConnectRequestHandler::on_connect_action_request_access_token, this); m_actions["REQUEST_CONFIG"] = std::bind(&ConnectRequestHandler::on_connect_action_request_config, this); m_actions["WEBAPP_READY"] = std::bind(&ConnectRequestHandler::on_connect_action_webapp_ready, this); m_actions["SELECT_PRINTER"] = std::bind(&ConnectRequestHandler::on_connect_action_select_printer, this); m_actions["PRINT"] = std::bind(&ConnectRequestHandler::on_connect_action_print, this); - // obsolete - //m_actions["REQUEST_SELECTED_PRINTER"] = std::bind(&ConnectRequestHandler::on_connect_action_print, this); } ConnectRequestHandler::~ConnectRequestHandler() { @@ -519,13 +521,6 @@ void ConnectRequestHandler::resend_config() on_connect_action_request_config(); } -void ConnectRequestHandler::on_connect_action_request_access_token() -{ - std::string token = wxGetApp().plater()->get_user_account()->get_access_token(); - wxString script = GUI::format_wxstr("window._prusaConnect_v1.setAccessToken(\'%1%\')", token); - run_script_bridge(script); -} - void ConnectRequestHandler::on_connect_action_request_config() { /* @@ -540,7 +535,7 @@ void ConnectRequestHandler::on_connect_action_request_config() const std::string dark_mode = wxGetApp().dark_mode() ? "DARK" : "LIGHT"; wxString language = GUI::wxGetApp().current_language_code(); language = language.SubString(0, 1); - const std::string init_options = GUI::format("{\"accessToken\": \"%1%\" , \"clientVersion\": \"%2%\", \"colorMode\": \"%3%\", \"language\": \"%4%\"}", token, SLIC3R_VERSION, dark_mode, language); + const std::string init_options = GUI::format("{\"clientVersion\": \"%1%\", \"colorMode\": \"%2%\", \"language\": \"%3%\"}", SLIC3R_VERSION, dark_mode, language); // \"accessToken\": \"%1%\" , wxString script = GUI::format_wxstr("window._prusaConnect_v1.init(%1%)", init_options); run_script_bridge(script); @@ -631,7 +626,10 @@ void ConnectWebViewPanel::on_script_message(wxWebViewEvent& evt) BOOST_LOG_TRIVIAL(debug) << "recieved message from PrusaConnect FE: " << evt.GetString(); handle_message(into_u8(evt.GetString())); } - +void ConnectWebViewPanel::on_navigation_request(wxWebViewEvent &evt) +{ + //TODO Stop request out of connect +} void ConnectWebViewPanel::logout() { wxString script = L"window._prusaConnect_v1.logout()"; diff --git a/src/slic3r/GUI/WebViewDialog.hpp b/src/slic3r/GUI/WebViewDialog.hpp index a40e634369..76138d8c45 100644 --- a/src/slic3r/GUI/WebViewDialog.hpp +++ b/src/slic3r/GUI/WebViewDialog.hpp @@ -1,7 +1,7 @@ #ifndef slic3r_WebViewDialog_hpp_ #define slic3r_WebViewDialog_hpp_ -#define DEBUG_URL_PANEL +//#define DEBUG_URL_PANEL #include #include @@ -53,6 +53,7 @@ public: void on_select_all(wxCommandEvent& evt); void On_enable_context_menu(wxCommandEvent& evt); void On_enable_dev_tools(wxCommandEvent& evt); + virtual void on_navigation_request(wxWebViewEvent &evt); wxString get_default_url() const { return m_default_url; } void set_default_url(const wxString& url) { m_default_url = url; } @@ -173,7 +174,6 @@ public: void resend_config(); protected: // action callbacs stored in m_actions - virtual void on_connect_action_request_access_token(); virtual void on_connect_action_request_config(); virtual void on_connect_action_select_printer() = 0; virtual void on_connect_action_print() = 0; @@ -193,6 +193,7 @@ public: void on_script_message(wxWebViewEvent& evt) override; void logout(); void sys_color_changed() override; + void on_navigation_request(wxWebViewEvent &evt) override; protected: void on_connect_action_select_printer() override; void on_connect_action_print() override;