OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::WebViewPanel Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/WebViewDialog.hpp>

Inheritance diagram for Slic3r::GUI::WebViewPanel:
Collaboration diagram for Slic3r::GUI::WebViewPanel:

Public Member Functions

 WebViewPanel (wxWindow *parent)
virtual ~WebViewPanel ()
void load_url (wxString &url)
void UpdateState ()
void OnIdle (wxIdleEvent &evt)
void OnUrl (wxCommandEvent &evt)
void OnBack (wxCommandEvent &evt)
void OnForward (wxCommandEvent &evt)
void OnStop (wxCommandEvent &evt)
void OnReload (wxCommandEvent &evt)
void OnNavigationRequest (wxWebViewEvent &evt)
void OnNavigationComplete (wxWebViewEvent &evt)
void OnDocumentLoaded (wxWebViewEvent &evt)
void OnTitleChanged (wxWebViewEvent &evt)
void OnNewWindow (wxWebViewEvent &evt)
void OnScriptMessage (wxWebViewEvent &evt)
void OnScriptResponseMessage (wxCommandEvent &evt)
void OnViewSourceRequest (wxCommandEvent &evt)
void OnViewTextRequest (wxCommandEvent &evt)
void OnToolsClicked (wxCommandEvent &evt)
void OnError (wxWebViewEvent &evt)
void OnCut (wxCommandEvent &evt)
void OnCopy (wxCommandEvent &evt)
void OnPaste (wxCommandEvent &evt)
void OnUndo (wxCommandEvent &evt)
void OnRedo (wxCommandEvent &evt)
void OnMode (wxCommandEvent &evt)
void RunScript (const wxString &javascript)
void OnRunScriptString (wxCommandEvent &evt)
void OnRunScriptInteger (wxCommandEvent &evt)
void OnRunScriptDouble (wxCommandEvent &evt)
void OnRunScriptBool (wxCommandEvent &evt)
void OnRunScriptObject (wxCommandEvent &evt)
void OnRunScriptArray (wxCommandEvent &evt)
void OnRunScriptDOM (wxCommandEvent &evt)
void OnRunScriptUndefined (wxCommandEvent &evt)
void OnRunScriptNull (wxCommandEvent &evt)
void OnRunScriptDate (wxCommandEvent &evt)
void OnRunScriptMessage (wxCommandEvent &evt)
void OnRunScriptCustom (wxCommandEvent &evt)
void OnAddUserScript (wxCommandEvent &evt)
void OnSetCustomUserAgent (wxCommandEvent &evt)
void OnClearSelection (wxCommandEvent &evt)
void OnDeleteSelection (wxCommandEvent &evt)
void OnSelectAll (wxCommandEvent &evt)
void OnLoadScheme (wxCommandEvent &evt)
void OnUseMemoryFS (wxCommandEvent &evt)
void OnEnableContextMenu (wxCommandEvent &evt)
void OnEnableDevTools (wxCommandEvent &evt)
void OnClose (wxCloseEvent &evt)
void OnFreshLoginStatus (wxTimerEvent &event)
void SendRecentList (int images)
void SetLoginPanelVisibility (bool bshow)
void SendDesignStaffpick (bool on)
void OpenModelDetail (std::string id, NetworkAgent *agent)
void SendLoginInfo ()
void ShowNetpluginTip ()
void SendCloudProvidersInfo ()
void get_design_staffpick (int offset, int limit, std::function< void(std::string)> callback)
int get_model_mall_detail_url (std::string *url, std::string id)
void update_mode ()
void set_cloud_mode (bool on, const wxString &url=wxString(), const wxString &page_url=wxString())
bool cloud_mode_active () const
void load_cloud_url (const wxString &url)
void cloud_signed_out (const wxString &signout_url)
bool Show (bool show=true) override

Static Public Member Functions

static WebViewPanel * if_built ()
static WebViewPanel * ensure ()
static void when_built (std::function< void(WebViewPanel &)> fn)

Public Attributes

wxTimer * m_LoginUpdateTimer {nullptr}

Private Member Functions

void create_browser ()
void create_cloud_browser ()
void reset_browser ()
void OnCloudWebViewEvent (wxWebViewEvent &evt)
bool is_cloud_origin (const wxString &url) const
bool should_divert_cloud_url (const wxString &url) const
void on_cloud_script_message (const std::string &body)
void load_cloud_after_signout (const wxString &url)
void schedule_cloud_load (const wxString &url)
void clear_cloud_storage ()
void apply_cloud_layout (bool cloud_on)

Private Attributes

wxWebView * m_browser
wxWebView * m_cloud_browser {nullptr}
wxBoxSizer * m_content_sizer {nullptr}
wxString m_home_url
bool m_reset_on_show {false}
wxString m_cloud_base_url
wxString m_cloud_seed_url
wxString m_cloud_signout_url
wxString m_cloud_after_signout_url
bool m_cloud_pending_signout {false}
wxButton * m_button_stop
wxTextCtrl * m_url
wxBoxSizer * bSizer_toolbar
wxButton * m_button_back
wxButton * m_button_forward
wxButton * m_button_reload
wxButton * m_button_tools
wxMenu * m_tools_menu
wxMenuItem * m_tools_handle_navigation
wxMenuItem * m_tools_handle_new_window
wxMenuItem * m_edit_cut
wxMenuItem * m_edit_copy
wxMenuItem * m_edit_paste
wxMenuItem * m_edit_undo
wxMenuItem * m_edit_redo
wxMenuItem * m_edit_mode
wxMenuItem * m_script_string
wxMenuItem * m_script_integer
wxMenuItem * m_script_double
wxMenuItem * m_script_bool
wxMenuItem * m_script_object
wxMenuItem * m_script_array
wxMenuItem * m_script_dom
wxMenuItem * m_script_undefined
wxMenuItem * m_script_null
wxMenuItem * m_script_date
wxMenuItem * m_script_message
wxMenuItem * m_script_custom
wxMenuItem * m_selection_clear
wxMenuItem * m_selection_delete
wxMenuItem * m_context_menu
wxMenuItem * m_dev_tools
wxInfoBar * m_info
long m_zoomFactor
wxString m_javascript
wxString m_response_js

Static Private Attributes

static Lazy< WebViewPanel > * s_lazy

Detailed Description

Constructor & Destructor Documentation

◆ WebViewPanel()

