mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-16 16:45:55 +08:00
prototype of inner login dialog
This commit is contained in:
parent
0af38e5507
commit
b2e80bd5be
@ -880,12 +880,12 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
|
|||||||
// than open url
|
// than open url
|
||||||
//wxGetApp().open_login_browser_with_dialog(evt.data);
|
//wxGetApp().open_login_browser_with_dialog(evt.data);
|
||||||
|
|
||||||
WebViewDialog dlg(this->q
|
std::string dialog_msg;
|
||||||
, evt.data
|
LoginWebViewDialog dialog(this->q, dialog_msg, evt.data);
|
||||||
, _L("Log in")
|
if (dialog.ShowModal() != wxID_OK) {
|
||||||
, wxSize(std::max(this->q->GetClientSize().x / 2, 100 * wxGetApp().em_unit()), std::max(this->q->GetClientSize().y / 2, 50 * wxGetApp().em_unit()))
|
return;
|
||||||
,{});
|
}
|
||||||
dlg.ShowModal();
|
user_account->on_login_code_recieved(dialog_msg);
|
||||||
});
|
});
|
||||||
|
|
||||||
this->q->Bind(EVT_UA_LOGGEDOUT, [this](UserAccountSuccessEvent& evt) {
|
this->q->Bind(EVT_UA_LOGGEDOUT, [this](UserAccountSuccessEvent& evt) {
|
||||||
|
@ -860,6 +860,7 @@ WebViewDialog::WebViewDialog(wxWindow* parent, const wxString& url, const wxStri
|
|||||||
Bind(wxEVT_MENU, &WebViewDialog::on_run_script_custom, this, m_script_custom->GetId());
|
Bind(wxEVT_MENU, &WebViewDialog::on_run_script_custom, this, m_script_custom->GetId());
|
||||||
Bind(wxEVT_MENU, &WebViewDialog::on_add_user_script, this, addUserScript->GetId());
|
Bind(wxEVT_MENU, &WebViewDialog::on_add_user_script, this, addUserScript->GetId());
|
||||||
#endif
|
#endif
|
||||||
|
Bind(wxEVT_WEBVIEW_NAVIGATING, &WebViewDialog::on_navigation_request, this, m_browser->GetId());
|
||||||
|
|
||||||
Bind(wxEVT_CLOSE_WINDOW, ([this](wxCloseEvent& evt) { EndModal(wxID_CANCEL); }));
|
Bind(wxEVT_CLOSE_WINDOW, ([this](wxCloseEvent& evt) { EndModal(wxID_CANCEL); }));
|
||||||
|
|
||||||
@ -943,6 +944,11 @@ void WebViewDialog::on_reload_button(wxCommandEvent& WXUNUSED(evt))
|
|||||||
m_browser->Reload();
|
m_browser->Reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void WebViewDialog::on_navigation_request(wxWebViewEvent &evt)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void WebViewDialog::on_script_message(wxWebViewEvent& evt)
|
void WebViewDialog::on_script_message(wxWebViewEvent& evt)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -1248,6 +1254,25 @@ void PrinterPickWebViewDialog::request_compatible_printers_SLA()
|
|||||||
wxString script = GUI::format_wxstr("window._prusaConnect_v1.requestCompatiblePrinter(%1%)", request);
|
wxString script = GUI::format_wxstr("window._prusaConnect_v1.requestCompatiblePrinter(%1%)", request);
|
||||||
run_script(script);
|
run_script(script);
|
||||||
}
|
}
|
||||||
|
LoginWebViewDialog::LoginWebViewDialog(wxWindow *parent, std::string &ret_val, const wxString& url)
|
||||||
|
: WebViewDialog(parent
|
||||||
|
, url
|
||||||
|
, _L("Log in dialog")
|
||||||
|
, wxSize(std::max(parent->GetClientSize().x / 2, 100 * wxGetApp().em_unit()), std::max(parent->GetClientSize().y / 2, 50 * wxGetApp().em_unit()))
|
||||||
|
, {})
|
||||||
|
, m_ret_val(ret_val)
|
||||||
|
{
|
||||||
|
Centre();
|
||||||
|
}
|
||||||
|
void LoginWebViewDialog::on_navigation_request(wxWebViewEvent &evt)
|
||||||
|
{
|
||||||
|
BOOST_LOG_TRIVIAL(error) << evt.GetURL();
|
||||||
|
wxString url = evt.GetURL();
|
||||||
|
if (url.starts_with(L"prusaslicer")) {
|
||||||
|
evt.Veto();
|
||||||
|
m_ret_val = into_u8(url);
|
||||||
|
EndModal(wxID_OK);
|
||||||
|
}
|
||||||
|
}
|
||||||
} // GUI
|
} // GUI
|
||||||
} // Slic3r
|
} // Slic3r
|
||||||
|
@ -128,6 +128,8 @@ public:
|
|||||||
void On_enable_context_menu(wxCommandEvent& evt);
|
void On_enable_context_menu(wxCommandEvent& evt);
|
||||||
void On_enable_dev_tools(wxCommandEvent& evt);
|
void On_enable_dev_tools(wxCommandEvent& evt);
|
||||||
|
|
||||||
|
virtual void on_navigation_request(wxWebViewEvent &evt);
|
||||||
|
|
||||||
void run_script(const wxString& javascript);
|
void run_script(const wxString& javascript);
|
||||||
|
|
||||||
void load_error_page();
|
void load_error_page();
|
||||||
@ -247,6 +249,15 @@ public:
|
|||||||
SourceViewDialog(wxWindow* parent, wxString source);
|
SourceViewDialog(wxWindow* parent, wxString source);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class LoginWebViewDialog : public WebViewDialog
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LoginWebViewDialog(wxWindow *parent, std::string &ret_val, const wxString& url);
|
||||||
|
void on_navigation_request(wxWebViewEvent &evt) override;
|
||||||
|
private:
|
||||||
|
std::string &m_ret_val;
|
||||||
|
};
|
||||||
|
|
||||||
} // GUI
|
} // GUI
|
||||||
} // Slic3r
|
} // Slic3r
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user