mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-15 21:05:57 +08:00
prototype of inner login dialog
This commit is contained in:
parent
0af38e5507
commit
b2e80bd5be
@ -869,24 +869,24 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
|
||||
user_account->on_login_code_recieved(evt.data);
|
||||
});
|
||||
this->q->Bind(EVT_OPEN_PRUSAAUTH, [this](OpenPrusaAuthEvent& evt) {
|
||||
BOOST_LOG_TRIVIAL(info) << "open browser: " << evt.data;
|
||||
// first register url to be sure to get the code back
|
||||
//auto downloader_worker = new DownloaderUtils::Worker(nullptr);
|
||||
DownloaderUtils::Worker::perform_register(wxGetApp().app_config->get("url_downloader_dest"));
|
||||
BOOST_LOG_TRIVIAL(info) << "open browser: " << evt.data;
|
||||
// first register url to be sure to get the code back
|
||||
//auto downloader_worker = new DownloaderUtils::Worker(nullptr);
|
||||
DownloaderUtils::Worker::perform_register(wxGetApp().app_config->get("url_downloader_dest"));
|
||||
#ifdef __linux__
|
||||
if (DownloaderUtils::Worker::perform_registration_linux)
|
||||
DesktopIntegrationDialog::perform_downloader_desktop_integration();
|
||||
#endif // __linux__
|
||||
// than open url
|
||||
//wxGetApp().open_login_browser_with_dialog(evt.data);
|
||||
if (DownloaderUtils::Worker::perform_registration_linux)
|
||||
DesktopIntegrationDialog::perform_downloader_desktop_integration();
|
||||
#endif // __linux__
|
||||
// than open url
|
||||
//wxGetApp().open_login_browser_with_dialog(evt.data);
|
||||
|
||||
WebViewDialog dlg(this->q
|
||||
, evt.data
|
||||
, _L("Log in")
|
||||
, wxSize(std::max(this->q->GetClientSize().x / 2, 100 * wxGetApp().em_unit()), std::max(this->q->GetClientSize().y / 2, 50 * wxGetApp().em_unit()))
|
||||
,{});
|
||||
dlg.ShowModal();
|
||||
});
|
||||
std::string dialog_msg;
|
||||
LoginWebViewDialog dialog(this->q, dialog_msg, evt.data);
|
||||
if (dialog.ShowModal() != wxID_OK) {
|
||||
return;
|
||||
}
|
||||
user_account->on_login_code_recieved(dialog_msg);
|
||||
});
|
||||
|
||||
this->q->Bind(EVT_UA_LOGGEDOUT, [this](UserAccountSuccessEvent& evt) {
|
||||
user_account->clear();
|
||||
|
@ -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_add_user_script, this, addUserScript->GetId());
|
||||
#endif
|
||||
Bind(wxEVT_WEBVIEW_NAVIGATING, &WebViewDialog::on_navigation_request, this, m_browser->GetId());
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
void WebViewDialog::on_navigation_request(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);
|
||||
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
|
||||
} // Slic3r
|
||||
|
@ -127,6 +127,8 @@ 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);
|
||||
|
||||
void run_script(const wxString& javascript);
|
||||
|
||||
@ -247,6 +249,15 @@ public:
|
||||
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
|
||||
} // Slic3r
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user