Slic3r::GUI::WebViewPanel::WebViewPanel ( wxWindow * parent)
98 : wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize)
99 {
100 m_home_url = file_url_from_path(boost::filesystem::path(resources_dir()) / "web/homepage/index.html");
101 wxString strlang = wxGetApp().current_language_code_safe();
102 if (strlang != "")
103 m_home_url += "?lang=" + strlang;
104
105 wxBoxSizer* topsizer = new wxBoxSizer(wxVERTICAL);
106
107#if !BBL_RELEASE_TO_PUBLIC
108 // Create the button
109 bSizer_toolbar = new wxBoxSizer(wxHORIZONTAL);
110
111 m_button_back = new wxButton(this, wxID_ANY, _L_CONTEXT("Back", "Navigation"), wxDefaultPosition, wxDefaultSize, 0);
112 m_button_back->Enable(false);
113 bSizer_toolbar->Add(m_button_back, 0, wxALL, 5);
114
115 m_button_forward = new wxButton(this, wxID_ANY, _L("Forward"), wxDefaultPosition, wxDefaultSize, 0);
116 m_button_forward->Enable(false);
117 bSizer_toolbar->Add(m_button_forward, 0, wxALL, 5);
118
119 m_button_stop = new wxButton(this, wxID_ANY, _L("Stop"), wxDefaultPosition, wxDefaultSize, 0);
120
121 bSizer_toolbar->Add(m_button_stop, 0, wxALL, 5);
122
123 m_button_reload = new wxButton(this, wxID_ANY, _L("Reload"), wxDefaultPosition, wxDefaultSize, 0);
124 bSizer_toolbar->Add(m_button_reload, 0, wxALL, 5);
125
126 m_url = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER);
127 bSizer_toolbar->Add(m_url, 1, wxALL | wxEXPAND, 5);
128
129 m_button_tools = new wxButton(this, wxID_ANY, _L("Tools"), wxDefaultPosition, wxDefaultSize, 0);
130 bSizer_toolbar->Add(m_button_tools, 0, wxALL, 5);
131
132 topsizer->Add(bSizer_toolbar, 0, wxEXPAND, 0);
133 bSizer_toolbar->Show(false);
134
135 // Create panel for find toolbar.
136 wxPanel* panel = new wxPanel(this);
137 topsizer->Add(panel, wxSizerFlags().Expand());
138
139 // Create sizer for panel.
140 wxBoxSizer* panel_sizer = new wxBoxSizer(wxVERTICAL);
141 panel->SetSizer(panel_sizer);
142#endif //BBL_RELEASE_TO_PUBLIC
143 // Create the info panel
144 m_info = new wxInfoBar(this);
145 topsizer->Add(m_info, wxSizerFlags().Expand());
146 // Create the webview
149 SetSizer(topsizer);
150
151 // The homepage shell is the left nav column; when OrcaCloud opens, its page lives in a
152 // second native pane beside it (the site refuses to be framed).
153 m_content_sizer = new wxBoxSizer(wxHORIZONTAL);
154 m_content_sizer->Add(m_browser, wxSizerFlags().Expand().Proportion(1));
155 topsizer->Add(m_content_sizer, wxSizerFlags().Expand().Proportion(1));
156
157 // Log backend information
158 /* m_browser->GetUserAgent() may lead crash
159 if (wxGetApp().get_mode() == comDevelop) {
160 wxLogMessage(wxWebView::GetBackendVersionInfo().ToString());
161 wxLogMessage("Backend: %s Version: %s", m_browser->GetClassInfo()->GetClassName(),
162 wxWebView::GetBackendVersionInfo().ToString());
163 wxLogMessage("User Agent: %s", m_browser->GetUserAgent());
164 }
165 */
166
167 // Create the Tools menu
168 m_tools_menu = new wxMenu();
169 wxMenuItem* viewSource = m_tools_menu->Append(wxID_ANY, _L("View Source"));
170 wxMenuItem* viewText = m_tools_menu->Append(wxID_ANY, _L("View Text"));
171 m_tools_menu->AppendSeparator();
172 m_tools_handle_navigation = m_tools_menu->AppendCheckItem(wxID_ANY, _L("Handle Navigation"));
173 m_tools_handle_new_window = m_tools_menu->AppendCheckItem(wxID_ANY, _L("Handle New Windows"));
174 m_tools_menu->AppendSeparator();
175
176 //Create an editing menu
177 wxMenu* editmenu = new wxMenu();
178 m_edit_cut = editmenu->Append(wxID_ANY, _L("Cut"));
179 m_edit_copy = editmenu->Append(wxID_ANY, _L("Copy"));
180 m_edit_paste = editmenu->Append(wxID_ANY, _L("Paste"));
181 editmenu->AppendSeparator();
182 m_edit_undo = editmenu->Append(wxID_ANY, _L("Undo"));
183 m_edit_redo = editmenu->Append(wxID_ANY, _L("Redo"));
184 editmenu->AppendSeparator();
185 m_edit_mode = editmenu->AppendCheckItem(wxID_ANY, _L("Edit Mode"));
186 m_tools_menu->AppendSubMenu(editmenu, "Edit");
187
188 wxMenu* script_menu = new wxMenu;
189 m_script_string = script_menu->Append(wxID_ANY, "Return String");
190 m_script_integer = script_menu->Append(wxID_ANY, "Return integer");
191 m_script_double = script_menu->Append(wxID_ANY, "Return double");
192 m_script_bool = script_menu->Append(wxID_ANY, "Return bool");
193 m_script_object = script_menu->Append(wxID_ANY, "Return JSON object");
194 m_script_array = script_menu->Append(wxID_ANY, "Return array");
195 m_script_dom = script_menu->Append(wxID_ANY, "Modify DOM");
196 m_script_undefined = script_menu->Append(wxID_ANY, "Return undefined");
197 m_script_null = script_menu->Append(wxID_ANY, "Return null");
198 m_script_date = script_menu->Append(wxID_ANY, "Return Date");
199 m_script_message = script_menu->Append(wxID_ANY, "Send script message");
200 m_script_custom = script_menu->Append(wxID_ANY, "Custom script");
201 m_tools_menu->AppendSubMenu(script_menu, _L("Run Script"));
202 wxMenuItem* addUserScript = m_tools_menu->Append(wxID_ANY, _L("Add user script"));
203 wxMenuItem* setCustomUserAgent = m_tools_menu->Append(wxID_ANY, _L("Set custom user agent"));
204
205 //Selection menu
206 wxMenu* selection = new wxMenu();
207 m_selection_clear = selection->Append(wxID_ANY, _L("Clear Selection"));
208 m_selection_delete = selection->Append(wxID_ANY, _L("Delete Selection"));
209 wxMenuItem* selectall = selection->Append(wxID_ANY, _L("Select All"));
210
211 editmenu->AppendSubMenu(selection, "Selection");
212
213 wxMenuItem* loadscheme = m_tools_menu->Append(wxID_ANY, _L("Custom Scheme Example"));
214 wxMenuItem* usememoryfs = m_tools_menu->Append(wxID_ANY, _L("Memory File System Example"));
215
216 m_context_menu = m_tools_menu->AppendCheckItem(wxID_ANY, _L("Enable Context Menu"));
217 m_dev_tools = m_tools_menu->AppendCheckItem(wxID_ANY, _L("Enable Dev Tools"));
218
219 //By default we want to handle navigation and new windows
222
223 //Zoom
224 m_zoomFactor = 100;
225
226 // Connect the button events
227#if !BBL_RELEASE_TO_PUBLIC
228 Bind(wxEVT_BUTTON, &WebViewPanel::OnBack, this, m_button_back->GetId());
229 Bind(wxEVT_BUTTON, &WebViewPanel::OnForward, this, m_button_forward->GetId());
230 Bind(wxEVT_BUTTON, &WebViewPanel::OnStop, this, m_button_stop->GetId());
231 Bind(wxEVT_BUTTON, &WebViewPanel::OnReload, this, m_button_reload->GetId());
232 Bind(wxEVT_BUTTON, &WebViewPanel::OnToolsClicked, this, m_button_tools->GetId());
233 Bind(wxEVT_TEXT_ENTER, &WebViewPanel::OnUrl, this, m_url->GetId());
234
235#endif //BBL_RELEASE_TO_PUBLIC
236
237 // Connect the webview events
238 Bind(wxEVT_WEBVIEW_NAVIGATING, &WebViewPanel::OnNavigationRequest, this);
239 Bind(wxEVT_WEBVIEW_NAVIGATED, &WebViewPanel::OnNavigationComplete, this);
240 Bind(wxEVT_WEBVIEW_LOADED, &WebViewPanel::OnDocumentLoaded, this);
241 Bind(wxEVT_WEBVIEW_TITLE_CHANGED, &WebViewPanel::OnTitleChanged, this);
242 Bind(wxEVT_WEBVIEW_ERROR, &WebViewPanel::OnError, this);
243 Bind(wxEVT_WEBVIEW_NEWWINDOW, &WebViewPanel::OnNewWindow, this);
244 Bind(wxEVT_WEBVIEW_SCRIPT_MESSAGE_RECEIVED, &WebViewPanel::OnScriptMessage, this);
245 Bind(EVT_RESPONSE_MESSAGE, &WebViewPanel::OnScriptResponseMessage, this);
246
247 // Connect the menu events
248 Bind(wxEVT_MENU, &WebViewPanel::OnViewSourceRequest, this, viewSource->GetId());
249 Bind(wxEVT_MENU, &WebViewPanel::OnViewTextRequest, this, viewText->GetId());
250 Bind(wxEVT_MENU, &WebViewPanel::OnCut, this, m_edit_cut->GetId());
251 Bind(wxEVT_MENU, &WebViewPanel::OnCopy, this, m_edit_copy->GetId());
252 Bind(wxEVT_MENU, &WebViewPanel::OnPaste, this, m_edit_paste->GetId());
253 Bind(wxEVT_MENU, &WebViewPanel::OnUndo, this, m_edit_undo->GetId());
254 Bind(wxEVT_MENU, &WebViewPanel::OnRedo, this, m_edit_redo->GetId());
255 Bind(wxEVT_MENU, &WebViewPanel::OnMode, this, m_edit_mode->GetId());
256 Bind(wxEVT_MENU, &WebViewPanel::OnRunScriptString, this, m_script_string->GetId());
257 Bind(wxEVT_MENU, &WebViewPanel::OnRunScriptInteger, this, m_script_integer->GetId());
258 Bind(wxEVT_MENU, &WebViewPanel::OnRunScriptDouble, this, m_script_double->GetId());
259 Bind(wxEVT_MENU, &WebViewPanel::OnRunScriptBool, this, m_script_bool->GetId());
260 Bind(wxEVT_MENU, &WebViewPanel::OnRunScriptObject, this, m_script_object->GetId());
261 Bind(wxEVT_MENU, &WebViewPanel::OnRunScriptArray, this, m_script_array->GetId());
262 Bind(wxEVT_MENU, &WebViewPanel::OnRunScriptDOM, this, m_script_dom->GetId());
263 Bind(wxEVT_MENU, &WebViewPanel::OnRunScriptUndefined, this, m_script_undefined->GetId());
264 Bind(wxEVT_MENU, &WebViewPanel::OnRunScriptNull, this, m_script_null->GetId());
265 Bind(wxEVT_MENU, &WebViewPanel::OnRunScriptDate, this, m_script_date->GetId());
266 Bind(wxEVT_MENU, &WebViewPanel::OnRunScriptMessage, this, m_script_message->GetId());
267 Bind(wxEVT_MENU, &WebViewPanel::OnRunScriptCustom, this, m_script_custom->GetId());
268 Bind(wxEVT_MENU, &WebViewPanel::OnAddUserScript, this, addUserScript->GetId());
269 Bind(wxEVT_MENU, &WebViewPanel::OnSetCustomUserAgent, this, setCustomUserAgent->GetId());
270 Bind(wxEVT_MENU, &WebViewPanel::OnClearSelection, this, m_selection_clear->GetId());
271 Bind(wxEVT_MENU, &WebViewPanel::OnDeleteSelection, this, m_selection_delete->GetId());
272 Bind(wxEVT_MENU, &WebViewPanel::OnSelectAll, this, selectall->GetId());
273 Bind(wxEVT_MENU, &WebViewPanel::OnLoadScheme, this, loadscheme->GetId());
274 Bind(wxEVT_MENU, &WebViewPanel::OnUseMemoryFS, this, usememoryfs->GetId());
275 Bind(wxEVT_MENU, &WebViewPanel::OnEnableContextMenu, this, m_context_menu->GetId());
276 Bind(wxEVT_MENU, &WebViewPanel::OnEnableDevTools, this, m_dev_tools->GetId());
277
278 //Connect the idle events
279 Bind(wxEVT_IDLE, &WebViewPanel::OnIdle, this);
280 Bind(wxEVT_CLOSE_WINDOW, &WebViewPanel::OnClose, this);
281
282 m_LoginUpdateTimer = nullptr;
283 update_mode();
284 }
#define _L(s)
Definition OBJ.cpp:34
class WXDLLIMPEXP_FWD_CORE wxButton
Definition ProgressDialog.hpp:27
wxMenuItem * m_edit_redo
Definition WebViewDialog.hpp:195
void OnDeleteSelection(wxCommandEvent &evt)
Definition WebViewDialog.cpp:1261
void update_mode()
Definition WebViewDialog.cpp:932
void OnViewSourceRequest(wxCommandEvent &evt)
Definition WebViewDialog.cpp:1083
void OnClearSelection(wxCommandEvent &evt)
Definition WebViewDialog.cpp:1256
wxMenuItem * m_script_date
Definition WebViewDialog.hpp:206
void OnRunScriptDate(wxCommandEvent &evt)
Definition WebViewDialog.cpp:1192
void OnNewWindow(wxWebViewEvent &evt)
Definition WebViewDialog.cpp:1025
void OnViewTextRequest(wxCommandEvent &evt)
Definition WebViewDialog.cpp:1092
void OnRunScriptDouble(wxCommandEvent &evt)
Definition WebViewDialog.cpp:1156
void OnForward(wxCommandEvent &evt)
Definition WebViewDialog.cpp:690
wxMenuItem * m_edit_mode
Definition WebViewDialog.hpp:196
void OnScriptMessage(wxWebViewEvent &evt)
Definition WebViewDialog.cpp:1046
wxButton * m_button_reload
Definition WebViewDialog.hpp:184
wxBoxSizer * m_content_sizer
Definition WebViewDialog.hpp:163
void OnPaste(wxCommandEvent &evt)
Definition WebViewDialog.cpp:724
wxMenuItem * m_script_string
Definition WebViewDialog.hpp:197
void OnRunScriptNull(wxCommandEvent &evt)
Definition WebViewDialog.cpp:1187
wxMenuItem * m_script_array
Definition WebViewDialog.hpp:202
wxMenuItem * m_tools_handle_new_window
Definition WebViewDialog.hpp:190
void OnToolsClicked(wxCommandEvent &evt)
Definition WebViewDialog.cpp:1113
void OnUrl(wxCommandEvent &evt)
Definition WebViewDialog.cpp:669
wxMenuItem * m_edit_paste
Definition WebViewDialog.hpp:193
void OnError(wxWebViewEvent &evt)
Definition WebViewDialog.cpp:1274
wxMenuItem * m_selection_clear
Definition WebViewDialog.hpp:209
wxMenuItem * m_script_integer
Definition WebViewDialog.hpp:198
void OnNavigationComplete(wxWebViewEvent &evt)
Definition WebViewDialog.cpp:986
void OnStop(wxCommandEvent &evt)
Definition WebViewDialog.cpp:699
void OnBack(wxCommandEvent &evt)
Definition WebViewDialog.cpp:681
void OnTitleChanged(wxWebViewEvent &evt)
Definition WebViewDialog.cpp:1016
void create_browser()
Definition WebViewDialog.cpp:302
void OnNavigationRequest(wxWebViewEvent &evt)
Definition WebViewDialog.cpp:942
wxWebView * m_browser
Definition WebViewDialog.hpp:161
wxMenu * m_tools_menu
Definition WebViewDialog.hpp:188
void OnSelectAll(wxCommandEvent &evt)
Definition WebViewDialog.cpp:1266
wxMenuItem * m_script_undefined
Definition WebViewDialog.hpp:204
wxMenuItem * m_context_menu
Definition WebViewDialog.hpp:211
wxMenuItem * m_script_object
Definition WebViewDialog.hpp:201
wxTimer * m_LoginUpdateTimer
Definition WebViewDialog.hpp:101
void OnSetCustomUserAgent(wxCommandEvent &evt)
Definition WebViewDialog.cpp:1238
long m_zoomFactor
Definition WebViewDialog.hpp:216
void OnRunScriptString(wxCommandEvent &evt)
Definition WebViewDialog.cpp:1146
wxBoxSizer * bSizer_toolbar
Definition WebViewDialog.hpp:181
void OnDocumentLoaded(wxWebViewEvent &evt)
Definition WebViewDialog.cpp:1000
void OnIdle(wxIdleEvent &evt)
Definition WebViewDialog.cpp:650
void OnRedo(wxCommandEvent &evt)
Definition WebViewDialog.cpp:734
void OnEnableDevTools(wxCommandEvent &evt)
Definition WebViewDialog.cpp:771
wxMenuItem * m_script_message
Definition WebViewDialog.hpp:207
void OnRunScriptObject(wxCommandEvent &evt)
Definition WebViewDialog.cpp:1166
wxTextCtrl * m_url
Definition WebViewDialog.hpp:178
wxMenuItem * m_script_dom
Definition WebViewDialog.hpp:203
wxMenuItem * m_edit_undo
Definition WebViewDialog.hpp:194
wxButton * m_button_stop
Definition WebViewDialog.hpp:177
void OnAddUserScript(wxCommandEvent &evt)
Definition WebViewDialog.cpp:1220
wxMenuItem * m_script_double
Definition WebViewDialog.hpp:199
void OnReload(wxCommandEvent &evt)
Definition WebViewDialog.cpp:708
void OnCut(wxCommandEvent &evt)
Definition WebViewDialog.cpp:714
void OnRunScriptCustom(wxCommandEvent &evt)
Definition WebViewDialog.cpp:1204
void OnRunScriptMessage(wxCommandEvent &evt)
Definition WebViewDialog.cpp:1199
wxMenuItem * m_edit_copy
Definition WebViewDialog.hpp:192
void OnLoadScheme(wxCommandEvent &evt)
Definition WebViewDialog.cpp:744
wxButton * m_button_tools
Definition WebViewDialog.hpp:185
wxMenuItem * m_tools_handle_navigation
Definition WebViewDialog.hpp:189
wxMenuItem * m_script_bool
Definition WebViewDialog.hpp:200
bool m_reset_on_show
Definition WebViewDialog.hpp:165
wxMenuItem * m_dev_tools
Definition WebViewDialog.hpp:212
void OnRunScriptDOM(wxCommandEvent &evt)
Definition WebViewDialog.cpp:1177
wxButton * m_button_forward
Definition WebViewDialog.hpp:183
void OnMode(wxCommandEvent &evt)
Definition WebViewDialog.cpp:739
wxButton * m_button_back
Definition WebViewDialog.hpp:182
wxInfoBar * m_info
Definition WebViewDialog.hpp:214
wxMenuItem * m_script_null
Definition WebViewDialog.hpp:205
void OnUndo(wxCommandEvent &evt)
Definition WebViewDialog.cpp:729
void OnRunScriptArray(wxCommandEvent &evt)
Definition WebViewDialog.cpp:1172
wxMenuItem * m_script_custom
Definition WebViewDialog.hpp:208
void OnRunScriptInteger(wxCommandEvent &evt)
Definition WebViewDialog.cpp:1151
void OnUseMemoryFS(wxCommandEvent &evt)
Definition WebViewDialog.cpp:761
void OnCopy(wxCommandEvent &evt)
Definition WebViewDialog.cpp:719
wxString m_home_url
Definition WebViewDialog.hpp:164
void OnEnableContextMenu(wxCommandEvent &evt)
Definition WebViewDialog.cpp:766
void OnRunScriptUndefined(wxCommandEvent &evt)
Definition WebViewDialog.cpp:1182
void OnRunScriptBool(wxCommandEvent &evt)
Definition WebViewDialog.cpp:1161
wxMenuItem * m_edit_cut
Definition WebViewDialog.hpp:191
wxMenuItem * m_selection_delete
Definition WebViewDialog.hpp:210
void OnScriptResponseMessage(wxCommandEvent &evt)
Definition WebViewDialog.cpp:1073
void OnClose(wxCloseEvent &evt)
Definition WebViewDialog.cpp:776
static bool NeedsRecreateOnShow()
Definition WebView.cpp:424
wxString file_url_from_path(const boost::filesystem::path &path)
Definition GUI.cpp:569
const std::string & resources_dir()
Definition utils.cpp:296
#define _L_CONTEXT(s, ctx)
Definition I18N.hpp:15

References WebViewPanel(), _L, _L_CONTEXT, bSizer_toolbar, create_browser(), Slic3r::GUI::file_url_from_path(), m_browser, m_button_back, m_button_forward, m_button_reload, m_button_stop, m_button_tools, m_content_sizer, m_context_menu, m_dev_tools, m_edit_copy, m_edit_cut, m_edit_mode, m_edit_paste, m_edit_redo, m_edit_undo, m_home_url, m_info, m_LoginUpdateTimer, m_reset_on_show, m_script_array, m_script_bool, m_script_custom, m_script_date, m_script_dom, m_script_double, m_script_integer, m_script_message, m_script_null, m_script_object, m_script_string, m_script_undefined, m_selection_clear, m_selection_delete, m_tools_handle_navigation, m_tools_handle_new_window, m_tools_menu, m_url, m_zoomFactor, WebView::NeedsRecreateOnShow(), OnAddUserScript(), OnBack(), OnClearSelection(), OnClose(), OnCopy(), OnCut(), OnDeleteSelection(), OnDocumentLoaded(), OnEnableContextMenu(), OnEnableDevTools(), OnError(), OnForward(), OnIdle(), OnLoadScheme(), OnMode(), OnNavigationComplete(), OnNavigationRequest(), OnNewWindow(), OnPaste(), OnRedo(), OnReload(), OnRunScriptArray(), OnRunScriptBool(), OnRunScriptCustom(), OnRunScriptDate(), OnRunScriptDOM(), OnRunScriptDouble(), OnRunScriptInteger(), OnRunScriptMessage(), OnRunScriptNull(), OnRunScriptObject(), OnRunScriptString(), OnRunScriptUndefined(), OnScriptMessage(), OnScriptResponseMessage(), OnSelectAll(), OnSetCustomUserAgent(), OnStop(), OnTitleChanged(), OnToolsClicked(), OnUndo(), OnUrl(), OnUseMemoryFS(), OnViewSourceRequest(), OnViewTextRequest(), Slic3r::resources_dir(), update_mode(), and wxButton.

Referenced by WebViewPanel().

Here is the caller graph for this function:

◆ ~WebViewPanel()

Slic3r::GUI::WebViewPanel::~WebViewPanel ( )
virtual
287{
288 BOOST_LOG_TRIVIAL(trace) << __FUNCTION__ << " Start";
289 SetEvtHandlerEnabled(false);
290
291 delete m_tools_menu;
292
293 if (m_LoginUpdateTimer != nullptr) {
294 m_LoginUpdateTimer->Stop();
295 delete m_LoginUpdateTimer;
296 m_LoginUpdateTimer = NULL;
297 }
298 BOOST_LOG_TRIVIAL(trace) << __FUNCTION__ << " End";
299}
void trace(unsigned int level, const char *message)
Definition utils.cpp:247

References m_LoginUpdateTimer, m_tools_menu, and Slic3r::trace().

Here is the call graph for this function:

Member Function Documentation

◆ apply_cloud_layout()

void Slic3r::GUI::WebViewPanel::apply_cloud_layout ( bool cloud_on)
private
439{
440 if (!m_content_sizer)
441 return;
442
443 // Cloud mode pins the homepage to the nav column width; otherwise it fills the panel.
444 if (m_browser) {
445 if (wxSizerItem* item = m_content_sizer->GetItem(m_browser))
446 item->SetProportion(cloud_on ? 0 : 1);
447 // kLeftNavWidth is in DIP: the web view's CSS px are DIP, so scale to physical pixels.
448 m_browser->SetMinSize(cloud_on ? m_browser->FromDIP(wxSize(kLeftNavWidth, -1)) : wxDefaultSize);
449 }
450 Layout();
451}
static const int kLeftNavWidth
Definition WebViewDialog.cpp:68

References Slic3r::GUI::kLeftNavWidth, m_browser, and m_content_sizer.

Referenced by reset_browser(), and set_cloud_mode().

Here is the caller graph for this function:

◆ clear_cloud_storage()

void Slic3r::GUI::WebViewPanel::clear_cloud_storage ( )
private
490{
491 if (m_cloud_browser)
492 m_cloud_browser->ClearBrowsingData(wxWEBVIEW_BROWSING_DATA_ALL);
493}
wxWebView * m_cloud_browser
Definition WebViewDialog.hpp:162

References m_cloud_browser.

Referenced by cloud_signed_out(), and load_cloud_after_signout().

Here is the caller graph for this function:

◆ cloud_mode_active()

bool Slic3r::GUI::WebViewPanel::cloud_mode_active ( ) const
inline
127{ return m_cloud_browser && m_cloud_browser->IsShown(); }

References m_cloud_browser.

◆ cloud_signed_out()

void Slic3r::GUI::WebViewPanel::cloud_signed_out ( const wxString & signout_url)
522{
523 if (signout_url.empty())
524 return;
525 m_cloud_signout_url = signout_url;
526 // The next Start URL must re-seed the pane (it now reflects the signed-out state), so forget
527 // the previous seed regardless of which branch below runs.
528 m_cloud_seed_url.clear();
529 if (m_cloud_browser) {
531 // Run the sign-out page (ends the server-side session), then clear the pane's stored data.
532 load_cloud_url(signout_url);
534 } else {
535 // Pane never opened this run: clear the persisted session on its first open.
537 }
538}
void load_cloud_url(const wxString &url)
Definition WebViewDialog.cpp:453
wxString m_cloud_signout_url
Definition WebViewDialog.hpp:174
wxString m_cloud_seed_url
Definition WebViewDialog.hpp:172
void clear_cloud_storage()
Definition WebViewDialog.cpp:489
bool m_cloud_pending_signout
Definition WebViewDialog.hpp:176

References clear_cloud_storage(), load_cloud_url(), m_cloud_browser, m_cloud_pending_signout, m_cloud_seed_url, and m_cloud_signout_url.

Here is the call graph for this function:

◆ create_browser()

void Slic3r::GUI::WebViewPanel::create_browser ( )
private
303{
304 // Created empty and loaded after the strings are added, so the first load already has them.
305 m_browser = WebView::CreateWebView(this, wxEmptyString);
306 m_browser->AddUserScript(wxString::FromUTF8(WebViewHostDialog::localized_strings_script(home_page_strings())));
308 m_browser->Hide();
309}
static std::string localized_strings_script(const nlohmann::json &strings)
Definition WebViewHostDialog.cpp:156
static void LoadUrl(wxWebView *webView, wxString const &url)
Definition WebView.cpp:480
static wxWebView * CreateWebView(wxWindow *parent, wxString const &url)
Definition WebView.cpp:313
static json home_page_strings()
Definition WebViewDialog.cpp:71

References WebView::CreateWebView(), Slic3r::GUI::home_page_strings(), WebView::LoadUrl(), Slic3r::GUI::WebViewHostDialog::localized_strings_script(), m_browser, and m_home_url.

Referenced by WebViewPanel(), and reset_browser().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_cloud_browser()

void Slic3r::GUI::WebViewPanel::create_cloud_browser ( )
private
314{
315 m_cloud_browser = WebView::CreateWebView(this, wxEmptyString);
316
317#ifdef __linux__
318 // The pane's web session is a cookie (guide §3), and WebKitGTK keeps cookies only in memory
319 // unless a persistent store is set up, so without this the sign-in is lost on every restart
320 // (and on every reset_browser). Each wxWebView has its own context, so give the cloud pane its
321 // own store instead of sharing PrinterWebView's. Mirrors PrinterWebView::create_browser.
322 if (auto* wv = static_cast<WebKitWebView*>(m_cloud_browser->GetNativeBackend())) {
323 const auto cookies_path = boost::filesystem::path(data_dir() + "/cache/cloud_cookies.db");
324 auto* cookie_manager = webkit_web_context_get_cookie_manager(webkit_web_view_get_context(wv));
325 webkit_cookie_manager_set_persistent_storage(cookie_manager, cookies_path.c_str(),
326 WEBKIT_COOKIE_PERSISTENT_STORAGE_SQLITE);
327 }
328#endif
329
330 // Webview events are command events, so they would otherwise propagate up to the
331 // panel's handlers, which drive the homepage view. Keep the cloud pane's events here.
332 m_cloud_browser->Bind(wxEVT_WEBVIEW_NAVIGATING, &WebViewPanel::OnCloudWebViewEvent, this);
333 m_cloud_browser->Bind(wxEVT_WEBVIEW_NAVIGATED, &WebViewPanel::OnCloudWebViewEvent, this);
334 m_cloud_browser->Bind(wxEVT_WEBVIEW_LOADED, &WebViewPanel::OnCloudWebViewEvent, this);
335 m_cloud_browser->Bind(wxEVT_WEBVIEW_TITLE_CHANGED, &WebViewPanel::OnCloudWebViewEvent, this);
336 m_cloud_browser->Bind(wxEVT_WEBVIEW_ERROR, &WebViewPanel::OnCloudWebViewEvent, this);
337 m_cloud_browser->Bind(wxEVT_WEBVIEW_NEWWINDOW, &WebViewPanel::OnCloudWebViewEvent, this);
338 m_cloud_browser->Bind(wxEVT_WEBVIEW_SCRIPT_MESSAGE_RECEIVED, &WebViewPanel::OnCloudWebViewEvent, this);
339
340 m_cloud_browser->Hide();
341 if (m_content_sizer)
342 m_content_sizer->Add(m_cloud_browser, wxSizerFlags().Expand().Proportion(1));
343}
void OnCloudWebViewEvent(wxWebViewEvent &evt)
Definition WebViewDialog.cpp:388
const std::string & data_dir()
Definition utils.cpp:365

References WebView::CreateWebView(), Slic3r::data_dir(), m_cloud_browser, m_content_sizer, and OnCloudWebViewEvent().

Referenced by reset_browser(), and set_cloud_mode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ensure()

WebViewPanel * Slic3r::GUI::LazyInstance< WebViewPanel >::ensure ( )
inlinestaticinherited
186{ return s_lazy ? s_lazy->ensure() : nullptr; }
Definition Lazy.hpp:180
static Self * ensure()
Definition Lazy.hpp:186

Referenced by Slic3r::GUI::MainFrame::init_tabpanel(), and Slic3r::GUI::GUI_App::open_orca_cloud().

Here is the caller graph for this function:

◆ get_design_staffpick()

void Slic3r::GUI::WebViewPanel::get_design_staffpick ( int offset,
int limit,
std::function< void(std::string)> callback )
907{
908 // auto host = wxGetApp().get_http_url(wxGetApp().app_config->get_country_code(), "v1/design-service/design/staffpick");
909 // std::string url = (boost::format("%1%/?offset=%2%&limit=%3%") % host % offset % limit).str();
910
911 // Http http = Http::get(url);
912 // http.header("accept", "application/json")
913 // .header("Content-Type", "application/json")
914 // .on_complete([this, callback](std::string body, unsigned status) { callback(body); })
915 // .on_error([this, callback](std::string body, std::string error, unsigned status) {
916 // callback(body);
917 // })
918 // .perform();
919}

References Slic3r::offset().

Here is the call graph for this function:

◆ get_model_mall_detail_url()

int Slic3r::GUI::WebViewPanel::get_model_mall_detail_url ( std::string * url,
std::string id )
922{
923 // https://makerhub-qa.bambu-lab.com/en/models/2077
924 std::string h = wxGetApp().get_model_http_url(wxGetApp().app_config->get_country_code());
925 auto l = wxGetApp().current_language_code_safe();
926 if (auto n = l.find('_'); n != std::string::npos)
927 l = l.substr(0, n);
928 *url = (boost::format("%1%%2%/models/%3%") % h % l % id).str();
929 return 0;
930}

Referenced by OpenModelDetail().

Here is the caller graph for this function:

◆ if_built()

◆ is_cloud_origin()

bool Slic3r::GUI::WebViewPanel::is_cloud_origin ( const wxString & url) const
private
471{
472 const wxString origin = http_origin_of(url);
473 return !origin.IsEmpty() && !m_cloud_base_url.IsEmpty() && origin == m_cloud_base_url;
474}
wxString m_cloud_base_url
Definition WebViewDialog.hpp:169
static wxString http_origin_of(const wxString &url)
Definition WebViewDialog.cpp:348

References Slic3r::GUI::http_origin_of(), and m_cloud_base_url.

Referenced by OnCloudWebViewEvent().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_cloud_after_signout()

void Slic3r::GUI::WebViewPanel::load_cloud_after_signout ( const wxString & url)
private
496{
498 // The pane did not exist when the user signed out, so its persisted session must be
499 // cleared before the sign-out page runs and `url` loads once that navigation finishes
500 // (see OnCloudWebViewEvent).
505 return;
506 }
507 load_cloud_url(url);
508}
wxString m_cloud_after_signout_url
Definition WebViewDialog.hpp:175

References clear_cloud_storage(), load_cloud_url(), m_cloud_after_signout_url, m_cloud_pending_signout, and m_cloud_signout_url.

Referenced by schedule_cloud_load(), and set_cloud_mode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_cloud_url()

void Slic3r::GUI::WebViewPanel::load_cloud_url ( const wxString & url)
454{
455 if (url.empty())
456 return;
457 // Track the origin of whatever the pane is told to load (Start URL, Complete URL, sign-out or
458 // the plain cloud fallback), so navigation policy has the right origin from the first load on.
459 const wxString origin = http_origin_of(url);
460 if (!origin.IsEmpty())
461 m_cloud_base_url = origin;
462 if (!m_cloud_browser)
463 return;
464 // Raw LoadURL: WebView::LoadUrl re-serialises through wxURI, which must not alter the
465 // fragment that carries the one-time handoff token. Log only the redacted URL.
466 BOOST_LOG_TRIVIAL(trace) << __FUNCTION__ << ": " << WebView::RedactUrl(url).ToUTF8().data();
467 m_cloud_browser->LoadURL(url);
468}
static wxString RedactUrl(const wxString &url)
Definition WebView.cpp:474

References Slic3r::GUI::http_origin_of(), m_cloud_base_url, m_cloud_browser, WebView::RedactUrl(), and Slic3r::trace().

Referenced by cloud_signed_out(), load_cloud_after_signout(), OnCloudWebViewEvent(), and set_cloud_mode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_url()

void Slic3r::GUI::WebViewPanel::load_url ( wxString & url)
605{
606 this->Show();
607 this->Raise();
608 m_url->ChangeValue(url);
609
610 if (wxGetApp().get_mode() == comDevelop)
611 wxLogMessage(m_url->GetValue());
612 m_browser->LoadURL(url);
613 m_browser->SetFocus();
614 UpdateState();
615}
void UpdateState()
Definition WebViewDialog.cpp:621
bool Show(bool show=true) override
Definition WebViewDialog.cpp:597
@ comDevelop
Definition Config.hpp:225

References Slic3r::comDevelop, m_browser, m_url, Show(), and UpdateState().

Referenced by Slic3r::GUI::MainFrame::init_tabpanel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ on_cloud_script_message()

void Slic3r::GUI::WebViewPanel::on_cloud_script_message ( const std::string & body)
private
424{
425 const json msg = json::parse(body, nullptr, false);
426 if (msg.is_discarded() || !msg.is_object() || msg.value("command", std::string()) != "request_web_session")
427 return;
428
429 std::string state;
430 if (msg.contains("data") && msg["data"].is_object())
431 state = msg["data"].value("state", std::string());
432 if (state.empty())
433 return;
434
435 wxGetApp().CallAfter([state = std::move(state)] { wxGetApp().request_cloud_web_session(state); });
436}
nlohmann::json json
Definition AssembleList.cpp:42

Referenced by OnCloudWebViewEvent().

Here is the caller graph for this function:

◆ OnAddUserScript()

void Slic3r::GUI::WebViewPanel::OnAddUserScript ( wxCommandEvent & evt)
1221{
1222 wxString userScript = "window.wx_test_var = 'wxWidgets webview sample';";
1223 wxTextEntryDialog dialog
1224 (
1225 this,
1226 "Enter the JavaScript code to run as the initialization script that runs before any script in the HTML document.",
1227 wxGetTextFromUserPromptStr,
1228 userScript,
1229 wxOK | wxCANCEL | wxCENTRE | wxTE_MULTILINE
1230 );
1231 if (dialog.ShowModal() != wxID_OK)
1232 return;
1233
1234 if (!m_browser->AddUserScript(dialog.GetValue()))
1235 wxLogError("Could not add user script");
1236}

References m_browser.

Referenced by WebViewPanel().

Here is the caller graph for this function:

◆ OnBack()

void Slic3r::GUI::WebViewPanel::OnBack ( wxCommandEvent & evt)

Callback invoked when user pressed the "back" button

682{
683 m_browser->GoBack();
684 UpdateState();
685}

References m_browser, and UpdateState().

Referenced by WebViewPanel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnClearSelection()

void Slic3r::GUI::WebViewPanel::OnClearSelection ( wxCommandEvent & evt)
1257{
1258 m_browser->ClearSelection();
1259}

References m_browser.

Referenced by WebViewPanel().

Here is the caller graph for this function:

◆ OnClose()

void Slic3r::GUI::WebViewPanel::OnClose ( wxCloseEvent & evt)
777{
778 this->Hide();
779}

Referenced by WebViewPanel().

Here is the caller graph for this function:

◆ OnCloudWebViewEvent()

void Slic3r::GUI::WebViewPanel::OnCloudWebViewEvent ( wxWebViewEvent & evt)
private
389{
390 const wxEventType event_type = evt.GetEventType();
391 if (event_type == wxEVT_WEBVIEW_NAVIGATING) {
392 const wxString url = evt.GetURL();
393 // Guide §3: keep every {web} page in the pane and open other sites (OAuth providers
394 // included) in the system browser. Only top-level navigations are diverted, and
395 // should_divert_cloud_url() excludes same-origin URLs and internal schemes.
397 evt.Veto();
399 }
400 } else if (event_type == wxEVT_WEBVIEW_NEWWINDOW) {
401 const wxString url = evt.GetURL();
402 if (!url.empty()) {
403 if (is_cloud_origin(url))
404 load_cloud_url(url);
405 else
407 }
408 evt.Veto();
409 } else if (event_type == wxEVT_WEBVIEW_SCRIPT_MESSAGE_RECEIVED) {
410 on_cloud_script_message(evt.GetString().utf8_string());
411 } else if (event_type == wxEVT_WEBVIEW_LOADED || event_type == wxEVT_WEBVIEW_ERROR) {
412 // A Start URL deferred behind a sign-out (see load_cloud_after_signout).
413 if (!m_cloud_after_signout_url.IsEmpty()) {
414 const wxString next = std::exchange(m_cloud_after_signout_url, wxString());
415 load_cloud_url(next);
416 }
417 }
418}
bool is_cloud_origin(const wxString &url) const
Definition WebViewDialog.cpp:470
void on_cloud_script_message(const std::string &body)
Definition WebViewDialog.cpp:423
bool should_divert_cloud_url(const wxString &url) const
Definition WebViewDialog.cpp:476
static void open_cloud_url_externally(const wxString &url)
Definition WebViewDialog.cpp:378
static bool cloud_navigation_is_top_level(const wxWebViewEvent &evt)
Definition WebViewDialog.cpp:367

References Slic3r::GUI::cloud_navigation_is_top_level(), is_cloud_origin(), load_cloud_url(), m_cloud_after_signout_url, on_cloud_script_message(), Slic3r::GUI::open_cloud_url_externally(), and should_divert_cloud_url().

Referenced by create_cloud_browser().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnCopy()

void Slic3r::GUI::WebViewPanel::OnCopy ( wxCommandEvent & evt)
720{
721 m_browser->Copy();
722}

References m_browser.

Referenced by WebViewPanel().

Here is the caller graph for this function:

◆ OnCut()

void Slic3r::GUI::WebViewPanel::OnCut ( wxCommandEvent & evt)
715{
716 m_browser->Cut();
717}

References m_browser.

Referenced by WebViewPanel().

Here is the caller graph for this function:

◆ OnDeleteSelection()

void Slic3r::GUI::WebViewPanel::OnDeleteSelection ( wxCommandEvent & evt)
1262{
1263 m_browser->DeleteSelection();
1264}

References m_browser.

Referenced by WebViewPanel().

Here is the caller graph for this function:

◆ OnDocumentLoaded()

void Slic3r::GUI::WebViewPanel::OnDocumentLoaded ( wxWebViewEvent & evt)

Callback invoked when a page is finished loading

1001{
1002 BOOST_LOG_TRIVIAL(trace) << __FUNCTION__ << ": " << evt.GetTarget().ToUTF8().data();
1003 // Only notify if the document is the main frame, not a subframe
1004 if (evt.GetURL() == m_browser->GetCurrentURL())
1005 {
1006 if (wxGetApp().get_mode() == comDevelop)
1007 wxLogMessage("%s", "Document loaded; url='" + evt.GetURL() + "'");
1008 }
1009 // A reloaded homepage loses its cloud-mode class; restore it if the pane is open.
1010 if (m_cloud_browser && m_cloud_browser->IsShown())
1011 RunScript("SetCloudMode(true)");
1012 UpdateState();
1014}
void RunScript(const wxString &javascript)
Definition WebViewDialog.cpp:1135
void SendCloudProvidersInfo()
Definition WebViewDialog.cpp:881

References Slic3r::comDevelop, m_browser, m_cloud_browser, RunScript(), SendCloudProvidersInfo(), Slic3r::trace(), and UpdateState().

Referenced by WebViewPanel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnEnableContextMenu()

void Slic3r::GUI::WebViewPanel::OnEnableContextMenu ( wxCommandEvent & evt)
767{
768 m_browser->EnableContextMenu(evt.IsChecked());
769}

References m_browser.

Referenced by WebViewPanel().

Here is the caller graph for this function:

◆ OnEnableDevTools()

void Slic3r::GUI::WebViewPanel::OnEnableDevTools ( wxCommandEvent & evt)
772{
773 m_browser->EnableAccessToDevTools(evt.IsChecked());
774}

References m_browser.

Referenced by WebViewPanel().

Here is the caller graph for this function:

◆ OnError()

void Slic3r::GUI::WebViewPanel::OnError ( wxWebViewEvent & evt)

Callback invoked when a loading error occurs

1275{
1276#define WX_ERROR_CASE(type) \
1277 case type: \
1278 category = #type; \
1279 break;
1280
1281 wxString category;
1282 switch (evt.GetInt())
1283 {
1284 WX_ERROR_CASE(wxWEBVIEW_NAV_ERR_CONNECTION);
1285 WX_ERROR_CASE(wxWEBVIEW_NAV_ERR_CERTIFICATE);
1286 WX_ERROR_CASE(wxWEBVIEW_NAV_ERR_AUTH);
1287 WX_ERROR_CASE(wxWEBVIEW_NAV_ERR_SECURITY);
1288 WX_ERROR_CASE(wxWEBVIEW_NAV_ERR_NOT_FOUND);
1289 WX_ERROR_CASE(wxWEBVIEW_NAV_ERR_REQUEST);
1290 WX_ERROR_CASE(wxWEBVIEW_NAV_ERR_USER_CANCELLED);
1291 WX_ERROR_CASE(wxWEBVIEW_NAV_ERR_OTHER);
1292 }
1293
1294 BOOST_LOG_TRIVIAL(trace) << __FUNCTION__ << ": [" << category << "] " << evt.GetString().ToUTF8().data();
1295
1296 if (wxGetApp().get_mode() == comDevelop)
1297 {
1298 wxLogMessage("%s", "Error; url='" + evt.GetURL() + "', error='" + category + " (" + evt.GetString() + ")'");
1299
1300 // Show the info bar with an error
1301 m_info->ShowMessage(wxString::Format(_L("An error occurred loading %s"), evt.GetURL()) + "\n" + "'" + category + "'", wxICON_ERROR);
1302 }
1303
1304 UpdateState();
1305}
#define WX_ERROR_CASE(type)

References _L, Slic3r::comDevelop, m_info, Slic3r::trace(), UpdateState(), and WX_ERROR_CASE.

Referenced by WebViewPanel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnForward()

void Slic3r::GUI::WebViewPanel::OnForward ( wxCommandEvent & evt)

Callback invoked when user pressed the "forward" button

691{
692 m_browser->GoForward();
693 UpdateState();
694}

References m_browser, and UpdateState().

Referenced by WebViewPanel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnFreshLoginStatus()

void Slic3r::GUI::WebViewPanel::OnFreshLoginStatus ( wxTimerEvent & event)
782{
783 if (WebViewPanel::if_built() == this) {
784 auto* app_config = Slic3r::GUI::wxGetApp().app_config;
785 if (app_config && app_config->get_stealth_mode()) return;
786 Slic3r::GUI::wxGetApp().get_login_info(ORCA_CLOUD_PROVIDER);
787 if (app_config && app_config->has_cloud_provider(BBL_CLOUD_PROVIDER)) {
788 Slic3r::GUI::wxGetApp().get_login_info(BBL_CLOUD_PROVIDER);
789 }
790 }
791}
static WebViewPanel * if_built()
Definition Lazy.hpp:183
static const std::string ORCA_CLOUD_PROVIDER("orca")
static const std::string BBL_CLOUD_PROVIDER("bbl")

References Slic3r::BBL_CLOUD_PROVIDER(), Slic3r::GUI::LazyInstance< WebViewPanel >::if_built(), and Slic3r::ORCA_CLOUD_PROVIDER().

Here is the call graph for this function:

◆ OnIdle()

void Slic3r::GUI::WebViewPanel::OnIdle ( wxIdleEvent & evt)
651{
652#if !BBL_RELEASE_TO_PUBLIC
653 if (m_browser->IsBusy())
654 {
655 wxSetCursor(wxCURSOR_ARROWWAIT);
656 m_button_stop->Enable(true);
657 }
658 else
659 {
660 wxSetCursor(wxNullCursor);
661 m_button_stop->Enable(false);
662 }
663#endif //BBL_RELEASE_TO_PUBLIC
664}

References m_browser, and m_button_stop.

Referenced by WebViewPanel().

Here is the caller graph for this function:

◆ OnLoadScheme()

void Slic3r::GUI::WebViewPanel::OnLoadScheme ( wxCommandEvent & evt)
745{
746 wxPathList pathlist;
747 pathlist.Add(".");
748 pathlist.Add("..");
749 pathlist.Add("../help");
750 pathlist.Add("../../../samples/help");
751
752 wxFileName helpfile(pathlist.FindValidPath("doc.zip"));
753 helpfile.MakeAbsolute();
754 wxString path = helpfile.GetFullPath();
755 //Under MSW we need to flip the slashes
756 path.Replace("\\", "/");
757 path = "wxfs:///" + path + ";protocol=zip/doc.htm";
758 m_browser->LoadURL(path);
759}

References m_browser.

Referenced by WebViewPanel().

Here is the caller graph for this function:

◆ OnMode()

void Slic3r::GUI::WebViewPanel::OnMode ( wxCommandEvent & evt)
740{
741 m_browser->SetEditable(m_edit_mode->IsChecked());
742}

References m_browser, and m_edit_mode.

Referenced by WebViewPanel().

Here is the caller graph for this function:

◆ OnNavigationComplete()

void Slic3r::GUI::WebViewPanel::OnNavigationComplete ( wxWebViewEvent & evt)

Callback invoked when a navigation request was accepted

987{
988 m_browser->Show();
989 Layout();
990 BOOST_LOG_TRIVIAL(trace) << __FUNCTION__ << ": " << WebView::RedactUrl(evt.GetURL()).ToUTF8().data();
991 if (wxGetApp().get_mode() == comDevelop)
992 wxLogMessage("%s", "Navigation complete; url='" + evt.GetURL() + "'");
993 UpdateState();
995}
void ShowNetpluginTip()
Definition WebViewDialog.cpp:857

References Slic3r::comDevelop, m_browser, WebView::RedactUrl(), ShowNetpluginTip(), Slic3r::trace(), and UpdateState().

Referenced by WebViewPanel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnNavigationRequest()

void Slic3r::GUI::WebViewPanel::OnNavigationRequest ( wxWebViewEvent & evt)

Callback invoked when there is a request to load a new page (for instance when the user clicks a link)

943{
944 BOOST_LOG_TRIVIAL(trace) << __FUNCTION__ << ": " << WebView::RedactUrl(evt.GetURL()).ToUTF8().data();
945 const wxString &url = evt.GetURL();
946 if (url.StartsWith("File://") || url.StartsWith("file://")) {
947 if (!url.Contains("/web/homepage/index.html")) {
948 auto file = wxURL::Unescape(wxURL(url).GetPath());
949#ifdef _WIN32
950 if (file.StartsWith('/'))
951 file = file.Mid(1);
952 else
953 file = "//" + file; // When file from network location
954#endif
955 wxGetApp().plater()->load_files(wxArrayString{1, &file});
956 evt.Veto();
957 return;
958 }
959 }
960
961 if (m_info->IsShown())
962 {
963 m_info->Dismiss();
964 }
965
966 if (wxGetApp().get_mode() == comDevelop)
967 wxLogMessage("%s", "Navigation request to '" + evt.GetURL() + "' (target='" +
968 evt.GetTarget() + "')");
969
970 //If we don't want to handle navigation then veto the event and navigation
971 //will not take place, we also need to stop the loading animation
972 if (!m_tools_handle_navigation->IsChecked())
973 {
974 evt.Veto();
975 m_button_stop->Enable(false);
976 }
977 else
978 {
979 UpdateState();
980 }
981}

References Slic3r::comDevelop, m_button_stop, m_info, m_tools_handle_navigation, WebView::RedactUrl(), Slic3r::trace(), and UpdateState().

Referenced by WebViewPanel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnNewWindow()

void Slic3r::GUI::WebViewPanel::OnNewWindow ( wxWebViewEvent & evt)

On new window, we veto to stop extra windows appearing

1026{
1027 BOOST_LOG_TRIVIAL(trace) << __FUNCTION__ << ": " << WebView::RedactUrl(evt.GetURL()).ToUTF8().data();
1028 wxString flag = " (other)";
1029
1030 if (evt.GetNavigationAction() == wxWEBVIEW_NAV_ACTION_USER)
1031 {
1032 flag = " (user)";
1033 }
1034
1035 if (wxGetApp().get_mode() == comDevelop)
1036 wxLogMessage("%s", "New window; url='" + evt.GetURL() + "'" + flag);
1037
1038 //If we handle new window events then just load them in this window as we
1039 //are a single window browser
1040 if (m_tools_handle_new_window->IsChecked())
1041 m_browser->LoadURL(evt.GetURL());
1042
1043 UpdateState();
1044}

References Slic3r::comDevelop, m_browser, m_tools_handle_new_window, WebView::RedactUrl(), Slic3r::trace(), and UpdateState().

Referenced by WebViewPanel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnPaste()

void Slic3r::GUI::WebViewPanel::OnPaste ( wxCommandEvent & evt)
725{
726 m_browser->Paste();
727}

References m_browser.

Referenced by WebViewPanel().

Here is the caller graph for this function:

◆ OnRedo()

void Slic3r::GUI::WebViewPanel::OnRedo ( wxCommandEvent & evt)
735{
736 m_browser->Redo();
737}

References m_browser.

Referenced by WebViewPanel().

Here is the caller graph for this function:

◆ OnReload()

void Slic3r::GUI::WebViewPanel::OnReload ( wxCommandEvent & evt)

Callback invoked when user pressed the "reload" button

709{
710 m_browser->Reload();
711 UpdateState();
712}

References m_browser, and UpdateState().

Referenced by WebViewPanel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnRunScriptArray()

void Slic3r::GUI::WebViewPanel::OnRunScriptArray ( wxCommandEvent & evt)
1173{
1174 RunScript("function f(){ return [\"foo\", \"bar\"]; }f();");
1175}

References RunScript().

Referenced by WebViewPanel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnRunScriptBool()

void Slic3r::GUI::WebViewPanel::OnRunScriptBool ( wxCommandEvent & evt)
1162{
1163 RunScript("function f(a){return a;}f(false);");
1164}

References RunScript().

Referenced by WebViewPanel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnRunScriptCustom()

void Slic3r::GUI::WebViewPanel::OnRunScriptCustom ( wxCommandEvent & evt)
1205{
1206 wxTextEntryDialog dialog
1207 (
1208 this,
1209 "Please enter JavaScript code to execute",
1210 wxGetTextFromUserPromptStr,
1212 wxOK | wxCANCEL | wxCENTRE | wxTE_MULTILINE
1213 );
1214 if (dialog.ShowModal() != wxID_OK)
1215 return;
1216
1217 RunScript(dialog.GetValue());
1218}
wxString m_javascript
Definition WebViewDialog.hpp:219

References m_javascript, and RunScript().

Referenced by WebViewPanel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnRunScriptDate()

void Slic3r::GUI::WebViewPanel::OnRunScriptDate ( wxCommandEvent & evt)
1193{
1194 RunScript("function f(){var d = new Date('10/08/2017 21:30:40'); \
1195 var tzoffset = d.getTimezoneOffset() * 60000; \
1196 return new Date(d.getTime() - tzoffset);}f();");
1197}

References RunScript().

Referenced by WebViewPanel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnRunScriptDOM()

void Slic3r::GUI::WebViewPanel::OnRunScriptDOM ( wxCommandEvent & evt)
1178{
1179 RunScript("document.write(\"Hello World!\");");
1180}

References RunScript().

Referenced by WebViewPanel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnRunScriptDouble()

void Slic3r::GUI::WebViewPanel::OnRunScriptDouble ( wxCommandEvent & evt)
1157{
1158 RunScript("function f(a){return a;}f(2.34);");
1159}

References RunScript().

Referenced by WebViewPanel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnRunScriptInteger()

void Slic3r::GUI::WebViewPanel::OnRunScriptInteger ( wxCommandEvent & evt)
1152{
1153 RunScript("function f(a){return a;}f(123);");
1154}

References RunScript().

Referenced by WebViewPanel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnRunScriptMessage()

void Slic3r::GUI::WebViewPanel::OnRunScriptMessage ( wxCommandEvent & evt)
1200{
1201 RunScript("window.wx.postMessage('This is a web message');");
1202}

References RunScript().

Referenced by WebViewPanel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnRunScriptNull()

void Slic3r::GUI::WebViewPanel::OnRunScriptNull ( wxCommandEvent & evt)
1188{
1189 RunScript("function f(){return null;}f();");
1190}

References RunScript().

Referenced by WebViewPanel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnRunScriptObject()

void Slic3r::GUI::WebViewPanel::OnRunScriptObject ( wxCommandEvent & evt)
1167{
1168 RunScript("function f(){var person = new Object();person.name = 'Foo'; \
1169 person.lastName = 'Bar';return person;}f();");
1170}

References RunScript().

Referenced by WebViewPanel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnRunScriptString()

void Slic3r::GUI::WebViewPanel::OnRunScriptString ( wxCommandEvent & evt)
1147{
1148 RunScript("setCount(345);");
1149}

References RunScript().

Referenced by WebViewPanel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnRunScriptUndefined()

void Slic3r::GUI::WebViewPanel::OnRunScriptUndefined ( wxCommandEvent & evt)
1183{
1184 RunScript("function f(){var person = new Object();}f();");
1185}

References RunScript().

Referenced by WebViewPanel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnScriptMessage()

void Slic3r::GUI::WebViewPanel::OnScriptMessage ( wxWebViewEvent & evt)
1047{
1048 BOOST_LOG_TRIVIAL(trace) << __FUNCTION__ << ": " << evt.GetString().ToUTF8().data();
1049 // update login status
1050 if (m_LoginUpdateTimer == nullptr) {
1051 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " Create Timer";
1053 m_LoginUpdateTimer->Start(2000);
1054 }
1055
1056 if (wxGetApp().get_mode() == comDevelop)
1057 wxLogMessage("Script message received; value = %s, handler = %s", evt.GetString(), evt.GetMessageHandler());
1058 std::string response = wxGetApp().handle_web_request(evt.GetString().ToUTF8().data());
1059 if (response.empty()) return;
1060
1061 /* remove \n in response string */
1062 response.erase(std::remove(response.begin(), response.end(), '\n'), response.end());
1063 if (!response.empty()) {
1064 m_response_js = wxString::Format("window.postMessage('%s')", response);
1065 wxCommandEvent* event = new wxCommandEvent(EVT_RESPONSE_MESSAGE, this->GetId());
1066 wxQueueEvent(this, event);
1067 }
1068 else {
1069 m_response_js.clear();
1070 }
1071}
#define LOGIN_INFO_UPDATE_TIMER_ID
Definition WebViewDialog.cpp:61
wxString m_response_js
Definition WebViewDialog.hpp:220

References Slic3r::comDevelop, LOGIN_INFO_UPDATE_TIMER_ID, m_LoginUpdateTimer, m_response_js, and Slic3r::trace().

Referenced by WebViewPanel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnScriptResponseMessage()

void Slic3r::GUI::WebViewPanel::OnScriptResponseMessage ( wxCommandEvent & evt)
1074{
1075 if (!m_response_js.empty()) {
1077 }
1078}

References m_response_js, and RunScript().

Referenced by WebViewPanel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnSelectAll()

void Slic3r::GUI::WebViewPanel::OnSelectAll ( wxCommandEvent & evt)
1267{
1268 m_browser->SelectAll();
1269}

References m_browser.

Referenced by WebViewPanel().

Here is the caller graph for this function:

◆ OnSetCustomUserAgent()

void Slic3r::GUI::WebViewPanel::OnSetCustomUserAgent ( wxCommandEvent & evt)
1239{
1240 wxString customUserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.1 Mobile/15E148 Safari/604.1";
1241 wxTextEntryDialog dialog
1242 (
1243 this,
1244 "Enter the custom user agent string you would like to use.",
1245 wxGetTextFromUserPromptStr,
1246 customUserAgent,
1247 wxOK | wxCANCEL | wxCENTRE
1248 );
1249 if (dialog.ShowModal() != wxID_OK)
1250 return;
1251
1252 if (!m_browser->SetUserAgent(customUserAgent))
1253 wxLogError("Could not set custom user agent");
1254}

References m_browser.

Referenced by WebViewPanel().

Here is the caller graph for this function:

◆ OnStop()

void Slic3r::GUI::WebViewPanel::OnStop ( wxCommandEvent & evt)

Callback invoked when user pressed the "stop" button

700{
701 m_browser->Stop();
702 UpdateState();
703}

References m_browser, and UpdateState().

Referenced by WebViewPanel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnTitleChanged()

void Slic3r::GUI::WebViewPanel::OnTitleChanged ( wxWebViewEvent & evt)
1017{
1018 BOOST_LOG_TRIVIAL(trace) << __FUNCTION__ << ": " << evt.GetString().ToUTF8().data();
1019 // wxGetApp().CallAfter([this] { SendRecentList(); });
1020}

References Slic3r::trace().

Referenced by WebViewPanel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnToolsClicked()

void Slic3r::GUI::WebViewPanel::OnToolsClicked ( wxCommandEvent & evt)

Invoked when user selects the "Menu" item

1114{
1115 if (m_browser->GetCurrentURL() == "")
1116 return;
1117
1118 m_edit_cut->Enable(m_browser->CanCut());
1119 m_edit_copy->Enable(m_browser->CanCopy());
1120 m_edit_paste->Enable(m_browser->CanPaste());
1121
1122 m_edit_undo->Enable(m_browser->CanUndo());
1123 m_edit_redo->Enable(m_browser->CanRedo());
1124
1125 m_selection_clear->Enable(m_browser->HasSelection());
1126 m_selection_delete->Enable(m_browser->HasSelection());
1127
1128 m_context_menu->Check(m_browser->IsContextMenuEnabled());
1129 m_dev_tools->Check(m_browser->IsAccessToDevToolsEnabled());
1130
1131 wxPoint position = ScreenToClient(wxGetMousePosition());
1132 PopupMenu(m_tools_menu, position.x, position.y);
1133}

References m_browser, m_context_menu, m_dev_tools, m_edit_copy, m_edit_cut, m_edit_paste, m_edit_redo, m_edit_undo, m_selection_clear, m_selection_delete, and m_tools_menu.

Referenced by WebViewPanel().

Here is the caller graph for this function:

◆ OnUndo()

void Slic3r::GUI::WebViewPanel::OnUndo ( wxCommandEvent & evt)
730{
731 m_browser->Undo();
732}

References m_browser.

Referenced by WebViewPanel().

Here is the caller graph for this function:

◆ OnUrl()

void Slic3r::GUI::WebViewPanel::OnUrl ( wxCommandEvent & evt)

Callback invoked when user entered an URL and pressed enter

670{
671 if (wxGetApp().get_mode() == comDevelop)
672 wxLogMessage(m_url->GetValue());
673 m_browser->LoadURL(m_url->GetValue());
674 m_browser->SetFocus();
675 UpdateState();
676}

References Slic3r::comDevelop, m_browser, m_url, and UpdateState().

Referenced by WebViewPanel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnUseMemoryFS()

void Slic3r::GUI::WebViewPanel::OnUseMemoryFS ( wxCommandEvent & evt)
762{
763 m_browser->LoadURL("memory:page1.htm");
764}

References m_browser.

Referenced by WebViewPanel().

Here is the caller graph for this function:

◆ OnViewSourceRequest()

void Slic3r::GUI::WebViewPanel::OnViewSourceRequest ( wxCommandEvent & evt)

Invoked when user selects the "View Source" menu item

1084{
1085 SourceViewDialog dlg(this, m_browser->GetPageSource());
1086 dlg.ShowModal();
1087}

References m_browser.

Referenced by WebViewPanel().

Here is the caller graph for this function:

◆ OnViewTextRequest()

void Slic3r::GUI::WebViewPanel::OnViewTextRequest ( wxCommandEvent & evt)

Invoked when user selects the "View Text" menu item

1093{
1094 wxDialog textViewDialog(this, wxID_ANY, "Page Text",
1095 wxDefaultPosition, wxSize(700, 500),
1096 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER);
1097
1098 wxTextCtrl* text = new wxTextCtrl(this, wxID_ANY, m_browser->GetPageText(),
1099 wxDefaultPosition, wxDefaultSize,
1100 wxTE_MULTILINE |
1101 wxTE_RICH |
1102 wxTE_READONLY);
1103
1104 wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
1105 sizer->Add(text, 1, wxEXPAND);
1106 SetSizer(sizer);
1107 textViewDialog.ShowModal();
1108}

References m_browser.

Referenced by WebViewPanel().

Here is the caller graph for this function:

◆ OpenModelDetail()

void Slic3r::GUI::WebViewPanel::OpenModelDetail ( std::string id,
NetworkAgent * agent )
833{
834 std::string url;
835 if ((agent ? agent->get_model_mall_detail_url(&url, id, wxGetApp().get_printer_cloud_provider()) : get_model_mall_detail_url(&url, id)) == 0)
836 {
837 if (url.find("?") != std::string::npos)
838 {
839 url += "&from=orcaslicer";
840 } else {
841 url += "?from=orcaslicer";
842 }
843
844 wxLaunchDefaultBrowser(url);
845 }
846}
int get_model_mall_detail_url(std::string *url, std::string id)
Definition WebViewDialog.cpp:921

References get_model_mall_detail_url(), and Slic3r::NetworkAgent::get_model_mall_detail_url().

Here is the call graph for this function:

◆ reset_browser()

void Slic3r::GUI::WebViewPanel::reset_browser ( )
private
576{
577 // Rebuild both views the same way, keeping the cloud pane's open/closed state.
578 const bool cloud_on = m_cloud_browser && m_cloud_browser->IsShown();
579
580 m_browser->Destroy(); // also removes it from the sizer
582 m_content_sizer->Insert(size_t(0), m_browser, wxSizerFlags().Expand().Proportion(1));
583
584 if (m_cloud_browser) {
585 m_cloud_browser->Destroy();
586 m_cloud_browser = nullptr;
589 m_cloud_browser->Show(cloud_on);
590 // The rebuilt pane holds no seed, so the next open loads the Start URL again.
591 m_cloud_seed_url.clear();
592 }
593
594 apply_cloud_layout(cloud_on);
595}
void create_cloud_browser()
Definition WebViewDialog.cpp:313
void schedule_cloud_load(const wxString &url)
Definition WebViewDialog.cpp:510
void apply_cloud_layout(bool cloud_on)
Definition WebViewDialog.cpp:438
static const char *const kCloudUrl
Definition WebViewDialog.cpp:65

References apply_cloud_layout(), create_browser(), create_cloud_browser(), Slic3r::GUI::kCloudUrl, m_browser, m_cloud_browser, m_cloud_seed_url, m_content_sizer, and schedule_cloud_load().

Referenced by Show().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RunScript()

void Slic3r::GUI::WebViewPanel::RunScript ( const wxString & javascript)
1136{
1137 // Remember the script we run in any case, so the next time the user opens
1138 // the "Run Script" dialog box, it is shown there for convenient updating.
1139 m_javascript = javascript;
1140
1141 if (!m_browser) return;
1142
1143 WebView::RunScript(m_browser, javascript);
1144}
static bool RunScript(wxWebView *webView, wxString const &msg)
Definition WebView.cpp:491

References m_browser, m_javascript, and WebView::RunScript().

Referenced by OnDocumentLoaded(), OnRunScriptArray(), OnRunScriptBool(), OnRunScriptCustom(), OnRunScriptDate(), OnRunScriptDOM(), OnRunScriptDouble(), OnRunScriptInteger(), OnRunScriptMessage(), OnRunScriptNull(), OnRunScriptObject(), OnRunScriptString(), OnRunScriptUndefined(), OnScriptResponseMessage(), SendCloudProvidersInfo(), SendLoginInfo(), SendRecentList(), set_cloud_mode(), SetLoginPanelVisibility(), and ShowNetpluginTip().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ schedule_cloud_load()

void Slic3r::GUI::WebViewPanel::schedule_cloud_load ( const wxString & url)
private
511{
512 if (!m_cloud_browser) {
514 return;
515 }
516 // CreateWebView queues the "wx" handler add on the view (macOS/Linux); queue the load behind
517 // it so the page's first scripts already see the bridge (guide §3).
518 m_cloud_browser->CallAfter([this, url]() { load_cloud_after_signout(url); });
519}
void load_cloud_after_signout(const wxString &url)
Definition WebViewDialog.cpp:495

References load_cloud_after_signout(), and m_cloud_browser.

Referenced by reset_browser(), and set_cloud_mode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SendCloudProvidersInfo()

void Slic3r::GUI::WebViewPanel::SendCloudProvidersInfo ( )
882{
883 auto* app_config = wxGetApp().app_config;
884 if (!app_config)
885 return;
886
887 json j;
888 j["command"] = "cloud_providers_info";
889 json data;
890 json provider_array = json::array();
891
892 if (!app_config->get_hide_login_side_panel()) {
893 auto providers = app_config->get_cloud_providers();
894 for (const auto& p : providers) {
895 provider_array.push_back(p);
896 }
897 }
898
899 data["providers"] = provider_array;
900 j["data"] = data;
901
902 wxString strJS = wxString::Format("window.postMessage(%s)", j.dump());
903 RunScript(strJS);
904}

References RunScript().

Referenced by OnDocumentLoaded().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SendDesignStaffpick()

void Slic3r::GUI::WebViewPanel::SendDesignStaffpick ( bool on)
812{
813 // if (on) {
814 // get_design_staffpick(0, 60, [this](std::string body) {
815 // if (body.empty() || body.front() != '{') {
816 // BOOST_LOG_TRIVIAL(warning) << "get_design_staffpick failed " + body;
817 // return;
818 // }
819 // CallAfter([this, body] {
820 // auto body2 = from_u8(body);
821 // body2.insert(1, "\"command\": \"modelmall_model_advise_get\", ");
822 // RunScript(wxString::Format("window.postMessage(%s)", body2));
823 // });
824 // });
825 // } else {
826 // std::string body2 = "{\"total\":0, \"hits\":[]}";
827 // body2.insert(1, "\"command\": \"modelmall_model_advise_get\", ");
828 // RunScript(wxString::Format("window.postMessage(%s)", body2));
829 // }
830}

◆ SendLoginInfo()

void Slic3r::GUI::WebViewPanel::SendLoginInfo ( )
849{
850 if (wxGetApp().getAgent()) {
851 std::string login_info = wxGetApp().getAgent()->build_login_info();
852 wxString strJS = wxString::Format("window.postMessage(%s)", login_info);
853 RunScript(strJS);
854 }
855}

References RunScript().

Here is the call graph for this function:

◆ SendRecentList()

void Slic3r::GUI::WebViewPanel::SendRecentList ( int images)
799{
800 boost::property_tree::wptree req;
801 boost::property_tree::wptree data;
802 wxGetApp().mainframe->get_recent_projects(data, images);
803 req.put(L"sequence_id", "");
804 req.put(L"command", L"get_recent_projects");
805 req.put_child(L"response", data);
806 std::wostringstream oss;
807 pt::write_json(oss, req, false);
808 RunScript(wxString::Format("window.postMessage(%s)", oss.str()));
809}
#define L(s)
Definition ExtrusionEntity.cpp:25

References L, and RunScript().

Here is the call graph for this function:

◆ set_cloud_mode()

void Slic3r::GUI::WebViewPanel::set_cloud_mode ( bool on,
const wxString & url = wxString(),
const wxString & page_url = wxString() )
541{
542 if (on) {
543 // load_cloud_url records the origin from whatever it loads, including the plain cloud
544 // fallback used when `url` is empty.
545 if (!m_cloud_browser) {
547 m_cloud_seed_url = url;
548 schedule_cloud_load(url.empty() ? wxString(kCloudUrl) : url);
549 } else if (!page_url.empty()) {
550 // The pane already holds a session, so an explicit page loads straight in; the handoff is
551 // only needed to establish one, not to reach an ordinary page.
552 load_cloud_url(page_url);
553 } else if (!url.empty() && url != m_cloud_seed_url) {
554 // Re-seed only when the Start URL actually changed — a login, an account switch or a
555 // sign-out changes it; an ordinary re-open does not (guide §8). Reloading an unchanged
556 // Start URL re-runs the page's auth check on every open, which flashes "Signing you
557 // in…" and re-requests a session (guide §10: mint when the page asks, not per open).
558 // The pane is kept alive, so an unchanged open just shows the page it already holds.
559 m_cloud_seed_url = url;
561 }
562 m_cloud_browser->Show();
563 // The homepage shell owns the nav highlight and the cloud-mode layout class. A native open
564 // (not the page's own GotoCloud) must ask it to switch; the page's SetCloudMode no-ops if it
565 // already did. OnDocumentLoaded re-applies this when the homepage was still loading.
566 RunScript("SetCloudMode(true)");
567 } else if (m_cloud_browser) {
568 // Closing keeps the pane alive with its session, so re-opening does not have to sign in
569 // again (guide §10). Nothing is cleared here.
570 m_cloud_browser->Hide();
571 }
572 apply_cloud_layout(on && m_cloud_browser != nullptr);
573}

References apply_cloud_layout(), create_cloud_browser(), Slic3r::GUI::kCloudUrl, load_cloud_after_signout(), load_cloud_url(), m_cloud_browser, m_cloud_seed_url, RunScript(), and schedule_cloud_load().

Here is the call graph for this function:

◆ SetLoginPanelVisibility()

void Slic3r::GUI::WebViewPanel::SetLoginPanelVisibility ( bool bshow)
794{
795 wxString strJS = wxString::Format("SetLoginPanelVisibility(%s)", bshow ? "true" : "false");
796 RunScript(strJS);
797}

References RunScript().

Here is the call graph for this function:

◆ should_divert_cloud_url()

bool Slic3r::GUI::WebViewPanel::should_divert_cloud_url ( const wxString & url) const
private
477{
478 const wxString origin = http_origin_of(url);
479 // Unknown cloud origin or a non-web scheme: never divert (the pane must keep working).
480 if (origin.IsEmpty() || m_cloud_base_url.IsEmpty())
481 return false;
482 return origin != m_cloud_base_url;
483}

References Slic3r::GUI::http_origin_of(), and m_cloud_base_url.

Referenced by OnCloudWebViewEvent().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Show()

bool Slic3r::GUI::WebViewPanel::Show ( bool show = true)
override
598{
599 if (show && std::exchange(m_reset_on_show, false))
601 return wxPanel::Show(show);
602}
void reset_browser()
Definition WebViewDialog.cpp:575

References m_reset_on_show, and reset_browser().

Referenced by load_url().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ShowNetpluginTip()

void Slic3r::GUI::WebViewPanel::ShowNetpluginTip ( )
858{
859 // Install Network Plugin
860 const auto bblnetwork_enabled =wxGetApp().app_config->get_bool("installed_networking");
861 if(!bblnetwork_enabled) {
862 return;
863 }
864 bool bValid = wxGetApp().is_compatibility_version();
865
866 int nShow = 0;
867 if (!bValid) nShow = 1;
868
869 BOOST_LOG_TRIVIAL(info) << __FUNCTION__<< boost::format(": bValid=%1%, nShow=%2%")%bValid %nShow;
870
871 json m_Res = json::object();
872 m_Res["command"] = "network_plugin_installtip";
873 m_Res["sequence_id"] = "10001";
874 m_Res["show"] = nShow;
875
876 wxString strJS = wxString::Format("window.postMessage(%s)", m_Res.dump(-1, ' ', false, json::error_handler_t::ignore));
877
878 RunScript(strJS);
879}

References RunScript().

Referenced by OnNavigationComplete().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_mode()

void Slic3r::GUI::WebViewPanel::update_mode ( )
933{
934 GetSizer()->Show(size_t(0), wxGetApp().app_config->get("internal_developer_mode") == "true");
935 GetSizer()->Layout();
936}

Referenced by WebViewPanel().

Here is the caller graph for this function:

◆ UpdateState()

void Slic3r::GUI::WebViewPanel::UpdateState ( )

Method that retrieves the current state from the web control and updates the GUI the reflect this current state.

622{
623#if !BBL_RELEASE_TO_PUBLIC
624 if (m_browser->CanGoBack()) {
625 m_button_back->Enable(true);
626 }
627 else {
628 m_button_back->Enable(false);
629 }
630 if (m_browser->CanGoForward()) {
631 m_button_forward->Enable(true);
632 }
633 else {
634 m_button_forward->Enable(false);
635 }
636 if (m_browser->IsBusy())
637 {
638 m_button_stop->Enable(true);
639 }
640 else
641 {
642 m_button_stop->Enable(false);
643 }
644
645 //SetTitle(m_browser->GetCurrentTitle());
646 m_url->SetValue(m_browser->GetCurrentURL());
647#endif //BBL_RELEASE_TO_PUBLIC
648}

References m_browser, m_button_back, m_button_forward, m_button_stop, and m_url.

Referenced by load_url(), OnBack(), OnDocumentLoaded(), OnError(), OnForward(), OnNavigationComplete(), OnNavigationRequest(), OnNewWindow(), OnReload(), OnStop(), and OnUrl().

Here is the caller graph for this function:

◆ when_built()

void Slic3r::GUI::LazyInstance< WebViewPanel >::when_built ( std::function< void(WebViewPanel &)> fn)
inlinestaticinherited
189 {
190 if (s_lazy)
192 }
static void when_built(std::function< void(Self &)> fn)
Definition Lazy.hpp:188

Member Data Documentation

◆ bSizer_toolbar

wxBoxSizer* Slic3r::GUI::WebViewPanel::bSizer_toolbar
private

Referenced by WebViewPanel().

◆ m_browser

◆ m_button_back

wxButton* Slic3r::GUI::WebViewPanel::m_button_back
private

Referenced by WebViewPanel(), and UpdateState().

◆ m_button_forward

wxButton* Slic3r::GUI::WebViewPanel::m_button_forward
private

Referenced by WebViewPanel(), and UpdateState().

◆ m_button_reload

wxButton* Slic3r::GUI::WebViewPanel::m_button_reload
private

Referenced by WebViewPanel().

◆ m_button_stop

wxButton* Slic3r::GUI::WebViewPanel::m_button_stop
private

◆ m_button_tools

wxButton* Slic3r::GUI::WebViewPanel::m_button_tools
private

Referenced by WebViewPanel().

◆ m_cloud_after_signout_url

wxString Slic3r::GUI::WebViewPanel::m_cloud_after_signout_url
private

◆ m_cloud_base_url

wxString Slic3r::GUI::WebViewPanel::m_cloud_base_url
private

◆ m_cloud_browser

wxWebView* Slic3r::GUI::WebViewPanel::m_cloud_browser {nullptr}
private

◆ m_cloud_pending_signout

bool Slic3r::GUI::WebViewPanel::m_cloud_pending_signout {false}
private
176{false};

Referenced by cloud_signed_out(), and load_cloud_after_signout().

◆ m_cloud_seed_url

wxString Slic3r::GUI::WebViewPanel::m_cloud_seed_url
private

◆ m_cloud_signout_url

wxString Slic3r::GUI::WebViewPanel::m_cloud_signout_url
private

◆ m_content_sizer

wxBoxSizer* Slic3r::GUI::WebViewPanel::m_content_sizer {nullptr}
private

◆ m_context_menu

wxMenuItem* Slic3r::GUI::WebViewPanel::m_context_menu
private

Referenced by WebViewPanel(), and OnToolsClicked().

◆ m_dev_tools

wxMenuItem* Slic3r::GUI::WebViewPanel::m_dev_tools
private

Referenced by WebViewPanel(), and OnToolsClicked().

◆ m_edit_copy

wxMenuItem* Slic3r::GUI::WebViewPanel::m_edit_copy
private

Referenced by WebViewPanel(), and OnToolsClicked().

◆ m_edit_cut

wxMenuItem* Slic3r::GUI::WebViewPanel::m_edit_cut
private

Referenced by WebViewPanel(), and OnToolsClicked().

◆ m_edit_mode

wxMenuItem* Slic3r::GUI::WebViewPanel::m_edit_mode
private

Referenced by WebViewPanel(), and OnMode().

◆ m_edit_paste

wxMenuItem* Slic3r::GUI::WebViewPanel::m_edit_paste
private

Referenced by WebViewPanel(), and OnToolsClicked().

◆ m_edit_redo

wxMenuItem* Slic3r::GUI::WebViewPanel::m_edit_redo
private

Referenced by WebViewPanel(), and OnToolsClicked().

◆ m_edit_undo

wxMenuItem* Slic3r::GUI::WebViewPanel::m_edit_undo
private

Referenced by WebViewPanel(), and OnToolsClicked().

◆ m_home_url

wxString Slic3r::GUI::WebViewPanel::m_home_url
private

Referenced by WebViewPanel(), and create_browser().

◆ m_info

wxInfoBar* Slic3r::GUI::WebViewPanel::m_info
private

◆ m_javascript

wxString Slic3r::GUI::WebViewPanel::m_javascript
private

Referenced by OnRunScriptCustom(), and RunScript().

◆ m_LoginUpdateTimer

wxTimer* Slic3r::GUI::WebViewPanel::m_LoginUpdateTimer {nullptr}
101{nullptr};

Referenced by WebViewPanel(), ~WebViewPanel(), and OnScriptMessage().

◆ m_reset_on_show

bool Slic3r::GUI::WebViewPanel::m_reset_on_show {false}
private
165{false};

Referenced by WebViewPanel(), and Show().

◆ m_response_js

wxString Slic3r::GUI::WebViewPanel::m_response_js
private

◆ m_script_array

wxMenuItem* Slic3r::GUI::WebViewPanel::m_script_array
private

Referenced by WebViewPanel().

◆ m_script_bool

wxMenuItem* Slic3r::GUI::WebViewPanel::m_script_bool
private

Referenced by WebViewPanel().

◆ m_script_custom

wxMenuItem* Slic3r::GUI::WebViewPanel::m_script_custom
private

Referenced by WebViewPanel().

◆ m_script_date

wxMenuItem* Slic3r::GUI::WebViewPanel::m_script_date
private

Referenced by WebViewPanel().

◆ m_script_dom

wxMenuItem* Slic3r::GUI::WebViewPanel::m_script_dom
private

Referenced by WebViewPanel().

◆ m_script_double

wxMenuItem* Slic3r::GUI::WebViewPanel::m_script_double
private

Referenced by WebViewPanel().

◆ m_script_integer

wxMenuItem* Slic3r::GUI::WebViewPanel::m_script_integer
private

Referenced by WebViewPanel().

◆ m_script_message

wxMenuItem* Slic3r::GUI::WebViewPanel::m_script_message
private

Referenced by WebViewPanel().

◆ m_script_null

wxMenuItem* Slic3r::GUI::WebViewPanel::m_script_null
private

Referenced by WebViewPanel().

◆ m_script_object

wxMenuItem* Slic3r::GUI::WebViewPanel::m_script_object
private

Referenced by WebViewPanel().

◆ m_script_string

wxMenuItem* Slic3r::GUI::WebViewPanel::m_script_string
private

Referenced by WebViewPanel().

◆ m_script_undefined

wxMenuItem* Slic3r::GUI::WebViewPanel::m_script_undefined
private

Referenced by WebViewPanel().

◆ m_selection_clear

wxMenuItem* Slic3r::GUI::WebViewPanel::m_selection_clear
private

Referenced by WebViewPanel(), and OnToolsClicked().

◆ m_selection_delete

wxMenuItem* Slic3r::GUI::WebViewPanel::m_selection_delete
private

Referenced by WebViewPanel(), and OnToolsClicked().

◆ m_tools_handle_navigation

wxMenuItem* Slic3r::GUI::WebViewPanel::m_tools_handle_navigation
private

◆ m_tools_handle_new_window

wxMenuItem* Slic3r::GUI::WebViewPanel::m_tools_handle_new_window
private

Referenced by WebViewPanel(), and OnNewWindow().

◆ m_tools_menu

wxMenu* Slic3r::GUI::WebViewPanel::m_tools_menu
private

◆ m_url

wxTextCtrl* Slic3r::GUI::WebViewPanel::m_url
private

◆ m_zoomFactor

long Slic3r::GUI::WebViewPanel::m_zoomFactor
private

Referenced by WebViewPanel().

◆ s_lazy

Lazy<WebViewPanel>* Slic3r::GUI::LazyInstance< WebViewPanel >::s_lazy
inlinestaticprivateinherited
196{ nullptr };

The documentation for this class was generated from the following files: